@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,4 @@
1
+ import React from "react";
2
+ import type { FabComponent, FabActionProps } from "./Fab.types";
3
+ export declare const Fab: FabComponent;
4
+ export declare const FabAction: React.ForwardRefExoticComponent<FabActionProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,25 @@
1
+ import type { ComponentProps, ForwardRefExoticComponent, ReactNode, RefAttributes } from "react";
2
+ import type { ButtonProps } from "../button";
3
+ export interface FabProps extends Omit<ComponentProps<"div">, "ref"> {
4
+ contained?: boolean;
5
+ start?: boolean;
6
+ speedDial?: boolean;
7
+ label?: string;
8
+ actions?: ReactNode;
9
+ extended?: boolean;
10
+ buttonProps?: Omit<ButtonProps, "children" | "type" | "popoverTarget" | "aria-label">;
11
+ }
12
+ export interface FabActionProps extends FabSectionProps {
13
+ label?: ReactNode;
14
+ }
15
+ export interface FabTriggerProps extends ButtonProps {
16
+ extended?: boolean;
17
+ }
18
+ export type FabSectionProps = Omit<ComponentProps<"div">, "ref">;
19
+ export type FabLabelProps = Omit<ComponentProps<"span">, "ref">;
20
+ export interface FabComponent extends ForwardRefExoticComponent<FabProps & RefAttributes<HTMLDivElement>> {
21
+ Trigger: ForwardRefExoticComponent<FabTriggerProps & RefAttributes<HTMLButtonElement>>;
22
+ Actions: ForwardRefExoticComponent<FabSectionProps & RefAttributes<HTMLDivElement>>;
23
+ Action: ForwardRefExoticComponent<FabSectionProps & RefAttributes<HTMLDivElement>>;
24
+ Label: ForwardRefExoticComponent<FabLabelProps & RefAttributes<HTMLSpanElement>>;
25
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Fab";
2
+ export * from "./Fab.types";
@@ -0,0 +1,480 @@
1
+ "use client";
2
+
3
+ // src/components/fab/Fab.tsx
4
+ import { createContext, forwardRef, useContext, useId } 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/fab.ts
32
+ var fabClass = "fab";
33
+ var fabTriggerClass = "fab-trigger";
34
+ var fabActionsClass = "fab-actions";
35
+ var fabActionClass = "fab-action";
36
+ var fabLabelClass = "fab-label";
37
+ function getFabClasses({
38
+ contained,
39
+ start,
40
+ speedDial,
41
+ className
42
+ }) {
43
+ return cn(fabClass, contained && "fab-contained", start && "fab-start", speedDial && "fab-speed-dial", className);
44
+ }
45
+
46
+ // src/components/button/Button.tsx
47
+ import React from "react";
48
+ import { createPortal } from "react-dom";
49
+
50
+ // src/classes/button.ts
51
+ var buttonBaseClass = "btn";
52
+ var buttonColorClasses = {
53
+ primary: "btn-primary",
54
+ secondary: "btn-secondary",
55
+ tertiary: "btn-tertiary",
56
+ accent: "btn-accent",
57
+ neutral: "btn-neutral",
58
+ base: "btn-base",
59
+ info: "btn-info",
60
+ success: "btn-success",
61
+ warning: "btn-warning",
62
+ error: "btn-error"
63
+ };
64
+ var buttonAppearanceClasses = {
65
+ filled: "",
66
+ outline: "btn-outline",
67
+ tonal: "btn-tonal",
68
+ ghost: "btn-ghost",
69
+ text: "btn-text"
70
+ };
71
+ var buttonShapeClasses = {
72
+ rect: "",
73
+ circle: "btn-circle btn-icon",
74
+ square: "btn-square"
75
+ };
76
+ var buttonSizeClasses = {
77
+ xs: "btn-xs",
78
+ sm: "btn-sm",
79
+ md: "btn-md",
80
+ lg: "btn-lg"
81
+ };
82
+ var buttonBlockClass = "btn-block";
83
+ var buttonIsLoadingClass = "btn-loading";
84
+ function getButtonClasses({
85
+ color = "primary",
86
+ appearance = "filled",
87
+ shape = "rect",
88
+ size = "md",
89
+ block,
90
+ isLoading,
91
+ className
92
+ }) {
93
+ return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], shape === "circle" && size === "xs" && "btn-icon-sm", shape === "circle" && size === "sm" && "btn-icon-sm", shape === "circle" && size === "lg" && "btn-icon-lg", block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
94
+ }
95
+
96
+ // src/components/button/Button.tsx
97
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
98
+ function isPromiseLike(value) {
99
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
100
+ }
101
+ function Button({
102
+ color = "primary",
103
+ appearance = "filled",
104
+ shape = "rect",
105
+ size = "md",
106
+ block,
107
+ isLoading,
108
+ leftIcon,
109
+ rightIcon,
110
+ className,
111
+ children,
112
+ disabled,
113
+ ref,
114
+ confirm,
115
+ onClick,
116
+ ...props
117
+ }) {
118
+ const buttonRef = React.useRef(null);
119
+ const popoverRef = React.useRef(null);
120
+ const cancelRef = React.useRef(null);
121
+ const approvalRef = React.useRef("idle");
122
+ const pendingRef = React.useRef(false);
123
+ const actionRef = React.useRef(0);
124
+ const operationRef = React.useRef(0);
125
+ const mountedRef = React.useRef(false);
126
+ const [portalTarget, setPortalTarget] = React.useState(null);
127
+ const [confirmLoading, setConfirmLoading] = React.useState(false);
128
+ const [confirmError, setConfirmError] = React.useState(false);
129
+ const generatedId = React.useId().replace(/:/g, "");
130
+ const popoverId = `button-confirm-${generatedId}`;
131
+ const titleId = `${popoverId}-title`;
132
+ const descriptionId = `${popoverId}-description`;
133
+ const anchor = `--${popoverId}-anchor`;
134
+ const hasConfirm = Boolean(confirm);
135
+ const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
136
+ const title = confirmation ? confirmation.title : "Confirm action";
137
+ const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
138
+ const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
139
+ const hasContent = content !== undefined && content !== null && content !== false && content !== "";
140
+ const mergedRef = React.useCallback((node) => {
141
+ buttonRef.current = node;
142
+ if (!node) {
143
+ if (typeof ref === "function")
144
+ ref(null);
145
+ else if (ref)
146
+ ref.current = null;
147
+ return;
148
+ }
149
+ const cleanup = typeof ref === "function" ? ref(node) : undefined;
150
+ if (ref && typeof ref !== "function")
151
+ ref.current = node;
152
+ return () => {
153
+ buttonRef.current = null;
154
+ if (typeof cleanup === "function")
155
+ cleanup();
156
+ else if (typeof ref === "function")
157
+ ref(null);
158
+ else if (ref)
159
+ ref.current = null;
160
+ };
161
+ }, [ref]);
162
+ React.useEffect(() => {
163
+ mountedRef.current = true;
164
+ return () => {
165
+ mountedRef.current = false;
166
+ operationRef.current += 1;
167
+ };
168
+ }, []);
169
+ React.useEffect(() => {
170
+ operationRef.current += 1;
171
+ approvalRef.current = "idle";
172
+ setConfirmError(false);
173
+ setPortalTarget(hasConfirm ? document.body : null);
174
+ }, [hasConfirm]);
175
+ function closePopover() {
176
+ if (popoverRef.current?.matches(":popover-open")) {
177
+ popoverRef.current.hidePopover();
178
+ }
179
+ buttonRef.current?.focus();
180
+ }
181
+ function handleClick(event) {
182
+ if (!confirm) {
183
+ onClick?.(event);
184
+ return;
185
+ }
186
+ if (approvalRef.current === "native") {
187
+ approvalRef.current = "idle";
188
+ return;
189
+ }
190
+ if (approvalRef.current === "action") {
191
+ approvalRef.current = "idle";
192
+ let result;
193
+ try {
194
+ result = onClick?.(event);
195
+ } catch {
196
+ event.preventDefault();
197
+ pendingRef.current = false;
198
+ setConfirmError(true);
199
+ return;
200
+ }
201
+ if (!isPromiseLike(result)) {
202
+ pendingRef.current = false;
203
+ closePopover();
204
+ return;
205
+ }
206
+ const userPreventedDefault = event.defaultPrevented;
207
+ event.preventDefault();
208
+ setConfirmLoading(true);
209
+ const action = actionRef.current;
210
+ const operation = operationRef.current;
211
+ Promise.resolve(result).then(() => {
212
+ if (!mountedRef.current || action !== actionRef.current)
213
+ return;
214
+ pendingRef.current = false;
215
+ setConfirmLoading(false);
216
+ if (operation !== operationRef.current)
217
+ return;
218
+ closePopover();
219
+ if (!userPreventedDefault && !buttonRef.current?.disabled) {
220
+ approvalRef.current = "native";
221
+ buttonRef.current?.click();
222
+ approvalRef.current = "idle";
223
+ }
224
+ }, () => {
225
+ if (!mountedRef.current || action !== actionRef.current)
226
+ return;
227
+ pendingRef.current = false;
228
+ setConfirmLoading(false);
229
+ if (operation !== operationRef.current)
230
+ return;
231
+ setConfirmError(true);
232
+ cancelRef.current?.focus();
233
+ });
234
+ return;
235
+ }
236
+ event.preventDefault();
237
+ if (disabled || isLoading || pendingRef.current)
238
+ return;
239
+ if (popoverRef.current?.matches(":popover-open")) {
240
+ closePopover();
241
+ return;
242
+ }
243
+ setConfirmError(false);
244
+ popoverRef.current?.showPopover();
245
+ cancelRef.current?.focus();
246
+ }
247
+ function handleConfirm(event) {
248
+ event.preventDefault();
249
+ event.stopPropagation();
250
+ const trigger = buttonRef.current;
251
+ if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
252
+ return;
253
+ setConfirmError(false);
254
+ pendingRef.current = true;
255
+ actionRef.current += 1;
256
+ approvalRef.current = "action";
257
+ trigger.click();
258
+ if (approvalRef.current === "action") {
259
+ approvalRef.current = "idle";
260
+ pendingRef.current = false;
261
+ }
262
+ }
263
+ const classes = getButtonClasses({
264
+ color,
265
+ appearance,
266
+ shape,
267
+ size,
268
+ block,
269
+ isLoading,
270
+ className
271
+ });
272
+ const confirmClasses = getButtonClasses({
273
+ color,
274
+ size: "sm",
275
+ isLoading: confirmLoading
276
+ });
277
+ return /* @__PURE__ */ jsxs(Fragment, {
278
+ children: [
279
+ /* @__PURE__ */ jsxs("button", {
280
+ ref: confirm ? mergedRef : ref,
281
+ className: classes,
282
+ disabled: disabled || isLoading,
283
+ "aria-busy": isLoading,
284
+ "aria-disabled": disabled || isLoading,
285
+ ...props,
286
+ style: confirm ? { ...props.style, anchorName: anchor } : props.style,
287
+ "aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
288
+ "aria-controls": confirm ? popoverId : props["aria-controls"],
289
+ onClick: confirm ? handleClick : onClick,
290
+ children: [
291
+ isLoading && /* @__PURE__ */ jsx("span", {
292
+ className: "btn-spinner"
293
+ }),
294
+ !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
295
+ className: "btn-icon-left",
296
+ children: leftIcon
297
+ }),
298
+ /* @__PURE__ */ jsx("span", {
299
+ className: "btn-content",
300
+ children
301
+ }),
302
+ !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
303
+ className: "btn-icon-right",
304
+ children: rightIcon
305
+ })
306
+ ]
307
+ }),
308
+ confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
309
+ id: popoverId,
310
+ ref: popoverRef,
311
+ popover: "auto",
312
+ role: "dialog",
313
+ "aria-labelledby": hasTitle ? titleId : undefined,
314
+ "aria-label": hasTitle ? undefined : "Confirm action",
315
+ "aria-describedby": hasContent ? descriptionId : undefined,
316
+ className: "popover popover-confirm popover-bottom",
317
+ style: { positionAnchor: anchor },
318
+ onSubmit: handleConfirm,
319
+ onClick: (event) => event.stopPropagation(),
320
+ onToggle: (event) => {
321
+ if (!event.currentTarget.matches(":popover-open")) {
322
+ operationRef.current += 1;
323
+ if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
324
+ buttonRef.current?.focus();
325
+ }
326
+ }
327
+ },
328
+ children: [
329
+ hasTitle && /* @__PURE__ */ jsx("div", {
330
+ className: "popover-header",
331
+ children: /* @__PURE__ */ jsx("h3", {
332
+ id: titleId,
333
+ className: "popover-title",
334
+ children: title
335
+ })
336
+ }),
337
+ hasContent && /* @__PURE__ */ jsx("div", {
338
+ id: descriptionId,
339
+ className: "popover-body",
340
+ children: content
341
+ }),
342
+ confirmError && /* @__PURE__ */ jsx("div", {
343
+ role: "alert",
344
+ className: "popover-body",
345
+ children: "The action failed. Please try again."
346
+ }),
347
+ /* @__PURE__ */ jsxs("div", {
348
+ className: "popover-footer",
349
+ children: [
350
+ /* @__PURE__ */ jsx("button", {
351
+ ref: cancelRef,
352
+ type: "button",
353
+ className: "btn btn-text btn-sm",
354
+ popoverTarget: popoverId,
355
+ popoverTargetAction: "hide",
356
+ disabled: confirmLoading,
357
+ children: confirmation?.cancelText ?? "Cancel"
358
+ }),
359
+ /* @__PURE__ */ jsx("button", {
360
+ type: "submit",
361
+ className: confirmClasses,
362
+ disabled: disabled || isLoading || confirmLoading,
363
+ "aria-busy": confirmLoading,
364
+ children: confirmation?.confirmText ?? "Confirm"
365
+ })
366
+ ]
367
+ })
368
+ ]
369
+ }), portalTarget)
370
+ ]
371
+ });
372
+ }
373
+ // src/components/fab/Fab.tsx
374
+ import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
375
+ var FabContext = createContext(null);
376
+ function useFabContext() {
377
+ const context = useContext(FabContext);
378
+ if (!context)
379
+ throw new Error("Fab subcomponents must be inside Fab");
380
+ return context;
381
+ }
382
+ var Trigger = forwardRef(({ extended, className, type = "button", ...props }, ref) => {
383
+ const { actionsId, speedDial } = useFabContext();
384
+ return /* @__PURE__ */ jsx2(Button, {
385
+ ...props,
386
+ ref,
387
+ type,
388
+ popoverTarget: speedDial ? actionsId : undefined,
389
+ className: cn(fabTriggerClass, extended && "fab-extended", className)
390
+ });
391
+ });
392
+ Trigger.displayName = "Fab.Trigger";
393
+ var Actions = forwardRef(({ className, ...props }, ref) => {
394
+ const { actionsId } = useFabContext();
395
+ return /* @__PURE__ */ jsx2("div", {
396
+ ...props,
397
+ ref,
398
+ id: actionsId,
399
+ popover: "auto",
400
+ className: cn(fabActionsClass, className)
401
+ });
402
+ });
403
+ Actions.displayName = "Fab.Actions";
404
+ var Action = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx2("div", {
405
+ ...props,
406
+ ref,
407
+ className: cn(fabActionClass, className)
408
+ }));
409
+ Action.displayName = "Fab.Action";
410
+ var Label = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx2("span", {
411
+ ...props,
412
+ ref,
413
+ className: cn(fabLabelClass, className)
414
+ }));
415
+ Label.displayName = "Fab.Label";
416
+ var FabRoot = forwardRef(({
417
+ contained,
418
+ start,
419
+ speedDial = false,
420
+ label,
421
+ actions,
422
+ extended,
423
+ buttonProps,
424
+ className,
425
+ children,
426
+ ...props
427
+ }, ref) => {
428
+ const actionsId = `fab-actions-${useId().replace(/:/g, "")}`;
429
+ const hasActions = actions != null;
430
+ const resolvedSpeedDial = speedDial || hasActions;
431
+ return /* @__PURE__ */ jsx2(FabContext.Provider, {
432
+ value: { actionsId, speedDial: resolvedSpeedDial },
433
+ children: /* @__PURE__ */ jsx2("div", {
434
+ ...props,
435
+ ref,
436
+ className: getFabClasses({
437
+ contained,
438
+ start,
439
+ speedDial: resolvedSpeedDial,
440
+ className
441
+ }),
442
+ children: label != null ? /* @__PURE__ */ jsxs2(Fragment2, {
443
+ children: [
444
+ /* @__PURE__ */ jsx2(Trigger, {
445
+ ...buttonProps,
446
+ type: "button",
447
+ "aria-label": label,
448
+ extended,
449
+ className: cn(!extended && "btn-icon", buttonProps?.className),
450
+ children
451
+ }),
452
+ hasActions && /* @__PURE__ */ jsx2(Actions, {
453
+ children: actions
454
+ })
455
+ ]
456
+ }) : children
457
+ })
458
+ });
459
+ });
460
+ FabRoot.displayName = "Fab";
461
+ FabRoot.Trigger = Trigger;
462
+ FabRoot.Actions = Actions;
463
+ FabRoot.Action = Action;
464
+ FabRoot.Label = Label;
465
+ var Fab = FabRoot;
466
+ var FabAction = forwardRef(({ label, children, ...props }, ref) => /* @__PURE__ */ jsxs2(Action, {
467
+ ...props,
468
+ ref,
469
+ children: [
470
+ label ? /* @__PURE__ */ jsx2(Label, {
471
+ children: label
472
+ }) : null,
473
+ children
474
+ ]
475
+ }));
476
+ FabAction.displayName = "FabAction";
477
+ export {
478
+ Fab,
479
+ FabAction
480
+ };
@@ -52,6 +52,7 @@ export interface FormItemProps extends Omit<ComponentProps<"div">, "children" |
52
52
  children?: ReactNode;
