@ciridae/ui 2.80.0 → 2.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -39,6 +39,12 @@ export type CheckboxListProps = {
|
|
|
39
39
|
searchFrom?: number;
|
|
40
40
|
/** Select all and Clear for the items shown, beside how many of all of them are ticked. */
|
|
41
41
|
bulkActions?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The app's own actions on the ticked items, such as saving them as a preset, drawn with
|
|
44
|
+
* `bulkActions` after Select all and Clear. Keep a control here whatever is ticked, disabled
|
|
45
|
+
* when it does not apply, so the row does not shift as items are ticked.
|
|
46
|
+
*/
|
|
47
|
+
actions?: ReactNode;
|
|
42
48
|
labels?: Partial<CiridaeLabels["checklist"]>;
|
|
43
49
|
};
|
|
44
50
|
/**
|
|
@@ -111,7 +111,7 @@ function matchesSearch(item, search) {
|
|
|
111
111
|
const fields = item.searchText ?? (typeof item.label === "string" ? [item.label] : []);
|
|
112
112
|
return fields.some((field) => field?.toLocaleLowerCase().includes(needle));
|
|
113
113
|
}
|
|
114
|
-
function SearchableCheckboxes({ items, emptyMessage, selectedKeys, onChange, disabled, searchFrom, bulkActions: offerBulkActions = false, labels: ownLabels, }) {
|
|
114
|
+
function SearchableCheckboxes({ items, emptyMessage, selectedKeys, onChange, disabled, searchFrom, bulkActions: offerBulkActions = false, actions, labels: ownLabels, }) {
|
|
115
115
|
const labels = { ...useCiridaeLocale().labels.checklist, ...ownLabels };
|
|
116
116
|
const [search, setSearch] = useState("");
|
|
117
117
|
const searching = search.trim() !== "";
|
|
@@ -137,7 +137,7 @@ function SearchableCheckboxes({ items, emptyMessage, selectedKeys, onChange, dis
|
|
|
137
137
|
onKeyDown: (event) => {
|
|
138
138
|
if (event.key === "Enter")
|
|
139
139
|
event.preventDefault();
|
|
140
|
-
} })), offerBulkActions && (_jsxs("div", { className: toolbarActions, children: [_jsxs("div", { className: bulkActions, role: "group", "aria-label": labels.bulkActions, children: [_jsx(Button, { variant: "secondary", size: "small", focusableWhenDisabled: true, disabled: disabled || shownKeys.every((key) => selectedKeys.has(key)), onClick: () => setShown(true), children: searching ? labels.selectMatches : labels.selectAll }), _jsx(Button, { variant: "secondary", size: "small", focusableWhenDisabled: true, disabled: disabled || !shownKeys.some((key) => selectedKeys.has(key)), onClick: () => setShown(false), children: searching ? labels.clearMatches : labels.clear })] }), _jsx("span", { className: selectedCount, "aria-live": "polite", children: labels.selectedCount(items.filter((item) => selectedKeys.has(item.key)).length, items.length) })] }))] }), listed] }));
|
|
140
|
+
} })), offerBulkActions && (_jsxs("div", { className: toolbarActions, children: [_jsxs("div", { className: bulkActions, role: "group", "aria-label": labels.bulkActions, children: [_jsx(Button, { variant: "secondary", size: "small", focusableWhenDisabled: true, disabled: disabled || shownKeys.every((key) => selectedKeys.has(key)), onClick: () => setShown(true), children: searching ? labels.selectMatches : labels.selectAll }), _jsx(Button, { variant: "secondary", size: "small", focusableWhenDisabled: true, disabled: disabled || !shownKeys.some((key) => selectedKeys.has(key)), onClick: () => setShown(false), children: searching ? labels.clearMatches : labels.clear })] }), actions, _jsx("span", { className: selectedCount, "aria-live": "polite", children: labels.selectedCount(items.filter((item) => selectedKeys.has(item.key)).length, items.length) })] }))] }), listed] }));
|
|
141
141
|
}
|
|
142
142
|
function ListedCheckboxes({ items, selectedKeys, onChange, disabled, labels, }) {
|
|
143
143
|
const toggle = (keys, checked) => {
|