@skeletonlabs/skeleton-react 1.0.0-next.1 → 1.0.0-next.10

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.
Files changed (61) hide show
  1. package/dist/components/Accordion/Accordion.d.ts +9 -8
  2. package/dist/components/Accordion/Accordion.js +47 -68
  3. package/dist/components/Accordion/types.d.ts +24 -25
  4. package/dist/components/AppBar/AppBar.d.ts +6 -8
  5. package/dist/components/AppBar/AppBar.js +28 -32
  6. package/dist/components/AppBar/types.d.ts +5 -5
  7. package/dist/components/Avatar/Avatar.d.ts +2 -2
  8. package/dist/components/Avatar/Avatar.js +21 -7
  9. package/dist/components/Avatar/types.d.ts +10 -5
  10. package/dist/components/FileUpload/FileUpload.d.ts +3 -0
  11. package/dist/components/FileUpload/FileUpload.js +41 -0
  12. package/dist/components/FileUpload/types.d.ts +73 -0
  13. package/dist/components/FileUpload/types.js +1 -0
  14. package/dist/components/Navigation/Navigation.d.ts +11 -0
  15. package/dist/components/Navigation/Navigation.js +103 -0
  16. package/dist/components/Navigation/types.d.ts +132 -0
  17. package/dist/components/Navigation/types.js +2 -0
  18. package/dist/components/Pagination/Pagination.d.ts +3 -0
  19. package/dist/components/Pagination/Pagination.js +38 -0
  20. package/dist/components/Pagination/types.d.ts +52 -0
  21. package/dist/components/Pagination/types.js +1 -0
  22. package/dist/components/Progress/Progress.d.ts +2 -2
  23. package/dist/components/Progress/Progress.js +22 -14
  24. package/dist/components/Progress/types.d.ts +20 -8
  25. package/dist/components/ProgressRing/ProgressRing.d.ts +3 -0
  26. package/dist/components/ProgressRing/ProgressRing.js +31 -0
  27. package/dist/components/ProgressRing/types.d.ts +51 -0
  28. package/dist/components/ProgressRing/types.js +1 -0
  29. package/dist/components/Rating/Rating.d.ts +3 -0
  30. package/dist/components/Rating/Rating.js +52 -0
  31. package/dist/components/Rating/types.d.ts +40 -0
  32. package/dist/components/Rating/types.js +1 -0
  33. package/dist/components/Segment/Segment.d.ts +6 -0
  34. package/dist/components/Segment/Segment.js +63 -0
  35. package/dist/components/Segment/types.d.ts +61 -0
  36. package/dist/components/Segment/types.js +2 -0
  37. package/dist/components/Slider/Slider.d.ts +3 -0
  38. package/dist/components/Slider/Slider.js +43 -0
  39. package/dist/components/Slider/types.d.ts +72 -0
  40. package/dist/components/Slider/types.js +1 -0
  41. package/dist/components/Switch/Switch.d.ts +2 -2
  42. package/dist/components/Switch/Switch.js +37 -27
  43. package/dist/components/Switch/types.d.ts +30 -25
  44. package/dist/components/Tabs/Tabs.d.ts +12 -7
  45. package/dist/components/Tabs/Tabs.js +65 -99
  46. package/dist/components/Tabs/types.d.ts +48 -81
  47. package/dist/components/TagsInput/TagsInput.d.ts +3 -0
  48. package/dist/components/TagsInput/TagsInput.js +42 -0
  49. package/dist/components/TagsInput/types.d.ts +44 -0
  50. package/dist/components/TagsInput/types.js +1 -0
  51. package/dist/index.d.ts +15 -7
  52. package/dist/index.js +14 -7
  53. package/dist/internal/nodes.d.ts +3 -0
  54. package/dist/internal/nodes.js +4 -0
  55. package/dist/internal/noop.d.ts +1 -0
  56. package/dist/internal/noop.js +2 -0
  57. package/package.json +46 -41
  58. package/dist/components/Test/Test.d.ts +0 -2
  59. package/dist/components/Test/Test.js +0 -10
  60. package/dist/utils/react-compose.d.ts +0 -4
  61. package/dist/utils/react-compose.js +0 -3
