@lglab/compose-ui 0.29.0 → 0.30.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.
Files changed (91) hide show
  1. package/dist/accordion.d.ts +6 -6
  2. package/dist/alert-dialog.d.ts +10 -10
  3. package/dist/alert-dialog.d.ts.map +1 -1
  4. package/dist/autocomplete.d.ts +13 -13
  5. package/dist/autocomplete.d.ts.map +1 -1
  6. package/dist/avatar.d.ts +5 -5
  7. package/dist/avatar.d.ts.map +1 -1
  8. package/dist/badge.d.ts +4 -4
  9. package/dist/badge.js +5 -5
  10. package/dist/badge.js.map +1 -1
  11. package/dist/button.d.ts +2 -2
  12. package/dist/button.d.ts.map +1 -1
  13. package/dist/card.d.ts +8 -8
  14. package/dist/checkbox-group.d.ts +2 -2
  15. package/dist/checkbox.d.ts +3 -3
  16. package/dist/checkbox.d.ts.map +1 -1
  17. package/dist/collapsible.d.ts +4 -4
  18. package/dist/collapsible.d.ts.map +1 -1
  19. package/dist/combobox.d.ts +25 -25
  20. package/dist/components/table/filters.d.ts +29 -0
  21. package/dist/components/table/filters.d.ts.map +1 -0
  22. package/dist/components/table/filters.js +47 -0
  23. package/dist/components/table/filters.js.map +1 -0
  24. package/dist/components/table/primitives.d.ts +93 -0
  25. package/dist/components/table/primitives.d.ts.map +1 -0
  26. package/dist/components/table/primitives.js +129 -0
  27. package/dist/components/table/primitives.js.map +1 -0
  28. package/dist/components/table/sort.js +17 -0
  29. package/dist/components/table/sort.js.map +1 -0
  30. package/dist/components/table/types.d.ts +101 -0
  31. package/dist/components/table/types.d.ts.map +1 -0
  32. package/dist/context-menu.d.ts +20 -20
  33. package/dist/context-menu.d.ts.map +1 -1
  34. package/dist/dialog.d.ts +11 -11
  35. package/dist/drawer.d.ts +12 -12
  36. package/dist/field.d.ts +8 -8
  37. package/dist/fieldset.d.ts +3 -3
  38. package/dist/fieldset.d.ts.map +1 -1
  39. package/dist/form.d.ts +2 -2
  40. package/dist/form.d.ts.map +1 -1
  41. package/dist/index.d.ts +5 -1
  42. package/dist/index.js +4 -1
  43. package/dist/input.d.ts +2 -2
  44. package/dist/input.d.ts.map +1 -1
  45. package/dist/lib/control-variants.js +3 -2
  46. package/dist/lib/control-variants.js.map +1 -1
  47. package/dist/menu.d.ts +20 -20
  48. package/dist/menubar.d.ts +21 -21
  49. package/dist/meter.d.ts +6 -6
  50. package/dist/navigation-menu.d.ts +14 -14
  51. package/dist/number-field.d.ts +8 -8
  52. package/dist/number-field.d.ts.map +1 -1
  53. package/dist/pagination.d.ts +184 -0
  54. package/dist/pagination.d.ts.map +1 -0
  55. package/dist/pagination.js +164 -0
  56. package/dist/pagination.js.map +1 -0
  57. package/dist/popover.d.ts +12 -12
  58. package/dist/preview-card.d.ts +8 -8
  59. package/dist/progress.d.ts +6 -6
  60. package/dist/progress.d.ts.map +1 -1
  61. package/dist/radio-group.d.ts +2 -2
  62. package/dist/radio-group.d.ts.map +1 -1
  63. package/dist/radio.d.ts +3 -3
  64. package/dist/radio.d.ts.map +1 -1
  65. package/dist/scroll-area.d.ts +7 -7
  66. package/dist/scroll-area.d.ts.map +1 -1
  67. package/dist/select.d.ts +19 -19
  68. package/dist/select.d.ts.map +1 -1
  69. package/dist/select.js +1 -1
  70. package/dist/select.js.map +1 -1
  71. package/dist/separator.d.ts +2 -2
  72. package/dist/skeleton.d.ts +2 -2
  73. package/dist/skeleton.d.ts.map +1 -1
  74. package/dist/slider.d.ts +7 -7
  75. package/dist/slider.d.ts.map +1 -1
  76. package/dist/styles/default.css +1 -1
  77. package/dist/switch.d.ts +3 -3
  78. package/dist/table/index.d.ts +5 -0
  79. package/dist/table/index.js +5 -0
  80. package/dist/table/use-table.d.ts +9 -0
  81. package/dist/table/use-table.d.ts.map +1 -0
  82. package/dist/table/use-table.js +256 -0
  83. package/dist/table/use-table.js.map +1 -0
  84. package/dist/tabs.d.ts +6 -6
  85. package/dist/textarea.d.ts +2 -2
  86. package/dist/toast.d.ts +10 -10
  87. package/dist/toggle-group.d.ts +3 -3
  88. package/dist/toggle.d.ts +2 -2
  89. package/dist/toolbar.d.ts +7 -7
  90. package/dist/tooltip.d.ts +8 -8
  91. package/package.json +20 -8
@@ -1,17 +1,17 @@
1
1
  import * as React from "react";
2
- import * as react_jsx_runtime229 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime221 from "react/jsx-runtime";
3
3
  import { Combobox as BaseCombobox, ComboboxRootProps as ComboboxRootProps$1 } from "@base-ui/react/combobox";
4
4
  import * as _base_ui_react0 from "@base-ui/react";
5
5
 
6
6
  //#region src/components/combobox.d.ts
7
- declare function ComboboxRoot<Value, Multiple extends boolean | undefined = false>(props: ComboboxRootProps$1<Value, Multiple>): react_jsx_runtime229.JSX.Element;
7
+ declare function ComboboxRoot<Value, Multiple extends boolean | undefined = false>(props: ComboboxRootProps$1<Value, Multiple>): react_jsx_runtime221.JSX.Element;
8
8
  declare namespace ComboboxRoot {
9
9
  var displayName: string;
10
10
  }
11
11
  type ComboboxRootProps<Value, Multiple extends boolean | undefined = false> = ComboboxRootProps$1<Value, Multiple>;
12
12
  type ComboboxValueProps = React.ComponentProps<typeof BaseCombobox.Value>;
13
13
  declare const ComboboxValue: {
14
- (props: ComboboxValueProps): react_jsx_runtime229.JSX.Element;
14
+ (props: ComboboxValueProps): react_jsx_runtime221.JSX.Element;
15
15
  displayName: string;
16
16
  };
17
17
  type ComboboxIconProps = React.ComponentProps<typeof BaseCombobox.Icon>;
@@ -19,7 +19,7 @@ declare const ComboboxIcon: {
19
19
  ({
20
20
  className,
21
21
  ...props
22
- }: ComboboxIconProps): react_jsx_runtime229.JSX.Element;
22
+ }: ComboboxIconProps): react_jsx_runtime221.JSX.Element;
23
23
  displayName: string;
