@rockshin/tao-ui 0.0.21 → 0.0.23

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 (105) hide show
  1. package/README.md +8 -1
  2. package/component-manifest.json +77 -48
  3. package/dist/components/button/button.css +11 -11
  4. package/dist/components/button/button.d.ts +3 -2
  5. package/dist/components/button/button.js +55 -47
  6. package/dist/components/checkbox/checkbox.d.ts +3 -2
  7. package/dist/components/checkbox/checkbox.js +91 -81
  8. package/dist/components/date-picker/calendar/calendar-grid.d.ts +7 -1
  9. package/dist/components/date-picker/calendar/calendar-grid.js +158 -160
  10. package/dist/components/date-picker/calendar/time-panel.js +64 -70
  11. package/dist/components/date-picker/date-picker.css +11 -5
  12. package/dist/components/date-picker/date-picker.d.ts +13 -5
  13. package/dist/components/date-picker/date-picker.js +389 -718
  14. package/dist/components/date-picker/range-picker.d.ts +12 -5
  15. package/dist/components/date-picker/range-picker.js +68 -12
  16. package/dist/components/date-picker/types.d.ts +5 -0
  17. package/dist/components/drawer/drawer.css +3 -1
  18. package/dist/components/form-field/form-field.d.ts +1 -1
  19. package/dist/components/form-field/form-field.js +106 -63
  20. package/dist/components/input/input.css +13 -0
  21. package/dist/components/input/input.d.ts +2 -1
  22. package/dist/components/input/input.js +76 -70
  23. package/dist/components/input-number/input-number.d.ts +5 -3
  24. package/dist/components/input-number/input-number.js +63 -47
  25. package/dist/components/modal/modal.css +2 -1
  26. package/dist/components/radio/radio.d.ts +3 -2
  27. package/dist/components/radio/radio.js +43 -39
  28. package/dist/components/select/mobile-select.d.ts +1 -1
  29. package/dist/components/select/mobile-select.js +1 -1
  30. package/dist/components/select/select-icons.d.ts +7 -0
  31. package/dist/components/select/select-icons.js +141 -0
  32. package/dist/components/select/select-model.d.ts +4 -0
  33. package/dist/components/select/select-model.js +22 -0
  34. package/dist/components/select/select-searchable-list.d.ts +22 -0
  35. package/dist/components/select/select-searchable-list.js +101 -0
  36. package/dist/components/select/select-tags.d.ts +15 -0
  37. package/dist/components/select/select-tags.js +152 -0
  38. package/dist/components/select/select-types.d.ts +82 -0
  39. package/dist/components/select/select-types.js +0 -0
  40. package/dist/components/select/select.css +2 -1
  41. package/dist/components/select/select.d.ts +2 -118
  42. package/dist/components/select/select.js +91 -404
  43. package/dist/components/select/use-is-mobile.js +2 -5
  44. package/dist/components/sonner/sonner.js +9 -3
  45. package/dist/components/spinner/spinner.css +1 -1
  46. package/dist/components/splitter/splitter.js +181 -133
  47. package/dist/components/switch/switch.css +17 -8
  48. package/dist/components/switch/switch.d.ts +3 -2
  49. package/dist/components/switch/switch.js +90 -79
  50. package/dist/components/table/table-filter.d.ts +6 -0
  51. package/dist/components/table/table-filter.js +123 -0
  52. package/dist/components/table/table-icons.d.ts +9 -0
  53. package/dist/components/table/table-icons.js +157 -0
  54. package/dist/components/table/table-model.d.ts +11 -0
  55. package/dist/components/table/table-model.js +33 -0
  56. package/dist/components/table/table-types.d.ts +87 -0
  57. package/dist/components/table/table-types.js +0 -0
  58. package/dist/components/table/table.css +14 -15
  59. package/dist/components/table/table.d.ts +3 -101
  60. package/dist/components/table/table.js +29 -329
  61. package/dist/components/tabs/tabs.css +5 -2
  62. package/dist/components/tabs/tabs.js +71 -62
  63. package/dist/components/textarea/textarea.d.ts +5 -3
  64. package/dist/components/textarea/textarea.js +102 -85
  65. package/dist/docs/component-docs.d.ts +1 -0
  66. package/dist/docs/components/breadcrumb.doc.js +3 -1
  67. package/dist/docs/components/checkbox.doc.js +2 -5
  68. package/dist/docs/components/context-menu.doc.js +7 -2
  69. package/dist/docs/components/drawer.doc.js +4 -2
  70. package/dist/docs/components/dropdown.doc.js +7 -3
  71. package/dist/docs/components/form-field.doc.js +0 -1
  72. package/dist/docs/components/form-layout.doc.d.ts +1 -0
  73. package/dist/docs/components/form-layout.doc.js +3 -0
  74. package/dist/docs/components/form-section.doc.js +1 -1
  75. package/dist/docs/components/input-number.doc.js +2 -3
  76. package/dist/docs/components/input.doc.js +1 -2
  77. package/dist/docs/components/modal.doc.js +1 -1
  78. package/dist/docs/components/pagination.doc.js +1 -3
  79. package/dist/docs/components/radio.doc.js +1 -4
  80. package/dist/docs/components/range-picker.doc.js +2 -2
  81. package/dist/docs/components/select.doc.js +19 -6
  82. package/dist/docs/components/spinner.doc.js +4 -1
  83. package/dist/docs/components/splitter.doc.js +1 -1
  84. package/dist/docs/components/stack.doc.d.ts +1 -0
  85. package/dist/docs/components/stack.doc.js +3 -0
  86. package/dist/docs/components/switch.doc.js +1 -2
  87. package/dist/docs/components/table.doc.js +9 -4
  88. package/dist/docs/components/tabs.doc.js +2 -1
  89. package/dist/docs/components/tag.doc.js +1 -0
  90. package/dist/docs/components/tao-provider.doc.js +1 -2
  91. package/dist/index.d.ts +7 -9
  92. package/dist/index.js +4 -5
  93. package/dist/layouts/form-layout/form-layout.d.ts +8 -2
  94. package/dist/layouts/form-layout/form-layout.js +33 -9
  95. package/dist/layouts/stack/stack.d.ts +8 -2
  96. package/dist/layouts/stack/stack.js +36 -12
  97. package/dist/provider/tao-provider.d.ts +3 -9
  98. package/dist/provider/tao-provider.js +99 -33
  99. package/dist/theme/theme.css +24 -14
  100. package/dist/theme/tokens.d.ts +2 -2
  101. package/dist/theme/tokens.js +4 -1
  102. package/dist/utils/refs.d.ts +2 -0
  103. package/dist/utils/refs.js +7 -0
  104. package/llms.txt +26 -24
  105. package/package.json +16 -4
