@konstructio/ui 0.1.2-alpha.54 → 0.1.2-alpha.55
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/dist/components/Button/Button.variants.js +7 -1
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +34 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +118 -0
- package/dist/components/ButtonGroup/ButtonGroup.types.d.ts +92 -0
- package/dist/components/ButtonGroup/ButtonGroup.variants.d.ts +13 -0
- package/dist/components/ButtonGroup/ButtonGroup.variants.js +31 -0
- package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.d.ts +3 -0
- package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.js +263 -0
- package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.types.d.ts +21 -0
- package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.variants.d.ts +26 -0
- package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.variants.js +89 -0
- package/dist/components/ButtonGroup/components/ButtonGroupItem/index.d.ts +2 -0
- package/dist/components/ButtonGroup/components/ButtonGroupItem/index.js +4 -0
- package/dist/components/ButtonGroup/components/ButtonGroupLabel/ButtonGroupLabel.d.ts +3 -0
- package/dist/components/ButtonGroup/components/ButtonGroupLabel/ButtonGroupLabel.js +45 -0
- package/dist/components/ButtonGroup/components/ButtonGroupLabel/ButtonGroupLabel.types.d.ts +8 -0
- package/dist/components/ButtonGroup/components/ButtonGroupLabel/index.d.ts +2 -0
- package/dist/components/ButtonGroup/components/ButtonGroupLabel/index.js +4 -0
- package/dist/components/ButtonGroup/components/ButtonGroupMessage/ButtonGroupMessage.d.ts +3 -0
- package/dist/components/ButtonGroup/components/ButtonGroupMessage/ButtonGroupMessage.js +37 -0
- package/dist/components/ButtonGroup/components/ButtonGroupMessage/ButtonGroupMessage.types.d.ts +6 -0
- package/dist/components/ButtonGroup/components/ButtonGroupMessage/index.d.ts +2 -0
- package/dist/components/ButtonGroup/components/ButtonGroupMessage/index.js +4 -0
- package/dist/components/ButtonGroup/components/index.d.ts +3 -0
- package/dist/components/ButtonGroup/components/index.js +8 -0
- package/dist/components/ButtonGroup/hooks/index.d.ts +2 -0
- package/dist/components/ButtonGroup/hooks/index.js +4 -0
- package/dist/components/ButtonGroup/hooks/useButtonGroup.d.ts +3 -0
- package/dist/components/ButtonGroup/hooks/useButtonGroup.js +67 -0
- package/dist/components/ButtonGroup/hooks/useButtonGroup.types.d.ts +18 -0
- package/dist/components/DateRangePicker/components/CalendarPanel/components/IndependentModeCalendar/IndependentModeCalendar.js +1 -1
- package/dist/components/DateRangePicker/components/CalendarPanel/components/TogetherModeCalendar/TogetherModeCalendar.js +1 -1
- package/dist/components/DateRangePicker/components/PresetPanel/PresetPanel.js +11 -11
- package/dist/components/Drawer/Drawer.d.ts +36 -0
- package/dist/components/Drawer/Drawer.js +134 -0
- package/dist/components/Drawer/Drawer.types.d.ts +65 -0
- package/dist/components/Drawer/Drawer.variants.d.ts +8 -0
- package/dist/components/Drawer/Drawer.variants.js +92 -0
- package/dist/components/Drawer/components/Body/Body.d.ts +3 -0
- package/dist/components/Drawer/components/Body/Body.js +24 -0
- package/dist/components/Drawer/components/Body/Body.types.d.ts +7 -0
- package/dist/components/Drawer/components/Body/index.d.ts +2 -0
- package/dist/components/Drawer/components/Body/index.js +4 -0
- package/dist/components/Drawer/components/Footer/Footer.d.ts +3 -0
- package/dist/components/Drawer/components/Footer/Footer.js +26 -0
- package/dist/components/Drawer/components/Footer/Footer.types.d.ts +7 -0
- package/dist/components/Drawer/components/Footer/index.d.ts +2 -0
- package/dist/components/Drawer/components/Footer/index.js +4 -0
- package/dist/components/Drawer/components/Header/Header.d.ts +3 -0
- package/dist/components/Drawer/components/Header/Header.js +27 -0
- package/dist/components/Drawer/components/Header/Header.types.d.ts +9 -0
- package/dist/components/Drawer/components/Header/index.d.ts +2 -0
- package/dist/components/Drawer/components/Header/index.js +4 -0
- package/dist/components/Drawer/components/index.d.ts +3 -0
- package/dist/components/Drawer/components/index.js +8 -0
- package/dist/components/Drawer/constants/index.d.ts +6 -0
- package/dist/components/Drawer/constants/index.js +9 -0
- package/dist/components/Drawer/contexts/Drawer.context.d.ts +7 -0
- package/dist/components/Drawer/contexts/Drawer.context.js +6 -0
- package/dist/components/Drawer/contexts/index.d.ts +2 -0
- package/dist/components/Drawer/contexts/index.js +5 -0
- package/dist/components/Drawer/hooks/index.d.ts +2 -0
- package/dist/components/Drawer/hooks/index.js +4 -0
- package/dist/components/Drawer/hooks/useDrawer.d.ts +2 -0
- package/dist/components/Drawer/hooks/useDrawer.js +66 -0
- package/dist/components/Drawer/hooks/useDrawer.types.d.ts +30 -0
- package/dist/components/PhoneNumberInput/components/Wrapper.js +116 -116
- package/dist/components/RadioGroup/RadioGroup.js +34 -33
- package/dist/components/RadioGroup/RadioGroup.types.d.ts +3 -1
- package/dist/components/Stepper/Stepper.js +29 -25
- package/dist/components/Stepper/components/HorizontalStepItem/HorizontalStepItem.d.ts +1 -2
- package/dist/components/Stepper/components/HorizontalStepItem/HorizontalStepItem.js +96 -91
- package/dist/components/Stepper/components/StepConnector/StepConnector.d.ts +1 -2
- package/dist/components/Stepper/components/StepConnector/StepConnector.js +10 -9
- package/dist/components/Stepper/components/StepIndicatorContent/StepIndicatorContent.d.ts +1 -2
- package/dist/components/Stepper/components/StepIndicatorContent/StepIndicatorContent.js +13 -19
- package/dist/components/Stepper/components/StepItem/StepItem.d.ts +1 -2
- package/dist/components/Stepper/components/StepItem/StepItem.js +6 -5
- package/dist/components/Stepper/components/VerticalStepItem/VerticalStepItem.d.ts +1 -2
- package/dist/components/Stepper/components/VerticalStepItem/VerticalStepItem.js +65 -60
- package/dist/components/Stepper/constants/index.d.ts +3 -0
- package/dist/components/Stepper/constants/index.js +13 -0
- package/dist/components/Stepper/hooks/index.d.ts +1 -0
- package/dist/components/Stepper/hooks/index.js +4 -0
- package/dist/components/Stepper/hooks/useStepItemLogic.d.ts +2 -0
- package/dist/components/Stepper/hooks/useStepItemLogic.js +27 -0
- package/dist/components/Stepper/hooks/useStepItemLogic.types.d.ts +16 -0
- package/dist/components/Stepper/utils/index.d.ts +3 -0
- package/dist/components/Stepper/utils/index.js +13 -0
- package/dist/components/Tooltip/Tooltip.variants.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +113 -109
- package/dist/index.js +115 -111
- package/dist/package.json +18 -17
- package/dist/{proxy-Drz23HDt.js → proxy-i19-YB39.js} +1044 -1035
- package/dist/styles.css +1 -1
- package/package.json +15 -16
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { c as t } from "../../../../index-D29mdTf5.js";
|
|
2
|
+
const r = t(
|
|
3
|
+
[
|
|
4
|
+
"flex",
|
|
5
|
+
"flex-1",
|
|
6
|
+
"items-start",
|
|
7
|
+
"cursor-pointer",
|
|
8
|
+
"select-none",
|
|
9
|
+
"transition-colors",
|
|
10
|
+
"p-2",
|
|
11
|
+
"border-metal-700",
|
|
12
|
+
"border-t",
|
|
13
|
+
"border-b",
|
|
14
|
+
"bg-metal-900",
|
|
15
|
+
"first:border-l",
|
|
16
|
+
"first:rounded-l-lg",
|
|
17
|
+
"last:border-r",
|
|
18
|
+
"last:rounded-r-lg",
|
|
19
|
+
"focus:outline-none",
|
|
20
|
+
"focus-visible:ring-2",
|
|
21
|
+
"focus-visible:ring-aurora-500",
|
|
22
|
+
"focus-visible:ring-inset"
|
|
23
|
+
],
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
disabled: {
|
|
27
|
+
true: "pointer-events-none opacity-50",
|
|
28
|
+
false: ""
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
disabled: !1
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
), s = t([
|
|
36
|
+
"absolute",
|
|
37
|
+
"inset-2",
|
|
38
|
+
"bg-metal-800",
|
|
39
|
+
"rounded-lg"
|
|
40
|
+
]), a = t(
|
|
41
|
+
["flex", "flex-col", "flex-1", "rounded-lg", "px-4", "py-2"],
|
|
42
|
+
{
|
|
43
|
+
variants: {
|
|
44
|
+
hasDescription: {
|
|
45
|
+
true: "items-start text-left justify-start",
|
|
46
|
+
false: "items-center text-center justify-center"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
hasDescription: !1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
), n = t(
|
|
54
|
+
[
|
|
55
|
+
"text-sm",
|
|
56
|
+
"font-medium",
|
|
57
|
+
"leading-5",
|
|
58
|
+
"tracking-[0.1px]",
|
|
59
|
+
"flex",
|
|
60
|
+
"items-center",
|
|
61
|
+
"gap-2",
|
|
62
|
+
"transition-colors",
|
|
63
|
+
"ease-in-out"
|
|
64
|
+
],
|
|
65
|
+
{
|
|
66
|
+
variants: {
|
|
67
|
+
selected: {
|
|
68
|
+
true: "text-aurora-500",
|
|
69
|
+
false: "text-metal-50"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
selected: !1
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
), o = t([
|
|
77
|
+
"text-sm",
|
|
78
|
+
"font-normal",
|
|
79
|
+
"leading-5",
|
|
80
|
+
"tracking-[0.15px]",
|
|
81
|
+
"text-metal-300"
|
|
82
|
+
]);
|
|
83
|
+
export {
|
|
84
|
+
o as buttonGroupDescriptionVariants,
|
|
85
|
+
a as buttonGroupItemContentVariants,
|
|
86
|
+
r as buttonGroupItemVariants,
|
|
87
|
+
n as buttonGroupLabelVariants,
|
|
88
|
+
s as buttonGroupPillVariants
|
|
89
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsxs as p, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { memo as l } from "react";
|
|
3
|
+
import { cn as t } from "../../../../utils/index.js";
|
|
4
|
+
import { Typography as e } from "../../../Typography/Typography.js";
|
|
5
|
+
const c = l(
|
|
6
|
+
({ className: o, htmlFor: r, isRequired: m, label: a, requiredClassName: n }) => /* @__PURE__ */ p(
|
|
7
|
+
e,
|
|
8
|
+
{
|
|
9
|
+
component: "label",
|
|
10
|
+
variant: "labelLarge",
|
|
11
|
+
htmlFor: r,
|
|
12
|
+
className: t(
|
|
13
|
+
"cursor-pointer",
|
|
14
|
+
"flex",
|
|
15
|
+
"gap-1",
|
|
16
|
+
"text-sm",
|
|
17
|
+
"font-medium",
|
|
18
|
+
"text-metal-50",
|
|
19
|
+
o
|
|
20
|
+
),
|
|
21
|
+
children: [
|
|
22
|
+
a,
|
|
23
|
+
" ",
|
|
24
|
+
m && /* @__PURE__ */ s(
|
|
25
|
+
e,
|
|
26
|
+
{
|
|
27
|
+
component: "span",
|
|
28
|
+
className: t(
|
|
29
|
+
"text-red-600",
|
|
30
|
+
"dark:text-red-500",
|
|
31
|
+
"text-xs",
|
|
32
|
+
"mt-0.5",
|
|
33
|
+
n
|
|
34
|
+
),
|
|
35
|
+
children: "*"
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
c.displayName = "KonstructButtonGroupLabel";
|
|
43
|
+
export {
|
|
44
|
+
c as ButtonGroupLabel
|
|
45
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { memo as m } from "react";
|
|
3
|
+
import { cn as r } from "../../../../utils/index.js";
|
|
4
|
+
import { Typography as e } from "../../../Typography/Typography.js";
|
|
5
|
+
const p = m(
|
|
6
|
+
({ error: t, errorClassName: s, helperText: n, helperTextClassName: a }) => typeof t == "string" && t.length > 0 ? /* @__PURE__ */ o(
|
|
7
|
+
e,
|
|
8
|
+
{
|
|
9
|
+
component: "span",
|
|
10
|
+
className: r(
|
|
11
|
+
"text-xs",
|
|
12
|
+
"tracking-normal",
|
|
13
|
+
"text-red-400",
|
|
14
|
+
s
|
|
15
|
+
),
|
|
16
|
+
children: t
|
|
17
|
+
}
|
|
18
|
+
) : n ? /* @__PURE__ */ o(
|
|
19
|
+
e,
|
|
20
|
+
{
|
|
21
|
+
component: "span",
|
|
22
|
+
variant: "body1",
|
|
23
|
+
className: r(
|
|
24
|
+
"text-xs",
|
|
25
|
+
"text-metal-300",
|
|
26
|
+
"select-none",
|
|
27
|
+
"tracking-normal",
|
|
28
|
+
a
|
|
29
|
+
),
|
|
30
|
+
children: n
|
|
31
|
+
}
|
|
32
|
+
) : null
|
|
33
|
+
);
|
|
34
|
+
p.displayName = "KonstructButtonGroupMessage";
|
|
35
|
+
export {
|
|
36
|
+
p as ButtonGroupMessage
|
|
37
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ButtonGroupItem as r } from "./ButtonGroupItem/ButtonGroupItem.js";
|
|
2
|
+
import { ButtonGroupLabel as p } from "./ButtonGroupLabel/ButtonGroupLabel.js";
|
|
3
|
+
import { ButtonGroupMessage as m } from "./ButtonGroupMessage/ButtonGroupMessage.js";
|
|
4
|
+
export {
|
|
5
|
+
r as ButtonGroupItem,
|
|
6
|
+
p as ButtonGroupLabel,
|
|
7
|
+
m as ButtonGroupMessage
|
|
8
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { UseButtonGroupProps, UseButtonGroupReturn } from './useButtonGroup.types';
|
|
2
|
+
export type { AnimationDirection } from './useButtonGroup.types';
|
|
3
|
+
export declare const useButtonGroup: ({ defaultValue, disabled, options, value, onValueChange, }: UseButtonGroupProps) => UseButtonGroupReturn;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useId as A, useRef as S, useState as D, useCallback as d } from "react";
|
|
2
|
+
const R = ({
|
|
3
|
+
defaultValue: g,
|
|
4
|
+
disabled: l,
|
|
5
|
+
options: o,
|
|
6
|
+
value: f,
|
|
7
|
+
onValueChange: x
|
|
8
|
+
}) => {
|
|
9
|
+
const p = A(), I = S(null), u = f !== void 0, [k, w] = D(
|
|
10
|
+
() => g
|
|
11
|
+
), a = u ? f : k, [b, m] = D("none"), s = d(
|
|
12
|
+
(e) => e ? o.findIndex((n) => n.value === e) : -1,
|
|
13
|
+
[o]
|
|
14
|
+
), i = d(
|
|
15
|
+
(e) => {
|
|
16
|
+
if (l) return;
|
|
17
|
+
const n = s(a), t = s(e);
|
|
18
|
+
n !== -1 && t !== -1 && m(t > n ? "right" : "left"), u || w(e), x?.(e);
|
|
19
|
+
},
|
|
20
|
+
[l, s, u, x, a]
|
|
21
|
+
), v = d(
|
|
22
|
+
(e, n) => {
|
|
23
|
+
const t = o.filter(
|
|
24
|
+
(c) => !c.disabled && !l
|
|
25
|
+
), h = t.findIndex(
|
|
26
|
+
(c) => c.value === o[n].value
|
|
27
|
+
);
|
|
28
|
+
let r = -1;
|
|
29
|
+
switch (e.key) {
|
|
30
|
+
case "ArrowRight":
|
|
31
|
+
case "ArrowDown":
|
|
32
|
+
e.preventDefault(), r = (h + 1) % t.length;
|
|
33
|
+
break;
|
|
34
|
+
case "ArrowLeft":
|
|
35
|
+
case "ArrowUp":
|
|
36
|
+
e.preventDefault(), r = (h - 1 + t.length) % t.length;
|
|
37
|
+
break;
|
|
38
|
+
case "Home":
|
|
39
|
+
e.preventDefault(), r = 0;
|
|
40
|
+
break;
|
|
41
|
+
case "End":
|
|
42
|
+
e.preventDefault(), r = t.length - 1;
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (r >= 0) {
|
|
48
|
+
const c = t[r];
|
|
49
|
+
i(c.value), I.current?.querySelector(
|
|
50
|
+
`[data-value="${c.value}"]`
|
|
51
|
+
)?.focus();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[l, i, o]
|
|
55
|
+
);
|
|
56
|
+
return {
|
|
57
|
+
animationDirection: b,
|
|
58
|
+
groupRef: I,
|
|
59
|
+
id: p,
|
|
60
|
+
selected: a,
|
|
61
|
+
handleKeyDown: v,
|
|
62
|
+
handleSelect: i
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
R as useButtonGroup
|
|
67
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { KeyboardEvent, RefObject } from 'react';
|
|
2
|
+
import { ButtonGroupOption } from '../ButtonGroup.types';
|
|
3
|
+
export type AnimationDirection = 'left' | 'right' | 'none';
|
|
4
|
+
export type UseButtonGroupProps = {
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
options: ButtonGroupOption[];
|
|
8
|
+
value?: string;
|
|
9
|
+
onValueChange?: (value: string) => void;
|
|
10
|
+
};
|
|
11
|
+
export type UseButtonGroupReturn = {
|
|
12
|
+
animationDirection: AnimationDirection;
|
|
13
|
+
groupRef: RefObject<HTMLDivElement | null>;
|
|
14
|
+
id: string;
|
|
15
|
+
selected: string | undefined;
|
|
16
|
+
handleKeyDown: (event: KeyboardEvent<HTMLButtonElement>, currentIndex: number) => void;
|
|
17
|
+
handleSelect: (value: string) => void;
|
|
18
|
+
};
|
|
@@ -7,7 +7,7 @@ import { CalendarDivider as tt } from "../CalendarDivider/CalendarDivider.js";
|
|
|
7
7
|
import { CalendarMonth as d } from "../CalendarMonth/CalendarMonth.js";
|
|
8
8
|
import { NavigationButton as g } from "../NavigationButton/NavigationButton.js";
|
|
9
9
|
import { useIndependentCarousel as nt } from "../../hooks/useIndependentCarousel.js";
|
|
10
|
-
import { m as et } from "../../../../../../proxy-
|
|
10
|
+
import { m as et } from "../../../../../../proxy-i19-YB39.js";
|
|
11
11
|
const at = ({
|
|
12
12
|
className: b,
|
|
13
13
|
calendarWidth: x = 550,
|
|
@@ -6,7 +6,7 @@ import { CalendarDivider as F } from "../CalendarDivider/CalendarDivider.js";
|
|
|
6
6
|
import { CalendarMonth as G } from "../CalendarMonth/CalendarMonth.js";
|
|
7
7
|
import { NavigationButton as m } from "../NavigationButton/NavigationButton.js";
|
|
8
8
|
import { useTogetherCarousel as H } from "../../hooks/useTogetherCarousel.js";
|
|
9
|
-
import { m as R } from "../../../../../../proxy-
|
|
9
|
+
import { m as R } from "../../../../../../proxy-i19-YB39.js";
|
|
10
10
|
const S = ({
|
|
11
11
|
className: s,
|
|
12
12
|
calendarWidth: h = 550,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs as f, jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as h, useMemo as
|
|
2
|
+
import { useCallback as h, useMemo as x } from "react";
|
|
3
3
|
import { cn as t } from "../../../../utils/index.js";
|
|
4
|
-
import { RadioGroup as
|
|
5
|
-
import { Typography as
|
|
6
|
-
import { presetTitleVariants as
|
|
4
|
+
import { RadioGroup as y } from "../../../RadioGroup/RadioGroup.js";
|
|
5
|
+
import { Typography as g } from "../../../Typography/Typography.js";
|
|
6
|
+
import { presetTitleVariants as k, presetPanelVariants as T } from "./PresetPanel.variants.js";
|
|
7
7
|
import { useDateRangePicker as b } from "../../contexts/date-range-picker.hook.js";
|
|
8
|
-
import { PRESET_OPTIONS as
|
|
8
|
+
import { PRESET_OPTIONS as v } from "../../constants/presets.js";
|
|
9
9
|
const E = {
|
|
10
10
|
today: "today",
|
|
11
11
|
"current-month": "currentMonth",
|
|
@@ -24,8 +24,8 @@ const E = {
|
|
|
24
24
|
o(e);
|
|
25
25
|
},
|
|
26
26
|
[o]
|
|
27
|
-
), u =
|
|
28
|
-
() =>
|
|
27
|
+
), u = x(
|
|
28
|
+
() => v.map((e) => {
|
|
29
29
|
const n = E[e.value], P = n && r?.[n];
|
|
30
30
|
return {
|
|
31
31
|
value: e.value,
|
|
@@ -37,20 +37,20 @@ const E = {
|
|
|
37
37
|
);
|
|
38
38
|
return /* @__PURE__ */ f("div", { className: t(T({ className: l }), a?.root), children: [
|
|
39
39
|
/* @__PURE__ */ i(
|
|
40
|
-
|
|
40
|
+
g,
|
|
41
41
|
{
|
|
42
42
|
component: "span",
|
|
43
|
-
className: t(
|
|
43
|
+
className: t(k(), a?.title),
|
|
44
44
|
"aria-label": p,
|
|
45
45
|
children: m
|
|
46
46
|
}
|
|
47
47
|
),
|
|
48
48
|
/* @__PURE__ */ i(
|
|
49
|
-
|
|
49
|
+
y,
|
|
50
50
|
{
|
|
51
51
|
name: "date-range-preset",
|
|
52
52
|
options: u,
|
|
53
|
-
|
|
53
|
+
value: c,
|
|
54
54
|
onValueChange: d,
|
|
55
55
|
direction: "col",
|
|
56
56
|
wrapperClassName: t("gap-4 pl-2", a?.radioGroup),
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BodyProps, FooterProps, HeaderProps } from './components';
|
|
3
|
+
import { Props } from './Drawer.types';
|
|
4
|
+
/**
|
|
5
|
+
* A drawer/panel component that slides in from the side of the screen.
|
|
6
|
+
* Supports Header, Body, and Footer sub-components, keyboard navigation (Escape to close),
|
|
7
|
+
* and optional resizing.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
*
|
|
13
|
+
* <Button onClick={() => setIsOpen(true)}>Open Drawer</Button>
|
|
14
|
+
*
|
|
15
|
+
* <Drawer isOpen={isOpen} onClose={() => setIsOpen(false)}>
|
|
16
|
+
* <Drawer.Header>Panel Title</Drawer.Header>
|
|
17
|
+
* <Drawer.Body>
|
|
18
|
+
* Panel content goes here.
|
|
19
|
+
* </Drawer.Body>
|
|
20
|
+
* <Drawer.Footer>
|
|
21
|
+
* <Button variant="secondary" onClick={() => setIsOpen(false)}>
|
|
22
|
+
* Cancel
|
|
23
|
+
* </Button>
|
|
24
|
+
* <Button onClick={handleConfirm}>Confirm</Button>
|
|
25
|
+
* </Drawer.Footer>
|
|
26
|
+
* </Drawer>
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://konstructio.github.io/konstruct-ui/?path=/docs/components-drawer--docs Storybook}
|
|
30
|
+
*/
|
|
31
|
+
declare const Drawer: FC<Props> & {
|
|
32
|
+
Header: FC<HeaderProps>;
|
|
33
|
+
Body: FC<BodyProps>;
|
|
34
|
+
Footer: FC<FooterProps>;
|
|
35
|
+
};
|
|
36
|
+
export { Drawer };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { R as g } from "../../index-BKjcReYh.js";
|
|
3
|
+
import { useId as z, useMemo as B } from "react";
|
|
4
|
+
import { createPortal as F } from "react-dom";
|
|
5
|
+
import { R as I } from "../../Combination-BtmnusWq.js";
|
|
6
|
+
import { cn as o } from "../../utils/index.js";
|
|
7
|
+
import { overlayVariants as M, resizeHandleVariants as j, buttonCloseVariants as k, drawerVariants as A } from "./Drawer.variants.js";
|
|
8
|
+
import { DEFAULT_WIDTH as f } from "./constants/index.js";
|
|
9
|
+
import { useDrawer as K } from "./hooks/useDrawer.js";
|
|
10
|
+
import { DrawerContext as P } from "./contexts/Drawer.context.js";
|
|
11
|
+
import { X as T } from "../../x-Eoa9FJjA.js";
|
|
12
|
+
import { Header as W } from "./components/Header/Header.js";
|
|
13
|
+
import { Body as E } from "./components/Body/Body.js";
|
|
14
|
+
import { Footer as L } from "./components/Footer/Footer.js";
|
|
15
|
+
const d = ({
|
|
16
|
+
canResize: t = !1,
|
|
17
|
+
children: s,
|
|
18
|
+
className: u,
|
|
19
|
+
classNames: r,
|
|
20
|
+
container: c,
|
|
21
|
+
isOpen: p,
|
|
22
|
+
maxWidth: h,
|
|
23
|
+
minWidth: w,
|
|
24
|
+
position: i = "right",
|
|
25
|
+
showCloseButton: y = !0,
|
|
26
|
+
theme: b,
|
|
27
|
+
onClose: a
|
|
28
|
+
}) => {
|
|
29
|
+
const n = z(), {
|
|
30
|
+
handleKeyDown: v,
|
|
31
|
+
handleMouseDown: D,
|
|
32
|
+
isAnimating: m,
|
|
33
|
+
isVisible: x,
|
|
34
|
+
translateClass: V,
|
|
35
|
+
width: H
|
|
36
|
+
} = K({
|
|
37
|
+
canResize: t,
|
|
38
|
+
defaultWidth: f,
|
|
39
|
+
isOpen: p,
|
|
40
|
+
maxWidth: h,
|
|
41
|
+
minWidth: w,
|
|
42
|
+
position: i,
|
|
43
|
+
onClose: a
|
|
44
|
+
}), C = B(
|
|
45
|
+
() => ({ classNames: r, headerId: n }),
|
|
46
|
+
[r, n]
|
|
47
|
+
);
|
|
48
|
+
if (!x)
|
|
49
|
+
return null;
|
|
50
|
+
const R = /* @__PURE__ */ e(P.Provider, { value: C, children: /* @__PURE__ */ e(I, { children: /* @__PURE__ */ l(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: o("fixed inset-0 z-40", r?.root),
|
|
54
|
+
"data-theme": b,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ e(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
className: o(
|
|
60
|
+
M(),
|
|
61
|
+
{
|
|
62
|
+
"opacity-50": m,
|
|
63
|
+
"opacity-0": !m
|
|
64
|
+
},
|
|
65
|
+
r?.overlay
|
|
66
|
+
),
|
|
67
|
+
"aria-hidden": "true",
|
|
68
|
+
onClick: a,
|
|
69
|
+
role: "presentation"
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ l(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
className: o(
|
|
76
|
+
A({ position: i }),
|
|
77
|
+
V,
|
|
78
|
+
r?.panel,
|
|
79
|
+
u
|
|
80
|
+
),
|
|
81
|
+
style: { width: t ? H : f },
|
|
82
|
+
role: "dialog",
|
|
83
|
+
"aria-modal": "true",
|
|
84
|
+
"aria-labelledby": n,
|
|
85
|
+
children: [
|
|
86
|
+
t && /* @__PURE__ */ e(
|
|
87
|
+
"button",
|
|
88
|
+
{
|
|
89
|
+
type: "button",
|
|
90
|
+
"aria-label": "Resize drawer",
|
|
91
|
+
className: o(
|
|
92
|
+
j({ position: i }),
|
|
93
|
+
r?.resizeHandle
|
|
94
|
+
),
|
|
95
|
+
onMouseDown: D,
|
|
96
|
+
onKeyDown: v
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
y && /* @__PURE__ */ l(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
className: o(k(), r?.closeButton),
|
|
103
|
+
onClick: a,
|
|
104
|
+
type: "button",
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ e(T, { size: 20 }),
|
|
107
|
+
/* @__PURE__ */ e(g, { children: "Dismiss drawer" })
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ e(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
className: o(
|
|
115
|
+
"flex flex-1 flex-col h-full overflow-hidden",
|
|
116
|
+
r?.content
|
|
117
|
+
),
|
|
118
|
+
children: s
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
) }) });
|
|
127
|
+
return F(R, c || document.body);
|
|
128
|
+
};
|
|
129
|
+
d.Header = W;
|
|
130
|
+
d.Body = E;
|
|
131
|
+
d.Footer = L;
|
|
132
|
+
export {
|
|
133
|
+
d as Drawer
|
|
134
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { drawerVariants } from './Drawer.variants';
|
|
4
|
+
import { Theme } from '../../domain/theme';
|
|
5
|
+
/**
|
|
6
|
+
* Custom class names for each Drawer element.
|
|
7
|
+
*/
|
|
8
|
+
export type ClassNames = {
|
|
9
|
+
/** Class for the drawer body section */
|
|
10
|
+
body?: string;
|
|
11
|
+
/** Class for the close button */
|
|
12
|
+
closeButton?: string;
|
|
13
|
+
/** Class for the content wrapper (contains header, body, footer) */
|
|
14
|
+
content?: string;
|
|
15
|
+
/** Class for the drawer footer section */
|
|
16
|
+
footer?: string;
|
|
17
|
+
/** Class for the drawer header section */
|
|
18
|
+
header?: string;
|
|
19
|
+
/** Class for the background overlay */
|
|
20
|
+
overlay?: string;
|
|
21
|
+
/** Class for the drawer panel */
|
|
22
|
+
panel?: string;
|
|
23
|
+
/** Class for the resize handle */
|
|
24
|
+
resizeHandle?: string;
|
|
25
|
+
/** Class for the root wrapper */
|
|
26
|
+
root?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Props for the Drawer component.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <Drawer isOpen={isOpen} onClose={() => setIsOpen(false)}>
|
|
34
|
+
* <Drawer.Header>Title</Drawer.Header>
|
|
35
|
+
* <Drawer.Body>Content</Drawer.Body>
|
|
36
|
+
* <Drawer.Footer>
|
|
37
|
+
* <Button onClick={() => setIsOpen(false)}>Close</Button>
|
|
38
|
+
* </Drawer.Footer>
|
|
39
|
+
* </Drawer>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export type Props = PropsWithChildren & VariantProps<typeof drawerVariants> & {
|
|
43
|
+
/** Enable resizable drawer */
|
|
44
|
+
canResize?: boolean;
|
|
45
|
+
/** Additional CSS classes for the drawer panel */
|
|
46
|
+
className?: string;
|
|
47
|
+
/** Custom class names for each element */
|
|
48
|
+
classNames?: ClassNames;
|
|
49
|
+
/** DOM element to portal the drawer into (defaults to document.body) */
|
|
50
|
+
container?: Element | DocumentFragment;
|
|
51
|
+
/** Whether the drawer is open */
|
|
52
|
+
isOpen?: boolean;
|
|
53
|
+
/** Maximum width when resizable (default: 800) */
|
|
54
|
+
maxWidth?: number;
|
|
55
|
+
/** Minimum width when resizable (default: 400) */
|
|
56
|
+
minWidth?: number;
|
|
57
|
+
/** Position of the drawer */
|
|
58
|
+
position?: 'left' | 'right';
|
|
59
|
+
/** Show the X close button in the corner */
|
|
60
|
+
showCloseButton?: boolean;
|
|
61
|
+
/** Theme override for this component */
|
|
62
|
+
theme?: Theme;
|
|
63
|
+
/** Callback when drawer is closed (Escape key, overlay click, or close button) */
|
|
64
|
+
onClose?: () => void;
|
|
65
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const drawerVariants: (props?: ({
|
|
2
|
+
position?: "left" | "right" | null | undefined;
|
|
3
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
4
|
+
export declare const overlayVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
5
|
+
export declare const buttonCloseVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
6
|
+
export declare const resizeHandleVariants: (props?: ({
|
|
7
|
+
position?: "left" | "right" | null | undefined;
|
|
8
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|