@duskmoon-dev/components 0.3.1 → 0.4.0

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 (109) hide show
  1. package/README.md +61 -2
  2. package/dist/{chunk-r9wkv7xd.js → chunk-fwjzvsrx.js} +3 -3
  3. package/dist/classes/chat.d.ts +43 -0
  4. package/dist/classes/console-page.d.ts +16 -0
  5. package/dist/classes/dropdown.d.ts +5 -5
  6. package/dist/classes/fab.d.ts +11 -0
  7. package/dist/classes/index.d.ts +6 -0
  8. package/dist/classes/index.js +1443 -1210
  9. package/dist/classes/megamenu.d.ts +10 -0
  10. package/dist/classes/otp-input.d.ts +12 -0
  11. package/dist/classes/popover.d.ts +1 -3
  12. package/dist/classes/swap.d.ts +12 -0
  13. package/dist/classes/tree-select.d.ts +6 -6
  14. package/dist/components/anchor/index.js +2 -2
  15. package/dist/components/app/index.js +211 -151
  16. package/dist/components/avatar/Avatar.types.d.ts +1 -1
  17. package/dist/components/avatar/index.js +2 -1
  18. package/dist/components/badge/index.js +1 -1
  19. package/dist/components/button/Button.d.ts +1 -1
  20. package/dist/components/button/Button.types.d.ts +8 -0
  21. package/dist/components/button/index.js +253 -24
  22. package/dist/components/calendar/index.js +44 -19
  23. package/dist/components/cascader/index.js +2 -2
  24. package/dist/components/chat/Chat.d.ts +22 -0
  25. package/dist/components/chat/Chat.types.d.ts +73 -0
  26. package/dist/components/chat/index.d.ts +2 -0
  27. package/dist/components/chat/index.js +309 -0
  28. package/dist/components/color-picker/ColorPicker.types.d.ts +2 -1
  29. package/dist/components/color-picker/index.js +210 -13
  30. package/dist/components/config-provider/index.js +2 -2
  31. package/dist/components/console-page/ConsolePage.d.ts +2 -0
  32. package/dist/components/console-page/ConsolePage.types.d.ts +29 -0
  33. package/dist/components/console-page/index.d.ts +2 -0
  34. package/dist/components/console-page/index.js +205 -0
  35. package/dist/components/date-picker/DatePicker.types.d.ts +1 -0
  36. package/dist/components/date-picker/index.js +537 -35
  37. package/dist/components/date-picker/usePickerDropdown.d.ts +17 -0
  38. package/dist/components/dm-breadcrumb/index.js +18 -18
  39. package/dist/components/dm-date-picker/index.js +635 -133
  40. package/dist/components/dm-drawer/index.js +269 -40
  41. package/dist/components/dm-layout/index.js +575 -208
  42. package/dist/components/dm-menu/index.js +399 -32
  43. package/dist/components/dm-message/index.js +18 -18
  44. package/dist/components/dm-page-header/index.js +537 -247
  45. package/dist/components/dm-pagination/index.js +39 -39
  46. package/dist/components/dm-pro-table/index.js +2374 -1559
  47. package/dist/components/dm-provider/index.js +94 -94
  48. package/dist/components/dm-query/DmQuery.types.d.ts +1 -1
  49. package/dist/components/dm-query/index.js +955 -210
  50. package/dist/components/dm-search/DmSearch.types.d.ts +4 -0
  51. package/dist/components/dm-search/index.js +937 -183
  52. package/dist/components/dm-splitter/index.js +32 -32
  53. package/dist/components/dm-status/index.js +25 -25
  54. package/dist/components/dm-table/index.js +1430 -676
  55. package/dist/components/dm-tabs/index.js +34 -34
  56. package/dist/components/dm-toolbar/index.js +423 -133
  57. package/dist/components/dm-tree/index.js +92 -92
  58. package/dist/components/dm-truncate/index.js +145 -65
  59. package/dist/components/dropdown/Dropdown.types.d.ts +1 -1
  60. package/dist/components/dropdown/index.js +467 -177
  61. package/dist/components/fab/Fab.d.ts +4 -0
  62. package/dist/components/fab/Fab.types.d.ts +25 -0
  63. package/dist/components/fab/index.d.ts +2 -0
  64. package/dist/components/fab/index.js +480 -0
  65. package/dist/components/form/Form.types.d.ts +1 -0
  66. package/dist/components/form/index.js +16 -5
  67. package/dist/components/grid/index.js +2 -2
  68. package/dist/components/input/index.js +4 -4
  69. package/dist/components/markdown/index.js +1 -1
  70. package/dist/components/megamenu/Megamenu.d.ts +2 -0
  71. package/dist/components/megamenu/Megamenu.types.d.ts +32 -0
  72. package/dist/components/megamenu/index.d.ts +2 -0
  73. package/dist/components/megamenu/index.js +214 -0
  74. package/dist/components/message/index.js +5 -5
  75. package/dist/components/modal/index.js +128 -68
  76. package/dist/components/notification/index.js +2 -2
  77. package/dist/components/otp-input/OtpInput.d.ts +2 -0
  78. package/dist/components/otp-input/OtpInput.types.d.ts +16 -0
  79. package/dist/components/otp-input/index.d.ts +2 -0
  80. package/dist/components/otp-input/index.js +112 -0
  81. package/dist/components/popconfirm/index.js +297 -68
  82. package/dist/components/popover/index.js +24 -4
  83. package/dist/components/skeleton/index.js +5 -5
  84. package/dist/components/spin/index.js +2 -2
  85. package/dist/components/steps/index.js +2 -2
  86. package/dist/components/swap/Swap.d.ts +3 -0
  87. package/dist/components/swap/Swap.types.d.ts +22 -0
  88. package/dist/components/swap/index.d.ts +2 -0
  89. package/dist/components/swap/index.js +109 -0
  90. package/dist/components/table/index.js +2 -2
  91. package/dist/components/tabs/index.js +2 -2
  92. package/dist/components/tag/index.js +2 -2
  93. package/dist/components/time-picker/TimePicker.types.d.ts +1 -0
  94. package/dist/components/time-picker/index.js +167 -29
  95. package/dist/components/tooltip/Tooltip.types.d.ts +4 -0
  96. package/dist/components/tooltip/index.js +107 -27
  97. package/dist/components/tour/index.js +315 -86
  98. package/dist/components/tree-select/index.js +8 -8
  99. package/dist/components/typography/index.js +4 -4
  100. package/dist/components/upload/Upload.types.d.ts +1 -0
  101. package/dist/components/upload/index.js +7 -5
  102. package/dist/generated/version.d.ts +1 -1
  103. package/dist/index.d.ts +6 -0
  104. package/dist/index.js +4023 -2134
  105. package/dist/infrastructure.js +11 -11
  106. package/dist/styles.css +13677 -9811
  107. package/dist/theme/index.js +3 -3
  108. package/dist/utils/index.js +5 -5
  109. package/package.json +30 -6
