@skeletonlabs/skeleton-react 1.0.0-next.2 → 1.0.0-next.4
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/Accordion.d.ts +9 -8
- package/dist/components/Accordion/Accordion.js +47 -68
- package/dist/components/Accordion/types.d.ts +24 -25
- package/dist/components/AppBar/AppBar.d.ts +2 -2
- package/dist/components/AppBar/AppBar.js +18 -20
- package/dist/components/AppBar/types.d.ts +1 -1
- package/dist/components/Avatar/Avatar.d.ts +2 -2
- package/dist/components/Avatar/Avatar.js +21 -7
- package/dist/components/Avatar/types.d.ts +10 -5
- package/dist/components/Navigation/Navigation.d.ts +2 -2
- package/dist/components/Navigation/Navigation.js +53 -30
- package/dist/components/Navigation/types.d.ts +6 -1
- package/dist/components/Progress/Progress.d.ts +2 -2
- package/dist/components/Progress/Progress.js +21 -14
- package/dist/components/Progress/types.d.ts +20 -8
- package/dist/components/ProgressRing/ProgressRing.d.ts +2 -2
- package/dist/components/ProgressRing/ProgressRing.js +22 -27
- package/dist/components/ProgressRing/types.d.ts +9 -13
- package/dist/components/Rating/Rating.d.ts +3 -3
- package/dist/components/Rating/Rating.js +50 -76
- package/dist/components/Rating/types.d.ts +35 -54
- package/dist/components/Segment/Segment.d.ts +6 -0
- package/dist/components/Segment/Segment.js +62 -0
- package/dist/components/Segment/types.d.ts +59 -0
- package/dist/components/Segment/types.js +2 -0
- package/dist/components/Switch/Switch.d.ts +2 -2
- package/dist/components/Switch/Switch.js +34 -27
- package/dist/components/Switch/types.d.ts +28 -25
- package/dist/components/Tabs/Tabs.d.ts +12 -7
- package/dist/components/Tabs/Tabs.js +65 -99
- package/dist/components/Tabs/types.d.ts +48 -81
- package/dist/components/Test/Test.js +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +11 -10
- package/dist/internal/nodes.d.ts +3 -0
- package/dist/internal/nodes.js +4 -0
- package/dist/internal/noop.d.ts +1 -0
- package/dist/internal/noop.js +2 -0
- package/package.json +36 -35
- package/dist/utils/react-compose.d.ts +0 -4
- package/dist/utils/react-compose.js +0 -3
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import * as zagSwitch from '@zag-js/switch';
|
|
5
|
+
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
+
import { noop } from '../../internal/noop.js';
|
|
7
|
+
export const Switch = ({ name = '', checked = false, disabled = false, compact = false,
|
|
6
8
|
// Root (Track)
|
|
7
|
-
base =
|
|
9
|
+
base = 'inline-flex items-center gap-4', classes = '',
|
|
10
|
+
// Control
|
|
11
|
+
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 = '',
|
|
8
12
|
// Thumb
|
|
9
|
-
thumbBase =
|
|
13
|
+
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 = '',
|
|
14
|
+
// Label
|
|
15
|
+
labelBase = '', labelClasses = '',
|
|
10
16
|
// Icons
|
|
11
|
-
iconInactiveBase =
|
|
17
|
+
iconInactiveBase = 'pointer-events-none', iconActiveBase = 'pointer-events-none',
|
|
12
18
|
// Events
|
|
13
|
-
onCheckedChange =
|
|
19
|
+
onCheckedChange = noop,
|
|
14
20
|
// Children
|
|
15
|
-
inactiveChild, activeChild
|
|
21
|
+
children, inactiveChild, activeChild }) => {
|
|
22
|
+
// Zag
|
|
23
|
+
const [state, send] = useMachine(zagSwitch.machine({
|
|
24
|
+
id: useId(),
|
|
25
|
+
name,
|
|
26
|
+
disabled,
|
|
27
|
+
checked,
|
|
28
|
+
onCheckedChange: (details) => onCheckedChange(details.checked)
|
|
29
|
+
}));
|
|
30
|
+
const api = zagSwitch.connect(state, send, normalizeProps);
|
|
16
31
|
// Set Compact Mode
|
|
17
32
|
if (compact) {
|
|
18
|
-
|
|
33
|
+
controlBase = thumbBase;
|
|
19
34
|
// Removes the height class
|
|
20
|
-
|
|
35
|
+
controlHeight = '';
|
|
21
36
|
// Thumb inherits track styles
|
|
22
|
-
thumbInactive =
|
|
23
|
-
thumbActive =
|
|
37
|
+
thumbInactive = controlInactive;
|
|
38
|
+
thumbActive = controlActive;
|
|
24
39
|
// Remove X-axis translate
|
|
25
|
-
thumbTranslateX =
|
|
40
|
+
thumbTranslateX = '';
|
|
26
41
|
// Remove padding
|
|
27
|
-
|
|
42
|
+
controlPadding = '';
|
|
28
43
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
onCheckedChange(checked);
|
|
34
|
-
}
|
|
35
|
-
const rxTrackState = checked ? stateActive : stateInactive;
|
|
36
|
-
const rxThumbState = checked
|
|
37
|
-
? `${thumbActive} ${thumbTranslateX}`
|
|
38
|
-
: thumbInactive;
|
|
39
|
-
const rxDisabled = disabled ? stateDisabled : "";
|
|
40
|
-
return (_jsxs("button", { type: "button", className: `${base} ${rxTrackState} ${width} ${height} ${padding} ${rounded} ${hover} ${rxDisabled} ${classes}`, role: "switch", "aria-checked": checked, "aria-labelledby": labelledby, "aria-describedby": describedby, onClick: toggle, "data-testid": "switch", children: [_jsx("input", { type: "checkbox", id: id, name: name, checked: checked, onChange: () => { }, className: "hidden", disabled: disabled }), _jsxs("div", { className: `${thumbBase} ${rxThumbState} ${thumbRounded} ${thumbTransition} ${thumbEase} ${thumbDuration} ${thumbClasses}`, children: [!checked && inactiveChild ? (_jsx("span", { className: iconInactiveBase, children: inactiveChild })) : null, checked && activeChild ? (_jsx("span", { className: iconActiveBase, children: activeChild })) : null] })] }));
|
|
44
|
+
const rxTrackState = api.checked ? controlActive : controlInactive;
|
|
45
|
+
const rxThumbState = api.checked ? `${thumbActive} ${thumbTranslateX}` : thumbInactive;
|
|
46
|
+
const rxDisabled = api.disabled ? controlDisabled : '';
|
|
47
|
+
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: `${controlBase} ${rxTrackState} ${controlWidth} ${controlHeight} ${controlPadding} ${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: [!checked && inactiveChild ? (_jsx("span", { className: iconInactiveBase, "data-testid": "switch-icon-inactive", children: inactiveChild })) : null, checked && activeChild ? (_jsx("span", { className: iconActiveBase, "data-testid": "switch-icon-active", children: activeChild })) : null] }) }), _jsx("span", { ...api.getLabelProps(), className: `${labelBase} ${labelClasses}`, "data-testid": "switch-label", children: children })] }));
|
|
41
48
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
id: string;
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import * as zagSwitch from '@zag-js/switch';
|
|
3
|
+
export interface SwitchProps extends React.PropsWithChildren, Omit<zagSwitch.Context, 'id' | 'onCheckedChange'> {
|
|
5
4
|
/** Set a unique name for the switch input. */
|
|
6
5
|
name: string;
|
|
7
6
|
/** Set the checked state. */
|
|
@@ -10,30 +9,30 @@ export interface SwitchProps {
|
|
|
10
9
|
disabled?: boolean;
|
|
11
10
|
/** Set the compact display mode. */
|
|
12
11
|
compact?: boolean;
|
|
13
|
-
/** Identifies the element that labels the switch. */
|
|
14
|
-
labelledby?: string | undefined;
|
|
15
|
-
/** Identifies the element that describes the switch. */
|
|
16
|
-
describedby?: string | undefined;
|
|
17
12
|
/** Set base classes for the root element. */
|
|
18
13
|
base?: string;
|
|
19
|
-
/** Set inactive state classes for the root element. */
|
|
20
|
-
stateInactive?: string;
|
|
21
|
-
/** Set active state classes for the root element. */
|
|
22
|
-
stateActive?: string;
|
|
23
|
-
/** Set disabled state classes for the root element. */
|
|
24
|
-
stateDisabled?: string;
|
|
25
|
-
/** Set width classes for the root element. */
|
|
26
|
-
width?: string;
|
|
27
|
-
/** Set height classes for the root element. */
|
|
28
|
-
height?: string;
|
|
29
|
-
/** Set padding classes for the root element. */
|
|
30
|
-
padding?: string;
|
|
31
|
-
/** Set rounded classes for the root element. */
|
|
32
|
-
rounded?: string;
|
|
33
|
-
/** Set hover classes for the root element. */
|
|
34
|
-
hover?: string;
|
|
35
14
|
/** Provide arbitrary classes to the root element. */
|
|
36
15
|
classes?: string;
|
|
16
|
+
/** Set base classes for the control element. */
|
|
17
|
+
controlBase?: string;
|
|
18
|
+
/** Set inactive state classes for the control element. */
|
|
19
|
+
controlInactive?: string;
|
|
20
|
+
/** Set active state classes for the control element. */
|
|
21
|
+
controlActive?: string;
|
|
22
|
+
/** Set disabled state classes for the control element. */
|
|
23
|
+
controlDisabled?: string;
|
|
24
|
+
/** Set width classes for the control element. */
|
|
25
|
+
controlWidth?: string;
|
|
26
|
+
/** Set height classes for the control element. */
|
|
27
|
+
controlHeight?: string;
|
|
28
|
+
/** Set padding classes for the control element. */
|
|
29
|
+
controlPadding?: string;
|
|
30
|
+
/** Set rounded classes for the control element. */
|
|
31
|
+
controlRounded?: string;
|
|
32
|
+
/** Set hover classes for the control element. */
|
|
33
|
+
controlHover?: string;
|
|
34
|
+
/** Provide arbitrary classes to the control element. */
|
|
35
|
+
controlClasses?: string;
|
|
37
36
|
/** Set base classes for the thumb element. */
|
|
38
37
|
thumbBase?: string;
|
|
39
38
|
/** Set inactive classes for the thumb element. */
|
|
@@ -52,12 +51,16 @@ export interface SwitchProps {
|
|
|
52
51
|
thumbDuration?: string;
|
|
53
52
|
/** Provide arbitrary classes to the thumb element. */
|
|
54
53
|
thumbClasses?: string;
|
|
54
|
+
/** Set base classes for the label element. */
|
|
55
|
+
labelBase?: string;
|
|
56
|
+
/** Provide arbitrary classes to the label element. */
|
|
57
|
+
labelClasses?: string;
|
|
55
58
|
/** Set base classes for the inactive icon child. */
|
|
56
59
|
iconInactiveBase?: string;
|
|
57
60
|
/** Set base classes for the active icon child. */
|
|
58
61
|
iconActiveBase?: string;
|
|
59
62
|
/** Triggers when the switch is toggled. */
|
|
60
|
-
onCheckedChange?: (
|
|
63
|
+
onCheckedChange?: (value: boolean) => void;
|
|
61
64
|
/** The inactive state children. */
|
|
62
65
|
inactiveChild?: ReactNode;
|
|
63
66
|
/** The active state children. */
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TabsContextState, TabsRootProps, TabsListProps, TabsControlProps, TabsContentProps, TabsPanelProps } from './types.js';
|
|
3
|
+
export declare const TabsContext: import("react").Context<TabsContextState>;
|
|
4
|
+
export declare const Tabs: FC<TabsRootProps> & {
|
|
5
|
+
/** A group of tab controls. */
|
|
6
|
+
List: FC<TabsListProps>;
|
|
7
|
+
/** An individual tab control. */
|
|
8
|
+
Control: FC<TabsControlProps>;
|
|
9
|
+
/** A group of tab panels. */
|
|
10
|
+
Content: FC<TabsContentProps>;
|
|
11
|
+
/** An individual tab panel. */
|
|
12
|
+
Panel: FC<TabsPanelProps>;
|
|
8
13
|
};
|
|
@@ -1,121 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
+
import { createContext, useContext, useId } from 'react';
|
|
4
|
+
import * as tabs from '@zag-js/tabs';
|
|
5
|
+
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
+
import { noop } from '../../internal/noop.js';
|
|
7
|
+
// Context ---
|
|
8
|
+
export const TabsContext = createContext({
|
|
9
|
+
fluid: false,
|
|
10
|
+
api: {}
|
|
11
|
+
});
|
|
3
12
|
// Components ---
|
|
4
|
-
const TabsRoot = ({
|
|
13
|
+
const TabsRoot = ({ fluid = false,
|
|
5
14
|
// Root
|
|
6
|
-
base =
|
|
15
|
+
base = 'w-full', classes = '',
|
|
16
|
+
// Events
|
|
17
|
+
onValueChange = noop,
|
|
7
18
|
// Children
|
|
8
|
-
children,
|
|
9
|
-
|
|
19
|
+
children,
|
|
20
|
+
// Zag
|
|
21
|
+
...zagProps }) => {
|
|
22
|
+
// Zag
|
|
23
|
+
const [state, send] = useMachine(tabs.machine({
|
|
24
|
+
id: useId(),
|
|
25
|
+
onValueChange: (details) => onValueChange(details.value)
|
|
26
|
+
}), { context: zagProps });
|
|
27
|
+
const api = tabs.connect(state, send, normalizeProps);
|
|
28
|
+
return (_jsx("div", { ...api.getRootProps(), className: `${base} ${classes}`, "data-testid": "tabs", children: _jsx(TabsContext.Provider, { value: { fluid, api }, children: children }) }));
|
|
10
29
|
};
|
|
11
30
|
const TabsList = ({
|
|
12
31
|
// Root
|
|
13
|
-
base =
|
|
32
|
+
base = 'flex', justify = 'justify-start', border = 'border-b border-surface-200-800', margin = 'mb-4', gap = 'gap-2', classes = '',
|
|
14
33
|
// Children
|
|
15
|
-
children
|
|
16
|
-
|
|
34
|
+
children }) => {
|
|
35
|
+
const ctx = useContext(TabsContext);
|
|
36
|
+
return (_jsx("div", { ...ctx.api.getListProps(), className: `${base} ${justify} ${border} ${margin} ${gap} ${classes}`, "data-testid": "tabs-list", children: children }));
|
|
17
37
|
};
|
|
18
|
-
const TabsControl = ({
|
|
19
|
-
// A11y
|
|
20
|
-
label = "", controls = "",
|
|
38
|
+
const TabsControl = ({
|
|
21
39
|
// Root
|
|
22
|
-
base =
|
|
23
|
-
//
|
|
24
|
-
|
|
40
|
+
base = 'border-b border-transparent', padding = 'pb-2', translateX = 'translate-y-[1px]', classes = '',
|
|
41
|
+
// Label
|
|
42
|
+
labelBase = 'btn hover:preset-tonal-primary', labelClasses = '',
|
|
43
|
+
// State
|
|
44
|
+
stateInactive = '[&:not(:hover)]:opacity-50', stateActive = 'border-surface-950-50 opacity-100', stateLabelInactive = '', stateLabelActive = '',
|
|
45
|
+
// Nodes
|
|
46
|
+
lead,
|
|
25
47
|
// Children
|
|
26
|
-
children,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
const elemInputRef = useRef(null);
|
|
39
|
-
function onKeyDownHandler(event) {
|
|
40
|
-
// Fire Event Handler
|
|
41
|
-
onKeydown(event);
|
|
42
|
-
// If select key events
|
|
43
|
-
if (!["ArrowRight", "ArrowLeft", "Home", "End"].includes(event.code))
|
|
44
|
-
return;
|
|
45
|
-
const elemInput = elemInputRef.current;
|
|
46
|
-
if (!elemInput)
|
|
47
|
-
return;
|
|
48
|
-
// Prevent default behavior
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
// Find the closest tab/tablelist
|
|
51
|
-
const currTab = elemInput.closest('[role="tab"]');
|
|
52
|
-
if (!currTab)
|
|
53
|
-
return;
|
|
54
|
-
const tabList = elemInput.closest('[role="tablist"]');
|
|
55
|
-
if (!tabList)
|
|
56
|
-
return;
|
|
57
|
-
// Get RTL mode
|
|
58
|
-
const isRTL = getComputedStyle(tabList).direction === "rtl";
|
|
59
|
-
// Get list of tab elements
|
|
60
|
-
const tabs = Array.from(tabList.querySelectorAll('[role="tab"]'));
|
|
61
|
-
// Get a reference to the current tab
|
|
62
|
-
const currIndex = tabs.indexOf(currTab);
|
|
63
|
-
// Determine the index of the next tab
|
|
64
|
-
let nextIndex = -1;
|
|
65
|
-
switch (event.code) {
|
|
66
|
-
case "ArrowRight":
|
|
67
|
-
if (isRTL) {
|
|
68
|
-
nextIndex = currIndex - 1 < 0 ? tabs.length - 1 : currIndex - 1;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
nextIndex = currIndex + 1 >= tabs.length ? 0 : currIndex + 1;
|
|
72
|
-
break;
|
|
73
|
-
case "ArrowLeft":
|
|
74
|
-
if (isRTL) {
|
|
75
|
-
nextIndex = currIndex + 1 >= tabs.length ? 0 : currIndex + 1;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
nextIndex = currIndex - 1 < 0 ? tabs.length - 1 : currIndex - 1;
|
|
79
|
-
break;
|
|
80
|
-
case "Home":
|
|
81
|
-
nextIndex = 0;
|
|
82
|
-
break;
|
|
83
|
-
case "End":
|
|
84
|
-
nextIndex = tabs.length - 1;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
if (nextIndex < 0)
|
|
88
|
-
return;
|
|
89
|
-
// Set Active Tab
|
|
90
|
-
const nextTab = tabs[nextIndex];
|
|
91
|
-
const nextTabInput = nextTab?.querySelector("input");
|
|
92
|
-
if (nextTabInput) {
|
|
93
|
-
nextTabInput.click();
|
|
94
|
-
nextTab.focus();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return (_jsx("label", { id: id, className: `${base} ${width} ${rxActive} ${flex} ${background} ${border} ${text} ${padding} ${rounded} ${gap} ${cursor} ${classes}`, "aria-label": label, title: title, children: _jsxs("div", { className: "size-full", role: "tab", "aria-controls": controls, "aria-selected": selected, "data-testid": "tabs-control", tabIndex: selected ? 0 : -1, onKeyDown: onKeyDownHandler, onKeyUp: onKeyup, children: [_jsx("div", { className: "h-0 w-0 flex-none overflow-hidden", children: _jsx("input", { ref: elemInputRef, type: "radio", name: name, value: name, checked: selected, onChange: handleOnChange, onClick: onClick, tabIndex: -1 }) }), children] }) }));
|
|
48
|
+
children,
|
|
49
|
+
// Zag
|
|
50
|
+
...zagProps }) => {
|
|
51
|
+
const ctx = useContext(TabsContext);
|
|
52
|
+
const state = ctx.api.getTriggerState(zagProps);
|
|
53
|
+
// Reactive
|
|
54
|
+
const rxActive = state.selected ? stateActive : stateInactive;
|
|
55
|
+
const rxLabelActive = state.selected ? stateLabelActive : stateLabelInactive;
|
|
56
|
+
// Styles
|
|
57
|
+
const commonStyles = { width: ctx.fluid ? '100%' : '' };
|
|
58
|
+
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 })] }) }));
|
|
98
59
|
};
|
|
99
|
-
const
|
|
60
|
+
const TabsContent = ({
|
|
100
61
|
// Root
|
|
101
|
-
base =
|
|
62
|
+
base = '', classes = '',
|
|
102
63
|
// Children
|
|
103
|
-
children
|
|
104
|
-
return (_jsx("div", { className: `${base} ${
|
|
64
|
+
children }) => {
|
|
65
|
+
return (_jsx("div", { className: `${base} ${classes}`, "data-testid": "tabs-content", children: children }));
|
|
105
66
|
};
|
|
106
|
-
const
|
|
107
|
-
// A11y
|
|
108
|
-
labelledBy,
|
|
67
|
+
const TabsPanel = ({
|
|
109
68
|
// Root
|
|
110
|
-
classes =
|
|
69
|
+
base = '', classes = '',
|
|
111
70
|
// Children
|
|
112
|
-
children,
|
|
113
|
-
|
|
114
|
-
|
|
71
|
+
children,
|
|
72
|
+
// Zag
|
|
73
|
+
...zagProps }) => {
|
|
74
|
+
const ctx = useContext(TabsContext);
|
|
75
|
+
return (_jsx("div", { ...ctx.api.getContentProps(zagProps), className: `${base} ${classes}`, "data-testid": "tabs-panel", children: children }));
|
|
115
76
|
};
|
|
77
|
+
// Export ---
|
|
116
78
|
export const Tabs = Object.assign(TabsRoot, {
|
|
79
|
+
/** A group of tab controls. */
|
|
117
80
|
List: TabsList,
|
|
81
|
+
/** An individual tab control. */
|
|
118
82
|
Control: TabsControl,
|
|
119
|
-
|
|
120
|
-
|
|
83
|
+
/** A group of tab panels. */
|
|
84
|
+
Content: TabsContent,
|
|
85
|
+
/** An individual tab panel. */
|
|
86
|
+
Panel: TabsPanel
|
|
121
87
|
});
|
|
@@ -1,99 +1,66 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React, { ReactNode } 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 React.PropsWithChildren, Omit<tabs.Context, 'id' | 'orientation' | 'onValueChange'> {
|
|
8
|
+
/** Set tabs to stretch to fill the available width. */
|
|
9
|
+
fluid?: boolean;
|
|
10
|
+
/** Set base classes for the root element. */
|
|
6
11
|
base?: string;
|
|
7
|
-
/**
|
|
8
|
-
spaceY?: string;
|
|
9
|
-
/** Provide arbitrary CSS classes. */
|
|
12
|
+
/** Provide arbitrary classes for the root element. */
|
|
10
13
|
classes?: string;
|
|
14
|
+
/** Triggers when the value state is changed. */
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
11
16
|
}
|
|
12
17
|
export interface TabsListProps extends React.PropsWithChildren {
|
|
13
|
-
/**
|
|
18
|
+
/** Set base classes for the list element. */
|
|
14
19
|
base?: string;
|
|
15
|
-
/**
|
|
20
|
+
/** Set justify classes for the list element. */
|
|
16
21
|
justify?: string;
|
|
17
|
-
/**
|
|
18
|
-
gap?: string;
|
|
19
|
-
/** Sets the border styles. */
|
|
22
|
+
/** Set border classes for the list element. */
|
|
20
23
|
border?: string;
|
|
21
|
-
/**
|
|
24
|
+
/** Set margin classes for the list element. */
|
|
25
|
+
margin?: string;
|
|
26
|
+
/** Set gap classes for the list element. */
|
|
27
|
+
gap?: string;
|
|
28
|
+
/** Provide arbitrary classes for the list element. */
|
|
22
29
|
classes?: string;
|
|
23
30
|
}
|
|
24
|
-
export interface TabsControlProps extends React.PropsWithChildren {
|
|
25
|
-
/**
|
|
26
|
-
id?: string;
|
|
27
|
-
/** Provide the tab control name. */
|
|
28
|
-
name: string;
|
|
29
|
-
/** Provide the tab control radio group. */
|
|
30
|
-
group: string;
|
|
31
|
-
/** Provide a hoverable title attribute. */
|
|
32
|
-
title?: string;
|
|
33
|
-
/** Sets the A11y label. */
|
|
34
|
-
label?: string;
|
|
35
|
-
/** Sets ARIA controls value to define which panel this tab controls. */
|
|
36
|
-
controls?: string;
|
|
37
|
-
/** Sets base styles. */
|
|
31
|
+
export interface TabsControlProps extends React.PropsWithChildren, tabs.TriggerProps {
|
|
32
|
+
/** Set base classes for the control element. */
|
|
38
33
|
base?: string;
|
|
39
|
-
/**
|
|
40
|
-
width?: string;
|
|
41
|
-
/** Sets the active control styles. */
|
|
42
|
-
active?: string;
|
|
43
|
-
/** Sets the inactive control styles. */
|
|
44
|
-
inactive?: string;
|
|
45
|
-
/** Sets flex styles. */
|
|
46
|
-
flex?: string;
|
|
47
|
-
/** Sets background styles. */
|
|
48
|
-
background?: string;
|
|
49
|
-
/** Sets border styles. */
|
|
50
|
-
border?: string;
|
|
51
|
-
/** Sets text size styles. */
|
|
52
|
-
text?: string;
|
|
53
|
-
/** Sets padding styles. */
|
|
34
|
+
/** Set padding classes for the control element. */
|
|
54
35
|
padding?: string;
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
gap?: string;
|
|
59
|
-
/** Sets cursor styles. */
|
|
60
|
-
cursor?: string;
|
|
61
|
-
/** Provide arbitrary CSS classes. */
|
|
36
|
+
/** Set x-axis translate classes for the control element. */
|
|
37
|
+
translateX?: string;
|
|
38
|
+
/** Provide arbitrary classes for the control element. */
|
|
62
39
|
classes?: string;
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
40
|
+
/** Set base classes for the label element. */
|
|
41
|
+
labelBase?: string;
|
|
42
|
+
/** Provide arbitrary classes for the label element. */
|
|
43
|
+
labelClasses?: string;
|
|
44
|
+
/** Set inactive classes for the control element. */
|
|
45
|
+
stateInactive?: string;
|
|
46
|
+
/** Set active classes for the control element. */
|
|
47
|
+
stateActive?: string;
|
|
48
|
+
/** Set inactive classes for the label element. */
|
|
49
|
+
stateLabelInactive?: string;
|
|
50
|
+
/** Set active classes for the label element. */
|
|
51
|
+
stateLabelActive?: string;
|
|
52
|
+
/** The lead node for the control element. */
|
|
53
|
+
lead?: ReactNode;
|
|
71
54
|
}
|
|
72
|
-
export interface
|
|
73
|
-
/**
|
|
55
|
+
export interface TabsContentProps extends React.PropsWithChildren {
|
|
56
|
+
/** Set base classes for the panel group element. */
|
|
74
57
|
base?: string;
|
|
75
|
-
/**
|
|
76
|
-
flex?: string;
|
|
77
|
-
/** Sets gap styles. */
|
|
78
|
-
gap?: string;
|
|
79
|
-
/** Sets background styles. */
|
|
80
|
-
background?: string;
|
|
81
|
-
/** Sets padding styles. */
|
|
82
|
-
padding?: string;
|
|
83
|
-
/** Sets rounded styles. */
|
|
84
|
-
rounded?: string;
|
|
85
|
-
/** Provide arbitrary CSS classes. */
|
|
58
|
+
/** Provide arbitrary classes for the panel group element. */
|
|
86
59
|
classes?: string;
|
|
87
60
|
}
|
|
88
|
-
export interface
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
/** Provide the
|
|
92
|
-
value: string;
|
|
93
|
-
/** Provide the tab control radio group. */
|
|
94
|
-
group: string;
|
|
95
|
-
/** Sets the A11y labelledby. */
|
|
96
|
-
labelledBy?: string;
|
|
97
|
-
/** Provide arbitrary CSS classes. */
|
|
61
|
+
export interface TabsPanelProps extends React.PropsWithChildren, tabs.ContentProps {
|
|
62
|
+
/** Set base classes for the panel element. */
|
|
63
|
+
base?: string;
|
|
64
|
+
/** Provide arbitrary classes for the panel element. */
|
|
98
65
|
classes?: string;
|
|
99
66
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { default as TestReact } from
|
|
2
|
-
export { Accordion } from
|
|
3
|
-
export { Avatar } from
|
|
4
|
-
export { AppBar } from
|
|
5
|
-
export { Nav } from
|
|
6
|
-
export { Progress } from
|
|
7
|
-
export { ProgressRing } from
|
|
8
|
-
export { Switch } from
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
1
|
+
export { default as TestReact } from './components/Test/Test.js';
|
|
2
|
+
export { Accordion } from './components/Accordion/Accordion.js';
|
|
3
|
+
export { Avatar } from './components/Avatar/Avatar.js';
|
|
4
|
+
export { AppBar } from './components/AppBar/AppBar.js';
|
|
5
|
+
export { Nav } from './components/Navigation/Navigation.js';
|
|
6
|
+
export { Progress } from './components/Progress/Progress.js';
|
|
7
|
+
export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
|
|
8
|
+
export { Switch } from './components/Switch/Switch.js';
|
|
9
|
+
export { Segment } from './components/Segment/Segment.js';
|
|
10
|
+
export { Tabs } from './components/Tabs/Tabs.js';
|
|
11
|
+
export { Rating } from './components/Rating/Rating.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export { default as TestReact } from
|
|
1
|
+
export { default as TestReact } from './components/Test/Test.js';
|
|
2
2
|
// Components
|
|
3
|
-
export { Accordion } from
|
|
4
|
-
export { Avatar } from
|
|
5
|
-
export { AppBar } from
|
|
6
|
-
export { Nav } from
|
|
7
|
-
export { Progress } from
|
|
8
|
-
export { ProgressRing } from
|
|
9
|
-
export { Switch } from
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
3
|
+
export { Accordion } from './components/Accordion/Accordion.js';
|
|
4
|
+
export { Avatar } from './components/Avatar/Avatar.js';
|
|
5
|
+
export { AppBar } from './components/AppBar/AppBar.js';
|
|
6
|
+
export { Nav } from './components/Navigation/Navigation.js';
|
|
7
|
+
export { Progress } from './components/Progress/Progress.js';
|
|
8
|
+
export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
|
|
9
|
+
export { Switch } from './components/Switch/Switch.js';
|
|
10
|
+
export { Segment } from './components/Segment/Segment.js';
|
|
11
|
+
export { Tabs } from './components/Tabs/Tabs.js';
|
|
12
|
+
export { Rating } from './components/Rating/Rating.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export 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" }) }));
|
|
3
|
+
export const starHalf = (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", height: "24", width: "24", children: [_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" })] }));
|
|
4
|
+
export 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" }) }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function noop(): void;
|