24
24
  };
25
25
  type ComboboxInputProps = React.ComponentProps<typeof BaseCombobox.Input>;
@@ -27,7 +27,7 @@ declare const ComboboxInput: {
27
27
  ({
28
28
  className,
29
29
  ...props
30
- }: ComboboxInputProps): react_jsx_runtime229.JSX.Element;
30
+ }: ComboboxInputProps): react_jsx_runtime221.JSX.Element;
31
31
  displayName: string;
32
32
  };
33
33
  type ComboboxControlProps = React.ComponentProps<'div'>;
@@ -35,7 +35,7 @@ declare const ComboboxControl: {
35
35
  ({
36
36
  className,
37
37
  ...props
38
- }: ComboboxControlProps): react_jsx_runtime229.JSX.Element;
38
+ }: ComboboxControlProps): react_jsx_runtime221.JSX.Element;
39
39
  displayName: string;
40
40
  };
41
41
  type ComboboxClearProps = React.ComponentProps<typeof BaseCombobox.Clear>;
@@ -43,7 +43,7 @@ declare const ComboboxClear: {
43
43
  ({
44
44
  className,
45
45
  ...props
46
- }: ComboboxClearProps): react_jsx_runtime229.JSX.Element;
46
+ }: ComboboxClearProps): react_jsx_runtime221.JSX.Element;
47
47
  displayName: string;
48
48
  };
49
49
  type ComboboxTriggerProps = React.ComponentProps<typeof BaseCombobox.Trigger>;
@@ -51,7 +51,7 @@ declare const ComboboxTrigger: {
51
51
  ({
52
52
  className,
53
53
  ...props
54
- }: ComboboxTriggerProps): react_jsx_runtime229.JSX.Element;
54
+ }: ComboboxTriggerProps): react_jsx_runtime221.JSX.Element;
55
55
  displayName: string;
56
56
  };
57
57
  type ComboboxBackdropProps = React.ComponentProps<typeof BaseCombobox.Backdrop>;
@@ -59,12 +59,12 @@ declare const ComboboxBackdrop: {
59
59
  ({
60
60
  className,
61
61
  ...props
62
- }: ComboboxBackdropProps): react_jsx_runtime229.JSX.Element;
62
+ }: ComboboxBackdropProps): react_jsx_runtime221.JSX.Element;
63
63
  displayName: string;
64
64
  };
65
65
  type ComboboxPortalProps = React.ComponentProps<typeof BaseCombobox.Portal>;
66
66
  declare const ComboboxPortal: {
67
- (props: ComboboxPortalProps): react_jsx_runtime229.JSX.Element;
67
+ (props: ComboboxPortalProps): react_jsx_runtime221.JSX.Element;
68
68
  displayName: string;
69
69
  };
70
70
  type ComboboxPositionerProps = React.ComponentProps<typeof BaseCombobox.Positioner>;
@@ -72,7 +72,7 @@ declare const ComboboxPositioner: {
72
72
  ({
73
73
  className,
74
74
  ...props
75
- }: ComboboxPositionerProps): react_jsx_runtime229.JSX.Element;
75
+ }: ComboboxPositionerProps): react_jsx_runtime221.JSX.Element;
76
76
  displayName: string;
77
77
  };
78
78
  type ComboboxPopupProps = React.ComponentProps<typeof BaseCombobox.Popup>;
@@ -80,7 +80,7 @@ declare const ComboboxPopup: {
80
80
  ({
81
81
  className,
82
82
  ...props
83
- }: ComboboxPopupProps): react_jsx_runtime229.JSX.Element;
83
+ }: ComboboxPopupProps): react_jsx_runtime221.JSX.Element;
84
84
  displayName: string;
85
85
  };
86
86
  type ComboboxListProps = React.ComponentProps<typeof BaseCombobox.List>;
@@ -88,7 +88,7 @@ declare const ComboboxList: {
88
88
  ({
89
89
  className,
90
90
  ...props
91
- }: ComboboxListProps): react_jsx_runtime229.JSX.Element;
91
+ }: ComboboxListProps): react_jsx_runtime221.JSX.Element;
92
92
  displayName: string;
93
93
  };
94
94
  type ComboboxEmptyProps = React.ComponentProps<typeof BaseCombobox.Empty>;
@@ -96,7 +96,7 @@ declare const ComboboxEmpty: {
96
96
  ({
97
97
  className,
98
98
  ...props
99
- }: ComboboxEmptyProps): react_jsx_runtime229.JSX.Element;
99
+ }: ComboboxEmptyProps): react_jsx_runtime221.JSX.Element;
100
100
  displayName: string;
101
101
  };
102
102
  type ComboboxItemProps = React.ComponentProps<typeof BaseCombobox.Item>;
@@ -104,7 +104,7 @@ declare const ComboboxItem: {
104
104
  ({
105
105
  className,
106
106
  ...props
107
- }: ComboboxItemProps): react_jsx_runtime229.JSX.Element;
107
+ }: ComboboxItemProps): react_jsx_runtime221.JSX.Element;
108
108
  displayName: string;
109
109
  };
110
110
  type ComboboxItemTextProps = React.ComponentProps<'span'>;
@@ -112,7 +112,7 @@ declare const ComboboxItemText: {
112
112
  ({
113
113
  className,
114
114
  ...props
115
- }: ComboboxItemTextProps): react_jsx_runtime229.JSX.Element;
115
+ }: ComboboxItemTextProps): react_jsx_runtime221.JSX.Element;
116
116
  displayName: string;
117
117
  };
118
118
  type ComboboxItemIndicatorProps = React.ComponentProps<typeof BaseCombobox.ItemIndicator>;
@@ -120,7 +120,7 @@ declare const ComboboxItemIndicator: {
120
120
  ({
121
121
  className,
122
122
  ...props
123
- }: ComboboxItemIndicatorProps): react_jsx_runtime229.JSX.Element;
123
+ }: ComboboxItemIndicatorProps): react_jsx_runtime221.JSX.Element;
124
124
  displayName: string;
125
125
  };
126
126
  type ComboboxGroupProps = React.ComponentProps<typeof BaseCombobox.Group>;
@@ -128,7 +128,7 @@ declare const ComboboxGroup: {
128
128
  ({
129
129
  className,
130
130
  ...props
131
- }: ComboboxGroupProps): react_jsx_runtime229.JSX.Element;
131
+ }: ComboboxGroupProps): react_jsx_runtime221.JSX.Element;
132
132
  displayName: string;
133
133
  };
134
134
  type ComboboxGroupLabelProps = React.ComponentProps<typeof BaseCombobox.GroupLabel>;
@@ -136,12 +136,12 @@ declare const ComboboxGroupLabel: {
136
136
  ({
137
137
  className,
138
138
  ...props
139
- }: ComboboxGroupLabelProps): react_jsx_runtime229.JSX.Element;
139
+ }: ComboboxGroupLabelProps): react_jsx_runtime221.JSX.Element;
140
140
  displayName: string;
