asterui 0.12.42 → 0.12.44

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.
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ export declare const IconSizeContext: React.Context<"xs" | "sm" | "md" | "lg" | "xl" | undefined>;
2
3
  type BaseButtonProps = {
3
4
  /** Button color */
4
5
  color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral';
@@ -1,21 +1,22 @@
1
- import { jsx as o, jsxs as F, Fragment as I } from "react/jsx-runtime";
2
- const J = ({
3
- children: s,
4
- color: y,
5
- variant: c,
6
- size: p = "md",
7
- active: C = !1,
8
- loading: n = !1,
9
- shape: i,
10
- noAnimation: k = !1,
11
- icon: a,
12
- iconPosition: l = "start",
13
- danger: x = !1,
1
+ import { jsx as r, jsxs as I, Fragment as E } from "react/jsx-runtime";
2
+ import { createContext as F } from "react";
3
+ const $ = F(void 0), Q = ({
4
+ children: a,
5
+ color: p,
6
+ variant: i,
7
+ size: c = "md",
8
+ active: x = !1,
9
+ loading: t = !1,
10
+ shape: d,
11
+ noAnimation: C = !1,
12
+ icon: l,
13
+ iconPosition: n = "start",
14
+ danger: k = !1,
14
15
  pressed: b,
15
- className: w = "",
16
- ...r
16
+ className: v = "",
17
+ ...o
17
18
  }) => {
18
- const d = x ? "error" : y, D = {
19
+ const m = k ? "error" : p, g = {
19
20
  primary: "btn-primary",
20
21
  secondary: "btn-secondary",
21
22
  accent: "btn-accent",
@@ -24,7 +25,7 @@ const J = ({
24
25
  warning: "btn-warning",
25
26
  error: "btn-error",
26
27
  neutral: "btn-neutral"
27
- }, v = {
28
+ }, w = {
28
29
  solid: "",
29
30
  // default, no extra class needed
30
31
  outline: "btn-outline",
@@ -32,13 +33,13 @@ const J = ({
32
33
  soft: "btn-soft",
33
34
  ghost: "btn-ghost",
34
35
  link: "btn-link"
35
- }, g = {
36
+ }, D = {
36
37
  xs: "btn-xs",
37
38
  sm: "btn-sm",
38
39
  md: "",
39
40
  lg: "btn-lg",
40
41
  xl: "btn-xl"
41
- }, K = {
42
+ }, B = {
42
43
  square: "btn-square",
43
44
  circle: "btn-circle",
44
45
  wide: "btn-wide",
@@ -46,61 +47,68 @@ const J = ({
46
47
  round: "rounded-full"
47
48
  }, u = [
48
49
  "btn",
49
- d && D[d],
50
- c && v[c],
51
- g[p],
52
- C && "btn-active",
53
- i && K[i],
54
- k && "no-animation",
55
- w
56
- ].filter(Boolean).join(" "), N = s != null && s !== "" ? l === "start" ? "mr-2" : "ml-2" : "", f = a && /* @__PURE__ */ o("span", { className: `inline-flex items-center ${N}`, "aria-hidden": "true", children: a }), h = /* @__PURE__ */ F(I, { children: [
57
- n && /* @__PURE__ */ o("span", { className: "loading loading-spinner", "aria-hidden": "true" }),
58
- !n && a && l === "start" && f,
59
- s,
60
- !n && a && l === "end" && f
50
+ m && g[m],
51
+ i && w[i],
52
+ D[c],
53
+ x && "btn-active",
54
+ d && B[d],
55
+ C && "no-animation",
56
+ v
57
+ ].filter(Boolean).join(" "), K = a != null && a !== "" ? {
58
+ xs: n === "start" ? "mr-1" : "ml-1",
59
+ sm: n === "start" ? "mr-1" : "ml-1",
60
+ md: n === "start" ? "mr-1.5" : "ml-1.5",
61
+ lg: n === "start" ? "mr-2" : "ml-2",
62
+ xl: n === "start" ? "mr-2" : "ml-2"
63
+ }[c] : "", f = l && /* @__PURE__ */ r($.Provider, { value: c, children: /* @__PURE__ */ r("span", { className: `inline-flex items-center ${K}`, "aria-hidden": "true", children: l }) }), h = /* @__PURE__ */ I(E, { children: [
64
+ t && /* @__PURE__ */ r("span", { className: "loading loading-spinner", "aria-hidden": "true" }),
65
+ !t && l && n === "start" && f,
66
+ a,
67
+ !t && l && n === "end" && f
61
68
  ] });
62
- if ("href" in r && r.href !== void 0) {
63
- const { href: j, disabled: q, onKeyDown: B, onClick: z, ...E } = r, e = q || n;
64
- return /* @__PURE__ */ o(
69
+ if ("href" in o && o.href !== void 0) {
70
+ const { href: S, disabled: T, onKeyDown: j, onClick: q, ...z } = o, s = T || t;
71
+ return /* @__PURE__ */ r(
65
72
  "a",
66
73
  {
67
- href: e ? void 0 : j,
74
+ href: s ? void 0 : S,
68
75
  role: "button",
69
76
  className: u,
70
- "aria-disabled": e || void 0,
71
- "aria-busy": n || void 0,
77
+ "aria-disabled": s || void 0,
78
+ "aria-busy": t || void 0,
72
79
  "aria-pressed": b,
73
- tabIndex: e ? -1 : 0,
74
- onKeyDown: (t) => {
75
- t.key === " " && !e && (t.preventDefault(), t.currentTarget.click()), B?.(t);
80
+ tabIndex: s ? -1 : 0,
81
+ onKeyDown: (e) => {
82
+ e.key === " " && !s && (e.preventDefault(), e.currentTarget.click()), j?.(e);
76
83
  },
77
- onClick: (t) => {
78
- if (e) {
79
- t.preventDefault();
84
+ onClick: (e) => {
85
+ if (s) {
86
+ e.preventDefault();
80
87
  return;
81
88
  }
82
- z?.(t);
89
+ q?.(e);
83
90
  },
84
- ...E,
91
+ ...z,
85
92
  children: h
86
93
  }
87
94
  );
88
95
  }
89
- const { htmlType: T, ...m } = r;
90
- return /* @__PURE__ */ o(
96
+ const { htmlType: N, ...y } = o;
97
+ return /* @__PURE__ */ r(
91
98
  "button",
92
99
  {
93
- type: T ?? "button",
100
+ type: N ?? "button",
94
101
  className: u,
95
- "aria-busy": n || void 0,
102
+ "aria-busy": t || void 0,
96
103
  "aria-pressed": b,
97
- disabled: n || m.disabled,
98
- ...m,
104
+ disabled: t || y.disabled,
105
+ ...y,
99
106
  children: h
100
107
  }
101
108
  );
102
109
  };
103
110
  export {
104
- J as Button
111
+ Q as Button,
112
+ $ as IconSizeContext
105
113
  };
106
114
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React from 'react'\n\ntype BaseButtonProps = {\n /** Button color */\n color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral'\n /** Button style variant */\n variant?: 'solid' | 'outline' | 'dash' | 'soft' | 'ghost' | 'link'\n /** Button size */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Active/pressed visual state */\n active?: boolean\n /** Show loading spinner and disable button */\n loading?: boolean\n /** Button shape */\n shape?: 'square' | 'circle' | 'wide' | 'block' | 'round'\n /** Disable click animation */\n noAnimation?: boolean\n /** Icon element to display */\n icon?: React.ReactNode\n /** Position of the icon */\n iconPosition?: 'start' | 'end'\n /** Applies error/danger styling (shorthand for color=\"error\") */\n danger?: boolean\n /** Toggle button pressed state (sets aria-pressed) */\n pressed?: boolean\n}\n\ntype ButtonAsButton = BaseButtonProps &\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> & {\n href?: undefined\n htmlType?: 'button' | 'submit' | 'reset'\n }\n\ntype ButtonAsAnchor = BaseButtonProps &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'type'> & {\n href: string\n htmlType?: undefined\n /** Disable the link button */\n disabled?: boolean\n }\n\nexport type ButtonProps = ButtonAsButton | ButtonAsAnchor\n\nexport const Button: React.FC<ButtonProps> = ({\n children,\n color,\n variant,\n size = 'md',\n active = false,\n loading = false,\n shape,\n noAnimation = false,\n icon,\n iconPosition = 'start',\n danger = false,\n pressed,\n className = '',\n ...props\n}) => {\n // danger prop is a shorthand for color=\"error\"\n const effectiveColor = danger ? 'error' : color\n\n const colorClasses = {\n primary: 'btn-primary',\n secondary: 'btn-secondary',\n accent: 'btn-accent',\n info: 'btn-info',\n success: 'btn-success',\n warning: 'btn-warning',\n error: 'btn-error',\n neutral: 'btn-neutral',\n }\n\n const variantClasses = {\n solid: '', // default, no extra class needed\n outline: 'btn-outline',\n dash: 'btn-dash',\n soft: 'btn-soft',\n ghost: 'btn-ghost',\n link: 'btn-link',\n }\n\n const sizeClasses = {\n xs: 'btn-xs',\n sm: 'btn-sm',\n md: '',\n lg: 'btn-lg',\n xl: 'btn-xl',\n }\n\n const shapeClasses = {\n square: 'btn-square',\n circle: 'btn-circle',\n wide: 'btn-wide',\n block: 'btn-block',\n round: 'rounded-full',\n }\n\n const classes = [\n 'btn',\n effectiveColor && colorClasses[effectiveColor],\n variant && variantClasses[variant],\n sizeClasses[size],\n active && 'btn-active',\n shape && shapeClasses[shape],\n noAnimation && 'no-animation',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Determine icon spacing based on whether there's text content\n const hasChildren = children !== undefined && children !== null && children !== ''\n const iconSpacing = hasChildren ? (iconPosition === 'start' ? 'mr-2' : 'ml-2') : ''\n\n const iconElement = icon && (\n <span className={`inline-flex items-center ${iconSpacing}`} aria-hidden=\"true\">\n {icon}\n </span>\n )\n\n const content = (\n <>\n {loading && <span className=\"loading loading-spinner\" aria-hidden=\"true\"></span>}\n {!loading && icon && iconPosition === 'start' && iconElement}\n {children}\n {!loading && icon && iconPosition === 'end' && iconElement}\n </>\n )\n\n if ('href' in props && props.href !== undefined) {\n const { href, disabled, onKeyDown, onClick, ...anchorProps } = props as ButtonAsAnchor & {\n onKeyDown?: React.KeyboardEventHandler<HTMLAnchorElement>\n onClick?: React.MouseEventHandler<HTMLAnchorElement>\n }\n const isDisabled = disabled || loading\n\n // Handle Space key for anchor buttons (links only respond to Enter natively)\n const handleKeyDown = (event: React.KeyboardEvent<HTMLAnchorElement>) => {\n if (event.key === ' ' && !isDisabled) {\n event.preventDefault()\n event.currentTarget.click()\n }\n onKeyDown?.(event)\n }\n\n // Prevent click when disabled\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault()\n return\n }\n onClick?.(event)\n }\n\n return (\n <a\n href={isDisabled ? undefined : href}\n role=\"button\"\n className={classes}\n aria-disabled={isDisabled || undefined}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n tabIndex={isDisabled ? -1 : 0}\n onKeyDown={handleKeyDown}\n onClick={handleClick}\n {...anchorProps}\n >\n {content}\n </a>\n )\n }\n\n const { htmlType, ...buttonProps } = props as Omit<ButtonAsButton, keyof BaseButtonProps>\n const buttonType: 'button' | 'submit' | 'reset' = htmlType ?? 'button'\n return (\n <button\n type={buttonType}\n className={classes}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n disabled={loading || buttonProps.disabled}\n {...buttonProps}\n >\n {content}\n </button>\n )\n}\n"],"names":["Button","children","color","variant","size","active","loading","shape","noAnimation","icon","iconPosition","danger","pressed","className","props","effectiveColor","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","iconSpacing","iconElement","jsx","content","jsxs","Fragment","href","disabled","onKeyDown","onClick","anchorProps","isDisabled","event","htmlType","buttonProps"],"mappings":";AA2CO,MAAMA,IAAgC,CAAC;AAAA,EAC5C,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU;AAAA,EACV,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,QAAAC,IAAS;AAAA,EACT,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AAEJ,QAAMC,IAAiBJ,IAAS,UAAUT,GAEpCc,IAAe;AAAA,IACnB,SAAS;AAAA,IACT,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS;AAAA,EAAA,GAGLC,IAAiB;AAAA,IACrB,OAAO;AAAA;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,EAAA,GAGFC,IAAc;AAAA,IAClB,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EAAA,GAGAC,IAAe;AAAA,IACnB,QAAQ;A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,cAAc,MAAA,IAEtBJ,IAAYI,CAAK;AAAA,QACnB;AAAA,QAqBI,SAlBgB,CAACA,MAA+C;AAClE,cAAID,GAAY;AACd,YAAAC,EAAM,eAAA;AACN;AAAA,UACF;AACA,UAAAH,IAAUG,CAAK;AAAA,QACjB;AAAA,QAaK,GAAGF;AAAA,QAEH,UAAAP;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AAEA,QAAM,EAAE,UAAAU,GAAU,GAAGC,EAAA,IAAgBrB;AAErC,SACE,gBAAAS;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAH8CW,KAAY;AAAA,MAI1D,WAAWd;AAAA,MACX,aAAWd,KAAW;AAAA,MACtB,gBAAcM;AAAA,MACd,UAAUN,KAAW6B,EAAY;AAAA,MAChC,GAAGA;AAAA,MAEH,UAAAX;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React, { createContext } from 'react'\n\nexport const IconSizeContext = createContext<'xs' | 'sm' | 'md' | 'lg' | 'xl' | undefined>(undefined)\n\ntype BaseButtonProps = {\n /** Button color */\n color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral'\n /** Button style variant */\n variant?: 'solid' | 'outline' | 'dash' | 'soft' | 'ghost' | 'link'\n /** Button size */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Active/pressed visual state */\n active?: boolean\n /** Show loading spinner and disable button */\n loading?: boolean\n /** Button shape */\n shape?: 'square' | 'circle' | 'wide' | 'block' | 'round'\n /** Disable click animation */\n noAnimation?: boolean\n /** Icon element to display */\n icon?: React.ReactNode\n /** Position of the icon */\n iconPosition?: 'start' | 'end'\n /** Applies error/danger styling (shorthand for color=\"error\") */\n danger?: boolean\n /** Toggle button pressed state (sets aria-pressed) */\n pressed?: boolean\n}\n\ntype ButtonAsButton = BaseButtonProps &\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> & {\n href?: undefined\n htmlType?: 'button' | 'submit' | 'reset'\n }\n\ntype ButtonAsAnchor = BaseButtonProps &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'type'> & {\n href: string\n htmlType?: undefined\n /** Disable the link button */\n disabled?: boolean\n }\n\nexport type ButtonProps = ButtonAsButton | ButtonAsAnchor\n\nexport const Button: React.FC<ButtonProps> = ({\n children,\n color,\n variant,\n size = 'md',\n active = false,\n loading = false,\n shape,\n noAnimation = false,\n icon,\n iconPosition = 'start',\n danger = false,\n pressed,\n className = '',\n ...props\n}) => {\n // danger prop is a shorthand for color=\"error\"\n const effectiveColor = danger ? 'error' : color\n\n const colorClasses = {\n primary: 'btn-primary',\n secondary: 'btn-secondary',\n accent: 'btn-accent',\n info: 'btn-info',\n success: 'btn-success',\n warning: 'btn-warning',\n error: 'btn-error',\n neutral: 'btn-neutral',\n }\n\n const variantClasses = {\n solid: '', // default, no extra class needed\n outline: 'btn-outline',\n dash: 'btn-dash',\n soft: 'btn-soft',\n ghost: 'btn-ghost',\n link: 'btn-link',\n }\n\n const sizeClasses = {\n xs: 'btn-xs',\n sm: 'btn-sm',\n md: '',\n lg: 'btn-lg',\n xl: 'btn-xl',\n }\n\n const shapeClasses = {\n square: 'btn-square',\n circle: 'btn-circle',\n wide: 'btn-wide',\n block: 'btn-block',\n round: 'rounded-full',\n }\n\n const classes = [\n 'btn',\n effectiveColor && colorClasses[effectiveColor],\n variant && variantClasses[variant],\n sizeClasses[size],\n active && 'btn-active',\n shape && shapeClasses[shape],\n noAnimation && 'no-animation',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Determine icon spacing based on whether there's text content and button size\n const hasChildren = children !== undefined && children !== null && children !== ''\n const spacingBySize = {\n xs: iconPosition === 'start' ? 'mr-1' : 'ml-1',\n sm: iconPosition === 'start' ? 'mr-1' : 'ml-1',\n md: iconPosition === 'start' ? 'mr-1.5' : 'ml-1.5',\n lg: iconPosition === 'start' ? 'mr-2' : 'ml-2',\n xl: iconPosition === 'start' ? 'mr-2' : 'ml-2',\n }\n const iconSpacing = hasChildren ? spacingBySize[size] : ''\n\n const iconElement = icon && (\n <IconSizeContext.Provider value={size}>\n <span className={`inline-flex items-center ${iconSpacing}`} aria-hidden=\"true\">\n {icon}\n </span>\n </IconSizeContext.Provider>\n )\n\n const content = (\n <>\n {loading && <span className=\"loading loading-spinner\" aria-hidden=\"true\"></span>}\n {!loading && icon && iconPosition === 'start' && iconElement}\n {children}\n {!loading && icon && iconPosition === 'end' && iconElement}\n </>\n )\n\n if ('href' in props && props.href !== undefined) {\n const { href, disabled, onKeyDown, onClick, ...anchorProps } = props as ButtonAsAnchor & {\n onKeyDown?: React.KeyboardEventHandler<HTMLAnchorElement>\n onClick?: React.MouseEventHandler<HTMLAnchorElement>\n }\n const isDisabled = disabled || loading\n\n // Handle Space key for anchor buttons (links only respond to Enter natively)\n const handleKeyDown = (event: React.KeyboardEvent<HTMLAnchorElement>) => {\n if (event.key === ' ' && !isDisabled) {\n event.preventDefault()\n event.currentTarget.click()\n }\n onKeyDown?.(event)\n }\n\n // Prevent click when disabled\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault()\n return\n }\n onClick?.(event)\n }\n\n return (\n <a\n href={isDisabled ? undefined : href}\n role=\"button\"\n className={classes}\n aria-disabled={isDisabled || undefined}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n tabIndex={isDisabled ? -1 : 0}\n onKeyDown={handleKeyDown}\n onClick={handleClick}\n {...anchorProps}\n >\n {content}\n </a>\n )\n }\n\n const { htmlType, ...buttonProps } = props as Omit<ButtonAsButton, keyof BaseButtonProps>\n const buttonType: 'button' | 'submit' | 'reset' = htmlType ?? 'button'\n return (\n <button\n type={buttonType}\n className={classes}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n disabled={loading || buttonProps.disabled}\n {...buttonProps}\n >\n {content}\n </button>\n )\n}\n"],"names":["IconSizeContext","createContext","Button","children","color","variant","size","active","loading","shape","noAnimation","icon","iconPosition","danger","pressed","className","props","effectiveColor","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","iconSpacing","iconElement","jsx","content","jsxs","Fragment","href","disabled","onKeyDown","onClick","anchorProps","isDisabled","event","htmlType","buttonProps"],"mappings":";;AAEO,MAAMA,IAAkBC,EAA4D,MAAS,GA2CvFC,IAAgC,CAAC;AAAA,EAC5C,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU;AAAA,EACV,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,QAAAC,IAAS;AAAA,EACT,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AAEJ,QAAMC,IAAiBJ,IAAS,UAAUT,GAEpCc,IAAe;AAAA,IACnB,SAAS;AAAA,IACT,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS;AAAA,EAAA,GAGLC,IAAiB;AAAA,IACrB,OAAO;AAAA;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,EAAA,GAGFC,IAAc;AAAA,IAClB,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EAAA,GAGAC,IAAe;AAAA,IACnB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,EAAA,GAGHC,IAAU;AAAA,IACd;AAAA,IACAL,KAAkBC,EAAaD,CAAc;AAAA,IAC7CZ,KAAWc,EAAed,CAAO;AAAA,IACjCe,E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UAAIA,EAAM,QAAQ,OAAO,CAACD,MACxBC,EAAM,eAAA,GACNA,EAAM,cAAc,MAAA,IAEtBJ,IAAYI,CAAK;AAAA,QACnB;AAAA,QAqBI,SAlBgB,CAACA,MAA+C;AAClE,cAAID,GAAY;AACd,YAAAC,EAAM,eAAA;AACN;AAAA,UACF;AACA,UAAAH,IAAUG,CAAK;AAAA,QACjB;AAAA,QAaK,GAAGF;AAAA,QAEH,UAAAP;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AAEA,QAAM,EAAE,UAAAU,GAAU,GAAGC,EAAA,IAAgBrB;AAErC,SACE,gBAAAS;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAH8CW,KAAY;AAAA,MAI1D,WAAWd;AAAA,MACX,aAAWd,KAAW;AAAA,MACtB,gBAAcM;AAAA,MACd,UAAUN,KAAW6B,EAAY;AAAA,MAChC,GAAGA;AAAA,MAEH,UAAAX;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -21,8 +21,6 @@ export interface ContextMenuProps {
21
21
  className?: string;
22
22
  }
23
23
  export interface ContextMenuItemProps {
24
- /** Unique key for the item */
25
- itemKey: string;
26
24
  /** Item content */
27
25
  children: React.ReactNode;
28
26
  /** Icon to display before label */
@@ -33,14 +31,14 @@ export interface ContextMenuItemProps {
33
31
  danger?: boolean;
34
32
  /** Additional CSS classes */
35
33
  className?: string;
34
+ /** @internal */
35
+ _key?: string;
36
36
  }
37
37
  export interface ContextMenuDividerProps {
38
38
  /** Additional CSS classes */
39
39
  className?: string;
40
40
  }
41
41
  export interface ContextMenuSubMenuProps {
42
- /** Unique key for the submenu */
43
- itemKey: string;
44
42
  /** Submenu label */
45
43
  label: React.ReactNode;
46
44
  /** Icon to display before label */
@@ -51,6 +49,8 @@ export interface ContextMenuSubMenuProps {
51
49
  children: React.ReactNode;
52
50
  /** Additional CSS classes */
53
51
  className?: string;
52
+ /** @internal */
53
+ _key?: string;
54
54
  }
55
55
  export declare const ContextMenu: React.FC<ContextMenuProps> & {
56
56
  Item: React.FC<ContextMenuItemProps>;
@@ -1,25 +1,25 @@
1
- import { jsxs as b, Fragment as P, jsx as n } from "react/jsx-runtime";
2
- import T, { useState as g, useRef as C, useCallback as M, useEffect as N, createContext as W, useContext as z } from "react";
3
- import { createPortal as B } from "react-dom";
4
- const E = W(null), I = () => {
5
- const e = z(E);
1
+ import { jsxs as b, Fragment as B, jsx as n } from "react/jsx-runtime";
2
+ import C, { useState as g, useRef as y, useCallback as M, useEffect as E, createContext as I, useContext as K } from "react";
3
+ import { createPortal as V } from "react-dom";
4
+ const L = I(null), A = () => {
5
+ const e = K(L);
6
6
  if (!e)
7
7
  throw new Error("ContextMenu compound components must be used within a ContextMenu");
8
8
  return e;
9
- }, A = ({
10
- itemKey: e,
11
- children: u,
12
- icon: l,
9
+ }, S = ({
10
+ children: e,
11
+ icon: c,
13
12
  disabled: s = !1,
14
13
  danger: d = !1,
15
- className: o = ""
14
+ className: h = "",
15
+ _key: l
16
16
  }) => {
17
- const { onSelect: h, onClose: t } = I();
18
- return /* @__PURE__ */ n("li", { className: o, children: /* @__PURE__ */ b(
17
+ const { onSelect: m, onClose: o } = A();
18
+ return /* @__PURE__ */ n("li", { className: h, children: /* @__PURE__ */ b(
19
19
  "button",
20
20
  {
21
21
  onClick: () => {
22
- s || (h(e), t());
22
+ s || !l || (m(l), o());
23
23
  },
24
24
  disabled: s,
25
25
  className: `
@@ -28,30 +28,30 @@ const E = W(null), I = () => {
28
28
  ${d ? "text-error hover:bg-error/10" : ""}
29
29
  `,
30
30
  children: [
31
- l && /* @__PURE__ */ n("span", { className: "w-4 h-4", children: l }),
32
- /* @__PURE__ */ n("span", { className: "flex-1", children: u })
31
+ c && /* @__PURE__ */ n("span", { className: "w-4 h-4", children: c }),
32
+ /* @__PURE__ */ n("span", { className: "flex-1", children: e })
33
33
  ]
34
34
  }
35
35
  ) });
36
- }, H = ({ className: e = "" }) => /* @__PURE__ */ n("li", { className: `divider my-1 ${e}` }), K = ({
37
- itemKey: e,
38
- label: u,
39
- icon: l,
36
+ }, H = ({ className: e = "" }) => /* @__PURE__ */ n("li", { className: `divider my-1 ${e}` }), R = ({
37
+ label: e,
38
+ icon: c,
40
39
  disabled: s = !1,
41
40
  children: d,
42
- className: o = ""
41
+ className: h = "",
42
+ _key: l
43
43
  }) => {
44
- const [h, t] = g(!1), a = C(null), c = () => {
45
- s || (a.current && clearTimeout(a.current), t(!0));
46
- }, m = () => {
47
- a.current = setTimeout(() => t(!1), 100);
44
+ const [m, o] = g(!1), a = y(null), u = () => {
45
+ s || (a.current && clearTimeout(a.current), o(!0));
46
+ }, f = () => {
47
+ a.current = setTimeout(() => o(!1), 100);
48
48
  };
49
49
  return /* @__PURE__ */ b(
50
50
  "li",
51
51
  {
52
- onMouseEnter: c,
53
- onMouseLeave: m,
54
- className: `relative ${o}`,
52
+ onMouseEnter: u,
53
+ onMouseLeave: f,
54
+ className: `relative ${h}`,
55
55
  children: [
56
56
  /* @__PURE__ */ b(
57
57
  "button",
@@ -62,46 +62,46 @@ const E = W(null), I = () => {
62
62
  ${s ? "opacity-50 cursor-not-allowed" : "hover:bg-base-200"}
63
63
  `,
64
64
  children: [
65
- l && /* @__PURE__ */ n("span", { className: "w-4 h-4", children: l }),
66
- /* @__PURE__ */ n("span", { className: "flex-1", children: u }),
65
+ c && /* @__PURE__ */ n("span", { className: "w-4 h-4", children: c }),
66
+ /* @__PURE__ */ n("span", { className: "flex-1", children: e }),
67
67
  /* @__PURE__ */ n("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
68
68
  ]
69
69
  }
70
70
  ),
71
- h && /* @__PURE__ */ n(
71
+ m && /* @__PURE__ */ n(
72
72
  "ul",
73
73
  {
74
74
  className: "menu bg-base-100 rounded-box shadow-lg border border-base-300 absolute left-full top-0 min-w-[160px] z-50 p-1",
75
- onMouseEnter: c,
76
- onMouseLeave: m,
75
+ onMouseEnter: u,
76
+ onMouseLeave: f,
77
77
  children: d
78
78
  }
79
79
  )
80
80
  ]
81
81
  }
82
82
  );
83
- }, L = ({ item: e, onSelect: u, onClose: l }) => {
84
- const [s, d] = g(!1), o = C(null);
83
+ }, $ = ({ item: e, onSelect: c, onClose: s }) => {
84
+ const [d, h] = g(!1), l = y(null);
85
85
  if (e.divider)
86
86
  return /* @__PURE__ */ n("li", { className: "divider my-1" });
87
- const h = () => {
88
- e.disabled || e.children && e.children.length > 0 || (u(e.key), l());
89
- }, t = e.children && e.children.length > 0, a = () => {
90
- t && (o.current && clearTimeout(o.current), d(!0));
91
- }, c = () => {
92
- t && (o.current = setTimeout(() => d(!1), 100));
87
+ const m = () => {
88
+ e.disabled || e.children && e.children.length > 0 || (c(e.key), s());
89
+ }, o = e.children && e.children.length > 0, a = () => {
90
+ o && (l.current && clearTimeout(l.current), h(!0));
91
+ }, u = () => {
92
+ o && (l.current = setTimeout(() => h(!1), 100));
93
93
  };
94
94
  return /* @__PURE__ */ b(
95
95
  "li",
96
96
  {
97
97
  onMouseEnter: a,
98
- onMouseLeave: c,
98
+ onMouseLeave: u,
99
99
  className: "relative",
100
100
  children: [
101
101
  /* @__PURE__ */ b(
102
102
  "button",
103
103
  {
104
- onClick: h,
104
+ onClick: m,
105
105
  disabled: e.disabled,
106
106
  className: `
107
107
  flex items-center gap-2 w-full px-4 py-2 text-left text-sm
@@ -111,17 +111,17 @@ const E = W(null), I = () => {
111
111
  children: [
112
112
  e.icon && /* @__PURE__ */ n("span", { className: "w-4 h-4", children: e.icon }),
113
113
  /* @__PURE__ */ n("span", { className: "flex-1", children: e.label }),
114
- t && /* @__PURE__ */ n("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
114
+ o && /* @__PURE__ */ n("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
115
115
  ]
116
116
  }
117
117
  ),
118
- t && s && /* @__PURE__ */ n(
118
+ o && d && /* @__PURE__ */ n(
119
119
  "ul",
120
120
  {
121
121
  className: "menu bg-base-100 rounded-box shadow-lg border border-base-300 absolute left-full top-0 min-w-[160px] z-50 p-1",
122
122
  onMouseEnter: a,
123
- onMouseLeave: c,
124
- children: e.children.map((m) => /* @__PURE__ */ n(L, { item: m, onSelect: u, onClose: l }, m.key))
123
+ onMouseLeave: u,
124
+ children: e.children.map((f) => /* @__PURE__ */ n($, { item: f, onSelect: c, onClose: s }, f.key))
125
125
  }
126
126
  )
127
127
  ]
@@ -129,69 +129,76 @@ const E = W(null), I = () => {
129
129
  );
130
130
  }, O = ({
131
131
  children: e,
132
- items: u,
133
- onSelect: l,
134
- disabled: s = !1,
135
- className: d = ""
132
+ items: c,
133
+ onSelect: s,
134
+ disabled: d = !1,
135
+ className: h = ""
136
136
  }) => {
137
- const [o, h] = g(!1), [t, a] = g({ x: 0, y: 0 }), c = C(null), m = C(null), S = M(
137
+ const [l, m] = g(!1), [o, a] = g({ x: 0, y: 0 }), u = y(null), f = y(null), j = M(
138
138
  (r) => {
139
- if (s) return;
139
+ if (d) return;
140
140
  r.preventDefault(), r.stopPropagation();
141
- let i = r.clientX, f = r.clientY;
142
- a({ x: i, y: f }), h(!0);
141
+ let t = r.clientX, i = r.clientY;
142
+ a({ x: t, y: i }), m(!0);
143
143
  },
144
- [s]
145
- ), x = M(() => {
146
- h(!1);
147
- }, []), y = M(
144
+ [d]
145
+ ), p = M(() => {
146
+ m(!1);
147
+ }, []), k = M(
148
148
  (r) => {
149
- l?.(r);
149
+ s?.(r);
150
150
  },
151
- [l]
151
+ [s]
152
152
  );
153
- N(() => {
154
- if (o && c.current) {
155
- const i = c.current.getBoundingClientRect(), f = window.innerWidth, p = window.innerHeight;
156
- let { x: v, y: w } = t;
157
- v + i.width > f && (v = f - i.width - 8), w + i.height > p && (w = p - i.height - 8), (v !== t.x || w !== t.y) && a({ x: v, y: w });
153
+ E(() => {
154
+ if (l && u.current) {
155
+ const t = u.current.getBoundingClientRect(), i = window.innerWidth, x = window.innerHeight;
156
+ let { x: v, y: w } = o;
157
+ v + t.width > i && (v = i - t.width - 8), w + t.height > x && (w = x - t.height - 8), (v !== o.x || w !== o.y) && a({ x: v, y: w });
158
158
  }
159
- }, [o, t]), N(() => {
160
- if (!o) return;
161
- const r = (p) => {
162
- c.current && !c.current.contains(p.target) && x();
163
- }, i = (p) => {
164
- p.key === "Escape" && x();
165
- }, f = () => {
166
- x();
159
+ }, [l, o]), E(() => {
160
+ if (!l) return;
161
+ const r = (x) => {
162
+ u.current && !u.current.contains(x.target) && p();
163
+ }, t = (x) => {
164
+ x.key === "Escape" && p();
165
+ }, i = () => {
166
+ p();
167
167
  };
168
- return document.addEventListener("mousedown", r), document.addEventListener("keydown", i), document.addEventListener("scroll", f, !0), () => {
169
- document.removeEventListener("mousedown", r), document.removeEventListener("keydown", i), document.removeEventListener("scroll", f, !0);
168
+ return document.addEventListener("mousedown", r), document.addEventListener("keydown", t), document.addEventListener("scroll", i, !0), () => {
169
+ document.removeEventListener("mousedown", r), document.removeEventListener("keydown", t), document.removeEventListener("scroll", i, !0);
170
170
  };
171
- }, [o, x]);
172
- const k = T.Children.toArray(e), R = k[0], $ = k.slice(1), j = u && u.length > 0, D = {
173
- onSelect: y,
174
- onClose: x
171
+ }, [l, p]);
172
+ const D = (r) => C.Children.map(r, (t) => {
173
+ if (C.isValidElement(t)) {
174
+ const i = t.key != null ? String(t.key) : void 0;
175
+ if (t.type === S || t.type === R)
176
+ return C.cloneElement(t, { _key: i });
177
+ }
178
+ return t;
179
+ }), N = C.Children.toArray(e), W = N[0], P = D(N.slice(1)), T = c && c.length > 0, z = {
180
+ onSelect: k,
181
+ onClose: p
175
182
  };
176
- return /* @__PURE__ */ b(P, { children: [
177
- /* @__PURE__ */ n("div", { ref: m, onContextMenu: S, className: "inline-block", children: R }),
178
- o && B(
179
- /* @__PURE__ */ n(E.Provider, { value: D, children: /* @__PURE__ */ n(
183
+ return /* @__PURE__ */ b(B, { children: [
184
+ /* @__PURE__ */ n("div", { ref: f, onContextMenu: j, className: "inline-block", children: W }),
185
+ l && V(
186
+ /* @__PURE__ */ n(L.Provider, { value: z, children: /* @__PURE__ */ n(
180
187
  "ul",
181
188
  {
182
- ref: c,
183
- className: `menu bg-base-100 rounded-box shadow-lg border border-base-300 min-w-[160px] p-1 fixed z-[9999] ${d}`,
184
- style: { left: t.x, top: t.y },
185
- children: j ? u.map((r) => /* @__PURE__ */ n(L, { item: r, onSelect: y, onClose: x }, r.key)) : $
189
+ ref: u,
190
+ className: `menu bg-base-100 rounded-box shadow-lg border border-base-300 min-w-[160px] p-1 fixed z-[9999] ${h}`,
191
+ style: { left: o.x, top: o.y },
192
+ children: T ? c.map((r) => /* @__PURE__ */ n($, { item: r, onSelect: k, onClose: p }, r.key)) : P
186
193
  }
187
194
  ) }),
188
195
  document.body
189
196
  )
190
197
  ] });
191
198
  }, Y = Object.assign(O, {
192
- Item: A,
199
+ Item: S,
193
200
  Divider: H,
194
- SubMenu: K
201
+ SubMenu: R
195
202
  });
196
203
  export {
197
204
  Y as ContextMenu