@scattered-light/loomiere-base-ui 0.19.0 → 0.20.1

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.
Files changed (98) hide show
  1. package/README.md +4 -2
  2. package/dist/{chunk-M7KJASGK.js → chunk-43IJNNXK.js} +86 -3
  3. package/dist/chunk-43IJNNXK.js.map +1 -0
  4. package/dist/{chunk-2BFNETZZ.js → chunk-B5FH3RF5.js} +33 -15
  5. package/dist/chunk-B5FH3RF5.js.map +1 -0
  6. package/dist/chunk-Z6SR3KMB.js +77 -0
  7. package/dist/chunk-Z6SR3KMB.js.map +1 -0
  8. package/dist/custom/collection/index.d.ts +37 -2
  9. package/dist/custom/collection/index.js +70 -5
  10. package/dist/custom/collection/index.js.map +1 -1
  11. package/dist/custom/index.d.ts +1 -1
  12. package/dist/custom/index.js +2 -2
  13. package/dist/design-system/components/CollectionCards/README.md +32 -0
  14. package/dist/design-system/components/CollectionCards/preview.html +2 -2
  15. package/dist/design-system/components/CollectionToolbar/README.md +3 -1
  16. package/dist/design-system/components/PickerButton/README.md +1 -1
  17. package/dist/design-system/components/SplitButton/README.md +25 -0
  18. package/dist/design-system/components/SplitButton/preview.html +19 -0
  19. package/dist/design-system/components/StatCard/README.md +4 -1
  20. package/dist/design-system/components/StatCard/preview.html +1 -1
  21. package/dist/design-system/components/bundle.js +7 -7
  22. package/dist/design-system/components/index.d.ts +1 -1
  23. package/dist/design-system/components/styles.css +180 -67
  24. package/dist/{index-ywBkS0AA.d.ts → index-CB3_OECu.d.ts} +35 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +5 -18
  27. package/dist/index.js.map +1 -1
  28. package/dist/styles/components/Accordion.css +1 -1
  29. package/dist/styles/components/AlertDialog.css +1 -1
  30. package/dist/styles/components/Autocomplete.css +1 -1
  31. package/dist/styles/components/Avatar.css +1 -1
  32. package/dist/styles/components/Button.css +1 -1
  33. package/dist/styles/components/Checkbox.css +1 -1
  34. package/dist/styles/components/CheckboxGroup.css +1 -1
  35. package/dist/styles/components/Collapsible.css +1 -1
  36. package/dist/styles/components/Combobox.css +1 -1
  37. package/dist/styles/components/ContextMenu.css +1 -1
  38. package/dist/styles/components/Dialog.css +1 -1
  39. package/dist/styles/components/Drawer.css +1 -1
  40. package/dist/styles/components/Field.css +1 -1
  41. package/dist/styles/components/Fieldset.css +1 -1
  42. package/dist/styles/components/Form.css +1 -1
  43. package/dist/styles/components/Input.css +1 -1
  44. package/dist/styles/components/Menu.css +1 -1
  45. package/dist/styles/components/Menubar.css +1 -1
  46. package/dist/styles/components/Meter.css +1 -1
  47. package/dist/styles/components/NavigationMenu.css +1 -1
  48. package/dist/styles/components/NumberField.css +1 -1
  49. package/dist/styles/components/OTPField.css +1 -1
  50. package/dist/styles/components/Popover.css +1 -1
  51. package/dist/styles/components/PreviewCard.css +1 -1
  52. package/dist/styles/components/Progress.css +1 -1
  53. package/dist/styles/components/Radio.css +1 -1
  54. package/dist/styles/components/ScrollArea.css +1 -1
  55. package/dist/styles/components/Select.css +1 -1
  56. package/dist/styles/components/Separator.css +1 -1
  57. package/dist/styles/components/Slider.css +1 -1
  58. package/dist/styles/components/Switch.css +1 -1
  59. package/dist/styles/components/Tabs.css +1 -1
  60. package/dist/styles/components/Toast.css +1 -1
  61. package/dist/styles/components/Toggle.css +1 -1
  62. package/dist/styles/components/ToggleGroup.css +1 -1
  63. package/dist/styles/components/Toolbar.css +1 -1
  64. package/dist/styles/components/Tooltip.css +1 -1
  65. package/dist/styles/custom/AppBar.css +1 -1
  66. package/dist/styles/custom/Badge.css +1 -1
  67. package/dist/styles/custom/Collection.css +1 -1
  68. package/dist/styles/custom/CollectionCards.css +1 -1
  69. package/dist/styles/custom/CollectionPagination.css +1 -1
  70. package/dist/styles/custom/CollectionToolbar.css +47 -1
  71. package/dist/styles/custom/DataList.css +1 -1
  72. package/dist/styles/custom/DataTable.css +1 -1
  73. package/dist/styles/custom/DatePicker.css +1 -1
  74. package/dist/styles/custom/DescriptionList.css +1 -1
  75. package/dist/styles/custom/EditableList.css +1 -1
  76. package/dist/styles/custom/EmptyState.css +1 -1
  77. package/dist/styles/custom/ListDetail.css +1 -1
  78. package/dist/styles/custom/MoneyField.css +1 -1
  79. package/dist/styles/custom/PickerButton.css +4 -4
  80. package/dist/styles/custom/PickerSplit.css +2 -2
  81. package/dist/styles/custom/Sheet.css +1 -1
  82. package/dist/styles/custom/SideNav.css +1 -1
  83. package/dist/styles/custom/SplitButton.css +23 -0
  84. package/dist/styles/custom/Splitter.css +1 -1
  85. package/dist/styles/custom/StatCard.css +44 -1
  86. package/dist/styles/custom/StatFigure.css +1 -1
  87. package/dist/styles/custom/Table.css +1 -1
  88. package/dist/styles/index.css +2 -1
  89. package/dist/styles/reset/accessibility.css +1 -1
  90. package/dist/styles/reset/reset-accessibility.css +1 -1
  91. package/dist/styles/reset/reset-tailwind.css +1 -1
  92. package/dist/styles/reset/reset.css +1 -1
  93. package/dist/styles/tailwind.css +2 -1
  94. package/package.json +2 -2
  95. package/dist/chunk-2BFNETZZ.js.map +0 -1
  96. package/dist/chunk-M7KJASGK.js.map +0 -1
  97. package/dist/chunk-Y2CPBMFJ.js +0 -147
  98. 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"]}
