@rockshin/tao-ui 0.0.2 → 0.0.4

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 (49) hide show
  1. package/dist/components/breadcrumb/breadcrumb.css +2 -976
  2. package/dist/components/button/button.css +2 -976
  3. package/dist/components/checkbox/checkbox.css +3 -976
  4. package/dist/components/collapsible/collapsible.css +2 -976
  5. package/dist/components/context-menu/context-menu.css +1 -1141
  6. package/dist/components/context-menu/context-menu.js +10 -8
  7. package/dist/components/date-picker/calendar/month-grid.d.ts +1 -1
  8. package/dist/components/date-picker/calendar/time-panel.d.ts +1 -1
  9. package/dist/components/date-picker/calendar/year-grid.d.ts +1 -1
  10. package/dist/components/date-picker/date-picker.css +23 -1147
  11. package/dist/components/date-picker/date-picker.js +9 -7
  12. package/dist/components/date-picker/range-picker.js +9 -7
  13. package/dist/components/drawer/drawer.css +29 -1006
  14. package/dist/components/drawer/drawer.js +27 -18
  15. package/dist/components/dropdown/dropdown.css +0 -975
  16. package/dist/components/dropdown/dropdown.js +17 -15
  17. package/dist/components/form-field/form.css +4 -977
  18. package/dist/components/input/input.css +0 -1134
  19. package/dist/components/menu/menu-render.js +11 -8
  20. package/dist/components/menu/menu.css +4 -978
  21. package/dist/components/modal/modal.css +7 -981
  22. package/dist/components/modal/modal.js +27 -18
  23. package/dist/components/pagination/pagination.css +4 -977
  24. package/dist/components/pagination/pagination.js +3 -1
  25. package/dist/components/radio/radio.css +4 -977
  26. package/dist/components/scroll-area/scroll-area.css +11 -981
  27. package/dist/components/select/mobile-select.css +9 -976
  28. package/dist/components/select/mobile-select.d.ts +4 -1
  29. package/dist/components/select/mobile-select.js +103 -121
  30. package/dist/components/select/select.css +31 -1150
  31. package/dist/components/select/select.d.ts +58 -4
  32. package/dist/components/select/select.js +356 -410
  33. package/dist/components/spinner/spinner.css +97 -0
  34. package/dist/components/spinner/spinner.d.ts +26 -0
  35. package/dist/components/spinner/spinner.js +229 -0
  36. package/dist/components/splitter/splitter.css +7 -978
  37. package/dist/components/switch/switch.css +8 -981
  38. package/dist/components/table/table.css +13 -992
  39. package/dist/components/tabs/tabs.css +4 -977
  40. package/dist/components/tag/tag.css +6 -977
  41. package/dist/components/textarea/textarea.css +0 -1134
  42. package/dist/index.d.ts +32 -29
  43. package/dist/index.js +6 -3
  44. package/dist/layouts/stack/layout.css +0 -975
  45. package/dist/provider/tao-provider.d.ts +17 -1
  46. package/dist/provider/tao-provider.js +53 -15
  47. package/dist/theme/control.css +35 -983
  48. package/dist/theme/theme.css +74 -902
  49. package/package.json +13 -16
@@ -9,9 +9,12 @@ interface MobileSelectContentProps {
9
9
  showSearch?: boolean;
10
10
  filterOption?: (input: string, option: SelectOption) => boolean;
11
11
  notFoundContent?: ReactNode;
12
+ optionRender?: (option: SelectOption, info: {
13
+ index: number;
14
+ }) => ReactNode;
12
15
  onClose: () => void;
13
16
  }
