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.
- package/README.md +2 -2
- package/ai/README.md +210 -16
- package/ai/schemas/components/Accordion.d.ts +84 -0
- package/ai/schemas/components/Button.d.ts +12 -0
- package/ai/schemas/components/ChatContainer.d.ts +0 -8
- package/ai/schemas/components/Column.d.ts +5 -5
- package/ai/schemas/components/InputFile.d.ts +17 -5
- package/ai/schemas/components/Menu.d.ts +37 -0
- package/ai/schemas/components/Row.d.ts +6 -6
- package/ai/schemas/components/Scroll.d.ts +7 -0
- package/ai/schemas/components/Typography.d.ts +0 -21
- package/assets/icons/account_circle.d.ts +1 -3
- package/assets/icons/account_circle.js +7 -14
- package/assets/icons/arrow-down.d.ts +2 -3
- package/assets/icons/arrow-down.js +6 -11
- package/assets/icons/arrow-forward.d.ts +1 -3
- package/assets/icons/arrow-forward.js +6 -13
- package/assets/icons/attachment.d.ts +1 -3
- package/assets/icons/attachment.js +7 -14
- package/assets/icons/check.d.ts +1 -3
- package/assets/icons/check.js +5 -11
- package/assets/icons/chevron-left.d.ts +1 -3
- package/assets/icons/chevron-left.js +7 -14
- package/assets/icons/chevron-right.d.ts +1 -3
- package/assets/icons/chevron-right.js +6 -13
- package/assets/icons/content-copy.d.ts +1 -3
- package/assets/icons/content-copy.js +7 -14
- package/assets/icons/delete_outlined.d.ts +1 -3
- package/assets/icons/delete_outlined.js +5 -12
- package/assets/icons/dot.d.ts +1 -3
- package/assets/icons/dot.js +5 -11
- package/assets/icons/error_outline.d.ts +1 -4
- package/assets/icons/error_outline.js +6 -18
- package/assets/icons/eye.d.ts +1 -3
- package/assets/icons/eye.js +7 -14
- package/assets/icons/file-copy.d.ts +1 -3
- package/assets/icons/file-copy.js +7 -13
- package/assets/icons/filter.d.ts +1 -3
- package/assets/icons/filter.js +6 -13
- package/assets/icons/folder.d.ts +1 -3
- package/assets/icons/folder.js +6 -13
- package/assets/icons/folderOpen.d.ts +1 -3
- package/assets/icons/folderOpen.js +7 -14
- package/assets/icons/home.d.ts +1 -3
- package/assets/icons/home.js +6 -13
- package/assets/icons/local_shipping.d.ts +1 -3
- package/assets/icons/local_shipping.js +4 -11
- package/assets/icons/minus.d.ts +1 -3
- package/assets/icons/minus.js +7 -13
- package/assets/icons/mobile_menu_button.d.ts +1 -3
- package/assets/icons/mobile_menu_button.js +7 -14
- package/assets/icons/paymentCard.d.ts +1 -3
- package/assets/icons/paymentCard.js +6 -13
- package/assets/icons/plus.d.ts +1 -3
- package/assets/icons/plus.js +5 -11
- package/assets/icons/portrait.d.ts +1 -3
- package/assets/icons/portrait.js +5 -12
- package/assets/icons/processing.d.ts +1 -3
- package/assets/icons/processing.js +6 -13
- package/assets/icons/ruler.d.ts +1 -3
- package/assets/icons/ruler.js +6 -13
- package/assets/icons/search.d.ts +1 -3
- package/assets/icons/search.js +6 -13
- package/assets/icons/shopping_bag.d.ts +1 -3
- package/assets/icons/shopping_bag.js +7 -14
- package/assets/icons/slash.d.ts +1 -3
- package/assets/icons/slash.js +6 -13
- package/assets/icons/star.d.ts +1 -3
- package/assets/icons/star.js +6 -12
- package/assets/icons/starOutlined.d.ts +1 -3
- package/assets/icons/starOutlined.js +5 -11
- package/assets/icons/toast_error.d.ts +1 -3
- package/assets/icons/toast_error.js +9 -15
- package/assets/icons/toast_info.d.ts +1 -3
- package/assets/icons/toast_info.js +7 -13
- package/assets/icons/toast_warning.d.ts +1 -3
- package/assets/icons/toast_warning.js +7 -13
- package/assets/icons/upload.d.ts +1 -3
- package/assets/icons/upload.js +6 -13
- package/assets/icons/volume-up.d.ts +1 -3
- package/assets/icons/volume-up.js +6 -13
- package/assets/icons/wifiTethering.d.ts +1 -3
- package/assets/icons/wifiTethering.js +4 -11
- package/components/core/Button/Button.js +30 -27
- package/components/core/Button/Button.types.d.ts +2 -2
- package/components/core/Button/ButtonStyled.js +40 -39
- package/components/core/Dropdown/Dropdown.d.ts +1 -1
- package/components/core/Dropdown/Dropdown.js +16 -16
- package/components/core/Dropdown/Dropdown.types.d.ts +3 -3
- package/components/core/Dropdown/DropdownStyled.js +13 -14
- package/components/core/Icon/Icon.js +41 -33
- package/components/core/Icon/Icon.types.d.ts +2 -1
- package/components/core/Icon/constants.d.ts +37 -109
- package/components/core/Input/Input.d.ts +1 -1
- package/components/core/InputFile/InputFile.d.ts +0 -32
- package/components/core/InputFile/InputFile.js +47 -33
- package/components/core/InputFile/InputFileStyled.js +24 -22
- package/components/core/Loader/Loader.js +19 -17
- package/components/core/Loader/Loader.types.d.ts +3 -1
- package/components/core/Loader/LoaderStyled.js +34 -30
- package/components/core/Menu/Menu.d.ts +2 -2
- package/components/core/Menu/Menu.js +113 -93
- package/components/core/Menu/Menu.types.d.ts +16 -11
- package/components/core/Menu/MenuStyled.d.ts +1 -1
- package/components/core/Menu/constants.js +4 -12
- package/components/core/Modal/Modal.js +60 -36
- package/components/core/Modal/ModalStyled.js +21 -22
- package/components/core/Scroll/Scroll.d.ts +6 -0
- package/components/core/Scroll/Scroll.js +53 -31
- package/components/core/Scroll/Scroll.types.d.ts +5 -0
- package/components/core/Scroll/ScrollBar.js +45 -43
- package/components/core/Scroll/ScrollStyled.js +46 -42
- package/components/core/Scroll/constants.d.ts +2 -0
- package/components/core/Scroll/constants.js +6 -4
- package/components/core/Select/Select.js +162 -134
- package/components/core/Select/Select.types.d.ts +2 -4
- package/components/core/Snackbar/Snackbar.js +60 -37
- package/components/core/Snackbar/Snackbar.types.d.ts +1 -2
- package/components/core/Snackbar/SnackbarManager.js +45 -30
- package/components/core/Snackbar/SnackbarStyled.d.ts +5 -5
- package/components/core/Snackbar/SnackbarStyled.js +111 -101
- package/components/core/Textarea/Textarea.d.ts +4 -0
- package/components/core/Tooltip/Tooltip.js +68 -44
- package/components/core/Tooltip/TooltipStyled.js +26 -27
- package/components/core/Tooltip/utils.js +47 -45
- package/components/core/Typography/Typography.js +18 -18
- package/components/core/Typography/Typography.types.d.ts +3 -3
- package/components/core/Typography/TypographyStyled.js +28 -29
- package/components/domainSpecific/Accordion/Accordion.d.ts +1 -1
- package/components/domainSpecific/Accordion/Accordion.js +19 -17
- package/components/domainSpecific/Accordion/Accordion.types.d.ts +7 -4
- package/components/domainSpecific/Accordion/AccordionContent/AccordionContent.d.ts +1 -1
- package/components/domainSpecific/Accordion/AccordionContent/AccordionContent.js +13 -12
- package/components/domainSpecific/Accordion/AccordionHeader/AccordionHeader.d.ts +1 -1
- package/components/domainSpecific/Accordion/AccordionHeader/AccordionHeader.js +15 -14
- package/components/domainSpecific/Accordion/AccordionItem/AccordionItem.d.ts +1 -1
- package/components/domainSpecific/Accordion/AccordionItem/AccordionItem.js +18 -16
- package/components/domainSpecific/Accordion/AccordionStyled.js +44 -35
- package/components/domainSpecific/Card/Card.js +31 -27
- package/components/domainSpecific/Card/CardTitle/constants.js +4 -4
- package/components/domainSpecific/Header/Header.js +4 -4
- package/components/domainSpecific/SearchModal/SearchModal.js +0 -1
- package/components/domainSpecific/SearchModal/SearchModal.types.d.ts +1 -1
- package/components/index.types.d.ts +1 -0
- package/components/layout/ChatContainer/ChatContainer.d.ts +1 -1
- package/components/layout/ChatContainer/ChatContainer.js +58 -41
- package/components/layout/ChatContainer/ChatContainer.types.d.ts +8 -5
- package/components/layout/ChatContainer/ChatContainerStyled.d.ts +2 -0
- package/components/layout/ChatContainer/ChatContainerStyled.js +105 -84
- package/components/layout/Column/Column.types.d.ts +3 -1
- package/components/layout/Column/ColumnStyled.js +23 -23
- package/components/layout/FlexContainer/FlexContainerStyled.js +7 -8
- package/components/layout/Row/Row.d.ts +1 -1
- package/components/layout/Row/Row.js +20 -20
- package/components/layout/Row/Row.types.d.ts +3 -1
- package/components/layout/Row/RowStyled.js +26 -26
- package/constants/index.d.ts +0 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/useLogger/NoOpLogger.d.ts +11 -0
- package/hooks/useLogger/NoOpLogger.js +15 -0
- package/hooks/useLogger/index.d.ts +2 -0
- package/hooks/useLogger/useLogger.d.ts +4 -0
- package/hooks/useLogger/useLogger.js +27 -0
- package/hooks/useLogger/useLogger.types.d.ts +30 -0
- package/hooks/useTheme/NoOpTheme.d.ts +4050 -0
- package/hooks/useTheme/NoOpTheme.js +15 -0
- package/hooks/useTheme/useTheme.d.ts +3 -4
- package/hooks/useTheme/useTheme.js +62 -41
- package/hooks/useTheme/useTheme.types.d.ts +3 -2
- package/index.d.ts +4 -0
- package/index.js +354 -350
- package/llms.txt +39 -19
- package/package.json +1 -1
- package/tokens/accordion.d.ts +9 -3
- package/tokens/accordion.js +14 -11
- package/tokens/button.d.ts +17 -19
- package/tokens/button.js +54 -56
- package/tokens/card.d.ts +2 -3
- package/tokens/card.js +50 -53
- package/tokens/carousel.d.ts +2 -2
- package/tokens/carousel.js +8 -9
- package/tokens/chat.d.ts +69 -48
- package/tokens/chat.js +86 -68
- package/tokens/constants.d.ts +0 -1
- package/tokens/constants.js +1 -1
- package/tokens/defaultTheme.d.ts +199 -112
- package/tokens/defaultTheme.js +27 -25
- package/tokens/header.d.ts +1 -1
- package/tokens/header.js +3 -4
- package/tokens/index.d.ts +175 -104
- package/tokens/index.js +102 -101
- package/tokens/input.d.ts +2 -2
- package/tokens/input.js +25 -26
- package/tokens/inputfile.d.ts +1 -1
- package/tokens/inputfile.js +4 -4
- package/tokens/link.d.ts +5 -0
- package/tokens/loader.d.ts +3 -0
- package/tokens/loader.js +3 -0
- package/tokens/menu.d.ts +1 -0
- package/tokens/menu.js +1 -0
- package/tokens/modal.d.ts +6 -4
- package/tokens/modal.js +42 -60
- package/tokens/scroll.d.ts +19 -2
- package/tokens/scroll.js +23 -7
- package/tokens/select.d.ts +9 -7
- package/tokens/select.js +30 -29
- package/tokens/snackbar.d.ts +36 -20
- package/tokens/snackbar.js +92 -93
- package/tokens/stepper.d.ts +1 -1
- package/tokens/stepper.js +3 -3
- package/tokens/tabs.d.ts +1 -1
- package/tokens/tabs.js +1 -1
- package/tokens/textarea.d.ts +4 -0
- package/tokens/tooltip.d.ts +5 -1
- package/tokens/tooltip.js +23 -21
- package/tokens/typography.js +114 -116
- package/tokens/values.d.ts +5 -1
- package/tokens/values.js +12 -8
- package/tokens/wrapper.d.ts +2 -2
- package/tokens/wrapper.js +7 -7
- package/tokens/zIndex.d.ts +9 -0
- package/tokens/zIndex.js +12 -0
- package/types/index.d.ts +0 -1
- package/types/styles.d.ts +1 -0
- package/utils/helpers.js +14 -15
- package/CHANGELOG.md +0 -177
- package/constants/positioning.d.ts +0 -9
- package/constants/positioning.js +0 -11
- package/types/chat.d.ts +0 -5
- package/types/chat.js +0 -4
|
@@ -1,195 +1,223 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { KEYBOARD_KEYS as
|
|
5
|
-
import { DropdownItem as
|
|
6
|
-
import { Dropdown as
|
|
7
|
-
import { DEFAULT_SELECTED_VALUE as
|
|
8
|
-
import { SelectWrapperStyled as
|
|
9
|
-
import { getClosestFocusable as
|
|
10
|
-
import { get as
|
|
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 {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
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:
|
|
18
|
-
children:
|
|
19
|
-
initiator:
|
|
20
|
-
onInitiatorClick:
|
|
21
|
-
renderOption:
|
|
22
|
-
emptyItemsResult:
|
|
23
|
-
autoOpen:
|
|
24
|
-
width:
|
|
25
|
-
minWidth:
|
|
26
|
-
maxWidth:
|
|
27
|
-
styles:
|
|
28
|
-
activeIndex:
|
|
29
|
-
value:
|
|
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:
|
|
32
|
-
itemStringifier:
|
|
33
|
-
itemIdentifier:
|
|
34
|
-
disabled:
|
|
35
|
-
items:
|
|
36
|
-
adornmentStart:
|
|
37
|
-
adornmentEnd:
|
|
38
|
-
dropdownMaxHeight:
|
|
39
|
-
} =
|
|
40
|
-
theme:
|
|
41
|
-
} = He(),
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
}, [
|
|
48
|
-
const
|
|
49
|
-
const e =
|
|
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(),
|
|
52
|
-
let
|
|
53
|
-
!
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
}, [
|
|
57
|
-
|
|
58
|
-
if (!
|
|
59
|
-
|
|
60
|
-
const e = () =>
|
|
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
|
-
}, [
|
|
65
|
-
const W =
|
|
66
|
-
if (
|
|
67
|
-
const e =
|
|
68
|
-
initial:
|
|
69
|
-
root:
|
|
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
|
-
}, [
|
|
80
|
+
}, [r]), ve = () => p != null && p.length ? Se() : oe, j = ({
|
|
75
81
|
event: e,
|
|
76
82
|
data: t
|
|
77
83
|
}) => {
|
|
78
|
-
|
|
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
|
-
}),
|
|
92
|
+
}), u(!1), setTimeout(() => {
|
|
82
93
|
W();
|
|
83
94
|
}));
|
|
84
|
-
},
|
|
85
|
-
onSelect:
|
|
86
|
-
value:
|
|
87
|
-
itemIdentifier:
|
|
88
|
-
},
|
|
89
|
-
if (!(
|
|
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
|
|
92
|
-
|
|
102
|
+
case h.ARROW_DOWN:
|
|
103
|
+
Y(e, !1);
|
|
93
104
|
break;
|
|
94
|
-
case
|
|
95
|
-
|
|
105
|
+
case h.ARROW_UP:
|
|
106
|
+
Y(e, !0);
|
|
96
107
|
break;
|
|
97
108
|
}
|
|
98
|
-
},
|
|
99
|
-
if (
|
|
109
|
+
}, Y = (e, t) => {
|
|
110
|
+
if (r)
|
|
100
111
|
return;
|
|
101
112
|
e.preventDefault();
|
|
102
|
-
const
|
|
103
|
-
if (!
|
|
104
|
-
|
|
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
|
-
|
|
108
|
-
|
|
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:
|
|
127
|
+
root: i
|
|
111
128
|
});
|
|
112
129
|
n == null || n.focus();
|
|
113
130
|
}, ye = () => {
|
|
114
|
-
!
|
|
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
|
-
|
|
117
|
-
},
|
|
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:
|
|
121
|
-
className:
|
|
122
|
-
}) : /* @__PURE__ */
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
}, [
|
|
126
|
-
if (!
|
|
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
|
|
129
|
-
!
|
|
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
|
-
}, [
|
|
156
|
+
}, [l]), y(() => {
|
|
133
157
|
const e = (t) => {
|
|
134
|
-
var
|
|
135
|
-
if (!(!
|
|
136
|
-
if (t.key ===
|
|
137
|
-
t.preventDefault(),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
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
|
-
}, [
|
|
154
|
-
ref:
|
|
155
|
-
isOpen:
|
|
156
|
-
selectedValue:
|
|
157
|
-
onSelect:
|
|
181
|
+
}, [l, r, W]), ke(ee, () => ({
|
|
182
|
+
ref: c,
|
|
183
|
+
isOpen: l,
|
|
184
|
+
selectedValue: o,
|
|
185
|
+
onSelect: j,
|
|
158
186
|
open: () => {
|
|
159
|
-
|
|
187
|
+
r || u(!0);
|
|
160
188
|
},
|
|
161
|
-
close: () =>
|
|
189
|
+
close: () => u(!1),
|
|
162
190
|
toggle: () => {
|
|
163
|
-
|
|
191
|
+
r || u((e) => !e);
|
|
164
192
|
}
|
|
165
|
-
})), /* @__PURE__ */
|
|
166
|
-
...
|
|
167
|
-
width:
|
|
168
|
-
maxWidth:
|
|
169
|
-
minWidth:
|
|
170
|
-
}, $disabled:
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
|
|
173
|
-
/* @__PURE__ */
|
|
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": `${
|
|
177
|
-
|
|
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:
|
|
180
|
-
maxWidth:
|
|
181
|
-
minWidth:
|
|
182
|
-
maxHeight:
|
|
183
|
-
left:
|
|
184
|
-
...
|
|
185
|
-
top:
|
|
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:
|
|
215
|
+
bottom: ge
|
|
188
216
|
}
|
|
189
|
-
}, ref:
|
|
217
|
+
}, ref: L, children: Array.isArray(v) || Ie(v) ? v : ve() }) })
|
|
190
218
|
] }) });
|
|
191
219
|
});
|
|
192
|
-
|
|
220
|
+
Fe.displayName = s;
|
|
193
221
|
export {
|
|
194
|
-
|
|
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
|
|
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
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import {
|
|
5
|
-
import { SnackbarStyled as
|
|
6
|
-
import { useTheme as
|
|
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
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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(
|
|
34
|
-
}, [n
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
6
|
-
import { Snackbar as
|
|
7
|
-
import { DEFAULT_DURATION as
|
|
8
|
-
import { get as
|
|
9
|
-
import { useTheme as
|
|
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
|
|
13
|
-
|
|
13
|
+
const c = [], d = () => {
|
|
14
|
+
c.forEach((e) => e(i));
|
|
14
15
|
}, M = (e) => {
|
|
15
|
-
const
|
|
16
|
-
id:
|
|
17
|
-
variant:
|
|
18
|
-
position:
|
|
19
|
-
duration:
|
|
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,
|
|
23
|
-
},
|
|
23
|
+
i = [...i, s].slice(-50), d();
|
|
24
|
+
}, x = (e) => {
|
|
24
25
|
i = i.filter((n) => n.id !== e), d();
|
|
25
|
-
},
|
|
26
|
+
}, q = (e) => M(e), B = () => {
|
|
26
27
|
const {
|
|
27
28
|
theme: e
|
|
28
|
-
} = _(), [
|
|
29
|
-
|
|
30
|
-
const r = (o) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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 =
|
|
37
|
-
const t = o.position ||
|
|
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
|
-
}, {}), [
|
|
40
|
-
return
|
|
41
|
-
var
|
|
42
|
-
(u
|
|
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
|
-
|
|
47
|
-
|
|
61
|
+
B as SnackbarManager,
|
|
62
|
+
q as showSnackbar
|
|
48
63
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SnackbarCommonStyledProps, SnackbarContainerStyledProps, SnackbarIconProps, SnackbarStyledProps } from './
|
|
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:
|
|
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:
|
|
10
|
-
export declare const SnackbarDescriptionStyled: (props:
|
|
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;
|