@@ -518,6 +518,22 @@ interface CollectionPaginationProps {
518
518
  */
519
519
  declare function CollectionPagination({ page, pageCount, pageSize, total, filtered, onPageChange, onPageSizeChange, pageSizeOptions, label, previousLabel, nextLabel, rowsPerPageLabel, className, }: CollectionPaginationProps): react_jsx_runtime.JSX.Element;
520
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
+ }
521
537
  interface CollectionToolbarProps<T> {
522
538
  collection: CollectionApi<T>;
523
539
  /** Required when any column is searchable. */
@@ -542,13 +558,21 @@ interface CollectionToolbarProps<T> {
542
558
  metaEnd?: React.ReactNode;
543
559
  /** Pads the toolbar and rules it from the table below, for a toolbar inside a Sheet above an edge-to-edge table. */
544
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;
545
569
  className?: string;
546
570
  }
547
571
  /**
548
572
  * Tabs and search stay put while rows are selected. The trailing controls swap for the
549
573
  * selection bar, so the bar takes their place and the row does not grow.
550
574
  */
551
- 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;
552
576
  declare function ToolbarTabs<T>({ collection, column }: {
553
577
  collection: CollectionApi<T>;
554
578
  column: CollectionColumn<T>;
@@ -572,6 +596,17 @@ declare function FilterControl<T>({ collection, column }: {
572
596
  declare function SortControl<T>({ collection }: {
573
597
  collection: CollectionApi<T>;
574
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;
575
610
  declare function ToolbarClear<T>({ collection }: {
576
611
  collection: CollectionApi<T>;
577
612
  }): react_jsx_runtime.JSX.Element | null;
@@ -604,4 +639,4 @@ declare const CollectionToolbar: typeof CollectionToolbarImpl & {
604
639
  */
605
640
  declare function totalText<T>(column: CollectionColumn<T>, rows: readonly T[], locale: string): string;
606
641
 
607
- 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 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, Checkbox, Menu } from '../../chunk-Y2CPBMFJ.js';
2
- import { useUnderWidth, Button, cn, Select, Combobox, isEmptyValue, formatPercent, formatNumber, sumMoney, fractionDigitsOf, formatMoney, minorToDecimal, EmptyState, selectableIds, pageFlat, hiddenSelectedCount, nextSort, pageBounds, searchMatches, treeVisibleIds, isoDate, toMinor, comparePresent, collatorFor, formatDate, moneySearchForms, searchHaystack } from '../../chunk-M7KJASGK.js';
3
- export { balanceOf, compareDecimal, countFacets, formatDate, formatMoney, hiddenSelectedCount, nextSort, pageBounds, pageFlat, searchMatches, selectableIds, sortRows, sumMoney, toMinor, treeVisibleIds } from '../../chunk-M7KJASGK.js';
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';
@@ -844,7 +844,7 @@ function CollectionPagination({
844
844
  ] });
845
845
  }
846
846
  var COMBOBOX_AT = 12;
847
- 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 }) {
848
848
  const tabs = collection.columns.find((column) => column.filter?.kind === "tabs");
849
849
  const selects = collection.columns.filter((column) => column.filter && column.filter.kind !== "tabs");
850
850
  const searchable = collection.columns.some((column) => column.searchable);
@@ -870,6 +870,24 @@ function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, se
870
870
  }, [collection.selection, collection.hiddenSelectedCount, collection.messages]);
871
871
  const selecting = collection.selection.length > 0;
872
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
+ }
873
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: [
874
892
  tabs ? /* @__PURE__ */ jsx(ToolbarTabs, { collection, column: tabs }) : null,
875
893
  /* @__PURE__ */ jsxs("div", { className: "CollectionToolbarMain", children: [
@@ -1083,6 +1101,53 @@ function SortControl({ collection }) {
1083
1101
  )
1084
1102
  ] });
1085
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
+ }
1086
1151
  function ToolbarClear({ collection }) {
1087
1152
  if (!collection.isFiltered) return null;
1088
1153
  return /* @__PURE__ */ jsx(Button, { emphasis: "quiet", onClick: collection.clearFilters, children: collection.messages.clearFilters });
@@ -1562,6 +1627,6 @@ function leafRows(row) {
1562
1627
  return children.flatMap(leafRows);
1563
1628
  }
1564
1629
 
1565
- export { CollectionCards, CollectionPagination, CollectionToolbar, DataList, DataTable, collectionTableOptions, defineColumns, headerLabel, totalText, useCollection };
1630
+ export { CollectionCards, CollectionPagination, CollectionToolbar, DataList, DataTable, collectionTableOptions, defineColumns, headerLabel, segmentFilter, segmentSort, totalText, useCollection };
1566
1631
  //# sourceMappingURL=index.js.map
1567
1632
  //# sourceMappingURL=index.js.map