14
- export declare function MobileSelectContent({ options, value, onChange, showSearch, filterOption, notFoundContent, onClose, }: MobileSelectContentProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function MobileSelectContent({ options, value, onChange, showSearch, filterOption, notFoundContent, optionRender, onClose, }: MobileSelectContentProps): import("react/jsx-runtime").JSX.Element;
15
18
  export interface MobileSelectDrawerProps extends MobileSelectContentProps {
16
19
  open: boolean;
17
20
  }
@@ -1,140 +1,122 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
- import { useState } from "react";
3
+ import { useCallback, useMemo, useState } from "react";
4
4
  import { Drawer } from "../drawer/drawer.js";
5
5
  import "./mobile-select.css";
6
6
  const defaultFilter = (input, option)=>{
7
7
  const label = 'string' == typeof option.label ? option.label : String(option.label);
8
8
  return label.toLowerCase().includes(input.toLowerCase());
9
9
  };
10
- function MobileSelectContent(t0) {
11
- const $ = c(23);
12
- const { options, value, onChange, showSearch, filterOption, notFoundContent: t1, onClose } = t0;
13
- const notFoundContent = void 0 === t1 ? "No results" : t1;
14
- const [search, setSearch] = useState("");
15
- let t2;
16
- bb0: {
17
- if (!showSearch || !search) {
18
- t2 = options;
19
- break bb0;
20
- }
10
+ function filterTree(options, fn, input) {
11
+ const result = [];
12
+ for (const o of options)if (o.options) {
13
+ const kids = filterTree(o.options, fn, input);
14
+ if (kids.length) result.push({
15
+ ...o,
16
+ options: kids
17
+ });
18
+ } else if (fn(input, o)) result.push(o);
19
+ return result;
20
+ }
21
+ function countLeaves(options) {
22
+ return options.reduce((n, o)=>n + (o.options ? countLeaves(o.options) : 1), 0);
23
+ }
24
+ function MobileSelectContent({ options, value, onChange, showSearch, filterOption, notFoundContent = 'No results', optionRender, onClose }) {
25
+ const [search, setSearch] = useState('');
26
+ const filteredOptions = useMemo(()=>{
27
+ if (!showSearch || !search) return options;
21
28
  const fn = filterOption ?? defaultFilter;
22
- let t3;
23
- if ($[0] !== fn || $[1] !== options || $[2] !== search) {
24
- let t4;
25
- if ($[4] !== fn || $[5] !== search) {
26
- t4 = (o)=>fn(search, o);
27
- $[4] = fn;
28
- $[5] = search;
29
- $[6] = t4;
30
- } else t4 = $[6];
31
- t3 = options.filter(t4);
32
- $[0] = fn;
33
- $[1] = options;
34
- $[2] = search;
35
- $[3] = t3;
36
- } else t3 = $[3];
37
- t2 = t3;
38
- }
39
- const filteredOptions = t2;
40
- let t3;
41
- if ($[7] !== onChange || $[8] !== onClose) {
42
- t3 = (optValue)=>{
43
- onChange?.(optValue);
44
- onClose();
45
- };
46
- $[7] = onChange;
47
- $[8] = onClose;
48
- $[9] = t3;
49
- } else t3 = $[9];
50
- const handleSelect = t3;
51
- let t4;
52
- if ($[10] !== search || $[11] !== showSearch) {
53
- t4 = showSearch && /*#__PURE__*/ jsxs("div", {
54
- "data-tao-sheet-search": "",
29
+ return filterTree(options, fn, search);
30
+ }, [
31
+ options,
32
+ search,
33
+ showSearch,
34
+ filterOption
35
+ ]);
36
+ const handleSelect = useCallback((optValue)=>{
37
+ onChange?.(optValue);
38
+ onClose();
39
+ }, [
40
+ onChange,
41
+ onClose
42
+ ]);
43
+ let optIndex = 0;
44
+ const renderItem = (opt)=>{
45
+ const index = optIndex++;
46
+ const isSelected = opt.value === value;
47
+ return /*#__PURE__*/ jsxs("div", {
48
+ "data-tao-sheet-item": "",
49
+ "data-tao-selected": isSelected || void 0,
50
+ "data-tao-disabled": opt.disabled || void 0,
51
+ onClick: ()=>{
52
+ if (!opt.disabled) handleSelect(opt.value);
53
+ },
54
+ "data-tao-has-desc": null != opt.description || void 0,
55
55
  children: [
56
- /*#__PURE__*/ jsx(SearchIcon, {}),
57
- /*#__PURE__*/ jsx("input", {
58
- "data-tao-sheet-search-input": "",
59
- value: search,
60
- onChange: (e)=>setSearch(e.target.value),
61
- placeholder: "Search...",
62
- autoFocus: true
56
+ optionRender ? optionRender(opt, {
57
+ index
58
+ }) : /*#__PURE__*/ jsxs(Fragment, {
59
+ children: [
60
+ null != opt.icon && /*#__PURE__*/ jsx("span", {
61
+ "data-tao-sheet-item-icon": "",
62
+ children: opt.icon
63
+ }),
64
+ /*#__PURE__*/ jsxs("span", {
65
+ "data-tao-sheet-item-main": "",
66
+ children: [
67
+ /*#__PURE__*/ jsx("span", {
68
+ "data-tao-sheet-item-label": "",
69
+ children: opt.label
70
+ }),
71
+ null != opt.description && /*#__PURE__*/ jsx("span", {
72
+ "data-tao-sheet-item-desc": "",
73
+ children: opt.description
74
+ })
75
+ ]
76
+ })
77
+ ]
78
+ }),
79
+ isSelected && /*#__PURE__*/ jsx("span", {
80
+ "data-tao-sheet-item-check": "",
81
+ children: /*#__PURE__*/ jsx(CheckIcon, {})
63
82
  })
64
83
  ]
65
- });
66
- $[10] = search;
67
- $[11] = showSearch;
68
- $[12] = t4;
69
- } else t4 = $[12];
70
- let t5;
71
- if ($[13] !== filteredOptions || $[14] !== handleSelect || $[15] !== notFoundContent || $[16] !== value) {
72
- t5 = filteredOptions.length > 0 ? filteredOptions.map((opt)=>{
73
- const isSelected = opt.value === value;
74
- return /*#__PURE__*/ jsxs("div", {
75
- "data-tao-sheet-item": "",
76
- "data-tao-selected": isSelected || void 0,
77
- "data-tao-disabled": opt.disabled || void 0,
78
- onClick: ()=>{
79
- if (!opt.disabled) handleSelect(opt.value);
80
- },
81
- "data-tao-has-desc": null != opt.description || void 0,
84
+ }, opt.value);
85
+ };
86
+ const renderTree = (opts)=>opts.map((o)=>o.options ? /*#__PURE__*/ jsxs("div", {
87
+ "data-tao-sheet-group": "",
82
88
  children: [
83
- null != opt.icon && /*#__PURE__*/ jsx("span", {
84
- "data-tao-sheet-item-icon": "",
85
- children: opt.icon
86
- }),
87
- /*#__PURE__*/ jsxs("span", {
88
- "data-tao-sheet-item-main": "",
89
- children: [
90
- /*#__PURE__*/ jsx("span", {
91
- "data-tao-sheet-item-label": "",
92
- children: opt.label
93
- }),
94
- null != opt.description && /*#__PURE__*/ jsx("span", {
95
- "data-tao-sheet-item-desc": "",
96
- children: opt.description
97
- })
98
- ]
89
+ /*#__PURE__*/ jsx("div", {
90
+ "data-tao-sheet-group-label": "",
91
+ children: o.label
99
92
  }),
100
- isSelected && /*#__PURE__*/ jsx("span", {
101
- "data-tao-sheet-item-check": "",
102
- children: /*#__PURE__*/ jsx(CheckIcon, {})
93
+ o.options.map(renderItem)
94
+ ]
95
+ }, o.value) : renderItem(o));
96
+ return /*#__PURE__*/ jsxs(Fragment, {
97
+ children: [
98
+ showSearch && /*#__PURE__*/ jsxs("div", {
99
+ "data-tao-sheet-search": "",
100
+ children: [
101
+ /*#__PURE__*/ jsx(SearchIcon, {}),
102
+ /*#__PURE__*/ jsx("input", {
103
+ "data-tao-sheet-search-input": "",
104
+ value: search,
105
+ onChange: (e)=>setSearch(e.target.value),
106
+ placeholder: "Search...",
107
+ autoFocus: true
103
108
  })
104
109
  ]
105
- }, opt.value);
106
- }) : /*#__PURE__*/ jsx("div", {
107
- "data-tao-sheet-empty": "",
108
- children: notFoundContent
109
- });
110
- $[13] = filteredOptions;
111
- $[14] = handleSelect;
112
- $[15] = notFoundContent;
113
- $[16] = value;
114
- $[17] = t5;
115
- } else t5 = $[17];
116
- let t6;
117
- if ($[18] !== t5) {
118
- t6 = /*#__PURE__*/ jsx("div", {
119
- "data-tao-sheet-list": "",
120
- children: t5
121
- });
122
- $[18] = t5;
123
- $[19] = t6;
124
- } else t6 = $[19];
125
- let t7;
126
- if ($[20] !== t4 || $[21] !== t6) {
127
- t7 = /*#__PURE__*/ jsxs(Fragment, {
128
- children: [
129
- t4,
130
- t6
131
- ]
132
- });
133
- $[20] = t4;
134
- $[21] = t6;
135
- $[22] = t7;
136
- } else t7 = $[22];
137
- return t7;
110
+ }),
111
+ /*#__PURE__*/ jsx("div", {
112
+ "data-tao-sheet-list": "",
113
+ children: countLeaves(filteredOptions) > 0 ? renderTree(filteredOptions) : /*#__PURE__*/ jsx("div", {
114
+ "data-tao-sheet-empty": "",
115
+ children: notFoundContent
116
+ })
117
+ })
118
+ ]
119
+ });
138
120
  }
139
121
  function MobileSelectDrawer(t0) {
140
122
  const $ = c(14);