@skeletonlabs/skeleton-react 1.0.0-next.0 → 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.
- 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 +6 -8
- package/dist/components/AppBar/AppBar.js +28 -32
- package/dist/components/AppBar/types.d.ts +5 -5
- 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/FileUpload/FileUpload.d.ts +3 -0
- package/dist/components/FileUpload/FileUpload.js +41 -0
- package/dist/components/FileUpload/types.d.ts +73 -0
- package/dist/components/FileUpload/types.js +1 -0
- package/dist/components/Navigation/Navigation.d.ts +11 -0
- package/dist/components/Navigation/Navigation.js +103 -0
- package/dist/components/Navigation/types.d.ts +132 -0
- package/dist/components/Navigation/types.js +2 -0
- package/dist/components/Pagination/Pagination.d.ts +3 -0
- package/dist/components/Pagination/Pagination.js +38 -0
- package/dist/components/Pagination/types.d.ts +52 -0
- package/dist/components/Pagination/types.js +1 -0
- package/dist/components/Progress/Progress.d.ts +2 -2
- package/dist/components/Progress/Progress.js +22 -14
- package/dist/components/Progress/types.d.ts +20 -8
- package/dist/components/ProgressRing/ProgressRing.d.ts +3 -0
- package/dist/components/ProgressRing/ProgressRing.js +31 -0
- package/dist/components/ProgressRing/types.d.ts +51 -0
- package/dist/components/ProgressRing/types.js +1 -0
- package/dist/components/Rating/Rating.d.ts +3 -0
- package/dist/components/Rating/Rating.js +52 -0
- package/dist/components/Rating/types.d.ts +40 -0
- package/dist/components/Rating/types.js +1 -0
- package/dist/components/Segment/Segment.d.ts +6 -0
- package/dist/components/Segment/Segment.js +63 -0
- package/dist/components/Segment/types.d.ts +61 -0
- package/dist/components/Segment/types.js +2 -0
- package/dist/components/Slider/Slider.d.ts +3 -0
- package/dist/components/Slider/Slider.js +43 -0
- package/dist/components/Slider/types.d.ts +72 -0
- package/dist/components/Slider/types.js +1 -0
- package/dist/components/Switch/Switch.d.ts +3 -0
- package/dist/components/Switch/Switch.js +51 -0
- package/dist/components/Switch/types.d.ts +70 -0
- package/dist/components/Switch/types.js +1 -0
- 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/TagsInput/TagsInput.d.ts +3 -0
- package/dist/components/TagsInput/TagsInput.js +42 -0
- package/dist/components/TagsInput/types.d.ts +44 -0
- package/dist/components/TagsInput/types.js +1 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.js +14 -6
- 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 +46 -40
- package/dist/components/Test/Test.d.ts +0 -2
- package/dist/components/Test/Test.js +0 -10
- package/dist/utils/react-compose.d.ts +0 -4
- package/dist/utils/react-compose.js +0 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import * as accordion from '@zag-js/accordion';
|
|
3
|
+
import type { AccordionContextState, AccordionControlProps, AccordionItemProps, AccordionPanelProps, AccordionProps } from './types.js';
|
|
4
|
+
export declare const AccordionContext: import("react").Context<AccordionContextState>;
|
|
5
|
+
export declare const AccordionItemContext: import("react").Context<accordion.ItemProps>;
|
|
6
|
+
export declare const Accordion: FC<AccordionProps> & {
|
|
7
|
+
Item: FC<AccordionItemProps>;
|
|
8
|
+
Control: FC<AccordionControlProps>;
|
|
9
|
+
Panel: FC<AccordionPanelProps>;
|
|
9
10
|
};
|
|
@@ -1,98 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext,
|
|
4
|
-
import
|
|
3
|
+
import { createContext, useContext, useId } from 'react';
|
|
4
|
+
import * as accordion from '@zag-js/accordion';
|
|
5
|
+
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
+
import { noop } from '../../internal/noop.js';
|
|
5
7
|
// Contexts ---
|
|
6
8
|
export const AccordionContext = createContext({
|
|
7
9
|
animDuration: 0.2,
|
|
8
|
-
iconOpen:
|
|
9
|
-
iconClosed:
|
|
10
|
-
|
|
11
|
-
close: () => { },
|
|
12
|
-
toggle: () => { },
|
|
13
|
-
isOpen: () => false,
|
|
10
|
+
iconOpen: '-',
|
|
11
|
+
iconClosed: '+',
|
|
12
|
+
api: {}
|
|
14
13
|
});
|
|
15
14
|
export const AccordionItemContext = createContext({
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
value: '',
|
|
16
|
+
disabled: false
|
|
18
17
|
});
|
|
19
18
|
// Components ---
|
|
20
|
-
const AccordionRoot = ({
|
|
19
|
+
const AccordionRoot = ({ animDuration = 0.2,
|
|
21
20
|
// Root
|
|
22
|
-
base =
|
|
21
|
+
base = '', padding = '', spaceY = 'space-y-2', rounded = 'rounded', width = 'w-full', classes = '',
|
|
23
22
|
// Icons
|
|
24
|
-
iconOpen =
|
|
23
|
+
iconOpen = '-', iconClosed = '+',
|
|
25
24
|
// Events
|
|
26
|
-
onValueChange =
|
|
25
|
+
onValueChange = noop,
|
|
27
26
|
// Children
|
|
28
|
-
children,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
function isOpen(id) {
|
|
42
|
-
return value.includes(id);
|
|
43
|
-
}
|
|
44
|
-
// Effect
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
onValueChange(value);
|
|
47
|
-
}, [onValueChange, value]);
|
|
48
|
-
// Context
|
|
49
|
-
const ctx = {
|
|
50
|
-
animDuration,
|
|
51
|
-
iconOpen,
|
|
52
|
-
iconClosed,
|
|
53
|
-
open,
|
|
54
|
-
close,
|
|
55
|
-
toggle,
|
|
56
|
-
isOpen,
|
|
57
|
-
};
|
|
58
|
-
return (_jsx("div", { className: `${base} ${padding} ${spaceY} ${rounded} ${width} ${classes}`, "data-testid": "accordion", children: _jsx(AccordionContext.Provider, { value: ctx, children: children }) }));
|
|
27
|
+
children,
|
|
28
|
+
// Zag
|
|
29
|
+
...zagProps }) => {
|
|
30
|
+
// Zag
|
|
31
|
+
const [state, send] = useMachine(accordion.machine({
|
|
32
|
+
id: useId(),
|
|
33
|
+
onValueChange: (details) => {
|
|
34
|
+
onValueChange(details.value);
|
|
35
|
+
}
|
|
36
|
+
}), { context: zagProps });
|
|
37
|
+
const api = accordion.connect(state, send, normalizeProps);
|
|
38
|
+
return (_jsx("div", { className: `${base} ${padding} ${spaceY} ${rounded} ${width} ${classes}`, ...api.getRootProps(), "data-testid": "accordion", children: _jsx(AccordionContext.Provider, { value: { animDuration, iconOpen, iconClosed, api }, children: children }) }));
|
|
59
39
|
};
|
|
60
|
-
const AccordionItem = ({
|
|
61
|
-
// Events
|
|
62
|
-
onClick = () => { },
|
|
40
|
+
const AccordionItem = ({ base = '', spaceY = '', classes = '',
|
|
63
41
|
// Children
|
|
64
|
-
children, }) => {
|
|
65
|
-
|
|
42
|
+
children, ...zagProps }) => {
|
|
43
|
+
const ctx = useContext(AccordionContext);
|
|
44
|
+
return (_jsx(AccordionItemContext.Provider, { value: zagProps, children: _jsx("div", { className: `${base} ${spaceY} ${classes}`, ...ctx?.api.getItemProps(zagProps), "data-testid": "accordion-item", children: children }) }));
|
|
66
45
|
};
|
|
67
|
-
const AccordionControl = ({
|
|
46
|
+
const AccordionControl = ({ headingElement = 'h3',
|
|
68
47
|
// Control
|
|
69
|
-
base =
|
|
48
|
+
base = 'flex text-start items-center space-x-4 w-full', hover = 'hover:preset-tonal-primary', padding = 'py-2 px-4', rounded = 'rounded', classes = '',
|
|
49
|
+
// Lead
|
|
50
|
+
leadBase = '', leadClasses = '',
|
|
51
|
+
// Content
|
|
52
|
+
contentBase = 'flex-1', contentClasses = '',
|
|
53
|
+
// Indicator
|
|
54
|
+
indicatorBase = '', indicatorClasses = '',
|
|
70
55
|
// Icons
|
|
71
56
|
lead,
|
|
72
57
|
// Children
|
|
73
|
-
children
|
|
74
|
-
const
|
|
58
|
+
children }) => {
|
|
59
|
+
const ctx = useContext(AccordionContext);
|
|
75
60
|
const itemCtx = useContext(AccordionItemContext);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
itemCtx.onClick(event);
|
|
79
|
-
}
|
|
80
|
-
return (_jsxs("button", { type: "button", className: `${base} ${hover} ${padding} ${rounded} ${classes}`, "aria-expanded": rootCtx.isOpen(itemCtx.id), "aria-controls": `accordion-panel-${itemCtx.id}`, onClick: clickHandler, disabled: disabled, "data-testid": "accordion-control", children: [lead && _jsx("div", { children: lead }), _jsx("div", { className: "flex-1", children: children }), _jsx("div", { className: `${iconsBase}`, children: rootCtx.isOpen(itemCtx.id) ? rootCtx.iconOpen : rootCtx.iconClosed })] }));
|
|
61
|
+
const HeadingElement = headingElement;
|
|
62
|
+
return (_jsx(HeadingElement, { children: _jsxs("button", { className: `${base} ${hover} ${padding} ${rounded} ${classes}`, ...ctx.api.getItemTriggerProps(itemCtx), "data-testid": "accordion-control", children: [lead && (_jsx("div", { className: `${leadBase} ${leadClasses}`, "data-testid": "accordion-lead", children: lead })), _jsx("div", { className: `${contentBase} ${contentClasses}`, "data-testid": "accordion-content", children: children }), _jsx("div", { className: `${indicatorBase} ${indicatorClasses}`, "data-testid": "accordion-indicator", children: ctx.api.value.includes(itemCtx.value) ? ctx.iconOpen : ctx.iconClosed })] }) }));
|
|
81
63
|
};
|
|
82
64
|
const AccordionPanel = ({
|
|
83
65
|
// Panel
|
|
84
|
-
base =
|
|
66
|
+
base = '', padding = 'py-2 px-4', rounded = '', classes = '',
|
|
85
67
|
// Children
|
|
86
|
-
children
|
|
87
|
-
const
|
|
68
|
+
children }) => {
|
|
69
|
+
const ctx = useContext(AccordionContext);
|
|
88
70
|
const itemCtx = useContext(AccordionItemContext);
|
|
89
|
-
return (_jsx("div", {
|
|
90
|
-
open: { opacity: 1, height: "auto" },
|
|
91
|
-
collapsed: { opacity: 0, height: 0 },
|
|
92
|
-
}, transition: { duration: rootCtx.animDuration && 0.2 }, children: _jsx("div", { className: `${base} ${padding} ${rounded} ${classes}`, "data-testid": "accordion-panel-children", children: children }) })) }) }));
|
|
71
|
+
return (ctx.api.value.includes(itemCtx.value) && (_jsx("div", { ...ctx.api.getItemContentProps(itemCtx), className: `${base} ${padding} ${rounded} ${classes}`, "data-testid": "accordion-panel", children: children })));
|
|
93
72
|
};
|
|
94
73
|
export const Accordion = Object.assign(AccordionRoot, {
|
|
95
74
|
Item: AccordionItem,
|
|
96
75
|
Control: AccordionControl,
|
|
97
|
-
Panel: AccordionPanel
|
|
76
|
+
Panel: AccordionPanel
|
|
98
77
|
});
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import React, { type ReactNode } from
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import * as accordion from '@zag-js/accordion';
|
|
2
3
|
export interface AccordionContextState {
|
|
3
|
-
animDuration
|
|
4
|
-
iconOpen
|
|
5
|
-
iconClosed
|
|
6
|
-
|
|
7
|
-
close: (id: string) => void;
|
|
8
|
-
toggle: (id: string) => void;
|
|
9
|
-
isOpen: (id: string) => boolean;
|
|
4
|
+
animDuration: number;
|
|
5
|
+
iconOpen: ReactNode;
|
|
6
|
+
iconClosed: ReactNode;
|
|
7
|
+
api: ReturnType<typeof accordion.connect>;
|
|
10
8
|
}
|
|
11
9
|
export interface AccordionItemContextState {
|
|
12
10
|
id: string;
|
|
13
11
|
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
14
12
|
}
|
|
15
|
-
export interface AccordionProps extends React.PropsWithChildren {
|
|
16
|
-
/**
|
|
17
|
-
* Enables opening multiple items at once.
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
multiple?: boolean;
|
|
21
|
-
/** Takes an array list of open items. */
|
|
22
|
-
value?: string[];
|
|
23
|
-
/** The slide animation duration in milliseconds. */
|
|
13
|
+
export interface AccordionProps extends React.PropsWithChildren, Omit<accordion.Context, 'id' | 'orientation' | 'onValueChange'> {
|
|
14
|
+
/** The slide animation duration as a float value (ex: 0.2). */
|
|
24
15
|
animDuration?: number;
|
|
25
16
|
/** Set the open state icon. */
|
|
26
17
|
iconOpen?: ReactNode;
|
|
27
18
|
/** Set the closed state icon. */
|
|
28
19
|
iconClosed?: ReactNode;
|
|
29
20
|
/** Set the opened state. */
|
|
30
|
-
onValueChange?: (
|
|
21
|
+
onValueChange?: (value: string[]) => void;
|
|
31
22
|
/** Sets base styles. */
|
|
32
23
|
base?: string;
|
|
33
24
|
/** Set padding styles. */
|
|
@@ -41,19 +32,17 @@ export interface AccordionProps extends React.PropsWithChildren {
|
|
|
41
32
|
/** Provide arbitrary CSS classes. */
|
|
42
33
|
classes?: string;
|
|
43
34
|
}
|
|
44
|
-
export interface AccordionItemProps extends React.PropsWithChildren {
|
|
45
|
-
/** The unique ID. */
|
|
46
|
-
id: string;
|
|
35
|
+
export interface AccordionItemProps extends React.PropsWithChildren, accordion.ItemProps {
|
|
47
36
|
/** Sets base styles. */
|
|
48
37
|
base?: string;
|
|
49
38
|
/** Set vertical spacing styles. */
|
|
50
39
|
spaceY?: string;
|
|
51
40
|
/** Provide arbitrary CSS classes. */
|
|
52
41
|
classes?: string;
|
|
53
|
-
/** Triggers on item click. */
|
|
54
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
55
42
|
}
|
|
56
43
|
export interface AccordionControlProps extends React.PropsWithChildren {
|
|
44
|
+
/** The heading element. */
|
|
45
|
+
headingElement?: keyof JSX.IntrinsicElements;
|
|
57
46
|
/** Set a disabled state for the item. */
|
|
58
47
|
disabled?: boolean;
|
|
59
48
|
/** Sets control's base styles. */
|
|
@@ -66,8 +55,18 @@ export interface AccordionControlProps extends React.PropsWithChildren {
|
|
|
66
55
|
rounded?: string;
|
|
67
56
|
/** Provide arbitrary CSS classes to the control. */
|
|
68
57
|
classes?: string;
|
|
69
|
-
/**
|
|
70
|
-
|
|
58
|
+
/** Sets the lead's base styles */
|
|
59
|
+
leadBase?: string;
|
|
60
|
+
/** Provide arbitrary CSS classes to the lead. */
|
|
61
|
+
leadClasses?: string;
|
|
62
|
+
/** Sets the lead's base styles */
|
|
63
|
+
contentBase?: string;
|
|
64
|
+
/** Provide arbitrary CSS classes to the content. */
|
|
65
|
+
contentClasses?: string;
|
|
66
|
+
/** Sets the lead's base styles */
|
|
67
|
+
indicatorBase?: string;
|
|
68
|
+
/** Provide arbitrary CSS classes to the indicator. */
|
|
69
|
+
indicatorClasses?: string;
|
|
71
70
|
/** The lead child slot for the control. */
|
|
72
71
|
lead?: ReactNode;
|
|
73
72
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {
|
|
3
|
-
export declare const ToolBar: React.FC<AppBarToolBarProps> & {
|
|
4
|
-
Lead: React.FC<AppBarLeadProps>;
|
|
5
|
-
Center: React.FC<AppBarCenterProps>;
|
|
6
|
-
Trail: React.FC<AppBarTrailProps>;
|
|
7
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarCenterProps, AppBarHeadlineProps, ToolbarLeadProps, AppBarProps, ToolBarProps, ToolbarTrailProps } from './types.js';
|
|
8
3
|
export declare const AppBar: React.FC<AppBarProps> & {
|
|
9
|
-
Toolbar: React.FC<
|
|
4
|
+
Toolbar: React.FC<ToolBarProps>;
|
|
5
|
+
ToolbarLead: React.FC<ToolbarLeadProps>;
|
|
6
|
+
ToolbarCenter: React.FC<ToolbarCenterProps>;
|
|
7
|
+
ToolbarTrail: React.FC<ToolbarTrailProps>;
|
|
10
8
|
Headline: React.FC<AppBarHeadlineProps>;
|
|
11
9
|
};
|
|
@@ -1,56 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
// React Compose ---
|
|
4
|
-
import { reactCompose } from "../../utils/react-compose.js";
|
|
5
3
|
// Components ---
|
|
6
4
|
const AppBarRoot = ({
|
|
7
5
|
// Root
|
|
8
|
-
base =
|
|
6
|
+
base = 'w-full flex flex-col', background = 'bg-surface-100-900', spaceY = 'space-y-4', border = '', padding = 'p-4', shadow = '', classes = '',
|
|
9
7
|
// Children
|
|
10
|
-
children
|
|
8
|
+
children }) => {
|
|
11
9
|
return (_jsx("div", { className: `${base} ${background} ${spaceY} ${border} ${padding} ${shadow} ${classes}`, role: "toolbar", "data-testid": "app-bar", children: children }));
|
|
12
10
|
};
|
|
13
|
-
const
|
|
11
|
+
const Toolbar = ({
|
|
14
12
|
// Toolbar
|
|
15
|
-
base =
|
|
13
|
+
base = 'flex justify-between', gridCols = 'grid-cols-[auto_1fr_auto]', gap = 'gap-4', classes = '',
|
|
16
14
|
// Children
|
|
17
|
-
children
|
|
18
|
-
return (_jsx("div", { className: `${base} ${gridCols} ${gap} ${classes}`, children: children }));
|
|
15
|
+
children }) => {
|
|
16
|
+
return (_jsx("div", { className: `${base} ${gridCols} ${gap} ${classes}`, "data-testid": "app-bar-toolbar", children: children }));
|
|
19
17
|
};
|
|
20
|
-
const
|
|
18
|
+
const ToolbarLead = ({
|
|
21
19
|
// Lead
|
|
22
|
-
base =
|
|
20
|
+
base = 'flex', spaceX = 'space-x-4 rtl:space-x-reverse', padding = '', classes = '',
|
|
23
21
|
// Children
|
|
24
|
-
children
|
|
25
|
-
return (_jsx("div", { className: `${base} ${spaceX} ${padding} ${classes}`, children: children }));
|
|
22
|
+
children }) => {
|
|
23
|
+
return (_jsx("div", { className: `${base} ${spaceX} ${padding} ${classes}`, "data-testid": "app-bar-toolbar-lead", children: children }));
|
|
26
24
|
};
|
|
27
|
-
const
|
|
25
|
+
const ToolbarCenter = ({
|
|
28
26
|
// Center
|
|
29
|
-
base =
|
|
27
|
+
base = 'grow', align = 'text-center', padding = '', classes = '',
|
|
30
28
|
// Children
|
|
31
|
-
children
|
|
32
|
-
return (_jsx("div", { className: `${base} ${align} ${padding} ${classes}`, children: children }));
|
|
29
|
+
children }) => {
|
|
30
|
+
return (_jsx("div", { className: `${base} ${align} ${padding} ${classes}`, "data-testid": "app-bar-toolbar-center", children: children }));
|
|
33
31
|
};
|
|
34
|
-
const
|
|
32
|
+
const ToolbarTrail = ({
|
|
35
33
|
// Trail
|
|
36
|
-
base =
|
|
34
|
+
base = 'flex', spaceX = 'space-x-4 rtl:space-x-reverse', padding = '', classes = '',
|
|
37
35
|
// Children
|
|
38
|
-
children
|
|
39
|
-
return (_jsx("div", { className: `${base} ${spaceX} ${padding} ${classes}`, children: children }));
|
|
36
|
+
children }) => {
|
|
37
|
+
return (_jsx("div", { className: `${base} ${spaceX} ${padding} ${classes}`, "data-testid": "app-bar-toolbar-trail", children: children }));
|
|
40
38
|
};
|
|
41
39
|
const AppBarHeadline = ({
|
|
42
40
|
// Headline
|
|
43
|
-
base =
|
|
41
|
+
base = 'w-full', classes = '',
|
|
44
42
|
// Children
|
|
45
|
-
children
|
|
46
|
-
return _jsx("div", { className: `${base} ${classes}`, children: children });
|
|
43
|
+
children }) => {
|
|
44
|
+
return (_jsx("div", { className: `${base} ${classes}`, "data-testid": "app-bar-headline", children: children }));
|
|
47
45
|
};
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Toolbar: ToolBar,
|
|
55
|
-
Headline: AppBarHeadline,
|
|
46
|
+
export const AppBar = Object.assign(AppBarRoot, {
|
|
47
|
+
Toolbar: Toolbar,
|
|
48
|
+
ToolbarLead: ToolbarLead,
|
|
49
|
+
ToolbarCenter: ToolbarCenter,
|
|
50
|
+
ToolbarTrail: ToolbarTrail,
|
|
51
|
+
Headline: AppBarHeadline
|
|
56
52
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface AppBarProps extends React.PropsWithChildren {
|
|
3
3
|
/** Set base styles. */
|
|
4
4
|
base?: string;
|
|
@@ -15,7 +15,7 @@ export interface AppBarProps extends React.PropsWithChildren {
|
|
|
15
15
|
/** Provide arbitrary CSS classes. */
|
|
16
16
|
classes?: string;
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
18
|
+
export interface ToolBarProps extends React.PropsWithChildren {
|
|
19
19
|
/** Sets the toolbar component's base styles. */
|
|
20
20
|
base?: string;
|
|
21
21
|
/** Sets the toolbar component's grid columns styles. */
|
|
@@ -25,7 +25,7 @@ export interface AppBarToolBarProps extends React.PropsWithChildren {
|
|
|
25
25
|
/** Provide arbitrary CSS classes to the toolbar component. */
|
|
26
26
|
classes?: string;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
28
|
+
export interface ToolbarLeadProps extends React.PropsWithChildren {
|
|
29
29
|
/** Sets the lead component's base styles. */
|
|
30
30
|
base?: string;
|
|
31
31
|
/** Sets the lead component's horizontal spacing styles. */
|
|
@@ -35,7 +35,7 @@ export interface AppBarLeadProps extends React.PropsWithChildren {
|
|
|
35
35
|
/** Provide arbitrary CSS classes to the lead component. */
|
|
36
36
|
classes?: string;
|
|
37
37
|
}
|
|
38
|
-
export interface
|
|
38
|
+
export interface ToolbarCenterProps extends React.PropsWithChildren {
|
|
39
39
|
/** Sets the center component's base styles. */
|
|
40
40
|
base?: string;
|
|
41
41
|
/** Sets the center component's alignment styles. */
|
|
@@ -45,7 +45,7 @@ export interface AppBarCenterProps extends React.PropsWithChildren {
|
|
|
45
45
|
/** Provide arbitrary CSS classes to the center component. */
|
|
46
46
|
classes?: string;
|
|
47
47
|
}
|
|
48
|
-
export interface
|
|
48
|
+
export interface ToolbarTrailProps extends React.PropsWithChildren {
|
|
49
49
|
/** Sets the trail component's base styles. */
|
|
50
50
|
base?: string;
|
|
51
51
|
/** Sets the trail component's horizontal spacing styles. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { AvatarProps } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AvatarProps } from './types.js';
|
|
3
3
|
export declare const Avatar: React.FC<AvatarProps>;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import * as avatar from '@zag-js/avatar';
|
|
5
|
+
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
+
export const Avatar = ({ src, srcSet, name, filter,
|
|
4
7
|
// Root
|
|
5
|
-
base =
|
|
8
|
+
base = 'overflow-hidden isolate', background = 'bg-surface-400-600', size = 'size-16', font = '', border = '', rounded = 'rounded-full', shadow = '', classes = '',
|
|
6
9
|
// Image
|
|
7
|
-
imageBase =
|
|
10
|
+
imageBase = 'w-full object-cover', imageClasses = '',
|
|
11
|
+
// Fallback
|
|
12
|
+
fallbackBase = 'w-full h-full flex justify-center items-center', fallbackClasses = '',
|
|
8
13
|
// Children
|
|
9
|
-
children
|
|
10
|
-
|
|
14
|
+
children }) => {
|
|
15
|
+
// Zag
|
|
16
|
+
const [state, send] = useMachine(avatar.machine({ id: useId() }));
|
|
17
|
+
const api = avatar.connect(state, send, normalizeProps);
|
|
18
|
+
function getInitials(name) {
|
|
19
|
+
return name
|
|
20
|
+
.split(' ')
|
|
21
|
+
.map((word) => word[0])
|
|
22
|
+
.join('');
|
|
23
|
+
}
|
|
24
|
+
return (_jsxs("figure", { ...api.getRootProps(), className: `${base} ${background} ${size} ${font} ${border} ${rounded} ${shadow} ${classes}`, "data-testid": "avatar", children: [(src || srcSet) && (_jsx("img", { ...api.getImageProps(), src: src, srcSet: srcSet, alt: name, className: `${imageBase} ${imageClasses}`, style: { filter: filter ? `url(${filter})` : undefined }, "data-testid": "avatar-image" })), _jsx("span", { ...api.getFallbackProps(), className: `${fallbackBase} ${fallbackClasses}`, "data-testid": "avatar-fallback", children: children ? children : getInitials(name) })] }));
|
|
11
25
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export interface AvatarProps extends React.PropsWithChildren {
|
|
3
|
-
/**
|
|
2
|
+
/** The source of the avatar image. */
|
|
4
3
|
src?: string;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
/**
|
|
4
|
+
/** The source set of the avatar image. */
|
|
5
|
+
srcSet?: string;
|
|
6
|
+
/** Provide a name or username for the avatar. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Set avatar image filter name, such as: "#Apollo". */
|
|
8
9
|
filter?: string;
|
|
9
10
|
/** Set base styles. */
|
|
10
11
|
base?: string;
|
|
@@ -26,4 +27,8 @@ export interface AvatarProps extends React.PropsWithChildren {
|
|
|
26
27
|
imageBase?: string;
|
|
27
28
|
/** Provide avatar image arbitrary CSS classes. */
|
|
28
29
|
imageClasses?: string;
|
|
30
|
+
/** Set base classes for the fallback element. */
|
|
31
|
+
fallbackBase?: string;
|
|
32
|
+
/** Provide arbitrary CSS classes to fallback element. */
|
|
33
|
+
fallbackClasses?: string;
|
|
29
34
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId } from 'react';
|
|
4
|
+
import * as fileUpload from '@zag-js/file-upload';
|
|
5
|
+
import { normalizeProps, useMachine } from '@zag-js/react';
|
|
6
|
+
export const FileUpload = ({ label = `Select file or drag here`, subtext = '',
|
|
7
|
+
// Root
|
|
8
|
+
base = '', classes = '',
|
|
9
|
+
// Interface
|
|
10
|
+
interfaceBase = 'flex flex-col items-center gap-2 hover:cursor-pointer', interfaceBg = 'hover:preset-tonal', interfaceBorder = 'border-[1px] border-dashed', interfaceBorderColor = 'border-surface-200-800', interfacePadding = 'p-4 py-10', interfaceRounded = 'rounded-container', interfaceClasses = '',
|
|
11
|
+
// Interface (content)
|
|
12
|
+
interfaceIcon = '', interfaceText = '', interfaceSubtext = 'type-scale-1 opacity-60',
|
|
13
|
+
// Files List
|
|
14
|
+
filesListBase = 'mt-2 space-y-2', filesListClasses = '',
|
|
15
|
+
// File
|
|
16
|
+
fileBase = 'grid grid-cols-[auto_1fr_auto] rtl:grid-cols-[1fr_auto_auto] items-center', fileBg = 'preset-tonal', fileGap = 'gap-4 px-4', filePadding = 'py-2', fileRounded = 'rounded', fileClasses = '',
|
|
17
|
+
// File (content)
|
|
18
|
+
fileIcon = '', fileName = 'type-scale-2 flex items-center gap-4', fileSize = 'type-scale-1 opacity-60', fileButton = '',
|
|
19
|
+
// State
|
|
20
|
+
stateInvalid = 'border-error-500', stateDisabled = 'disabled', stateDragging = 'preset-filled-primary-500',
|
|
21
|
+
// Children
|
|
22
|
+
children, iconInterface, iconFile, iconFileRemove,
|
|
23
|
+
// Zag
|
|
24
|
+
internalApi, ...zagProps }) => {
|
|
25
|
+
// Zag
|
|
26
|
+
const [state, send] = useMachine(fileUpload.machine({
|
|
27
|
+
id: useId()
|
|
28
|
+
}), { context: zagProps });
|
|
29
|
+
const api = fileUpload.connect(state, send, normalizeProps);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (internalApi)
|
|
32
|
+
internalApi(api);
|
|
33
|
+
}, [internalApi, api]);
|
|
34
|
+
// Reactive
|
|
35
|
+
const rxDisabled = state.context.disabled ? stateDisabled : '';
|
|
36
|
+
const rxInvalid = api.rejectedFiles.length > 0 ? stateInvalid : interfaceBorderColor;
|
|
37
|
+
const rxDragging = api.dragging && !children ? stateDragging : '';
|
|
38
|
+
return (_jsxs("div", { ...api.getRootProps(), className: `${base} ${rxDisabled} ${classes}`, style: { display: children ? 'inline-block' : 'block' }, "data-testid": "uploader", children: [_jsxs("div", { ...api.getDropzoneProps(), children: [_jsx("input", { ...api.getHiddenInputProps(), "data-testid": "uploader-input" }), children ?? (_jsxs("div", { className: `${interfaceBase} ${interfaceBg} ${interfaceBorder} ${interfacePadding} ${interfaceRounded} ${rxInvalid} ${rxDragging} ${interfaceClasses}`, "data-testid": "uploader-interface", children: [iconInterface && (_jsx("span", { className: interfaceIcon, "data-testid": "uploader-interface-icon", children: iconInterface })), label && (_jsx("p", { className: interfaceText, "data-testid": "uploader-interface-text", children: label })), subtext && (_jsx("small", { className: interfaceSubtext, "data-testid": "uploader-interface-subtext", children: subtext }))] }))] }), !children && (_jsx("ul", { ...api.getItemGroupProps(), className: `${filesListBase} ${filesListClasses}`, "data-testid": "uploader-files-list", children: api.acceptedFiles.map((file) => (
|
|
39
|
+
// File
|
|
40
|
+
_jsxs("li", { ...api.getItemProps({ file }), className: `${fileBase} ${fileBg} ${fileGap} ${filePadding} ${fileRounded} ${fileClasses}`, "data-testid": "uploader-file", children: [_jsxs("p", { ...api.getItemNameProps({ file }), className: fileName, "data-testid": "uploader-file-name", children: [iconFile ?? (_jsx("span", { className: fileIcon, "data-testid": "uploader-file-icon", children: iconFile })), _jsx("span", { children: file.name })] }), _jsx("p", { ...api.getItemNameProps({ file }), className: fileSize, "data-testid": "uploader-file-size", children: api.getFileSize(file) }), _jsx("button", { ...api.getItemDeleteTriggerProps({ file }), className: fileButton, "data-testid": "uploader-file-button", children: iconFileRemove ?? _jsx("span", { children: "\u2715" }) })] }, file.name))) }))] }));
|
|
41
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import * as fileUpload from '@zag-js/file-upload';
|
|
3
|
+
import type { PropTypes } from '@zag-js/react';
|
|
4
|
+
export interface FileUploadApi extends fileUpload.Api<PropTypes> {
|
|
5
|
+
}
|
|
6
|
+
export interface FileUploadProps extends React.PropsWithChildren, Omit<fileUpload.Context, 'id'> {
|
|
7
|
+
/** Set the interface text value. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Set the interface subtext value. */
|
|
10
|
+
subtext?: string;
|
|
11
|
+
/** Set root base classes */
|
|
12
|
+
base?: string;
|
|
13
|
+
/** Set root arbitrary classes */
|
|
14
|
+
classes?: string;
|
|
15
|
+
/** Set interface base classes */
|
|
16
|
+
interfaceBase?: string;
|
|
17
|
+
/** Set interface background classes */
|
|
18
|
+
interfaceBg?: string;
|
|
19
|
+
/** Set interface border classes */
|
|
20
|
+
interfaceBorder?: string;
|
|
21
|
+
/** Set interface border color classes */
|
|
22
|
+
interfaceBorderColor?: string;
|
|
23
|
+
/** Set interface border classes */
|
|
24
|
+
interfacePadding?: string;
|
|
25
|
+
/** Set interface border radius classes */
|
|
26
|
+
interfaceRounded?: string;
|
|
27
|
+
/** Set interface arbitrary classes */
|
|
28
|
+
interfaceClasses?: string;
|
|
29
|
+
/** Set interface icon classes */
|
|
30
|
+
interfaceIcon?: string;
|
|
31
|
+
/** Set interface text classes */
|
|
32
|
+
interfaceText?: string;
|
|
33
|
+
/** Set interface subtext classes */
|
|
34
|
+
interfaceSubtext?: string;
|
|
35
|
+
/** Set file list base classes */
|
|
36
|
+
filesListBase?: string;
|
|
37
|
+
/** Set file list arbitrary classes */
|
|
38
|
+
filesListClasses?: string;
|
|
39
|
+
/** Set file base classes */
|
|
40
|
+
fileBase?: string;
|
|
41
|
+
/** Set file background classes */
|
|
42
|
+
fileBg?: string;
|
|
43
|
+
/** Set file gap classes */
|
|
44
|
+
fileGap?: string;
|
|
45
|
+
/** Set file padding classes */
|
|
46
|
+
filePadding?: string;
|
|
47
|
+
/** Set file border-radius classes */
|
|
48
|
+
fileRounded?: string;
|
|
49
|
+
/** Set file arbitrary classes */
|
|
50
|
+
fileClasses?: string;
|
|
51
|
+
/** Set file icon classes */
|
|
52
|
+
fileIcon?: string;
|
|
53
|
+
/** Set file name classes */
|
|
54
|
+
fileName?: string;
|
|
55
|
+
/** Set file size classes */
|
|
56
|
+
fileSize?: string;
|
|
57
|
+
/** Set file button classes */
|
|
58
|
+
fileButton?: string;
|
|
59
|
+
/** Set disabled state classes for the root. */
|
|
60
|
+
stateDisabled?: string;
|
|
61
|
+
/** Set invalid state classes for the interface. */
|
|
62
|
+
stateInvalid?: string;
|
|
63
|
+
/** Set dragging state classes for the interface. */
|
|
64
|
+
stateDragging?: string;
|
|
65
|
+
/** Provide an icon for the interface. */
|
|
66
|
+
iconInterface?: ReactNode;
|
|
67
|
+
/** Provide an icon proceeding each file. */
|
|
68
|
+
iconFile?: ReactNode;
|
|
69
|
+
/** Provide an icon for the remove file action. */
|
|
70
|
+
iconFileRemove?: ReactNode;
|
|
71
|
+
/** Binds the Zag API for external use. */
|
|
72
|
+
internalApi?: (api: FileUploadApi) => void;
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NavContextState, NavRailProps, NavBarProps, NavTileProps } from './types.js';
|
|
3
|
+
export declare const NavContext: React.Context<NavContextState>;
|
|
4
|
+
export declare const NavRail: React.FC<NavRailProps>;
|
|
5
|
+
export declare const NavBar: React.FC<NavBarProps>;
|
|
6
|
+
export declare const NavTile: React.FC<NavTileProps>;
|
|
7
|
+
export declare const Nav: (() => null) & {
|
|
8
|
+
Rail: React.FC<NavRailProps>;
|
|
9
|
+
Bar: React.FC<NavBarProps>;
|
|
10
|
+
Tile: React.FC<NavTileProps>;
|
|
11
|
+
};
|