@@ -0,0 +1,214 @@
1
+ "use client";
2
+
3
+ // src/components/megamenu/Megamenu.tsx
4
+ import {
5
+ createContext,
6
+ forwardRef,
7
+ useContext,
8
+ useId
9
+ } from "react";
10
+
11
+ // src/classes/megamenu.ts
12
+ var megamenuClass = "megamenu";
13
+ var megamenuBarClass = "megamenu-bar";
14
+ var megamenuTriggerClass = "megamenu-trigger";
15
+ var megamenuPanelClass = "megamenu-panel";
16
+ var megamenuGridClass = "megamenu-grid";
17
+ var megamenuGroupClass = "megamenu-group";
18
+ var megamenuHeadingClass = "megamenu-heading";
19
+ var megamenuSupportingClass = "megamenu-supporting";
20
+ var megamenuMobileClass = "megamenu-mobile";
21
+
22
+ // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
23
+ function r(e) {
24
+ var t, f, n = "";
25
+ if (typeof e == "string" || typeof e == "number")
26
+ n += e;
27
+ else if (typeof e == "object")
28
+ if (Array.isArray(e)) {
29
+ var o = e.length;
30
+ for (t = 0;t < o; t++)
31
+ e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
32
+ } else
33
+ for (f in e)
34
+ e[f] && (n && (n += " "), n += f);
35
+ return n;
36
+ }
37
+ function clsx() {
38
+ for (var e, t, f = 0, n = "", o = arguments.length;f < o; f++)
39
+ (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
40
+ return n;
41
+ }
42
+
43
+ // src/utils/cn.ts
44
+ function cn(...inputs) {
45
+ return clsx(inputs);
46
+ }
47
+ // src/components/megamenu/Megamenu.tsx
48
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
49
+ var ItemContext = createContext(null);
50
+ function useItem() {
51
+ const context = useContext(ItemContext);
52
+ if (!context)
53
+ throw new Error("Megamenu.Trigger and Panel require Megamenu.Item");
54
+ return context;
55
+ }
56
+ var Bar = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("ul", {
57
+ ...props,
58
+ ref,
59
+ className: cn(megamenuBarClass, "megamenu-desktop", className)
60
+ }));
61
+ Bar.displayName = "Megamenu.Bar";
62
+ var Item = forwardRef(({ style, children, ...props }, ref) => {
63
+ const key = useId().replace(/:/g, "");
64
+ const panelId = `megamenu-panel-${key}`;
65
+ const anchorStyle = {
66
+ ...style,
67
+ "--megamenu-anchor": `--megamenu-${key}`
68
+ };
69
+ return /* @__PURE__ */ jsx(ItemContext.Provider, {
70
+ value: { panelId },
71
+ children: /* @__PURE__ */ jsx("li", {
72
+ ...props,
73
+ ref,
74
+ style: anchorStyle,
75
+ children
76
+ })
77
+ });
78
+ });
79
+ Item.displayName = "Megamenu.Item";
80
+ var Trigger = forwardRef(({ className, type = "button", ...props }, ref) => {
81
+ const { panelId } = useItem();
82
+ return /* @__PURE__ */ jsx("button", {
83
+ ...props,
84
+ ref,
85
+ type,
86
+ popoverTarget: panelId,
87
+ className: cn(megamenuTriggerClass, className)
88
+ });
89
+ });
90
+ Trigger.displayName = "Megamenu.Trigger";
91
+ var Panel = forwardRef(({ full, className, ...props }, ref) => {
92
+ const { panelId } = useItem();
93
+ return /* @__PURE__ */ jsx("div", {
94
+ ...props,
95
+ ref,
96
+ id: panelId,
97
+ popover: "auto",
98
+ className: cn(megamenuPanelClass, full && "megamenu-panel-full", className)
99
+ });
100
+ });
101
+ Panel.displayName = "Megamenu.Panel";
102
+ var Grid = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
103
+ ...props,
104
+ ref,
105
+ className: cn(megamenuGridClass, className)
106
+ }));
107
+ Grid.displayName = "Megamenu.Grid";
108
+ var Group = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("section", {
109
+ ...props,
110
+ ref,
111
+ className: cn(megamenuGroupClass, className)
112
+ }));
113
+ Group.displayName = "Megamenu.Group";
114
+ var Heading = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("h2", {
115
+ ...props,
116
+ ref,
117
+ className: cn(megamenuHeadingClass, className)
118
+ }));
119
+ Heading.displayName = "Megamenu.Heading";
120
+ var Supporting = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", {
121
+ ...props,
122
+ ref,
123
+ className: cn(megamenuSupportingClass, className)
124
+ }));
125
+ Supporting.displayName = "Megamenu.Supporting";
126
+ var Mobile = forwardRef(({ summary, className, children, ...props }, ref) => /* @__PURE__ */ jsxs("details", {
127
+ ...props,
128
+ ref,
129
+ className: cn(megamenuMobileClass, className),
130
+ children: [
131
+ /* @__PURE__ */ jsx("summary", {
132
+ children: summary
133
+ }),
134
+ children
135
+ ]
136
+ }));
137
+ Mobile.displayName = "Megamenu.Mobile";
138
+ var MegamenuRoot = forwardRef(({
139
+ trigger,
140
+ panelHeading,
141
+ panel,
142
+ mobile,
143
+ leading,
144
+ fullWidth,
145
+ className,
146
+ children,
147
+ ...props
148
+ }, ref) => {
149
+ const key = useId().replace(/[^a-zA-Z0-9_-]/g, "");
150
+ const panelId = `dm-megamenu-${key}`;
151
+ const headingId = `${panelId}-heading`;
152
+ const anchorStyle = {
153
+ "--megamenu-anchor": `--dm-megamenu-${key}`
154
+ };
155
+ return /* @__PURE__ */ jsx("nav", {
156
+ ...props,
157
+ ref,
158
+ className: cn(megamenuClass, className),
159
+ children: trigger != null ? /* @__PURE__ */ jsxs(Fragment, {
160
+ children: [
161
+ /* @__PURE__ */ jsxs(Bar, {
162
+ children: [
163
+ leading != null && /* @__PURE__ */ jsx("li", {
164
+ children: leading
165
+ }),
166
+ /* @__PURE__ */ jsxs("li", {
167
+ children: [
168
+ /* @__PURE__ */ jsx("button", {
169
+ type: "button",
170
+ className: megamenuTriggerClass,
171
+ popoverTarget: panelId,
172
+ style: anchorStyle,
173
+ children: trigger
174
+ }),
175
+ /* @__PURE__ */ jsxs("div", {
176
+ id: panelId,
177
+ className: cn(megamenuPanelClass, fullWidth && "megamenu-panel-full"),
178
+ popover: "auto",
179
+ "aria-labelledby": headingId,
180
+ style: anchorStyle,
181
+ children: [
182
+ /* @__PURE__ */ jsx(Heading, {
183
+ id: headingId,
184
+ children: panelHeading
185
+ }),
186
+ panel
187
+ ]
188
+ })
189
+ ]
190
+ })
191
+ ]
192
+ }),
193
+ /* @__PURE__ */ jsx("div", {
194
+ className: megamenuMobileClass,
195
+ children: mobile
196
+ })
197
+ ]
198
+ }) : children
199
+ });
200
+ });
201
+ MegamenuRoot.displayName = "Megamenu";
202
+ MegamenuRoot.Bar = Bar;
203
+ MegamenuRoot.Item = Item;
204
+ MegamenuRoot.Trigger = Trigger;
205
+ MegamenuRoot.Panel = Panel;
206
+ MegamenuRoot.Grid = Grid;
207
+ MegamenuRoot.Group = Group;
208
+ MegamenuRoot.Heading = Heading;
209
+ MegamenuRoot.Supporting = Supporting;
210
+ MegamenuRoot.Mobile = Mobile;
211
+ var Megamenu = MegamenuRoot;
212
+ export {
213
+ Megamenu
214
+ };
@@ -154,13 +154,13 @@ function config(nextConfig) {
154
154
  emit();
155
155
  }
