mirror of
https://github.com/outline/outline.git
synced 2026-11-21 05:24:03 +03:00
* feat: Multi-select in the users settings table Adds multi-selection to the base settings table — a table opts in by supplying `isRowSelectable` and a `selectionToolbar`, reusing the model selection and toolbar infrastructure built for document lists. User actions are updated to the context based format so the same definitions drive the row menu and the bulk toolbar. * feat: Multi-select in the groups settings table Group deletion now operates on every active group so it can be performed from the bulk selection toolbar as well as the row menu. * feat: Multi-select in the group members settings table Group member removal and permission changes now operate on every active user, so they can be performed from the bulk selection toolbar as well as the row menu. * fix: Table selection styling feedback Lighten the selected row tint and drop the opaque background from the sticky actions cell so the row shows through. The selection checkbox is positioned absolutely so it centers in the row without influencing the cell's inline layout. * fix: Bleed the selected table row highlight past the table edges The highlight is drawn on a pseudo element behind the cells so it can extend 8px either side of the table and be rounded. * fix: Join the highlight of adjacent selected table rows Square off the corners between neighbouring selected rows so a run of them reads as one rounded block. * tweaks * Add new icons, styling tweaks * fix: Make the base key of new count strings singular i18next resolves the base key for count=1, which happens on a partial batch success, so the singular form belongs there and the plural in the _plural value.
93 lines
2.3 KiB
TypeScript
93 lines
2.3 KiB
TypeScript
import { CheckmarkIcon } from "outline-icons";
|
|
import * as React from "react";
|
|
import styled, { css } from "styled-components";
|
|
import { hover, s } from "@shared/styles";
|
|
import NudeButton from "~/components/NudeButton";
|
|
|
|
type Props = {
|
|
/** Whether the item, or every item in the list, is selected. */
|
|
checked: boolean;
|
|
/** Whether only some of the items in the list are selected. */
|
|
indeterminate?: boolean;
|
|
/** The accessible label for the checkbox. */
|
|
label: string;
|
|
/** Called when the checkbox is clicked, the event carries any modifier keys. */
|
|
onClick: (event: React.MouseEvent) => void;
|
|
className?: string;
|
|
};
|
|
|
|
/**
|
|
* A checkbox used to add an item, or every item in a list, to a multi-selection.
|
|
* It is positioned absolutely, vertically centered within the nearest
|
|
* positioned ancestor.
|
|
*
|
|
* @param props The component props.
|
|
* @returns the checkbox element.
|
|
*/
|
|
export function SelectionCheckbox({
|
|
checked,
|
|
indeterminate,
|
|
label,
|
|
onClick,
|
|
className,
|
|
}: Props) {
|
|
// Suppress the browser's text selection when shift-clicking a range.
|
|
const handleMouseDown = (event: React.MouseEvent) => {
|
|
if (event.shiftKey) {
|
|
event.preventDefault();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Checkbox
|
|
role="checkbox"
|
|
aria-checked={indeterminate ? "mixed" : checked}
|
|
aria-label={label}
|
|
className={className}
|
|
$checked={checked || !!indeterminate}
|
|
onClick={onClick}
|
|
onMouseDown={handleMouseDown}
|
|
>
|
|
{checked ? <CheckmarkIcon size={16} /> : indeterminate ? <Dash /> : null}
|
|
</Checkbox>
|
|
);
|
|
}
|
|
|
|
const Checkbox = styled(NudeButton)<{ $checked: boolean }>`
|
|
position: absolute;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
width: 18px;
|
|
height: 18px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 4px;
|
|
border: 2px solid ${s("inputBorder")};
|
|
color: ${(props) => props.theme.accentText};
|
|
opacity: 0.75;
|
|
transition:
|
|
opacity 100ms ease,
|
|
background 100ms ease,
|
|
border-color 100ms ease;
|
|
|
|
&: ${hover} {
|
|
opacity: 1;
|
|
}
|
|
|
|
${(props) =>
|
|
props.$checked &&
|
|
css`
|
|
background: ${props.theme.accent};
|
|
border-color: ${props.theme.accent};
|
|
opacity: 1;
|
|
`}
|
|
`;
|
|
|
|
const Dash = styled.span`
|
|
width: 8px;
|
|
height: 2px;
|
|
border-radius: 1px;
|
|
background: currentColor;
|
|
`;
|