@@ -0,0 +1,103 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createContext, useContext } from 'react';
4
+ // Contexts ---
5
+ export const NavContext = createContext({
6
+ parent: 'none',
7
+ value: '',
8
+ expanded: false,
9
+ onSelectionHandler: () => { }
10
+ });
11
+ // Components ---
12
+ export const NavRail = ({ value = '', expanded = false,
13
+ // Root
14
+ base = 'h-full flex flex-col', background = 'preset-filled-surface-100-900', padding = 'p-1', width = 'w-24', widthExpanded = 'w-64', height = 'h-full', classes = '',
15
+ // Header
16
+ headerBase = 'flex', headerFlexDirection = 'flex-col', headerJustify = 'justify-center', headerItems = 'items-center', headerGap = 'gap-1', headerClasses = '',
17
+ // Tiles
18
+ tilesBase = 'flex-1 flex', tilesFlexDirection = 'flex-col', tilesJustify = 'justify-center', tilesItems = 'items-center', tilesGap = 'gap-1', tilesClasses = '',
19
+ // Footer
20
+ footerBase = 'flex', footerFlexDirection = 'flex-col', footerJustify = 'justify-center', footerItems = 'items-center', footerGap = 'gap-1', footerClasses = '',
21
+ // Events
22
+ onChange,
23
+ // Snippets
24
+ header, children, footer }) => {
25
+ function onSelectionHandler(id) {
26
+ value = id;
27
+ if (onChange)
28
+ onChange(id);
29
+ }
30
+ // Set Context
31
+ const ctx = {
32
+ parent: 'rail',
33
+ value,
34
+ expanded,
35
+ onSelectionHandler
36
+ };
37
+ // Reactive
38
+ const rxWidth = expanded ? widthExpanded : width;
39
+ return (_jsx("aside", { className: `${base} ${background} ${height} ${padding} ${rxWidth} ${classes}`, "data-testid": "nav-rail", children: _jsxs(NavContext.Provider, { value: ctx, children: [header ? (_jsx("header", { className: `${headerBase} ${headerFlexDirection} ${headerJustify} ${headerItems} ${headerGap} ${headerClasses}`, "data-testid": "nav-rail-header", children: header })) : null, children ? (_jsx("nav", { className: `${tilesBase} ${tilesFlexDirection} ${tilesJustify} ${tilesItems} ${tilesGap} ${tilesClasses}`, "data-testid": "nav-rail-tiles", children: children })) : null, footer ? (_jsx("footer", { className: `${footerBase} ${footerFlexDirection} ${footerJustify} ${footerItems} ${footerGap} ${footerClasses}`, "data-testid": "nav-rail-footer", children: footer })) : null] }) }));
40
+ };
41
+ export const NavBar = ({ value = '',
42
+ // Root
43
+ base = 'h-full flex flex-col', background = 'preset-filled-surface-100-900', width = 'min-w-[320px] w-full', height = 'h-20', padding = 'p-1', classes = '',
44
+ // Tiles
45
+ tilesBase = 'flex-1 flex', tilesFlexDirection = '', tilesJustify = 'justify-center', tilesItems = 'items-center', tilesGap = 'gap-1', tilesClasses = '',
46
+ // Events
47
+ onChange,
48
+ // Snippets
49
+ children }) => {
50
+ function onSelectionHandler(id) {
51
+ value = id;
52
+ if (onChange)
53
+ onChange(id);
54
+ }
55
+ // Set Context
56
+ const ctx = {
57
+ parent: 'bar',
58
+ value,
59
+ expanded: false,
60
+ onSelectionHandler
61
+ };
62
+ return (_jsx("aside", { className: `${base} ${background} ${width} ${height} ${padding} ${classes}`, "data-testid": "nav-bar", children: _jsx(NavContext.Provider, { value: ctx, children: children ? (_jsx("nav", { className: `${tilesBase} ${tilesFlexDirection} ${tilesJustify} ${tilesItems} ${tilesGap} ${tilesClasses}`, children: children })) : null }) }));
63
+ };
64
+ export const NavTile = ({ id, href, target, label, labelExpanded, title, selected = false, type = 'button',
65
+ // Root
66
+ base = 'flex items-center', width = 'w-full', aspect = 'aspect-square', background = '', hover = 'hover:preset-filled-surface-50-950', active = 'preset-filled-primary-500', padding = 'p-2', gap = 'gap-1', rounded = 'rounded-container', classes = 'flex-col justify-center',
67
+ // Expanded
68
+ expandedPadding = 'py-3 px-4', expandedGap = 'gap-4', expandedClasses = '',
69
+ // Label (base)
70
+ labelBase = 'type-scale-1', labelClasses = '',
71
+ // Label (expanded)
72
+ labelExpandedBase = '', labelExpandedClasses = '',
73
+ // Events
74
+ onClick,
75
+ // Snippets
76
+ children }) => {
77
+ // Get Context
78
+ const ctx = useContext(NavContext);
79
+ // Local
80
+ const TileElement = href ? 'a' : 'button';
81
+ const role = href ? undefined : 'button';
82
+ // Reactive
83
+ const rxSize = ctx.parent === 'bar' ? `h-full` : `${aspect}`;
84
+ const classesCollapsed = `${rxSize} ${padding} ${gap} ${classes}`;
85
+ const classesExtended = `${expandedPadding} ${expandedGap} ${expandedClasses}`;
86
+ const rxMode = ctx.expanded ? classesExtended : classesCollapsed;
87
+ const rxBackground = selected || ctx.value === id ? active : `${background} ${hover}`;
88
+ function onClickHandler() {
89
+ if (onClick && !id)
90
+ throw new Error('No ID was provided');
91
+ if (onClick && id)
92
+ onClick(id);
93
+ if (ctx.onSelectionHandler && id)
94
+ ctx.onSelectionHandler(id);
95
+ }
96
+ return (_jsxs(TileElement, { className: `${base} ${width} ${rounded} ${rxBackground} ${rxMode}`, href: href, target: target, type: TileElement === 'button' ? type : undefined, title: title, role: role, onClick: onClickHandler, "data-parent": ctx.parent, "data-expanded": ctx.expanded, "data-testid": "nav-tile", children: [children && _jsx("div", { children: children }), label && !ctx.expanded && (_jsx("div", { className: `${labelBase} ${labelClasses}`, "data-testid": "nav-tile-label", children: label })), labelExpanded && ctx.expanded && (_jsx("div", { className: `${labelExpandedBase} ${labelExpandedClasses}`, "data-testid": "nav-tile-label-expanded", children: labelExpanded }))] }));
97
+ };
98
+ // Exports ---
99
+ export const Nav = Object.assign(() => null, {
100
+ Rail: NavRail,
101
+ Bar: NavBar,
102
+ Tile: NavTile
103
+ });
@@ -0,0 +1,132 @@
1
+ export interface NavContextState {
2
+ parent: string;
3
+ value: string;
4
+ expanded?: boolean;
5
+ onSelectionHandler: (id: string) => void;
6
+ }
7
+ /** Props common between NavRail and NavBar */
8
+ export interface NavCommonProps {
9
+ value?: string;
10
+ /** Set base styles. */
11
+ base?: string;
12
+ /** Set background classes. */
13
+ background?: string;
14
+ /** Set padding classes. */
15
+ padding?: string;
16
+ /** Set width classes. */
17
+ width?: string;
18
+ /** Set width classes for expanded mode. */
19
+ widthExpanded?: string;
20
+ /** Set width classes. */
21
+ height?: string;
22
+ /** Provide arbitrary CSS classes. */
23
+ classes?: string;
24
+ /** Set base classes. */
25
+ tilesBase?: string;
26
+ /** Set flex direction classes. */
27
+ tilesFlexDirection?: string;
28
+ /** Set flex justify classes. */
29
+ tilesJustify?: string;
30
+ /** Set flex align classes. */
31
+ tilesItems?: string;
32
+ /** Set gap classes. */
33
+ tilesGap?: string;
34
+ /** Provide arbitrary CSS classes. */
35
+ tilesClasses?: string;
36
+ /** Triggers when selection occurs. */
37
+ onChange?: (id: string) => void;
38
+ }
39
+ export interface NavBarProps extends NavCommonProps {
40
+ /** The default children. */
41
+ children?: React.ReactNode;
42
+ }
43
+ export interface NavRailProps extends NavCommonProps {
44
+ /** Enabled expanded mode. */
45
+ expanded?: boolean;
46
+ /** Set base classes. */
47
+ headerBase?: string;
48
+ /** Set flex direction classes. */
49
+ headerFlexDirection?: string;
50
+ /** Set flex justify classes. */
51
+ headerJustify?: string;
52
+ /** Set flex align classes. */
53
+ headerItems?: string;
54
+ /** Set gap classes. */
55
+ headerGap?: string;
56
+ /** Provide arbitrary CSS classes. */
57
+ headerClasses?: string;
58
+ /** Set base classes. */
59
+ footerBase?: string;
60
+ /** Set flex direction classes. */
61
+ footerFlexDirection?: string;
62
+ /** Set flex justify classes. */
63
+ footerJustify?: string;
64
+ /** Set flex align classes. */
65
+ footerItems?: string;
66
+ /** Set gap classes. */
67
+ footerGap?: string;
68
+ /** Provide arbitrary CSS classes. */
69
+ footerClasses?: string;
70
+ /** The header child node. */
71
+ header?: React.ReactNode;
72
+ /** The tiles child node. */
73
+ children?: React.ReactNode;
74
+ /** The footer child node. */
75
+ footer?: React.ReactNode;
76
+ }
77
+ export interface NavTileProps {
78
+ /** Provide a unique ID. */
79
+ id?: string;
80
+ /** Provide an href link; turns Tiles into an anchor */
81
+ href?: string;
82
+ /** Set the href target attribute. */
83
+ target?: string;
84
+ /** Provide the label text. */
85
+ label?: string;
86
+ /** Provide a longer label in expanded mode. */
87
+ labelExpanded?: string;
88
+ /** Provile a title attribute. */
89
+ title?: string;
90
+ /** Enable the active selected state. */
91
+ selected?: boolean;
92
+ /** Set button type. */
93
+ type?: 'button' | 'submit' | 'reset';
94
+ /** Set base styles. */
95
+ base?: string;
96
+ /** Set width classes. */
97
+ width?: string;
98
+ /** Set aspect ratio classes. */
99
+ aspect?: string;
100
+ /** Set background classes. */
101
+ background?: string;
102
+ /** Set hover classes. */
103
+ hover?: string;
104
+ /** Set active classes. */
105
+ active?: string;
106
+ /** Set padding classes. */
107
+ padding?: string;
108
+ /** Set gap classes. */
109
+ gap?: string;
110
+ /** Set rounded classes. */
111
+ rounded?: string;
112
+ /** Provide arbitrary CSS classes. */
113
+ classes?: string;
114
+ /** Set padding classes for expanded mode. */
115
+ expandedPadding?: string;
116
+ /** Set gap classes for expanded mode. */
117
+ expandedGap?: string;
118
+ /** Provide arbitrary CSS classes for expanded mode. */
119
+ expandedClasses?: string;
120
+ /** Set base classes. */
121
+ labelBase?: string;
122
+ /** Provide arbitrary CSS classes. */
123
+ labelClasses?: string;
124
+ /** Set base classes. */
125
+ labelExpandedBase?: string;
126
+ /** Provide arbitrary CSS classes. */
127
+ labelExpandedClasses?: string;
128
+ /** Triggers when the tile is clicked. */
129
+ onClick?: (id: string) => void;
130
+ /** The default children. */
131
+ children?: React.ReactNode;
132
+ }
@@ -0,0 +1,2 @@
1
+ // Context ---
2
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import type { PaginationProps } from './types';
3
+ export declare const Pagination: FC<PaginationProps>;
@@ -0,0 +1,38 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useId } from 'react';
4
+ import * as pagination from '@zag-js/pagination';
5
+ import { useMachine, normalizeProps } from '@zag-js/react';
6
+ export const Pagination = ({ data, alternative = false, textSeparator = 'of',
7
+ // Titles
8
+ titleFirst, titlePrevious, titleNumeral, titleNext, titleLast,
9
+ // Root
10
+ base = 'inline-flex items-stretch overflow-hidden', background = 'preset-outlined-surface-200-800', border = 'p-2', gap = 'gap-2', padding = '', rounded = 'rounded-container', classes = '',
11
+ // Buttons
12
+ buttonBase = 'btn', buttonActive = 'preset-filled', buttonInactive = 'preset-tonal', buttonHover = 'hover:preset-filled', buttonClasses = '',
13
+ // Children
14
+ labelFirst = '\u00AB', labelPrevious = '\u2190', labelEllipsis = '\u22EF', labelNext = '\u2192', labelLast = '\u00BB',
15
+ // Zag
16
+ ...zagProps }) => {
17
+ // Zag
18
+ const [state, send] = useMachine(pagination.machine({
19
+ id: useId(),
20
+ count: data.length
21
+ }), { context: zagProps });
22
+ const api = pagination.connect(state, send, normalizeProps);
23
+ // Reactive
24
+ const rxButtonActive = (page) => {
25
+ return state.context.page === page.value ? buttonActive : `${buttonInactive} ${buttonHover}`;
26
+ };
27
+ return (_jsx(_Fragment, { children: api.totalPages > 1 && (_jsxs("div", { ...api.getRootProps(), className: `${base} ${background} ${border} ${gap} ${padding} ${rounded} ${classes}`, "data-testid": "pagination", children: [alternative && (_jsx("button", { type: "button", onClick: api.goToFirstPage, className: `${buttonBase} ${buttonInactive} ${buttonHover} ${buttonClasses}`, title: titleFirst, disabled: api.page === 1, "data-testid": "pagination-button-previous", children: labelFirst })), _jsx("button", { type: "button", ...api.getPrevTriggerProps(), className: `${buttonBase} ${buttonInactive} ${buttonHover} ${buttonClasses}`, title: titlePrevious, disabled: api.page === 1, "data-testid": "pagination-button-previous", children: labelPrevious }), !alternative &&
28
+ api.pages.map((page, i) => {
29
+ if (page.type === 'page')
30
+ return (
31
+ // Numeral
32
+ _jsx("button", { type: "button", ...api.getItemProps(page), className: `${buttonBase} ${rxButtonActive(page)} ${buttonClasses}`, title: titleNumeral && `${titleNumeral} ${page.value}`, "data-testid": "pagination-button-numeral", children: page.value }, page.value));
33
+ else
34
+ return (
35
+ // Ellipsis
36
+ _jsx("span", { ...api.getEllipsisProps({ index: i }), className: `${buttonBase} ${buttonInactive} ${buttonClasses}`, "data-testid": "pagination-ellipsis", children: labelEllipsis }, `ellipsis-${i}`));
37
+ }), alternative && (_jsxs("span", { className: `${buttonBase} ${buttonInactive} ${buttonClasses}`, "data-testid": "pagination-alt-ui", children: [_jsxs("span", { children: [api.pageRange.start + 1, " - ", api.pageRange.end] }), _jsxs("span", { className: "opacity-60", children: [api.page, " ", textSeparator, " ", api.totalPages] })] })), _jsx("button", { type: "button", ...api.getNextTriggerProps(), className: `${buttonBase} ${buttonInactive} ${buttonHover} ${buttonClasses}`, title: titleNext, disabled: !api.nextPage, "data-testid": "pagination-button-next", children: labelNext }), alternative && (_jsx("button", { type: "button", onClick: api.goToLastPage, className: `${buttonBase} ${buttonInactive} ${buttonHover} ${buttonClasses}`, title: titleLast, disabled: !api.nextPage, "data-testid": "pagination-button-previous", children: labelLast }))] })) }));
38
+ };
@@ -0,0 +1,52 @@
1
+ import { ReactNode } from 'react';
2
+ import * as pagination from '@zag-js/pagination';
3
+ export interface PaginationProps extends Omit<pagination.Context, 'id'> {
4
+ data: unknown[];
5
+ alternative?: boolean;
6
+ /** Set the separator text or character, such as "of" in "X of Y". */
7
+ textSeparator?: string;
8
+ /** Set an optional title for the first button. */
9
+ titleFirst?: string;
10
+ /** Set an optional title for the previous button. */
11
+ titlePrevious?: string;
12
+ /** Set an optional title for the numeral buttons (ex: Page 1). */
13
+ titleNumeral?: string;
14
+ /** Set an optional title for the next button. */
15
+ titleNext?: string;
16
+ /** Set an optional title for the last button. */
17
+ titleLast?: string;
18
+ /** Sets base classes for the list. */
19
+ base?: string;
20
+ /** Sets background classes for the list. */
21
+ background?: string;
22
+ /** Sets border classes for the list. */
23
+ border?: string;
24
+ /** Sets gap classes for the list. */
25
+ gap?: string;
26
+ /** Sets padding classes for the list. */
27
+ padding?: string;
28
+ /** Sets border radius classes for the list. */
29
+ rounded?: string;
30
+ /** Provide arbitrary CSS classes for the root. */
31
+ classes?: string;
32
+ /** Sets base classes for buttons. */
33
+ buttonBase?: string;
34
+ /** Sets active state classes for buttons. */
35
+ buttonActive?: string;
36
+ /** Sets inactive state classes for buttons. */
37
+ buttonInactive?: string;
38
+ /** Sets hover state classes for buttons. */
39
+ buttonHover?: string;
40
+ /** Provide arbitrary CSS classes for buttons. */
41
+ buttonClasses?: string;
42
+ /** Set button icon or label for first button. */
43
+ labelFirst?: ReactNode;
44
+ /** Set button icon or label for previous button. */
45
+ labelPrevious?: ReactNode;
46
+ /** Set button icon or label for ellipsis. */
47
+ labelEllipsis?: ReactNode;
48
+ /** Set button icon or label for next button. */
49
+ labelNext?: ReactNode;
50
+ /** Set button icon or label for last button. */
51
+ labelLast?: ReactNode;
52
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,3 @@
1
- import { type FC } from "react";
2
- import { ProgressProps } from "./types.js";
1
+ import type { FC } from 'react';
2
+ import type { ProgressProps } from './types.js';
3
3
  export declare const Progress: FC<ProgressProps>;
@@ -1,17 +1,25 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect } from "react";
3
- export const Progress = ({ value, max = 100, labelledBy = "",
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as progress from '@zag-js/progress';
4
+ import { normalizeProps, useMachine } from '@zag-js/react';
5
+ import { useId } from 'react';
6
+ export const Progress = ({
4
7
  // Root
5
- base = "overflow-x-hidden", bg = "bg-surface-200-800", width = "w-full", height = "h-2", rounded = "rounded", classes = "",
8
+ base = 'flex items-center gap-4', height = 'h-2', width = 'w-full', classes = '',
9
+ // Label
10
+ labelBase = 'whitespace-nowrap', labelText = 'text-xs', labelClasses = '',
11
+ // Track
12
+ trackBase = 'h-full w-full overflow-x-hidden', trackBg = 'bg-surface-200-800', trackRounded = 'rounded', trackClasses = '',
6
13
  // Meter
7
- meterBase = "h-full", meterBg = "bg-surface-950-50", meterRounded = "rounded", meterTransition = "transition-[width]", meterAnimate = "animate-indeterminate", meterClasses = "", }) => {
8
- useEffect(() => {
9
- if (max < 0) {
10
- console.warn("The max prop should be greater than or equal to 0");
11
- }
12
- });
13
- const indeterminate = value === undefined;
14
- const fillPercentage = `${indeterminate ? 50 : ((value - 0) / (max - 0)) * 100}%`;
15
- const rxIndeterminate = indeterminate ? meterAnimate : "";
16
- return (_jsx(_Fragment, { children: _jsx("div", { role: "progressbar", "aria-labelledby": labelledBy, "aria-valuenow": value, "aria-valuemin": 0, "aria-valuemax": max, className: `${base} ${bg} ${width} ${height} ${rounded} ${classes}`, children: _jsx("div", { className: `${meterBase} ${meterBg} ${meterRounded} ${meterTransition} ${rxIndeterminate} ${meterClasses}`, style: { width: fillPercentage } }) }) }));
14
+ meterBase = 'h-full w-full', meterBg = 'bg-surface-950-50', meterRounded = 'rounded', meterTransition = 'transition-[width]', meterAnimate = 'animate-progress-indeterminate', meterClasses = '',
15
+ // Children
16
+ children,
17
+ // Zag
18
+ ...zagProps }) => {
19
+ // Zag
20
+ const [state, send] = useMachine(progress.machine({ id: useId() }), { context: zagProps });
21
+ const api = progress.connect(state, send, normalizeProps);
22
+ // Reactive
23
+ const rxIndeterminate = api.indeterminate ? meterAnimate : '';
24
+ return (_jsxs("figure", { ...api.getRootProps(), className: `${base} ${height} ${width} ${classes}`, "data-testid": "progress", children: [!!children && (_jsx("div", { ...api.getLabelProps(), className: `${labelBase} ${labelText} ${labelClasses}`, "data-testid": "progress-label", children: children })), _jsx("div", { ...api.getTrackProps(), className: `${trackBase} ${trackBg} ${trackRounded} ${trackClasses}`, "data-testid": "progress-track", children: _jsx("div", { ...api.getRangeProps(), className: `${meterBase} ${meterBg} ${meterRounded} ${meterTransition} ${rxIndeterminate} ${meterClasses}`, "data-testid": "progress-meter" }) })] }));
17
25
  };
@@ -1,10 +1,6 @@
1
- export interface ProgressProps {
2
- /** Set the value */
3
- value?: number;
4
- /** Set the maximum value */
5
- max?: number;
6
- /** Set the aria-labelledby */
7
- labelledBy?: string;
1
+ import * as progress from '@zag-js/progress';
2
+ import type { ReactNode } from 'react';
3
+ export interface ProgressProps extends React.PropsWithChildren, Omit<progress.Context, 'id'> {
8
4
  /** Set root base classes */
9
5
  base?: string;
10
6
  /** Set root background classes */
@@ -17,6 +13,20 @@ export interface ProgressProps {
17
13
  rounded?: string;
18
14
  /** Set root arbitrary classes */
19
15
  classes?: string;
16
+ /** Set label base classes. */
17
+ labelBase?: string;
18
+ /** Set label text classes. */
19
+ labelText?: string;
20
+ /** Set label classes. */
21
+ labelClasses?: string;
22
+ /** Set the track base classes. */
23
+ trackBase?: string;
24
+ /** Set the track background classes. */
25
+ trackBg?: string;
26
+ /** Set the track border radius classes. */
27
+ trackRounded?: string;
28
+ /** Set arbitrary track classes. */
29
+ trackClasses?: string;
20
30
  /** Set meter base classes. */
21
31
  meterBase?: string;
22
32
  /** Set meter bg classes */
@@ -25,8 +35,10 @@ export interface ProgressProps {
25
35
  meterRounded?: string;
26
36
  /** Set meter transition classes. */
27
37
  meterTransition?: string;
28
- /** Set meter animation classes for indeterminate mode. */
38
+ /** Set meter animation classes for indeterminate mode. (value === undefined) */
29
39
  meterAnimate?: string;
30
40
  /** Set meter arbitrary classes. */
31
41
  meterClasses?: string;
42
+ /** Set the label */
43
+ label?: ReactNode;
32
44
  }
@@ -0,0 +1,3 @@
1
+ import type { FC } from 'react';
2
+ import type { ProgressRingProps } from './types.js';
3
+ export declare const ProgressRing: FC<ProgressRingProps>;
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId } from 'react';
4
+ import { normalizeProps, useMachine } from '@zag-js/react';
5
+ import * as progress from '@zag-js/progress';
6
+ export const ProgressRing = ({ label, strokeWidth = '10px', strokeLinecap = 'round',
7
+ // Root
8
+ base = 'relative', size = 'size-32', classes = '',
9
+ // Slot
10
+ childrenBase = 'absolute top-0 left-0 z-[1] flex justify-center items-center', childrenClasses = '',
11
+ // SVG
12
+ svgBase = 'absolute top-0 left-0 size-full rounded-full', svgClasses = '',
13
+ // Track
14
+ trackBase = 'fill-none', trackStroke = 'stroke-surface-200-800', trackClasses = '',
15
+ // Meter
16
+ meterBase = 'fill-none', meterStroke = 'stroke-primary-500', meterTransition = 'transition-[stroke-dashoffset] transition-[stroke-dashoffset]', meterAnimate = 'animate-ring-indeterminate', meterDuration = 'duration-200', meterClasses = '',
17
+ // Label
18
+ labelBase = '', labelFill = 'fill-surface-950-50', labelFontSize = 24, // px
19
+ labelFontWeight = 'bold', labelClasses = '',
20
+ // Children
21
+ children,
22
+ // Zag
23
+ ...zagProps }) => {
24
+ // Zag
25
+ const [state, send] = useMachine(progress.machine({ id: useId() }), { context: zagProps });
26
+ const api = progress.connect(state, send, normalizeProps);
27
+ // Reactive Classes
28
+ const rxAnimCircle = api.indeterminate ? 'animate-spin' : '';
29
+ const rxAnimMeter = api.indeterminate ? meterAnimate : '';
30
+ return (_jsxs("figure", { ...api.getRootProps(), className: `${base} ${size} ${classes}`, "data-testid": "progress-ring", children: [_jsx("div", { ...api.getLabelProps(), className: `${childrenBase} ${size} ${childrenClasses}`, "data-testid": "progress-ring-children", children: children }), _jsxs("svg", { ...api.getCircleProps(), className: `${svgBase} ${svgClasses} ${rxAnimCircle}`, style: { '--size': '100%', '--thickness': strokeWidth }, "data-testid": "progress-ring-svg", children: [_jsx("circle", { ...api.getCircleTrackProps(), className: `${trackBase} ${trackStroke} ${trackClasses}`, "data-testid": "progress-ring-track" }), _jsx("circle", { ...api.getCircleRangeProps(), className: `${meterBase} ${meterStroke} ${meterTransition} ${meterDuration} ${meterClasses} ${rxAnimMeter}`, strokeLinecap: strokeLinecap, "data-testid": "progress-ring-meter" }), api.value !== null && !children && (_jsx("text", { className: `${labelBase} ${labelFill} ${labelClasses}`, x: "50%", y: "50%", fontSize: labelFontSize, fontWeight: labelFontWeight, textAnchor: "middle", dominantBaseline: "central", "data-testid": "progress-ring-label", children: label ?? `${api.value}%` }))] })] }));
31
+ };
@@ -0,0 +1,51 @@
1
+ import * as progress from '@zag-js/progress';
2
+ export interface ProgressRingProps extends React.PropsWithChildren, Omit<progress.Context, 'id'> {
3
+ /** Set the text for the scalable label */
4
+ label?: string;
5
+ /** Set the stroke size (ex: 15px) */
6
+ strokeWidth?: string;
7
+ /** Defines the shape of the meter */
8
+ strokeLinecap?: 'inherit' | 'butt' | 'round' | 'square';
9
+ /** Set the root base classes */
10
+ base?: string;
11
+ /** Set the root size classes */
12
+ size?: string;
13
+ /** Provide arbitrary classes to the root element */
14
+ classes?: string;
15
+ /** Set the nested children base classes */
16
+ childrenBase?: string;
17
+ /** Provide arbitrary classes to the nested children. */
18
+ childrenClasses?: string;
19
+ /** Set the SVG element base classes */
20
+ svgBase?: string;
21
+ /** Provide arbitrary classes to the SVG element */
22
+ svgClasses?: string;
23
+ /** Set the track base classes */
24
+ trackBase?: string;
25
+ /** Set the track stroke color classes */
26
+ trackStroke?: string;
27
+ /** Provide arbitrary classes to the track element */
28
+ trackClasses?: string;
29
+ /** Set the meter base classes */
30
+ meterBase?: string;
31
+ /** Set the meter stroke color classes */
32
+ meterStroke?: string;
33
+ /** Set the meter transition classes */
34
+ meterTransition?: string;
35
+ /** Set the meter animation classes */
36
+ meterAnimate?: string;
37
+ /** Set the meter transition duration classes */
38
+ meterDuration?: string;
39
+ /** Provide arbitrary classes to the meter element */
40
+ meterClasses?: string;
41
+ /** Set the label classes */
42
+ labelBase?: string;
43
+ /** Set the label fill color classes */
44
+ labelFill?: string;
45
+ /** Set the label font size */
46
+ labelFontSize?: number;
47
+ /** Set the label font weight */
48
+ labelFontWeight?: string;
49
+ /** Provide arbitrary classes to the label element */
50
+ labelClasses?: string;
51
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type FC } from 'react';
2
+ import type { RatingProps } from './types';
3
+ export declare const Rating: FC<RatingProps>;
@@ -0,0 +1,52 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, 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
+ import { starEmpty, starHalf, starFull } from '../../internal/nodes';
7
+ import { noop } from '../../internal/noop';
8
+ export const Rating = ({
9
+ // Root
10
+ base = '', classes = '',
11
+ // Control
12
+ controlBase = 'flex', controlGap = 'gap-2', controlClasses,
13
+ // Label
14
+ labelBase = '', labelClasses = '',
15
+ // Item
16
+ itemBase = '', itemClasses = '',
17
+ // State
18
+ stateInteractive = 'cursor-pointer', stateReadOnly = '', stateDisabled = 'cursor-not-allowed opacity-50',
19
+ // Icons
20
+ iconEmpty = starEmpty, iconHalf = starHalf, iconFull = starFull,
21
+ // Children
22
+ label,
23
+ // Events
24
+ onValueChange = noop,
25
+ // Zag
26
+ ...zagProps }) => {
27
+ // Zag
28
+ const [state, send] = useMachine(rating.machine({
29
+ id: useId(),
30
+ onValueChange: (details) => onValueChange(details.value)
31
+ }), { context: zagProps });
32
+ const api = rating.connect(state, send, normalizeProps);
33
+ // Reactive
34
+ const rxInteractive = state.context.isInteractive ? stateInteractive : '';
35
+ const rxReadOnly = state.context.readOnly ? stateReadOnly : '';
36
+ const rxDisabled = state.context.disabled ? stateDisabled : '';
37
+ 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} ${rxInteractive} ${rxReadOnly} ${rxDisabled} ${controlClasses}`, "data-testid": "rating-control", children: api.items.map((item) => {
38
+ const itemState = api.getItemState({ index: item });
39
+ const icon = (() => {
40
+ if (!itemState.highlighted) {
41
+ return iconEmpty;
42
+ }
43
+ else if (itemState.half) {
44
+ return iconHalf;
45
+ }
46
+ else {
47
+ return iconFull;
48
+ }
49
+ })();
50
+ return (_jsx(_Fragment, { children: _jsx("span", { ...api.getItemProps({ index: item }), className: `${itemBase} ${itemClasses}`, "data-testid": "rating-item", children: icon }, item) }));
51
+ }) }), _jsx("input", { ...api.getHiddenInputProps(), "data-testid": "rating-input" })] }));
52
+ };
@@ -0,0 +1,40 @@
1
+ import * as rating from '@zag-js/rating-group';
2
+ import type { ReactNode } from 'react';
3
+ export interface RatingProps extends Omit<rating.Context, 'id' | 'onValueChange'> {
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 interactive state classes */
25
+ stateInteractive?: string;
26
+ /** Set item read-only state classes */
27
+ stateReadOnly?: string;
28
+ /** Set item disabled state classes */
29
+ stateDisabled?: string;
30
+ /** Set the empty icon node */
31
+ iconEmpty?: ReactNode;
32
+ /** Set the half icon node */
33
+ iconHalf?: ReactNode;
34
+ /** Set the full icon node */
35
+ iconFull?: ReactNode;
36
+ /** Set the label node */
37
+ label?: ReactNode;
38
+ /** Set the onValueChange callback */
39
+ onValueChange?: (value: number) => void;
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ import type { SegmentContextState, SegmentProps, SegmentItemsProps } from './types.js';
3
+ export declare const SegmentContext: import("react").Context<SegmentContextState>;
4
+ export declare const Segment: FC<SegmentProps> & {
5
+ Item: FC<SegmentItemsProps>;
6
+ };