@kolking/react-ui 1.4.0 → 1.6.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 (60) hide show
  1. package/dist/{Input-DE1QkW7S.js → Input-D46mAsdt.js} +39 -29
  2. package/dist/ValidationTooltip-D8d9O6Re.js +31 -0
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -0
  4. package/dist/components/Breadcrumbs/Breadcrumbs.js +40 -0
  5. package/dist/components/Breadcrumbs/index.d.ts +1 -0
  6. package/dist/components/Breadcrumbs/index.js +4 -0
  7. package/dist/components/Button/Button.js +1 -1
  8. package/dist/components/Dialog/Dialog.d.ts +14 -5
  9. package/dist/components/Dialog/Dialog.js +67 -49
  10. package/dist/components/Dialog/useDialog.d.ts +2 -1
  11. package/dist/components/Dialog/useDialog.js +29 -42
  12. package/dist/components/Dialog/withDialog.d.ts +1 -1
  13. package/dist/components/Fields/Checkbox.js +1 -1
  14. package/dist/components/Fields/Field.d.ts +1 -1
  15. package/dist/components/Fields/Field.js +28 -27
  16. package/dist/components/Fields/Input.d.ts +2 -0
  17. package/dist/components/Fields/Input.js +2 -2
  18. package/dist/components/Fields/Numeric.d.ts +4 -0
  19. package/dist/components/Fields/Numeric.js +62 -0
  20. package/dist/components/Fields/Radio.js +1 -1
  21. package/dist/components/Fields/Range.d.ts +20 -0
  22. package/dist/components/Fields/Range.js +54 -0
  23. package/dist/components/Fields/Select.js +1 -1
  24. package/dist/components/Fields/Switch.d.ts +13 -0
  25. package/dist/components/Fields/Switch.js +36 -0
  26. package/dist/components/Fields/Textarea.js +1 -1
  27. package/dist/components/Fields/ValidationTooltip.d.ts +1 -1
  28. package/dist/components/Fields/ValidationTooltip.js +3 -2
  29. package/dist/components/Fields/index.d.ts +3 -1
  30. package/dist/components/Fields/index.js +20 -16
  31. package/dist/components/Flex/Flex.d.ts +1 -1
  32. package/dist/components/Flex/Flex.js +24 -23
  33. package/dist/components/Menu/Menu.d.ts +6 -2
  34. package/dist/components/Menu/Menu.js +57 -51
  35. package/dist/components/Menu/MenuContext.d.ts +1 -0
  36. package/dist/components/Menu/MenuItem.d.ts +2 -3
  37. package/dist/components/Menu/MenuItem.js +23 -29
  38. package/dist/components/Segmented/Segmented.js +22 -19
  39. package/dist/components/ToggleButton/ToggleButton.d.ts +5 -0
  40. package/dist/components/ToggleButton/ToggleButton.js +16 -0
  41. package/dist/components/ToggleButton/ToggleGroup.d.ts +12 -0
  42. package/dist/components/ToggleButton/ToggleGroup.js +43 -0
  43. package/dist/components/ToggleButton/index.d.ts +2 -0
  44. package/dist/components/ToggleButton/index.js +6 -0
  45. package/dist/components/Tooltip/Tooltip.d.ts +2 -1
  46. package/dist/components/Tooltip/Tooltip.js +59 -56
  47. package/dist/index.d.ts +2 -0
  48. package/dist/index.js +62 -52
  49. package/dist/styles/_theme-default.scss +23 -21
  50. package/dist/styles/style.css +1 -1
  51. package/dist/styles.module-D1F3R7Vi.js +11 -0
  52. package/dist/utils/helpers.d.ts +2 -3
  53. package/dist/utils/helpers.js +20 -22
  54. package/package.json +2 -1
  55. package/dist/ValidationTooltip-BgSwl0hJ.js +0 -30
  56. package/dist/components/Dialog/DialogFocusTrap.d.ts +0 -2
  57. package/dist/components/Dialog/DialogFocusTrap.js +0 -17
  58. package/dist/components/Fields/Quantity.d.ts +0 -7
  59. package/dist/components/Fields/Quantity.js +0 -61
  60. package/dist/styles.module-CUhWny5T.js +0 -11
