gd-design-library 1.0.2 → 1.2.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 (230) hide show
  1. package/README.md +2 -2
  2. package/ai/README.md +210 -16
  3. package/ai/schemas/components/Accordion.d.ts +84 -0
  4. package/ai/schemas/components/Button.d.ts +12 -0
  5. package/ai/schemas/components/ChatContainer.d.ts +0 -8
  6. package/ai/schemas/components/Column.d.ts +5 -5
  7. package/ai/schemas/components/InputFile.d.ts +17 -5
  8. package/ai/schemas/components/Menu.d.ts +37 -0
  9. package/ai/schemas/components/Row.d.ts +6 -6
  10. package/ai/schemas/components/Scroll.d.ts +7 -0
  11. package/ai/schemas/components/Typography.d.ts +0 -21
  12. package/assets/icons/account_circle.d.ts +1 -3
  13. package/assets/icons/account_circle.js +7 -14
  14. package/assets/icons/arrow-down.d.ts +2 -3
  15. package/assets/icons/arrow-down.js +6 -11
  16. package/assets/icons/arrow-forward.d.ts +1 -3
  17. package/assets/icons/arrow-forward.js +6 -13
  18. package/assets/icons/attachment.d.ts +1 -3
  19. package/assets/icons/attachment.js +7 -14
  20. package/assets/icons/check.d.ts +1 -3
  21. package/assets/icons/check.js +5 -11
  22. package/assets/icons/chevron-left.d.ts +1 -3
  23. package/assets/icons/chevron-left.js +7 -14
  24. package/assets/icons/chevron-right.d.ts +1 -3
  25. package/assets/icons/chevron-right.js +6 -13
  26. package/assets/icons/content-copy.d.ts +1 -3
  27. package/assets/icons/content-copy.js +7 -14
  28. package/assets/icons/delete_outlined.d.ts +1 -3
  29. package/assets/icons/delete_outlined.js +5 -12
  30. package/assets/icons/dot.d.ts +1 -3
  31. package/assets/icons/dot.js +5 -11
  32. package/assets/icons/error_outline.d.ts +1 -4
  33. package/assets/icons/error_outline.js +6 -18
  34. package/assets/icons/eye.d.ts +1 -3
  35. package/assets/icons/eye.js +7 -14
  36. package/assets/icons/file-copy.d.ts +1 -3
  37. package/assets/icons/file-copy.js +7 -13
  38. package/assets/icons/filter.d.ts +1 -3
  39. package/assets/icons/filter.js +6 -13
  40. package/assets/icons/folder.d.ts +1 -3
  41. package/assets/icons/folder.js +6 -13
  42. package/assets/icons/folderOpen.d.ts +1 -3
  43. package/assets/icons/folderOpen.js +7 -14
  44. package/assets/icons/home.d.ts +1 -3
  45. package/assets/icons/home.js +6 -13
  46. package/assets/icons/local_shipping.d.ts +1 -3
  47. package/assets/icons/local_shipping.js +4 -11
  48. package/assets/icons/minus.d.ts +1 -3
  49. package/assets/icons/minus.js +7 -13
  50. package/assets/icons/mobile_menu_button.d.ts +1 -3
  51. package/assets/icons/mobile_menu_button.js +7 -14
  52. package/assets/icons/paymentCard.d.ts +1 -3
  53. package/assets/icons/paymentCard.js +6 -13
  54. package/assets/icons/plus.d.ts +1 -3
  55. package/assets/icons/plus.js +5 -11
  56. package/assets/icons/portrait.d.ts +1 -3
  57. package/assets/icons/portrait.js +5 -12
  58. package/assets/icons/processing.d.ts +1 -3
  59. package/assets/icons/processing.js +6 -13
  60. package/assets/icons/ruler.d.ts +1 -3
  61. package/assets/icons/ruler.js +6 -13
  62. package/assets/icons/search.d.ts +1 -3
  63. package/assets/icons/search.js +6 -13
  64. package/assets/icons/shopping_bag.d.ts +1 -3
  65. package/assets/icons/shopping_bag.js +7 -14
  66. package/assets/icons/slash.d.ts +1 -3
  67. package/assets/icons/slash.js +6 -13
  68. package/assets/icons/star.d.ts +1 -3
  69. package/assets/icons/star.js +6 -12
  70. package/assets/icons/starOutlined.d.ts +1 -3
  71. package/assets/icons/starOutlined.js +5 -11
  72. package/assets/icons/toast_error.d.ts +1 -3
  73. package/assets/icons/toast_error.js +9 -15
  74. package/assets/icons/toast_info.d.ts +1 -3
  75. package/assets/icons/toast_info.js +7 -13
  76. package/assets/icons/toast_warning.d.ts +1 -3
  77. package/assets/icons/toast_warning.js +7 -13
  78. package/assets/icons/upload.d.ts +1 -3
  79. package/assets/icons/upload.js +6 -13
  80. package/assets/icons/volume-up.d.ts +1 -3
  81. package/assets/icons/volume-up.js +6 -13
  82. package/assets/icons/wifiTethering.d.ts +1 -3
  83. package/assets/icons/wifiTethering.js +4 -11
  84. package/components/core/Button/Button.js +30 -27
  85. package/components/core/Button/Button.types.d.ts +2 -2
  86. package/components/core/Button/ButtonStyled.js +40 -39
  87. package/components/core/Dropdown/Dropdown.d.ts +1 -1
  88. package/components/core/Dropdown/Dropdown.js +16 -16
  89. package/components/core/Dropdown/Dropdown.types.d.ts +3 -3
  90. package/components/core/Dropdown/DropdownStyled.js +13 -14
  91. package/components/core/Icon/Icon.js +41 -33
  92. package/components/core/Icon/Icon.types.d.ts +2 -1
  93. package/components/core/Icon/constants.d.ts +37 -109
  94. package/components/core/Input/Input.d.ts +1 -1
  95. package/components/core/InputFile/InputFile.d.ts +0 -32
  96. package/components/core/InputFile/InputFile.js +47 -33
  97. package/components/core/InputFile/InputFileStyled.js +24 -22
  98. package/components/core/Loader/Loader.js +19 -17
  99. package/components/core/Loader/Loader.types.d.ts +3 -1
  100. package/components/core/Loader/LoaderStyled.js +34 -30
  101. package/components/core/Menu/Menu.d.ts +2 -2
  102. package/components/core/Menu/Menu.js +113 -93
  103. package/components/core/Menu/Menu.types.d.ts +16 -11
  104. package/components/core/Menu/MenuStyled.d.ts +1 -1
  105. package/components/core/Menu/constants.js +4 -12
  106. package/components/core/Modal/Modal.js +60 -36
  107. package/components/core/Modal/ModalStyled.js +21 -22
  108. package/components/core/Scroll/Scroll.d.ts +6 -0
  109. package/components/core/Scroll/Scroll.js +53 -31
  110. package/components/core/Scroll/Scroll.types.d.ts +5 -0
  111. package/components/core/Scroll/ScrollBar.js +45 -43
  112. package/components/core/Scroll/ScrollStyled.js +46 -42
  113. package/components/core/Scroll/constants.d.ts +2 -0
  114. package/components/core/Scroll/constants.js +6 -4
  115. package/components/core/Select/Select.js +162 -134
  116. package/components/core/Select/Select.types.d.ts +2 -4
  117. package/components/core/Snackbar/Snackbar.js +60 -37
  118. package/components/core/Snackbar/Snackbar.types.d.ts +1 -2
  119. package/components/core/Snackbar/SnackbarManager.js +45 -30
  120. package/components/core/Snackbar/SnackbarStyled.d.ts +5 -5
  121. package/components/core/Snackbar/SnackbarStyled.js +111 -101
  122. package/components/core/Textarea/Textarea.d.ts +4 -0
  123. package/components/core/Tooltip/Tooltip.js +68 -44
  124. package/components/core/Tooltip/TooltipStyled.js +26 -27
  125. package/components/core/Tooltip/utils.js +47 -45
  126. package/components/core/Typography/Typography.js +18 -18
  127. package/components/core/Typography/Typography.types.d.ts +3 -3
  128. package/components/core/Typography/TypographyStyled.js +28 -29
  129. package/components/domainSpecific/Accordion/Accordion.d.ts +1 -1
  130. package/components/domainSpecific/Accordion/Accordion.js +19 -17
  131. package/components/domainSpecific/Accordion/Accordion.types.d.ts +7 -4
  132. package/components/domainSpecific/Accordion/AccordionContent/AccordionContent.d.ts +1 -1
  133. package/components/domainSpecific/Accordion/AccordionContent/AccordionContent.js +13 -12
  134. package/components/domainSpecific/Accordion/AccordionHeader/AccordionHeader.d.ts +1 -1
  135. package/components/domainSpecific/Accordion/AccordionHeader/AccordionHeader.js +15 -14
  136. package/components/domainSpecific/Accordion/AccordionItem/AccordionItem.d.ts +1 -1
  137. package/components/domainSpecific/Accordion/AccordionItem/AccordionItem.js +18 -16
  138. package/components/domainSpecific/Accordion/AccordionStyled.js +44 -35
  139. package/components/domainSpecific/Card/Card.js +31 -27
  140. package/components/domainSpecific/Card/CardTitle/constants.js +4 -4
  141. package/components/domainSpecific/Header/Header.js +4 -4
  142. package/components/domainSpecific/SearchModal/SearchModal.js +0 -1
  143. package/components/domainSpecific/SearchModal/SearchModal.types.d.ts +1 -1
  144. package/components/index.types.d.ts +1 -0
  145. package/components/layout/ChatContainer/ChatContainer.d.ts +1 -1
  146. package/components/layout/ChatContainer/ChatContainer.js +58 -41
  147. package/components/layout/ChatContainer/ChatContainer.types.d.ts +8 -5
  148. package/components/layout/ChatContainer/ChatContainerStyled.d.ts +2 -0
  149. package/components/layout/ChatContainer/ChatContainerStyled.js +105 -84
  150. package/components/layout/Column/Column.types.d.ts +3 -1
  151. package/components/layout/Column/ColumnStyled.js +23 -23
  152. package/components/layout/FlexContainer/FlexContainerStyled.js +7 -8
  153. package/components/layout/Row/Row.d.ts +1 -1
  154. package/components/layout/Row/Row.js +20 -20
  155. package/components/layout/Row/Row.types.d.ts +3 -1
  156. package/components/layout/Row/RowStyled.js +26 -26
  157. package/constants/index.d.ts +0 -1
  158. package/hooks/index.d.ts +1 -0
  159. package/hooks/useLogger/NoOpLogger.d.ts +11 -0
  160. package/hooks/useLogger/NoOpLogger.js +15 -0
  161. package/hooks/useLogger/index.d.ts +2 -0
  162. package/hooks/useLogger/useLogger.d.ts +4 -0
  163. package/hooks/useLogger/useLogger.js +27 -0
  164. package/hooks/useLogger/useLogger.types.d.ts +30 -0
  165. package/hooks/useTheme/NoOpTheme.d.ts +4050 -0
  166. package/hooks/useTheme/NoOpTheme.js +15 -0
  167. package/hooks/useTheme/useTheme.d.ts +3 -4
  168. package/hooks/useTheme/useTheme.js +62 -41
  169. package/hooks/useTheme/useTheme.types.d.ts +3 -2
  170. package/index.d.ts +4 -0
  171. package/index.js +354 -350
  172. package/llms.txt +39 -19
  173. package/package.json +1 -1
  174. package/tokens/accordion.d.ts +9 -3
  175. package/tokens/accordion.js +14 -11
  176. package/tokens/button.d.ts +17 -19
  177. package/tokens/button.js +54 -56
  178. package/tokens/card.d.ts +2 -3
  179. package/tokens/card.js +50 -53
  180. package/tokens/carousel.d.ts +2 -2
  181. package/tokens/carousel.js +8 -9
  182. package/tokens/chat.d.ts +69 -48
  183. package/tokens/chat.js +86 -68
  184. package/tokens/constants.d.ts +0 -1
  185. package/tokens/constants.js +1 -1
  186. package/tokens/defaultTheme.d.ts +199 -112
  187. package/tokens/defaultTheme.js +27 -25
  188. package/tokens/header.d.ts +1 -1
  189. package/tokens/header.js +3 -4
  190. package/tokens/index.d.ts +175 -104
  191. package/tokens/index.js +102 -101
  192. package/tokens/input.d.ts +2 -2
  193. package/tokens/input.js +25 -26
  194. package/tokens/inputfile.d.ts +1 -1
  195. package/tokens/inputfile.js +4 -4
  196. package/tokens/link.d.ts +5 -0
  197. package/tokens/loader.d.ts +3 -0
  198. package/tokens/loader.js +3 -0
  199. package/tokens/menu.d.ts +1 -0
  200. package/tokens/menu.js +1 -0
  201. package/tokens/modal.d.ts +6 -4
  202. package/tokens/modal.js +42 -60
  203. package/tokens/scroll.d.ts +19 -2
  204. package/tokens/scroll.js +23 -7
  205. package/tokens/select.d.ts +9 -7
  206. package/tokens/select.js +30 -29
  207. package/tokens/snackbar.d.ts +36 -20
  208. package/tokens/snackbar.js +92 -93
  209. package/tokens/stepper.d.ts +1 -1
  210. package/tokens/stepper.js +3 -3
  211. package/tokens/tabs.d.ts +1 -1
  212. package/tokens/tabs.js +1 -1
  213. package/tokens/textarea.d.ts +4 -0
  214. package/tokens/tooltip.d.ts +5 -1
  215. package/tokens/tooltip.js +23 -21
  216. package/tokens/typography.js +114 -116
  217. package/tokens/values.d.ts +5 -1
  218. package/tokens/values.js +12 -8
  219. package/tokens/wrapper.d.ts +2 -2
  220. package/tokens/wrapper.js +7 -7
  221. package/tokens/zIndex.d.ts +9 -0
  222. package/tokens/zIndex.js +12 -0
  223. package/types/index.d.ts +0 -1
  224. package/types/styles.d.ts +1 -0
  225. package/utils/helpers.js +14 -15
  226. package/CHANGELOG.md +0 -177
  227. package/constants/positioning.d.ts +0 -9
  228. package/constants/positioning.js +0 -11
  229. package/types/chat.d.ts +0 -5
  230. package/types/chat.js +0 -4
