@rockshin/tao-ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +65 -0
- package/dist/components/button/button.css +1055 -0
- package/dist/components/button/button.d.ts +15 -0
- package/dist/components/button/button.js +93 -0
- package/dist/components/checkbox/checkbox.css +1035 -0
- package/dist/components/checkbox/checkbox.d.ts +33 -0
- package/dist/components/checkbox/checkbox.js +312 -0
- package/dist/components/date-picker/calendar/calendar-grid.d.ts +18 -0
- package/dist/components/date-picker/calendar/calendar-grid.js +173 -0
- package/dist/components/date-picker/calendar/calendar-header.d.ts +10 -0
- package/dist/components/date-picker/calendar/calendar-header.js +336 -0
- package/dist/components/date-picker/calendar/month-grid.d.ts +9 -0
- package/dist/components/date-picker/calendar/month-grid.js +61 -0
- package/dist/components/date-picker/calendar/time-panel.d.ts +12 -0
- package/dist/components/date-picker/calendar/time-panel.js +233 -0
- package/dist/components/date-picker/calendar/use-calendar.d.ts +15 -0
- package/dist/components/date-picker/calendar/use-calendar.js +24 -0
- package/dist/components/date-picker/calendar/year-grid.d.ts +9 -0
- package/dist/components/date-picker/calendar/year-grid.js +60 -0
- package/dist/components/date-picker/date-picker.css +1799 -0
- package/dist/components/date-picker/date-picker.d.ts +29 -0
- package/dist/components/date-picker/date-picker.js +663 -0
- package/dist/components/date-picker/presets.d.ts +9 -0
- package/dist/components/date-picker/presets.js +36 -0
- package/dist/components/date-picker/range-picker.d.ts +30 -0
- package/dist/components/date-picker/range-picker.js +432 -0
- package/dist/components/date-picker/types.d.ts +39 -0
- package/dist/components/date-picker/types.js +7 -0
- package/dist/components/drawer/drawer.css +1112 -0
- package/dist/components/drawer/drawer.d.ts +17 -0
- package/dist/components/drawer/drawer.js +184 -0
- package/dist/components/form-actions/form-actions.d.ts +12 -0
- package/dist/components/form-actions/form-actions.js +42 -0
- package/dist/components/form-field/form-field.d.ts +17 -0
- package/dist/components/form-field/form-field.js +101 -0
- package/dist/components/form-field/form.css +1036 -0
- package/dist/components/form-section/form-section.d.ts +14 -0
- package/dist/components/form-section/form-section.js +92 -0
- package/dist/components/input/input.css +1185 -0
- package/dist/components/input/input.d.ts +15 -0
- package/dist/components/input/input.js +143 -0
- package/dist/components/pagination/pagination.css +1099 -0
- package/dist/components/pagination/pagination.d.ts +22 -0
- package/dist/components/pagination/pagination.js +310 -0
- package/dist/components/radio/radio.css +1045 -0
- package/dist/components/radio/radio.d.ts +34 -0
- package/dist/components/radio/radio.js +215 -0
- package/dist/components/scroll-area/scroll-area.css +1099 -0
- package/dist/components/scroll-area/scroll-area.d.ts +33 -0
- package/dist/components/scroll-area/scroll-area.js +375 -0
- package/dist/components/select/mobile-select.css +1044 -0
- package/dist/components/select/mobile-select.d.ts +19 -0
- package/dist/components/select/mobile-select.js +224 -0
- package/dist/components/select/select.css +1327 -0
- package/dist/components/select/select.d.ts +32 -0
- package/dist/components/select/select.js +532 -0
- package/dist/components/select/use-is-mobile.d.ts +1 -0
- package/dist/components/select/use-is-mobile.js +30 -0
- package/dist/components/splitter/splitter.css +1104 -0
- package/dist/components/splitter/splitter.d.ts +33 -0
- package/dist/components/splitter/splitter.js +451 -0
- package/dist/components/switch/switch.css +1170 -0
- package/dist/components/switch/switch.d.ts +19 -0
- package/dist/components/switch/switch.js +143 -0
- package/dist/components/table/table.css +1255 -0
- package/dist/components/table/table.d.ts +73 -0
- package/dist/components/table/table.js +1022 -0
- package/dist/components/tabs/tabs.css +1076 -0
- package/dist/components/tabs/tabs.d.ts +24 -0
- package/dist/components/tabs/tabs.js +256 -0
- package/dist/components/tag/tag.css +1124 -0
- package/dist/components/tag/tag.d.ts +33 -0
- package/dist/components/tag/tag.js +237 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/layouts/form-layout/form-layout.d.ts +6 -0
- package/dist/layouts/form-layout/form-layout.js +18 -0
- package/dist/layouts/stack/layout.css +1003 -0
- package/dist/layouts/stack/stack.d.ts +9 -0
- package/dist/layouts/stack/stack.js +27 -0
- package/dist/number-input/cursor.d.ts +9 -0
- package/dist/number-input/cursor.js +44 -0
- package/dist/number-input/format.d.ts +5 -0
- package/dist/number-input/format.js +50 -0
- package/dist/number-input/index.d.ts +5 -0
- package/dist/number-input/index.js +2 -0
- package/dist/number-input/number-input.d.ts +9 -0
- package/dist/number-input/number-input.js +101 -0
- package/dist/number-input/percentage.d.ts +3 -0
- package/dist/number-input/percentage.js +28 -0
- package/dist/number-input/types.d.ts +5 -0
- package/dist/number-input/types.js +0 -0
- package/dist/number-input/use-number-input.d.ts +30 -0
- package/dist/number-input/use-number-input.js +211 -0
- package/dist/number-input/validate.d.ts +3 -0
- package/dist/number-input/validate.js +17 -0
- package/dist/provider/tao-provider.d.ts +42 -0
- package/dist/provider/tao-provider.js +67 -0
- package/dist/theme/control.css +1061 -0
- package/dist/theme/theme.css +957 -0
- package/dist/utils/semantic.d.ts +10 -0
- package/dist/utils/semantic.js +5 -0
- package/llms.txt +67 -0
- package/package.json +97 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type TaoSize } from '../../provider/tao-provider';
|
|
3
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic';
|
|
4
|
+
import './tabs.css';
|
|
5
|
+
export type TabsSemanticPart = 'root' | 'nav' | 'tab' | 'indicator' | 'panel';
|
|
6
|
+
export interface TabItem {
|
|
7
|
+
key: string;
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface TabsProps {
|
|
13
|
+
items: TabItem[];
|
|
14
|
+
activeKey?: string;
|
|
15
|
+
defaultActiveKey?: string;
|
|
16
|
+
onChange?: (key: string) => void;
|
|
17
|
+
size?: TaoSize;
|
|
18
|
+
variant?: 'line' | 'card';
|
|
19
|
+
destroyInactiveTabPane?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
classNames?: SemanticClassNames<TabsSemanticPart>;
|
|
22
|
+
styles?: SemanticStyles<TabsSemanticPart>;
|
|
23
|
+
}
|
|
24
|
+
export declare function Tabs({ items, activeKey: activeKeyProp, defaultActiveKey, onChange, size, variant, destroyInactiveTabPane, className, classNames, styles, }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
5
|
+
import { cx } from "../../utils/semantic.js";
|
|
6
|
+
import "./tabs.css";
|
|
7
|
+
function Tabs(t0) {
|
|
8
|
+
const $ = c(61);
|
|
9
|
+
const { items, activeKey: activeKeyProp, defaultActiveKey, onChange, size, variant: t1, destroyInactiveTabPane: t2, className, classNames, styles } = t0;
|
|
10
|
+
const variant = void 0 === t1 ? "line" : t1;
|
|
11
|
+
const destroyInactiveTabPane = void 0 === t2 ? false : t2;
|
|
12
|
+
const ctx = useTaoConfig();
|
|
13
|
+
const resolvedSize = size ?? ctx.size;
|
|
14
|
+
const isControlled = void 0 !== activeKeyProp;
|
|
15
|
+
const firstEnabledKey = items.find(_temp)?.key ?? items[0]?.key ?? "";
|
|
16
|
+
const [internalKey, setInternalKey] = useState(defaultActiveKey ?? firstEnabledKey);
|
|
17
|
+
const currentKey = isControlled ? activeKeyProp : internalKey;
|
|
18
|
+
let t3;
|
|
19
|
+
if ($[0] !== isControlled || $[1] !== onChange) {
|
|
20
|
+
t3 = (key)=>{
|
|
21
|
+
if (!isControlled) setInternalKey(key);
|
|
22
|
+
onChange?.(key);
|
|
23
|
+
};
|
|
24
|
+
$[0] = isControlled;
|
|
25
|
+
$[1] = onChange;
|
|
26
|
+
$[2] = t3;
|
|
27
|
+
} else t3 = $[2];
|
|
28
|
+
const handleSelect = t3;
|
|
29
|
+
const tablistRef = useRef(null);
|
|
30
|
+
const [inkStyle, setInkStyle] = useState(null);
|
|
31
|
+
let t4;
|
|
32
|
+
if ($[3] !== currentKey || $[4] !== variant) {
|
|
33
|
+
t4 = ()=>{
|
|
34
|
+
if ("line" !== variant) return;
|
|
35
|
+
const list = tablistRef.current;
|
|
36
|
+
if (!list) return;
|
|
37
|
+
const active = list.querySelector(`[data-tao-tab-key="${CSS.escape(currentKey)}"]`);
|
|
38
|
+
if (active) setInkStyle({
|
|
39
|
+
left: active.offsetLeft,
|
|
40
|
+
width: active.offsetWidth
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
$[3] = currentKey;
|
|
44
|
+
$[4] = variant;
|
|
45
|
+
$[5] = t4;
|
|
46
|
+
} else t4 = $[5];
|
|
47
|
+
let t5;
|
|
48
|
+
if ($[6] !== currentKey || $[7] !== items || $[8] !== variant) {
|
|
49
|
+
t5 = [
|
|
50
|
+
currentKey,
|
|
51
|
+
variant,
|
|
52
|
+
items
|
|
53
|
+
];
|
|
54
|
+
$[6] = currentKey;
|
|
55
|
+
$[7] = items;
|
|
56
|
+
$[8] = variant;
|
|
57
|
+
$[9] = t5;
|
|
58
|
+
} else t5 = $[9];
|
|
59
|
+
useEffect(t4, t5);
|
|
60
|
+
let t6;
|
|
61
|
+
if ($[10] !== currentKey || $[11] !== handleSelect || $[12] !== items) {
|
|
62
|
+
t6 = (e)=>{
|
|
63
|
+
const enabledItems = items.filter(_temp2);
|
|
64
|
+
const idx = enabledItems.findIndex((t_1)=>t_1.key === currentKey);
|
|
65
|
+
let next;
|
|
66
|
+
if ("ArrowRight" === e.key || "ArrowDown" === e.key) {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
next = enabledItems[(idx + 1) % enabledItems.length];
|
|
69
|
+
} else if ("ArrowLeft" === e.key || "ArrowUp" === e.key) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
next = enabledItems[(idx - 1 + enabledItems.length) % enabledItems.length];
|
|
72
|
+
} else if ("Home" === e.key) {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
next = enabledItems[0];
|
|
75
|
+
} else if ("End" === e.key) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
next = enabledItems[enabledItems.length - 1];
|
|
78
|
+
}
|
|
79
|
+
if (next) {
|
|
80
|
+
handleSelect(next.key);
|
|
81
|
+
const list_0 = tablistRef.current;
|
|
82
|
+
const btn = list_0?.querySelector(`[data-tao-tab-key="${CSS.escape(next.key)}"]`);
|
|
83
|
+
btn?.focus();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
$[10] = currentKey;
|
|
87
|
+
$[11] = handleSelect;
|
|
88
|
+
$[12] = items;
|
|
89
|
+
$[13] = t6;
|
|
90
|
+
} else t6 = $[13];
|
|
91
|
+
const handleKeyDown = t6;
|
|
92
|
+
const t7 = classNames?.root;
|
|
93
|
+
let t8;
|
|
94
|
+
if ($[14] !== className || $[15] !== t7) {
|
|
95
|
+
t8 = cx(t7, className);
|
|
96
|
+
$[14] = className;
|
|
97
|
+
$[15] = t7;
|
|
98
|
+
$[16] = t8;
|
|
99
|
+
} else t8 = $[16];
|
|
100
|
+
const t9 = styles?.root;
|
|
101
|
+
const t10 = classNames?.nav;
|
|
102
|
+
let t11;
|
|
103
|
+
if ($[17] !== t10) {
|
|
104
|
+
t11 = cx(t10);
|
|
105
|
+
$[17] = t10;
|
|
106
|
+
$[18] = t11;
|
|
107
|
+
} else t11 = $[18];
|
|
108
|
+
const t12 = styles?.nav;
|
|
109
|
+
let t13;
|
|
110
|
+
if ($[19] !== classNames?.tab || $[20] !== currentKey || $[21] !== handleSelect || $[22] !== items || $[23] !== styles?.tab) {
|
|
111
|
+
let t14;
|
|
112
|
+
if ($[25] !== classNames?.tab || $[26] !== currentKey || $[27] !== handleSelect || $[28] !== styles?.tab) {
|
|
113
|
+
t14 = (item)=>{
|
|
114
|
+
const isActive = item.key === currentKey;
|
|
115
|
+
return /*#__PURE__*/ jsx("button", {
|
|
116
|
+
type: "button",
|
|
117
|
+
role: "tab",
|
|
118
|
+
"aria-selected": isActive,
|
|
119
|
+
"aria-controls": `tabpanel-${item.key}`,
|
|
120
|
+
"aria-disabled": item.disabled || void 0,
|
|
121
|
+
tabIndex: isActive ? 0 : -1,
|
|
122
|
+
"data-tao-tab": "",
|
|
123
|
+
"data-tao-tab-key": item.key,
|
|
124
|
+
"data-tao-active": isActive || void 0,
|
|
125
|
+
"data-tao-disabled": item.disabled || void 0,
|
|
126
|
+
disabled: item.disabled,
|
|
127
|
+
onClick: ()=>handleSelect(item.key),
|
|
128
|
+
className: cx(classNames?.tab),
|
|
129
|
+
style: styles?.tab,
|
|
130
|
+
children: item.label
|
|
131
|
+
}, item.key);
|
|
132
|
+
};
|
|
133
|
+
$[25] = classNames?.tab;
|
|
134
|
+
$[26] = currentKey;
|
|
135
|
+
$[27] = handleSelect;
|
|
136
|
+
$[28] = styles?.tab;
|
|
137
|
+
$[29] = t14;
|
|
138
|
+
} else t14 = $[29];
|
|
139
|
+
t13 = items.map(t14);
|
|
140
|
+
$[19] = classNames?.tab;
|
|
141
|
+
$[20] = currentKey;
|
|
142
|
+
$[21] = handleSelect;
|
|
143
|
+
$[22] = items;
|
|
144
|
+
$[23] = styles?.tab;
|
|
145
|
+
$[24] = t13;
|
|
146
|
+
} else t13 = $[24];
|
|
147
|
+
let t14;
|
|
148
|
+
if ($[30] !== classNames?.indicator || $[31] !== inkStyle || $[32] !== styles?.indicator || $[33] !== variant) {
|
|
149
|
+
t14 = "line" === variant && inkStyle && /*#__PURE__*/ jsx("span", {
|
|
150
|
+
"data-tao-tabs-ink": "",
|
|
151
|
+
style: {
|
|
152
|
+
left: inkStyle.left,
|
|
153
|
+
width: inkStyle.width,
|
|
154
|
+
...styles?.indicator
|
|
155
|
+
},
|
|
156
|
+
className: cx(classNames?.indicator)
|
|
157
|
+
});
|
|
158
|
+
$[30] = classNames?.indicator;
|
|
159
|
+
$[31] = inkStyle;
|
|
160
|
+
$[32] = styles?.indicator;
|
|
161
|
+
$[33] = variant;
|
|
162
|
+
$[34] = t14;
|
|
163
|
+
} else t14 = $[34];
|
|
164
|
+
let t15;
|
|
165
|
+
if ($[35] !== handleKeyDown || $[36] !== t13 || $[37] !== t14) {
|
|
166
|
+
t15 = /*#__PURE__*/ jsxs("div", {
|
|
167
|
+
ref: tablistRef,
|
|
168
|
+
role: "tablist",
|
|
169
|
+
"data-tao-tabs-list": "",
|
|
170
|
+
onKeyDown: handleKeyDown,
|
|
171
|
+
children: [
|
|
172
|
+
t13,
|
|
173
|
+
t14
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
$[35] = handleKeyDown;
|
|
177
|
+
$[36] = t13;
|
|
178
|
+
$[37] = t14;
|
|
179
|
+
$[38] = t15;
|
|
180
|
+
} else t15 = $[38];
|
|
181
|
+
let t16;
|
|
182
|
+
if ($[39] !== t11 || $[40] !== t12 || $[41] !== t15) {
|
|
183
|
+
t16 = /*#__PURE__*/ jsx("div", {
|
|
184
|
+
"data-tao-tabs-nav": "",
|
|
185
|
+
className: t11,
|
|
186
|
+
style: t12,
|
|
187
|
+
children: t15
|
|
188
|
+
});
|
|
189
|
+
$[39] = t11;
|
|
190
|
+
$[40] = t12;
|
|
191
|
+
$[41] = t15;
|
|
192
|
+
$[42] = t16;
|
|
193
|
+
} else t16 = $[42];
|
|
194
|
+
let t17;
|
|
195
|
+
if ($[43] !== classNames?.panel || $[44] !== currentKey || $[45] !== destroyInactiveTabPane || $[46] !== items || $[47] !== styles?.panel) {
|
|
196
|
+
let t18;
|
|
197
|
+
if ($[49] !== classNames?.panel || $[50] !== currentKey || $[51] !== destroyInactiveTabPane || $[52] !== styles?.panel) {
|
|
198
|
+
t18 = (item_0)=>{
|
|
199
|
+
const isActive_0 = item_0.key === currentKey;
|
|
200
|
+
if (destroyInactiveTabPane && !isActive_0) return null;
|
|
201
|
+
return /*#__PURE__*/ jsx("div", {
|
|
202
|
+
role: "tabpanel",
|
|
203
|
+
id: `tabpanel-${item_0.key}`,
|
|
204
|
+
"aria-labelledby": item_0.key,
|
|
205
|
+
hidden: !isActive_0,
|
|
206
|
+
"data-tao-tabs-panel": "",
|
|
207
|
+
"data-tao-active": isActive_0 || void 0,
|
|
208
|
+
className: cx(classNames?.panel),
|
|
209
|
+
style: styles?.panel,
|
|
210
|
+
children: item_0.children
|
|
211
|
+
}, item_0.key);
|
|
212
|
+
};
|
|
213
|
+
$[49] = classNames?.panel;
|
|
214
|
+
$[50] = currentKey;
|
|
215
|
+
$[51] = destroyInactiveTabPane;
|
|
216
|
+
$[52] = styles?.panel;
|
|
217
|
+
$[53] = t18;
|
|
218
|
+
} else t18 = $[53];
|
|
219
|
+
t17 = items.map(t18);
|
|
220
|
+
$[43] = classNames?.panel;
|
|
221
|
+
$[44] = currentKey;
|
|
222
|
+
$[45] = destroyInactiveTabPane;
|
|
223
|
+
$[46] = items;
|
|
224
|
+
$[47] = styles?.panel;
|
|
225
|
+
$[48] = t17;
|
|
226
|
+
} else t17 = $[48];
|
|
227
|
+
let t18;
|
|
228
|
+
if ($[54] !== resolvedSize || $[55] !== t16 || $[56] !== t17 || $[57] !== t8 || $[58] !== t9 || $[59] !== variant) {
|
|
229
|
+
t18 = /*#__PURE__*/ jsxs("div", {
|
|
230
|
+
"data-tao-tabs": "",
|
|
231
|
+
"data-tao-variant": variant,
|
|
232
|
+
"data-tao-size": resolvedSize,
|
|
233
|
+
className: t8,
|
|
234
|
+
style: t9,
|
|
235
|
+
children: [
|
|
236
|
+
t16,
|
|
237
|
+
t17
|
|
238
|
+
]
|
|
239
|
+
});
|
|
240
|
+
$[54] = resolvedSize;
|
|
241
|
+
$[55] = t16;
|
|
242
|
+
$[56] = t17;
|
|
243
|
+
$[57] = t8;
|
|
244
|
+
$[58] = t9;
|
|
245
|
+
$[59] = variant;
|
|
246
|
+
$[60] = t18;
|
|
247
|
+
} else t18 = $[60];
|
|
248
|
+
return t18;
|
|
249
|
+
}
|
|
250
|
+
function _temp2(t_0) {
|
|
251
|
+
return !t_0.disabled;
|
|
252
|
+
}
|
|
253
|
+
function _temp(t) {
|
|
254
|
+
return !t.disabled;
|
|
255
|
+
}
|
|
256
|
+
export { Tabs };
|