53
53
  name?: FormNamePath;
54
54
  label?: ReactNode;
55
+ htmlFor?: string;
55
56
  rules?: FormRule[];
56
57
  required?: boolean;
57
58
  valuePropName?: string;
@@ -9,6 +9,7 @@ import React, {
9
9
  useContext,
10
10
  useEffect,
11
11
  useImperativeHandle,
12
+ useId,
12
13
  useLayoutEffect,
13
14
  useMemo,
14
15
  useRef,
@@ -308,6 +309,7 @@ var FormItem = forwardRef(({
308
309
  className,
309
310
  extra,
310
311
  help,
312
+ htmlFor,
311
313
  label,
312
314
  name,
313
315
  noStyle,
@@ -318,9 +320,13 @@ var FormItem = forwardRef(({
318
320
  ...props
319
321
  }, ref) => {
320
322
  const context = useContext(FormContext);
323
+ const generatedId = useId();
321
324
  useFormVersion(context?.form);
322
325
  const fieldErrors = name && context ? context.getFieldError(name) : [];
323
326
  const ruleRequired = required ?? rules.some((rule) => rule.required);
327
+ const child = isValidElement(children) && children.type !== React.Fragment ? children : null;
328
+ const childProps = child?.props;
329
+ const controlId = label && !noStyle && htmlFor === undefined && child ? childProps?.id ?? generatedId : undefined;
324
330
  useEffect(() => {
325
331
  if (!name || !context) {
326
332
  return;
@@ -328,14 +334,18 @@ var FormItem = forwardRef(({
328
334
  return context.registerField(name, rules);
329
335
  }, [context, name, rules]);
330
336
  function renderControl() {
331
- if (!name || !context || !isValidElement(children)) {
337
+ if (!child || !childProps) {
332
338
  return children;
333
339
  }
340
+ const associationProps = controlId && childProps.id == null ? { id: controlId } : {};
341
+ if (!name || !context) {
342
+ return controlId && childProps.id == null ? React.cloneElement(child, associationProps) : children;
343
+ }
334
344
  const key = nameKey(name);
335
345
  const value = context.form.getFieldValue(name);
336
- const childProps = children.props;
337
346
  const originalTrigger = childProps[trigger];
338
- return React.cloneElement(children, {
347
+ return React.cloneElement(child, {
348
+ ...associationProps,
339
349
  [valuePropName]: valuePropName === "checked" ? Boolean(value) : value ?? "",
340
350
  disabled: childProps.disabled ?? context.disabled,
341
351
  [trigger]: (...args) => {
@@ -363,6 +373,7 @@ var FormItem = forwardRef(({
363
373
  children: [
364
374
  label ? /* @__PURE__ */ jsx("label", {
365
375
  className: formItemLabelClass,
376
+ htmlFor: htmlFor ?? controlId,
366
377
  children: label
367
378
  }) : null,
368
379
  /* @__PURE__ */ jsx("div", {
@@ -444,6 +455,6 @@ Form.create = () => {
444
455
  return;
445
456
  };
446
457
  export {
447
- FormContext,
448
- Form
458
+ Form,
459
+ FormContext
449
460
  };
@@ -98,7 +98,7 @@ var Grid = {
98
98
  useWatch
99
99
  };
100
100
  export {
101
- useWatch,
101
+ Grid,
102
102
  useBreakpoint,
103
- Grid
103
+ useWatch
104
104
  };
@@ -344,9 +344,9 @@ var Input = Object.assign(InputRoot, {
344
344
  Group
345
345
  });
346
346
  export {
347
- TextArea,
348
- Search,
349
- Password,
347
+ Group,
350
348
  Input,
351
- Group
349
+ Password,
350
+ Search,
351
+ TextArea
352
352
  };
@@ -104,7 +104,7 @@ function markdownSource(markdown, mode) {
104
104
  const frontMatter = splitFrontMatter(markdown);
105
105
  return frontMatter ?? { body: markdown, source: undefined };
106
106
  }
107
- var Markdown = forwardRef(function Markdown2({
107
+ var Markdown = forwardRef(function Markdown({
108
108
  markdown = "",
109
109
  breaks = true,
110
110
  colorChips = true,
@@ -0,0 +1,2 @@
1
+ import type { MegamenuComponent } from "./Megamenu.types";
2
+ export declare const Megamenu: MegamenuComponent;
@@ -0,0 +1,32 @@
1
+ import type { ComponentProps, ForwardRefExoticComponent, ReactNode, RefAttributes } from "react";
2
+ export interface MegamenuProps extends Omit<ComponentProps<"nav">, "ref"> {
3
+ trigger?: ReactNode;
4
+ panelHeading?: ReactNode;
5
+ panel?: ReactNode;
6
+ mobile?: ReactNode;
7
+ leading?: ReactNode;
8
+ fullWidth?: boolean;
9
+ }
10
+ export type MegamenuBarProps = Omit<ComponentProps<"ul">, "ref">;
11
+ export type MegamenuItemProps = Omit<ComponentProps<"li">, "ref">;
12
+ export type MegamenuTriggerProps = Omit<ComponentProps<"button">, "ref">;
13
+ export interface MegamenuPanelProps extends Omit<ComponentProps<"div">, "ref"> {
14
+ full?: boolean;
15
+ }
16
+ export type MegamenuGroupProps = Omit<ComponentProps<"section">, "ref">;
17
+ export type MegamenuHeadingProps = Omit<ComponentProps<"h2">, "ref">;
18
+ export type MegamenuSupportingProps = Omit<ComponentProps<"p">, "ref">;
19
+ export interface MegamenuMobileProps extends Omit<ComponentProps<"details">, "ref"> {
20
+ summary: ReactNode;
21
+ }
22
+ export interface MegamenuComponent extends ForwardRefExoticComponent<MegamenuProps & RefAttributes<HTMLElement>> {
23
+ Bar: ForwardRefExoticComponent<MegamenuBarProps & RefAttributes<HTMLUListElement>>;
24
+ Item: ForwardRefExoticComponent<MegamenuItemProps & RefAttributes<HTMLLIElement>>;
25
+ Trigger: ForwardRefExoticComponent<MegamenuTriggerProps & RefAttributes<HTMLButtonElement>>;
26
+ Panel: ForwardRefExoticComponent<MegamenuPanelProps & RefAttributes<HTMLDivElement>>;
27
+ Grid: ForwardRefExoticComponent<Omit<ComponentProps<"div">, "ref"> & RefAttributes<HTMLDivElement>>;
28
+ Group: ForwardRefExoticComponent<MegamenuGroupProps & RefAttributes<HTMLElement>>;
29
+ Heading: ForwardRefExoticComponent<MegamenuHeadingProps & RefAttributes<HTMLHeadingElement>>;
30
+ Supporting: ForwardRefExoticComponent<MegamenuSupportingProps & RefAttributes<HTMLParagraphElement>>;
31
+ Mobile: ForwardRefExoticComponent<MegamenuMobileProps & RefAttributes<HTMLDetailsElement>>;
32
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Megamenu";
2
+ export * from "./Megamenu.types";