@@ -1,125 +1,136 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
+ import { useState } from "react";
3
4
  import { useTaoConfig } from "../../provider/tao-provider.js";
4
5
  import { cx } from "../../utils/semantic.js";
5
6
  import "./switch.css";
6
7
  function Switch(t0) {
7
- const $ = c(32);
8
- const { checked, onChange, disabled, loading, size: t1, checkedChildren, unCheckedChildren, className, style, classNames, styles } = t0;
8
+ const $ = c(34);
9
+ const { checked, defaultChecked, onChange, disabled, loading, size: t1, checkedChildren, unCheckedChildren, className, style, classNames, styles, ref } = t0;
9
10
  const size = void 0 === t1 ? "medium" : t1;
10
11
  const ctx = useTaoConfig();
11
12
  const resolvedDisabled = disabled ?? ctx.disabled ?? false;
12
13
  const isDisabled = resolvedDisabled || loading;
13
- const t2 = !!checked;
14
+ const controlled = void 0 !== checked;
15
+ const [internalChecked, setInternalChecked] = useState(defaultChecked ?? false);
16
+ const resolvedChecked = controlled ? checked : internalChecked;
17
+ let t2;
18
+ if ($[0] !== controlled || $[1] !== onChange || $[2] !== resolvedChecked) {
19
+ t2 = ()=>{
20
+ const next = !resolvedChecked;
21
+ if (!controlled) setInternalChecked(next);
22
+ onChange?.(next);
23
+ };
24
+ $[0] = controlled;
25
+ $[1] = onChange;
26
+ $[2] = resolvedChecked;
27
+ $[3] = t2;
28
+ } else t2 = $[3];
29
+ const handleChange = t2;
14
30
  const t3 = classNames?.root;
15
31
  let t4;
16
- if ($[0] !== className || $[1] !== t3) {
32
+ if ($[4] !== className || $[5] !== t3) {
17
33
  t4 = cx(t3, className);
18
- $[0] = className;
19
- $[1] = t3;
20
- $[2] = t4;
21
- } else t4 = $[2];
34
+ $[4] = className;
35
+ $[5] = t3;
36
+ $[6] = t4;
37
+ } else t4 = $[6];
22
38
  const t5 = styles?.root;
23
39
  let t6;
24
- if ($[3] !== style || $[4] !== t5) {
40
+ if ($[7] !== style || $[8] !== t5) {
25
41
  t6 = {
26
42
  ...t5,
27
43
  ...style
28
44
  };
29
- $[3] = style;
30
- $[4] = t5;
31
- $[5] = t6;
32
- } else t6 = $[5];
33
- const t7 = checked || void 0;
34
- let t8;
35
- if ($[6] !== checked || $[7] !== onChange) {
36
- t8 = ()=>onChange?.(!checked);
37
- $[6] = checked;
38
- $[7] = onChange;
39
- $[8] = t8;
40
- } else t8 = $[8];
41
- const t9 = classNames?.handle;
42
- const t10 = styles?.handle;
45
+ $[7] = style;
46
+ $[8] = t5;
47
+ $[9] = t6;
48
+ } else t6 = $[9];
49
+ const t7 = resolvedChecked || void 0;
50
+ const t8 = classNames?.handle;
51
+ const t9 = styles?.handle;
52
+ let t10;
53
+ if ($[10] !== loading) {
54
+ t10 = loading && /*#__PURE__*/ jsx(LoadingIcon, {});
55
+ $[10] = loading;
56
+ $[11] = t10;
57
+ } else t10 = $[11];
43
58
  let t11;
44
- if ($[9] !== loading) {
45
- t11 = loading && /*#__PURE__*/ jsx(LoadingIcon, {});
46
- $[9] = loading;
47
- $[10] = t11;
48
- } else t11 = $[10];
49
- let t12;
50
- if ($[11] !== t10 || $[12] !== t11 || $[13] !== t9) {
51
- t12 = /*#__PURE__*/ jsx("div", {
52
- className: t9,
53
- style: t10,
59
+ if ($[12] !== t10 || $[13] !== t8 || $[14] !== t9) {
60
+ t11 = /*#__PURE__*/ jsx("div", {
61
+ className: t8,
62
+ style: t9,
54
63
  "data-tao-switch-handle": "",
55
- children: t11
64
+ children: t10
56
65
  });
57
- $[11] = t10;
58
- $[12] = t11;
59
- $[13] = t9;
60
- $[14] = t12;
61
- } else t12 = $[14];
62
- let t13;
63
- if ($[15] !== checkedChildren) {
64
- t13 = /*#__PURE__*/ jsx("span", {
66
+ $[12] = t10;
67
+ $[13] = t8;
68
+ $[14] = t9;
69
+ $[15] = t11;
70
+ } else t11 = $[15];
71
+ let t12;
72
+ if ($[16] !== checkedChildren) {
73
+ t12 = /*#__PURE__*/ jsx("span", {
65
74
  "data-tao-switch-inner-checked": "",
66
75
  children: checkedChildren
67
76
  });
68
- $[15] = checkedChildren;
69
- $[16] = t13;
70
- } else t13 = $[16];
71
- let t14;
72
- if ($[17] !== unCheckedChildren) {
73
- t14 = /*#__PURE__*/ jsx("span", {
77
+ $[16] = checkedChildren;
78
+ $[17] = t12;
79
+ } else t12 = $[17];
80
+ let t13;
81
+ if ($[18] !== unCheckedChildren) {
82
+ t13 = /*#__PURE__*/ jsx("span", {
74
83
  "data-tao-switch-inner-unchecked": "",
75
84
  children: unCheckedChildren
76
85
  });
77
- $[17] = unCheckedChildren;
78
- $[18] = t14;
79
- } else t14 = $[18];
80
- let t15;
81
- if ($[19] !== t13 || $[20] !== t14) {
82
- t15 = /*#__PURE__*/ jsxs("span", {
86
+ $[18] = unCheckedChildren;
87
+ $[19] = t13;
88
+ } else t13 = $[19];
89
+ let t14;
90
+ if ($[20] !== t12 || $[21] !== t13) {
91
+ t14 = /*#__PURE__*/ jsxs("span", {
83
92
  "data-tao-switch-inner": "",
84
93
  children: [
85
- t13,
86
- t14
94
+ t12,
95
+ t13
87
96
  ]
88
97
  });
89
- $[19] = t13;
90
- $[20] = t14;
91
- $[21] = t15;
92
- } else t15 = $[21];
93
- let t16;
94
- if ($[22] !== isDisabled || $[23] !== size || $[24] !== t12 || $[25] !== t15 || $[26] !== t2 || $[27] !== t4 || $[28] !== t6 || $[29] !== t7 || $[30] !== t8) {
95
- t16 = /*#__PURE__*/ jsxs("button", {
98
+ $[20] = t12;
99
+ $[21] = t13;
100
+ $[22] = t14;
101
+ } else t14 = $[22];
102
+ let t15;
103
+ if ($[23] !== handleChange || $[24] !== isDisabled || $[25] !== ref || $[26] !== resolvedChecked || $[27] !== size || $[28] !== t11 || $[29] !== t14 || $[30] !== t4 || $[31] !== t6 || $[32] !== t7) {
104
+ t15 = /*#__PURE__*/ jsxs("button", {
105
+ ref: ref,
96
106
  type: "button",
97
107
  role: "switch",
98
- "aria-checked": t2,
108
+ "aria-checked": resolvedChecked,
99
109
  disabled: isDisabled,
100
110
  className: t4,
101
111
  style: t6,
102
112
  "data-tao-switch": "",
103
113
  "data-tao-size": size,
104
114
  "data-tao-checked": t7,
105
- onClick: t8,
115
+ onClick: handleChange,
106
116
  children: [
107
- t12,
108
- t15
117
+ t11,
118
+ t14
109
119
  ]
110
120
  });
111
- $[22] = isDisabled;
112
- $[23] = size;
113
- $[24] = t12;
114
- $[25] = t15;
115
- $[26] = t2;
116
- $[27] = t4;
117
- $[28] = t6;
118
- $[29] = t7;
119
- $[30] = t8;
120
- $[31] = t16;
121
- } else t16 = $[31];
122
- return t16;
121
+ $[23] = handleChange;
122
+ $[24] = isDisabled;
123
+ $[25] = ref;
124
+ $[26] = resolvedChecked;
125
+ $[27] = size;
126
+ $[28] = t11;
127
+ $[29] = t14;
128
+ $[30] = t4;
129
+ $[31] = t6;
130
+ $[32] = t7;
131
+ $[33] = t15;
132
+ } else t15 = $[33];
133
+ return t15;
123
134
  }
124
135
  function LoadingIcon() {
125
136
  const $ = c(1);
@@ -0,0 +1,6 @@
1
+ import type { TableFilterItem } from './table-types';
2
+ export declare function TableFilterDropdown({ filters, activeValues, onSelect, }: {
3
+ filters: TableFilterItem[];
4
+ activeValues: string[];
5
+ onSelect: (values: string[]) => void;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,123 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { TaoPortalScope } from "../../provider/tao-provider.js";
4
+ import { CheckIcon, FilterIcon } from "./table-icons.js";
5
+ import * as __rspack_external__radix_ui_react_dropdown_menu_154a7470 from "@radix-ui/react-dropdown-menu";
6
+ function TableFilterDropdown(t0) {
7
+ const $ = c(21);
8
+ const { filters, activeValues, onSelect } = t0;
9
+ let t1;
10
+ if ($[0] !== activeValues || $[1] !== onSelect) {
11
+ t1 = (value)=>{
12
+ onSelect(activeValues.includes(value) ? activeValues.filter((item)=>item !== value) : [
13
+ ...activeValues,
14
+ value
15
+ ]);
16
+ };
17
+ $[0] = activeValues;
18
+ $[1] = onSelect;
19
+ $[2] = t1;
20
+ } else t1 = $[2];
21
+ const toggle = t1;
22
+ const t2 = activeValues.length > 0;
23
+ let t3;
24
+ if ($[3] !== t2) {
25
+ t3 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Trigger, {
26
+ asChild: true,
27
+ children: /*#__PURE__*/ jsx("button", {
28
+ type: "button",
29
+ "data-tao-table-filter-trigger": "",
30
+ "aria-label": "Filter",
31
+ children: /*#__PURE__*/ jsx(FilterIcon, {
32
+ active: t2
33
+ })
34
+ })
35
+ });
36
+ $[3] = t2;
37
+ $[4] = t3;
38
+ } else t3 = $[4];
39
+ let t4;
40
+ if ($[5] !== activeValues || $[6] !== filters || $[7] !== toggle) {
41
+ let t5;
42
+ if ($[9] !== activeValues || $[10] !== toggle) {
43
+ t5 = (filter)=>{
44
+ const checked = activeValues.includes(filter.value);
45
+ return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.CheckboxItem, {
46
+ checked: checked,
47
+ "data-tao-table-filter-option": "",
48
+ onCheckedChange: ()=>toggle(filter.value),
49
+ onSelect: _temp,
50
+ children: [
51
+ /*#__PURE__*/ jsx("span", {
52
+ "data-tao-table-filter-check": "",
53
+ "data-tao-checked": checked || void 0,
54
+ children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.ItemIndicator, {
55
+ children: /*#__PURE__*/ jsx(CheckIcon, {})
56
+ })
57
+ }),
58
+ /*#__PURE__*/ jsx("span", {
59
+ children: filter.text
60
+ })
61
+ ]
62
+ }, filter.value);
63
+ };
64
+ $[9] = activeValues;
65
+ $[10] = toggle;
66
+ $[11] = t5;
67
+ } else t5 = $[11];
68
+ t4 = filters.map(t5);
69
+ $[5] = activeValues;
70
+ $[6] = filters;
71
+ $[7] = toggle;
72
+ $[8] = t4;
73
+ } else t4 = $[8];
74
+ let t5;
75
+ if ($[12] !== activeValues.length || $[13] !== onSelect) {
76
+ t5 = activeValues.length > 0 && /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Item, {
77
+ "data-tao-table-filter-reset": "",
78
+ onSelect: ()=>onSelect([]),
79
+ children: "Reset"
80
+ });
81
+ $[12] = activeValues.length;
82
+ $[13] = onSelect;
83
+ $[14] = t5;
84
+ } else t5 = $[14];
85
+ let t6;
86
+ if ($[15] !== t4 || $[16] !== t5) {
87
+ t6 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Portal, {
88
+ children: /*#__PURE__*/ jsx(TaoPortalScope, {
89
+ asChild: true,
90
+ children: /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Content, {
91
+ "data-tao-table-filter-panel": "",
92
+ align: "end",
93
+ sideOffset: 4,
94
+ loop: true,
95
+ children: [
96
+ t4,
97
+ t5
98
+ ]
99
+ })
100
+ })
101
+ });
102
+ $[15] = t4;
103
+ $[16] = t5;
104
+ $[17] = t6;
105
+ } else t6 = $[17];
106
+ let t7;
107
+ if ($[18] !== t3 || $[19] !== t6) {
108
+ t7 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Root, {
109
+ children: [
110
+ t3,
111
+ t6
112
+ ]
113
+ });
114
+ $[18] = t3;
115
+ $[19] = t6;
116
+ $[20] = t7;
117
+ } else t7 = $[20];
118
+ return t7;
119
+ }
120
+ function _temp(event) {
121
+ return event.preventDefault();
122
+ }
123
+ export { TableFilterDropdown };
@@ -0,0 +1,9 @@
1
+ import type { SortOrder } from './table-types';
2
+ export declare function SortIcon({ order }: {
3
+ order: SortOrder;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ export declare function FilterIcon({ active }: {
6
+ active: boolean;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ export declare function TableLoadingSpinner(): import("react/jsx-runtime").JSX.Element;
9
+ export declare function CheckIcon(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,157 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ function SortIcon(t0) {
4
+ const $ = c(10);
5
+ const { order } = t0;
6
+ const t1 = order ?? void 0;
7
+ const t2 = "ascend" === order ? 1 : 0.3;
8
+ let t3;
9
+ if ($[0] !== t2) {
10
+ t3 = /*#__PURE__*/ jsx("path", {
11
+ d: "M7 2.5L10 6H4L7 2.5Z",
12
+ fill: "currentColor",
13
+ opacity: t2
14
+ });
15
+ $[0] = t2;
16
+ $[1] = t3;
17
+ } else t3 = $[1];
18
+ const t4 = "descend" === order ? 1 : 0.3;
19
+ let t5;
20
+ if ($[2] !== t4) {
21
+ t5 = /*#__PURE__*/ jsx("path", {
22
+ d: "M7 11.5L4 8H10L7 11.5Z",
23
+ fill: "currentColor",
24
+ opacity: t4
25
+ });
26
+ $[2] = t4;
27
+ $[3] = t5;
28
+ } else t5 = $[3];
29
+ let t6;
30
+ if ($[4] !== t3 || $[5] !== t5) {
31
+ t6 = /*#__PURE__*/ jsxs("svg", {
32
+ width: "14",
33
+ height: "14",
34
+ viewBox: "0 0 14 14",
35
+ fill: "none",
36
+ "aria-hidden": "true",
37
+ focusable: "false",
38
+ children: [
39
+ t3,
40
+ t5
41
+ ]
42
+ });
43
+ $[4] = t3;
44
+ $[5] = t5;
45
+ $[6] = t6;
46
+ } else t6 = $[6];
47
+ let t7;
48
+ if ($[7] !== t1 || $[8] !== t6) {
49
+ t7 = /*#__PURE__*/ jsx("span", {
50
+ "data-tao-table-sort-icon": "",
51
+ "data-tao-sort-order": t1,
52
+ children: t6
53
+ });
54
+ $[7] = t1;
55
+ $[8] = t6;
56
+ $[9] = t7;
57
+ } else t7 = $[9];
58
+ return t7;
59
+ }
60
+ function FilterIcon(t0) {
61
+ const $ = c(5);
62
+ const { active } = t0;
63
+ const t1 = active || void 0;
64
+ const t2 = active ? "currentColor" : "none";
65
+ let t3;
66
+ if ($[0] !== t2) {
67
+ t3 = /*#__PURE__*/ jsx("svg", {
68
+ width: "14",
69
+ height: "14",
70
+ viewBox: "0 0 14 14",
71
+ fill: "none",
72
+ "aria-hidden": "true",
73
+ focusable: "false",
74
+ children: /*#__PURE__*/ jsx("path", {
75
+ d: "M2 3h10L8.5 7.5V11L5.5 12V7.5L2 3Z",
76
+ stroke: "currentColor",
77
+ fill: t2,
78
+ strokeWidth: "1.2",
79
+ strokeLinejoin: "round"
80
+ })
81
+ });
82
+ $[0] = t2;
83
+ $[1] = t3;
84
+ } else t3 = $[1];
85
+ let t4;
86
+ if ($[2] !== t1 || $[3] !== t3) {
87
+ t4 = /*#__PURE__*/ jsx("span", {
88
+ "data-tao-table-filter-icon": "",
89
+ "data-tao-active": t1,
90
+ children: t3
91
+ });
92
+ $[2] = t1;
93
+ $[3] = t3;
94
+ $[4] = t4;
95
+ } else t4 = $[4];
96
+ return t4;
97
+ }
98
+ function TableLoadingSpinner() {
99
+ const $ = c(1);
100
+ let t0;
101
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
102
+ t0 = /*#__PURE__*/ jsx("div", {
103
+ "data-tao-table-loading": "",
104
+ children: /*#__PURE__*/ jsxs("svg", {
105
+ "data-tao-table-spinner": "",
106
+ width: "24",
107
+ height: "24",
108
+ viewBox: "0 0 24 24",
109
+ fill: "none",
110
+ "aria-hidden": "true",
111
+ focusable: "false",
112
+ children: [
113
+ /*#__PURE__*/ jsx("circle", {
114
+ cx: "12",
115
+ cy: "12",
116
+ r: "10",
117
+ stroke: "currentColor",
118
+ strokeWidth: "2.5",
119
+ opacity: "0.2"
120
+ }),
121
+ /*#__PURE__*/ jsx("path", {
122
+ d: "M12 2a10 10 0 019.8 8",
123
+ stroke: "currentColor",
124
+ strokeWidth: "2.5",
125
+ strokeLinecap: "round"
126
+ })
127
+ ]
128
+ })
129
+ });
130
+ $[0] = t0;
131
+ } else t0 = $[0];
132
+ return t0;
133
+ }
134
+ function CheckIcon() {
135
+ const $ = c(1);
136
+ let t0;
137
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
138
+ t0 = /*#__PURE__*/ jsx("svg", {
139
+ width: "12",
140
+ height: "12",
141
+ viewBox: "0 0 12 12",
142
+ fill: "none",
143
+ "aria-hidden": "true",
144
+ focusable: "false",
145
+ children: /*#__PURE__*/ jsx("path", {
146
+ d: "M2.5 6L5 8.5L9.5 3.5",
147
+ stroke: "currentColor",
148
+ strokeWidth: "1.5",
149
+ strokeLinecap: "round",
150
+ strokeLinejoin: "round"
151
+ })
152
+ });
153
+ $[0] = t0;
154
+ } else t0 = $[0];
155
+ return t0;
156
+ }
157
+ export { CheckIcon, FilterIcon, SortIcon, TableLoadingSpinner };
@@ -0,0 +1,11 @@
1
+ import type { CSSProperties, Key } from 'react';
2
+ import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic';
3
+ import type { SortOrder, TableColumn, TableProps, TableRecord, TableSemanticClassNames, TableSemanticPart, TableSemanticStyles } from './table-types';
4
+ export declare function getRowKey<T extends TableRecord>(record: T, rowKey: keyof T | ((record: T) => Key)): Key;
5
+ export declare function getColKey<T extends TableRecord>(col: TableColumn<T>, index: number): string;
6
+ export declare function getCellValue<T extends TableRecord>(record: T, dataIndex?: keyof T): unknown;
7
+ export declare function resolveSemanticClassNames<T extends TableRecord>(classNames: TableSemanticClassNames<T> | undefined, props: TableProps<T>): SemanticClassNames<TableSemanticPart>;
8
+ export declare function resolveSemanticStyles<T extends TableRecord>(styles: TableSemanticStyles<T> | undefined, props: TableProps<T>): SemanticStyles<TableSemanticPart>;
9
+ export declare function resolveRowClassName<T extends TableRecord>(rowClassName: TableProps<T>['rowClassName'], record: T, index: number): string | undefined;
10
+ export declare function resolveRowStyle<T extends TableRecord>(rowStyle: TableProps<T>['rowStyle'], record: T, index: number): CSSProperties | undefined;
11
+ export declare function nextSortOrder(current: SortOrder): SortOrder;
@@ -0,0 +1,33 @@
1
+ function getRowKey(record, rowKey) {
2
+ if ('function' == typeof rowKey) return rowKey(record);
3
+ return record[rowKey];
4
+ }
5
+ function getColKey(col, index) {
6
+ return col.key ?? (null == col.dataIndex ? String(index) : String(col.dataIndex));
7
+ }
8
+ function getCellValue(record, dataIndex) {
9
+ if (!dataIndex) return;
10
+ return record[dataIndex];
11
+ }
12
+ function resolveSemanticClassNames(classNames, props) {
13
+ return 'function' == typeof classNames ? classNames({
14
+ props
15
+ }) : classNames ?? {};
16
+ }
17
+ function resolveSemanticStyles(styles, props) {
18
+ return 'function' == typeof styles ? styles({
19
+ props
20
+ }) : styles ?? {};
21
+ }
22
+ function resolveRowClassName(rowClassName, record, index) {
23
+ return 'function' == typeof rowClassName ? rowClassName(record, index) : rowClassName;
24
+ }
25
+ function resolveRowStyle(rowStyle, record, index) {
26
+ return 'function' == typeof rowStyle ? rowStyle(record, index) : rowStyle;
27
+ }
28
+ function nextSortOrder(current) {
29
+ if ('ascend' === current) return 'descend';
30
+ if ('descend' === current) return null;
31
+ return 'ascend';
32
+ }
33
+ export { getCellValue, getColKey, getRowKey, nextSortOrder, resolveRowClassName, resolveRowStyle, resolveSemanticClassNames, resolveSemanticStyles };
@@ -0,0 +1,87 @@
1
+ import type { CSSProperties, HTMLAttributes, Key, ReactNode, TdHTMLAttributes, ThHTMLAttributes } from 'react';
2
+ import type { TaoSize, TaoVariant } from '../../provider/tao-provider';
3
+ import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic';
4
+ export type TableRecord = object;
5
+ export type TableSemanticPart = 'root' | 'scroll' | 'table' | 'header.wrapper' | 'header.row' | 'header.cell' | 'header.content' | 'header.title' | 'body.row' | 'body.cell' | 'selection.cell' | 'empty' | 'pagination';
6
+ export type TableVariant = TaoVariant | 'modern';
7
+ export type SortOrder = 'ascend' | 'descend' | null;
8
+ export interface TableFilterItem {
9
+ text: ReactNode;
10
+ value: string;
11
+ }
12
+ export interface TableColumn<T extends TableRecord = Record<string, unknown>> {
13
+ key?: string;
14
+ dataIndex?: keyof T;
15
+ title?: ReactNode;
16
+ render?: (value: unknown, record: T, index: number) => ReactNode;
17
+ width?: number | string;
18
+ align?: 'left' | 'center' | 'right';
19
+ fixed?: 'left' | 'right';
20
+ ellipsis?: boolean;
21
+ onCell?: (record: T, index: number) => TdHTMLAttributes<HTMLTableCellElement>;
22
+ onHeaderCell?: (column: TableColumn<T>) => ThHTMLAttributes<HTMLTableCellElement>;
23
+ sorter?: ((a: T, b: T) => number) | boolean;
24
+ sortOrder?: SortOrder;
25
+ defaultSortOrder?: SortOrder;
26
+ filters?: TableFilterItem[];
27
+ onFilter?: (value: string, record: T) => boolean;
28
+ filteredValue?: string[];
29
+ }
30
+ export interface TableRowSelection<T extends TableRecord = Record<string, unknown>> {
31
+ type?: 'checkbox' | 'radio';
32
+ selectedRowKeys?: Key[];
33
+ onChange?: (selectedKeys: Key[], selectedRows: T[]) => void;
34
+ getCheckboxProps?: (record: T) => {
35
+ disabled?: boolean;
36
+ };
37
+ fixed?: boolean;
38
+ columnWidth?: number | string;
39
+ }
40
+ export interface TablePagination {
41
+ current?: number;
42
+ pageSize?: number;
43
+ total?: number;
44
+ defaultCurrent?: number;
45
+ defaultPageSize?: number;
46
+ showSizeChanger?: boolean;
47
+ pageSizeOptions?: number[];
48
+ showTotal?: (total: number, range: [number, number]) => ReactNode;
49
+ }
50
+ export interface SorterResult<T extends TableRecord = Record<string, unknown>> {
51
+ column?: TableColumn<T>;
52
+ order: SortOrder;
53
+ field?: keyof T;
54
+ }
55
+ export type TableSemanticInfo<T extends TableRecord = Record<string, unknown>> = {
56
+ props: TableProps<T>;
57
+ };
58
+ export type TableSemanticClassNames<T extends TableRecord = Record<string, unknown>> = SemanticClassNames<TableSemanticPart> | ((info: TableSemanticInfo<T>) => SemanticClassNames<TableSemanticPart>);
59
+ export type TableSemanticStyles<T extends TableRecord = Record<string, unknown>> = SemanticStyles<TableSemanticPart> | ((info: TableSemanticInfo<T>) => SemanticStyles<TableSemanticPart>);
60
+ export interface TableProps<T extends TableRecord = Record<string, unknown>> {
61
+ columns: TableColumn<T>[];
62
+ dataSource: T[];
63
+ rowKey: keyof T | ((record: T) => Key);
64
+ loading?: boolean;
65
+ pagination?: TablePagination | false;
66
+ onChange?: (pagination: {
67
+ current: number;
68
+ pageSize: number;
69
+ }, filters: Record<string, string[] | null>, sorter: SorterResult<T>) => void;
70
+ scroll?: {
71
+ x?: number | string;
72
+ };
73
+ rowSelection?: TableRowSelection<T>;
74
+ rowClassName?: string | ((record: T, index: number) => string);
75
+ rowStyle?: CSSProperties | ((record: T, index: number) => CSSProperties);
76
+ onRow?: (record: T, index: number) => HTMLAttributes<HTMLTableRowElement>;
77
+ onHeaderRow?: (columns: TableColumn<T>[], index: number) => HTMLAttributes<HTMLTableRowElement>;
78
+ size?: TaoSize;
79
+ variant?: TableVariant;
80
+ headerBackground?: boolean;
81
+ emptyText?: ReactNode;
82
+ bordered?: boolean;
83
+ className?: string;
84
+ style?: CSSProperties;
85
+ classNames?: TableSemanticClassNames<T>;
86
+ styles?: TableSemanticStyles<T>;
87
+ }
File without changes