@skeletonlabs/skeleton-react 1.0.0-next.6 → 1.0.0-next.8

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.
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId } from 'react';
3
+ import { useEffect, useId } from 'react';
4
4
  import * as fileUpload from '@zag-js/file-upload';
5
5
  import { normalizeProps, useMachine } from '@zag-js/react';
6
6
  export const FileUpload = ({ label = `Select file or drag here`, subtext = '',
@@ -13,25 +13,29 @@ interfaceIcon = '', interfaceText = '', interfaceSubtext = 'type-scale-1 opacity
13
13
  // Files List
14
14
  filesListBase = 'mt-2 space-y-2', filesListClasses = '',
15
15
  // File
16
- fileBase = 'grid grid-cols-[auto_auto_1fr_auto] rtl:grid-cols-[auto_1fr_auto_auto] items-center', fileBg = 'preset-tonal', fileGap = 'gap-4 px-4', filePadding = 'py-2', fileRounded = 'rounded', fileClasses = '',
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
17
  // File (content)
18
- fileIcon = '', fileName = 'type-scale-2', fileSize = 'type-scale-1 opacity-60', fileButton = '',
18
+ fileIcon = '', fileName = 'type-scale-2 flex items-center gap-4', fileSize = 'type-scale-1 opacity-60', fileButton = '',
19
19
  // State
20
20
  stateInvalid = 'border-error-500', stateDisabled = 'disabled', stateDragging = 'preset-filled-primary-500',
21
21
  // Children
22
22
  children, iconInterface, iconFile, iconFileRemove,
23
23
  // Zag
24
- ...zagProps }) => {
24
+ internalApi, ...zagProps }) => {
25
25
  // Zag
26
26
  const [state, send] = useMachine(fileUpload.machine({
27
27
  id: useId()
28
28
  }), { context: zagProps });
29
29
  const api = fileUpload.connect(state, send, normalizeProps);
30
+ useEffect(() => {
31
+ if (internalApi)
32
+ internalApi(api);
33
+ }, [internalApi, api]);
30
34
  // Reactive
31
35
  const rxDisabled = state.context.disabled ? stateDisabled : '';
32
36
  const rxInvalid = api.rejectedFiles.length > 0 ? stateInvalid : interfaceBorderColor;
33
37
  const rxDragging = api.dragging && !children ? stateDragging : '';
34
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) => (
35
39
  // File
36
- _jsxs("li", { ...api.getItemProps({ file }), className: `${fileBase} ${fileBg} ${fileGap} ${filePadding} ${fileRounded} ${fileClasses}`, "data-testid": "uploader-file", children: [_jsx("span", { className: fileIcon, "data-testid": "uploader-file-icon", children: iconFile ?? '•' }), _jsx("p", { ...api.getItemNameProps({ file }), className: fileName, "data-testid": "uploader-file-name", children: file.name }), _jsxs("p", { ...api.getItemNameProps({ file }), className: fileSize, "data-testid": "uploader-file-size", children: [(file.size / 100000).toFixed(1), " mb"] }), _jsx("button", { ...api.getItemDeleteTriggerProps({ file }), className: fileButton, "data-testid": "uploader-file-button", children: iconFileRemove ?? _jsx("span", { children: "\u2715" }) })] }, file.name))) }))] }));
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))) }))] }));
37
41
  };
@@ -1,5 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
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
+ }
3
6
  export interface FileUploadProps extends React.PropsWithChildren, Omit<fileUpload.Context, 'id'> {
4
7
  /** Set the interface text value. */
5
8
  label?: string;
@@ -65,4 +68,6 @@ export interface FileUploadProps extends React.PropsWithChildren, Omit<fileUploa
65
68
  iconFile?: ReactNode;
66
69
  /** Provide an icon for the remove file action. */
67
70
  iconFileRemove?: ReactNode;
71
+ /** Binds the Zag API for external use. */
72
+ internalApi?: (api: FileUploadApi) => void;
68
73
  }