141
141
  };
142
142
  type ComboboxCollectionProps = React.ComponentProps<typeof BaseCombobox.Collection>;
143
143
  declare const ComboboxCollection: {
144
- (props: ComboboxCollectionProps): react_jsx_runtime229.JSX.Element;
144
+ (props: ComboboxCollectionProps): react_jsx_runtime221.JSX.Element;
145
145
  displayName: string;
146
146
  };
147
147
  type ComboboxSeparatorProps = React.ComponentProps<typeof BaseCombobox.Separator>;
@@ -149,7 +149,7 @@ declare const ComboboxSeparator: {
149
149
  ({
150
150
  className,
151
151
  ...props
152
- }: ComboboxSeparatorProps): react_jsx_runtime229.JSX.Element;
152
+ }: ComboboxSeparatorProps): react_jsx_runtime221.JSX.Element;
153
153
  displayName: string;
154
154
  };
155
155
  type ComboboxStatusProps = React.ComponentProps<typeof BaseCombobox.Status>;
@@ -157,7 +157,7 @@ declare const ComboboxStatus: {
157
157
  ({
158
158
  className,
159
159
  ...props
160
- }: ComboboxStatusProps): react_jsx_runtime229.JSX.Element;
160
+ }: ComboboxStatusProps): react_jsx_runtime221.JSX.Element;
161
161
  displayName: string;
162
162
  };
163
163
  type ComboboxChipsProps = React.ComponentProps<typeof BaseCombobox.Chips>;
@@ -167,7 +167,7 @@ declare const ComboboxChip: {
167
167
  ({
168
168
  className,
169
169
  ...props
170
- }: ComboboxChipProps): react_jsx_runtime229.JSX.Element;
170
+ }: ComboboxChipProps): react_jsx_runtime221.JSX.Element;
171
171
  displayName: string;
172
172
  };
173
173
  type ComboboxChipRemoveProps = React.ComponentProps<typeof BaseCombobox.ChipRemove>;
@@ -175,7 +175,7 @@ declare const ComboboxChipRemove: {
175
175
  ({
176
176
  className,
177
177
  ...props
178
- }: ComboboxChipRemoveProps): react_jsx_runtime229.JSX.Element;
178
+ }: ComboboxChipRemoveProps): react_jsx_runtime221.JSX.Element;
179
179
  displayName: string;
180
180
  };
181
181
  type ComboboxArrowProps = React.ComponentProps<typeof BaseCombobox.Arrow>;
@@ -183,7 +183,7 @@ declare const ComboboxArrow: {
183
183
  ({
184
184
  className,
185
185
  ...props
186
- }: ComboboxArrowProps): react_jsx_runtime229.JSX.Element;
186
+ }: ComboboxArrowProps): react_jsx_runtime221.JSX.Element;
187
187
  displayName: string;
188
188
  };
189
189
  //#endregion
