@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.
- package/dist/components/breadcrumb/breadcrumb.css +2 -976
- package/dist/components/button/button.css +2 -976
- package/dist/components/checkbox/checkbox.css +3 -976
- package/dist/components/collapsible/collapsible.css +2 -976
- package/dist/components/context-menu/context-menu.css +1 -1141
- package/dist/components/context-menu/context-menu.js +10 -8
- package/dist/components/date-picker/calendar/month-grid.d.ts +1 -1
- package/dist/components/date-picker/calendar/time-panel.d.ts +1 -1
- package/dist/components/date-picker/calendar/year-grid.d.ts +1 -1
- package/dist/components/date-picker/date-picker.css +23 -1147
- package/dist/components/date-picker/date-picker.js +9 -7
- package/dist/components/date-picker/range-picker.js +9 -7
- package/dist/components/drawer/drawer.css +29 -1006
- package/dist/components/drawer/drawer.js +27 -18
- package/dist/components/dropdown/dropdown.css +0 -975
- package/dist/components/dropdown/dropdown.js +17 -15
- package/dist/components/form-field/form.css +4 -977
- package/dist/components/input/input.css +0 -1134
- package/dist/components/menu/menu-render.js +11 -8
- package/dist/components/menu/menu.css +4 -978
- package/dist/components/modal/modal.css +7 -981
- package/dist/components/modal/modal.js +27 -18
- package/dist/components/pagination/pagination.css +4 -977
- package/dist/components/pagination/pagination.js +3 -1
- package/dist/components/radio/radio.css +4 -977
- package/dist/components/scroll-area/scroll-area.css +11 -981
- package/dist/components/select/mobile-select.css +9 -976
- package/dist/components/select/mobile-select.d.ts +4 -1
- package/dist/components/select/mobile-select.js +103 -121
- package/dist/components/select/select.css +31 -1150
- package/dist/components/select/select.d.ts +58 -4
- package/dist/components/select/select.js +356 -410
- package/dist/components/spinner/spinner.css +97 -0
- package/dist/components/spinner/spinner.d.ts +26 -0
- package/dist/components/spinner/spinner.js +229 -0
- package/dist/components/splitter/splitter.css +7 -978
- package/dist/components/switch/switch.css +8 -981
- package/dist/components/table/table.css +13 -992
- package/dist/components/tabs/tabs.css +4 -977
- package/dist/components/tag/tag.css +6 -977
- package/dist/components/textarea/textarea.css +0 -1134
- package/dist/index.d.ts +32 -29
- package/dist/index.js +6 -3
- package/dist/layouts/stack/layout.css +0 -975
- package/dist/provider/tao-provider.d.ts +17 -1
- package/dist/provider/tao-provider.js +53 -15
- package/dist/theme/control.css +35 -983
- package/dist/theme/theme.css +74 -902
- 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
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
84
|
-
"data-tao-sheet-
|
|
85
|
-
children:
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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);
|