@@ -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,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useId } from 'react';
3
+ import * as pagination from '@zag-js/pagination';
4
+ import { useMachine, normalizeProps } from '@zag-js/react';
5
+ export const Pagination = ({ data, alternative = false, textSeparator = 'of',
6
+ // Titles
7
+ titleFirst, titlePrevious, titleNumeral, titleNext, titleLast,
8
+ // Root
9
+ base = 'inline-flex items-stretch overflow-hidden', background = 'preset-outlined-surface-200-800', border = 'p-2', gap = 'gap-2', padding = '', rounded = 'rounded-container', classes = '',
10
+ // Buttons
11
+ buttonBase = 'btn', buttonActive = 'preset-filled', buttonInactive = 'preset-tonal', buttonHover = 'hover:preset-filled', buttonClasses = '',
12
+ // Children
13
+ labelFirst = '\u00AB', labelPrevious = '\u2190', labelEllipsis = '\u22EF', labelNext = '\u2192', labelLast = '\u00BB',
14
+ // Zag
15
+ ...zagProps }) => {
16
+ // Zag
17
+ const [state, send] = useMachine(pagination.machine({
18
+ id: useId(),
19
+ count: data.length
20
+ }), { context: zagProps });
21
+ const api = pagination.connect(state, send, normalizeProps);
22
+ // Reactive
23
+ const rxButtonActive = (page) => {
24
+ return state.context.page === page.value ? buttonActive : `${buttonInactive} ${buttonHover}`;
25
+ };
26
+ 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 &&
27
+ api.pages.map((page, i) => {
28
+ if (page.type === 'page')
29
+ return (
30
+ // Numeral
31
+ _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));
32
+ else
33
+ return (
34
+ // Ellipsis
35
+ _jsx("span", { ...api.getEllipsisProps({ index: i }), className: `${buttonBase} ${buttonInactive} ${buttonClasses}`, "data-testid": "pagination-ellipsis", children: labelEllipsis }, `ellipsis-${i}`));
36
+ }), 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.count] })] })), _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 }))] })) }));
37
+ };
@@ -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 {};
@@ -27,9 +27,7 @@ onValueChange = noop,
27
27
  const [state, send] = useMachine(rating.machine({
28
28
  id: useId(),
29
29
  onValueChange: (details) => onValueChange(details.value)
30
- }), {
31
- context: zagProps
32
- });
30
+ }), { context: zagProps });
33
31
  const api = rating.connect(state, send, normalizeProps);
34
32
  // Reactive
35
33
  const rxInteractive = state.context.isInteractive ? stateInteractive : '';
@@ -29,7 +29,7 @@ children,
29
29
  };
30
30
  const TabsList = ({
31
31
  // Root
32
- base = 'flex', justify = 'justify-start', border = 'border-b border-surface-200-800', margin = 'mb-4', gap = 'gap-2', classes = '',
32
+ base = 'flex', justify = 'justify-start', border = 'border-b-[1px] border-surface-200-800', margin = 'mb-4', gap = 'gap-2', classes = '',
33
33
  // Children
34
34
  children }) => {
35
35
  const ctx = useContext(TabsContext);
@@ -37,7 +37,7 @@ children }) => {
37
37
  };