@@ -1,195 +1,223 @@
1
1
  "use client";
2
- import { jsx as l, jsxs as Y, Fragment as Ae } from "@emotion/react/jsx-runtime";
3
- import { forwardRef as Ie, useRef as x, useState as m, useEffect as E, useCallback as q, useImperativeHandle as ke, isValidElement as Le } from "react";
4
- import { KEYBOARD_KEYS as w } from "../../../constants/keyboard.js";
5
- import { DropdownItem as Oe } from "../DropdownItem/DropdownItem.js";
6
- import { Dropdown as We } from "../Dropdown/Dropdown.js";
7
- import { DEFAULT_SELECTED_VALUE as xe, COMPONENT_NAME as g } from "./constants.js";
8
- import { SelectWrapperStyled as Me, InitiatorWrapperStyled as Ce, DropdownButtonStyled as Ne, SelectAdornmentStyled as M, ArrowIconWrapperStyled as Be } from "./SelectStyled.js";
9
- import { getClosestFocusable as C } from "../../../utils/focus.js";
10
- import { get as G, toNumber as J } from "../../../utils/helpers.js";
2
+ import { jsx as a, jsxs as J, Fragment as Oe } from "@emotion/react/jsx-runtime";
3
+ import { forwardRef as $e, useRef as x, useState as w, useEffect as y, useCallback as Q, useImperativeHandle as ke, isValidElement as Ie } from "react";
4
+ import { KEYBOARD_KEYS as h } from "../../../constants/keyboard.js";
5
+ import { DropdownItem as Ce } from "../DropdownItem/DropdownItem.js";
6
+ import { Dropdown as Le } from "../Dropdown/Dropdown.js";
7
+ import { DEFAULT_SELECTED_VALUE as We, COMPONENT_NAME as s } from "./constants.js";
8
+ import { SelectWrapperStyled as xe, InitiatorWrapperStyled as Me, DropdownButtonStyled as Ne, SelectAdornmentStyled as M, ArrowIconWrapperStyled as Be } from "./SelectStyled.js";
9
+ import { getClosestFocusable as N } from "../../../utils/focus.js";
10
+ import { get as V, toNumber as X } from "../../../utils/helpers.js";
11
11
  import { useTheme as He } from "../../../hooks/useTheme/useTheme.js";
