@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
|
@@ -179,7 +179,13 @@ const a = r(
|
|
|
179
179
|
"text-red-700",
|
|
180
180
|
"border-red-700",
|
|
181
181
|
"bg-white",
|
|
182
|
-
"hover:bg-red-50"
|
|
182
|
+
"hover:bg-red-50",
|
|
183
|
+
"dark:bg-transparent",
|
|
184
|
+
"dark:border-rose-400",
|
|
185
|
+
"dark:text-rose-400",
|
|
186
|
+
"dark:hover:bg-rose-950",
|
|
187
|
+
"dark:hover:border-rose-400",
|
|
188
|
+
"dark:focus-visible:bg-rose-950"
|
|
183
189
|
]
|
|
184
190
|
},
|
|
185
191
|
{
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from './ButtonGroup.types';
|
|
3
|
+
/**
|
|
4
|
+
* A segmented toggle button group for single selection among options.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // Simple button group
|
|
9
|
+
* <ButtonGroup
|
|
10
|
+
* name="processor"
|
|
11
|
+
* options={[
|
|
12
|
+
* { value: 'cpu', label: 'CPU' },
|
|
13
|
+
* { value: 'gpu', label: 'GPU' },
|
|
14
|
+
* ]}
|
|
15
|
+
* defaultValue="cpu"
|
|
16
|
+
* onValueChange={(value) => setProcessor(value)}
|
|
17
|
+
* />
|
|
18
|
+
*
|
|
19
|
+
* // With descriptions
|
|
20
|
+
* <ButtonGroup
|
|
21
|
+
* name="instance-type"
|
|
22
|
+
* label="Instance Type"
|
|
23
|
+
* isRequired
|
|
24
|
+
* options={[
|
|
25
|
+
* { value: 'standard', label: 'Standard', description: 'Balanced compute resources' },
|
|
26
|
+
* { value: 'spot', label: 'Spot', description: 'Cost-effective for flexible workloads' },
|
|
27
|
+
* ]}
|
|
28
|
+
* onValueChange={setInstanceType}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @see {@link https://konstructio.github.io/konstruct-ui/?path=/docs/components-buttongroup--docs Storybook}
|
|
33
|
+
*/
|
|
34
|
+
export declare const ButtonGroup: FC<Props>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsxs as k, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { cn as u } from "../../utils/index.js";
|
|
3
|
+
import { buttonGroupVariants as q, buttonGroupWrapperVariants as z } from "./ButtonGroup.variants.js";
|
|
4
|
+
import { useButtonGroup as A } from "./hooks/useButtonGroup.js";
|
|
5
|
+
import { ButtonGroupLabel as E } from "./components/ButtonGroupLabel/ButtonGroupLabel.js";
|
|
6
|
+
import { ButtonGroupItem as H } from "./components/ButtonGroupItem/ButtonGroupItem.js";
|
|
7
|
+
import { ButtonGroupMessage as J } from "./components/ButtonGroupMessage/ButtonGroupMessage.js";
|
|
8
|
+
const O = ({
|
|
9
|
+
className: l,
|
|
10
|
+
contentClassName: m,
|
|
11
|
+
defaultValue: p,
|
|
12
|
+
descriptionClassName: c,
|
|
13
|
+
disabled: t,
|
|
14
|
+
duration: d,
|
|
15
|
+
error: v,
|
|
16
|
+
errorClassName: f,
|
|
17
|
+
fullWidth: s,
|
|
18
|
+
helperText: G,
|
|
19
|
+
helperTextClassName: h,
|
|
20
|
+
isRequired: b,
|
|
21
|
+
itemClassName: y,
|
|
22
|
+
itemLabelClassName: B,
|
|
23
|
+
label: o,
|
|
24
|
+
labelClassName: D,
|
|
25
|
+
name: N,
|
|
26
|
+
options: i,
|
|
27
|
+
pillClassName: g,
|
|
28
|
+
requiredClassName: x,
|
|
29
|
+
theme: K,
|
|
30
|
+
value: S,
|
|
31
|
+
wrapperClassName: j,
|
|
32
|
+
onValueChange: w
|
|
33
|
+
}) => {
|
|
34
|
+
const {
|
|
35
|
+
animationDirection: I,
|
|
36
|
+
groupRef: V,
|
|
37
|
+
id: a,
|
|
38
|
+
selected: n,
|
|
39
|
+
handleKeyDown: C,
|
|
40
|
+
handleSelect: F
|
|
41
|
+
} = A({
|
|
42
|
+
defaultValue: p,
|
|
43
|
+
disabled: t ?? void 0,
|
|
44
|
+
options: i,
|
|
45
|
+
value: S,
|
|
46
|
+
onValueChange: w
|
|
47
|
+
});
|
|
48
|
+
return /* @__PURE__ */ k(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
className: u(
|
|
52
|
+
z({ fullWidth: s }),
|
|
53
|
+
j
|
|
54
|
+
),
|
|
55
|
+
"data-theme": K,
|
|
56
|
+
children: [
|
|
57
|
+
o && /* @__PURE__ */ r(
|
|
58
|
+
E,
|
|
59
|
+
{
|
|
60
|
+
className: D,
|
|
61
|
+
htmlFor: a,
|
|
62
|
+
isRequired: b,
|
|
63
|
+
label: o,
|
|
64
|
+
requiredClassName: x
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ r(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
ref: V,
|
|
71
|
+
role: "radiogroup",
|
|
72
|
+
"aria-labelledby": o ? a : void 0,
|
|
73
|
+
className: u(q({ fullWidth: s, disabled: t }), l),
|
|
74
|
+
children: i.map((e, L) => {
|
|
75
|
+
const M = n === e.value, R = t || e.disabled, $ = !!e.description;
|
|
76
|
+
return /* @__PURE__ */ r(
|
|
77
|
+
H,
|
|
78
|
+
{
|
|
79
|
+
animationDirection: I,
|
|
80
|
+
className: y,
|
|
81
|
+
contentClassName: m,
|
|
82
|
+
descriptionClassName: c,
|
|
83
|
+
duration: d,
|
|
84
|
+
hasDescription: $,
|
|
85
|
+
index: L,
|
|
86
|
+
isDisabled: !!R,
|
|
87
|
+
isSelected: M,
|
|
88
|
+
labelClassName: B,
|
|
89
|
+
layoutId: `${a}-pill`,
|
|
90
|
+
option: e,
|
|
91
|
+
pillClassName: g,
|
|
92
|
+
value: e.value,
|
|
93
|
+
onKeyDown: C,
|
|
94
|
+
onSelect: F
|
|
95
|
+
},
|
|
96
|
+
e.value
|
|
97
|
+
);
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ r("input", { type: "hidden", name: N, value: n ?? "" }),
|
|
102
|
+
/* @__PURE__ */ r(
|
|
103
|
+
J,
|
|
104
|
+
{
|
|
105
|
+
error: v,
|
|
106
|
+
errorClassName: f,
|
|
107
|
+
helperText: G,
|
|
108
|
+
helperTextClassName: h
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
O.displayName = "KonstructButtonGroup";
|
|
116
|
+
export {
|
|
117
|
+
O as ButtonGroup
|
|
118
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { Theme } from '../../domain/theme';
|
|
4
|
+
import { buttonGroupVariants } from './ButtonGroup.variants';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for a single button option in the ButtonGroup.
|
|
7
|
+
*/
|
|
8
|
+
export type ButtonGroupOption = {
|
|
9
|
+
/** Optional description displayed below the label */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Whether this specific option is disabled */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Optional icon to display before the label */
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
/** The label text displayed for this option */
|
|
16
|
+
label: string;
|
|
17
|
+
/** The value associated with this option */
|
|
18
|
+
value: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Props for the ButtonGroup component.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Simple button group
|
|
26
|
+
* <ButtonGroup
|
|
27
|
+
* name="processor"
|
|
28
|
+
* options={[
|
|
29
|
+
* { value: 'cpu', label: 'CPU' },
|
|
30
|
+
* { value: 'gpu', label: 'GPU' },
|
|
31
|
+
* ]}
|
|
32
|
+
* defaultValue="cpu"
|
|
33
|
+
* onValueChange={(value) => setProcessor(value)}
|
|
34
|
+
* />
|
|
35
|
+
*
|
|
36
|
+
* // With descriptions
|
|
37
|
+
* <ButtonGroup
|
|
38
|
+
* name="instance-type"
|
|
39
|
+
* options={[
|
|
40
|
+
* { value: 'standard', label: 'Standard', description: 'Balanced compute resources' },
|
|
41
|
+
* { value: 'spot', label: 'Spot', description: 'Cost-effective for flexible workloads' },
|
|
42
|
+
* ]}
|
|
43
|
+
* onValueChange={setInstanceType}
|
|
44
|
+
* />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export type Props = VariantProps<typeof buttonGroupVariants> & {
|
|
48
|
+
/** CSS classes for the button group container */
|
|
49
|
+
className?: string;
|
|
50
|
+
/** CSS classes for the content wrapper inside each item */
|
|
51
|
+
contentClassName?: string;
|
|
52
|
+
/** Initially selected value (uncontrolled mode) */
|
|
53
|
+
defaultValue?: string;
|
|
54
|
+
/** CSS classes for description text */
|
|
55
|
+
descriptionClassName?: string;
|
|
56
|
+
/** Animation duration in seconds (default: 0.3) */
|
|
57
|
+
duration?: number;
|
|
58
|
+
/** Error message to display */
|
|
59
|
+
error?: string;
|
|
60
|
+
/** CSS classes for error message */
|
|
61
|
+
errorClassName?: string;
|
|
62
|
+
/** Helper text displayed below the button group */
|
|
63
|
+
helperText?: string;
|
|
64
|
+
/** CSS classes for helper text */
|
|
65
|
+
helperTextClassName?: string;
|
|
66
|
+
/** Whether the field is required */
|
|
67
|
+
isRequired?: boolean;
|
|
68
|
+
/** CSS classes for individual button items */
|
|
69
|
+
itemClassName?: string;
|
|
70
|
+
/** CSS classes for the label text inside items */
|
|
71
|
+
itemLabelClassName?: string;
|
|
72
|
+
/** Label displayed above the button group */
|
|
73
|
+
label?: string | ReactNode;
|
|
74
|
+
/** CSS classes for the label */
|
|
75
|
+
labelClassName?: string;
|
|
76
|
+
/** Form field name (required for form submission) */
|
|
77
|
+
name: string;
|
|
78
|
+
/** Array of button options */
|
|
79
|
+
options: ButtonGroupOption[];
|
|
80
|
+
/** CSS classes for the animated pill */
|
|
81
|
+
pillClassName?: string;
|
|
82
|
+
/** CSS classes for the required asterisk */
|
|
83
|
+
requiredClassName?: string;
|
|
84
|
+
/** Theme override for this component */
|
|
85
|
+
theme?: Theme;
|
|
86
|
+
/** Currently selected value (controlled mode) */
|
|
87
|
+
value?: string;
|
|
88
|
+
/** CSS classes for the outer wrapper */
|
|
89
|
+
wrapperClassName?: string;
|
|
90
|
+
/** Callback when selection changes */
|
|
91
|
+
onValueChange?: (value: string) => void;
|
|
92
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper variants for the outer container with label
|
|
3
|
+
*/
|
|
4
|
+
export declare const buttonGroupWrapperVariants: (props?: ({
|
|
5
|
+
fullWidth?: boolean | null | undefined;
|
|
6
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Group container variants - no outer border, just flex container
|
|
9
|
+
*/
|
|
10
|
+
export declare const buttonGroupVariants: (props?: ({
|
|
11
|
+
fullWidth?: boolean | null | undefined;
|
|
12
|
+
disabled?: boolean | null | undefined;
|
|
13
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { c as t } from "../../index-D29mdTf5.js";
|
|
2
|
+
const a = t(["flex", "flex-col", "gap-2"], {
|
|
3
|
+
variants: {
|
|
4
|
+
fullWidth: {
|
|
5
|
+
true: "w-full",
|
|
6
|
+
false: "w-fit"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
defaultVariants: {
|
|
10
|
+
fullWidth: !1
|
|
11
|
+
}
|
|
12
|
+
}), e = t(["inline-flex", "items-stretch"], {
|
|
13
|
+
variants: {
|
|
14
|
+
fullWidth: {
|
|
15
|
+
true: "w-full",
|
|
16
|
+
false: "w-fit"
|
|
17
|
+
},
|
|
18
|
+
disabled: {
|
|
19
|
+
true: "opacity-50 cursor-not-allowed",
|
|
20
|
+
false: ""
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
fullWidth: !1,
|
|
25
|
+
disabled: !1
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
e as buttonGroupVariants,
|
|
30
|
+
a as buttonGroupWrapperVariants
|
|
31
|
+
};
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { jsx as x, Fragment as X, jsxs as E } from "react/jsx-runtime";
|
|
2
|
+
import * as N from "react";
|
|
3
|
+
import { useId as D, useRef as I, useContext as O, useInsertionEffect as _, useMemo as k, Children as F, isValidElement as q, useState as H, memo as J } from "react";
|
|
4
|
+
import { cn as v } from "../../../../utils/index.js";
|
|
5
|
+
import { buttonGroupPillVariants as Q, buttonGroupLabelVariants as K, buttonGroupDescriptionVariants as Z, buttonGroupItemContentVariants as S, buttonGroupItemVariants as ee } from "./ButtonGroupItem.variants.js";
|
|
6
|
+
import { M as te, i as T, u as W, P as ne, a as se, b as re, L as oe, m as j } from "../../../../proxy-i19-YB39.js";
|
|
7
|
+
function A(e, s) {
|
|
8
|
+
if (typeof e == "function")
|
|
9
|
+
return e(s);
|
|
10
|
+
e != null && (e.current = s);
|
|
11
|
+
}
|
|
12
|
+
function ie(...e) {
|
|
13
|
+
return (s) => {
|
|
14
|
+
let t = !1;
|
|
15
|
+
const r = e.map((i) => {
|
|
16
|
+
const o = A(i, s);
|
|
17
|
+
return !t && typeof o == "function" && (t = !0), o;
|
|
18
|
+
});
|
|
19
|
+
if (t)
|
|
20
|
+
return () => {
|
|
21
|
+
for (let i = 0; i < r.length; i++) {
|
|
22
|
+
const o = r[i];
|
|
23
|
+
typeof o == "function" ? o() : A(e[i], null);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function ae(...e) {
|
|
29
|
+
return N.useCallback(ie(...e), e);
|
|
30
|
+
}
|
|
31
|
+
class ce extends N.Component {
|
|
32
|
+
getSnapshotBeforeUpdate(s) {
|
|
33
|
+
const t = this.props.childRef.current;
|
|
34
|
+
if (t && s.isPresent && !this.props.isPresent) {
|
|
35
|
+
const r = t.offsetParent, i = T(r) && r.offsetWidth || 0, o = T(r) && r.offsetHeight || 0, n = this.props.sizeRef.current;
|
|
36
|
+
n.height = t.offsetHeight || 0, n.width = t.offsetWidth || 0, n.top = t.offsetTop, n.left = t.offsetLeft, n.right = i - n.width - n.left, n.bottom = o - n.height - n.top;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Required with getSnapshotBeforeUpdate to stop React complaining.
|
|
42
|
+
*/
|
|
43
|
+
componentDidUpdate() {
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
return this.props.children;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function le({ children: e, isPresent: s, anchorX: t, anchorY: r, root: i }) {
|
|
50
|
+
const o = D(), n = I(null), m = I({
|
|
51
|
+
width: 0,
|
|
52
|
+
height: 0,
|
|
53
|
+
top: 0,
|
|
54
|
+
left: 0,
|
|
55
|
+
right: 0,
|
|
56
|
+
bottom: 0
|
|
57
|
+
}), { nonce: h } = O(te), b = e.props?.ref ?? e?.ref, l = ae(n, b);
|
|
58
|
+
return _(() => {
|
|
59
|
+
const { width: u, height: a, top: f, left: d, right: C, bottom: g } = m.current;
|
|
60
|
+
if (s || !n.current || !u || !a)
|
|
61
|
+
return;
|
|
62
|
+
const P = t === "left" ? `left: ${d}` : `right: ${C}`, $ = r === "bottom" ? `bottom: ${g}` : `top: ${f}`;
|
|
63
|
+
n.current.dataset.motionPopId = o;
|
|
64
|
+
const w = document.createElement("style");
|
|
65
|
+
h && (w.nonce = h);
|
|
66
|
+
const p = i ?? document.head;
|
|
67
|
+
return p.appendChild(w), w.sheet && w.sheet.insertRule(`
|
|
68
|
+
[data-motion-pop-id="${o}"] {
|
|
69
|
+
position: absolute !important;
|
|
70
|
+
width: ${u}px !important;
|
|
71
|
+
height: ${a}px !important;
|
|
72
|
+
${P}px !important;
|
|
73
|
+
${$}px !important;
|
|
74
|
+
}
|
|
75
|
+
`), () => {
|
|
76
|
+
p.contains(w) && p.removeChild(w);
|
|
77
|
+
};
|
|
78
|
+
}, [s]), x(ce, { isPresent: s, childRef: n, sizeRef: m, children: N.cloneElement(e, { ref: l }) });
|
|
79
|
+
}
|
|
80
|
+
const ue = ({ children: e, initial: s, isPresent: t, onExitComplete: r, custom: i, presenceAffectsLayout: o, mode: n, anchorX: m, anchorY: h, root: b }) => {
|
|
81
|
+
const l = W(fe), u = D();
|
|
82
|
+
let a = !0, f = k(() => (a = !1, {
|
|
83
|
+
id: u,
|
|
84
|
+
initial: s,
|
|
85
|
+
isPresent: t,
|
|
86
|
+
custom: i,
|
|
87
|
+
onExitComplete: (d) => {
|
|
88
|
+
l.set(d, !0);
|
|
89
|
+
for (const C of l.values())
|
|
90
|
+
if (!C)
|
|
91
|
+
return;
|
|
92
|
+
r && r();
|
|
93
|
+
},
|
|
94
|
+
register: (d) => (l.set(d, !1), () => l.delete(d))
|
|
95
|
+
}), [t, l, r]);
|
|
96
|
+
return o && a && (f = { ...f }), k(() => {
|
|
97
|
+
l.forEach((d, C) => l.set(C, !1));
|
|
98
|
+
}, [t]), N.useEffect(() => {
|
|
99
|
+
!t && !l.size && r && r();
|
|
100
|
+
}, [t]), n === "popLayout" && (e = x(le, { isPresent: t, anchorX: m, anchorY: h, root: b, children: e })), x(ne.Provider, { value: f, children: e });
|
|
101
|
+
};
|
|
102
|
+
function fe() {
|
|
103
|
+
return /* @__PURE__ */ new Map();
|
|
104
|
+
}
|
|
105
|
+
const L = (e) => e.key || "";
|
|
106
|
+
function B(e) {
|
|
107
|
+
const s = [];
|
|
108
|
+
return F.forEach(e, (t) => {
|
|
109
|
+
q(t) && s.push(t);
|
|
110
|
+
}), s;
|
|
111
|
+
}
|
|
112
|
+
const de = ({ children: e, custom: s, initial: t = !0, onExitComplete: r, presenceAffectsLayout: i = !0, mode: o = "sync", propagate: n = !1, anchorX: m = "left", anchorY: h = "top", root: b }) => {
|
|
113
|
+
const [l, u] = se(n), a = k(() => B(e), [e]), f = n && !l ? [] : a.map(L), d = I(!0), C = I(a), g = W(() => /* @__PURE__ */ new Map()), P = I(/* @__PURE__ */ new Set()), [$, w] = H(a), [p, V] = H(a);
|
|
114
|
+
re(() => {
|
|
115
|
+
d.current = !1, C.current = a;
|
|
116
|
+
for (let y = 0; y < p.length; y++) {
|
|
117
|
+
const c = L(p[y]);
|
|
118
|
+
f.includes(c) ? (g.delete(c), P.current.delete(c)) : g.get(c) !== !0 && g.set(c, !1);
|
|
119
|
+
}
|
|
120
|
+
}, [p, f.length, f.join("-")]);
|
|
121
|
+
const G = [];
|
|
122
|
+
if (a !== $) {
|
|
123
|
+
let y = [...a];
|
|
124
|
+
for (let c = 0; c < p.length; c++) {
|
|
125
|
+
const R = p[c], M = L(R);
|
|
126
|
+
f.includes(M) || (y.splice(c, 0, R), G.push(R));
|
|
127
|
+
}
|
|
128
|
+
return o === "wait" && G.length && (y = G), V(B(y)), w(a), null;
|
|
129
|
+
}
|
|
130
|
+
process.env.NODE_ENV !== "production" && o === "wait" && p.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
131
|
+
const { forceRender: Y } = O(oe);
|
|
132
|
+
return x(X, { children: p.map((y) => {
|
|
133
|
+
const c = L(y), R = n && !l ? !1 : a === p || f.includes(c), M = () => {
|
|
134
|
+
if (P.current.has(c))
|
|
135
|
+
return;
|
|
136
|
+
if (P.current.add(c), g.has(c))
|
|
137
|
+
g.set(c, !0);
|
|
138
|
+
else
|
|
139
|
+
return;
|
|
140
|
+
let z = !0;
|
|
141
|
+
g.forEach((U) => {
|
|
142
|
+
U || (z = !1);
|
|
143
|
+
}), z && (Y?.(), V(C.current), n && u?.(), r && r());
|
|
144
|
+
};
|
|
145
|
+
return x(ue, { isPresent: R, initial: !d.current || t ? void 0 : !1, custom: s, presenceAffectsLayout: i, mode: o, root: b, onExitComplete: R ? void 0 : M, anchorX: m, anchorY: h, children: y }, c);
|
|
146
|
+
}) });
|
|
147
|
+
}, pe = (e, s) => s === "none" ? e ? "inset(0 0 0 0)" : "inset(0 100% 0 0)" : e ? "inset(0 0 0 0)" : s === "right" ? "inset(0 0 0 100%)" : "inset(0 100% 0 0)", he = J(
|
|
148
|
+
({
|
|
149
|
+
animationDirection: e,
|
|
150
|
+
className: s,
|
|
151
|
+
contentClassName: t,
|
|
152
|
+
descriptionClassName: r,
|
|
153
|
+
duration: i = 0.3,
|
|
154
|
+
hasDescription: o,
|
|
155
|
+
index: n,
|
|
156
|
+
isDisabled: m,
|
|
157
|
+
isSelected: h,
|
|
158
|
+
labelClassName: b,
|
|
159
|
+
layoutId: l,
|
|
160
|
+
option: u,
|
|
161
|
+
pillClassName: a,
|
|
162
|
+
value: f,
|
|
163
|
+
onKeyDown: d,
|
|
164
|
+
onSelect: C
|
|
165
|
+
}) => /* @__PURE__ */ E(
|
|
166
|
+
"button",
|
|
167
|
+
{
|
|
168
|
+
type: "button",
|
|
169
|
+
role: "radio",
|
|
170
|
+
"aria-checked": h,
|
|
171
|
+
"data-value": u.value,
|
|
172
|
+
disabled: m,
|
|
173
|
+
tabIndex: h || n === 0 ? 0 : -1,
|
|
174
|
+
onClick: () => !m && C(f),
|
|
175
|
+
onKeyDown: (g) => d(g, n),
|
|
176
|
+
className: v(
|
|
177
|
+
ee({ disabled: m }),
|
|
178
|
+
"relative",
|
|
179
|
+
s
|
|
180
|
+
),
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ x(de, { mode: "popLayout", initial: !1, children: h && /* @__PURE__ */ x(
|
|
183
|
+
j.div,
|
|
184
|
+
{
|
|
185
|
+
layoutId: l,
|
|
186
|
+
className: v(Q(), a),
|
|
187
|
+
transition: {
|
|
188
|
+
type: "tween",
|
|
189
|
+
ease: "easeInOut",
|
|
190
|
+
duration: i
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
) }),
|
|
194
|
+
/* @__PURE__ */ E(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
className: v(
|
|
198
|
+
S({ hasDescription: o }),
|
|
199
|
+
"relative z-10",
|
|
200
|
+
t
|
|
201
|
+
),
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ E("span", { className: "relative", children: [
|
|
204
|
+
/* @__PURE__ */ E(
|
|
205
|
+
"span",
|
|
206
|
+
{
|
|
207
|
+
className: v(
|
|
208
|
+
K({ selected: !1 }),
|
|
209
|
+
b
|
|
210
|
+
),
|
|
211
|
+
children: [
|
|
212
|
+
u.icon,
|
|
213
|
+
u.label
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ E(
|
|
218
|
+
j.span,
|
|
219
|
+
{
|
|
220
|
+
className: v(
|
|
221
|
+
K({ selected: !0 }),
|
|
222
|
+
"absolute inset-0",
|
|
223
|
+
b
|
|
224
|
+
),
|
|
225
|
+
"aria-hidden": "true",
|
|
226
|
+
initial: !1,
|
|
227
|
+
animate: {
|
|
228
|
+
clipPath: pe(h, e)
|
|
229
|
+
},
|
|
230
|
+
transition: {
|
|
231
|
+
type: "tween",
|
|
232
|
+
ease: "easeInOut",
|
|
233
|
+
duration: i
|
|
234
|
+
},
|
|
235
|
+
children: [
|
|
236
|
+
u.icon,
|
|
237
|
+
u.label
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
] }),
|
|
242
|
+
u.description && /* @__PURE__ */ x(
|
|
243
|
+
"span",
|
|
244
|
+
{
|
|
245
|
+
className: v(
|
|
246
|
+
Z(),
|
|
247
|
+
r
|
|
248
|
+
),
|
|
249
|
+
children: u.description
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
u.value
|
|
258
|
+
)
|
|
259
|
+
);
|
|
260
|
+
he.displayName = "KonstructButtonGroupItem";
|
|
261
|
+
export {
|
|
262
|
+
he as ButtonGroupItem
|
|
263
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
import { ButtonGroupOption } from '../../ButtonGroup.types';
|
|
3
|
+
import { AnimationDirection } from '../../hooks';
|
|
4
|
+
export type Props = {
|
|
5
|
+
animationDirection: AnimationDirection;
|
|
6
|
+
className?: string;
|
|
7
|
+
contentClassName?: string;
|
|
8
|
+
descriptionClassName?: string;
|
|
9
|
+
duration?: number;
|
|
10
|
+
hasDescription: boolean;
|
|
11
|
+
index: number;
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
isSelected: boolean;
|
|
14
|
+
labelClassName?: string;
|
|
15
|
+
layoutId: string;
|
|
16
|
+
option: ButtonGroupOption;
|
|
17
|
+
pillClassName?: string;
|
|
18
|
+
value: string;
|
|
19
|
+
onKeyDown: (event: KeyboardEvent<HTMLButtonElement>, index: number) => void;
|
|
20
|
+
onSelect: (value: string) => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Individual button item variants - outer container with borders
|
|
3
|
+
*/
|
|
4
|
+
export declare const buttonGroupItemVariants: (props?: ({
|
|
5
|
+
disabled?: boolean | null | undefined;
|
|
6
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Animated pill background (selected state indicator)
|
|
9
|
+
*/
|
|
10
|
+
export declare const buttonGroupPillVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Inner content container (the content layer above the pill)
|
|
13
|
+
*/
|
|
14
|
+
export declare const buttonGroupItemContentVariants: (props?: ({
|
|
15
|
+
hasDescription?: boolean | null | undefined;
|
|
16
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Label text variants inside button item
|
|
19
|
+
*/
|
|
20
|
+
export declare const buttonGroupLabelVariants: (props?: ({
|
|
21
|
+
selected?: boolean | null | undefined;
|
|
22
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Description text variants inside button item
|
|
25
|
+
*/
|
|
26
|
+
export declare const buttonGroupDescriptionVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|