@skeletonlabs/skeleton-react 1.5.0-next.0 → 2.0.0-next.2
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/accordion/anatomy/accordion-content.d.ts +9 -0
- package/dist/components/accordion/anatomy/accordion-content.js +24 -0
- package/dist/components/accordion/anatomy/accordion-heading.d.ts +16 -0
- package/dist/components/accordion/anatomy/accordion-heading.js +17 -0
- package/dist/components/accordion/anatomy/accordion-indicator.d.ts +9 -0
- package/dist/components/accordion/anatomy/accordion-indicator.js +21 -0
- package/dist/components/accordion/anatomy/accordion-item-context.d.ts +10 -0
- package/dist/components/accordion/anatomy/accordion-item-context.js +11 -0
- package/dist/components/accordion/anatomy/accordion-item.d.ts +10 -0
- package/dist/components/accordion/anatomy/accordion-item.js +28 -0
- package/dist/components/accordion/anatomy/accordion-root-context.d.ts +10 -0
- package/dist/components/accordion/anatomy/accordion-root-context.js +11 -0
- package/dist/components/accordion/anatomy/accordion-root.d.ts +10 -0
- package/dist/components/accordion/anatomy/accordion-root.js +28 -0
- package/dist/components/accordion/anatomy/accordion-trigger.d.ts +9 -0
- package/dist/components/accordion/anatomy/accordion-trigger.js +21 -0
- package/dist/components/accordion/index.js +3 -0
- package/dist/components/accordion/modules/accordion-anatomy.d.ts +21 -0
- package/dist/components/accordion/modules/accordion-anatomy.js +22 -0
- package/dist/components/accordion/modules/accordion-item-context.d.ts +10 -0
- package/dist/components/accordion/modules/accordion-item-context.js +7 -0
- package/dist/components/accordion/modules/accordion-root-context.d.ts +9 -0
- package/dist/components/accordion/modules/accordion-root-context.js +7 -0
- package/dist/components/avatar/anatomy/avatar-fallback.d.ts +9 -0
- package/dist/components/avatar/anatomy/avatar-fallback.js +22 -0
- package/dist/components/avatar/anatomy/avatar-image.d.ts +9 -0
- package/dist/components/avatar/anatomy/avatar-image.js +19 -0
- package/dist/components/avatar/anatomy/avatar-root-context.d.ts +10 -0
- package/dist/components/avatar/anatomy/avatar-root-context.js +11 -0
- package/dist/components/avatar/anatomy/avatar-root.d.ts +10 -0
- package/dist/components/avatar/anatomy/avatar-root.js +31 -0
- package/dist/components/avatar/index.js +3 -0
- package/dist/components/avatar/modules/avatar-anatomy.d.ts +13 -0
- package/dist/components/avatar/modules/avatar-anatomy.js +14 -0
- package/dist/components/avatar/modules/avatar-root-context.d.ts +9 -0
- package/dist/components/avatar/modules/avatar-root-context.js +7 -0
- package/dist/components/rating-group/anatomy/rating-group-control.d.ts +9 -0
- package/dist/components/rating-group/anatomy/rating-group-control.js +19 -0
- package/dist/components/rating-group/anatomy/rating-group-hidden-input.d.ts +9 -0
- package/dist/components/rating-group/anatomy/rating-group-hidden-input.js +16 -0
- package/dist/components/rating-group/anatomy/rating-group-item-context.d.ts +10 -0
- package/dist/components/rating-group/anatomy/rating-group-item-context.js +11 -0
- package/dist/components/rating-group/anatomy/rating-group-item.d.ts +29 -0
- package/dist/components/rating-group/anatomy/rating-group-item.js +29 -0
- package/dist/components/rating-group/anatomy/rating-group-label.d.ts +9 -0
- package/dist/components/rating-group/anatomy/rating-group-label.js +19 -0
- package/dist/components/rating-group/anatomy/rating-group-root-context.d.ts +10 -0
- package/dist/components/rating-group/anatomy/rating-group-root-context.js +11 -0
- package/dist/components/rating-group/anatomy/rating-group-root.d.ts +10 -0
- package/dist/components/rating-group/anatomy/rating-group-root.js +28 -0
- package/dist/components/rating-group/index.js +3 -0
- package/dist/components/rating-group/modules/rating-group-anatomy.d.ts +19 -0
- package/dist/components/rating-group/modules/rating-group-anatomy.js +20 -0
- package/dist/components/rating-group/modules/rating-group-item-context.d.ts +9 -0
- package/dist/components/rating-group/modules/rating-group-item-context.js +7 -0
- package/dist/components/rating-group/modules/rating-group-root-context.d.ts +9 -0
- package/dist/components/rating-group/modules/rating-group-root-context.js +7 -0
- package/dist/components/tabs/anatomy/tabs-content.d.ts +10 -0
- package/dist/components/tabs/anatomy/tabs-content.js +21 -0
- package/dist/components/tabs/anatomy/tabs-indicator.d.ts +9 -0
- package/dist/components/tabs/anatomy/tabs-indicator.js +16 -0
- package/dist/components/tabs/anatomy/tabs-list.d.ts +9 -0
- package/dist/components/tabs/anatomy/tabs-list.js +19 -0
- package/dist/components/tabs/anatomy/tabs-root-context.d.ts +10 -0
- package/dist/components/tabs/anatomy/tabs-root-context.js +11 -0
- package/dist/components/tabs/anatomy/tabs-root.d.ts +10 -0
- package/dist/components/tabs/anatomy/tabs-root.js +28 -0
- package/dist/components/tabs/anatomy/tabs-trigger.d.ts +10 -0
- package/dist/components/tabs/anatomy/tabs-trigger.js +21 -0
- package/dist/components/tabs/index.js +3 -0
- package/dist/components/tabs/modules/tabs-anatomy.d.ts +17 -0
- package/dist/components/tabs/modules/tabs-anatomy.js +18 -0
- package/dist/components/tabs/modules/tabs-root-context.d.ts +9 -0
- package/dist/components/tabs/modules/tabs-root-context.js +7 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +36 -17
- package/dist/index.js +10 -17
- package/dist/internal/components/star-empty.js +22 -0
- package/dist/internal/components/star-full.js +20 -0
- package/dist/internal/components/star-half.js +36 -0
- package/dist/internal/props-with-element.d.ts +13 -0
- package/package.json +30 -33
- package/dist/components/Accordion/Accordion.d.ts +0 -7
- package/dist/components/Accordion/Accordion.js +0 -62
- package/dist/components/Accordion/context.d.ts +0 -4
- package/dist/components/Accordion/context.js +0 -10
- package/dist/components/Accordion/types.d.ts +0 -73
- package/dist/components/Accordion/types.js +0 -2
- package/dist/components/AppBar/AppBar.d.ts +0 -9
- package/dist/components/AppBar/AppBar.js +0 -52
- package/dist/components/AppBar/types.d.ts +0 -63
- package/dist/components/AppBar/types.js +0 -1
- package/dist/components/Avatar/Avatar.d.ts +0 -3
- package/dist/components/Avatar/Avatar.js +0 -28
- package/dist/components/Avatar/types.d.ts +0 -36
- package/dist/components/Avatar/types.js +0 -1
- package/dist/components/FileUpload/FileUpload.d.ts +0 -3
- package/dist/components/FileUpload/FileUpload.js +0 -41
- package/dist/components/FileUpload/types.d.ts +0 -73
- package/dist/components/FileUpload/types.js +0 -1
- package/dist/components/Navigation/Navigation.d.ts +0 -10
- package/dist/components/Navigation/Navigation.js +0 -92
- package/dist/components/Navigation/context.d.ts +0 -2
- package/dist/components/Navigation/context.js +0 -7
- package/dist/components/Navigation/types.d.ts +0 -132
- package/dist/components/Navigation/types.js +0 -2
- package/dist/components/Pagination/Pagination.d.ts +0 -3
- package/dist/components/Pagination/Pagination.js +0 -39
- package/dist/components/Pagination/types.d.ts +0 -56
- package/dist/components/Pagination/types.js +0 -1
- package/dist/components/Progress/Progress.d.ts +0 -3
- package/dist/components/Progress/Progress.js +0 -28
- package/dist/components/Progress/types.d.ts +0 -44
- package/dist/components/Progress/types.js +0 -1
- package/dist/components/ProgressRing/ProgressRing.d.ts +0 -3
- package/dist/components/ProgressRing/ProgressRing.js +0 -34
- package/dist/components/ProgressRing/types.d.ts +0 -53
- package/dist/components/ProgressRing/types.js +0 -1
- package/dist/components/Rating/Rating.d.ts +0 -3
- package/dist/components/Rating/Rating.js +0 -50
- package/dist/components/Rating/types.d.ts +0 -36
- package/dist/components/Rating/types.js +0 -1
- package/dist/components/Segment/Segment.d.ts +0 -5
- package/dist/components/Segment/Segment.js +0 -58
- package/dist/components/Segment/context.d.ts +0 -2
- package/dist/components/Segment/context.js +0 -5
- package/dist/components/Segment/types.d.ts +0 -59
- package/dist/components/Segment/types.js +0 -2
- package/dist/components/Slider/Slider.d.ts +0 -3
- package/dist/components/Slider/Slider.js +0 -39
- package/dist/components/Slider/types.d.ts +0 -66
- package/dist/components/Slider/types.js +0 -1
- package/dist/components/Switch/Switch.d.ts +0 -3
- package/dist/components/Switch/Switch.js +0 -40
- package/dist/components/Switch/types.d.ts +0 -62
- package/dist/components/Switch/types.js +0 -1
- package/dist/components/Tabs/Tabs.d.ts +0 -12
- package/dist/components/Tabs/Tabs.js +0 -80
- package/dist/components/Tabs/context.d.ts +0 -2
- package/dist/components/Tabs/context.js +0 -5
- package/dist/components/Tabs/types.d.ts +0 -64
- package/dist/components/Tabs/types.js +0 -1
- package/dist/components/TagsInput/TagsInput.d.ts +0 -3
- package/dist/components/TagsInput/TagsInput.js +0 -39
- package/dist/components/TagsInput/types.d.ts +0 -40
- package/dist/components/TagsInput/types.js +0 -1
- package/dist/components/Toast/Toast.d.ts +0 -2
- package/dist/components/Toast/Toast.js +0 -49
- package/dist/components/Toast/Toaster.d.ts +0 -2
- package/dist/components/Toast/Toaster.js +0 -28
- package/dist/components/Toast/create-toaster.d.ts +0 -2
- package/dist/components/Toast/create-toaster.js +0 -4
- package/dist/components/Toast/types.d.ts +0 -46
- package/dist/components/Toast/types.js +0 -1
- package/dist/composed/accordion/anatomy/accordion-content.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-content.js +0 -15
- package/dist/composed/accordion/anatomy/accordion-heading.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-heading.js +0 -11
- package/dist/composed/accordion/anatomy/accordion-indicator.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-indicator.js +0 -14
- package/dist/composed/accordion/anatomy/accordion-item.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-item.js +0 -16
- package/dist/composed/accordion/anatomy/accordion-root.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-root.js +0 -20
- package/dist/composed/accordion/anatomy/accordion-trigger.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-trigger.js +0 -15
- package/dist/composed/accordion/index.d.ts +0 -2
- package/dist/composed/accordion/index.js +0 -2
- package/dist/composed/accordion/modules/anatomy.d.ts +0 -14
- package/dist/composed/accordion/modules/anatomy.js +0 -14
- package/dist/composed/accordion/modules/context.d.ts +0 -4
- package/dist/composed/accordion/modules/context.js +0 -5
- package/dist/composed/accordion/modules/types.d.ts +0 -28
- package/dist/composed/accordion/modules/types.js +0 -1
- package/dist/composed/avatar/anatomy/avatar-fallback.d.ts +0 -2
- package/dist/composed/avatar/anatomy/avatar-fallback.js +0 -14
- package/dist/composed/avatar/anatomy/avatar-image.d.ts +0 -2
- package/dist/composed/avatar/anatomy/avatar-image.js +0 -14
- package/dist/composed/avatar/anatomy/avatar-root.d.ts +0 -2
- package/dist/composed/avatar/anatomy/avatar-root.js +0 -20
- package/dist/composed/avatar/index.d.ts +0 -2
- package/dist/composed/avatar/index.js +0 -2
- package/dist/composed/avatar/modules/anatomy.d.ts +0 -8
- package/dist/composed/avatar/modules/anatomy.js +0 -8
- package/dist/composed/avatar/modules/context.d.ts +0 -3
- package/dist/composed/avatar/modules/context.js +0 -3
- package/dist/composed/avatar/modules/types.d.ts +0 -13
- package/dist/composed/avatar/modules/types.js +0 -1
- package/dist/composed/index.d.ts +0 -2
- package/dist/composed/index.js +0 -2
- package/dist/internal/props-with-child.d.ts +0 -7
- package/dist/internal/props-with-child.js +0 -1
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as rating from '@zag-js/rating-group';
|
|
4
|
-
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
5
|
-
import { useId } from 'react';
|
|
6
|
-
const starEmpty = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", height: "24", width: "24", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z" }) }));
|
|
7
|
-
const starHalf = (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", height: "24", width: "24", children: [_jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z" }), _jsx("defs", { children: _jsxs("linearGradient", { id: "half-fill", children: [_jsx("stop", { offset: "50%", stopColor: "currentColor" }), _jsx("stop", { offset: "50%", stopColor: "transparent" })] }) }), _jsx("path", { fill: "url(#half-fill)", d: "M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z" })] }));
|
|
8
|
-
const starFull = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", height: "24", width: "24", children: _jsx("path", { fillRule: "evenodd", d: "M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z", clipRule: "evenodd" }) }));
|
|
9
|
-
export const Rating = ({
|
|
10
|
-
// Root
|
|
11
|
-
base = '', classes = '',
|
|
12
|
-
// Control
|
|
13
|
-
controlBase = 'flex', controlGap = 'gap-2', controlClasses,
|
|
14
|
-
// Label
|
|
15
|
-
labelBase = 'label-text', labelClasses = '',
|
|
16
|
-
// Item
|
|
17
|
-
itemBase = 'cursor-pointer', itemClasses = '',
|
|
18
|
-
// State
|
|
19
|
-
stateReadOnly = '', stateDisabled = 'cursor-not-allowed opacity-50',
|
|
20
|
-
// Icons
|
|
21
|
-
iconEmpty = starEmpty, iconHalf = starHalf, iconFull = starFull,
|
|
22
|
-
// Children
|
|
23
|
-
label,
|
|
24
|
-
// Zag
|
|
25
|
-
...zagProps }) => {
|
|
26
|
-
// Zag
|
|
27
|
-
const service = useMachine(rating.machine, {
|
|
28
|
-
id: useId(),
|
|
29
|
-
...zagProps
|
|
30
|
-
});
|
|
31
|
-
const api = rating.connect(service, normalizeProps);
|
|
32
|
-
// Reactive
|
|
33
|
-
const rxReadOnly = service.prop('readOnly') ? stateReadOnly : '';
|
|
34
|
-
const rxDisabled = service.prop('disabled') ? stateDisabled : '';
|
|
35
|
-
return (_jsxs("div", { ...api.getRootProps(), className: `${base} ${classes}`, "data-testid": "rating", children: [!!label && (_jsx("label", { ...api.getLabelProps(), className: `${labelBase} ${labelClasses}`, "data-testid": "rating-label", children: label })), _jsx("div", { ...api.getControlProps(), className: `${controlBase} ${controlGap} ${rxReadOnly} ${rxDisabled} ${controlClasses}`, "data-testid": "rating-control", children: api.items.map((item) => {
|
|
36
|
-
const itemState = api.getItemState({ index: item });
|
|
37
|
-
const icon = (() => {
|
|
38
|
-
if (!itemState.highlighted) {
|
|
39
|
-
return iconEmpty;
|
|
40
|
-
}
|
|
41
|
-
else if (itemState.half) {
|
|
42
|
-
return iconHalf;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
return iconFull;
|
|
46
|
-
}
|
|
47
|
-
})();
|
|
48
|
-
return (_jsx("span", { ...api.getItemProps({ index: item }), className: `${itemBase} ${itemClasses}`, "data-testid": "rating-item", children: icon }, item));
|
|
49
|
-
}) }), _jsx("input", { ...api.getHiddenInputProps(), "data-testid": "rating-input" })] }));
|
|
50
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as rating from '@zag-js/rating-group';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
export interface RatingProps extends Omit<rating.Props, 'id'> {
|
|
4
|
-
/** Set root base classes */
|
|
5
|
-
base?: string;
|
|
6
|
-
/** Set root gap classes */
|
|
7
|
-
gap?: string;
|
|
8
|
-
/** Set root arbitrary classes */
|
|
9
|
-
classes?: string;
|
|
10
|
-
/** Set control base classes */
|
|
11
|
-
controlBase?: string;
|
|
12
|
-
/** Set control gap classes */
|
|
13
|
-
controlGap?: string;
|
|
14
|
-
/** Set control arbitrary classes */
|
|
15
|
-
controlClasses?: string;
|
|
16
|
-
/** Set label base classes */
|
|
17
|
-
labelBase?: string;
|
|
18
|
-
/** Set label arbitrary classes */
|
|
19
|
-
labelClasses?: string;
|
|
20
|
-
/** Set item base classes */
|
|
21
|
-
itemBase?: string;
|
|
22
|
-
/** Set item arbitrary classes */
|
|
23
|
-
itemClasses?: string;
|
|
24
|
-
/** Set item read-only state classes */
|
|
25
|
-
stateReadOnly?: string;
|
|
26
|
-
/** Set item disabled state classes */
|
|
27
|
-
stateDisabled?: string;
|
|
28
|
-
/** Set the empty icon node */
|
|
29
|
-
iconEmpty?: ReactNode;
|
|
30
|
-
/** Set the half icon node */
|
|
31
|
-
iconHalf?: ReactNode;
|
|
32
|
-
/** Set the full icon node */
|
|
33
|
-
iconFull?: ReactNode;
|
|
34
|
-
/** Set the label node */
|
|
35
|
-
label?: ReactNode;
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as rating from '@zag-js/rating-group';
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useContext, useId } from 'react';
|
|
4
|
-
import * as radio from '@zag-js/radio-group';
|
|
5
|
-
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
-
import { SegmentContext } from './context.js';
|
|
7
|
-
// Components ---
|
|
8
|
-
const SegmentRoot = ({
|
|
9
|
-
// Root
|
|
10
|
-
base = 'inline-flex items-stretch overflow-hidden', background = 'preset-outlined-surface-200-800', border = '', gap = 'gap-2', padding = 'p-2', rounded = 'rounded-container', width = '', classes = '',
|
|
11
|
-
// States
|
|
12
|
-
orientVertical = 'flex-col items-stretch', orientHorizontal = 'flex-row', stateDisabled = 'disabled', stateReadOnly = 'pointer-events-none',
|
|
13
|
-
// Indicator
|
|
14
|
-
indicatorBase = 'top-[var(--top)] left-[var(--left)] w-[var(--width)] h-[var(--height)]', indicatorBg = 'preset-filled', indicatorText = 'text-surface-contrast-950 dark:text-surface-contrast-50', indicatorRounded = 'rounded-base', indicatorClasses = '',
|
|
15
|
-
// Label
|
|
16
|
-
labelledby = '',
|
|
17
|
-
// Children
|
|
18
|
-
children,
|
|
19
|
-
// Zag
|
|
20
|
-
...zagProps }) => {
|
|
21
|
-
// Zag
|
|
22
|
-
const service = useMachine(radio.machine, {
|
|
23
|
-
id: useId(),
|
|
24
|
-
orientation: zagProps.orientation ?? 'horizontal',
|
|
25
|
-
...zagProps
|
|
26
|
-
});
|
|
27
|
-
const api = radio.connect(service, normalizeProps);
|
|
28
|
-
// Set Context
|
|
29
|
-
const ctx = { api, indicatorText };
|
|
30
|
-
// Reactive
|
|
31
|
-
const rxOrientation = service.prop('orientation') === 'vertical' ? orientVertical : orientHorizontal;
|
|
32
|
-
const rxDisabled = service.prop('disabled') ? stateDisabled : '';
|
|
33
|
-
const rxReadOnly = service.prop('readOnly') ? stateReadOnly : '';
|
|
34
|
-
return (_jsxs("div", { ...api.getRootProps(), className: `${base} ${rxOrientation} ${background} ${border} ${padding} ${gap} ${rounded} ${width} ${rxDisabled} ${rxReadOnly} ${classes}`, "data-testid": "segment", "aria-labelledby": labelledby, children: [_jsx("div", { ...api.getIndicatorProps(), className: `${indicatorBase} ${indicatorBg} ${indicatorRounded} ${indicatorClasses}`, "data-testid": "segment-indicator" }), _jsx(SegmentContext.Provider, { value: ctx, children: children })] }));
|
|
35
|
-
};
|
|
36
|
-
const SegmentItem = ({
|
|
37
|
-
// Root
|
|
38
|
-
base = 'btn cursor-pointer z-[1]', classes = '',
|
|
39
|
-
// Label
|
|
40
|
-
labelBase = 'pointer-events-none transition-colors duration-100', labelClasses = '',
|
|
41
|
-
// State
|
|
42
|
-
stateDisabled = 'disabled', stateFocused = 'focused',
|
|
43
|
-
// Children
|
|
44
|
-
children,
|
|
45
|
-
// Zag
|
|
46
|
-
...zagProps }) => {
|
|
47
|
-
// Get Context
|
|
48
|
-
const ctx = useContext(SegmentContext);
|
|
49
|
-
const state = ctx.api.getItemState(zagProps);
|
|
50
|
-
// Reactive
|
|
51
|
-
const rxDisabled = state.disabled ? stateDisabled : '';
|
|
52
|
-
const rxActiveText = state.checked ? ctx.indicatorText : '';
|
|
53
|
-
const rxFocused = state.focused ? stateFocused : '';
|
|
54
|
-
return (_jsxs("label", { ...ctx.api.getItemProps(zagProps), className: `${base} ${rxDisabled} ${rxFocused} ${classes}`, "data-testid": "segment-item", children: [_jsx("span", { ...ctx.api.getItemTextProps(zagProps), className: `${labelBase} ${rxActiveText} ${labelClasses}`, "data-testid": "segment-item-label", children: children }), _jsx("input", { ...ctx.api.getItemHiddenInputProps(zagProps), "data-testid": "segment-item-input" })] }));
|
|
55
|
-
};
|
|
56
|
-
export const Segment = /* @__PURE__ */ Object.assign(SegmentRoot, {
|
|
57
|
-
Item: SegmentItem
|
|
58
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type * as radio from '@zag-js/radio-group';
|
|
2
|
-
export interface SegmentContextState {
|
|
3
|
-
api: ReturnType<typeof radio.connect>;
|
|
4
|
-
indicatorText: string;
|
|
5
|
-
}
|
|
6
|
-
export interface SegmentProps extends React.PropsWithChildren, Omit<radio.Props, 'id'> {
|
|
7
|
-
/** Sets base classes. */
|
|
8
|
-
base?: string;
|
|
9
|
-
/** Set background classes. */
|
|
10
|
-
background?: string;
|
|
11
|
-
/** Set border classes. */
|
|
12
|
-
border?: string;
|
|
13
|
-
/** Set flex direction classes. */
|
|
14
|
-
flexDirection?: string;
|
|
15
|
-
/** Set gap classes. */
|
|
16
|
-
gap?: string;
|
|
17
|
-
/** Set padding classes. */
|
|
18
|
-
padding?: string;
|
|
19
|
-
/** Set rounded classes. */
|
|
20
|
-
rounded?: string;
|
|
21
|
-
/** Set width classes. */
|
|
22
|
-
width?: string;
|
|
23
|
-
/** Provide arbitrary CSS classes. */
|
|
24
|
-
classes?: string;
|
|
25
|
-
/** Set classes to provide a vertical layout. */
|
|
26
|
-
orientVertical?: string;
|
|
27
|
-
/** Set classes to provide a horizontal layout. */
|
|
28
|
-
orientHorizontal?: string;
|
|
29
|
-
/** Set classes for the disabled state. */
|
|
30
|
-
stateDisabled?: string;
|
|
31
|
-
/** Set classes for the read-only state. */
|
|
32
|
-
stateReadOnly?: string;
|
|
33
|
-
/** Sets base classes to the indicator. */
|
|
34
|
-
indicatorBase?: string;
|
|
35
|
-
/** Sets background classes to the indicator. */
|
|
36
|
-
indicatorBg?: string;
|
|
37
|
-
/** Sets text classes to the indicator. */
|
|
38
|
-
indicatorText?: string;
|
|
39
|
-
/** Sets border radius classes to the indicator. */
|
|
40
|
-
indicatorRounded?: string;
|
|
41
|
-
/** Provide arbitrary CSS classes to the indicator. */
|
|
42
|
-
indicatorClasses?: string;
|
|
43
|
-
/** Set aria-labelledby for element */
|
|
44
|
-
labelledby?: string;
|
|
45
|
-
}
|
|
46
|
-
export interface SegmentItemsProps extends React.PropsWithChildren, Omit<radio.ItemProps, 'invalid'> {
|
|
47
|
-
/** Sets base classes. */
|
|
48
|
-
base?: string;
|
|
49
|
-
/** Provide arbitrary CSS classes. */
|
|
50
|
-
classes?: string;
|
|
51
|
-
/** Set classes for the disabled state. */
|
|
52
|
-
stateDisabled?: string;
|
|
53
|
-
/** Set classes for the focus state. */
|
|
54
|
-
stateFocused?: string;
|
|
55
|
-
/** Sets base classes for the label element. */
|
|
56
|
-
labelBase?: string;
|
|
57
|
-
/** Provide arbitrary CSS classes for the label element. */
|
|
58
|
-
labelClasses?: string;
|
|
59
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useId } from 'react';
|
|
4
|
-
import * as slider from '@zag-js/slider';
|
|
5
|
-
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
-
export const Slider = ({ height = 'h-1.5', markers = [],
|
|
7
|
-
// Root ---
|
|
8
|
-
base = 'w-full', classes = '',
|
|
9
|
-
// Control ---
|
|
10
|
-
controlBase = '', controlClasses = '',
|
|
11
|
-
// Track ---
|
|
12
|
-
trackBase = 'overflow-hidden', trackBg = 'bg-surface-200-800', trackRounded = 'rounded-full', trackClasses = '',
|
|
13
|
-
// Meter ---
|
|
14
|
-
meterBase = '', meterBg = 'bg-surface-950-50', meterRounded = 'rounded-container', meterClasses = '',
|
|
15
|
-
// Thumb ---
|
|
16
|
-
thumbBase = 'ring-inset transition-scale duration-100 ease-in-out', thumbSize = 'size-8 md:size-5', thumbBg = 'bg-surface-50-950', thumbRingSize = 'ring-2', thumbRingColor = 'ring-surface-950-50', thumbRounded = 'rounded-full', thumbCursor = 'hover:cursor-pointer', thumbClasses = '',
|
|
17
|
-
// Markers ---
|
|
18
|
-
markersBase = '', markersClasses = '',
|
|
19
|
-
// Mark ---
|
|
20
|
-
markBase = '', markText = 'text-[10px]', markOpacity = 'opacity-50', markClasses = '',
|
|
21
|
-
// State ---
|
|
22
|
-
stateDisabled = 'disabled', stateReadOnly = 'cursor-not-allowed',
|
|
23
|
-
// Children ---
|
|
24
|
-
mark,
|
|
25
|
-
// Zag ---
|
|
26
|
-
...zagProps }) => {
|
|
27
|
-
// Zag
|
|
28
|
-
const service = useMachine(slider.machine, {
|
|
29
|
-
id: useId(),
|
|
30
|
-
...zagProps
|
|
31
|
-
});
|
|
32
|
-
const api = slider.connect(service, normalizeProps);
|
|
33
|
-
// Reactive
|
|
34
|
-
const rxDisabled = service.prop('disabled') ? stateDisabled : '';
|
|
35
|
-
const rxReadOnly = service.prop('readOnly') ? stateReadOnly : thumbCursor;
|
|
36
|
-
return (_jsxs("div", { ...api.getRootProps(), className: `${base} ${height} ${rxDisabled} ${classes}`, "data-testid": "slider", children: [_jsxs("div", { ...api.getControlProps(), className: `${controlBase} ${controlClasses}`, "data-testid": "slider-control", children: [_jsx("div", { ...api.getTrackProps(), className: `${trackBase} ${trackBg} ${height} ${trackRounded} ${trackClasses}`, "data-testid": "slider-track", children: _jsx("div", { ...api.getRangeProps(), className: `${meterBase} ${height} ${meterBg} ${meterRounded} ${meterClasses}`, "data-testid": "slider-meter" }) }), _jsx("div", { className: `${height}`, style: { display: 'flex', alignItems: 'center', transform: 'translateY(-100%)' }, "data-testid": "slider-thumb-wrapper", children: api.value.map((_, index) => (_jsxs("div", { ...api.getThumbProps({ index }), children: [_jsx("div", { className: `${thumbBase} ${thumbSize} ${thumbBg} ${thumbRingSize} ${thumbRingColor} ${thumbRounded} ${rxReadOnly} ${thumbClasses}`, "data-testid": "slider-thumb" }), _jsx("input", { ...api.getHiddenInputProps({ index }), "data-testid": "slider-input" })] }, index))) })] }), markers.length > 0 && (_jsx("div", { ...api.getMarkerGroupProps(), className: `${markersBase} ${markersClasses}`, "data-testid": "slider-markers", children: markers.map((value) => (
|
|
37
|
-
// Mark
|
|
38
|
-
_jsx("span", { ...api.getMarkerProps({ value }), className: `${markBase} ${markText} ${markOpacity} ${markClasses}`, "data-testid": "slider-mark", children: mark ? mark : value }, value))) }))] }));
|
|
39
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import * as slider from '@zag-js/slider';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
export interface SliderProps extends Omit<slider.Props, 'id' | 'thumbSize'> {
|
|
4
|
-
/** Provide an array of value markers */
|
|
5
|
-
markers?: number[];
|
|
6
|
-
/** Set height classes for the overall slider. */
|
|
7
|
-
height?: string;
|
|
8
|
-
/** Set base classes. */
|
|
9
|
-
base?: string;
|
|
10
|
-
/** Provide arbitrary classes for the root. */
|
|
11
|
-
classes?: string;
|
|
12
|
-
/** Set base classes for the control. */
|
|
13
|
-
controlBase?: string;
|
|
14
|
-
/** Provide arbitrary classes for the control. */
|
|
15
|
-
controlClasses?: string;
|
|
16
|
-
/** Set base classes for the track. */
|
|
17
|
-
trackBase?: string;
|
|
18
|
-
/** Set background classes for the track. */
|
|
19
|
-
trackBg?: string;
|
|
20
|
-
/** Set border radius classes for the track. */
|
|
21
|
-
trackRounded?: string;
|
|
22
|
-
/** Provide arbitrary classes for the track. */
|
|
23
|
-
trackClasses?: string;
|
|
24
|
-
/** Set base classes for the meter. */
|
|
25
|
-
meterBase?: string;
|
|
26
|
-
/** Set background classes for the meter. */
|
|
27
|
-
meterBg?: string;
|
|
28
|
-
/** Set border radius classes for the meter. */
|
|
29
|
-
meterRounded?: string;
|
|
30
|
-
/** Provide arbitrary classes for the meter. */
|
|
31
|
-
meterClasses?: string;
|
|
32
|
-
/** Set base classes for the thumb. */
|
|
33
|
-
thumbBase?: string;
|
|
34
|
-
/** Set size classes for the thumb. */
|
|
35
|
-
thumbSize?: string;
|
|
36
|
-
/** Set background classes for the thumb. */
|
|
37
|
-
thumbBg?: string;
|
|
38
|
-
/** Set ring size classes for the thumb. */
|
|
39
|
-
thumbRingSize?: string;
|
|
40
|
-
/** Set ring color classes for the thumb. */
|
|
41
|
-
thumbRingColor?: string;
|
|
42
|
-
/** Set border-radius classes for the thumb. */
|
|
43
|
-
thumbRounded?: string;
|
|
44
|
-
/** Set cursor classes for the thumb. */
|
|
45
|
-
thumbCursor?: string;
|
|
46
|
-
/** Provide arbitrary classes for the thumb. */
|
|
47
|
-
thumbClasses?: string;
|
|
48
|
-
/** Set base classes for the markers. */
|
|
49
|
-
markersBase?: string;
|
|
50
|
-
/** Provide arbitrary classes for the markers. */
|
|
51
|
-
markersClasses?: string;
|
|
52
|
-
/** Set base classes for each mark. */
|
|
53
|
-
markBase?: string;
|
|
54
|
-
/** Set text size classes for each mark. */
|
|
55
|
-
markText?: string;
|
|
56
|
-
/** Set opacity classes for each mark. */
|
|
57
|
-
markOpacity?: string;
|
|
58
|
-
/** Provide arbitrary classes for each mark. */
|
|
59
|
-
markClasses?: string;
|
|
60
|
-
/** Set disabled state classes for the root element. */
|
|
61
|
-
stateDisabled?: string;
|
|
62
|
-
/** Set read-only state classes for the root element. */
|
|
63
|
-
stateReadOnly?: string;
|
|
64
|
-
/** Replace numeric markers with symbol, such as a icon. */
|
|
65
|
-
mark?: ReactNode;
|
|
66
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as slider from '@zag-js/slider';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React, { useId } from 'react';
|
|
4
|
-
import * as zagSwitch from '@zag-js/switch';
|
|
5
|
-
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
-
export const Switch = ({ compact = false,
|
|
7
|
-
// Root (Track)
|
|
8
|
-
base = 'inline-flex items-center gap-4',
|
|
9
|
-
// State
|
|
10
|
-
stateFocused = 'data-[focus-visible]:focused', classes = '',
|
|
11
|
-
// Control
|
|
12
|
-
controlBase = 'cursor-pointer transition duration-200', controlInactive = 'preset-filled-surface-200-800', controlActive = 'preset-filled-primary-500', controlDisabled = 'opacity-50 cursor-not-allowed', controlWidth = 'w-10', controlHeight = 'h-6', controlPadding = 'p-0.5', controlRounded = 'rounded-full', controlHover = 'hover:brightness-90 dark:hover:brightness-110', controlClasses = '',
|
|
13
|
-
// Thumb
|
|
14
|
-
thumbBase = 'right-0 aspect-square h-full flex justify-center items-center text-right cursor-pointer', thumbInactive = 'preset-filled-surface-50-950', thumbActive = 'bg-surface-50 text-surface-contrast-50', thumbRounded = 'rounded-full', thumbTranslateX = 'translate-x-4 rtl:-translate-x-4', thumbTransition = 'transition', thumbEase = 'ease-in-out', thumbDuration = 'duration-200', thumbClasses = '',
|
|
15
|
-
// Label
|
|
16
|
-
labelBase = '', labelClasses = '',
|
|
17
|
-
// Icons
|
|
18
|
-
iconInactiveBase = 'pointer-events-none', iconActiveBase = 'pointer-events-none',
|
|
19
|
-
// Children
|
|
20
|
-
children, inactiveChild, activeChild,
|
|
21
|
-
// Zag
|
|
22
|
-
...zagProps }) => {
|
|
23
|
-
// Zag
|
|
24
|
-
const service = useMachine(zagSwitch.machine, {
|
|
25
|
-
id: useId(),
|
|
26
|
-
...zagProps
|
|
27
|
-
});
|
|
28
|
-
const api = zagSwitch.connect(service, normalizeProps);
|
|
29
|
-
const rxControlBase = compact ? thumbBase : controlBase;
|
|
30
|
-
const rxControlHeight = compact ? '' : controlHeight;
|
|
31
|
-
const rxControlPadding = compact ? '' : controlPadding;
|
|
32
|
-
const rxThumbInactive = compact ? controlInactive : thumbInactive;
|
|
33
|
-
const rxThumbActive = compact ? controlActive : thumbActive;
|
|
34
|
-
const rxThumbTranslateX = compact ? '' : thumbTranslateX;
|
|
35
|
-
const rxTrackState = api.checked ? controlActive : controlInactive;
|
|
36
|
-
const rxThumbState = api.checked ? `${rxThumbActive} ${rxThumbTranslateX}` : rxThumbInactive;
|
|
37
|
-
const rxDisabled = api.disabled ? controlDisabled : '';
|
|
38
|
-
const rxFocused = api.focused ? stateFocused : '';
|
|
39
|
-
return (_jsxs("label", { ...api.getRootProps(), className: `${base} ${classes}`, "data-testid": "switch", children: [_jsx("input", { ...api.getHiddenInputProps(), "data-testid": "switch-input" }), _jsx("span", { ...api.getControlProps(), className: `${rxControlBase} ${rxTrackState} ${rxFocused} ${controlWidth} ${rxControlHeight} ${rxControlPadding} ${controlRounded} ${controlHover} ${rxDisabled} ${controlClasses}`, "data-testid": "switch-control", children: _jsxs("span", { ...api.getThumbProps(), className: `${thumbBase} ${rxThumbState} ${thumbRounded} ${thumbTransition} ${thumbEase} ${thumbDuration} ${thumbClasses}`, "data-testid": "switch-thumb", children: [!api.checked && inactiveChild ? (_jsx("span", { className: iconInactiveBase, "data-testid": "switch-icon-inactive", children: inactiveChild })) : null, api.checked && activeChild ? (_jsx("span", { className: iconActiveBase, "data-testid": "switch-icon-active", children: activeChild })) : null] }) }), children ? (_jsx("span", { ...api.getLabelProps(), className: `${labelBase} ${labelClasses}`, "data-testid": "switch-label", children: children })) : null] }));
|
|
40
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import * as zagSwitch from '@zag-js/switch';
|
|
3
|
-
export interface SwitchProps extends React.PropsWithChildren, Omit<zagSwitch.Props, 'id'> {
|
|
4
|
-
/** Set the compact display mode. */
|
|
5
|
-
compact?: boolean;
|
|
6
|
-
/** Set base classes for the root element. */
|
|
7
|
-
base?: string;
|
|
8
|
-
/** Provide arbitrary classes to the root element. */
|
|
9
|
-
classes?: string;
|
|
10
|
-
/** Set classes for the focus state. */
|
|
11
|
-
stateFocused?: string;
|
|
12
|
-
/** Set base classes for the control element. */
|
|
13
|
-
controlBase?: string;
|
|
14
|
-
/** Set inactive state classes for the control element. */
|
|
15
|
-
controlInactive?: string;
|
|
16
|
-
/** Set active state classes for the control element. */
|
|
17
|
-
controlActive?: string;
|
|
18
|
-
/** Set disabled state classes for the control element. */
|
|
19
|
-
controlDisabled?: string;
|
|
20
|
-
/** Set width classes for the control element. */
|
|
21
|
-
controlWidth?: string;
|
|
22
|
-
/** Set height classes for the control element. */
|
|
23
|
-
controlHeight?: string;
|
|
24
|
-
/** Set padding classes for the control element. */
|
|
25
|
-
controlPadding?: string;
|
|
26
|
-
/** Set rounded classes for the control element. */
|
|
27
|
-
controlRounded?: string;
|
|
28
|
-
/** Set hover classes for the control element. */
|
|
29
|
-
controlHover?: string;
|
|
30
|
-
/** Provide arbitrary classes to the control element. */
|
|
31
|
-
controlClasses?: string;
|
|
32
|
-
/** Set base classes for the thumb element. */
|
|
33
|
-
thumbBase?: string;
|
|
34
|
-
/** Set inactive classes for the thumb element. */
|
|
35
|
-
thumbInactive?: string;
|
|
36
|
-
/** Set active classes for the thumb element. */
|
|
37
|
-
thumbActive?: string;
|
|
38
|
-
/** Set rounded classes for the thumb element. */
|
|
39
|
-
thumbRounded?: string;
|
|
40
|
-
/** Set animation X-axis translate classes for the thumb element. */
|
|
41
|
-
thumbTranslateX?: string;
|
|
42
|
-
/** Set animation transition classes for the thumb element. */
|
|
43
|
-
thumbTransition?: string;
|
|
44
|
-
/** Set animation easing classes for the thumb element. */
|
|
45
|
-
thumbEase?: string;
|
|
46
|
-
/** Set animation duration classes for the thumb element. */
|
|
47
|
-
thumbDuration?: string;
|
|
48
|
-
/** Provide arbitrary classes to the thumb element. */
|
|
49
|
-
thumbClasses?: string;
|
|
50
|
-
/** Set base classes for the label element. */
|
|
51
|
-
labelBase?: string;
|
|
52
|
-
/** Provide arbitrary classes to the label element. */
|
|
53
|
-
labelClasses?: string;
|
|
54
|
-
/** Set base classes for the inactive icon child. */
|
|
55
|
-
iconInactiveBase?: string;
|
|
56
|
-
/** Set base classes for the active icon child. */
|
|
57
|
-
iconActiveBase?: string;
|
|
58
|
-
/** The inactive state children. */
|
|
59
|
-
inactiveChild?: ReactNode;
|
|
60
|
-
/** The active state children. */
|
|
61
|
-
activeChild?: ReactNode;
|
|
62
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as zagSwitch from '@zag-js/switch';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
import type { TabsRootProps, TabsListProps, TabsControlProps, TabsContentProps, TabsPanelProps } from './types.js';
|
|
3
|
-
export declare const Tabs: FC<TabsRootProps> & {
|
|
4
|
-
/** A group of tab controls. */
|
|
5
|
-
List: FC<TabsListProps>;
|
|
6
|
-
/** An individual tab control. */
|
|
7
|
-
Control: FC<TabsControlProps>;
|
|
8
|
-
/** A group of tab panels. */
|
|
9
|
-
Content: FC<TabsContentProps>;
|
|
10
|
-
/** An individual tab panel. */
|
|
11
|
-
Panel: FC<TabsPanelProps>;
|
|
12
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useContext, useId } from 'react';
|
|
4
|
-
import * as tabs from '@zag-js/tabs';
|
|
5
|
-
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
-
import { TabsContext } from './context.js';
|
|
7
|
-
// Components ---
|
|
8
|
-
const TabsRoot = ({ fluid = false,
|
|
9
|
-
// Root
|
|
10
|
-
base = 'w-full', classes = '',
|
|
11
|
-
// Children
|
|
12
|
-
children,
|
|
13
|
-
// Zag
|
|
14
|
-
...zagProps }) => {
|
|
15
|
-
// Zag
|
|
16
|
-
const service = useMachine(tabs.machine, {
|
|
17
|
-
id: useId(),
|
|
18
|
-
...zagProps
|
|
19
|
-
});
|
|
20
|
-
const api = tabs.connect(service, normalizeProps);
|
|
21
|
-
return (_jsx("div", { ...api.getRootProps(), className: `${base} ${classes}`, "data-testid": "tabs", children: _jsx(TabsContext.Provider, { value: { fluid, api }, children: children }) }));
|
|
22
|
-
};
|
|
23
|
-
const TabsList = ({
|
|
24
|
-
// Root
|
|
25
|
-
base = 'flex', justify = 'justify-start', border = 'border-b-[1px] border-surface-200-800', margin = 'mb-4', gap = 'gap-2', classes = '',
|
|
26
|
-
// Children
|
|
27
|
-
children }) => {
|
|
28
|
-
const ctx = useContext(TabsContext);
|
|
29
|
-
return (_jsx("div", { ...ctx.api.getListProps(), className: `${base} ${justify} ${border} ${margin} ${gap} ${classes}`, "data-testid": "tabs-list", children: children }));
|
|
30
|
-
};
|
|
31
|
-
const TabsControl = ({
|
|
32
|
-
// Root
|
|
33
|
-
base = 'border-b-[1px] border-transparent', padding = 'pb-2', translateX = 'translate-y-[1px]', classes = '',
|
|
34
|
-
// Label
|
|
35
|
-
labelBase = 'btn hover:preset-tonal-primary', labelClasses = '',
|
|
36
|
-
// State
|
|
37
|
-
stateInactive = '[&:not(:hover)]:opacity-50', stateActive = 'border-b-surface-950-50 opacity-100', stateLabelInactive = '', stateLabelActive = '',
|
|
38
|
-
// Nodes
|
|
39
|
-
lead,
|
|
40
|
-
// Children
|
|
41
|
-
children,
|
|
42
|
-
// Zag
|
|
43
|
-
...zagProps }) => {
|
|
44
|
-
const ctx = useContext(TabsContext);
|
|
45
|
-
const state = ctx.api.getTriggerState(zagProps);
|
|
46
|
-
// Reactive
|
|
47
|
-
const rxActive = state.selected ? stateActive : stateInactive;
|
|
48
|
-
const rxLabelActive = state.selected ? stateLabelActive : stateLabelInactive;
|
|
49
|
-
// Styles
|
|
50
|
-
const commonStyles = { width: ctx.fluid ? '100%' : '' };
|
|
51
|
-
return (_jsx("button", { ...ctx.api.getTriggerProps(zagProps), className: `${base} ${padding} ${translateX} ${rxActive} ${classes}`, style: commonStyles, "data-testid": "tabs-control", children: _jsxs("div", { className: `${labelBase} ${rxLabelActive} ${labelClasses}`, style: commonStyles, "data-testid": "tabs-control-label", children: [lead && _jsx("span", { "data-testid": "tabs-control-lead", children: lead }), _jsx("span", { "data-testid": "tabs-control-children", children: children })] }) }));
|
|
52
|
-
};
|
|
53
|
-
const TabsContent = ({
|
|
54
|
-
// Root
|
|
55
|
-
base = '', classes = '',
|
|
56
|
-
// Children
|
|
57
|
-
children }) => {
|
|
58
|
-
return (_jsx("div", { className: `${base} ${classes}`, "data-testid": "tabs-content", children: children }));
|
|
59
|
-
};
|
|
60
|
-
const TabsPanel = ({
|
|
61
|
-
// Root
|
|
62
|
-
base = '', classes = '',
|
|
63
|
-
// Children
|
|
64
|
-
children,
|
|
65
|
-
// Zag
|
|
66
|
-
...zagProps }) => {
|
|
67
|
-
const ctx = useContext(TabsContext);
|
|
68
|
-
return (_jsx("div", { ...ctx.api.getContentProps(zagProps), className: `${base} ${classes}`, "data-testid": "tabs-panel", children: children }));
|
|
69
|
-
};
|
|
70
|
-
// Export ---
|
|
71
|
-
export const Tabs = /* @__PURE__ */ Object.assign(TabsRoot, {
|
|
72
|
-
/** A group of tab controls. */
|
|
73
|
-
List: TabsList,
|
|
74
|
-
/** An individual tab control. */
|
|
75
|
-
Control: TabsControl,
|
|
76
|
-
/** A group of tab panels. */
|
|
77
|
-
Content: TabsContent,
|
|
78
|
-
/** An individual tab panel. */
|
|
79
|
-
Panel: TabsPanel
|
|
80
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { ReactNode, PropsWithChildren } from 'react';
|
|
2
|
-
import * as tabs from '@zag-js/tabs';
|
|
3
|
-
export interface TabsContextState {
|
|
4
|
-
fluid: boolean;
|
|
5
|
-
api: ReturnType<typeof tabs.connect>;
|
|
6
|
-
}
|
|
7
|
-
export interface TabsRootProps extends PropsWithChildren, Omit<tabs.Props, 'id' | 'orientation'> {
|
|
8
|
-
/** Set tabs to stretch to fill the available width. */
|
|
9
|
-
fluid?: boolean;
|
|
10
|
-
/** Set base classes for the root element. */
|
|
11
|
-
base?: string;
|
|
12
|
-
/** Provide arbitrary classes for the root element. */
|
|
13
|
-
classes?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface TabsListProps extends PropsWithChildren {
|
|
16
|
-
/** Set base classes for the list element. */
|
|
17
|
-
base?: string;
|
|
18
|
-
/** Set justify classes for the list element. */
|
|
19
|
-
justify?: string;
|
|
20
|
-
/** Set border classes for the list element. */
|
|
21
|
-
border?: string;
|
|
22
|
-
/** Set margin classes for the list element. */
|
|
23
|
-
margin?: string;
|
|
24
|
-
/** Set gap classes for the list element. */
|
|
25
|
-
gap?: string;
|
|
26
|
-
/** Provide arbitrary classes for the list element. */
|
|
27
|
-
classes?: string;
|
|
28
|
-
}
|
|
29
|
-
export interface TabsControlProps extends PropsWithChildren, tabs.TriggerProps {
|
|
30
|
-
/** Set base classes for the control element. */
|
|
31
|
-
base?: string;
|
|
32
|
-
/** Set padding classes for the control element. */
|
|
33
|
-
padding?: string;
|
|
34
|
-
/** Set x-axis translate classes for the control element. */
|
|
35
|
-
translateX?: string;
|
|
36
|
-
/** Provide arbitrary classes for the control element. */
|
|
37
|
-
classes?: string;
|
|
38
|
-
/** Set base classes for the label element. */
|
|
39
|
-
labelBase?: string;
|
|
40
|
-
/** Provide arbitrary classes for the label element. */
|
|
41
|
-
labelClasses?: string;
|
|
42
|
-
/** Set inactive classes for the control element. */
|
|
43
|
-
stateInactive?: string;
|
|
44
|
-
/** Set active classes for the control element. */
|
|
45
|
-
stateActive?: string;
|
|
46
|
-
/** Set inactive classes for the label element. */
|
|
47
|
-
stateLabelInactive?: string;
|
|
48
|
-
/** Set active classes for the label element. */
|
|
49
|
-
stateLabelActive?: string;
|
|
50
|
-
/** The lead node for the control element. */
|
|
51
|
-
lead?: ReactNode;
|
|
52
|
-
}
|
|
53
|
-
export interface TabsContentProps extends PropsWithChildren {
|
|
54
|
-
/** Set base classes for the panel group element. */
|
|
55
|
-
base?: string;
|
|
56
|
-
/** Provide arbitrary classes for the panel group element. */
|
|
57
|
-
classes?: string;
|
|
58
|
-
}
|
|
59
|
-
export interface TabsPanelProps extends PropsWithChildren, tabs.ContentProps {
|
|
60
|
-
/** Set base classes for the panel element. */
|
|
61
|
-
base?: string;
|
|
62
|
-
/** Provide arbitrary classes for the panel element. */
|
|
63
|
-
classes?: string;
|
|
64
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as tabs from '@zag-js/tabs';
|