@@ -0,0 +1,29 @@
1
+ import { FilterPredicate } from "./types.js";
2
+
3
+ //#region src/components/table/filters.d.ts
4
+
5
+ /**
6
+ * Multi-select filter: row value is included in selected array.
7
+ * Returns true if no values are selected (empty array or undefined).
8
+ */
9
+ declare function includesFilter<T, K extends keyof T>(key: K): FilterPredicate<T, T[K][]>;
10
+ /**
11
+ * Range filter: numeric row value is within [min, max] bounds.
12
+ * Returns true if range is undefined.
13
+ */
14
+ declare function rangeFilter<T, K extends keyof T>(key: K): FilterPredicate<T, [number, number]>;
15
+ /**
16
+ * Contains filter: string row value contains search term (case-insensitive).
17
+ * Returns true if search term is empty or undefined.
18
+ */
19
+ declare function containsFilter<T, K extends keyof T>(key: K): FilterPredicate<T, string>;
20
+ /**
21
+ * Equals filter: row value strictly equals filter value.
22
+ * Returns true if filter value is undefined.
23
+ */
24
+ declare function equalsFilter<T, K extends keyof T>(key: K): FilterPredicate<T, T[K]>;
25
+ //# sourceMappingURL=filters.d.ts.map
26
+
27
+ //#endregion
28
+ export { containsFilter, equalsFilter, includesFilter, rangeFilter };
29
+ //# sourceMappingURL=filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.d.ts","names":[],"sources":["../../../src/components/table/filters.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAAkD,iBAAlC,cAAkC,CAAA,CAAA,EAAA,UAAA,MAAA,CAAA,CAAA,CAAA,GAAA,EAAQ,CAAR,CAAA,EAAY,eAAZ,CAA4B,CAA5B,EAA+B,CAA/B,CAAiC,CAAjC,CAAA,EAAA,CAAA;;;;;AAAY,iBAW9C,WAX8C,CAAA,CAAA,EAAA,UAAA,MAWf,CAXe,CAAA,CAAA,GAAA,EAYvD,CAZuD,CAAA,EAa3D,eAb2D,CAa3C,CAb2C,EAAA,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;;AAW9D;;;AACO,iBAcS,cAdT,CAAA,CAAA,EAAA,UAAA,MAc2C,CAd3C,CAAA,CAAA,GAAA,EAcmD,CAdnD,CAAA,EAcuD,eAdvD,CAcuE,CAdvE,EAAA,MAAA,CAAA;;;;AAcP;AAA8B,iBAWd,YAXc,CAAA,CAAA,EAAA,UAAA,MAWkB,CAXlB,CAAA,CAAA,GAAA,EAW0B,CAX1B,CAAA,EAW8B,eAX9B,CAW8C,CAX9C,EAWiD,CAXjD,CAWmD,CAXnD,CAAA,CAAA"}
@@ -0,0 +1,47 @@
1
+ //#region src/components/table/filters.ts
2
+ /**
3
+ * Multi-select filter: row value is included in selected array.
4
+ * Returns true if no values are selected (empty array or undefined).
5
+ */
6
+ function includesFilter(key) {
7
+ return (row, value) => {
8
+ if (!value || value.length === 0) return true;
9
+ return value.includes(row[key]);
10
+ };
11
+ }
12
+ /**
13
+ * Range filter: numeric row value is within [min, max] bounds.
14
+ * Returns true if range is undefined.
15
+ */
16
+ function rangeFilter(key) {
17
+ return (row, value) => {
18
+ if (!value) return true;
19
+ const [min, max] = value;
20
+ const rowValue = row[key];
21
+ return rowValue >= min && rowValue <= max;
22
+ };
23
+ }
24
+ /**
25
+ * Contains filter: string row value contains search term (case-insensitive).
26
+ * Returns true if search term is empty or undefined.
27
+ */
28
+ function containsFilter(key) {
29
+ return (row, value) => {
30
+ if (!value) return true;
31
+ return String(row[key]).toLowerCase().includes(value.toLowerCase());
32
+ };
33
+ }
34
+ /**
35
+ * Equals filter: row value strictly equals filter value.
36
+ * Returns true if filter value is undefined.
37
+ */
38
+ function equalsFilter(key) {
39
+ return (row, value) => {
40
+ if (value === void 0) return true;
41
+ return row[key] === value;
42
+ };
43
+ }
44
+
45
+ //#endregion
46
+ export { containsFilter, equalsFilter, includesFilter, rangeFilter };
47
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","names":[],"sources":["../../../src/components/table/filters.ts"],"sourcesContent":["import type { FilterPredicate } from './types'\n\n/**\n * Multi-select filter: row value is included in selected array.\n * Returns true if no values are selected (empty array or undefined).\n */\nexport function includesFilter<T, K extends keyof T>(key: K): FilterPredicate<T, T[K][]> {\n return (row: T, value: T[K][]) => {\n if (!value || value.length === 0) return true\n return value.includes(row[key])\n }\n}\n\n/**\n * Range filter: numeric row value is within [min, max] bounds.\n * Returns true if range is undefined.\n */\nexport function rangeFilter<T, K extends keyof T>(\n key: K,\n): FilterPredicate<T, [number, number]> {\n return (row: T, value: [number, number]) => {\n if (!value) return true\n const [min, max] = value\n const rowValue = row[key] as number\n return rowValue >= min && rowValue <= max\n }\n}\n\n/**\n * Contains filter: string row value contains search term (case-insensitive).\n * Returns true if search term is empty or undefined.\n */\nexport function containsFilter<T, K extends keyof T>(key: K): FilterPredicate<T, string> {\n return (row: T, value: string) => {\n if (!value) return true\n return String(row[key]).toLowerCase().includes(value.toLowerCase())\n }\n}\n\n/**\n * Equals filter: row value strictly equals filter value.\n * Returns true if filter value is undefined.\n */\nexport function equalsFilter<T, K extends keyof T>(key: K): FilterPredicate<T, T[K]> {\n return (row: T, value: T[K]) => {\n if (value === undefined) return true\n return row[key] === value\n }\n}\n"],"mappings":";;;;;AAMA,SAAgB,eAAqC,KAAoC;AACvF,SAAQ,KAAQ,UAAkB;AAChC,MAAI,CAAC,SAAS,MAAM,WAAW,EAAG,QAAO;AACzC,SAAO,MAAM,SAAS,IAAI,KAAK;;;;;;;AAQnC,SAAgB,YACd,KACsC;AACtC,SAAQ,KAAQ,UAA4B;AAC1C,MAAI,CAAC,MAAO,QAAO;EACnB,MAAM,CAAC,KAAK,OAAO;EACnB,MAAM,WAAW,IAAI;AACrB,SAAO,YAAY,OAAO,YAAY;;;;;;;AAQ1C,SAAgB,eAAqC,KAAoC;AACvF,SAAQ,KAAQ,UAAkB;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,OAAO,IAAI,KAAK,CAAC,aAAa,CAAC,SAAS,MAAM,aAAa,CAAC;;;;;;;AAQvE,SAAgB,aAAmC,KAAkC;AACnF,SAAQ,KAAQ,UAAgB;AAC9B,MAAI,UAAU,OAAW,QAAO;AAChC,SAAO,IAAI,SAAS"}
@@ -0,0 +1,93 @@
1
+ import { SortDirection } from "./types.js";
2
+ import * as React from "react";
3
+ import { VariantProps } from "class-variance-authority";
4
+ import * as react_jsx_runtime285 from "react/jsx-runtime";
5
+ import * as class_variance_authority_types3 from "class-variance-authority/types";
6
+
7
+ //#region src/components/table/primitives.d.ts
8
+ declare const tableVariants: (props?: ({
9
+ variant?: "default" | "striped" | "bordered" | null | undefined;
10
+ size?: "default" | "compact" | null | undefined;
11
+ } & class_variance_authority_types3.ClassProp) | undefined) => string;
12
+ type TableVariant = VariantProps<typeof tableVariants>['variant'];
13
+ type TableSize = VariantProps<typeof tableVariants>['size'];
14
+ type TableRootProps = React.ComponentProps<'table'> & VariantProps<typeof tableVariants>;
15
+ declare const TableRoot: {
16
+ ({
17
+ className,
18
+ variant,
19
+ size,
20
+ ...props
21
+ }: TableRootProps): react_jsx_runtime285.JSX.Element;
22
+ displayName: string;
23
+ };
24
+ type TableHeaderProps = React.ComponentProps<'thead'>;
25
+ declare const TableHeader: {
26
+ ({
27
+ className,
28
+ ...props
29
+ }: TableHeaderProps): react_jsx_runtime285.JSX.Element;
30
+ displayName: string;
31
+ };
32
+ type TableBodyProps = React.ComponentProps<'tbody'>;
33
+ declare const TableBody: {
34
+ ({
35
+ className,
36
+ ...props
37
+ }: TableBodyProps): react_jsx_runtime285.JSX.Element;
38
+ displayName: string;
39
+ };
40
+ type TableFooterProps = React.ComponentProps<'tfoot'>;
41
+ declare const TableFooter: {
42
+ ({
43
+ className,
44
+ ...props
45
+ }: TableFooterProps): react_jsx_runtime285.JSX.Element;
46
+ displayName: string;
47
+ };
48
+ type TableRowProps = React.ComponentProps<'tr'>;
49
+ declare const TableRow: {
50
+ ({
51
+ className,
52
+ ...props
53
+ }: TableRowProps): react_jsx_runtime285.JSX.Element;
54
+ displayName: string;
55
+ };
56
+ type TableHeadProps = React.ComponentProps<'th'> & {
57
+ sortable?: boolean;
58
+ sortDirection?: SortDirection;
59
+ onSort?: () => void;
60
+ };
61
+ declare const TableHead: {
62
+ ({
63
+ className,
64
+ sortable,
65
+ sortDirection,
66
+ onSort,
67
+ children,
68
+ ...props
69
+ }: TableHeadProps): react_jsx_runtime285.JSX.Element;
70
+ displayName: string;
71
+ };
72
+ type TableCellProps = React.ComponentProps<'td'>;
73
+ declare const TableCell: {
74
+ ({
75
+ className,
76
+ ...props
77
+ }: TableCellProps): react_jsx_runtime285.JSX.Element;
78
+ displayName: string;
79
+ };
80
+ type TableCaptionProps = React.ComponentProps<'caption'> & {
81
+ position?: 'top' | 'bottom';
82
+ };
83
+ declare const TableCaption: {
84
+ ({
85
+ className,
86
+ position,
87
+ ...props
88
+ }: TableCaptionProps): react_jsx_runtime285.JSX.Element;
89
+ displayName: string;
90
+ };
91
+ //#endregion
92
+ export { TableBody, type TableBodyProps, TableCaption, type TableCaptionProps, TableCell, type TableCellProps, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TableHeader, type TableHeaderProps, TableRoot, type TableRootProps, TableRow, type TableRowProps, TableSize, TableVariant };
93
+ //# sourceMappingURL=primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.d.ts","names":[],"sources":["../../../src/components/table/primitives.tsx"],"sourcesContent":[],"mappings":";;;;;;;cAYM;;;IAcJ,+BAAA,CAAA;AAdI,KAgBM,YAAA,GAAe,YAFzB,CAAA,OAE6C,aAF7C,CAAA,CAAA,SAAA,CAAA;AAEU,KACA,SAAA,GAAY,YADA,CAAA,OACoB,aADpB,CAAA,CAAA,MAAA,CAAA;KAOnB,cAAA,GAAiB,KAAA,CAAM,cAPJ,CAAA,OAAA,CAAA,GAO8B,YAP9B,CAAA,OAOkD,aAPlD,CAAA;cASlB,SATyC,EAAA;;IAApB,SAAA;IAAA,OAAA;IAAA,IAAA;IAAA,GAAA;EAAA,CAAA,EASgC,cAThC,CAAA,EAS8C,oBAAA,CAAA,GAAA,CAAA,OAT9C;EAAY,WAAA,EAAA,MAAA;AACvC,CAAA;KAsBK,gBAAA,GAAmB,KAAA,CAAM,cAtBT,CAAA,OAAA,CAAA;cAwBf,WAxBsC,EAAA;;IAApB,SAAA;IAAA,GAAA;EAAA,CAAA,EAwBsB,gBAxBtB,CAAA,EAwBsC,oBAAA,CAAA,GAAA,CAAA,OAxBtC;EAAY,WAAA,EAAA,MAAA;AAA8B,CAAA;KAkC7D,cAAA,GAAiB,KAAA,CAAM,cA5BT,CAAA,OAAA,CAAA;cA8Bb,SA9BsB,EAAA;;IAA8C,SAAA;IAAA,GAAA;EAAA,CAAA,EA8B9B,cA9B8B,CAAA,EA8BhB,oBAAA,CAAA,GAAA,CAAA,OA9BgB;aAApB,EAAA,MAAA;CAAY;AAAA,KAwC7D,gBAAA,GAAmB,KAAA,CAAM,cAhC7B,CAAA,OAAA,CAAA;cAkCK,WAlCL,EAAA;;;;KAkC6C,mBAAgB,oBAAA,CAAA,GAAA,CAAA;;;KAezD,aAAA,GAAgB,KAAA,CAAM,cAvDgC,CAAA,IAAA,CAAA;cAyDrD,QAzDmE,EAAA;EAAA,CAAA;IAAA,SAAA;IAAA,GAAA;EAAA,CAAA,EAyD9B,aAzD8B,CAAA,EAyDjB,oBAAA,CAAA,GAAA,CAAA,OAzDiB;EAcpE,WAAA,EAAA,MAAgB;AAAuB,CAAA;KA+DvC,cAAA,GAAiB,KAAA,CAAM,cA3D3B,CAAA,IAAA,CAAA,GAAA;;eAF6C,CAAA,EA+D5B,aA/D4B;QAAgB,CAAA,EAAA,GAAA,GAAA,IAAA;CAAA;AAAA,cAgGxD,SAtFa,EAAA;EAEb,CAAA;IAAA,SAEL;IAAA,QAAA;IAAA,aAAA;IAAA,MAAA;IAAA,QAAA;IAAA,GAAA;EAAA,CAAA,EAyFE,cAzFF,CAAA,EAyFgB,oBAAA,CAAA,GAAA,CAAA,OAzFhB;EAAA,WAAA,EAAA,MAAA;;KAmII,cAAA,GAAiB,KAAA,CAAM,cArIgB,CAAA,IAAA,CAAA;cAuItC,SAvIoD,EAAA;EAAA,CAAA;IAAA,SAAA;IAAA,GAAA;EAAA,CAAA,EAuId,cAvIc,CAAA,EAuIA,oBAAA,CAAA,GAAA,CAAA,OAvIA;EAUrD,WAAA,EAAA,MAAgB;AAAuB,CAAA;KA+IvC,iBAAA,GAAoB,KAAA,CAAM,cAtI9B,CAAA,SAAA,CAAA,GAAA;;;cA0IK,YAjJwD,EAAA;EAAA,CAAA;IAAA,SAAA;IAAA,QAAA;IAAA,GAAA;EAAA,CAAA,EAqJ3D,iBArJ2D,CAAA,EAqJ1C,oBAAA,CAAA,GAAA,CAAA,OArJ0C;EAezD,WAAA,EAAA,MAAa;AAAuB,CAAA"}
@@ -0,0 +1,129 @@
1
+ 'use client';
2
+
3
+ import { cn } from "../../lib/utils.js";
4
+ import "react";
5
+ import { cva } from "class-variance-authority";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+
8
+ //#region src/components/table/primitives.tsx
9
+ const tableVariants = cva("w-full caption-bottom text-sm", {
10
+ variants: {
11
+ variant: {
12
+ default: "",
13
+ striped: "[&_tbody_tr:nth-child(even)]:bg-muted/50",
14
+ bordered: "[&_th:not(:last-child)]:border-r [&_td:not(:last-child)]:border-r [&_th]:border-border [&_td]:border-border"
15
+ },
16
+ size: {
17
+ default: "",
18
+ compact: "[&_th]:h-8 [&_th]:px-2 [&_td]:p-2.5"
19
+ }
20
+ },
21
+ defaultVariants: {
22
+ variant: "default",
23
+ size: "default"
24
+ }
25
+ });
26
+ const TableRoot = ({ className, variant, size, ...props }) => {
27
+ return /* @__PURE__ */ jsx("div", {
28
+ className: "relative w-full overflow-x-auto",
29
+ children: /* @__PURE__ */ jsx("table", {
30
+ className: cn(tableVariants({
31
+ variant,
32
+ size
33
+ }), className),
34
+ ...props
35
+ })
36
+ });
37
+ };
38
+ TableRoot.displayName = "TableRoot";
39
+ const TableHeader = ({ className, ...props }) => {
40
+ return /* @__PURE__ */ jsx("thead", {
41
+ className: cn("[&_tr]:border-b", className),
42
+ ...props
43
+ });
44
+ };
45
+ TableHeader.displayName = "TableHeader";
46
+ const TableBody = ({ className, ...props }) => {
47
+ return /* @__PURE__ */ jsx("tbody", {
48
+ className: cn("[&_tr:last-child]:border-0", className),
49
+ ...props
50
+ });
51
+ };
52
+ TableBody.displayName = "TableBody";
53
+ const TableFooter = ({ className, ...props }) => {
54
+ return /* @__PURE__ */ jsx("tfoot", {
55
+ className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className),
56
+ ...props
57
+ });
58
+ };
59
+ TableFooter.displayName = "TableFooter";
60
+ const TableRow = ({ className, ...props }) => {
61
+ return /* @__PURE__ */ jsx("tr", {
62
+ className: cn("border-b transition-colors hover:bg-muted/50", className),
63
+ ...props
64
+ });
65
+ };
66
+ TableRow.displayName = "TableRow";
67
+ const ariaSortValues = {
68
+ asc: "ascending",
69
+ desc: "descending"
70
+ };
71
+ const SortIcon = ({ direction }) => {
72
+ return /* @__PURE__ */ jsx("svg", {
73
+ xmlns: "http://www.w3.org/2000/svg",
74
+ width: "16",
75
+ height: "16",
76
+ viewBox: "0 0 24 24",
77
+ fill: "none",
78
+ stroke: "currentColor",
79
+ strokeWidth: "2",
80
+ strokeLinecap: "round",
81
+ strokeLinejoin: "round",
82
+ className: "ml-1 inline-block",
83
+ "aria-hidden": "true",
84
+ children: direction === "asc" ? /* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }) : direction === "desc" ? /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "m7 15 5 5 5-5" }), /* @__PURE__ */ jsx("path", { d: "m7 9 5-5 5 5" })] })
85
+ });
86
+ };
87
+ const TableHead = ({ className, sortable, sortDirection, onSort, children, ...props }) => {
88
+ const isInteractive = sortable && onSort;
89
+ const handleClick = () => {
90
+ if (isInteractive) onSort();
91
+ };
92
+ const handleKeyDown = (e) => {
93
+ if (isInteractive && (e.key === "Enter" || e.key === " ")) {
94
+ e.preventDefault();
95
+ onSort();
96
+ }
97
+ };
98
+ return /* @__PURE__ */ jsx("th", {
99
+ className: cn("h-10 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-[2px]", isInteractive && "cursor-pointer select-none hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", className),
100
+ tabIndex: isInteractive ? 0 : void 0,
101
+ "aria-sort": sortDirection ? ariaSortValues[sortDirection] : void 0,
102
+ onClick: handleClick,
103
+ onKeyDown: handleKeyDown,
104
+ ...props,
105
+ children: /* @__PURE__ */ jsxs("span", {
106
+ className: "inline-flex items-center",
107
+ children: [children, sortable && /* @__PURE__ */ jsx(SortIcon, { direction: sortDirection })]
108
+ })
109
+ });
110
+ };
111
+ TableHead.displayName = "TableHead";
112
+ const TableCell = ({ className, ...props }) => {
113
+ return /* @__PURE__ */ jsx("td", {
114
+ className: cn("p-4 align-middle [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-[2px]", className),
115
+ ...props
116
+ });
117
+ };
118
+ TableCell.displayName = "TableCell";
119
+ const TableCaption = ({ className, position = "bottom", ...props }) => {
120
+ return /* @__PURE__ */ jsx("caption", {
121
+ className: cn("mt-4 text-sm text-muted-foreground", position === "top" && "caption-top mb-4 mt-0", className),
122
+ ...props
123
+ });
124
+ };
125
+ TableCaption.displayName = "TableCaption";
126
+
127
+ //#endregion
128
+ export { TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRoot, TableRow };
129
+ //# sourceMappingURL=primitives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.js","names":[],"sources":["../../../src/components/table/primitives.tsx"],"sourcesContent":["'use client'\n\nimport { type VariantProps, cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { cn } from '../../lib/utils'\nimport type { SortDirection } from './types'\n\n// ============================================================================\n// Table Variants\n// ============================================================================\n\nconst tableVariants = cva('w-full caption-bottom text-sm', {\n variants: {\n variant: {\n default: '',\n striped: '[&_tbody_tr:nth-child(even)]:bg-muted/50',\n bordered:\n '[&_th:not(:last-child)]:border-r [&_td:not(:last-child)]:border-r [&_th]:border-border [&_td]:border-border',\n },\n size: {\n default: '',\n compact: '[&_th]:h-8 [&_th]:px-2 [&_td]:p-2.5',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n})\n\nexport type TableVariant = VariantProps<typeof tableVariants>['variant']\nexport type TableSize = VariantProps<typeof tableVariants>['size']\n\n// ============================================================================\n// TableRoot\n// ============================================================================\n\ntype TableRootProps = React.ComponentProps<'table'> & VariantProps<typeof tableVariants>\n\nconst TableRoot = ({ className, variant, size, ...props }: TableRootProps) => {\n return (\n <div className='relative w-full overflow-x-auto'>\n <table className={cn(tableVariants({ variant, size }), className)} {...props} />\n </div>\n )\n}\n\nTableRoot.displayName = 'TableRoot'\n\n// ============================================================================\n// TableHeader\n// ============================================================================\n\ntype TableHeaderProps = React.ComponentProps<'thead'>\n\nconst TableHeader = ({ className, ...props }: TableHeaderProps) => {\n return <thead className={cn('[&_tr]:border-b', className)} {...props} />\n}\n\nTableHeader.displayName = 'TableHeader'\n\n// ============================================================================\n// TableBody\n// ============================================================================\n\ntype TableBodyProps = React.ComponentProps<'tbody'>\n\nconst TableBody = ({ className, ...props }: TableBodyProps) => {\n return <tbody className={cn('[&_tr:last-child]:border-0', className)} {...props} />\n}\n\nTableBody.displayName = 'TableBody'\n\n// ============================================================================\n// TableFooter\n// ============================================================================\n\ntype TableFooterProps = React.ComponentProps<'tfoot'>\n\nconst TableFooter = ({ className, ...props }: TableFooterProps) => {\n return (\n <tfoot\n className={cn('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0', className)}\n {...props}\n />\n )\n}\n\nTableFooter.displayName = 'TableFooter'\n\n// ============================================================================\n// TableRow\n// ============================================================================\n\ntype TableRowProps = React.ComponentProps<'tr'>\n\nconst TableRow = ({ className, ...props }: TableRowProps) => {\n return (\n <tr\n className={cn('border-b transition-colors hover:bg-muted/50', className)}\n {...props}\n />\n )\n}\n\nTableRow.displayName = 'TableRow'\n\n// ============================================================================\n// TableHead\n// ============================================================================\n\nconst ariaSortValues: Record<SortDirection, 'ascending' | 'descending'> = {\n asc: 'ascending',\n desc: 'descending',\n}\n\ntype TableHeadProps = React.ComponentProps<'th'> & {\n sortable?: boolean\n sortDirection?: SortDirection\n onSort?: () => void\n}\n\nconst SortIcon = ({ direction }: { direction?: SortDirection }) => {\n return (\n <svg\n xmlns='http://www.w3.org/2000/svg'\n width='16'\n height='16'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2'\n strokeLinecap='round'\n strokeLinejoin='round'\n className='ml-1 inline-block'\n aria-hidden='true'\n >\n {direction === 'asc' ? (\n <path d='m18 15-6-6-6 6' />\n ) : direction === 'desc' ? (\n <path d='m6 9 6 6 6-6' />\n ) : (\n <>\n <path d='m7 15 5 5 5-5' />\n <path d='m7 9 5-5 5 5' />\n </>\n )}\n </svg>\n )\n}\n\nconst TableHead = ({\n className,\n sortable,\n sortDirection,\n onSort,\n children,\n ...props\n}: TableHeadProps) => {\n const isInteractive = sortable && onSort\n\n const handleClick = () => {\n if (isInteractive) onSort()\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTableCellElement>) => {\n if (isInteractive && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault()\n onSort()\n }\n }\n\n return (\n <th\n className={cn(\n 'h-10 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-[2px]',\n isInteractive &&\n 'cursor-pointer select-none hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset',\n className,\n )}\n tabIndex={isInteractive ? 0 : undefined}\n aria-sort={sortDirection ? ariaSortValues[sortDirection] : undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n <span className='inline-flex items-center'>\n {children}\n {sortable && <SortIcon direction={sortDirection} />}\n </span>\n </th>\n )\n}\n\nTableHead.displayName = 'TableHead'\n\n// ============================================================================\n// TableCell\n// ============================================================================\n\ntype TableCellProps = React.ComponentProps<'td'>\n\nconst TableCell = ({ className, ...props }: TableCellProps) => {\n return (\n <td\n className={cn(\n 'p-4 align-middle [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-[2px]',\n className,\n )}\n {...props}\n />\n )\n}\n\nTableCell.displayName = 'TableCell'\n\n// ============================================================================\n// TableCaption\n// ============================================================================\n\ntype TableCaptionProps = React.ComponentProps<'caption'> & {\n position?: 'top' | 'bottom'\n}\n\nconst TableCaption = ({\n className,\n position = 'bottom',\n ...props\n}: TableCaptionProps) => {\n return (\n <caption\n className={cn(\n 'mt-4 text-sm text-muted-foreground',\n position === 'top' && 'caption-top mb-4 mt-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nTableCaption.displayName = 'TableCaption'\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport {\n TableRoot,\n TableHeader,\n TableBody,\n TableFooter,\n TableRow,\n TableHead,\n TableCell,\n TableCaption,\n}\n\nexport type {\n TableRootProps,\n TableHeaderProps,\n TableBodyProps,\n TableFooterProps,\n TableRowProps,\n TableHeadProps,\n TableCellProps,\n TableCaptionProps,\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,gBAAgB,IAAI,iCAAiC;CACzD,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,UACE;GACH;EACD,MAAM;GACJ,SAAS;GACT,SAAS;GACV;EACF;CACD,iBAAiB;EAAE,SAAS;EAAW,MAAM;EAAW;CACzD,CAAC;AAWF,MAAM,aAAa,EAAE,WAAW,SAAS,MAAM,GAAG,YAA4B;AAC5E,QACE,oBAAC;EAAI,WAAU;YACb,oBAAC;GAAM,WAAW,GAAG,cAAc;IAAE;IAAS;IAAM,CAAC,EAAE,UAAU;GAAE,GAAI;IAAS;GAC5E;;AAIV,UAAU,cAAc;AAQxB,MAAM,eAAe,EAAE,WAAW,GAAG,YAA8B;AACjE,QAAO,oBAAC;EAAM,WAAW,GAAG,mBAAmB,UAAU;EAAE,GAAI;GAAS;;AAG1E,YAAY,cAAc;AAQ1B,MAAM,aAAa,EAAE,WAAW,GAAG,YAA4B;AAC7D,QAAO,oBAAC;EAAM,WAAW,GAAG,8BAA8B,UAAU;EAAE,GAAI;GAAS;;AAGrF,UAAU,cAAc;AAQxB,MAAM,eAAe,EAAE,WAAW,GAAG,YAA8B;AACjE,QACE,oBAAC;EACC,WAAW,GAAG,2DAA2D,UAAU;EACnF,GAAI;GACJ;;AAIN,YAAY,cAAc;AAQ1B,MAAM,YAAY,EAAE,WAAW,GAAG,YAA2B;AAC3D,QACE,oBAAC;EACC,WAAW,GAAG,gDAAgD,UAAU;EACxE,GAAI;GACJ;;AAIN,SAAS,cAAc;AAMvB,MAAM,iBAAoE;CACxE,KAAK;CACL,MAAM;CACP;AAQD,MAAM,YAAY,EAAE,gBAA+C;AACjE,QACE,oBAAC;EACC,OAAM;EACN,OAAM;EACN,QAAO;EACP,SAAQ;EACR,MAAK;EACL,QAAO;EACP,aAAY;EACZ,eAAc;EACd,gBAAe;EACf,WAAU;EACV,eAAY;YAEX,cAAc,QACb,oBAAC,UAAK,GAAE,mBAAmB,GACzB,cAAc,SAChB,oBAAC,UAAK,GAAE,iBAAiB,GAEzB,4CACE,oBAAC,UAAK,GAAE,kBAAkB,EAC1B,oBAAC,UAAK,GAAE,iBAAiB,IACxB;GAED;;AAIV,MAAM,aAAa,EACjB,WACA,UACA,eACA,QACA,UACA,GAAG,YACiB;CACpB,MAAM,gBAAgB,YAAY;CAElC,MAAM,oBAAoB;AACxB,MAAI,cAAe,SAAQ;;CAG7B,MAAM,iBAAiB,MAAiD;AACtE,MAAI,kBAAkB,EAAE,QAAQ,WAAW,EAAE,QAAQ,MAAM;AACzD,KAAE,gBAAgB;AAClB,WAAQ;;;AAIZ,QACE,oBAAC;EACC,WAAW,GACT,oHACA,iBACE,iJACF,UACD;EACD,UAAU,gBAAgB,IAAI;EAC9B,aAAW,gBAAgB,eAAe,iBAAiB;EAC3D,SAAS;EACT,WAAW;EACX,GAAI;YAEJ,qBAAC;GAAK,WAAU;cACb,UACA,YAAY,oBAAC,YAAS,WAAW,gBAAiB;IAC9C;GACJ;;AAIT,UAAU,cAAc;AAQxB,MAAM,aAAa,EAAE,WAAW,GAAG,YAA4B;AAC7D,QACE,oBAAC;EACC,WAAW,GACT,wFACA,UACD;EACD,GAAI;GACJ;;AAIN,UAAU,cAAc;AAUxB,MAAM,gBAAgB,EACpB,WACA,WAAW,UACX,GAAG,YACoB;AACvB,QACE,oBAAC;EACC,WAAW,GACT,sCACA,aAAa,SAAS,yBACtB,UACD;EACD,GAAI;GACJ;;AAIN,aAAa,cAAc"}
@@ -0,0 +1,17 @@
1
+ //#region src/components/table/sort.ts
2
+ function compareValues(a, b, direction) {
3
+ if (a == null && b == null) return 0;
4
+ if (a == null) return 1;
5
+ if (b == null) return -1;
6
+ const multiplier = direction === "asc" ? 1 : -1;
7
+ if (typeof a === "number" && typeof b === "number") return (a - b) * multiplier;
8
+ if (typeof a === "boolean" && typeof b === "boolean") return (Number(a) - Number(b)) * multiplier;
9
+ if (a instanceof Date && b instanceof Date) return (a.getTime() - b.getTime()) * multiplier;
10
+ const strA = String(a).toLowerCase();
11
+ const strB = String(b).toLowerCase();
12
+ return strA.localeCompare(strB) * multiplier;
13
+ }
14
+
15
+ //#endregion
16
+ export { compareValues };
17
+ //# sourceMappingURL=sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort.js","names":[],"sources":["../../../src/components/table/sort.ts"],"sourcesContent":["import type { SortDirection } from './types'\n\nexport function compareValues(a: unknown, b: unknown, direction: SortDirection): number {\n // Nulls always sort to end regardless of direction\n if (a == null && b == null) return 0\n if (a == null) return 1\n if (b == null) return -1\n\n const multiplier = direction === 'asc' ? 1 : -1\n\n // Number comparison\n if (typeof a === 'number' && typeof b === 'number') {\n return (a - b) * multiplier\n }\n\n // Boolean comparison (true > false)\n if (typeof a === 'boolean' && typeof b === 'boolean') {\n return (Number(a) - Number(b)) * multiplier\n }\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return (a.getTime() - b.getTime()) * multiplier\n }\n\n // String comparison (case-insensitive)\n const strA = String(a).toLowerCase()\n const strB = String(b).toLowerCase()\n return strA.localeCompare(strB) * multiplier\n}\n"],"mappings":";AAEA,SAAgB,cAAc,GAAY,GAAY,WAAkC;AAEtF,KAAI,KAAK,QAAQ,KAAK,KAAM,QAAO;AACnC,KAAI,KAAK,KAAM,QAAO;AACtB,KAAI,KAAK,KAAM,QAAO;CAEtB,MAAM,aAAa,cAAc,QAAQ,IAAI;AAG7C,KAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SACxC,SAAQ,IAAI,KAAK;AAInB,KAAI,OAAO,MAAM,aAAa,OAAO,MAAM,UACzC,SAAQ,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI;AAInC,KAAI,aAAa,QAAQ,aAAa,KACpC,SAAQ,EAAE,SAAS,GAAG,EAAE,SAAS,IAAI;CAIvC,MAAM,OAAO,OAAO,EAAE,CAAC,aAAa;CACpC,MAAM,OAAO,OAAO,EAAE,CAAC,aAAa;AACpC,QAAO,KAAK,cAAc,KAAK,GAAG"}
@@ -0,0 +1,101 @@
1
+ import { CSSProperties, ReactNode } from "react";
2
+
3
+ //#region src/components/table/types.d.ts
4
+ type SortDirection = 'asc' | 'desc';
5
+ interface ColumnDef<T, K extends keyof T = keyof T> {
6
+ key: K;
7
+ header: ReactNode;
8
+ format?: (value: T[K], row: T) => string;
9
+ cell?: (value: T[K], row: T) => ReactNode;
10
+ className?: string;
11
+ headerClassName?: string;
12
+ cellClassName?: string;
13
+ width?: string | number;
14
+ sortable?: boolean;
15
+ }
16
+ interface PaginationConfig {
17
+ pageSize: number;
18
+ pageSizeOptions?: number[];
19
+ }
20
+ interface SearchConfig<T> {
21
+ keys: (keyof T)[];
22
+ }
23
+ type FilterPredicate<T, V = unknown> = (row: T, value: V) => boolean;
24
+ interface FilterDef<T, V = unknown> {
25
+ predicate: FilterPredicate<T, V>;
26
+ defaultValue?: V;
27
+ }
28
+ type FiltersConfig<T> = Record<string, FilterDef<T, any>>;
29
+ type FilterValues = Record<string, unknown>;
30
+ type RowKeyGetter<T> = (row: T) => string | number;
31
+ interface SelectionConfig<T> {
32
+ rowKey: RowKeyGetter<T>;
33
+ defaultSelectedKeys?: (string | number)[];
34
+ selectedKeys?: (string | number)[];
35
+ onSelectionChange?: (keys: (string | number)[]) => void;
36
+ }
37
+ interface SelectionState<T> {
38
+ selectedKeys: (string | number)[];
39
+ selectedCount: number;
40
+ isSelected: (key: string | number) => boolean;
41
+ toggleRow: (key: string | number) => void;
42
+ isRowSelected: (row: T) => boolean;
43
+ toggleRowSelection: (row: T) => void;
44
+ toggleAllOnPage: () => void;
45
+ clearSelection: () => void;
46
+ pageSelectionState: 'all' | 'some' | 'none';
47
+ isIndeterminate: boolean;
48
+ isAllOnPageSelected: boolean;
49
+ }
50
+ interface UseTableOptions<T> {
51
+ data: T[];
52
+ columns: ColumnDef<T, keyof T>[];
53
+ pagination?: PaginationConfig;
54
+ sort?: {
55
+ key: keyof T;
56
+ direction: SortDirection;
57
+ };
58
+ search?: SearchConfig<T>;
59
+ filters?: FiltersConfig<T>;
60
+ selection?: SelectionConfig<T>;
61
+ }
62
+ interface ProcessedColumn<T> {
63
+ key: keyof T;
64
+ head: {
65
+ children: ReactNode;
66
+ className?: string;
67
+ style?: CSSProperties;
68
+ sortable: boolean;
69
+ sortDirection?: SortDirection;
70
+ onSort?: () => void;
71
+ };
72
+ cell: {
73
+ className?: string;
74
+ };
75
+ renderCell: (row: T) => ReactNode;
76
+ }
77
+ interface UseTableReturn<T> {
78
+ columns: ProcessedColumn<T>[];
79
+ rows: T[];
80
+ totalItems: number;
81
+ currentPage: number;
82
+ totalPages: number;
83
+ pageSize: number;
84
+ pageSizeOptions: number[];
85
+ onPageChange: (page: number) => void;
86
+ onPageSizeChange: (size: number) => void;
87
+ sortKey: keyof T | null;
88
+ sortDirection: SortDirection;
89
+ onSort: (key: keyof T) => void;
90
+ searchTerm: string;
91
+ onSearchChange: (term: string) => void;
92
+ filterValues: FilterValues;
93
+ setFilterValue: (filterId: string, value: unknown) => void;
94
+ clearFilters: () => void;
95
+ activeFilterCount: number;
96
+ selection?: SelectionState<T>;
97
+ }
98
+ //# sourceMappingURL=types.d.ts.map
99
+ //#endregion
100
+ export { ColumnDef, FilterDef, FilterPredicate, FilterValues, FiltersConfig, PaginationConfig, ProcessedColumn, RowKeyGetter, SearchConfig, SelectionConfig, SelectionState, SortDirection, UseTableOptions, UseTableReturn };
101
+ //# sourceMappingURL=types.d.ts.map