@@ -0,0 +1,62 @@
1
+ import { jsxs as p, jsx as t } from "react/jsx-runtime";
2
+ import b from "classnames";
3
+ import f, { useRef as y, useImperativeHandle as _, useCallback as c } from "react";
4
+ import { Icon as i } from "../Icon/Icon.js";
5
+ import { Button as o } from "../Button/Button.js";
6
+ import { I as h } from "../../Input-D46mAsdt.js";
7
+ const v = "styles_numeric_dzUSE", w = "styles_increase_5S-Jo", E = "styles_decrease_j8UR6", s = {
8
+ numeric: v,
9
+ increase: w,
10
+ decrease: E
11
+ }, j = f.forwardRef(
12
+ ({ className: l, ...a }, u) => {
13
+ const e = y(null);
14
+ _(u, () => e.current);
15
+ const m = c(() => {
16
+ var n, r;
17
+ (n = e.current) == null || n.stepUp(), (r = e.current) == null || r.dispatchEvent(new Event("change", { bubbles: !0 }));
18
+ }, []), d = c(() => {
19
+ var n, r;
20
+ (n = e.current) == null || n.stepDown(), (r = e.current) == null || r.dispatchEvent(new Event("change", { bubbles: !0 }));
21
+ }, []);
22
+ return /* @__PURE__ */ p(
23
+ h,
24
+ {
25
+ ...a,
26
+ ref: e,
27
+ type: "number",
28
+ wrapperType: "numeric",
29
+ className: b(s.numeric, l),
30
+ children: [
31
+ /* @__PURE__ */ t(
32
+ o,
33
+ {
34
+ type: "button",
35
+ variant: "secondary",
36
+ "aria-label": "Increase",
37
+ disabled: a.disabled,
38
+ className: s.increase,
39
+ icon: /* @__PURE__ */ t(i, { name: "triangle-up" }),
40
+ onClick: m
41
+ }
42
+ ),
43
+ /* @__PURE__ */ t(
44
+ o,
45
+ {
46
+ type: "button",
47
+ variant: "secondary",
48
+ "aria-label": "Decrease",
49
+ disabled: a.disabled,
50
+ className: s.decrease,
51
+ icon: /* @__PURE__ */ t(i, { name: "triangle-down" }),
52
+ onClick: d
53
+ }
54
+ )
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ );
60
+ export {
61
+ j as Numeric
62
+ };
@@ -2,7 +2,7 @@ import { jsxs as l, jsx as o } from "react/jsx-runtime";
2
2
  import c from "classnames";
3
3
  import f from "react";
4
4
  import { cssProps as n } from "../../utils/helpers.js";
5
- import { I as u, s } from "../../Input-DE1QkW7S.js";
5
+ import { I as u, s } from "../../Input-D46mAsdt.js";
6
6
  const I = f.forwardRef(
7
7
  ({ size: r, error: t, label: a, className: e, style: i, required: d, ...m }, p) => /* @__PURE__ */ l(
8
8
  "label",
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ import { BaseInputProps } from './Input';
3
+ type TickMarksProps = {
4
+ ticks: number | (string | number)[];
5
+ };
6
+ export type RangeProps = Omit<BaseInputProps, 'min' | 'max' | 'value' | 'defaultValue'> & {
7
+ min?: number;
8
+ max?: number;
9
+ value?: number;
10
+ defaultValue?: number;
11
+ ticks?: TickMarksProps['ticks'];
12
+ };
13
+ export declare const Range: React.ForwardRefExoticComponent<Omit<BaseInputProps, "max" | "min" | "defaultValue" | "value"> & {
14
+ min?: number;
15
+ max?: number;
16
+ value?: number;
17
+ defaultValue?: number;
18
+ ticks?: TickMarksProps["ticks"];
19
+ } & React.RefAttributes<HTMLInputElement>>;
20
+ export {};
@@ -0,0 +1,54 @@
1
+ import { jsxs as g, jsx as t } from "react/jsx-runtime";
2
+ import R from "classnames";
3
+ import w, { useRef as x, useState as T, useEffect as j, useCallback as P } from "react";
4
+ import { V } from "../../ValidationTooltip-D8d9O6Re.js";
5
+ import { cssProps as A, wrapNode as E } from "../../utils/helpers.js";
6
+ const J = "styles_range_j9iED", D = "styles_range_thumb_6aftN", F = "styles_range_wrapper_LTcAf", H = "styles_range_track_HdlJx", L = "styles_ticks_YaeJb", n = {
7
+ range: J,
8
+ range_thumb: D,
9
+ range_wrapper: F,
10
+ range_track: H,
11
+ ticks: L
12
+ };
13
+ function f(r, a, e, s) {
14
+ r == null || r.style.setProperty("--progress", `${(s - a) / (e - a)}`);
15
+ }
16
+ const M = ({ ticks: r }) => {
17
+ const a = typeof r == "number" ? [...Array(r)] : r;
18
+ return a.length < 2 ? null : /* @__PURE__ */ t("ul", { "data-range-ticks": !0, className: n.ticks, children: a.map((e, s) => /* @__PURE__ */ t("li", { children: e !== void 0 && /* @__PURE__ */ t("small", { children: e }) }, s)) });
19
+ }, B = w.forwardRef(
20
+ ({ size: r, height: a, error: e, ticks: s, className: m, style: y, children: u, onChange: c, ...i }, h) => {
21
+ const { min: l = 0, max: o = 100, defaultValue: v = 50, value: p = v } = i, d = x(null), [k, b] = T(null);
22
+ j(() => {
23
+ f(d.current, l, o, p);
24
+ }, [l, o, p]);
25
+ const N = P(
26
+ (_) => {
27
+ f(d.current, l, o, parseFloat(_.currentTarget.value)), c == null || c(_);
28
+ },
29
+ [l, o, c]
30
+ );
31
+ return /* @__PURE__ */ g(
32
+ "div",
33
+ {
34
+ ref: d,
35
+ "data-input": "range",
36
+ "data-disabled": i.disabled,
37
+ "data-invalid": e ? !0 : void 0,
38
+ className: R(n.range, m),
39
+ style: { ...y, ...A({ size: r, height: a }) },
40
+ children: [
41
+ /* @__PURE__ */ g("div", { className: n.range_wrapper, children: [
42
+ /* @__PURE__ */ t("div", { "data-range-track": !0, className: n.range_track }),
43
+ /* @__PURE__ */ t("div", { ref: b, "data-range-thumb": !0, className: n.range_thumb, children: u !== void 0 && E(u, "small") }),
44
+ /* @__PURE__ */ t(V, { content: e, placement: "top", anchor: k, children: /* @__PURE__ */ t("input", { ...i, ref: h, type: "range", onChange: N }) })
45
+ ] }),
46
+ s !== void 0 && /* @__PURE__ */ t(M, { ticks: s })
47
+ ]
48
+ }
49
+ );
50
+ }
51
+ );
52
+ export {
53
+ B as Range
54
+ };
@@ -2,7 +2,7 @@ import { jsx as e } from "react/jsx-runtime";
2
2
  import l from "classnames";
3
3
  import c from "react";
4
4
  import { cssProps as m } from "../../utils/helpers.js";
5
- import { V as d, s as f } from "../../ValidationTooltip-BgSwl0hJ.js";
5
+ import { V as d, s as f } from "../../ValidationTooltip-D8d9O6Re.js";
6
6
  const y = c.forwardRef(
7
7
  ({ size: o, error: t, className: s, style: a, ...r }, i) => /* @__PURE__ */ e(d, { content: t, children: /* @__PURE__ */ e(
8
8
  "select",
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ import { BaseInputProps } from './Input';
3
+ export type SwitchProps = BaseInputProps & {
4
+ label?: React.ReactNode;
5
+ checkedColor?: string;
6
+ };
7
+ export declare const Switch: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> & {
8
+ size?: "xs" | "sm" | "md" | "lg" | "xl";
9
+ error?: string;
10
+ } & {
11
+ label?: React.ReactNode;
12
+ checkedColor?: string;
13
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,36 @@
1
+ import { jsxs as d, jsx as t } from "react/jsx-runtime";
2
+ import m from "react";
3
+ import h from "classnames";
4
+ import { cssProps as u } from "../../utils/helpers.js";
5
+ import { V as f } from "../../ValidationTooltip-D8d9O6Re.js";
6
+ const _ = "styles_label_p-D4Y", w = "styles_input_VteBP", s = {
7
+ switch: "styles_switch_UNvH8",
8
+ label: _,
9
+ input: w
10
+ }, V = m.forwardRef(
11
+ ({ size: a, error: i, label: e, required: l, checkedColor: o, className: c, style: n, ...r }, p) => /* @__PURE__ */ d(
12
+ "label",
13
+ {
14
+ "data-input": "switch",
15
+ "data-required": l,
16
+ className: h(s.switch, c),
17
+ style: { ...n, ...u({ size: a, checkedColor: o }) },
18
+ children: [
19
+ /* @__PURE__ */ t(f, { content: i, children: /* @__PURE__ */ t(
20
+ "input",
21
+ {
22
+ ...r,
23
+ ref: p,
24
+ type: "checkbox",
25
+ "data-invalid": i ? !0 : void 0,
26
+ className: s.input
27
+ }
28
+ ) }),
29
+ e && /* @__PURE__ */ t("div", { className: s.label, children: e })
30
+ ]
31
+ }
32
+ )
33
+ );
34
+ export {
35
+ V as Switch
36
+ };
@@ -3,7 +3,7 @@ import c from "classnames";
3
3
  import d from "react";
4
4
  import f from "react-textarea-autosize";
5
5
  import { cssProps as l } from "../../utils/helpers.js";
6
- import { V as x, s as u } from "../../ValidationTooltip-BgSwl0hJ.js";
6
+ import { V as x, s as u } from "../../ValidationTooltip-D8d9O6Re.js";
7
7
  const _ = d.forwardRef(
8
8
  ({ autosize: t = !0, size: e, error: o, className: s, style: m, ...a }, i) => {
9
9
  const n = t ? f : "textarea", p = t ? { minRows: 2, ...a } : a;
@@ -1,2 +1,2 @@
1
1
  import { TooltipProps } from '../Tooltip';
2
- export declare const ValidationTooltip: (props: TooltipProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ValidationTooltip: ({ className, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import "react/jsx-runtime";
2
+ import "classnames";
2
3
  import "../Tooltip/Tooltip.js";
3
- import { V as r } from "../../ValidationTooltip-BgSwl0hJ.js";
4
+ import { V as m } from "../../ValidationTooltip-D8d9O6Re.js";
4
5
  export {
5
- r as ValidationTooltip
6
+ m as ValidationTooltip
6
7
  };
@@ -1,8 +1,10 @@
1
1
  export * from './Checkbox';
2
2
  export * from './Field';
3
3
  export * from './Input';
4
- export * from './Quantity';
4
+ export * from './Numeric';
5
5
  export * from './Radio';
6
+ export * from './Range';
6
7
  export * from './Select';
8
+ export * from './Switch';
7
9
  export * from './Textarea';
8
10
  export * from './ValidationTooltip';
@@ -1,20 +1,24 @@
1
- import { Checkbox as r } from "./Checkbox.js";
2
- import { Field as p, FieldDescription as i, FieldLabel as x } from "./Field.js";
3
- import { I as f } from "../../Input-DE1QkW7S.js";
4
- import { Quantity as l } from "./Quantity.js";
5
- import { Radio as n } from "./Radio.js";
6
- import { Select as s } from "./Select.js";
7
- import { Textarea as b } from "./Textarea.js";
8
- import { V as I } from "../../ValidationTooltip-BgSwl0hJ.js";
1
+ import { Checkbox as e } from "./Checkbox.js";
2
+ import { Field as p, FieldDescription as x, FieldLabel as i } from "./Field.js";
3
+ import { I as f } from "../../Input-D46mAsdt.js";
4
+ import { Numeric as l } from "./Numeric.js";
5
+ import { Radio as d } from "./Radio.js";
6
+ import { Range as s } from "./Range.js";
7
+ import { Select as b } from "./Select.js";
8
+ import { Switch as u } from "./Switch.js";
9
+ import { Textarea as R } from "./Textarea.js";
10
+ import { V as T } from "../../ValidationTooltip-D8d9O6Re.js";
9
11
  export {
10
- r as Checkbox,
12
+ e as Checkbox,
11
13
  p as Field,
12
- i as FieldDescription,
13
- x as FieldLabel,
14
+ x as FieldDescription,
15
+ i as FieldLabel,
14
16
  f as Input,
15
- l as Quantity,
16
- n as Radio,
17
- s as Select,
18
- b as Textarea,
19
- I as ValidationTooltip
17
+ l as Numeric,
18
+ d as Radio,
19
+ s as Range,
20
+ b as Select,
21
+ u as Switch,
22
+ R as Textarea,
23
+ T as ValidationTooltip
20
24
  };
@@ -19,4 +19,4 @@ export declare const Flex: <T extends React.ElementType = "div">(props: {
19
19
  wrap?: React.CSSProperties["flexWrap"];
20
20
  marginStart?: React.CSSProperties["marginBlockStart"];
21
21
  marginEnd?: React.CSSProperties["marginBlockEnd"];
22
- } & Omit<React.PropsWithoutRef<React.ComponentProps<T>>, "direction" | "as" | "align" | "wrap" | "justify" | "gap" | "marginStart" | "marginEnd"> & React.RefAttributes<unknown>) => React.ReactElement | null;
22
+ } & Omit<React.PropsWithoutRef<React.ComponentProps<T>>, "direction" | "as" | "align" | "wrap" | "justify" | "marginStart" | "marginEnd" | "gap"> & React.RefAttributes<unknown>) => React.ReactElement | null;
@@ -1,36 +1,37 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { jsx as p } from "react/jsx-runtime";
2
2
  import d from "classnames";
3
- import { fixedForwardRef as i, cssProps as p } from "../../utils/helpers.js";
4
- const y = "Flex_flex_GBHBA", F = {
5
- flex: y
3
+ import { fixedForwardRef as i, cssProps as F } from "../../utils/helpers.js";
4
+ const u = "Flex_flex_GBHBA", w = {
5
+ flex: u
6
6
  };
7
- function u({
8
- as: l,
7
+ function y({
8
+ as: o,
9
9
  direction: e = "row",
10
- gap: o,
11
- align: r,
10
+ gap: r,
11
+ align: t,
12
12
  justify: s,
13
- wrap: f,
14
- marginStart: n,
15
- marginEnd: x,
16
- className: m,
17
- ...t
18
- }, c) {
19
- return /* @__PURE__ */ a(
20
- l ?? "div",
13
+ wrap: l,
14
+ marginStart: f,
15
+ marginEnd: n,
16
+ className: x,
17
+ style: m,
18
+ ...c
19
+ }, a) {
20
+ return /* @__PURE__ */ p(
21
+ o ?? "div",
21
22
  {
22
- ...t,
23
- ref: c,
23
+ ...c,
24
+ ref: a,
24
25
  "data-flex": e,
25
- className: d(F.flex, m),
26
+ className: d(w.flex, x),
26
27
  style: {
27
- ...t.style,
28
- ...p({ gap: o, align: r, justify: s, direction: e, wrap: f, marginStart: n, marginEnd: x })
28
+ ...m,
29
+ ...F({ gap: r, align: t, justify: s, direction: e, wrap: l, marginStart: f, marginEnd: n })
29
30
  }
30
31
  }
31
32
  );
32
33
  }
33
- const j = i(u);
34
+ const v = i(y);
34
35
  export {
35
- j as Flex
36
+ v as Flex
36
37
  };
@@ -1,9 +1,13 @@
1
1
  import { default as React } from 'react';
2
2
  import { Placement } from '@floating-ui/react';
3
- export type MenuProps = React.HTMLAttributes<HTMLDivElement> & {
3
+ export type MenuProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
4
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
5
  placement?: Placement;
5
6
  trigger: React.JSX.Element;
6
7
  minWidth?: React.CSSProperties['minWidth'];
7
8
  maxWidth?: React.CSSProperties['maxWidth'];
9
+ minHeight?: React.CSSProperties['minHeight'];
10
+ maxHeight?: React.CSSProperties['maxHeight'];
11
+ onSelect?: (index: number) => void;
8
12
  };
9
- export declare const Menu: ({ placement, trigger, minWidth, maxWidth, className, children, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const Menu: ({ size, placement, trigger, minWidth, maxWidth, minHeight, maxHeight, className, children, onSelect, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,78 +1,84 @@
1
- import { jsxs as E, Fragment as I, jsx as t } from "react/jsx-runtime";
2
- import N, { useState as r, useRef as d, useMemo as j, useEffect as B } from "react";
3
- import { flushSync as L } from "react-dom";
4
- import { useFloating as O, offset as W, flip as _, size as b, autoUpdate as k, useInteractions as A, useDismiss as D, useRole as H, useClick as U, useListNavigation as q, FloatingPortal as G, FloatingFocusManager as J, FloatingList as K } from "@floating-ui/react";
5
- import Q from "classnames";
6
- import { MenuContext as T } from "./MenuContext.js";
7
- import { s as V } from "../../styles.module-CUhWny5T.js";
8
- const ne = ({
9
- placement: p = "bottom-start",
1
+ import { jsxs as B, Fragment as L, jsx as t } from "react/jsx-runtime";
2
+ import O, { useState as r, useRef as p, useMemo as W, useEffect as _ } from "react";
3
+ import { flushSync as b } from "react-dom";
4
+ import { useFloating as k, offset as A, flip as D, size as H, autoUpdate as U, useInteractions as q, useDismiss as G, useRole as J, useClick as K, useListNavigation as Q, FloatingPortal as T, FloatingFocusManager as V, FloatingList as X } from "@floating-ui/react";
5
+ import Y from "classnames";
6
+ import { MenuContext as Z } from "./MenuContext.js";
7
+ import { cssProps as $ } from "../../utils/helpers.js";
8
+ import { s as ee } from "../../styles.module-D1F3R7Vi.js";
9
+ const me = ({
10
+ size: g,
11
+ placement: h = "bottom-start",
10
12
  trigger: a,
11
- minWidth: g,
12
- maxWidth: h,
13
- className: R,
14
- children: v,
15
- ...x
13
+ minWidth: R,
14
+ maxWidth: v,
15
+ minHeight: x,
16
+ maxHeight: F,
17
+ className: P,
18
+ children: y,
19
+ onSelect: l,
20
+ ...z
16
21
  }) => {
17
- const [l, c] = r(!1), [i, F] = r(null), [y, M] = r({}), m = d([]), u = d(null), { refs: o, context: e, floatingStyles: P } = O({
18
- open: l,
19
- placement: p,
22
+ const [m, c] = r(!1), [i, M] = r(null), [w, C] = r({}), u = p([]), f = p(null), { refs: o, context: e, floatingStyles: E } = k({
23
+ open: m,
24
+ placement: h,
20
25
  onOpenChange: c,
21
- whileElementsMounted: k,
26
+ whileElementsMounted: U,
22
27
  middleware: [
23
- W(5),
24
- _({ padding: 10 }),
25
- b({
28
+ A(5),
29
+ D({ padding: 10 }),
30
+ H({
26
31
  padding: 10,
27
- apply({ rects: n, availableWidth: s, availableHeight: z }) {
28
- L(() => {
29
- M({
30
- minWidth: n.reference.width,
31
- maxWidth: s,
32
- maxHeight: z
32
+ apply({ rects: n, availableWidth: s, availableHeight: j }) {
33
+ b(() => {
34
+ C({
35
+ minHeight: x,
36
+ minWidth: R ?? n.reference.width,
37
+ maxWidth: v ?? s,
38
+ maxHeight: F ?? j
33
39
  });
34
40
  });
35
41
  }
36
42
  })
37
43
  ]
38
- }), { getReferenceProps: w, getFloatingProps: C, getItemProps: f } = A([
39
- D(e),
40
- H(e, { role: "menu" }),
41
- U(e, { event: "mousedown" }),
42
- q(e, {
43
- listRef: m,
44
+ }), { getReferenceProps: I, getFloatingProps: N, getItemProps: d } = q([
45
+ G(e),
46
+ J(e, { role: "menu" }),
47
+ K(e, { event: "mousedown" }),
48
+ Q(e, {
49
+ listRef: u,
44
50
  loop: !0,
45
51
  activeIndex: i,
46
- onNavigate: F
52
+ onNavigate: M
47
53
  })
48
- ]), S = j(
49
- () => ({ active: i, setOpen: c, getItemProps: f }),
50
- [i, f]
54
+ ]), S = W(
55
+ () => ({ active: i, setOpen: c, getItemProps: d, onSelect: l }),
56
+ [i, d, l]
51
57
  );
52
- return B(() => {
58
+ return _(() => {
53
59
  var s;
54
60
  const n = (s = o.domReference.current) == null ? void 0 : s.closest("[data-floating-root]");
55
- n && (u.current = n);
56
- }, [o]), /* @__PURE__ */ E(I, { children: [
57
- N.cloneElement(a, {
61
+ n && (f.current = n);
62
+ }, [o]), /* @__PURE__ */ B(L, { children: [
63
+ O.cloneElement(a, {
58
64
  ref: o.setReference,
59
- "data-menu": "trigger",
60
- ...w(a.props)
65
+ ...I(a.props),
66
+ "data-menu-trigger": !0
61
67
  }),
62
- /* @__PURE__ */ t(T.Provider, { value: S, children: l && /* @__PURE__ */ t(G, { root: u, children: /* @__PURE__ */ t(J, { context: e, modal: !1, initialFocus: -1, children: /* @__PURE__ */ t(
68
+ /* @__PURE__ */ t(Z.Provider, { value: S, children: m && /* @__PURE__ */ t(T, { root: f, children: /* @__PURE__ */ t(V, { context: e, modal: !1, initialFocus: -1, children: /* @__PURE__ */ t(
63
69
  "div",
64
70
  {
65
- ...x,
71
+ ...z,
72
+ ...N(),
66
73
  ref: o.setFloating,
67
- "data-menu": "content",
68
- className: Q(V.menu, R),
69
- style: { ...P, ...y, minWidth: g, maxWidth: h },
70
- ...C(),
71
- children: /* @__PURE__ */ t(K, { elementsRef: m, children: v })
74
+ "data-menu": !0,
75
+ className: Y(ee.menu, P),
76
+ style: { ...E, ...w, ...$({ size: g }) },
77
+ children: /* @__PURE__ */ t(X, { elementsRef: u, children: y })
72
78
  }
73
79
  ) }) }) })
74
80
  ] });
75
81
  };
76
82
  export {
77
- ne as Menu
83
+ me as Menu
78
84
  };
@@ -4,5 +4,6 @@ export type MenuContextProps = {
4
4
  active: number | null;
5
5
  setOpen: (value: boolean) => void;
6
6
  getItemProps: UseInteractionsReturn['getItemProps'];
7
+ onSelect?: (index: number) => void;
7
8
  };
8
9
  export declare const MenuContext: React.Context<MenuContextProps>;
@@ -1,7 +1,6 @@
1
- export type MenuItemProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
2
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
1
+ export type MenuItemProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'title'> & {
3
2
  scheme?: 'default' | 'negative' | 'positive' | 'warning';
4
3
  icon?: React.ReactElement;
5
4
  title?: React.ReactNode;
6
5
  };
7
- export declare const MenuItem: ({ size, scheme, icon, title, children, className, style, onClick, ...props }: MenuItemProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const MenuItem: ({ scheme, icon, title, children, className, onClick, ...props }: MenuItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,50 +1,44 @@
1
- import { jsx as i, jsxs as h, Fragment as j } from "react/jsx-runtime";
2
- import { useContext as M, useCallback as N } from "react";
3
- import { useListItem as P } from "@floating-ui/react";
4
- import v from "classnames";
1
+ import { jsx as I, jsxs as g, Fragment as h } from "react/jsx-runtime";
2
+ import { useContext as j, useCallback as y } from "react";
3
+ import { useListItem as M } from "@floating-ui/react";
4
+ import N from "classnames";
5
5
  import { MenuContext as w } from "./MenuContext.js";
6
- import { cssProps as A } from "../../utils/helpers.js";
7
- import { s as n } from "../../styles.module-CUhWny5T.js";
8
- function a(t) {
9
- return typeof t == "string" ? /* @__PURE__ */ i("span", { children: t }) : t;
10
- }
11
- const D = ({
12
- size: t,
6
+ import { wrapNode as n } from "../../utils/helpers.js";
7
+ import { s as i } from "../../styles.module-D1F3R7Vi.js";
8
+ const B = ({
13
9
  scheme: p = "default",
14
- icon: c,
10
+ icon: u,
15
11
  title: r,
16
12
  children: s,
17
13
  className: f,
18
- style: u,
19
- onClick: e,
14
+ onClick: t,
20
15
  ...d
21
16
  }) => {
22
- const { active: x, setOpen: o, getItemProps: l } = M(w), { ref: b, index: y } = P(), m = y === x, I = N(
23
- (g) => {
24
- o(!1), e == null || e(g);
17
+ const { active: c, setOpen: o, getItemProps: x, onSelect: e } = j(w), { ref: b, index: m } = M(), a = m === c, l = y(
18
+ (v) => {
19
+ o(!1), e == null || e(m), t == null || t(v);
25
20
  },
26
- [o, e]
21
+ [m, o, e, t]
27
22
  );
28
- return /* @__PURE__ */ i(
23
+ return /* @__PURE__ */ I(
29
24
  "button",
30
25
  {
31
26
  ...d,
32
27
  ref: b,
33
28
  type: "button",
34
29
  role: "menuitem",
35
- "data-menu": "item",
36
- "data-active": m,
37
- tabIndex: m ? 0 : -1,
38
- className: v(n.menuitem, n[p], f),
39
- style: { ...u, ...A({ size: t }) },
40
- ...l({ onClick: I }),
41
- children: s ? a(s) : /* @__PURE__ */ h(j, { children: [
42
- c,
43
- r && a(r)
30
+ "data-menu-item": !0,
31
+ "data-active": a,
32
+ tabIndex: a ? 0 : -1,
33
+ className: N(i.menuitem, i[p], f),
34
+ ...x({ onClick: l }),
35
+ children: s ? n(s, "span") : /* @__PURE__ */ g(h, { children: [
36
+ u,
37
+ r !== void 0 && n(r, "span")
44
38
  ] })
45
39
  }
46
40
  );
47
41
  };
48
42
  export {
49
- D as MenuItem
43
+ B as MenuItem
50
44
  };