gd-design-library 1.2.0 → 1.3.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 (48) hide show
  1. package/ai/schemas/components/Image.d.ts +8 -0
  2. package/ai/schemas/components/Menu.d.ts +5 -0
  3. package/ai/schemas/components/Switch.d.ts +5 -5
  4. package/components/core/Form/Form.stories.play.d.ts +4 -0
  5. package/components/core/Image/Image.d.ts +4 -0
  6. package/components/core/Image/Image.js +26 -24
  7. package/components/core/Image/Image.types.d.ts +10 -3
  8. package/components/core/Image/ImageStyled.js +39 -37
  9. package/components/core/InputFile/InputFile.d.ts +4 -0
  10. package/components/core/Menu/Menu.js +74 -66
  11. package/components/core/Menu/Menu.types.d.ts +5 -1
  12. package/components/core/Menu/constants.d.ts +0 -8
  13. package/components/core/Switch/Switch.js +35 -35
  14. package/components/core/Switch/Switch.types.d.ts +4 -4
  15. package/components/domainSpecific/Accordion/Accordion.d.ts +1 -1
  16. package/components/domainSpecific/Accordion/Accordion.js +38 -29
  17. package/components/domainSpecific/Accordion/Accordion.types.d.ts +4 -0
  18. package/components/domainSpecific/Accordion/AccordionHeader/AccordionHeader.js +17 -16
  19. package/components/domainSpecific/Accordion/AccordionItem/AccordionItem.d.ts +1 -1
  20. package/components/domainSpecific/Accordion/AccordionItem/AccordionItem.js +14 -14
  21. package/components/domainSpecific/Accordion/AccordionStyled.js +25 -22
  22. package/components/domainSpecific/Accordion/constants.js +6 -5
  23. package/components/domainSpecific/Card/Card.stories.play.d.ts +4 -0
  24. package/components/domainSpecific/ChatBubble/ChatBubbleStyled.js +11 -11
  25. package/components/domainSpecific/Header/Header.stories.play.d.ts +9 -0
  26. package/components/domainSpecific/SearchModal/SearchModal.stories.play.d.ts +2 -0
  27. package/components/widget/DragAndDrop/DragAndDrop.stories.play.d.ts +6 -0
  28. package/hooks/useMediaQuery/useMediaQuery.d.ts +3 -0
  29. package/hooks/useMediaQuery/useMediaQuery.js +9 -7
  30. package/hooks/useTheme/NoOpTheme.d.ts +27 -5
  31. package/llms.txt +6 -3
  32. package/package.json +1 -1
  33. package/tokens/accordion.d.ts +17 -4
  34. package/tokens/accordion.js +19 -6
  35. package/tokens/chatbubble.d.ts +2 -1
  36. package/tokens/chatbubble.js +4 -3
  37. package/tokens/defaultTheme.d.ts +27 -5
  38. package/tokens/index.d.ts +10 -1
  39. package/tokens/menu.d.ts +7 -0
  40. package/tokens/menu.js +12 -5
  41. package/tokens/select.d.ts +1 -0
  42. package/tokens/select.js +6 -5
  43. package/utils/play/formUtils.d.ts +27 -0
  44. package/utils/play/imageUtils.d.ts +12 -0
  45. package/utils/play/index.d.ts +5 -0
  46. package/utils/play/mockUtils.d.ts +29 -0
  47. package/utils/play/modalUtils.d.ts +26 -0
  48. package/utils/play/waitUtils.d.ts +47 -0
@@ -15,14 +15,22 @@ declare const _default: {
15
15
  keyboardSupport: boolean;
16
16
  screenReaderSupport: boolean;
17
17
  props: ({
18
+ name: string;
19
+ type: string;
20
+ description: string;
21
+ default: string;
22
+ required?: undefined;
23
+ } | {
18
24
  name: string;
19
25
  type: string;
20
26
  description: string;
21
27
  required: boolean;
28
+ default?: undefined;
22
29
  } | {
23
30
  name: string;
24
31
  type: string;
25
32
  description: string;
33
+ default?: undefined;
26
34
  required?: undefined;
27
35
  })[];
28
36
  examples: string[];
@@ -29,6 +29,11 @@ declare const _default: {
29
29
  type: string;
30
30
  description: string;
31
31
  default: string;
32
+ } | {
33
+ name: string;
34
+ type: string;
35
+ description: string;
36
+ default: number;
32
37
  })[];
