@rockshin/tao-ui 0.0.1 → 0.0.2

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 (59) hide show
  1. package/dist/components/breadcrumb/breadcrumb.css +1088 -0
  2. package/dist/components/breadcrumb/breadcrumb.d.ts +43 -0
  3. package/dist/components/breadcrumb/breadcrumb.js +268 -0
  4. package/dist/components/button/button.css +43 -21
  5. package/dist/components/checkbox/checkbox.css +30 -12
  6. package/dist/components/collapsible/collapsible.css +1023 -0
  7. package/dist/components/collapsible/collapsible.d.ts +39 -0
  8. package/dist/components/collapsible/collapsible.js +168 -0
  9. package/dist/components/context-menu/context-menu.css +1146 -0
  10. package/dist/components/context-menu/context-menu.d.ts +19 -0
  11. package/dist/components/context-menu/context-menu.js +104 -0
  12. package/dist/components/date-picker/date-picker.css +44 -16
  13. package/dist/components/drawer/drawer.css +123 -13
  14. package/dist/components/drawer/drawer.d.ts +36 -3
  15. package/dist/components/drawer/drawer.js +314 -121
  16. package/dist/components/dropdown/dropdown.css +996 -0
  17. package/dist/components/dropdown/dropdown.d.ts +45 -0
  18. package/dist/components/dropdown/dropdown.js +381 -0
  19. package/dist/components/form-field/form.css +30 -12
  20. package/dist/components/input/input.css +44 -14
  21. package/dist/components/menu/menu-render.d.ts +89 -0
  22. package/dist/components/menu/menu-render.js +376 -0
  23. package/dist/components/menu/menu.css +1142 -0
  24. package/dist/components/modal/confirm-dialog.d.ts +37 -0
  25. package/dist/components/modal/confirm-dialog.js +193 -0
  26. package/dist/components/modal/confirm.d.ts +13 -0
  27. package/dist/components/modal/confirm.js +56 -0
  28. package/dist/components/modal/index.d.ts +21 -0
  29. package/dist/components/modal/index.js +18 -0
  30. package/dist/components/modal/modal.css +1166 -0
  31. package/dist/components/modal/modal.d.ts +50 -0
  32. package/dist/components/modal/modal.js +353 -0
  33. package/dist/components/modal/use-modal.d.ts +21 -0
  34. package/dist/components/modal/use-modal.js +83 -0
  35. package/dist/components/pagination/pagination.css +30 -12
  36. package/dist/components/radio/radio.css +30 -12
  37. package/dist/components/scroll-area/scroll-area.css +30 -12
  38. package/dist/components/select/mobile-select.css +65 -13
  39. package/dist/components/select/mobile-select.js +17 -3
  40. package/dist/components/select/select.css +102 -15
  41. package/dist/components/select/select.d.ts +4 -0
  42. package/dist/components/select/select.js +204 -168
  43. package/dist/components/splitter/splitter.css +30 -12
  44. package/dist/components/switch/switch.css +30 -12
  45. package/dist/components/table/table.css +54 -18
  46. package/dist/components/table/table.d.ts +17 -2
  47. package/dist/components/table/table.js +214 -206
  48. package/dist/components/tabs/tabs.css +33 -17
  49. package/dist/components/tag/tag.css +30 -12
  50. package/dist/components/textarea/textarea.css +1204 -0
  51. package/dist/components/textarea/textarea.d.ts +19 -0
  52. package/dist/components/textarea/textarea.js +181 -0
  53. package/dist/index.d.ts +24 -18
  54. package/dist/index.js +21 -15
  55. package/dist/layouts/stack/layout.css +30 -12
  56. package/dist/theme/control.css +44 -13
  57. package/dist/theme/theme.css +30 -12
  58. package/llms.txt +7 -6
  59. package/package.json +6 -1