156
156
  function MessageHolder({ className }) {
157
- const snapshot2 = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
157
+ const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
158
158
  return /* @__PURE__ */ jsx("div", {
159
159
  className: getMessageHolderClasses({
160
- placement: snapshot2.config.placement,
160
+ placement: snapshot.config.placement,
161
161
  className
162
162
  }),
163
- children: snapshot2.messages.map((item) => /* @__PURE__ */ jsxs("div", {
163
+ children: snapshot.messages.map((item) => /* @__PURE__ */ jsxs("div", {
164
164
  className: getMessageClasses({
165
165
  type: item.type,
166
166
  className: item.className
@@ -200,6 +200,6 @@ var message = {
200
200
  useMessage: () => [message, /* @__PURE__ */ jsx(MessageHolder, {}, "message-holder")]
201
201
  };
202
202
  export {
203
- message,
204
- MessageHolder
203
+ MessageHolder,
204
+ message
205
205
  };
@@ -5,6 +5,7 @@ import {
5
5
  forwardRef,
6
6
  useCallback,
7
7
  useEffect,
8
+ useId,
8
9
  useRef,
9
10
  useState
10
11
  } from "react";
@@ -35,22 +36,12 @@ function cn(...inputs) {
35
36
  return clsx(inputs);
36
37
  }
37
38
  // src/classes/modal.ts
38
- var modalBackdropClass = "modal-backdrop";
39
- var modalOpenClass = "modal-open";
40
- var modalBackdropCenterClass = "modal-backdrop-center";
41
39
  var modalClass = "modal";
42
40
  var modalHeaderClass = "modal-header";
43
41
  var modalTitleClass = "modal-title";
44
42
  var modalCloseClass = "modal-close";
45
43
  var modalBodyClass = "modal-body";
46
44
  var modalFooterClass = "modal-footer";
47
- function getModalBackdropClasses({
48
- open,
49
- centered,
50
- className
51
- }) {
52
- return cn(modalBackdropClass, open && modalOpenClass, centered && modalBackdropCenterClass, className);
53
- }
54
45
  function getModalClasses({ className }) {
55
46
  return cn(modalClass, className);
56
47
  }
@@ -81,6 +72,13 @@ function getModalStyle({
81
72
  ...width !== undefined ? { width } : undefined
82
73
  };
83
74
  }
75
+ function showNativeModal(dialog) {
76
+ if (!dialog.isConnected || dialog.matches(":modal"))
77
+ return;
78
+ if (dialog.open)
79
+ dialog.close();
80
+ dialog.showModal();
81
+ }
84
82
  var ModalBase = forwardRef(({
85
83
  open,
86
84
  defaultOpen = false,
@@ -103,15 +101,41 @@ var ModalBase = forwardRef(({
103
101
  maskClassName,
104
102
  closeIcon = defaultCloseIcon,
105
103
  style,
106
- role = "dialog",
104
+ role,
107
105
  ...props
108
106
  }, ref) => {
109
107
  const controlled = open !== undefined;
110
108
  const [innerOpen, setInnerOpen] = useState(defaultOpen);
111
109
  const mergedOpen = controlled ? Boolean(open) : innerOpen;
112
110
  const previousOpen = useRef(mergedOpen);
111
+ const desiredOpen = useRef(mergedOpen);
112
+ desiredOpen.current = mergedOpen;
113
+ const dialogRef = useRef(null);
114
+ const cancelRequestRef = useRef(null);
115
+ const programmaticClose = useRef(false);
116
+ const titleId = useId();
117
+ const surfaceWidth = width ?? style?.width;
118
+ const callerNamed = props["aria-label"] != null || props["aria-labelledby"] != null;
113
119
  const showClose = closable && closeIcon !== null && closeIcon !== false;
114
120
  const body = children ?? content;
121
+ useEffect(() => {
122
+ const dialog = dialogRef.current;
123
+ if (!dialog)
124
+ return;
125
+ if (mergedOpen) {
126
+ programmaticClose.current = false;
127
+ showNativeModal(dialog);
128
+ } else if (dialog.open) {
129
+ programmaticClose.current = true;
130
+ dialog.close();
131
+ }
132
+ return () => {
133
+ if (dialog.open) {
134
+ programmaticClose.current = true;
135
+ dialog.close();
136
+ }
137
+ };
138
+ }, [mergedOpen]);
115
139
  useEffect(() => {
116
140
  if (previousOpen.current === mergedOpen) {
117
141
  return;
@@ -128,73 +152,109 @@ var ModalBase = forwardRef(({
128
152
  const handleOk = useCallback((event) => {
129
153
  onOk?.(event);
130
154
  }, [onOk]);
131
- const handleMaskClick = useCallback((event) => {
132
- if (event.target !== event.currentTarget || !maskClosable) {
155
+ const requestCancel = useCallback(() => {
156
+ cancelRequestRef.current?.click();
157
+ }, []);
158
+ const handleNativeClose = useCallback(() => {
159
+ const dialog = dialogRef.current;
160
+ if (!dialog || dialog.open || programmaticClose.current) {
161
+ programmaticClose.current = false;
133
162
  return;
134
163
  }
135
- close(event);
136
- }, [close, maskClosable]);
164
+ if (desiredOpen.current) {
165
+ requestCancel();
166
+ if (controlled) {
167
+ queueMicrotask(() => {
168
+ if (desiredOpen.current) {
169
+ showNativeModal(dialog);
170
+ }
171
+ });
172
+ }
173
+ }
174
+ }, [controlled, requestCancel]);
137
175
  if (!mergedOpen && destroyOnClose) {
138
176
  return null;
139
177
  }
140
- return /* @__PURE__ */ jsx("div", {
141
- "aria-hidden": mergedOpen ? undefined : true,
142
- role: "presentation",
143
- className: getModalBackdropClasses({
144
- open: mergedOpen,
145
- centered,
146
- className: maskClassName
147
- }),
148
- onMouseDown: handleMaskClick,
149
- children: /* @__PURE__ */ jsxs("div", {
150
- ...props,
151
- ref,
152
- role,
153
- "aria-modal": mergedOpen ? true : undefined,
154
- className: getModalClasses({ className }),
155
- style: getModalStyle({ width, style }),
156
- children: [
157
- title !== undefined || showClose ? /* @__PURE__ */ jsxs("div", {
158
- className: modalHeaderClass,
159
- children: [
160
- title !== undefined ? /* @__PURE__ */ jsx("h2", {
161
- className: modalTitleClass,
162
- children: title
163
- }) : null,
164
- showClose ? /* @__PURE__ */ jsx("button", {
165
- type: "button",
166
- className: modalCloseClass,
167
- "aria-label": "Close",
168
- onClick: close,
169
- children: closeIcon
170
- }) : null
171
- ]
172
- }) : null,
173
- /* @__PURE__ */ jsx("div", {
174
- className: modalBodyClass,
175
- children: body
176
- }),
177
- footer === null ? null : /* @__PURE__ */ jsx("div", {
178
- className: modalFooterClass,
179
- children: footer !== undefined ? footer : /* @__PURE__ */ jsxs(Fragment, {
178
+ return /* @__PURE__ */ jsxs("dialog", {
179
+ ref: dialogRef,
180
+ role: role === "alertdialog" ? role : undefined,
181
+ "aria-label": props["aria-label"] ?? (!callerNamed && title == null ? "Modal" : undefined),
182
+ "aria-labelledby": props["aria-labelledby"] ?? (!callerNamed && title != null ? titleId : undefined),
183
+ "aria-describedby": props["aria-describedby"],
184
+ className: getModalClasses({ className: cn(maskClassName, centered ? "modal-middle" : "modal-top") }),
185
+ style: surfaceWidth !== undefined ? { width: surfaceWidth, maxWidth: surfaceWidth } : undefined,
186
+ onCancel: (event) => {
187
+ event.preventDefault();
188
+ requestCancel();
189
+ },
190
+ onClose: handleNativeClose,
191
+ onMouseDown: (event) => {
192
+ if (!maskClosable || event.target !== event.currentTarget)
193
+ return;
194
+ const { left, right, top, bottom } = event.currentTarget.getBoundingClientRect();
195
+ if (event.clientX < left || event.clientX > right || event.clientY < top || event.clientY > bottom) {
196
+ requestCancel();
197
+ }
198
+ },
199
+ children: [
200
+ /* @__PURE__ */ jsx("button", {
201
+ ref: cancelRequestRef,
202
+ type: "button",
203
+ hidden: true,
204
+ tabIndex: -1,
205
+ "aria-hidden": "true",
206
+ onClick: close
207
+ }),
208
+ /* @__PURE__ */ jsxs("div", {
209
+ ...props,
210
+ ref,
211
+ role,
212
+ className: cn("modal-box", "react-modal-box", className),
213
+ style: getModalStyle({ width, style }),
214
+ children: [
215
+ title !== undefined || showClose ? /* @__PURE__ */ jsxs("div", {
216
+ className: modalHeaderClass,
180
217
  children: [
181
- /* @__PURE__ */ jsx("button", {
218
+ title !== undefined ? /* @__PURE__ */ jsx("h2", {
219
+ id: titleId,
220
+ className: modalTitleClass,
221
+ children: title
222
+ }) : null,
223
+ showClose ? /* @__PURE__ */ jsx("button", {
182
224
  type: "button",
225
+ className: modalCloseClass,
226
+ "aria-label": "Close",
183
227
  onClick: close,
184
- children: cancelText
185
- }),
186
- /* @__PURE__ */ jsx("button", {
187
- type: "button",
188
- "aria-busy": confirmLoading,
189
- disabled: confirmLoading,
190
- onClick: handleOk,
191
- children: okText
192
- })
228
+ children: closeIcon
229
+ }) : null
193
230
  ]
231
+ }) : null,
232
+ /* @__PURE__ */ jsx("div", {
233
+ className: modalBodyClass,
234
+ children: body
235
+ }),
236
+ footer === null ? null : /* @__PURE__ */ jsx("div", {
237
+ className: modalFooterClass,
238
+ children: footer !== undefined ? footer : /* @__PURE__ */ jsxs(Fragment, {
239
+ children: [
240
+ /* @__PURE__ */ jsx("button", {
241
+ type: "button",
242
+ onClick: close,
243
+ children: cancelText
244
+ }),
245
+ /* @__PURE__ */ jsx("button", {
246
+ type: "button",
247
+ "aria-busy": confirmLoading,
248
+ disabled: confirmLoading,
249
+ onClick: handleOk,
250
+ children: okText
251
+ })
252
+ ]
253
+ })
194
254
  })
195
- })
196
- ]
197
- })
255
+ ]
256
+ })
257
+ ]
198
258
  });
199
259
  });
200
260
  ModalBase.displayName = "Modal";
@@ -415,6 +415,6 @@ function useNotification(config = {}) {
415
415
  }
416
416
  var notification = globalApi;
417
417
  export {
418
- useNotification,
419
- notification
418
+ notification,
419
+ useNotification
420
420
  };
@@ -0,0 +1,2 @@
1
+ import type { OtpInputProps } from "./OtpInput.types";
2
+ export declare const OtpInput: import("react").ForwardRefExoticComponent<Omit<OtpInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,16 @@
1
+ import type { ComponentProps } from "react";
2
+ export type OtpInputLength = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
3
+ export type OtpInputSize = "xs" | "sm" | "md" | "lg" | "xl";
4
+ export type OtpInputVariant = "outlined" | "filled" | "underlined";
5
+ export type OtpInputColor = "primary" | "secondary" | "tertiary" | "info" | "success" | "warning" | "error" | "accent" | "neutral" | "base";
6
+ export interface OtpInputProps extends Omit<ComponentProps<"input">, "children" | "className" | "size" | "type"> {
7
+ /** Number of decorative slots. Native input constraints default to this length. */
8
+ length?: OtpInputLength;
9
+ size?: OtpInputSize;
10
+ variant?: OtpInputVariant;
11
+ color?: OtpInputColor;
12
+ /** Additional class names for the wrapping label. */
13
+ wrapperClassName?: string;
14
+ /** Additional class names for the native input. */
15
+ className?: string;
16
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./OtpInput";
2
+ export * from "./OtpInput.types";
@@ -0,0 +1,112 @@
1
+ "use client";
2
+
3
+ // src/components/otp-input/OtpInput.tsx
4
+ import { forwardRef } from "react";
5
+
6
+ // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
7
+ function r(e) {
8
+ var t, f, n = "";
9
+ if (typeof e == "string" || typeof e == "number")
10
+ n += e;
11
+ else if (typeof e == "object")
12
+ if (Array.isArray(e)) {
13
+ var o = e.length;
14
+ for (t = 0;t < o; t++)
15
+ e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
16
+ } else
17
+ for (f in e)
18
+ e[f] && (n && (n += " "), n += f);
19
+ return n;
20
+ }
21
+ function clsx() {
22
+ for (var e, t, f = 0, n = "", o = arguments.length;f < o; f++)
23
+ (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
24
+ return n;
25
+ }
26
+
27
+ // src/utils/cn.ts
28
+ function cn(...inputs) {
29
+ return clsx(inputs);
30
+ }
31
+ // src/classes/otp-input.ts
32
+ var otpInputBaseClass = "otp-input";
33
+ var otpInputCodeClass = "otp-code";
34
+ var otpInputSizeClasses = {
35
+ xs: "otp-input-xs",
36
+ sm: "otp-input-sm",
37
+ md: "otp-input-md",
38
+ lg: "otp-input-lg",
39
+ xl: "otp-input-xl"
40
+ };
41
+ var otpInputVariantClasses = {
42
+ outlined: "",
43
+ filled: "otp-input-filled",
44
+ underlined: "otp-input-underline"
45
+ };
46
+ var otpInputColorClasses = {
47
+ primary: "otp-input-primary",
48
+ secondary: "otp-input-secondary",
49
+ tertiary: "otp-input-tertiary",
50
+ info: "otp-input-info",
51
+ success: "otp-input-success",
52
+ warning: "otp-input-warning",
53
+ error: "otp-input-error",
54
+ accent: "otp-input-accent",
55
+ neutral: "otp-input-neutral",
56
+ base: "otp-input-base"
57
+ };
58
+ function getOtpInputClasses({
59
+ size = "md",
60
+ variant = "outlined",
61
+ color,
62
+ wrapperClassName
63
+ }) {
64
+ return cn(otpInputBaseClass, otpInputSizeClasses[size], otpInputVariantClasses[variant], color && otpInputColorClasses[color], wrapperClassName);
65
+ }
66
+ function getOtpInputCodeClasses({ className }) {
67
+ return cn(otpInputCodeClass, className);
68
+ }
69
+
70
+ // src/components/otp-input/OtpInput.tsx
71
+ import { jsx, jsxs } from "react/jsx-runtime";
72
+ var OtpInput = forwardRef(({
73
+ length = 6,
74
+ size = "md",
75
+ variant = "outlined",
76
+ color,
77
+ wrapperClassName,
78
+ className,
79
+ autoComplete,
80
+ inputMode,
81
+ minLength,
82
+ maxLength,
83
+ pattern,
84
+ ...inputProps
85
+ }, ref) => /* @__PURE__ */ jsxs("label", {
86
+ className: getOtpInputClasses({
87
+ size,
88
+ variant,
89
+ color,
90
+ wrapperClassName
91
+ }),
92
+ children: [
93
+ Array.from({ length }, (_, index) => /* @__PURE__ */ jsx("span", {
94
+ "aria-hidden": "true"
95
+ }, index)),
96
+ /* @__PURE__ */ jsx("input", {
97
+ ...inputProps,
98
+ ref,
99
+ type: "text",
100
+ className: getOtpInputCodeClasses({ className }),
101
+ autoComplete: autoComplete ?? "one-time-code",
102
+ inputMode: inputMode ?? "numeric",
103
+ minLength: minLength ?? length,
104
+ maxLength: maxLength ?? length,
105
+ pattern: pattern ?? `[0-9]{${length}}`
106
+ })
107
+ ]
108
+ }));
109
+ OtpInput.displayName = "OtpInput";
110
+ export {
111
+ OtpInput
112
+ };