33
38
  examples: string[];
34
39
  };
@@ -18,20 +18,20 @@ declare const _default: {
18
18
  name: string;
19
19
  type: string;
20
20
  description: string;
21
- default: boolean;
21
+ default?: undefined;
22
22
  enum?: undefined;
23
23
  } | {
24
24
  name: string;
25
25
  type: string;
26
26
  description: string;
27
- default: string;
28
- enum: string[];
27
+ default: boolean;
28
+ enum?: undefined;
29
29
  } | {
30
30
  name: string;
31
31
  type: string;
32
32
  description: string;
33
- default?: undefined;
34
- enum?: undefined;
33
+ default: string;
34
+ enum: string[];
35
35
  } | {
36
36
  name: string;
37
37
  type: string;
@@ -0,0 +1,4 @@
1
+ import { StoryContext } from '@storybook/types';
2
+ export declare const withSubmitActions: ({ args, canvasElement, step }: StoryContext) => Promise<void>;
3
+ export declare const withOnChangeActions: ({ args, canvasElement, step }: StoryContext) => Promise<void>;
4
+ export declare const validationErrorsActions: ({ args, canvasElement, step }: StoryContext) => Promise<void>;
@@ -1,2 +1,6 @@
1
1
  import { ImageProps } from './';
2
+ /**
3
+ * @TODO: Cerebra
4
+ * - as span
5
+ */
2
6
  export declare const Image: import('react').ForwardRefExoticComponent<ImageProps & import('react').RefAttributes<HTMLImageElement>>;
@@ -1,40 +1,42 @@
1
1
  "use client";
2
- import { jsxs as x, jsx as a } from "@emotion/react/jsx-runtime";
3
- import { forwardRef as P, useState as p, useCallback as f } from "react";
2
+ import { jsxs as A, jsx as r } from "@emotion/react/jsx-runtime";
3
+ import { forwardRef as F, useState as f, useCallback as u } from "react";
4
4
  import { COMPONENT_NAME as e } from "./constants.js";
5
- import { ImageWrapperStyled as F, PlaceholderStyled as M, ImageStyled as O, CaptionStyled as T } from "./ImageStyled.js";
6
- import { Skeleton as A } from "../Skeleton/Skeleton.js";
7
- import { useTheme as R } from "../../../hooks/useTheme/useTheme.js";
8
- const W = P((u, g) => {
5
+ import { ImageWrapperStyled as M, PlaceholderStyled as O, ImageStyled as T, CaptionStyled as R } from "./ImageStyled.js";
6
+ import { Skeleton as W } from "../Skeleton/Skeleton.js";
7
+ import { useTheme as _ } from "../../../hooks/useTheme/useTheme.js";
8
+ const q = F((g, S) => {
9
9
  const {
10
- id: S,
11
- src: l,
12
- alt: k,
13
- width: s,
10
+ id: k,
11
+ src: s,
12
+ alt: C,
13
+ width: l,
14
14
  height: i,
15
15
  placeholder: d,
16
16
  caption: c,
17
- onClick: C,
17
+ onClick: $,
18
18
  onLoad: t,
19
19
  onError: o,
20
20
  objectFit: b,
21
21
  fallbackComponent: n,
22
22
  styles: y,
23
- ...w
24
- } = u, {
25
- theme: r
26
- } = R(), [h, m] = p(!0), [E, I] = p(!1), L = h && d && l, N = (E || !l) && n, $ = f(() => {
27
- m(!1), t == null || t();
28
- }, [t]), j = f(() => {
29
- m(!1), I(!0), o == null || o();
23
+ as: h,
24
+ captionAs: w,
25
+ ...E
26
+ } = g, {
27
+ theme: a
28
+ } = _(), [m, p] = f(!0), [I, L] = f(!1), N = m && d && s, j = (I || !s) && n, x = u(() => {
29
+ p(!1), t == null || t();
30
+ }, [t]), P = u(() => {
31
+ p(!1), L(!0), o == null || o();
30
32
  }, [o]);
31
- return /* @__PURE__ */ x(F, { "data-testid": `${e}-wrapper`, id: S, width: s, height: i, theme: r, ...w, children: [
32
- L && /* @__PURE__ */ a(M, { "data-testid": `${e}-placeholder`, theme: r, children: /* @__PURE__ */ a(A, { height: "100%", children: d }) }),
33
- N ? n : /* @__PURE__ */ a(O, { "data-testid": e, theme: r, src: l, alt: k, width: s, height: i, objectFit: b, $isLoading: h, onLoad: $, onError: j, onClick: C, styles: y, ref: g }),
34
- c && /* @__PURE__ */ a(T, { "data-testid": `${e}-caption`, theme: r, children: c })
33
+ return /* @__PURE__ */ A(M, { "data-testid": `${e}-wrapper`, id: k, width: l, height: i, theme: a, $as: h, ...E, children: [
34
+ N && /* @__PURE__ */ r(O, { "data-testid": `${e}-placeholder`, $as: h, theme: a, children: /* @__PURE__ */ r(W, { height: "100%", children: d }) }),
35
+ j ? n : /* @__PURE__ */ r(T, { "data-testid": e, theme: a, src: s, alt: C, width: l, height: i, objectFit: b, $isLoading: m, onLoad: x, onError: P, onClick: $, styles: y, ref: S }),
36
+ c && /* @__PURE__ */ r(R, { "data-testid": `${e}-caption`, $as: w, theme: a, children: c })
35
37
  ] });
36
38
  });
37
- W.displayName = e;
39
+ q.displayName = e;
38
40
  export {
39
- W as Image
41
+ q as Image
40
42
  };
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { ElementType, ReactNode } from 'react';
2
2
  import { CommonCssComponentProps, CommonCssComponentStyledProps } from '../..';
3
3
  export interface ImageProps extends CommonCssComponentProps {
4
4
  id?: string;
@@ -13,8 +13,11 @@ export interface ImageProps extends CommonCssComponentProps {
13
13
  placeholder?: ReactNode;
14
14
  fallbackComponent?: ReactNode;
15
15
  objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
16
+ as?: keyof HTMLElementTagNameMap | ElementType;
17
+ captionAs?: keyof HTMLElementTagNameMap | ElementType;
16
18
  }
17
19
  export interface ImageWrapperStyledProps extends Pick<ImageProps, 'width' | 'height' | 'id' | 'className'>, CommonCssComponentStyledProps {
20
+ $as?: keyof HTMLElementTagNameMap | ElementType;
18
21
  }
19
22
  export interface ImageStyledProps extends Pick<ImageProps, 'objectFit'>, CommonCssComponentStyledProps<HTMLImageElement> {
20
23
  $isLoading?: boolean;
@@ -23,5 +26,9 @@ export interface ImageStyledProps extends Pick<ImageProps, 'objectFit'>, CommonC
23
26
  width?: number;
24
27
  height?: number;
25
28
  }
26
- export type ImagePlaceholderStyledProps = CommonCssComponentStyledProps;
27
- export type ImageCaptionStyledProps = CommonCssComponentStyledProps;
29
+ export interface ImagePlaceholderStyledProps extends CommonCssComponentStyledProps {
30
+ $as?: keyof HTMLElementTagNameMap | ElementType;
31
+ }
32
+ export interface ImageCaptionStyledProps extends CommonCssComponentStyledProps {
33
+ $as?: keyof HTMLElementTagNameMap | ElementType;
34
+ }
@@ -1,76 +1,78 @@
1
- "use client";
2
- import { jsx as l } from "@emotion/react/jsx-runtime";
1
+ import { jsx as a } from "@emotion/react/jsx-runtime";
3
2
  import { forwardRef as x } from "react";
4
- import { getBoxStyles as i, tokensHandler as y } from "../../../tokens/utils.js";
3
+ import { getBoxStyles as y, tokensHandler as i } from "../../../tokens/utils.js";
5
4
  import { get as d } from "../../../utils/helpers.js";
6
- const $ = (s) => {
5
+ const I = (s) => {
7
6
  const {
8
7
  width: t,
9
8
  height: e,
9
+ $as: o = "div",
10
10
  theme: {
11
- image: o,
12
- ...r
11
+ image: r,
12
+ ...n
13
13
  } = {},
14
- styles: c,
15
- ...n
14
+ styles: p,
15
+ ...c
16
16
  } = s, {
17
- boxStyles: p,
18
- restProps: m
19
- } = i(n), a = new Proxy(o || {}, y(r)), h = [d(a, "wrapper", {}), {
17
+ boxStyles: m,
18
+ restProps: l
19
+ } = y(c), h = new Proxy(r || {}, i(n)), g = [d(h, "wrapper", {}), {
20
20
  width: `${t ? `${t}px` : "100%"}`,
21
21
  height: `${e ? `${e}px` : "100%"}`
22
- }, p, c];
23
- return /* @__PURE__ */ l("div", { css: h, ...m });
22
+ }, m, p];
23
+ return /* @__PURE__ */ a(o, { css: g, ...l });
24
24
  }, b = x((s, t) => {
25
25
  const {
26
26
  objectFit: e = "cover",
27
27
  $isLoading: o,
28
28
  theme: {
29
29
  image: r,
30
- ...c
30
+ ...n
31
31
  } = {},
32
- styles: n,
33
- width: p,
32
+ styles: p,
33
+ width: c,
34
34
  height: m,
35
- ...a
35
+ ...l
36
36
  } = s, {
37
37
  boxStyles: h,
38
38
  restProps: g
39
- } = i(a), P = new Proxy(r || {}, y(c)), S = [d(P, "default", {}), {
39
+ } = y(l), P = new Proxy(r || {}, i(n)), S = [d(P, "default", {}), {
40
40
  objectFit: e,
41
41
  opacity: `${o ? 0 : 1}`
42
- }, h, n];
43
- return /* @__PURE__ */ l("img", { css: S, width: p, height: m, ...g, ref: t });
44
- }), N = (s) => {
42
+ }, h, p];
43
+ return /* @__PURE__ */ a("img", { css: S, width: c, height: m, ...g, ref: t });
44
+ }), C = (s) => {
45
45
  const {
46
46
  theme: {
47
47
  image: t,
48
48
  ...e
49
49
  } = {},
50
- styles: o,
51
- ...r
50
+ $as: o = "span",
51
+ styles: r,
52
+ ...n
52
53
  } = s, {
53
- boxStyles: c,
54
- restProps: n
55
- } = i(r), p = new Proxy(t || {}, y(e)), m = [d(p, "placeholder", {}), c, o];
56
- return /* @__PURE__ */ l("div", { css: m, ...n });
57
- }, v = (s) => {
54
+ boxStyles: p,
55
+ restProps: c
56
+ } = y(n), m = new Proxy(t || {}, i(e)), l = [d(m, "placeholder", {}), p, r];
57
+ return /* @__PURE__ */ a(o, { css: l, ...c });
58
+ }, N = (s) => {
58
59
  const {
59
60
  theme: {
60
61
  image: t,
61
62
  ...e
62
63
  } = {},
63
- styles: o,
64
- ...r
64
+ $as: o = "figcaption",
65
+ styles: r,
66
+ ...n
65
67
  } = s, {
66
- boxStyles: c,
67
- restProps: n
68
- } = i(r), p = new Proxy(t || {}, y(e)), m = [d(p, "caption", {}), c, o];
69
- return /* @__PURE__ */ l("figcaption", { css: m, ...n });
68
+ boxStyles: p,
69
+ restProps: c
70
+ } = y(n), m = new Proxy(t || {}, i(e)), l = [d(m, "caption", {}), p, r];
71
+ return /* @__PURE__ */ a(o, { css: l, ...c });
70
72
  };
71
73
  export {
72
- v as CaptionStyled,
74
+ N as CaptionStyled,
73
75
  b as ImageStyled,
74
- $ as ImageWrapperStyled,
75
- N as PlaceholderStyled
76
+ I as ImageWrapperStyled,
77
+ C as PlaceholderStyled
76
78
  };
@@ -1,2 +1,6 @@
1
1
  import { InputFileProps } from './';
2
+ /**
3
+ * @TODO: Cerebra
4
+ * - apply same styles as a button
5
+ */
2
6
  export declare const InputFile: import('react').ForwardRefExoticComponent<InputFileProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,126 +1,134 @@
1
1
  "use client";
2
- import { jsxs as X, jsx as x } from "@emotion/react/jsx-runtime";
3
- import { forwardRef as K, useState as y, useRef as H, useCallback as L, useEffect as U, useImperativeHandle as W } from "react";
4
- import { EMPTY_CLIENT_RECT as j, COMPONENT_NAME as m } from "./constants.js";
5
- import { MenuTriggerStyled as G, MenuContentStyled as R } from "./MenuStyled.js";
6
- import { useAnimationFrame as V } from "../../../utils/animationFrame.js";
7
- import { SelectContext as q } from "../Select/hooks/useSelectContext.js";
8
- import { convertToInlineBoxStyles as z } from "../../../tokens/utils.js";
9
- import { useTheme as J } from "../../../hooks/useTheme/useTheme.js";
10
- import { useLogger as Q } from "../../../hooks/useLogger/useLogger.js";
11
- import { Portal as Z } from "../Portal/Portal.js";
12
- import { KEYBOARD_KEYS as ee } from "../../../constants/keyboard.js";
13
- const n = 4, te = 400, oe = 80, ne = K(({
14
- onSelect: a,
15
- children: A,
16
- content: Y,
17
- itemIdentifier: I = (f, r) => (f == null ? void 0 : f.value) === (r == null ? void 0 : r.value),
2
+ import { jsxs as Z, jsx as O } from "@emotion/react/jsx-runtime";
3
+ import { forwardRef as ee, useState as Y, useRef as L, useCallback as $, useEffect as te, useImperativeHandle as oe } from "react";
4
+ import { EMPTY_CLIENT_RECT as ne, COMPONENT_NAME as f } from "./constants.js";
5
+ import { MenuTriggerStyled as re, MenuContentStyled as se } from "./MenuStyled.js";
6
+ import { useAnimationFrame as ie } from "../../../utils/animationFrame.js";
7
+ import { SelectContext as le } from "../Select/hooks/useSelectContext.js";
8
+ import { convertToInlineBoxStyles as ce } from "../../../tokens/utils.js";
9
+ import { useTheme as me } from "../../../hooks/useTheme/useTheme.js";
10
+ import { useLogger as fe } from "../../../hooks/useLogger/useLogger.js";
11
+ import { get as E } from "../../../utils/helpers.js";
12
+ import { Portal as ue } from "../Portal/Portal.js";
13
+ import { KEYBOARD_KEYS as pe } from "../../../constants/keyboard.js";
14
+ const ge = ee(({
15
+ onSelect: w,
16
+ children: X,
17
+ content: A,
18
+ itemIdentifier: I = (r, s) => (r == null ? void 0 : r.value) === (s == null ? void 0 : s.value),
18
19
  closeOnSelect: M = !0,
19
- placement: _,
20
- ...$
21
- }, v) => {
20
+ minHeight: _,
21
+ maxHeight: K,
22
+ offsetX: R,
23
+ offsetY: W,
24
+ placement: P,
25
+ ...B
26
+ }, d) => {
22
27
  const {
23
- theme: f
24
- } = J(), r = Q(), [l, g] = y(!1), [i, P] = y(), [N, E] = y(), p = H(null), s = H(null), S = H({
28
+ theme: r
29
+ } = me(), s = fe(), [l, a] = Y(!1), [i, j] = Y(), [D, x] = Y(), p = L(null), n = L(null), F = L({
25
30
  top: 0,
26
31
  left: 0
27
- }), F = L(({
32
+ }), N = _ || E(r, "menu.attrs.minHeight"), S = K || E(r, "menu.attrs.maxHeight"), g = R || E(r, "menu.attrs.offsetX", 0), u = W || E(r, "menu.attrs.offsetY", 0), V = $(({
28
33
  width: t,
29
34
  height: e
30
35
  }) => {
31
- const o = p.current ? p.current.getBoundingClientRect() : j, w = window.innerWidth, d = window.innerHeight, h = window.scrollX || window.pageXOffset || 0, k = window.scrollY || window.pageYOffset || 0, O = _ || "bottom-right";
32
- let c, u;
33
- switch (O) {
36
+ const o = p.current ? p.current.getBoundingClientRect() : ne, h = window.innerWidth, C = window.innerHeight, T = window.scrollX || window.pageXOffset || 0, b = window.scrollY || window.pageYOffset || 0, v = P || "bottom-right";
37
+ let c, m;
38
+ switch (v) {
34
39
  case "top-left": {
35
- c = o.left - t, u = o.top - e - n;
40
+ c = o.left - t - g, m = o.top - e - u;
36
41
  break;
37
42
  }
38
43
  case "top-right": {
39
- c = o.right + n, u = o.top - e - n;
44
+ c = o.right + g, m = o.top - e - u;
40
45
  break;
41
46
  }
42
47
  case "bottom-left": {
43
- c = o.left - t, u = o.bottom + n;
48
+ c = o.left - t - g, m = o.bottom + u;
44
49
  break;
45
50
  }
46
51
  case "bottom-right": {
47
- c = o.right + n, u = o.bottom + n;
52
+ c = o.right + g, m = o.bottom + u;
48
53
  break;
49
54
  }
50
55
  }
51
- return c + t > w && (c = w - t - n), c < 0 && (c = n), u + e > d && (u = d - e - n), u < 0 && (u = n), {
52
- left: c + h,
53
- top: u + k
56
+ const G = c + t > h, J = c < 0;
57
+ (G || J) && (v === "top-left" || v === "bottom-left" ? c = g : c = h - t - g);
58
+ const Q = m + e > C, U = m < 0;
59
+ return (Q || U) && (v === "top-left" || v === "top-right" ? m = u : m = C - e - u), {
60
+ left: c + T,
61
+ top: m + b
54
62
  };
55
- }, [_]), C = L(({
63
+ }, [P, g, u]), H = $(({
56
64
  event: t,
57
65
  data: e
58
66
  }) => {
59
- r.debug(`${m}: Select`, {
67
+ s.debug(`${f}: Select`, {
60
68
  value: e == null ? void 0 : e.value,
61
69
  name: e == null ? void 0 : e.name,
62
70
  previousValue: i == null ? void 0 : i.value,
63
71
  previousName: i == null ? void 0 : i.name
64
- }), a == null || a({
72
+ }), w == null || w({
65
73
  event: t,
66
74
  data: e
67
- }), P(e), M && g(!1);
68
- }, [a, M, i]), B = L(() => {
69
- g((t) => {
75
+ }), j(e), M && a(!1);
76
+ }, [w, M, i]), q = $(() => {
77
+ a((t) => {
70
78
  const e = !t;
71
- return r.debug(`${m}: ${e ? "Open" : "Close"}`, {
79
+ return s.debug(`${f}: ${e ? "Open" : "Close"}`, {
72
80
  trigger: "toggle"
73
81
  }), e;
74
82
  });
75
- }, []), D = {
76
- onSelect: C,
83
+ }, []), z = {
84
+ onSelect: H,
77
85
  value: i,
78
86
  itemIdentifier: I
79
- }, b = (t) => {
87
+ }, k = (t) => {
80
88
  var e;
81
- ((e = v == null ? void 0 : v.current) != null && e.isOpen || l) && t.key === ee.ESCAPE && (r.debug(`${m}: Close`, {
89
+ ((e = d == null ? void 0 : d.current) != null && e.isOpen || l) && t.key === pe.ESCAPE && (s.debug(`${f}: Close`, {
82
90
  trigger: "escape"
83
- }), g(!1));
84
- }, T = (t) => {
91
+ }), a(!1));
92
+ }, y = (t) => {
85
93
  var e, o;
86
- !((e = p == null ? void 0 : p.current) != null && e.contains(N || t.target)) && !((o = s == null ? void 0 : s.current) != null && o.contains(t.target)) && (r.debug(`${m}: Close`, {
94
+ !((e = p == null ? void 0 : p.current) != null && e.contains(D || t.target)) && !((o = n == null ? void 0 : n.current) != null && o.contains(t.target)) && (s.debug(`${f}: Close`, {
87
95
  trigger: "outsideClick"
88
- }), g(!1), E(null));
96
+ }), a(!1), x(null));
89
97
  };
90
- return U(() => (l ? (document.addEventListener("keydown", b), document.addEventListener("mousedown", T)) : (document.removeEventListener("keydown", b), document.removeEventListener("mousedown", T)), () => {
91
- document.removeEventListener("keydown", b), document.removeEventListener("mousedown", T);
92
- }), [l]), V(() => {
93
- if (s.current && l) {
94
- const t = s.current.getBoundingClientRect(), {
98
+ return te(() => (l ? (document.addEventListener("keydown", k), document.addEventListener("mousedown", y)) : (document.removeEventListener("keydown", k), document.removeEventListener("mousedown", y)), () => {
99
+ document.removeEventListener("keydown", k), document.removeEventListener("mousedown", y);
100
+ }), [l]), ie(() => {
101
+ if (n.current && l) {
102
+ const t = n.current.getBoundingClientRect(), {
95
103
  top: e,
96
104
  left: o
97
- } = F(t), w = window.innerHeight, d = window.scrollY || window.pageYOffset || 0, h = e - d, k = w - h - n, O = Math.max(oe, Math.min(te, k));
98
- S.current = {
105
+ } = V(t), h = window.innerHeight, C = window.scrollY || window.pageYOffset || 0, T = e - C, b = h - T - u;
106
+ F.current = {
99
107
  top: e,
100
108
  left: o
101
- }, s.current && (s.current.style.left = `${o}px`, s.current.style.top = `${e}px`, s.current.style.maxHeight = `${O}px`);
109
+ }, n.current && (n.current.style.left = `${o}px`, n.current.style.top = `${e}px`, S && (n.current.style.maxHeight = `${Math.min(S, b)}px`), N && (n.current.style.minHeight = `${Math.min(N, b)}px`));
102
110
  }
103
- }), W(v, () => ({
111
+ }), oe(d, () => ({
104
112
  ref: p,
105
113
  isOpen: l,
106
114
  selectedValue: i,
107
- onSelect: C,
115
+ onSelect: H,
108
116
  open: (t) => {
109
- r.debug(`${m}: Open`, {
117
+ s.debug(`${f}: Open`, {
110
118
  trigger: "ref"
111
- }), !l && (E(t || null), g(!0));
119
+ }), !l && (x(t || null), a(!0));
112
120
  },
113
121
  close: (t) => {
114
- r.debug(`${m}: Close`, {
122
+ s.debug(`${f}: Close`, {
115
123
  trigger: "ref"
116
- }), l && (E(t || null), g(!1));
124
+ }), l && (x(t || null), a(!1));
117
125
  }
118
- }), [l, i, C]), /* @__PURE__ */ X(q.Provider, { value: D, children: [
119
- /* @__PURE__ */ x(G, { onClick: B, theme: f, ref: p, "data-testid": m, ...$, children: A }),
120
- l && /* @__PURE__ */ x(Z, { withWrapper: !1, children: /* @__PURE__ */ x(R, { ref: s, "data-testid": m, theme: f, ...z($), children: Y }) })
126
+ }), [l, i, H]), /* @__PURE__ */ Z(le.Provider, { value: z, children: [
127
+ /* @__PURE__ */ O(re, { onClick: q, theme: r, ref: p, "data-testid": f, ...B, children: X }),
128
+ l && /* @__PURE__ */ O(ue, { withWrapper: !1, children: /* @__PURE__ */ O(se, { ref: n, "data-testid": f, theme: r, ...ce(B), children: A }) })
121
129
  ] });
122
130
  });
123
- ne.displayName = m;
131
+ ge.displayName = f;
124
132
  export {
125
- ne as Menu
133
+ ge as Menu
126
134
  };
@@ -1,11 +1,15 @@
1
1
  import { ReactNode, Ref } from 'react';
2
2
  import { BoxCssComponentProps, CommonCssComponentStyledProps, Option, SelectOnSelect, ItemIdentifier } from '../..';
3
3
  export type MenuPlacement = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
4
- export interface MenuProps extends Omit<BoxCssComponentProps, 'content' | 'onSelect'> {
4
+ export interface MenuProps extends Omit<BoxCssComponentProps, 'content' | 'onSelect' | 'minHeight' | 'maxHeight' | 'offsetX' | 'offsetY'> {
5
5
  itemIdentifier?: ItemIdentifier;
6
6
  content?: ReactNode;
7
7
  onSelect?: SelectOnSelect;
8
8
  closeOnSelect?: boolean;
9
+ offsetX?: number;
10
+ offsetY?: number;
11
+ minHeight?: number;
12
+ maxHeight?: number;
9
13
  placement?: MenuPlacement;
10
14
  }
11
15
  export interface MenuRef {
@@ -1,10 +1,2 @@
1
1
  export declare const COMPONENT_NAME = "Menu";
2
2
  export declare const EMPTY_CLIENT_RECT: DOMRect;
3
- export declare const MENU_DEFAULT_OPTIONS: {
4
- align: string;
5
- direction: null;
6
- limitWidth: string;
7
- maxHeight: number;
8
- minHeight: number;
9
- offset: number;
10
- };
@@ -1,46 +1,46 @@
1
1
  "use client";
2
- import { jsxs as m, jsx as c } from "@emotion/react/jsx-runtime";
3
- import { forwardRef as k, useState as u, useCallback as n, useEffect as $ } from "react";
4
- import { COMPONENT_NAME as t } from "./constants.js";
5
- import { SwitchWrapperStyled as g, SwitchLabelStyled as x, SwitchStyled as y, SwitchSliderStyled as N, HiddenCheckboxStyled as C } from "./SwitchStyled.js";
6
- import { LabelPosition as E } from "../../../types/label.js";
7
- import { useTheme as j } from "../../../hooks/useTheme/useTheme.js";
8
- import { get as I } from "../../../utils/helpers.js";
9
- const H = k((f, p) => {
2
+ import { jsxs as m, jsx as a } from "@emotion/react/jsx-runtime";
3
+ import { forwardRef as $, useState as g, useCallback as p, useEffect as x } from "react";
4
+ import { COMPONENT_NAME as r } from "./constants.js";
5
+ import { SwitchWrapperStyled as y, SwitchLabelStyled as C, SwitchStyled as N, SwitchSliderStyled as E, HiddenCheckboxStyled as j } from "./SwitchStyled.js";
6
+ import { LabelPosition as I } from "../../../types/label.js";
7
+ import { useTheme as L } from "../../../hooks/useTheme/useTheme.js";
8
+ import { get as M } from "../../../utils/helpers.js";
9
+ const W = $((S, b) => {
10
10
  const {
11
- onValueChange: d,
12
- checked: s = !1,
13
- disabled: r = !1,
14
- label: S = E.Right,
15
- children: b,
16
- ...i
17
- } = f, {
18
- theme: e
19
- } = j(), [l, o] = u(s), h = n((a) => {
20
- o(a), d == null || d(a);
21
- }, [d]), w = n((a) => {
22
- r || h(I(a, "target.checked", !1));
23
- }, [r, h]);
24
- return $(() => {
25
- o(s);
26
- }, [s]), /* @__PURE__ */ m(g, { theme: e, ref: p, $disabled: r, "data-testid": `${t}-wrapper`, ...i, children: [
27
- /* @__PURE__ */ c(x, { className: "gd-switch-label", theme: e, $label: S, "data-testid": `${t}-label`, children: b }),
28
- /* @__PURE__ */ m(y, { "data-testid": t, theme: e, children: [
29
- /* @__PURE__ */ c(N, { className: "gd-switch-slider", theme: e, $checked: l, "data-testid": `${t}-slider` }),
30
- /* @__PURE__ */ c(
31
- C,
11
+ onValueChange: c,
12
+ checked: e,
13
+ disabled: s = !1,
14
+ label: k = I.Right,
15
+ children: l,
16
+ ...o
17
+ } = S, {
18
+ theme: t
19
+ } = L(), d = e !== void 0, [u, h] = g(e ?? !1), n = d ? e : u, f = p((i) => {
20
+ d || h(i), c == null || c(i);
21
+ }, [c, d]), w = p((i) => {
22
+ s || f(M(i, "target.checked", !1));
23
+ }, [s, f]);
24
+ return x(() => {
25
+ d && h(e);
26
+ }, [e, d]), /* @__PURE__ */ m(y, { theme: t, ref: b, $disabled: s, "data-testid": `${r}-wrapper`, ...o, children: [
27
+ l && /* @__PURE__ */ a(C, { className: "gd-switch-label", theme: t, $label: k, "data-testid": `${r}-label`, children: l }),
28
+ /* @__PURE__ */ m(N, { "data-testid": r, theme: t, children: [
29
+ /* @__PURE__ */ a(E, { className: "gd-switch-slider", theme: t, $checked: n, "data-testid": `${r}-slider` }),
30
+ /* @__PURE__ */ a(
31
+ j,
32
32
  {
33
- theme: e,
34
- checked: l,
35
- disabled: r,
33
+ theme: t,
34
+ checked: n,
35
+ disabled: s,
36
36
  onChange: w,
37
- "data-testid": `${t}-checkbox`,
38
- ...i
37
+ "data-testid": `${r}-checkbox`,
38
+ ...o
39
39
  }
40
40
  )
41
41
  ] })
42
42
  ] });
43
43
  });
44
44
  export {
45
- H as Switch
45
+ W as Switch
46
46
  };