@@ -0,0 +1,89 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic';
3
+ import './menu.css';
4
+ export type MenuSemanticPart = 'root' | 'content' | 'item' | 'itemIcon' | 'itemLabel' | 'itemExtra' | 'divider' | 'groupLabel' | 'subTrigger' | 'subContent';
5
+ export interface MenuItemType {
6
+ key: string;
7
+ label: ReactNode;
8
+ icon?: ReactNode;
9
+ disabled?: boolean;
10
+ danger?: boolean;
11
+ /** Right-aligned extra content, e.g. a keyboard shortcut. */
12
+ extra?: ReactNode;
13
+ onClick?: (info: {
14
+ key: string;
15
+ }) => void;
16
+ /** Nested submenu. */
17
+ children?: MenuItemType[];
18
+ }
19
+ export interface MenuDividerType {
20
+ type: 'divider';
21
+ }
22
+ export interface MenuGroupType {
23
+ type: 'group';
24
+ key?: string;
25
+ label?: ReactNode;
26
+ children: MenuItemType[];
27
+ }
28
+ export type MenuItem = MenuItemType | MenuDividerType | MenuGroupType;
29
+ export interface MenuProps {
30
+ items: MenuItem[];
31
+ onClick?: (info: {
32
+ key: string;
33
+ }) => void;
34
+ /** Render items as checkbox/radio entries. */
35
+ selectable?: boolean;
36
+ /** Multi-select (checkbox) when selectable. Otherwise single (radio). */
37
+ multiple?: boolean;
38
+ selectedKeys?: string[];
39
+ defaultSelectedKeys?: string[];
40
+ onSelect?: (info: {
41
+ key: string;
42
+ selectedKeys: string[];
43
+ }) => void;
44
+ }
45
+ /**
46
+ * Radix `react-dropdown-menu` and `react-context-menu` expose parallel
47
+ * sub-components with identical names. We render an antd-style `items` array
48
+ * against whichever set is passed in, so Dropdown and ContextMenu share one
49
+ * renderer.
50
+ */
51
+ type AnyComp = ComponentType<any>;
52
+ export interface MenuPrimitives {
53
+ Item: AnyComp;
54
+ CheckboxItem: AnyComp;
55
+ RadioGroup: AnyComp;
56
+ RadioItem: AnyComp;
57
+ Label: AnyComp;
58
+ Separator: AnyComp;
59
+ Group: AnyComp;
60
+ Sub: AnyComp;
61
+ SubTrigger: AnyComp;
62
+ SubContent: AnyComp;
63
+ Portal: AnyComp;
64
+ ItemIndicator: AnyComp;
65
+ }
66
+ export interface RenderCtx {
67
+ P: MenuPrimitives;
68
+ classNames?: SemanticClassNames<MenuSemanticPart>;
69
+ styles?: SemanticStyles<MenuSemanticPart>;
70
+ /** Fire item.onClick + menu.onClick for a plain action item. */
71
+ onAction: (item: MenuItemType) => void;
72
+ /** Multi-select: current keys + toggler. */
73
+ selectedKeys: string[];
74
+ multiple: boolean;
75
+ selectable: boolean;
76
+ onToggle: (key: string) => void;
77
+ }
78
+ export declare function renderMenuItems(items: MenuItem[], ctx: RenderCtx): ReactNode;
79
+ /**
80
+ * Encapsulates a menu's selection state (controlled / uncontrolled), the
81
+ * item-click dispatch (`item.onClick` → `menu.onClick`), and rendering of the
82
+ * item tree (wrapping in a RadioGroup for single-select). Returns the ready
83
+ * content node. Shared by Dropdown and ContextMenu.
84
+ */
85
+ export declare function useMenuController(menu: MenuProps, P: MenuPrimitives, semantic: {
86
+ classNames?: SemanticClassNames<MenuSemanticPart>;
87
+ styles?: SemanticStyles<MenuSemanticPart>;
88
+ }): ReactNode;
89
+ export {};
@@ -0,0 +1,376 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { useState } from "react";
4
+ import { cx } from "../../utils/semantic.js";
5
+ import "./menu.css";
6
+ function ChevronRightIcon() {
7
+ const $ = c(1);
8
+ let t0;
9
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
10
+ t0 = /*#__PURE__*/ jsx("svg", {
11
+ "data-tao-menu-sub-icon": "",
12
+ width: "16",
13
+ height: "16",
14
+ viewBox: "0 0 24 24",
15
+ fill: "none",
16
+ stroke: "currentColor",
17
+ strokeWidth: "2",
18
+ strokeLinecap: "round",
19
+ strokeLinejoin: "round",
20
+ "aria-hidden": true,
21
+ children: /*#__PURE__*/ jsx("path", {
22
+ d: "m9 18 6-6-6-6"
23
+ })
24
+ });
25
+ $[0] = t0;
26
+ } else t0 = $[0];
27
+ return t0;
28
+ }
29
+ function CheckIcon() {
30
+ const $ = c(1);
31
+ let t0;
32
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
33
+ t0 = /*#__PURE__*/ jsx("svg", {
34
+ width: "16",
35
+ height: "16",
36
+ viewBox: "0 0 24 24",
37
+ fill: "none",
38
+ stroke: "currentColor",
39
+ strokeWidth: "2.5",
40
+ strokeLinecap: "round",
41
+ strokeLinejoin: "round",
42
+ "aria-hidden": true,
43
+ children: /*#__PURE__*/ jsx("polyline", {
44
+ points: "20 6 9 17 4 12"
45
+ })
46
+ });
47
+ $[0] = t0;
48
+ } else t0 = $[0];
49
+ return t0;
50
+ }
51
+ function DotIcon() {
52
+ const $ = c(1);
53
+ let t0;
54
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
55
+ t0 = /*#__PURE__*/ jsx("svg", {
56
+ width: "16",
57
+ height: "16",
58
+ viewBox: "0 0 24 24",
59
+ fill: "currentColor",
60
+ "aria-hidden": true,
61
+ children: /*#__PURE__*/ jsx("circle", {
62
+ cx: "12",
63
+ cy: "12",
64
+ r: "4"
65
+ })
66
+ });
67
+ $[0] = t0;
68
+ } else t0 = $[0];
69
+ return t0;
70
+ }
71
+ function ItemBody(t0) {
72
+ const $ = c(18);
73
+ const { icon, label, extra, ctx } = t0;
74
+ let t1;
75
+ if ($[0] !== ctx.classNames?.itemIcon || $[1] !== ctx.styles?.itemIcon || $[2] !== icon) {
76
+ t1 = null != icon && /*#__PURE__*/ jsx("span", {
77
+ "data-tao-menu-item-icon": "",
78
+ className: cx(ctx.classNames?.itemIcon),
79
+ style: ctx.styles?.itemIcon,
80
+ children: icon
81
+ });
82
+ $[0] = ctx.classNames?.itemIcon;
83
+ $[1] = ctx.styles?.itemIcon;
84
+ $[2] = icon;
85
+ $[3] = t1;
86
+ } else t1 = $[3];
87
+ const t2 = ctx.classNames?.itemLabel;
88
+ let t3;
89
+ if ($[4] !== t2) {
90
+ t3 = cx(t2);
91
+ $[4] = t2;
92
+ $[5] = t3;
93
+ } else t3 = $[5];
94
+ const t4 = ctx.styles?.itemLabel;
95
+ let t5;
96
+ if ($[6] !== label || $[7] !== t3 || $[8] !== t4) {
97
+ t5 = /*#__PURE__*/ jsx("span", {
98
+ "data-tao-menu-item-label": "",
99
+ className: t3,
100
+ style: t4,
101
+ children: label
102
+ });
103
+ $[6] = label;
104
+ $[7] = t3;
105
+ $[8] = t4;
106
+ $[9] = t5;
107
+ } else t5 = $[9];
108
+ let t6;
109
+ if ($[10] !== ctx.classNames?.itemExtra || $[11] !== ctx.styles?.itemExtra || $[12] !== extra) {
110
+ t6 = null != extra && /*#__PURE__*/ jsx("span", {
111
+ "data-tao-menu-item-extra": "",
112
+ className: cx(ctx.classNames?.itemExtra),
113
+ style: ctx.styles?.itemExtra,
114
+ children: extra
115
+ });
116
+ $[10] = ctx.classNames?.itemExtra;
117
+ $[11] = ctx.styles?.itemExtra;
118
+ $[12] = extra;
119
+ $[13] = t6;
120
+ } else t6 = $[13];
121
+ let t7;
122
+ if ($[14] !== t1 || $[15] !== t5 || $[16] !== t6) {
123
+ t7 = /*#__PURE__*/ jsxs(Fragment, {
124
+ children: [
125
+ t1,
126
+ t5,
127
+ t6
128
+ ]
129
+ });
130
+ $[14] = t1;
131
+ $[15] = t5;
132
+ $[16] = t6;
133
+ $[17] = t7;
134
+ } else t7 = $[17];
135
+ return t7;
136
+ }
137
+ function renderMenuItems(items, ctx) {
138
+ const { P } = ctx;
139
+ return items.map((item, index)=>{
140
+ if ('type' in item && 'divider' === item.type) return /*#__PURE__*/ jsx(P.Separator, {
141
+ "data-tao-menu-divider": "",
142
+ className: cx(ctx.classNames?.divider),
143
+ style: ctx.styles?.divider
144
+ }, `divider-${index}`);
145
+ if ('type' in item && 'group' === item.type) return /*#__PURE__*/ jsxs(P.Group, {
146
+ "data-tao-menu-group": "",
147
+ children: [
148
+ null != item.label && /*#__PURE__*/ jsx(P.Label, {
149
+ "data-tao-menu-group-label": "",
150
+ className: cx(ctx.classNames?.groupLabel),
151
+ style: ctx.styles?.groupLabel,
152
+ children: item.label
153
+ }),
154
+ renderMenuItems(item.children, ctx)
155
+ ]
156
+ }, item.key ?? `group-${index}`);
157
+ if (item.children && item.children.length > 0) return /*#__PURE__*/ jsxs(P.Sub, {
158
+ children: [
159
+ /*#__PURE__*/ jsxs(P.SubTrigger, {
160
+ disabled: item.disabled,
161
+ "data-tao-menu-item": "",
162
+ "data-tao-menu-sub-trigger": "",
163
+ "data-tao-danger": item.danger || void 0,
164
+ className: cx(ctx.classNames?.item, ctx.classNames?.subTrigger),
165
+ style: {
166
+ ...ctx.styles?.item,
167
+ ...ctx.styles?.subTrigger
168
+ },
169
+ children: [
170
+ /*#__PURE__*/ jsx(ItemBody, {
171
+ icon: item.icon,
172
+ label: item.label,
173
+ extra: item.extra,
174
+ ctx: ctx
175
+ }),
176
+ /*#__PURE__*/ jsx(ChevronRightIcon, {})
177
+ ]
178
+ }),
179
+ /*#__PURE__*/ jsx(P.Portal, {
180
+ children: /*#__PURE__*/ jsx(P.SubContent, {
181
+ "data-tao-menu-content": "",
182
+ "data-tao-menu-sub-content": "",
183
+ className: cx(ctx.classNames?.subContent),
184
+ style: ctx.styles?.subContent,
185
+ sideOffset: 2,
186
+ alignOffset: -4,
187
+ children: renderMenuItems(item.children, ctx)
188
+ })
189
+ })
190
+ ]
191
+ }, item.key);
192
+ if (ctx.selectable) {
193
+ if (ctx.multiple) return /*#__PURE__*/ jsxs(P.CheckboxItem, {
194
+ disabled: item.disabled,
195
+ checked: ctx.selectedKeys.includes(item.key),
196
+ onCheckedChange: ()=>{
197
+ ctx.onToggle(item.key);
198
+ ctx.onAction(item);
199
+ },
200
+ "data-tao-menu-item": "",
201
+ "data-tao-menu-selectable": "",
202
+ "data-tao-danger": item.danger || void 0,
203
+ className: cx(ctx.classNames?.item),
204
+ style: ctx.styles?.item,
205
+ children: [
206
+ /*#__PURE__*/ jsx("span", {
207
+ "data-tao-menu-item-indicator": "",
208
+ children: /*#__PURE__*/ jsx(P.ItemIndicator, {
209
+ children: /*#__PURE__*/ jsx(CheckIcon, {})
210
+ })
211
+ }),
212
+ /*#__PURE__*/ jsx(ItemBody, {
213
+ icon: item.icon,
214
+ label: item.label,
215
+ extra: item.extra,
216
+ ctx: ctx
217
+ })
218
+ ]
219
+ }, item.key);
220
+ return /*#__PURE__*/ jsxs(P.RadioItem, {
221
+ value: item.key,
222
+ disabled: item.disabled,
223
+ onSelect: ()=>ctx.onAction(item),
224
+ "data-tao-menu-item": "",
225
+ "data-tao-menu-selectable": "",
226
+ "data-tao-danger": item.danger || void 0,
227
+ className: cx(ctx.classNames?.item),
228
+ style: ctx.styles?.item,
229
+ children: [
230
+ /*#__PURE__*/ jsx("span", {
231
+ "data-tao-menu-item-indicator": "",
232
+ children: /*#__PURE__*/ jsx(P.ItemIndicator, {
233
+ children: /*#__PURE__*/ jsx(DotIcon, {})
234
+ })
235
+ }),
236
+ /*#__PURE__*/ jsx(ItemBody, {
237
+ icon: item.icon,
238
+ label: item.label,
239
+ extra: item.extra,
240
+ ctx: ctx
241
+ })
242
+ ]
243
+ }, item.key);
244
+ }
245
+ return /*#__PURE__*/ jsx(P.Item, {
246
+ disabled: item.disabled,
247
+ onSelect: ()=>ctx.onAction(item),
248
+ "data-tao-menu-item": "",
249
+ "data-tao-danger": item.danger || void 0,
250
+ className: cx(ctx.classNames?.item),
251
+ style: ctx.styles?.item,
252
+ children: /*#__PURE__*/ jsx(ItemBody, {
253
+ icon: item.icon,
254
+ label: item.label,
255
+ extra: item.extra,
256
+ ctx: ctx
257
+ })
258
+ }, item.key);
259
+ });
260
+ }
261
+ function useMenuController(menu, P, semantic) {
262
+ const $ = c(31);
263
+ const selectable = !!menu.selectable;
264
+ const multiple = !!menu.multiple;
265
+ const isSelControlled = null != menu.selectedKeys;
266
+ let t0;
267
+ if ($[0] !== menu.defaultSelectedKeys) {
268
+ t0 = menu.defaultSelectedKeys ?? [];
269
+ $[0] = menu.defaultSelectedKeys;
270
+ $[1] = t0;
271
+ } else t0 = $[1];
272
+ const [selInternal, setSelInternal] = useState(t0);
273
+ let t1;
274
+ if ($[2] !== isSelControlled || $[3] !== menu.selectedKeys || $[4] !== selInternal) {
275
+ t1 = isSelControlled ? menu.selectedKeys ?? [] : selInternal;
276
+ $[2] = isSelControlled;
277
+ $[3] = menu.selectedKeys;
278
+ $[4] = selInternal;
279
+ $[5] = t1;
280
+ } else t1 = $[5];
281
+ const selectedKeys = t1;
282
+ let t2;
283
+ if ($[6] !== isSelControlled || $[7] !== menu) {
284
+ t2 = (next, changedKey)=>{
285
+ if (!isSelControlled) setSelInternal(next);
286
+ menu.onSelect?.({
287
+ key: changedKey,
288
+ selectedKeys: next
289
+ });
290
+ };
291
+ $[6] = isSelControlled;
292
+ $[7] = menu;
293
+ $[8] = t2;
294
+ } else t2 = $[8];
295
+ const commitSel = t2;
296
+ let t3;
297
+ if ($[9] !== commitSel || $[10] !== selectedKeys) {
298
+ t3 = (key)=>{
299
+ const next_0 = selectedKeys.includes(key) ? selectedKeys.filter((k)=>k !== key) : [
300
+ ...selectedKeys,
301
+ key
302
+ ];
303
+ commitSel(next_0, key);
304
+ };
305
+ $[9] = commitSel;
306
+ $[10] = selectedKeys;
307
+ $[11] = t3;
308
+ } else t3 = $[11];
309
+ const toggleKey = t3;
310
+ let t4;
311
+ if ($[12] !== commitSel) {
312
+ t4 = (key_0)=>commitSel([
313
+ key_0
314
+ ], key_0);
315
+ $[12] = commitSel;
316
+ $[13] = t4;
317
+ } else t4 = $[13];
318
+ const radioChange = t4;
319
+ let t5;
320
+ if ($[14] !== menu) {
321
+ t5 = (item)=>{
322
+ item.onClick?.({
323
+ key: item.key
324
+ });
325
+ menu.onClick?.({
326
+ key: item.key
327
+ });
328
+ };
329
+ $[14] = menu;
330
+ $[15] = t5;
331
+ } else t5 = $[15];
332
+ const onAction = t5;
333
+ let t6;
334
+ if ($[16] !== P || $[17] !== menu.items || $[18] !== multiple || $[19] !== onAction || $[20] !== selectable || $[21] !== selectedKeys || $[22] !== semantic.classNames || $[23] !== semantic.styles || $[24] !== toggleKey) {
335
+ const ctx = {
336
+ P,
337
+ classNames: semantic.classNames,
338
+ styles: semantic.styles,
339
+ onAction,
340
+ selectedKeys,
341
+ multiple,
342
+ selectable,
343
+ onToggle: toggleKey
344
+ };
345
+ t6 = renderMenuItems(menu.items, ctx);
346
+ $[16] = P;
347
+ $[17] = menu.items;
348
+ $[18] = multiple;
349
+ $[19] = onAction;
350
+ $[20] = selectable;
351
+ $[21] = selectedKeys;
352
+ $[22] = semantic.classNames;
353
+ $[23] = semantic.styles;
354
+ $[24] = toggleKey;
355
+ $[25] = t6;
356
+ } else t6 = $[25];
357
+ const body = t6;
358
+ if (selectable && !multiple) {
359
+ let t7;
360
+ if ($[26] !== P.RadioGroup || $[27] !== body || $[28] !== radioChange || $[29] !== selectedKeys[0]) {
361
+ t7 = /*#__PURE__*/ jsx(P.RadioGroup, {
362
+ value: selectedKeys[0],
363
+ onValueChange: radioChange,
364
+ children: body
365
+ });
366
+ $[26] = P.RadioGroup;
367
+ $[27] = body;
368
+ $[28] = radioChange;
369
+ $[29] = selectedKeys[0];
370
+ $[30] = t7;
371
+ } else t7 = $[30];
372
+ return t7;
373
+ }
374
+ return body;
375
+ }
376
+ export { renderMenuItems, useMenuController };