@skeletonlabs/skeleton-react 1.4.0 → 2.0.0-next.1
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/index.css +2 -0
- package/dist/index.d.ts +85 -17
- package/dist/index.js +162 -17
- package/package.json +30 -31
- package/dist/components/Accordion/Accordion.d.ts +0 -7
- package/dist/components/Accordion/Accordion.js +0 -62
- package/dist/components/Accordion/context.d.ts +0 -4
- package/dist/components/Accordion/context.js +0 -10
- package/dist/components/Accordion/types.d.ts +0 -73
- package/dist/components/Accordion/types.js +0 -2
- package/dist/components/AppBar/AppBar.d.ts +0 -9
- package/dist/components/AppBar/AppBar.js +0 -52
- package/dist/components/AppBar/types.d.ts +0 -63
- package/dist/components/AppBar/types.js +0 -1
- package/dist/components/Avatar/Avatar.d.ts +0 -3
- package/dist/components/Avatar/Avatar.js +0 -28
- package/dist/components/Avatar/types.d.ts +0 -36
- package/dist/components/Avatar/types.js +0 -1
- package/dist/components/FileUpload/FileUpload.d.ts +0 -3
- package/dist/components/FileUpload/FileUpload.js +0 -41
- package/dist/components/FileUpload/types.d.ts +0 -73
- package/dist/components/FileUpload/types.js +0 -1
- package/dist/components/Navigation/Navigation.d.ts +0 -10
- package/dist/components/Navigation/Navigation.js +0 -92
- package/dist/components/Navigation/context.d.ts +0 -2
- package/dist/components/Navigation/context.js +0 -7
- package/dist/components/Navigation/types.d.ts +0 -132
- package/dist/components/Navigation/types.js +0 -2
- package/dist/components/Pagination/Pagination.d.ts +0 -3
- package/dist/components/Pagination/Pagination.js +0 -39
- package/dist/components/Pagination/types.d.ts +0 -56
- package/dist/components/Pagination/types.js +0 -1
- package/dist/components/Progress/Progress.d.ts +0 -3
- package/dist/components/Progress/Progress.js +0 -28
- package/dist/components/Progress/types.d.ts +0 -44
- package/dist/components/Progress/types.js +0 -1
- package/dist/components/ProgressRing/ProgressRing.d.ts +0 -3
- package/dist/components/ProgressRing/ProgressRing.js +0 -34
- package/dist/components/ProgressRing/types.d.ts +0 -53
- package/dist/components/ProgressRing/types.js +0 -1
- package/dist/components/Rating/Rating.d.ts +0 -3
- package/dist/components/Rating/Rating.js +0 -50
- package/dist/components/Rating/types.d.ts +0 -36
- package/dist/components/Rating/types.js +0 -1
- package/dist/components/Segment/Segment.d.ts +0 -5
- package/dist/components/Segment/Segment.js +0 -58
- package/dist/components/Segment/context.d.ts +0 -2
- package/dist/components/Segment/context.js +0 -5
- package/dist/components/Segment/types.d.ts +0 -59
- package/dist/components/Segment/types.js +0 -2
- package/dist/components/Slider/Slider.d.ts +0 -3
- package/dist/components/Slider/Slider.js +0 -39
- package/dist/components/Slider/types.d.ts +0 -66
- package/dist/components/Slider/types.js +0 -1
- package/dist/components/Switch/Switch.d.ts +0 -3
- package/dist/components/Switch/Switch.js +0 -40
- package/dist/components/Switch/types.d.ts +0 -62
- package/dist/components/Switch/types.js +0 -1
- package/dist/components/Tabs/Tabs.d.ts +0 -12
- package/dist/components/Tabs/Tabs.js +0 -80
- package/dist/components/Tabs/context.d.ts +0 -2
- package/dist/components/Tabs/context.js +0 -5
- package/dist/components/Tabs/types.d.ts +0 -64
- package/dist/components/Tabs/types.js +0 -1
- package/dist/components/TagsInput/TagsInput.d.ts +0 -3
- package/dist/components/TagsInput/TagsInput.js +0 -39
- package/dist/components/TagsInput/types.d.ts +0 -40
- package/dist/components/TagsInput/types.js +0 -1
- package/dist/components/Toast/Toast.d.ts +0 -2
- package/dist/components/Toast/Toast.js +0 -49
- package/dist/components/Toast/Toaster.d.ts +0 -2
- package/dist/components/Toast/Toaster.js +0 -28
- package/dist/components/Toast/create-toaster.d.ts +0 -2
- package/dist/components/Toast/create-toaster.js +0 -4
- package/dist/components/Toast/types.d.ts +0 -46
- package/dist/components/Toast/types.js +0 -1
- package/dist/composed/accordion/anatomy/accordion-content.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-content.js +0 -14
- package/dist/composed/accordion/anatomy/accordion-heading.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-heading.js +0 -6
- package/dist/composed/accordion/anatomy/accordion-indicator.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-indicator.js +0 -11
- package/dist/composed/accordion/anatomy/accordion-item.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-item.js +0 -13
- package/dist/composed/accordion/anatomy/accordion-root.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-root.js +0 -19
- package/dist/composed/accordion/anatomy/accordion-trigger.d.ts +0 -2
- package/dist/composed/accordion/anatomy/accordion-trigger.js +0 -14
- package/dist/composed/accordion/index.d.ts +0 -2
- package/dist/composed/accordion/index.js +0 -2
- package/dist/composed/accordion/modules/anatomy.d.ts +0 -14
- package/dist/composed/accordion/modules/anatomy.js +0 -14
- package/dist/composed/accordion/modules/context.d.ts +0 -4
- package/dist/composed/accordion/modules/context.js +0 -5
- package/dist/composed/accordion/modules/types.d.ts +0 -28
- package/dist/composed/accordion/modules/types.js +0 -1
- package/dist/composed/avatar/anatomy/avatar-fallback.d.ts +0 -2
- package/dist/composed/avatar/anatomy/avatar-fallback.js +0 -13
- package/dist/composed/avatar/anatomy/avatar-image.d.ts +0 -2
- package/dist/composed/avatar/anatomy/avatar-image.js +0 -13
- package/dist/composed/avatar/anatomy/avatar-root.d.ts +0 -2
- package/dist/composed/avatar/anatomy/avatar-root.js +0 -19
- package/dist/composed/avatar/index.d.ts +0 -2
- package/dist/composed/avatar/index.js +0 -2
- package/dist/composed/avatar/modules/anatomy.d.ts +0 -8
- package/dist/composed/avatar/modules/anatomy.js +0 -8
- package/dist/composed/avatar/modules/context.d.ts +0 -3
- package/dist/composed/avatar/modules/context.js +0 -3
- package/dist/composed/avatar/modules/types.d.ts +0 -13
- package/dist/composed/avatar/modules/types.js +0 -1
- package/dist/composed/index.d.ts +0 -2
- package/dist/composed/index.js +0 -2
- package/dist/internal/props-with-child.d.ts +0 -7
- package/dist/internal/props-with-child.js +0 -1
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface AppBarProps extends React.PropsWithChildren {
|
|
3
|
-
/** Set base styles. */
|
|
4
|
-
base?: string;
|
|
5
|
-
/** Set background styles. */
|
|
6
|
-
background?: string;
|
|
7
|
-
/** Set vertical spacing styles. */
|
|
8
|
-
spaceY?: string;
|
|
9
|
-
/** Set border styles. */
|
|
10
|
-
border?: string;
|
|
11
|
-
/** Set padding styles. */
|
|
12
|
-
padding?: string;
|
|
13
|
-
/** Set shadow styles. */
|
|
14
|
-
shadow?: string;
|
|
15
|
-
/** Provide arbitrary CSS classes. */
|
|
16
|
-
classes?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface ToolBarProps extends React.PropsWithChildren {
|
|
19
|
-
/** Sets the toolbar component's base styles. */
|
|
20
|
-
base?: string;
|
|
21
|
-
/** Sets the toolbar component's grid columns styles. */
|
|
22
|
-
gridCols?: string;
|
|
23
|
-
/** Sets the toolbar component's gap styles. */
|
|
24
|
-
gap?: string;
|
|
25
|
-
/** Provide arbitrary CSS classes to the toolbar component. */
|
|
26
|
-
classes?: string;
|
|
27
|
-
}
|
|
28
|
-
export interface ToolbarLeadProps extends React.PropsWithChildren {
|
|
29
|
-
/** Sets the lead component's base styles. */
|
|
30
|
-
base?: string;
|
|
31
|
-
/** Sets the lead component's horizontal spacing styles. */
|
|
32
|
-
spaceX?: string;
|
|
33
|
-
/** Sets the lead component's padding styles. */
|
|
34
|
-
padding?: string;
|
|
35
|
-
/** Provide arbitrary CSS classes to the lead component. */
|
|
36
|
-
classes?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface ToolbarCenterProps extends React.PropsWithChildren {
|
|
39
|
-
/** Sets the center component's base styles. */
|
|
40
|
-
base?: string;
|
|
41
|
-
/** Sets the center component's alignment styles. */
|
|
42
|
-
align?: string;
|
|
43
|
-
/** Sets the center component's padding styles. */
|
|
44
|
-
padding?: string;
|
|
45
|
-
/** Provide arbitrary CSS classes to the center component. */
|
|
46
|
-
classes?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface ToolbarTrailProps extends React.PropsWithChildren {
|
|
49
|
-
/** Sets the trail component's base styles. */
|
|
50
|
-
base?: string;
|
|
51
|
-
/** Sets the trail component's horizontal spacing styles. */
|
|
52
|
-
spaceX?: string;
|
|
53
|
-
/** Sets the trail component's padding styles. */
|
|
54
|
-
padding?: string;
|
|
55
|
-
/** Provide arbitrary CSS classes to the trail component. */
|
|
56
|
-
classes?: string;
|
|
57
|
-
}
|
|
58
|
-
export interface AppBarHeadlineProps extends React.PropsWithChildren {
|
|
59
|
-
/** Sets the headline component's base styles. */
|
|
60
|
-
base?: string;
|
|
61
|
-
/** Provide arbitrary CSS classes to the headline component. */
|
|
62
|
-
classes?: string;
|
|
63
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useId } from 'react';
|
|
4
|
-
import * as avatar from '@zag-js/avatar';
|
|
5
|
-
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
6
|
-
export const Avatar = ({ src, srcSet, name, initials = [0, -1],
|
|
7
|
-
// Root
|
|
8
|
-
base = 'overflow-hidden isolate', background = 'bg-surface-400-600', size = 'size-16', font = '', border = '', rounded = 'rounded-full', shadow = '', classes = '',
|
|
9
|
-
// Image
|
|
10
|
-
imageBase = 'w-full object-cover', imageClasses = '', style,
|
|
11
|
-
// Fallback
|
|
12
|
-
fallbackBase = 'w-full h-full flex justify-center items-center', fallbackClasses = '',
|
|
13
|
-
// Children
|
|
14
|
-
children,
|
|
15
|
-
// Zag
|
|
16
|
-
...zagProps }) => {
|
|
17
|
-
// Zag
|
|
18
|
-
const service = useMachine(avatar.machine, {
|
|
19
|
-
id: useId(),
|
|
20
|
-
...zagProps
|
|
21
|
-
});
|
|
22
|
-
const api = avatar.connect(service, normalizeProps);
|
|
23
|
-
function getInitials() {
|
|
24
|
-
const lettersArr = initials.map((index) => name.split(' ').at(index)?.charAt(0).toUpperCase());
|
|
25
|
-
return lettersArr.join('');
|
|
26
|
-
}
|
|
27
|
-
return (_jsxs("figure", { ...api.getRootProps(), className: `${base} ${background} ${size} ${font} ${border} ${rounded} ${shadow} ${classes}`, style: style, "data-testid": "avatar", children: [(src || srcSet) && (_jsx("img", { src: src, srcSet: srcSet, alt: name, className: `${imageBase} ${imageClasses}`, "data-testid": "avatar-image", ...api.getImageProps() })), _jsx("span", { ...api.getFallbackProps(), className: `${fallbackBase} ${fallbackClasses}`, "data-testid": "avatar-fallback", children: children ? children : getInitials() })] }));
|
|
28
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes } from 'react';
|
|
2
|
-
import type * as avatar from '@zag-js/avatar';
|
|
3
|
-
export interface AvatarProps extends Omit<avatar.Props, 'id'>, React.PropsWithChildren, Pick<HTMLAttributes<HTMLElement>, 'style'> {
|
|
4
|
-
/** The source of the avatar image. */
|
|
5
|
-
src?: string;
|
|
6
|
-
/** The source set of the avatar image. */
|
|
7
|
-
srcSet?: string;
|
|
8
|
-
/** Provide a name or username for the avatar. */
|
|
9
|
-
name: string;
|
|
10
|
-
/** Initials will be generated based on the name and this index array. */
|
|
11
|
-
initials?: number[];
|
|
12
|
-
/** Set base styles. */
|
|
13
|
-
base?: string;
|
|
14
|
-
/** Set background styles. */
|
|
15
|
-
background?: string;
|
|
16
|
-
/** Set size styles. */
|
|
17
|
-
size?: string;
|
|
18
|
-
/** Set font styles. */
|
|
19
|
-
font?: string;
|
|
20
|
-
/** Set border styles. */
|
|
21
|
-
border?: string;
|
|
22
|
-
/** Set border radius styles. */
|
|
23
|
-
rounded?: string;
|
|
24
|
-
/** Set shadow styles. */
|
|
25
|
-
shadow?: string;
|
|
26
|
-
/** Provide arbitrary CSS classes. */
|
|
27
|
-
classes?: string;
|
|
28
|
-
/** Set avatar image base styles. */
|
|
29
|
-
imageBase?: string;
|
|
30
|
-
/** Provide avatar image arbitrary CSS classes. */
|
|
31
|
-
imageClasses?: string;
|
|
32
|
-
/** Set base classes for the fallback element. */
|
|
33
|
-
fallbackBase?: string;
|
|
34
|
-
/** Provide arbitrary CSS classes to fallback element. */
|
|
35
|
-
fallbackClasses?: string;
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
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 = 'text-xs 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-base', fileClasses = '',
|
|
17
|
-
// File (content)
|
|
18
|
-
fileIcon = '', fileName = 'text-sm flex items-center gap-4', fileSize = 'text-xs 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
|
-
...zagProps }) => {
|
|
25
|
-
// Zag
|
|
26
|
-
const service = useMachine(fileUpload.machine, {
|
|
27
|
-
id: useId(),
|
|
28
|
-
...zagProps
|
|
29
|
-
});
|
|
30
|
-
const api = fileUpload.connect(service, normalizeProps);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
zagProps.onApiReady?.(api);
|
|
33
|
-
}, [zagProps, api]);
|
|
34
|
-
// Reactive
|
|
35
|
-
const rxDisabled = service.prop('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
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { 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.Props, '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
|
-
onApiReady?: (api: FileUploadApi) => void;
|
|
73
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as fileUpload from '@zag-js/file-upload';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
import type { NavRailProps, NavBarProps, NavTileProps } from './types.js';
|
|
3
|
-
export declare const NavRail: FC<NavRailProps>;
|
|
4
|
-
export declare const NavBar: FC<NavBarProps>;
|
|
5
|
-
export declare const NavTile: FC<NavTileProps>;
|
|
6
|
-
export declare const Navigation: (() => null) & {
|
|
7
|
-
Rail: FC<NavRailProps>;
|
|
8
|
-
Bar: FC<NavBarProps>;
|
|
9
|
-
Tile: FC<NavTileProps>;
|
|
10
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useContext, useId } from 'react';
|
|
4
|
-
import { NavContext } from './context.js';
|
|
5
|
-
// Components ---
|
|
6
|
-
export const NavRail = ({ value = '', expanded = false,
|
|
7
|
-
// Root
|
|
8
|
-
base = 'flex flex-col', background = 'preset-filled-surface-100-900', padding = 'p-1', width = 'w-24', widthExpanded = 'w-64', height = 'h-full', classes = '',
|
|
9
|
-
// Header
|
|
10
|
-
headerBase = 'flex', headerFlexDirection = 'flex-col', headerJustify = 'justify-center', headerItems = 'items-center', headerGap = 'gap-1', headerClasses = '',
|
|
11
|
-
// Tiles
|
|
12
|
-
tilesBase = 'flex-1 flex', tilesFlexDirection = 'flex-col', tilesJustify = 'justify-center', tilesItems = 'items-center', tilesGap = 'gap-1', tilesClasses = '',
|
|
13
|
-
// Footer
|
|
14
|
-
footerBase = 'flex', footerFlexDirection = 'flex-col', footerJustify = 'justify-center', footerItems = 'items-center', footerGap = 'gap-1', footerClasses = '',
|
|
15
|
-
// Events
|
|
16
|
-
onValueChange,
|
|
17
|
-
// Snippets
|
|
18
|
-
header, children, footer }) => {
|
|
19
|
-
// Set Context
|
|
20
|
-
const ctx = {
|
|
21
|
-
parent: 'rail',
|
|
22
|
-
value,
|
|
23
|
-
expanded,
|
|
24
|
-
onValueChange
|
|
25
|
-
};
|
|
26
|
-
// Reactive
|
|
27
|
-
const rxWidth = expanded ? widthExpanded : width;
|
|
28
|
-
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] }) }));
|
|
29
|
-
};
|
|
30
|
-
export const NavBar = ({ value = '',
|
|
31
|
-
// Root
|
|
32
|
-
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 = '',
|
|
33
|
-
// Tiles
|
|
34
|
-
tilesBase = 'flex-1 flex', tilesFlexDirection = '', tilesJustify = 'justify-center', tilesItems = 'items-center', tilesGap = 'gap-1', tilesClasses = '',
|
|
35
|
-
// Events
|
|
36
|
-
onValueChange,
|
|
37
|
-
// Snippets
|
|
38
|
-
children }) => {
|
|
39
|
-
// Set Context
|
|
40
|
-
const ctx = {
|
|
41
|
-
parent: 'bar',
|
|
42
|
-
value,
|
|
43
|
-
expanded: false,
|
|
44
|
-
onValueChange
|
|
45
|
-
};
|
|
46
|
-
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 }) }));
|
|
47
|
-
};
|
|
48
|
-
export const NavTile = ({ id, href, target, label, labelExpanded, title, selected = undefined, type = 'button',
|
|
49
|
-
// Root
|
|
50
|
-
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',
|
|
51
|
-
// Expanded
|
|
52
|
-
expandedPadding = 'py-3 px-4', expandedGap = 'gap-4', expandedClasses = '',
|
|
53
|
-
// Label (base)
|
|
54
|
-
labelBase = 'text-xs', labelClasses = '',
|
|
55
|
-
// Label (expanded)
|
|
56
|
-
labelExpandedBase = '', labelExpandedClasses = '',
|
|
57
|
-
// Events
|
|
58
|
-
onClick,
|
|
59
|
-
// Snippets
|
|
60
|
-
children }) => {
|
|
61
|
-
// Get Context
|
|
62
|
-
const ctx = useContext(NavContext);
|
|
63
|
-
const generatedId = useId();
|
|
64
|
-
if (!id) {
|
|
65
|
-
id = generatedId;
|
|
66
|
-
}
|
|
67
|
-
// Local
|
|
68
|
-
const TileElement = href ? 'a' : 'button';
|
|
69
|
-
const role = href ? undefined : 'button';
|
|
70
|
-
// Reactive
|
|
71
|
-
const rxSize = ctx.parent === 'bar' ? `h-full` : `${aspect}`;
|
|
72
|
-
const classesCollapsed = `${rxSize} ${padding} ${gap} ${classes}`;
|
|
73
|
-
const classesExtended = `${expandedPadding} ${expandedGap} ${expandedClasses}`;
|
|
74
|
-
const rxMode = ctx.expanded ? classesExtended : classesCollapsed;
|
|
75
|
-
const isActive = selected !== undefined ? selected : ctx.value === id;
|
|
76
|
-
const rxBackground = isActive ? active : `${background} ${hover}`;
|
|
77
|
-
function onClickHandler() {
|
|
78
|
-
if (onClick && !id)
|
|
79
|
-
throw new Error('No ID was provided');
|
|
80
|
-
if (onClick && id)
|
|
81
|
-
onClick(id);
|
|
82
|
-
if (id)
|
|
83
|
-
ctx.onValueChange?.(id);
|
|
84
|
-
}
|
|
85
|
-
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 }))] }));
|
|
86
|
-
};
|
|
87
|
-
// Exports ---
|
|
88
|
-
export const Navigation = /* @__PURE__ */ Object.assign(() => null, {
|
|
89
|
-
Rail: NavRail,
|
|
90
|
-
Bar: NavBar,
|
|
91
|
-
Tile: NavTile
|
|
92
|
-
});
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
export interface NavContextState {
|
|
2
|
-
parent: string;
|
|
3
|
-
value?: string;
|
|
4
|
-
expanded?: boolean;
|
|
5
|
-
onValueChange?: (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
|
-
onValueChange?: (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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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', showFirstLastButtons = false,
|
|
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 = '', gap = 'gap-2', padding = 'p-2', 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 service = useMachine(pagination.machine, {
|
|
19
|
-
id: useId(),
|
|
20
|
-
count: zagProps.count ?? data.length,
|
|
21
|
-
...zagProps
|
|
22
|
-
});
|
|
23
|
-
const api = pagination.connect(service, normalizeProps);
|
|
24
|
-
// Reactive
|
|
25
|
-
const rxButtonActive = (page) => {
|
|
26
|
-
return service.prop('page') === page.value ? buttonActive : `${buttonInactive} ${buttonHover}`;
|
|
27
|
-
};
|
|
28
|
-
return (_jsx(_Fragment, { children: api.totalPages > 1 && (_jsxs("div", { ...api.getRootProps(), className: `${base} ${background} ${border} ${gap} ${padding} ${rounded} ${classes}`, "data-testid": "pagination", children: [showFirstLastButtons && (_jsx("button", { type: "button", onClick: api.goToFirstPage, className: `${buttonBase} ${buttonInactive} ${buttonHover} ${buttonClasses}`, title: titleFirst, disabled: api.page === 1, "data-testid": "pagination-button-first", 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 &&
|
|
29
|
-
api.pages.map((page, i) => {
|
|
30
|
-
if (page.type === 'page')
|
|
31
|
-
return (
|
|
32
|
-
// Numeral
|
|
33
|
-
_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));
|
|
34
|
-
else
|
|
35
|
-
return (
|
|
36
|
-
// Ellipsis
|
|
37
|
-
_jsx("span", { ...api.getEllipsisProps({ index: i }), className: `${buttonBase} ${buttonInactive} ${buttonClasses}`, "data-testid": "pagination-ellipsis", children: labelEllipsis }, `ellipsis-${i}`));
|
|
38
|
-
}), 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 }), showFirstLastButtons && (_jsx("button", { type: "button", onClick: api.goToLastPage, className: `${buttonBase} ${buttonInactive} ${buttonHover} ${buttonClasses}`, title: titleLast, disabled: !api.nextPage, "data-testid": "pagination-button-last", children: labelLast }))] })) }));
|
|
39
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import * as pagination from '@zag-js/pagination';
|
|
3
|
-
export interface PaginationProps extends Omit<pagination.Props, 'id'> {
|
|
4
|
-
/** Provide source data as an array. */
|
|
5
|
-
data: unknown[];
|
|
6
|
-
/** Enables alternative display with stats and first/last buttons. */
|
|
7
|
-
alternative?: boolean;
|
|
8
|
-
/** Set the separator text or character, such as "of" in "X of Y". */
|
|
9
|
-
textSeparator?: string;
|
|
10
|
-
/** Show first and last page button. */
|
|
11
|
-
showFirstLastButtons?: boolean;
|
|
12
|
-
/** Set an optional title for the first button. */
|
|
13
|
-
titleFirst?: string;
|
|
14
|
-
/** Set an optional title for the previous button. */
|
|
15
|
-
titlePrevious?: string;
|
|
16
|
-
/** Set an optional title for the numeral buttons (ex: Page 1). */
|
|
17
|
-
titleNumeral?: string;
|
|
18
|
-
/** Set an optional title for the next button. */
|
|
19
|
-
titleNext?: string;
|
|
20
|
-
/** Set an optional title for the last button. */
|
|
21
|
-
titleLast?: string;
|
|
22
|
-
/** Sets base classes for the list. */
|
|
23
|
-
base?: string;
|
|
24
|
-
/** Sets background classes for the list. */
|
|
25
|
-
background?: string;
|
|
26
|
-
/** Sets border classes for the list. */
|
|
27
|
-
border?: string;
|
|
28
|
-
/** Sets gap classes for the list. */
|
|
29
|
-
gap?: string;
|
|
30
|
-
/** Sets padding classes for the list. */
|
|
31
|
-
padding?: string;
|
|
32
|
-
/** Sets border radius classes for the list. */
|
|
33
|
-
rounded?: string;
|
|
34
|
-
/** Provide arbitrary CSS classes for the root. */
|
|
35
|
-
classes?: string;
|
|
36
|
-
/** Sets base classes for buttons. */
|
|
37
|
-
buttonBase?: string;
|
|
38
|
-
/** Sets active state classes for buttons. */
|
|
39
|
-
buttonActive?: string;
|
|
40
|
-
/** Sets inactive state classes for buttons. */
|
|
41
|
-
buttonInactive?: string;
|
|
42
|
-
/** Sets hover state classes for buttons. */
|
|
43
|
-
buttonHover?: string;
|
|
44
|
-
/** Provide arbitrary CSS classes for buttons. */
|
|
45
|
-
buttonClasses?: string;
|
|
46
|
-
/** Set button icon or label for first button. */
|
|
47
|
-
labelFirst?: ReactNode;
|
|
48
|
-
/** Set button icon or label for previous button. */
|
|
49
|
-
labelPrevious?: ReactNode;
|
|
50
|
-
/** Set button icon or label for ellipsis. */
|
|
51
|
-
labelEllipsis?: ReactNode;
|
|
52
|
-
/** Set button icon or label for next button. */
|
|
53
|
-
labelNext?: ReactNode;
|
|
54
|
-
/** Set button icon or label for last button. */
|
|
55
|
-
labelLast?: ReactNode;
|
|
56
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as pagination from '@zag-js/pagination';
|