12
- import { SelectContext as Te } from "./hooks/useSelectContext.js";
13
- import { Icon as $e } from "../Icon/Icon.js";
14
- import { Portal as Pe } from "../Portal/Portal.js";
15
- const _e = Ie((Q, X) => {
12
+ import { useLogger as Te } from "../../../hooks/useLogger/useLogger.js";
13
+ import { SelectContext as Pe } from "./hooks/useSelectContext.js";
14
+ import { Icon as _e } from "../Icon/Icon.js";
15
+ import { Portal as Ke } from "../Portal/Portal.js";
16
+ const Fe = $e((Z, ee) => {
16
17
  const {
17
- onSelect: b,
18
- children: S,
19
- initiator: Z,
20
- onInitiatorClick: N,
21
- renderOption: B,
22
- emptyItemsResult: ee,
23
- autoOpen: te = !0,
24
- width: R = "100%",
25
- minWidth: H,
26
- maxWidth: T = "initial",
27
- styles: oe,
28
- activeIndex: A,
29
- value: I,
18
+ onSelect: R,
19
+ children: v,
20
+ initiator: te,
21
+ onInitiatorClick: B,
22
+ renderOption: H,
23
+ emptyItemsResult: oe,
24
+ autoOpen: re = !0,
25
+ width: A = "100%",
26
+ minWidth: T,
27
+ maxWidth: P = "initial",
28
+ styles: ne,
29
+ activeIndex: O,
30
+ value: $,
30
31
  onChange: k,
31
- placeholder: ne = xe,
32
- itemStringifier: re = (e) => G(e, "name", String(e)),
33
- itemIdentifier: ie = (e, t) => (e == null ? void 0 : e.value) === (t == null ? void 0 : t.value),
34
- disabled: o = !1,
35
- items: u,
36
- adornmentStart: $,
37
- adornmentEnd: P,
38
- dropdownMaxHeight: L = "240px"
39
- } = Q, {
40
- theme: a
41
- } = He(), i = x(null), O = x(null), y = x(null), [s, d] = m(!1), [f, _] = m(I), [se, ce] = m(R), [le, de] = m("bottom"), [ae, me] = m(L), [pe, ue] = m(-9999), [fe, K] = m(void 0), [we, F] = m(void 0), he = 1;
42
- E(() => {
43
- if (s && (y.current || i.current)) {
44
- const e = y.current || i.current;
45
- ce(`${e.getBoundingClientRect().width}px`);
32
+ placeholder: I = We,
33
+ itemStringifier: ie = (e) => V(e, "name", String(e)),
34
+ itemIdentifier: se = (e, t) => (e == null ? void 0 : e.value) === (t == null ? void 0 : t.value),
35
+ disabled: r = !1,
36
+ items: p,
37
+ adornmentStart: _,
38
+ adornmentEnd: K,
39
+ dropdownMaxHeight: C = "240px"
40
+ } = Z, {
41
+ theme: m
42
+ } = He(), f = Te(), c = x(null), L = x(null), D = x(null), [l, u] = w(!1), [o, F] = w($), [ce, le] = w(A), [de, ae] = w("bottom"), [pe, ue] = w(C), [me, fe] = w(-9999), [we, U] = w(void 0), [ge, z] = w(void 0), he = 1;
43
+ y(() => {
44
+ if (l && (f.debug(`${s}: Open`, {
45
+ trigger: "programmatic",
46
+ hasItems: !!(p != null && p.length || v),
47
+ placeholder: I,
48
+ currentValue: o == null ? void 0 : o.value
49
+ }), D.current || c.current)) {
50
+ const e = D.current || c.current;
51
+ le(`${e.getBoundingClientRect().width}px`);
46
52
  }
47
- }, [s, R]);
48
- const D = q(() => {
49
- const e = y.current || i.current;
53
+ }, [l, A, p, v, I, o]);
54
+ const S = Q(() => {
55
+ const e = D.current || c.current;
50
56
  if (!e) return;
51
- const t = e.getBoundingClientRect(), r = window.innerHeight || document.documentElement.clientHeight, c = r - t.bottom, n = t.top, h = parseFloat(String(L)), p = he, z = c >= h + p, j = n >= h + p;
52
- let v = "bottom";
53
- !z && j ? v = "top" : !z && !j && (v = c >= n ? "bottom" : "top"), de(v);
54
- const Se = (v === "bottom" ? c : n) - p, Re = Math.max(0, Math.min(h, Se));
55
- me(`${Math.floor(Re)}px`), ue(Math.floor(t.left)), v === "bottom" ? (K(Math.floor(t.bottom + p)), F(void 0)) : (K(void 0), F(Math.floor(r - t.top + p)));
56
- }, [L]);
57
- E(() => {
58
- if (!s) return;
59
- D();
60
- const e = () => D(), t = () => D();
57
+ const t = e.getBoundingClientRect(), i = window.innerHeight || document.documentElement.clientHeight, d = i - t.bottom, n = t.top, b = parseFloat(String(C)), g = he, q = d >= b + g, G = n >= b + g;
58
+ let E = "bottom";
59
+ !q && G ? E = "top" : !q && !G && (E = d >= n ? "bottom" : "top"), ae(E);
60
+ const Re = (E === "bottom" ? d : n) - g, Ae = Math.max(0, Math.min(b, Re));
61
+ ue(`${Math.floor(Ae)}px`), fe(Math.floor(t.left)), E === "bottom" ? (U(Math.floor(t.bottom + g)), z(void 0)) : (U(void 0), z(Math.floor(i - t.top + g)));
62
+ }, [C]);
63
+ y(() => {
64
+ if (!l) return;
65
+ S();
66
+ const e = () => S(), t = () => S();
61
67
  return window.addEventListener("resize", e), window.addEventListener("scroll", t, !0), () => {
62
68
  window.removeEventListener("resize", e), window.removeEventListener("scroll", t, !0);
63
69
  };
64
- }, [s, D]);
65
- const W = q(() => {
66
- if (i.current && !o) {
67
- const e = C({
68
- initial: i.current,
69
- root: i.current,
70
+ }, [l, S]);
71
+ const W = Q(() => {
72
+ if (c.current && !r) {
73
+ const e = N({
74
+ initial: c.current,
75
+ root: c.current,
70
76
  keyboard: !0
71
77
  });
72
78
  e == null || e.focus();
73
79
  }
74
- }, [o]), ve = () => u != null && u.length ? be() : ee, U = ({
80
+ }, [r]), ve = () => p != null && p.length ? Se() : oe, j = ({
75
81
  event: e,
76
82
  data: t
77
83
  }) => {
78
- o || (e.preventDefault(), _(t), k == null || k(t), b == null || b({
84
+ r || (e.preventDefault(), f.debug(`${s}: Select`, {
85
+ value: t == null ? void 0 : t.value,
86
+ name: t == null ? void 0 : t.name,
87
+ previousValue: o == null ? void 0 : o.value,
88
+ previousName: o == null ? void 0 : o.name
89
+ }), F(t), k == null || k(t), R == null || R({
79
90
  event: e,
80
91
  data: t
81
- }), d(!1), setTimeout(() => {
92
+ }), u(!1), setTimeout(() => {
82
93
  W();
83
94
  }));
84
- }, Ee = {
85
- onSelect: U,
86
- value: f,
87
- itemIdentifier: ie
88
- }, ge = (e) => {
89
- if (!(o || ![w.ARROW_DOWN, w.ARROW_UP].includes(e.key)))
95
+ }, be = {
96
+ onSelect: j,
97
+ value: o,
98
+ itemIdentifier: se
99
+ }, Ee = (e) => {
100
+ if (!(r || ![h.ARROW_DOWN, h.ARROW_UP].includes(e.key)))
90
101
  switch (e.preventDefault(), e.key) {
91
- case w.ARROW_DOWN:
92
- V(e, !1);
102
+ case h.ARROW_DOWN:
103
+ Y(e, !1);
93
104
  break;
94
- case w.ARROW_UP:
95
- V(e, !0);
105
+ case h.ARROW_UP:
106
+ Y(e, !0);
96
107
  break;
97
108
  }
98
- }, V = (e, t) => {
99
- if (o)
109
+ }, Y = (e, t) => {
110
+ if (r)
100
111
  return;
101
112
  e.preventDefault();
102
- const r = O.current;
103
- if (!r) {
104
- d(!0);
113
+ const i = L.current;
114
+ if (!i) {
115
+ f.debug(`${s}: Open`, {
116
+ trigger: "arrow",
117
+ direction: t ? "up" : "down"
118
+ }), u(!0);
105
119
  return;
106
120
  }
107
- const c = t ? r.appendChild(document.createElement("div")) : r, n = C({
108
- initial: c,
121
+ f.debug(`${s}: Arrow navigation`, {
122
+ direction: t ? "up" : "down"
123
+ });
124
+ const d = t ? i.appendChild(document.createElement("div")) : i, n = N({
125
+ initial: d,
109
126
  previous: t,
110
- root: r
127
+ root: i
111
128
  });
112
129
  n == null || n.focus();
113
130
  }, ye = () => {
114
- !o && te && d(!s);
131
+ if (!r && re) {
132
+ const e = !l;
133
+ f.debug(`${s}: ${e ? "Open" : "Close"}`, {
134
+ trigger: "click"
135
+ }), u(e);
136
+ }
115
137
  }, De = (e) => {
116
- o || (N ? N(e) : ye());
117
- }, be = () => /* @__PURE__ */ l(Ae, { children: u == null ? void 0 : u.map((e, t) => B ? B({
138
+ r || (B ? B(e) : ye());
139
+ }, Se = () => /* @__PURE__ */ a(Oe, { children: p == null ? void 0 : p.map((e, t) => H ? H({
118
140
  item: e,
119
141
  index: t,
120
- isActiveItem: A == t,
121
- className: J(A) === t ? "active" : ""
122
- }) : /* @__PURE__ */ l(Oe, { value: e.value, name: e.name, className: `${J(A) === t ? "active" : ""}` }, `dropdown-item-${e.value}-${t}`)) });
123
- return E(() => {
124
- _(I);
125
- }, [I]), E(() => {
126
- if (!s) return;
142
+ isActiveItem: O == t,
143
+ className: X(O) === t ? "active" : ""
144
+ }) : /* @__PURE__ */ a(Ce, { value: e.value, name: e.name, className: `${X(O) === t ? "active" : ""}` }, `dropdown-item-${e.value}-${t}`)) });
145
+ return y(() => {
146
+ F($);
147
+ }, [$]), y(() => {
148
+ if (!l) return;
127
149
  const e = (t) => {
128
- const r = t.target, c = i.current, n = O.current, h = !!c && c.contains(r), p = !!n && n.contains(r);
129
- !h && !p && d(!1);
150
+ const i = t.target, d = c.current, n = L.current, b = !!d && d.contains(i), g = !!n && n.contains(i);
151
+ !b && !g && (f.debug(`${s}: Close`, {
152
+ trigger: "outsideClick"
153
+ }), u(!1));
130
154
  };
131
155
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
132
- }, [s]), E(() => {
156
+ }, [l]), y(() => {
133
157
  const e = (t) => {
134
- var r;
135
- if (!(!s || o)) {
136
- if (t.key === w.ESCAPE)
137
- t.preventDefault(), d(!1), W();
138
- else if (t.key === w.TAB && (t.preventDefault(), d(!1), i.current)) {
139
- const c = document.createElement("div");
140
- (r = i.current.parentNode) == null || r.insertBefore(c, i.current.nextSibling);
141
- const n = C({
142
- initial: c,
158
+ var i;
159
+ if (!(!l || r)) {
160
+ if (t.key === h.ESCAPE)
161
+ t.preventDefault(), f.debug(`${s}: Close`, {
162
+ trigger: "escape"
163
+ }), u(!1), W();
164
+ else if (t.key === h.TAB && (t.preventDefault(), f.debug(`${s}: Close`, {
165
+ trigger: "tab"
166
+ }), u(!1), c.current)) {
167
+ const d = document.createElement("div");
168
+ (i = c.current.parentNode) == null || i.insertBefore(d, c.current.nextSibling);
169
+ const n = N({
170
+ initial: d,
143
171
  root: document.body,
144
172
  keyboard: !0
145
173
  });
146
- c.remove(), n == null || n.focus();
174
+ d.remove(), n == null || n.focus();
147
175
  }
148
176
  }
149
177
  };
150
178
  return document.addEventListener("keydown", e), () => {
151
179
  document.removeEventListener("keydown", e);
152
180
  };
153
- }, [s, o, W]), ke(X, () => ({
154
- ref: i,
155
- isOpen: s,
156
- selectedValue: f,
157
- onSelect: U,
181
+ }, [l, r, W]), ke(ee, () => ({
182
+ ref: c,
183
+ isOpen: l,
184
+ selectedValue: o,
185
+ onSelect: j,
158
186
  open: () => {
159
- o || d(!0);
187
+ r || u(!0);
160
188
  },
161
- close: () => d(!1),
189
+ close: () => u(!1),
162
190
  toggle: () => {
163
- o || d((e) => !e);
191
+ r || u((e) => !e);
164
192
  }
165
- })), /* @__PURE__ */ l(Te.Provider, { value: Ee, children: /* @__PURE__ */ Y(Me, { ref: i, theme: a, "data-testid": g, styles: {
166
- ...oe,
167
- width: R,
168
- maxWidth: T,
169
- minWidth: H
170
- }, $disabled: o, children: [
171
- /* @__PURE__ */ l(Ce, { ref: y, theme: a, onClick: De, onKeyDown: ge, "data-testid": `${g}-initiator-wrapper`, children: Z ?? /* @__PURE__ */ l(Ne, { theme: a, disabled: o, iconStart: $ && /* @__PURE__ */ l(M, { theme: a, children: $ }), iconEnd: /* @__PURE__ */ Y(M, { theme: a, children: [
172
- P && /* @__PURE__ */ l(M, { theme: a, children: P }),
173
- /* @__PURE__ */ l(Be, { theme: a, $isOpen: s, children: /* @__PURE__ */ l($e, { ...G(a, "select.arrowIcon", {
193
+ })), /* @__PURE__ */ a(Pe.Provider, { value: be, children: /* @__PURE__ */ J(xe, { ref: c, theme: m, "data-testid": s, styles: {
194
+ ...ne,
195
+ width: A,
196
+ maxWidth: P,
197
+ minWidth: T
198
+ }, $disabled: r, children: [
199
+ /* @__PURE__ */ a(Me, { ref: D, theme: m, onClick: De, onKeyDown: Ee, "data-testid": `${s}-initiator-wrapper`, children: te ?? /* @__PURE__ */ a(Ne, { theme: m, disabled: r, iconStart: _ && /* @__PURE__ */ a(M, { theme: m, children: _ }), iconEnd: /* @__PURE__ */ J(M, { theme: m, children: [
200
+ K && /* @__PURE__ */ a(M, { theme: m, children: K }),
201
+ /* @__PURE__ */ a(Be, { theme: m, $isOpen: l, children: /* @__PURE__ */ a(_e, { ...V(m, "select.icons.arrowIcon", {
174
202
  name: "arrowDown"
175
203
  }) }) })
176
- ] }), "data-testid": `${g}-initiator`, children: f != null && f.value ? re(f) : ne }) }),
177
- s && !o && /* @__PURE__ */ l(Pe, { withWrapper: !1, blocksScroll: !0, children: /* @__PURE__ */ l(We, { "data-testid": `${g}-dropdown`, styles: {
204
+ ] }), "data-testid": `${s}-initiator`, children: o != null && o.value ? ie(o) : I }) }),
205
+ l && !r && /* @__PURE__ */ a(Ke, { withWrapper: !1, blocksScroll: !0, children: /* @__PURE__ */ a(Le, { "data-testid": `${s}-dropdown`, styles: {
178
206
  position: "fixed",
179
- width: se,
180
- maxWidth: T,
181
- minWidth: H,
182
- maxHeight: ae,
183
- left: pe,
184
- ...le === "bottom" ? {
185
- top: fe
207
+ width: ce,
208
+ maxWidth: P,
209
+ minWidth: T,
210
+ maxHeight: pe,
211
+ left: me,
212
+ ...de === "bottom" ? {
213
+ top: we
186
214
  } : {
187
- bottom: we
215
+ bottom: ge
188
216
  }
189
- }, ref: O, children: Array.isArray(S) || Le(S) ? S : ve() }) })
217
+ }, ref: L, children: Array.isArray(v) || Ie(v) ? v : ve() }) })
190
218
  ] }) });
191
219
  });
192
- _e.displayName = g;
220
+ Fe.displayName = s;
193
221
  export {
194
- _e as Select
222
+ Fe as Select
195
223
  };
@@ -1,7 +1,6 @@
1
1
  import { PropsWithChildren, ReactNode, MouseEvent, ReactEventHandler, Ref } from 'react';
2
2
  import { Theme } from '../../../hooks/useTheme';
3
- import { ButtonProps, CommonCssComponentProps, CommonCssComponentStyledProps } from '../..';
4
- import { OnSelectProps } from '../types/index.types';
3
+ import { ButtonProps, CommonCssComponentProps, CommonCssComponentStyledProps, OnSelectProps } from '../..';
5
4
  export type ItemIdentifier = (selected: Option | null, current: Option) => boolean;
6
5
  export type SelectOnSelect = (props: OnSelectProps) => void;
7
6
  export interface Option<V = unknown> {
@@ -46,10 +45,9 @@ export interface SelectRef {
46
45
  onSelect: SelectOnSelect;
47
46
  open: () => void;
48
47
  close: () => void;
49
- toggle: () => void;
50
48
  }
51
49
  export interface SelectContextType {
52
- onSelect?: SelectOnSelect;
50
+ onSelect: SelectOnSelect;
53
51
  value?: Option | null;
54
52
  itemIdentifier?: ItemIdentifier;
55
53
  }
@@ -1,48 +1,71 @@
1
1
  "use client";
2
- import { jsxs as a, jsx as t } from "@emotion/react/jsx-runtime";
3
- import { forwardRef as T, useState as b, useCallback as A, useEffect as I } from "react";
4
- import { DEFAULT_VARIANT as N, ANIMATION_DURATION as v, COMPONENT_NAME as O } from "./constants.js";
5
- import { SnackbarStyled as $, CloseButtonWrapperStyled as g, CloseButtonIconStyled as x, SnackbarBodyStyled as B, SnackbarIconStyled as E, SnackbarContentStyled as D, SnackbarTitleStyled as M, SnackbarDescriptionStyled as R, SnackbarActionsContainerStyled as _ } from "./SnackbarStyled.js";
6
- import { useTheme as j } from "../../../hooks/useTheme/useTheme.js";
2
+ import { jsxs as S, jsx as l } from "@emotion/react/jsx-runtime";
3
+ import { forwardRef as I, useState as N, useCallback as h, useEffect as p } from "react";
4
+ import { COMPONENT_NAME as s, DEFAULT_VARIANT as x, ANIMATION_DURATION as B } from "./constants.js";
5
+ import { SnackbarStyled as E, CloseButtonWrapperStyled as D, CloseButtonIconStyled as M, SnackbarBodyStyled as R, SnackbarIconStyled as _, SnackbarContentStyled as j, SnackbarTitleStyled as L, SnackbarDescriptionStyled as O, SnackbarActionsContainerStyled as U } from "./SnackbarStyled.js";
6
+ import { useTheme as w } from "../../../hooks/useTheme/useTheme.js";
7
+ import { useLogger as F } from "../../../hooks/useLogger/useLogger.js";
7
8
  import { convertToInlineBoxStyles as P } from "../../../tokens/utils.js";
8
- const q = T((m, S) => {
9
+ const K = I(({
10
+ title: c,
11
+ message: f,
12
+ variant: e = x,
13
+ isAnimated: u = !0,
14
+ duration: n,
15
+ onClose: o,
16
+ action: i,
17
+ colored: k = !1,
18
+ dismissOnClick: a = !0,
19
+ icon: y,
20
+ position: t,
21
+ ...T
22
+ }, g) => {
9
23
  const {
10
- title: u,
11
- message: l,
12
- variant: s = N,
13
- isAnimated: i = !0,
14
- duration: n,
15
- onClose: r,
16
- action: c,
17
- colored: f = !1,
18
- dismissOnClick: C = !0,
19
- icon: k,
20
- ...p
21
- } = m, {
22
- theme: e
23
- } = j(), [d, h] = b(!1), o = A(() => {
24
- h(!0), setTimeout(() => {
25
- r == null || r();
26
- }, i ? v : 0);
27
- }, [i, r]);
28
- return I(() => {
24
+ theme: r
25
+ } = w(), m = F(), [b, A] = N(!1), d = h(() => {
26
+ m.debug(`${s}: Close`, {
27
+ variant: e,
28
+ position: t,
29
+ title: c,
30
+ hasAction: !!i
31
+ }), A(!0), setTimeout(() => {
32
+ o == null || o();
33
+ }, u ? B : 0);
34
+ }, [u, o, e, t, c, i]);
35
+ p(() => {
29
36
  if (!n) return;
30
- const y = setTimeout(() => {
31
- o();
37
+ m.debug(`${s}: Auto-dismiss timer started`, {
38
+ duration: n,
39
+ variant: e,
40
+ position: t
41
+ });
42
+ const C = setTimeout(() => {
43
+ m.debug(`${s}: Auto-dismiss timer fired`, {
44
+ variant: e,
45
+ position: t
46
+ }), d();
32
47
  }, n);
33
- return () => clearTimeout(y);
34
- }, [n]), /* @__PURE__ */ a($, { ref: S, $variant: s, $colored: f, $isClosing: d, $isAnimated: i, onClick: C ? o : void 0, theme: e, role: "alert", "aria-live": "polite", "aria-hidden": d, "data-testid": O, ...P(p), children: [
35
- r && /* @__PURE__ */ t(g, { theme: e, onClick: o, "aria-label": "Close notification", children: /* @__PURE__ */ t(x, { theme: e }) }),
36
- /* @__PURE__ */ a(B, { theme: e, children: [
37
- k || /* @__PURE__ */ t(E, { theme: e, $variant: s }),
38
- /* @__PURE__ */ a(D, { theme: e, children: [
39
- /* @__PURE__ */ t(M, { children: u }),
40
- l && /* @__PURE__ */ t(R, { children: l }),
41
- c && /* @__PURE__ */ t(_, { theme: e, children: c })
48
+ return () => clearTimeout(C);
49
+ }, [n, d, e, t]);
50
+ const $ = h(() => {
51
+ a && (m.debug(`${s}: Click (dismiss)`, {
52
+ variant: e,
53
+ position: t,
54
+ title: c
55
+ }), d());
56
+ }, [a, d, e, t, c]);
57
+ return /* @__PURE__ */ S(E, { ref: g, $variant: e, $colored: k, $isClosing: b, $isAnimated: u, onClick: a ? $ : void 0, theme: r, role: "alert", "aria-live": "polite", "aria-hidden": b, "data-testid": s, ...P(T), children: [
58
+ o && /* @__PURE__ */ l(D, { theme: r, onClick: d, "aria-label": "Close notification", children: /* @__PURE__ */ l(M, { theme: r, $variant: e }) }),
59
+ /* @__PURE__ */ S(R, { theme: r, children: [
60
+ y || /* @__PURE__ */ l(_, { theme: r, $variant: e }),
61
+ /* @__PURE__ */ S(j, { theme: r, children: [
62
+ /* @__PURE__ */ l(L, { theme: r, children: c }),
63
+ f && /* @__PURE__ */ l(O, { theme: r, children: f }),
64
+ i && /* @__PURE__ */ l(U, { theme: r, children: i })
42
65
  ] })
43
66
  ] })
44
67
  ] });
45
68
  });
46
69
  export {
47
- q as Snackbar
70
+ K as Snackbar
48
71
  };
@@ -1,6 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { BoxCssComponentProps, BoxCssComponentStyledProps, CommonCssComponentStyledProps } from '../../index.types';
3
- import { IconProps } from '../Icon';
4
3
  import { EnumOrPrimitive, SnackbarPosition, SnackbarVariant } from '../../../types';
5
4
  export interface SnackbarOptions {
6
5
  title?: ReactNode;
@@ -28,7 +27,7 @@ export interface SnackbarStyledProps extends BoxCssComponentStyledProps {
28
27
  $colored: boolean;
29
28
  }
30
29
  export type SnackbarCommonStyledProps = CommonCssComponentStyledProps;
31
- export interface SnackbarIconProps extends Partial<Omit<IconProps, 'onClick'>>, CommonCssComponentStyledProps {
30
+ export interface SnackbarIconProps extends CommonCssComponentStyledProps {
32
31
  $variant: EnumOrPrimitive<SnackbarVariant>;
33
32
  }
34
33
  export interface SnackbarContainerStyledProps extends CommonCssComponentStyledProps {
@@ -1,48 +1,63 @@
1
1
  "use client";
2
2
  import { jsx as m } from "@emotion/react/jsx-runtime";
3
- import { useState as a, useEffect as l, useMemo as S } from "react";
3
+ import { useState as S, useEffect as g, useMemo as h } from "react";
4
4
  import { v4 as A } from "uuid";
5
- import { SnackbarContainerStyled as h } from "./SnackbarStyled.js";
6
- import { Snackbar as E } from "./Snackbar.js";
7
- import { DEFAULT_DURATION as N, DEFAULT_POSITION as p, DEFAULT_VARIANT as T, COMPONENT_SNACKBAR_MANAGER_NAME as b } from "./constants.js";
8
- import { get as O } from "../../../utils/helpers.js";
9
- import { useTheme as _ } from "../../../hooks/useTheme/useTheme.js";
5
+ import { SnackbarContainerStyled as E } from "./SnackbarStyled.js";
6
+ import { Snackbar as N } from "./Snackbar.js";
7
+ import { DEFAULT_DURATION as T, DEFAULT_POSITION as a, DEFAULT_VARIANT as b, COMPONENT_SNACKBAR_MANAGER_NAME as u } from "./constants.js";
8
+ import { get as v } from "../../../utils/helpers.js";
9
+ import { useTheme as O } from "../../../hooks/useTheme/useTheme.js";
10
+ import { useLogger as _ } from "../../../hooks/useLogger/useLogger.js";
10
11
  import { Portal as C } from "../Portal/Portal.js";
11
12
  let i = [];
12
- const s = [], d = () => {
13
- s.forEach((e) => e(i));
13
+ const c = [], d = () => {
14
+ c.forEach((e) => e(i));
14
15
  }, M = (e) => {
15
- const c = {
16
- id: O(e, "id", A()),
17
- variant: T,
18
- position: p,
19
- duration: N,
16
+ const s = {
17
+ id: v(e, "id", A()),
18
+ variant: b,
19
+ position: a,
20
+ duration: T,
20
21
  ...e
21
22
  };
22
- i = [...i, c].slice(-50), d();
23
- }, g = (e) => {
23
+ i = [...i, s].slice(-50), d();
24
+ }, x = (e) => {
24
25
  i = i.filter((n) => n.id !== e), d();
25
- }, v = (e) => M(e), y = () => {
26
+ }, q = (e) => M(e), B = () => {
26
27
  const {
27
28
  theme: e
28
- } = _(), [n, c] = a(i);
29
- l(() => {
30
- const r = (o) => c(o);
31
- return s.push(r), () => {
32
- const o = s.indexOf(r);
33
- o > -1 && s.splice(o, 1);
29
+ } = O(), n = _(), [s, l] = S(i);
30
+ g(() => {
31
+ const r = (o) => {
32
+ n.debug(`${u}: Snackbar queue updated`, {
33
+ count: o.length,
34
+ snackbars: o.map((t) => ({
35
+ id: t.id,
36
+ variant: t.variant,
37
+ position: t.position,
38
+ title: t.title
39
+ }))
40
+ }), l(o);
41
+ };
42
+ return c.push(r), () => {
43
+ const o = c.indexOf(r);
44
+ o > -1 && c.splice(o, 1);
34
45
  };
35
46
  }, []);
36
- const f = S(() => n.reduce((r, o) => {
37
- const t = o.position || p;
47
+ const f = h(() => s.reduce((r, o) => {
48
+ const t = o.position || a;
38
49
  return r[t] = r[t] || [], r[t].push(o), r;
39
- }, {}), [n]);
40
- return n.length ? /* @__PURE__ */ m(C, { withWrapper: !1, "data-testid": b, children: Object.entries(f).map(([r, o]) => /* @__PURE__ */ m(h, { theme: e, $position: r, children: o.map((t) => /* @__PURE__ */ m(E, { ...t, onClose: () => {
41
- var u;
42
- (u = t.onClose) == null || u.call(t), g(t.id);
50
+ }, {}), [s]);
51
+ return s.length ? /* @__PURE__ */ m(C, { withWrapper: !1, "data-testid": u, children: Object.entries(f).map(([r, o]) => /* @__PURE__ */ m(E, { theme: e, $position: r, children: o.map((t) => /* @__PURE__ */ m(N, { ...t, onClose: () => {
52
+ var p;
53
+ n.debug(`${u}: Snackbar closed via manager`, {
54
+ id: t.id,
55
+ variant: t.variant,
56
+ position: t.position
57
+ }), (p = t.onClose) == null || p.call(t), x(t.id);
43
58
  } }, t.id)) }, r)) }) : null;
44
59
  };
45
60
  export {
46
- y as SnackbarManager,
47
- v as showSnackbar
61
+ B as SnackbarManager,
62
+ q as showSnackbar
48
63
  };
@@ -1,12 +1,12 @@
1
- import { PropsWithChildren } from 'react';
2
- import { SnackbarCommonStyledProps, SnackbarContainerStyledProps, SnackbarIconProps, SnackbarStyledProps } from './Snackbar.types';
1
+ import { CommonCssComponentStyledProps } from '../..';
2
+ import { SnackbarCommonStyledProps, SnackbarContainerStyledProps, SnackbarIconProps, SnackbarStyledProps } from './';
3
3
  export declare const SnackbarStyled: import('react').ForwardRefExoticComponent<Omit<SnackbarStyledProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
4
4
  export declare const CloseButtonWrapperStyled: (props: SnackbarCommonStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;
5
- export declare const CloseButtonIconStyled: (props: SnackbarCommonStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ export declare const CloseButtonIconStyled: (props: SnackbarIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
6
6
  export declare const SnackbarIconStyled: (props: SnackbarIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
7
7
  export declare const SnackbarBodyStyled: (props: SnackbarCommonStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;
8
8
  export declare const SnackbarContentStyled: (props: SnackbarCommonStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;
9
- export declare const SnackbarTitleStyled: (props: PropsWithChildren) => import("@emotion/react/jsx-runtime").JSX.Element;
10
- export declare const SnackbarDescriptionStyled: (props: PropsWithChildren) => import("@emotion/react/jsx-runtime").JSX.Element;
9
+ export declare const SnackbarTitleStyled: (props: CommonCssComponentStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export declare const SnackbarDescriptionStyled: (props: CommonCssComponentStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;
11
11
  export declare const SnackbarActionsContainerStyled: (props: SnackbarCommonStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;
12
12
  export declare const SnackbarContainerStyled: (props: SnackbarContainerStyledProps) => import("@emotion/react/jsx-runtime").JSX.Element;