38
38
  const TabsControl = ({
39
39
  // Root
40
- base = 'border-b border-transparent', padding = 'pb-2', translateX = 'translate-y-[1px]', classes = '',
40
+ base = 'border-b-[1px] border-transparent', padding = 'pb-2', translateX = 'translate-y-[1px]', classes = '',
41
41
  // Label
42
42
  labelBase = 'btn hover:preset-tonal-primary', labelClasses = '',
43
43
  // State
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { TagsInputProps } from './types.js';
3
+ export declare const TagsInput: React.FC<TagsInputProps>;
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId } from 'react';
4
+ import * as tagsInput from '@zag-js/tags-input';
5
+ import { useMachine, normalizeProps } from '@zag-js/react';
6
+ import { noop } from '../../internal/noop.js';
7
+ export const TagsInput = ({ placeholder = '',
8
+ // Root
9
+ base = 'grid input', gap = 'gap-2', padding = 'p-3', classes = '',
10
+ // Input: Add
11
+ inputBase = 'input-ghost', inputClasses = '',
12
+ // Tag List
13
+ tagListBase = 'flex gap-2', tagListClasses = '',
14
+ // Tag
15
+ tagBase = 'chip', tagBackground = 'preset-filled', tagClasses = '',
16
+ // Input: Edit
17
+ inputEditBase = 'chip-input -translate-y-0.25', tagEditBackground = 'preset-outlined-surface-200-800', inputEditClasses,
18
+ // Delete Button
19
+ buttonDeleteBase = '', buttonDeleteClasses = '',
20
+ // Snippets
21
+ buttonDelete,
22
+ // State
23
+ stateDisabled = 'disabled',
24
+ // Events
25
+ onValueChange = noop,
26
+ // Zag
27
+ ...zagProps }) => {
28
+ // Zag
29
+ const [state, send] = useMachine(tagsInput.machine({
30
+ id: useId(),
31
+ onValueChange: (details) => onValueChange(details.value)
32
+ }), { context: { ...zagProps } });
33
+ const api = tagsInput.connect(state, send, normalizeProps);
34
+ // Reactive
35
+ const rxDisabled = state.context.disabled ? stateDisabled : '';
36
+ return (_jsxs("div", { ...api.getRootProps(), className: `${base} ${padding} ${gap} ${rxDisabled} ${classes}`, "data-testid": "tags", children: [_jsx("input", { ...api.getInputProps(), placeholder: placeholder, className: `${inputBase} ${inputClasses}`, "data-testid": "tags-input-add" }), api.value.length > 0 && (_jsx("div", { className: `${tagListBase} ${tagListClasses}`, "data-testid": "tags-list", children: api.value.map((value, index) => {
37
+ const itemState = api.getItemState({ index, value });
38
+ return (
39
+ // Tag
40
+ _jsxs("div", { ...api.getItemProps({ value, index }), "data-testid": "tags-tag", children: [_jsxs("div", { ...api.getItemPreviewProps({ index, value }), className: `${tagBase} ${tagBackground} ${tagClasses}`, style: { display: itemState.editing ? 'none' : '' }, "data-testid": "tag-display", children: [_jsx("span", { children: value }), _jsx("button", { ...api.getItemDeleteTriggerProps({ index, value }), className: `${buttonDeleteBase} ${buttonDeleteClasses}`, "data-testid": "tag-delete", children: buttonDelete ?? _jsx("strong", { children: "\u00D7" }) })] }), _jsx("input", { ...api.getItemInputProps({ index, value }), className: `${inputEditBase} ${tagEditBackground} ${inputEditClasses}`, style: { display: itemState.editing ? '' : 'none' }, "data-testid": "tags-input-edit" })] }, value));
41
+ }) }))] }));
42
+ };
@@ -0,0 +1,44 @@
1
+ import { ReactNode } from 'react';
2
+ import * as tagsInput from '@zag-js/tags-input';
3
+ export interface TagsInputProps extends Omit<tagsInput.Context, 'id' | 'onValueChange'> {
4
+ /** Set the add tag input placeholder. */
5
+ placeholder?: string;
6
+ /** Set base classes for the root. */
7
+ base?: string;
8
+ /** Set gap classes for the root. */
9
+ gap?: string;
10
+ /** Set padding classes for the root. */
11
+ padding?: string;
12
+ /** Provide arbitrary classes to the root. */
13
+ classes?: string;
14
+ /** Set base classes for the add tag input. */
15
+ inputBase?: string;
16
+ /** Provide arbitrary classes to the add tag input. */
17
+ inputClasses?: string;
18
+ /** Set base classes for the tag list. */
19
+ tagListBase?: string;
20
+ /** Provide arbitrary classes to the tag list. */
21
+ tagListClasses?: string;
22
+ /** Set base classes for each tag. */
23
+ tagBase?: string;
24
+ /** Set background classes for each tag. */
25
+ tagBackground?: string;
26
+ /** Provide arbitrary classes to each tag. */
27
+ tagClasses?: string;
28
+ /** Set base classes for the edit tag input. */
29
+ inputEditBase?: string;
30
+ /** Set background classes for the edit tag input. */
31
+ tagEditBackground?: string;
32
+ /** Provide arbitrary classes to the edit tag input. */
33
+ inputEditClasses?: string;
34
+ /** Set base classes for the delete button. */
35
+ buttonDeleteBase?: string;
36
+ /** Provide arbitrary classes to the delete button. */
37
+ buttonDeleteClasses?: string;
38
+ /** The delete button label snippet. */
39
+ buttonDelete?: ReactNode;
40
+ /** Set the component disabled state. */
41
+ stateDisabled?: string;
42
+ /** Triggers when the switch is toggled. */
43
+ onValueChange?: (value: string[]) => void;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -3,10 +3,13 @@ export { Avatar } from './components/Avatar/Avatar.js';
3
3
  export { AppBar } from './components/AppBar/AppBar.js';
4
4
  export { FileUpload } from './components/FileUpload/FileUpload.js';
5
5
  export { Nav } from './components/Navigation/Navigation.js';
6
+ export { Pagination } from './components/Pagination/Pagination.js';
6
7
  export { Progress } from './components/Progress/Progress.js';
7
8
  export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
9
+ export { Rating } from './components/Rating/Rating.js';
8
10
  export { Segment } from './components/Segment/Segment.js';
9
11
  export { Slider } from './components/Slider/Slider.js';
10
12
  export { Switch } from './components/Switch/Switch.js';
11
13
  export { Tabs } from './components/Tabs/Tabs.js';
12
- export { Rating } from './components/Rating/Rating.js';
14
+ export type { FileUploadApi } from './components/FileUpload/types.js';
15
+ export { TagsInput } from './components/TagsInput/TagsInput.js';
package/dist/index.js CHANGED
@@ -4,10 +4,12 @@ export { Avatar } from './components/Avatar/Avatar.js';
4
4
  export { AppBar } from './components/AppBar/AppBar.js';
5
5
  export { FileUpload } from './components/FileUpload/FileUpload.js';
6
6
  export { Nav } from './components/Navigation/Navigation.js';
7
+ export { Pagination } from './components/Pagination/Pagination.js';
7
8
  export { Progress } from './components/Progress/Progress.js';
8
9
  export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
10
+ export { Rating } from './components/Rating/Rating.js';
9
11
  export { Segment } from './components/Segment/Segment.js';
10
12
  export { Slider } from './components/Slider/Slider.js';
11
13
  export { Switch } from './components/Switch/Switch.js';
12
14
  export { Tabs } from './components/Tabs/Tabs.js';
13
- export { Rating } from './components/Rating/Rating.js';
15
+ export { TagsInput } from './components/TagsInput/TagsInput.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton-react",
3
- "version": "1.0.0-next.6",
3
+ "version": "1.0.0-next.8",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -32,13 +32,15 @@
32
32
  "@zag-js/accordion": "^0.65.1",
33
33
  "@zag-js/avatar": "^0.65.1",
34
34
  "@zag-js/file-upload": "^0.65.1",
35
+ "@zag-js/pagination": "^0.65.1",
35
36
  "@zag-js/progress": "^0.65.1",
36
37
  "@zag-js/radio-group": "^0.65.1",
37
38
  "@zag-js/rating-group": "^0.65.1",
38
39
  "@zag-js/react": "^0.65.1",
39
40
  "@zag-js/slider": "^0.65.1",
40
41
  "@zag-js/switch": "^0.65.1",
41
- "@zag-js/tabs": "^0.65.1"
42
+ "@zag-js/tabs": "^0.65.1",
43
+ "@zag-js/tags-input": "^0.65.1"
42
44
  },
43
45
  "peerDependencies": {
44
46
  "react": "^18.0.0",
@@ -54,7 +56,7 @@
54
56
  "@vitejs/plugin-react": "^4.3.1",
55
57
  "autoprefixer": "^10.4.19",
56
58
  "jsdom": "^24.1.1",
57
- "lucide-react": "^0.341.0",
59
+ "lucide-react": "^0.436.0",
58
60
  "postcss": "^8.4.39",
59
61
  "react": "^18.2.0",
60
62
  "react-dom": "^18.2.0",
@@ -65,8 +67,8 @@
65
67
  "vite": "^5.3.4",
66
68
  "vite-plugin-remix-router": "^2.0.0",
67
69
  "vitest": "^1.6.0",
68
- "@skeletonlabs/skeleton": "3.0.0-next.4",
69
- "vite-plugin-tw-plugin-watcher": "0.0.1-next.0"
70
+ "vite-plugin-tw-plugin-watcher": "0.0.1-next.0",
71
+ "@skeletonlabs/skeleton": "3.0.0-next.5"
70
72
  },
71
73
  "scripts": {
72
74
  "dev": "vite",