@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,37 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic';
3
+ import { type ButtonProps } from '../button/button';
4
+ import { type ModalSemanticPart } from './modal';
5
+ export type ConfirmType = 'info' | 'success' | 'error' | 'warning' | 'confirm';
6
+ /** Config accepted by `Modal.confirm/info/...` and `modal.confirm/...` from `useModal`. */
7
+ export interface ModalFuncProps {
8
+ title?: ReactNode;
9
+ content?: ReactNode;
10
+ /** Custom status icon. Pass `null` to hide the icon. */
11
+ icon?: ReactNode | null;
12
+ type?: ConfirmType;
13
+ okText?: ReactNode;
14
+ cancelText?: ReactNode;
15
+ /** Show the Cancel button. Defaults to `true` only for `confirm` type. */
16
+ okCancel?: boolean;
17
+ okButtonProps?: ButtonProps;
18
+ cancelButtonProps?: ButtonProps;
19
+ /** Return a Promise to keep the OK button in loading state until it settles. */
20
+ onOk?: () => unknown;
21
+ onCancel?: () => unknown;
22
+ afterClose?: () => void;
23
+ centered?: boolean;
24
+ width?: number | string;
25
+ maskClosable?: boolean;
26
+ closable?: boolean;
27
+ keyboard?: boolean;
28
+ className?: string;
29
+ classNames?: SemanticClassNames<ModalSemanticPart>;
30
+ styles?: SemanticStyles<ModalSemanticPart>;
31
+ }
32
+ export interface ConfirmDialogProps extends ModalFuncProps {
33
+ open: boolean;
34
+ /** Requests close (container flips `open` to false). */
35
+ close: () => void;
36
+ }
37
+ export declare function ConfirmDialog({ open, close, type, icon, title, content, okText, cancelText, okCancel, okButtonProps, cancelButtonProps, onOk, onCancel, afterClose, centered, width, maskClosable, closable, keyboard, className, classNames, styles, }: ConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,193 @@
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 { Button } from "../button/button.js";
6
+ import { Modal } from "./modal.js";
7
+ function isPromise(v) {
8
+ return !!v && 'function' == typeof v.then;
9
+ }
10
+ function ConfirmDialog({ open, close, type = 'confirm', icon, title, content, okText, cancelText, okCancel, okButtonProps, cancelButtonProps, onOk, onCancel, afterClose, centered = true, width = 416, maskClosable = false, closable = false, keyboard = true, className, classNames, styles }) {
11
+ const [loading, setLoading] = useState(false);
12
+ const showCancel = okCancel ?? 'confirm' === type;
13
+ const runAndClose = async (handler, withLoading)=>{
14
+ const result = handler?.();
15
+ if (isPromise(result)) {
16
+ if (withLoading) setLoading(true);
17
+ try {
18
+ await result;
19
+ close();
20
+ } catch {} finally{
21
+ if (withLoading) setLoading(false);
22
+ }
23
+ } else close();
24
+ };
25
+ const handleOk = ()=>runAndClose(onOk, true);
26
+ const handleCancel = ()=>runAndClose(onCancel, false);
27
+ const iconNode = null === icon ? null : icon ?? /*#__PURE__*/ jsx(StatusIcon, {
28
+ type: type
29
+ });
30
+ const mergedClassNames = className ? {
31
+ ...classNames,
32
+ root: cx(classNames?.root, className)
33
+ } : classNames;
34
+ return /*#__PURE__*/ jsx(Modal, {
35
+ open: open,
36
+ title: null,
37
+ onClose: handleCancel,
38
+ afterClose: afterClose,
39
+ width: width,
40
+ centered: centered,
41
+ closable: closable,
42
+ maskClosable: maskClosable,
43
+ keyboard: keyboard,
44
+ classNames: mergedClassNames,
45
+ styles: styles,
46
+ footer: /*#__PURE__*/ jsxs(Fragment, {
47
+ children: [
48
+ showCancel && /*#__PURE__*/ jsx(Button, {
49
+ variant: "secondary",
50
+ onClick: handleCancel,
51
+ ...cancelButtonProps,
52
+ children: cancelText ?? 'Cancel'
53
+ }),
54
+ /*#__PURE__*/ jsx(Button, {
55
+ variant: "primary",
56
+ loading: loading,
57
+ onClick: handleOk,
58
+ ...okButtonProps,
59
+ children: okText ?? 'OK'
60
+ })
61
+ ]
62
+ }),
63
+ children: /*#__PURE__*/ jsxs("div", {
64
+ "data-tao-modal-confirm-body": "",
65
+ children: [
66
+ null != iconNode && /*#__PURE__*/ jsx("span", {
67
+ "data-tao-modal-confirm-icon": "",
68
+ "data-tao-status": type,
69
+ children: iconNode
70
+ }),
71
+ /*#__PURE__*/ jsxs("div", {
72
+ "data-tao-modal-confirm-main": "",
73
+ children: [
74
+ null != title && /*#__PURE__*/ jsx("div", {
75
+ "data-tao-modal-confirm-title": "",
76
+ children: title
77
+ }),
78
+ null != content && /*#__PURE__*/ jsx("div", {
79
+ "data-tao-modal-confirm-content": "",
80
+ children: content
81
+ })
82
+ ]
83
+ })
84
+ ]
85
+ })
86
+ });
87
+ }
88
+ function StatusIcon(t0) {
89
+ const $ = c(5);
90
+ const { type } = t0;
91
+ let t1;
92
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
93
+ t1 = {
94
+ width: 22,
95
+ height: 22,
96
+ viewBox: "0 0 24 24",
97
+ fill: "none",
98
+ stroke: "currentColor",
99
+ strokeWidth: 2,
100
+ strokeLinecap: "round",
101
+ strokeLinejoin: "round",
102
+ "aria-hidden": true
103
+ };
104
+ $[0] = t1;
105
+ } else t1 = $[0];
106
+ const common = t1;
107
+ switch(type){
108
+ case "success":
109
+ {
110
+ let t2;
111
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
112
+ t2 = /*#__PURE__*/ jsxs("svg", {
113
+ ...common,
114
+ children: [
115
+ /*#__PURE__*/ jsx("circle", {
116
+ cx: "12",
117
+ cy: "12",
118
+ r: "9"
119
+ }),
120
+ /*#__PURE__*/ jsx("path", {
121
+ d: "m8.5 12 2.5 2.5 4.5-5"
122
+ })
123
+ ]
124
+ });
125
+ $[1] = t2;
126
+ } else t2 = $[1];
127
+ return t2;
128
+ }
129
+ case "error":
130
+ {
131
+ let t2;
132
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
133
+ t2 = /*#__PURE__*/ jsxs("svg", {
134
+ ...common,
135
+ children: [
136
+ /*#__PURE__*/ jsx("circle", {
137
+ cx: "12",
138
+ cy: "12",
139
+ r: "9"
140
+ }),
141
+ /*#__PURE__*/ jsx("path", {
142
+ d: "M15 9 9 15M9 9l6 6"
143
+ })
144
+ ]
145
+ });
146
+ $[2] = t2;
147
+ } else t2 = $[2];
148
+ return t2;
149
+ }
150
+ case "warning":
151
+ case "confirm":
152
+ {
153
+ let t2;
154
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
155
+ t2 = /*#__PURE__*/ jsxs("svg", {
156
+ ...common,
157
+ children: [
158
+ /*#__PURE__*/ jsx("path", {
159
+ d: "M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"
160
+ }),
161
+ /*#__PURE__*/ jsx("path", {
162
+ d: "M12 9v4M12 17h.01"
163
+ })
164
+ ]
165
+ });
166
+ $[3] = t2;
167
+ } else t2 = $[3];
168
+ return t2;
169
+ }
170
+ default:
171
+ {
172
+ let t2;
173
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
174
+ t2 = /*#__PURE__*/ jsxs("svg", {
175
+ ...common,
176
+ children: [
177
+ /*#__PURE__*/ jsx("circle", {
178
+ cx: "12",
179
+ cy: "12",
180
+ r: "9"
181
+ }),
182
+ /*#__PURE__*/ jsx("path", {
183
+ d: "M12 16v-4M12 8h.01"
184
+ })
185
+ ]
186
+ });
187
+ $[4] = t2;
188
+ } else t2 = $[4];
189
+ return t2;
190
+ }
191
+ }
192
+ }
193
+ export { ConfirmDialog };
@@ -0,0 +1,13 @@
1
+ import { type ModalFuncProps } from './confirm-dialog';
2
+ export interface ModalFuncReturn {
3
+ destroy: () => void;
4
+ update: (configUpdate: Partial<ModalFuncProps> | ((prev: ModalFuncProps) => ModalFuncProps)) => void;
5
+ }
6
+ /** Registry of close handlers so `Modal.destroyAll()` can tear every instance down. */
7
+ export declare const destroyFns: Array<() => void>;
8
+ export default function confirm(config: ModalFuncProps): ModalFuncReturn;
9
+ export declare const withConfirm: (props: ModalFuncProps) => ModalFuncProps;
10
+ export declare const withInfo: (props: ModalFuncProps) => ModalFuncProps;
11
+ export declare const withSuccess: (props: ModalFuncProps) => ModalFuncProps;
12
+ export declare const withError: (props: ModalFuncProps) => ModalFuncProps;
13
+ export declare const withWarn: (props: ModalFuncProps) => ModalFuncProps;
@@ -0,0 +1,56 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createRoot } from "react-dom/client";
3
+ import { ConfirmDialog } from "./confirm-dialog.js";
4
+ const destroyFns = [];
5
+ function confirm_confirm(config) {
6
+ const container = document.createElement('div');
7
+ const root = createRoot(container);
8
+ let currentConfig = config;
9
+ let open = true;
10
+ function destroy() {
11
+ root.unmount();
12
+ const idx = destroyFns.indexOf(destroy);
13
+ if (-1 !== idx) destroyFns.splice(idx, 1);
14
+ }
15
+ function afterClose() {
16
+ currentConfig.afterClose?.();
17
+ destroy();
18
+ }
19
+ function close() {
20
+ open = false;
21
+ render();
22
+ }
23
+ function render() {
24
+ root.render(/*#__PURE__*/ jsx(ConfirmDialog, {
25
+ ...currentConfig,
26
+ open: open,
27
+ close: close,
28
+ afterClose: afterClose
29
+ }));
30
+ }
31
+ function update(configUpdate) {
32
+ currentConfig = 'function' == typeof configUpdate ? configUpdate(currentConfig) : {
33
+ ...currentConfig,
34
+ ...configUpdate
35
+ };
36
+ render();
37
+ }
38
+ render();
39
+ destroyFns.push(destroy);
40
+ return {
41
+ destroy: close,
42
+ update
43
+ };
44
+ }
45
+ const withType = (type, okCancel)=>(props)=>({
46
+ okCancel,
47
+ ...props,
48
+ type
49
+ });
50
+ const withConfirm = withType('confirm', true);
51
+ const withInfo = withType('info', false);
52
+ const withSuccess = withType('success', false);
53
+ const withError = withType('error', false);
54
+ const withWarn = withType('warning', false);
55
+ export default confirm_confirm;
56
+ export { destroyFns, withConfirm, withError, withInfo, withSuccess, withWarn };
@@ -0,0 +1,21 @@
1
+ import { type ModalFuncReturn } from './confirm';
2
+ import type { ModalFuncProps } from './confirm-dialog';
3
+ import { Modal as InternalModal } from './modal';
4
+ import { useModal } from './use-modal';
5
+ type ConfirmFn = (config: ModalFuncProps) => ModalFuncReturn;
6
+ type ModalType = typeof InternalModal & {
7
+ confirm: ConfirmFn;
8
+ info: ConfirmFn;
9
+ success: ConfirmFn;
10
+ error: ConfirmFn;
11
+ warning: ConfirmFn;
12
+ warn: ConfirmFn;
13
+ useModal: typeof useModal;
14
+ destroyAll: () => void;
15
+ };
16
+ declare const Modal: ModalType;
17
+ export type { ModalFuncReturn } from './confirm';
18
+ export type { ConfirmType, ModalFuncProps } from './confirm-dialog';
19
+ export type { ModalFooterRender, ModalProps, ModalSemanticPart } from './modal';
20
+ export type { ModalHookApi } from './use-modal';
21
+ export { Modal };
@@ -0,0 +1,18 @@
1
+ import confirm_0, { destroyFns, withConfirm, withError, withInfo, withSuccess, withWarn } from "./confirm.js";
2
+ import { Modal } from "./modal.js";
3
+ import { useModal } from "./use-modal.js";
4
+ const modal_Modal = Modal;
5
+ modal_Modal.confirm = (config)=>confirm_0(withConfirm(config));
6
+ modal_Modal.info = (config)=>confirm_0(withInfo(config));
7
+ modal_Modal.success = (config)=>confirm_0(withSuccess(config));
8
+ modal_Modal.error = (config)=>confirm_0(withError(config));
9
+ modal_Modal.warning = (config)=>confirm_0(withWarn(config));
10
+ modal_Modal.warn = modal_Modal.warning;
11
+ modal_Modal.useModal = useModal;
12
+ modal_Modal.destroyAll = ()=>{
13
+ while(destroyFns.length){
14
+ const close = destroyFns.pop();
15
+ close?.();
16
+ }
17
+ };
18
+ export { modal_Modal as Modal };