@scattered-light/loomiere-base-ui 0.18.0 → 0.20.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.
- package/README.md +13 -3
- package/dist/{chunk-M7KJASGK.js → chunk-43IJNNXK.js} +86 -3
- package/dist/chunk-43IJNNXK.js.map +1 -0
- package/dist/{chunk-2BFNETZZ.js → chunk-B5FH3RF5.js} +33 -15
- package/dist/chunk-B5FH3RF5.js.map +1 -0
- package/dist/chunk-Z6SR3KMB.js +77 -0
- package/dist/chunk-Z6SR3KMB.js.map +1 -0
- package/dist/custom/collection/index.d.ts +55 -2
- package/dist/custom/collection/index.js +89 -5
- package/dist/custom/collection/index.js.map +1 -1
- package/dist/custom/index.d.ts +1 -1
- package/dist/custom/index.js +2 -2
- package/dist/design-system/components/CollectionCards/README.md +58 -0
- package/dist/design-system/components/CollectionCards/preview.html +19 -0
- package/dist/design-system/components/CollectionToolbar/README.md +3 -1
- package/dist/design-system/components/PickerButton/README.md +1 -1
- package/dist/design-system/components/SplitButton/README.md +26 -0
- package/dist/design-system/components/SplitButton/preview.html +19 -0
- package/dist/design-system/components/StatCard/README.md +4 -1
- package/dist/design-system/components/StatCard/preview.html +1 -1
- package/dist/design-system/components/bundle.js +7 -7
- package/dist/design-system/components/index.d.ts +1 -1
- package/dist/design-system/components/styles.css +202 -66
- package/dist/{index-ywBkS0AA.d.ts → index-CB3_OECu.d.ts} +35 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -18
- package/dist/index.js.map +1 -1
- package/dist/styles/components/Accordion.css +1 -1
- package/dist/styles/components/AlertDialog.css +1 -1
- package/dist/styles/components/Autocomplete.css +1 -1
- package/dist/styles/components/Avatar.css +1 -1
- package/dist/styles/components/Button.css +1 -1
- package/dist/styles/components/Checkbox.css +1 -1
- package/dist/styles/components/CheckboxGroup.css +1 -1
- package/dist/styles/components/Collapsible.css +1 -1
- package/dist/styles/components/Combobox.css +1 -1
- package/dist/styles/components/ContextMenu.css +1 -1
- package/dist/styles/components/Dialog.css +1 -1
- package/dist/styles/components/Drawer.css +1 -1
- package/dist/styles/components/Field.css +1 -1
- package/dist/styles/components/Fieldset.css +1 -1
- package/dist/styles/components/Form.css +1 -1
- package/dist/styles/components/Input.css +1 -1
- package/dist/styles/components/Menu.css +1 -1
- package/dist/styles/components/Menubar.css +1 -1
- package/dist/styles/components/Meter.css +1 -1
- package/dist/styles/components/NavigationMenu.css +1 -1
- package/dist/styles/components/NumberField.css +1 -1
- package/dist/styles/components/OTPField.css +1 -1
- package/dist/styles/components/Popover.css +1 -1
- package/dist/styles/components/PreviewCard.css +1 -1
- package/dist/styles/components/Progress.css +1 -1
- package/dist/styles/components/Radio.css +1 -1
- package/dist/styles/components/ScrollArea.css +1 -1
- package/dist/styles/components/Select.css +1 -1
- package/dist/styles/components/Separator.css +1 -1
- package/dist/styles/components/Slider.css +1 -1
- package/dist/styles/components/Switch.css +1 -1
- package/dist/styles/components/Tabs.css +1 -1
- package/dist/styles/components/Toast.css +1 -1
- package/dist/styles/components/Toggle.css +1 -1
- package/dist/styles/components/ToggleGroup.css +1 -1
- package/dist/styles/components/Toolbar.css +1 -1
- package/dist/styles/components/Tooltip.css +1 -1
- package/dist/styles/custom/AppBar.css +1 -1
- package/dist/styles/custom/Badge.css +1 -1
- package/dist/styles/custom/Collection.css +2 -1
- package/dist/styles/custom/CollectionCards.css +24 -0
- package/dist/styles/custom/CollectionPagination.css +1 -1
- package/dist/styles/custom/CollectionToolbar.css +47 -1
- package/dist/styles/custom/DataList.css +1 -1
- package/dist/styles/custom/DataTable.css +1 -1
- package/dist/styles/custom/DatePicker.css +1 -1
- package/dist/styles/custom/DescriptionList.css +1 -1
- package/dist/styles/custom/EditableList.css +1 -1
- package/dist/styles/custom/EmptyState.css +1 -1
- package/dist/styles/custom/ListDetail.css +1 -1
- package/dist/styles/custom/MoneyField.css +1 -1
- package/dist/styles/custom/PickerButton.css +4 -4
- package/dist/styles/custom/PickerSplit.css +2 -2
- package/dist/styles/custom/Sheet.css +1 -1
- package/dist/styles/custom/SideNav.css +1 -1
- package/dist/styles/custom/SplitButton.css +21 -0
- package/dist/styles/custom/Splitter.css +1 -1
- package/dist/styles/custom/StatCard.css +44 -1
- package/dist/styles/custom/StatFigure.css +1 -1
- package/dist/styles/custom/Table.css +1 -1
- package/dist/styles/index.css +2 -1
- package/dist/styles/reset/accessibility.css +1 -1
- package/dist/styles/reset/reset-accessibility.css +1 -1
- package/dist/styles/reset/reset-tailwind.css +1 -1
- package/dist/styles/reset/reset.css +1 -1
- package/dist/styles/tailwind.css +2 -1
- package/package.json +2 -2
- package/dist/chunk-2BFNETZZ.js.map +0 -1
- package/dist/chunk-M7KJASGK.js.map +0 -1
- package/dist/chunk-Y2CPBMFJ.js +0 -147
- package/dist/chunk-Y2CPBMFJ.js.map +0 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { cnState, styledPart, styledPartUnless, cn } from './chunk-43IJNNXK.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Input as Input$1 } from '@base-ui/react/input';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
import { Checkbox as Checkbox$1 } from '@base-ui/react/checkbox';
|
|
6
|
+
import { Toggle as Toggle$1 } from '@base-ui/react/toggle';
|
|
7
|
+
import { ToggleGroup as ToggleGroup$1 } from '@base-ui/react/toggle-group';
|
|
8
|
+
import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
|
|
9
|
+
|
|
10
|
+
var Input = React.forwardRef(function Input2({ className, ...props }, ref) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Input$1, { ref, ...props, className: (state) => cnState("Input", className, state) });
|
|
12
|
+
});
|
|
13
|
+
Input.displayName = "Input";
|
|
14
|
+
var Root = styledPart(
|
|
15
|
+
Checkbox$1.Root,
|
|
16
|
+
"CheckboxRoot",
|
|
17
|
+
"CheckboxRoot"
|
|
18
|
+
);
|
|
19
|
+
var Indicator = styledPart(
|
|
20
|
+
Checkbox$1.Indicator,
|
|
21
|
+
"CheckboxIndicator",
|
|
22
|
+
"CheckboxIndicator"
|
|
23
|
+
);
|
|
24
|
+
function CheckboxLabel({ className, ...props }) {
|
|
25
|
+
return (
|
|
26
|
+
// The checkbox is a child of this label, which is what associates them.
|
|
27
|
+
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
28
|
+
/* @__PURE__ */ jsx("label", { className: cn("CheckboxLabel", className), ...props })
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
var Checkbox = {
|
|
32
|
+
Root,
|
|
33
|
+
Indicator,
|
|
34
|
+
Label: CheckboxLabel
|
|
35
|
+
};
|
|
36
|
+
var Toggle = styledPart(
|
|
37
|
+
Toggle$1,
|
|
38
|
+
"Toggle",
|
|
39
|
+
"Toggle"
|
|
40
|
+
);
|
|
41
|
+
var ToggleGroup = styledPartUnless(
|
|
42
|
+
ToggleGroup$1,
|
|
43
|
+
"ToggleGroup",
|
|
44
|
+
"ToggleGroup",
|
|
45
|
+
"ToolbarGroup"
|
|
46
|
+
);
|
|
47
|
+
var Root2 = styledPart(
|
|
48
|
+
Tabs$1.Root,
|
|
49
|
+
"TabsRoot",
|
|
50
|
+
"TabsRoot"
|
|
51
|
+
);
|
|
52
|
+
var List = styledPart(
|
|
53
|
+
Tabs$1.List,
|
|
54
|
+
"TabsList",
|
|
55
|
+
"TabsList"
|
|
56
|
+
);
|
|
57
|
+
var Tab = styledPart(
|
|
58
|
+
Tabs$1.Tab,
|
|
59
|
+
"TabsTab",
|
|
60
|
+
"TabsTab"
|
|
61
|
+
);
|
|
62
|
+
var Panel = styledPart(
|
|
63
|
+
Tabs$1.Panel,
|
|
64
|
+
"TabsPanel",
|
|
65
|
+
"TabsPanel"
|
|
66
|
+
);
|
|
67
|
+
var Tabs = {
|
|
68
|
+
Root: Root2,
|
|
69
|
+
List,
|
|
70
|
+
Tab,
|
|
71
|
+
Panel,
|
|
72
|
+
Indicator: Tabs$1.Indicator
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { Checkbox, CheckboxLabel, Input, Tabs, Toggle, ToggleGroup };
|
|
76
|
+
//# sourceMappingURL=chunk-Z6SR3KMB.js.map
|
|
77
|
+
//# sourceMappingURL=chunk-Z6SR3KMB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/input.tsx","../src/components/checkbox.tsx","../src/components/toggle.tsx","../src/components/toggle-group.tsx","../src/components/tabs.tsx"],"names":["Input","BaseInput","BaseCheckbox","jsx","BaseToggle","BaseToggleGroup","Root","BaseTabs"],"mappings":";;;;;;;;;AAUO,IAAM,KAAA,GAAc,iBAAyC,SAASA,MAAAA,CAC3E,EAAE,SAAA,EAAW,GAAG,KAAA,EAAM,EACtB,GAAA,EACA;AACA,EAAA,uBACE,GAAA,CAACC,OAAA,EAAA,EAAU,GAAA,EAAW,GAAG,KAAA,EAAO,SAAA,EAAW,CAAC,KAAA,KAAU,OAAA,CAAQ,OAAA,EAAS,SAAA,EAAW,KAAK,CAAA,EAAG,CAAA;AAE9F,CAAC;AAED,KAAA,CAAM,WAAA,GAAc,OAAA;ACdpB,IAAM,IAAA,GAAO,UAAA;AAAA,EACXC,UAAA,CAAa,IAAA;AAAA,EACb,cAAA;AAAA,EACA;AACF,CAAA;AACA,IAAM,SAAA,GAAY,UAAA;AAAA,EAChBA,UAAA,CAAa,SAAA;AAAA,EACb,mBAAA;AAAA,EACA;AACF,CAAA;AAKO,SAAS,aAAA,CAAc,EAAE,SAAA,EAAW,GAAG,OAAM,EAAuB;AACzE,EAAA;AAAA;AAAA;AAAA,oBAGEC,IAAC,OAAA,EAAA,EAAM,SAAA,EAAW,GAAG,eAAA,EAAiB,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO;AAAA;AAEjE;AAMO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA,EAAO;AACT;AC1BO,IAAM,MAAA,GAAS,UAAA;AAAA,EACpBC,QAAA;AAAA,EAGA,QAAA;AAAA,EACA;AACF;ACNO,IAAM,WAAA,GAAc,gBAAA;AAAA,EACzBC,aAAA;AAAA,EAGA,aAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF;ACZA,IAAMC,KAAAA,GAAO,UAAA;AAAA,EACXC,MAAA,CAAS,IAAA;AAAA,EACT,UAAA;AAAA,EACA;AACF,CAAA;AACA,IAAM,IAAA,GAAO,UAAA;AAAA,EACXA,MAAA,CAAS,IAAA;AAAA,EACT,UAAA;AAAA,EACA;AACF,CAAA;AACA,IAAM,GAAA,GAAM,UAAA;AAAA,EACVA,MAAA,CAAS,GAAA;AAAA,EACT,SAAA;AAAA,EACA;AACF,CAAA;AACA,IAAM,KAAA,GAAQ,UAAA;AAAA,EACZA,MAAA,CAAS,KAAA;AAAA,EACT,WAAA;AAAA,EACA;AACF,CAAA;AAMO,IAAM,IAAA,GAAO;AAAA,EAClB,IAAA,EAAAD,KAAAA;AAAA,EACA,IAAA;AAAA,EACA,GAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAWC,MAAA,CAAS;AACtB","file":"chunk-Z6SR3KMB.js","sourcesContent":["import * as React from 'react';\nimport { Input as BaseInput } from '@base-ui/react/input';\nimport { cnState } from '../utils/cn';\n\nexport type InputProps = React.ComponentProps<typeof BaseInput>;\n\n/**\n * Base UI [Input](https://base-ui.com/react/components/input) with design-system `Input` classes.\n * Pairs with {@link Field} for labels, validation, and descriptions.\n */\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n { className, ...props },\n ref,\n) {\n return (\n <BaseInput ref={ref} {...props} className={(state) => cnState('Input', className, state)} />\n );\n});\n\nInput.displayName = 'Input';\n","import * as React from 'react';\nimport { Checkbox as BaseCheckbox } from '@base-ui/react/checkbox';\nimport { cn } from '../utils/cn';\nimport { styledPart } from '../utils/styled-part';\n\nconst Root = styledPart<HTMLElement, React.ComponentProps<typeof BaseCheckbox.Root>>(\n BaseCheckbox.Root,\n 'CheckboxRoot',\n 'CheckboxRoot',\n);\nconst Indicator = styledPart<HTMLSpanElement, React.ComponentProps<typeof BaseCheckbox.Indicator>>(\n BaseCheckbox.Indicator,\n 'CheckboxIndicator',\n 'CheckboxIndicator',\n);\n\nexport type CheckboxLabelProps = React.ComponentProps<'label'>;\n\n/** The row around a checkbox. The control sits inside the label, so it needs no htmlFor. */\nexport function CheckboxLabel({ className, ...props }: CheckboxLabelProps) {\n return (\n // The checkbox is a child of this label, which is what associates them.\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label className={cn('CheckboxLabel', className)} {...props} />\n );\n}\n\n/**\n * Base UI [Checkbox](https://base-ui.com/react/components/checkbox) with design-system classes.\n * The mark icon stays yours: give it `className=\"CheckboxIcon\"`.\n */\nexport const Checkbox = {\n Root,\n Indicator,\n Label: CheckboxLabel,\n};\n","import * as React from 'react';\nimport { Toggle as BaseToggle } from '@base-ui/react/toggle';\nimport { styledPart } from '../utils/styled-part';\n\n/**\n * Base UI [Toggle](https://base-ui.com/react/components/toggle) with design-system classes.\n * Same height, padding, and trigger text as a Button of the same size. Pressed takes the\n * emphasis level (standard unless `data-emphasis` says otherwise).\n */\nexport const Toggle = styledPart<HTMLButtonElement, React.ComponentProps<typeof BaseToggle>>(\n BaseToggle as React.ComponentType<\n React.ComponentProps<typeof BaseToggle> & React.RefAttributes<HTMLButtonElement>\n >,\n 'Toggle',\n 'Toggle',\n);\n","import * as React from 'react';\nimport { ToggleGroup as BaseToggleGroup } from '@base-ui/react/toggle-group';\nimport { styledPartUnless } from '../utils/styled-part';\n\n/**\n * Base UI [Toggle Group](https://base-ui.com/react/components/toggle-group) with design-system classes.\n * The strip is a bar. Each child is a {@link Toggle}, with item corners so it nests in the strip.\n * A group inside a toolbar passes `className=\"ToolbarGroup\"` and does not also become a strip.\n */\nexport const ToggleGroup = styledPartUnless<HTMLDivElement, React.ComponentProps<typeof BaseToggleGroup>>(\n BaseToggleGroup as React.ComponentType<\n React.ComponentProps<typeof BaseToggleGroup> & React.RefAttributes<HTMLDivElement>\n >,\n 'ToggleGroup',\n 'ToggleGroup',\n 'ToolbarGroup',\n) as unknown as typeof BaseToggleGroup; // keeps Base UI's generic value type\n","import * as React from 'react';\nimport { Tabs as BaseTabs } from '@base-ui/react/tabs';\nimport { styledPart } from '../utils/styled-part';\n\nconst Root = styledPart<HTMLDivElement, React.ComponentProps<typeof BaseTabs.Root>>(\n BaseTabs.Root,\n 'TabsRoot',\n 'TabsRoot',\n);\nconst List = styledPart<HTMLDivElement, React.ComponentProps<typeof BaseTabs.List>>(\n BaseTabs.List,\n 'TabsList',\n 'TabsList',\n);\nconst Tab = styledPart<HTMLElement, React.ComponentProps<typeof BaseTabs.Tab>>(\n BaseTabs.Tab,\n 'TabsTab',\n 'TabsTab',\n);\nconst Panel = styledPart<HTMLDivElement, React.ComponentProps<typeof BaseTabs.Panel>>(\n BaseTabs.Panel,\n 'TabsPanel',\n 'TabsPanel',\n);\n\n/**\n * Base UI [Tabs](https://base-ui.com/react/components/tabs) with design-system classes.\n * `data-size` and `data-orientation` go on the root.\n */\nexport const Tabs = {\n Root,\n List,\n Tab,\n Panel,\n Indicator: BaseTabs.Indicator,\n};\n"]}
|
|
@@ -477,6 +477,24 @@ interface DataTableTotalRow<T = unknown> {
|
|
|
477
477
|
*/
|
|
478
478
|
declare function DataTable<T>({ collection, label, caption, onRowActivate, getRowHref, activeRowId, rowActions, empty, loading, stickyHeader, stickyRowHeader, narrow, size, totalStyle, totalRows, treeLines, headerStyle, figures, disclosure, getRowKind, rowNavigation, className, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
479
479
|
|
|
480
|
+
interface CollectionCardsProps<T> {
|
|
481
|
+
collection: CollectionApi<T>;
|
|
482
|
+
/** Names the list for screen readers: "Entities". */
|
|
483
|
+
label: string;
|
|
484
|
+
/** One card for a row, such as a StatCard. */
|
|
485
|
+
renderCard: (row: T) => React.ReactNode;
|
|
486
|
+
/** Shown when the data itself is empty. A search with no matches uses the built-in no-results state. */
|
|
487
|
+
empty?: React.ReactNode;
|
|
488
|
+
loading?: boolean;
|
|
489
|
+
className?: string;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* The rows of a collection as a grid of cards, for a page that lists things such as Entities or
|
|
493
|
+
* accounts. Search, filter, sort and paging come from the same collection the table and list use,
|
|
494
|
+
* so CollectionToolbar and CollectionPagination work with it unchanged. It shows the current page.
|
|
495
|
+
*/
|
|
496
|
+
declare function CollectionCards<T>({ collection, label, renderCard, empty, loading, className }: CollectionCardsProps<T>): react_jsx_runtime.JSX.Element;
|
|
497
|
+
|
|
480
498
|
interface CollectionPaginationProps {
|
|
481
499
|
/** 1-based. */
|
|
482
500
|
page: number;
|
|
@@ -500,6 +518,22 @@ interface CollectionPaginationProps {
|
|
|
500
518
|
*/
|
|
501
519
|
declare function CollectionPagination({ page, pageCount, pageSize, total, filtered, onPageChange, onPageSizeChange, pageSizeOptions, label, previousLabel, nextLabel, rowsPerPageLabel, className, }: CollectionPaginationProps): react_jsx_runtime.JSX.Element;
|
|
502
520
|
|
|
521
|
+
/** One segmented group in the toolbar: a quick filter, a sort or a grouping, as a row of toggles. */
|
|
522
|
+
interface ToolbarSegment {
|
|
523
|
+
/** Names the group for screen readers and, with `showLabel`, sits before it. */
|
|
524
|
+
label: string;
|
|
525
|
+
showLabel?: boolean;
|
|
526
|
+
value: string;
|
|
527
|
+
onChange: (value: string) => void;
|
|
528
|
+
/** `count` reads "All (12)" in the toggle. */
|
|
529
|
+
options: Array<{
|
|
530
|
+
value: string;
|
|
531
|
+
label: string;
|
|
532
|
+
count?: number;
|
|
533
|
+
}>;
|
|
534
|
+
/** Pushes this group, and the ones after it, to the far end of the row. */
|
|
535
|
+
end?: boolean;
|
|
536
|
+
}
|
|
503
537
|
interface CollectionToolbarProps<T> {
|
|
504
538
|
collection: CollectionApi<T>;
|
|
505
539
|
/** Required when any column is searchable. */
|
|
@@ -524,13 +558,21 @@ interface CollectionToolbarProps<T> {
|
|
|
524
558
|
metaEnd?: React.ReactNode;
|
|
525
559
|
/** Pads the toolbar and rules it from the table below, for a toolbar inside a Sheet above an edge-to-edge table. */
|
|
526
560
|
framed?: boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Segmented toggle groups for quick filters, sort and grouping. When set, the toolbar is one row:
|
|
563
|
+
* search, then the groups, then `meta`. Tabs, trailing selects and the sort select are not drawn.
|
|
564
|
+
* Build the groups with `segmentFilter` and `segmentSort`.
|
|
565
|
+
*/
|
|
566
|
+
segments?: ToolbarSegment[];
|
|
567
|
+
/** Rules the toolbar from the content above it with the sheet rule. For directory pages. */
|
|
568
|
+
ruled?: boolean;
|
|
527
569
|
className?: string;
|
|
528
570
|
}
|
|
529
571
|
/**
|
|
530
572
|
* Tabs and search stay put while rows are selected. The trailing controls swap for the
|
|
531
573
|
* selection bar, so the bar takes their place and the row does not grow.
|
|
532
574
|
*/
|
|
533
|
-
declare function CollectionToolbarImpl<T>({ collection, searchLabel, searchLabelVisible, searchPlaceholder, showSort, groupOptions, actions, bulkActions, searchWidth, meta, metaEnd, framed, className }: CollectionToolbarProps<T>): react_jsx_runtime.JSX.Element;
|
|
575
|
+
declare function CollectionToolbarImpl<T>({ collection, searchLabel, searchLabelVisible, searchPlaceholder, showSort, groupOptions, actions, bulkActions, searchWidth, meta, metaEnd, framed, segments, ruled, className }: CollectionToolbarProps<T>): react_jsx_runtime.JSX.Element;
|
|
534
576
|
declare function ToolbarTabs<T>({ collection, column }: {
|
|
535
577
|
collection: CollectionApi<T>;
|
|
536
578
|
column: CollectionColumn<T>;
|
|
@@ -554,6 +596,17 @@ declare function FilterControl<T>({ collection, column }: {
|
|
|
554
596
|
declare function SortControl<T>({ collection }: {
|
|
555
597
|
collection: CollectionApi<T>;
|
|
556
598
|
}): react_jsx_runtime.JSX.Element;
|
|
599
|
+
/** A segmented quick filter on a column: "All (12)", "Open items (4)". Include an `all` option to clear it. */
|
|
600
|
+
declare function segmentFilter<T>(collection: CollectionApi<T>, columnId: string, label: string, options: Array<{
|
|
601
|
+
value: string;
|
|
602
|
+
label: string;
|
|
603
|
+
}>): ToolbarSegment;
|
|
604
|
+
/** A segmented sort: each option names a column and a direction. */
|
|
605
|
+
declare function segmentSort<T>(collection: CollectionApi<T>, label: string, options: Array<{
|
|
606
|
+
value: string;
|
|
607
|
+
label: string;
|
|
608
|
+
desc?: boolean;
|
|
609
|
+
}>): ToolbarSegment;
|
|
557
610
|
declare function ToolbarClear<T>({ collection }: {
|
|
558
611
|
collection: CollectionApi<T>;
|
|
559
612
|
}): react_jsx_runtime.JSX.Element | null;
|
|
@@ -586,4 +639,4 @@ declare const CollectionToolbar: typeof CollectionToolbarImpl & {
|
|
|
586
639
|
*/
|
|
587
640
|
declare function totalText<T>(column: CollectionColumn<T>, rows: readonly T[], locale: string): string;
|
|
588
641
|
|
|
589
|
-
export { type CellContext, type CollectionAlign, type CollectionApi, type CollectionColumn, type CollectionFilter, type CollectionKind, CollectionPagination, type CollectionPaginationProps, type CollectionSort, CollectionToolbar, type CollectionToolbarProps, DataList, type DataListProps, DataTable, type DataTableProps, type DataTableTotalRow, type FilterKind, type FilterOption, type ListSlot, type UseCollectionOptions, balanceOf, collectionTableOptions, compareDecimal, countFacets, defineColumns, formatDate, formatMoney, headerLabel, hiddenSelectedCount, nextSort, pageBounds, pageFlat, searchMatches, selectableIds, sortRows, sumMoney, toMinor, totalText, treeVisibleIds, useCollection };
|
|
642
|
+
export { type CellContext, type CollectionAlign, type CollectionApi, CollectionCards, type CollectionCardsProps, type CollectionColumn, type CollectionFilter, type CollectionKind, CollectionPagination, type CollectionPaginationProps, type CollectionSort, CollectionToolbar, type CollectionToolbarProps, DataList, type DataListProps, DataTable, type DataTableProps, type DataTableTotalRow, type FilterKind, type FilterOption, type ListSlot, type ToolbarSegment, type UseCollectionOptions, balanceOf, collectionTableOptions, compareDecimal, countFacets, defineColumns, formatDate, formatMoney, headerLabel, hiddenSelectedCount, nextSort, pageBounds, pageFlat, searchMatches, segmentFilter, segmentSort, selectableIds, sortRows, sumMoney, toMinor, totalText, treeVisibleIds, useCollection };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Input, Tabs,
|
|
2
|
-
import { useUnderWidth,
|
|
3
|
-
export { balanceOf, compareDecimal, countFacets, formatDate, formatMoney, hiddenSelectedCount, nextSort, pageBounds, pageFlat, searchMatches, selectableIds, sortRows, sumMoney, toMinor, treeVisibleIds } from '../../chunk-
|
|
1
|
+
import { Input, Tabs, ToggleGroup, Toggle, Checkbox } from '../../chunk-Z6SR3KMB.js';
|
|
2
|
+
import { useUnderWidth, cn, Button, Select, Combobox, isEmptyValue, formatPercent, formatNumber, sumMoney, fractionDigitsOf, formatMoney, minorToDecimal, EmptyState, selectableIds, pageFlat, hiddenSelectedCount, nextSort, pageBounds, searchMatches, treeVisibleIds, isoDate, toMinor, Menu, comparePresent, collatorFor, formatDate, moneySearchForms, searchHaystack } from '../../chunk-43IJNNXK.js';
|
|
3
|
+
export { balanceOf, compareDecimal, countFacets, formatDate, formatMoney, hiddenSelectedCount, nextSort, pageBounds, pageFlat, searchMatches, selectableIds, sortRows, sumMoney, toMinor, treeVisibleIds } from '../../chunk-43IJNNXK.js';
|
|
4
4
|
import * as React4 from 'react';
|
|
5
5
|
import { useMemo, useRef, useState, useDeferredValue, useEffect } from 'react';
|
|
6
6
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -771,6 +771,25 @@ function widthStyle(width) {
|
|
|
771
771
|
if (!width || width === "auto" || width === "min") return void 0;
|
|
772
772
|
return { width: `var(--sl-${width.replace(/\./g, "-")})` };
|
|
773
773
|
}
|
|
774
|
+
function CollectionCards({ collection, label, renderCard, empty, loading, className }) {
|
|
775
|
+
const rows = collection.pageRows;
|
|
776
|
+
if (loading && collection.totalCount === 0) {
|
|
777
|
+
return /* @__PURE__ */ jsx(LoadingNote, { text: collection.messages.loading });
|
|
778
|
+
}
|
|
779
|
+
if (!rows.length) {
|
|
780
|
+
return collection.totalCount > 0 || collection.isFiltered ? /* @__PURE__ */ jsx(
|
|
781
|
+
EmptyState,
|
|
782
|
+
{
|
|
783
|
+
size: "compact",
|
|
784
|
+
kind: "no-results",
|
|
785
|
+
title: collection.messages.noResults,
|
|
786
|
+
description: collection.messages.noResultsDescription,
|
|
787
|
+
actions: /* @__PURE__ */ jsx(Button, { emphasis: "standard", onClick: collection.clearFilters, children: collection.messages.clearFilters })
|
|
788
|
+
}
|
|
789
|
+
) : /* @__PURE__ */ jsx(Fragment, { children: empty ?? /* @__PURE__ */ jsx(EmptyState, { size: "compact", kind: "start", title: collection.messages.nothingHere }) });
|
|
790
|
+
}
|
|
791
|
+
return /* @__PURE__ */ jsx("ul", { className: cn("CollectionCards", className), "aria-label": label, children: rows.map((row) => /* @__PURE__ */ jsx("li", { children: renderCard(row) }, collection.getRowId(row))) });
|
|
792
|
+
}
|
|
774
793
|
function CollectionPagination({
|
|
775
794
|
page,
|
|
776
795
|
pageCount,
|
|
@@ -825,7 +844,7 @@ function CollectionPagination({
|
|
|
825
844
|
] });
|
|
826
845
|
}
|
|
827
846
|
var COMBOBOX_AT = 12;
|
|
828
|
-
function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, searchPlaceholder, showSort, groupOptions, actions, bulkActions, searchWidth = "fill", meta, metaEnd, framed, className }) {
|
|
847
|
+
function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, searchPlaceholder, showSort, groupOptions, actions, bulkActions, searchWidth = "fill", meta, metaEnd, framed, segments, ruled, className }) {
|
|
829
848
|
const tabs = collection.columns.find((column) => column.filter?.kind === "tabs");
|
|
830
849
|
const selects = collection.columns.filter((column) => column.filter && column.filter.kind !== "tabs");
|
|
831
850
|
const searchable = collection.columns.some((column) => column.searchable);
|
|
@@ -851,6 +870,24 @@ function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, se
|
|
|
851
870
|
}, [collection.selection, collection.hiddenSelectedCount, collection.messages]);
|
|
852
871
|
const selecting = collection.selection.length > 0;
|
|
853
872
|
const narrow = useUnderWidth("--sl-collection-narrow-width");
|
|
873
|
+
if (segments) {
|
|
874
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("CollectionToolbar", className), "data-segmented": "", "data-ruled": ruled ? "" : void 0, children: [
|
|
875
|
+
searchable ? /* @__PURE__ */ jsx(
|
|
876
|
+
SearchField,
|
|
877
|
+
{
|
|
878
|
+
label: searchLabel ?? "Search",
|
|
879
|
+
visible: searchLabelVisible,
|
|
880
|
+
placeholder: searchPlaceholder,
|
|
881
|
+
value: collection.search,
|
|
882
|
+
onChange: collection.setSearch,
|
|
883
|
+
clearLabel: collection.messages.clearSearch
|
|
884
|
+
}
|
|
885
|
+
) : null,
|
|
886
|
+
segments.map((segment, index) => /* @__PURE__ */ jsx(ToolbarSegments, { segment, first: Boolean(segment.end) && !segments.slice(0, index).some((other) => other.end) }, segment.label)),
|
|
887
|
+
meta ? /* @__PURE__ */ jsx("p", { className: "CollectionToolbarMeta", "aria-live": "polite", children: meta }) : null,
|
|
888
|
+
/* @__PURE__ */ jsx("div", { className: "visually-hidden", "aria-live": "polite", children: announced })
|
|
889
|
+
] });
|
|
890
|
+
}
|
|
854
891
|
return /* @__PURE__ */ jsxs("div", { ref: narrow.ref, className: cn("CollectionToolbar", className), "data-selecting": selecting ? "" : void 0, "data-narrow": narrow.under ? "" : void 0, "data-search": searchWidth === "fixed" ? "fixed" : void 0, "data-framed": framed ? "" : void 0, children: [
|
|
855
892
|
tabs ? /* @__PURE__ */ jsx(ToolbarTabs, { collection, column: tabs }) : null,
|
|
856
893
|
/* @__PURE__ */ jsxs("div", { className: "CollectionToolbarMain", children: [
|
|
@@ -1064,6 +1101,53 @@ function SortControl({ collection }) {
|
|
|
1064
1101
|
)
|
|
1065
1102
|
] });
|
|
1066
1103
|
}
|
|
1104
|
+
function ToolbarSegments({ segment, first }) {
|
|
1105
|
+
return /* @__PURE__ */ jsxs("div", { className: "CollectionSegment", "data-end": first ? "" : void 0, children: [
|
|
1106
|
+
segment.showLabel ? /* @__PURE__ */ jsx("span", { className: "CollectionSegmentLabel", children: segment.label }) : null,
|
|
1107
|
+
/* @__PURE__ */ jsx(
|
|
1108
|
+
ToggleGroup,
|
|
1109
|
+
{
|
|
1110
|
+
"data-variant": "segmented",
|
|
1111
|
+
"aria-label": segment.label,
|
|
1112
|
+
value: segment.value ? [segment.value] : [],
|
|
1113
|
+
onValueChange: (next) => {
|
|
1114
|
+
if (next[0] && next[0] !== segment.value) segment.onChange(String(next[0]));
|
|
1115
|
+
},
|
|
1116
|
+
children: segment.options.map((option) => /* @__PURE__ */ jsxs(Toggle, { value: option.value, children: [
|
|
1117
|
+
option.label,
|
|
1118
|
+
option.count !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1119
|
+
" (",
|
|
1120
|
+
option.count,
|
|
1121
|
+
")"
|
|
1122
|
+
] }) : null
|
|
1123
|
+
] }, option.value))
|
|
1124
|
+
}
|
|
1125
|
+
)
|
|
1126
|
+
] });
|
|
1127
|
+
}
|
|
1128
|
+
function segmentFilter(collection, columnId, label, options) {
|
|
1129
|
+
const counts = collection.facetCounts(columnId);
|
|
1130
|
+
const total = [...counts.values()].reduce((sum, count) => sum + count, 0);
|
|
1131
|
+
const current = collection.filters[columnId];
|
|
1132
|
+
return {
|
|
1133
|
+
label,
|
|
1134
|
+
value: current == null || current === "" ? "all" : String(current),
|
|
1135
|
+
onChange: (value) => collection.setFilter(columnId, value === "all" ? void 0 : value),
|
|
1136
|
+
options: options.map((option) => ({ ...option, count: option.value === "all" ? total : counts.get(option.value) ?? 0 }))
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
function segmentSort(collection, label, options) {
|
|
1140
|
+
const active = options.find((option) => option.value === collection.sort?.id);
|
|
1141
|
+
return {
|
|
1142
|
+
label,
|
|
1143
|
+
value: active?.value ?? "",
|
|
1144
|
+
onChange: (value) => {
|
|
1145
|
+
const option = options.find((o) => o.value === value);
|
|
1146
|
+
if (option) collection.setSort({ id: option.value, desc: option.desc ?? false });
|
|
1147
|
+
},
|
|
1148
|
+
options
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1067
1151
|
function ToolbarClear({ collection }) {
|
|
1068
1152
|
if (!collection.isFiltered) return null;
|
|
1069
1153
|
return /* @__PURE__ */ jsx(Button, { emphasis: "quiet", onClick: collection.clearFilters, children: collection.messages.clearFilters });
|
|
@@ -1543,6 +1627,6 @@ function leafRows(row) {
|
|
|
1543
1627
|
return children.flatMap(leafRows);
|
|
1544
1628
|
}
|
|
1545
1629
|
|
|
1546
|
-
export { CollectionPagination, CollectionToolbar, DataList, DataTable, collectionTableOptions, defineColumns, headerLabel, totalText, useCollection };
|
|
1630
|
+
export { CollectionCards, CollectionPagination, CollectionToolbar, DataList, DataTable, collectionTableOptions, defineColumns, headerLabel, segmentFilter, segmentSort, totalText, useCollection };
|
|
1547
1631
|
//# sourceMappingURL=index.js.map
|
|
1548
1632
|
//# sourceMappingURL=index.js.map
|