@skeletonlabs/skeleton-react 1.0.0-next.5 → 1.0.0-next.7

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { FileUploadProps } from './types.js';
3
+ export declare const FileUpload: React.FC<FileUploadProps>;
@@ -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,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 : '';
@@ -44,7 +44,7 @@ base = 'btn cursor-pointer z-[1]', classes = '',
44
44
  // Label
45
45
  labelBase = 'pointer-events-none transition-colors duration-100', labelClasses = '',
46
46
  // State
47
- stateDisabled = 'disabled',
47
+ stateDisabled = 'disabled', stateFocused = 'focused',
48
48
  // Children
49
49
  children,
50
50
  // Zag
@@ -55,7 +55,8 @@ children,
55
55
  // Reactive
56
56
  const rxDisabled = state.disabled ? stateDisabled : '';
57
57
  const rxActiveText = state.checked ? ctx.indicatorText : '';
58
- return (_jsxs("label", { ...ctx.api.getItemProps(zagProps), className: `${base} ${rxDisabled} ${classes}`, "data-testid": "segment-item", children: [_jsx("span", { ...ctx.api.getItemTextProps(zagProps), className: `${labelBase} ${rxActiveText} ${labelClasses}`, "data-testid": "segment-item-label", children: children }), _jsx("input", { ...ctx.api.getItemHiddenInputProps(zagProps), "data-testid": "segment-item-input" })] }));
58
+ const rxFocused = state.focused ? stateFocused : '';
59
+ return (_jsxs("label", { ...ctx.api.getItemProps(zagProps), className: `${base} ${rxDisabled} ${rxFocused} ${classes}`, "data-testid": "segment-item", children: [_jsx("span", { ...ctx.api.getItemTextProps(zagProps), className: `${labelBase} ${rxActiveText} ${labelClasses}`, "data-testid": "segment-item-label", children: children }), _jsx("input", { ...ctx.api.getItemHiddenInputProps(zagProps), "data-testid": "segment-item-input" })] }));
59
60
  };
60
61
  export const Segment = Object.assign(SegmentRoot, {
61
62
  Item: SegmentItem
@@ -52,6 +52,8 @@ export interface SegmentItemsProps extends React.PropsWithChildren, Omit<radio.I
52
52
  classes?: string;
53
53
  /** Set claseses for the disabled state. */
54
54
  stateDisabled?: string;
55
+ /** Set claseses for the focus state. */
56
+ stateFocused?: string;
55
57
  /** Sets base classes for the label element. */
56
58
  labelBase?: string;
57
59
  /** Provide arbitrary CSS classes for the label element. */
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import type { SliderProps } from './types';
3
+ export declare const Slider: FC<SliderProps>;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from 'react';
3
+ import * as slider from '@zag-js/slider';
4
+ import { useMachine, normalizeProps } from '@zag-js/react';
5
+ import { noop } from '../../internal/noop.js';
6
+ export const Slider = ({ height = 'h-1.5', markers = [],
7
+ // Root ---
8
+ base = 'w-full', classes = '',
9
+ // Control ---
10
+ controlBase = '', controlClasses = '',
11
+ // Track ---
12
+ trackBase = 'overflow-hidden', trackBg = 'bg-surface-200-800', trackRounded = 'rounded-full', trackClasses = '',
13
+ // Meter ---
14
+ meterBase = '', meterBg = 'bg-surface-950-50', materRounded = 'rounded-container', meterClasses = '',
15
+ // Thumb ---
16
+ thumbBase = 'ring-inset transition-scale duration-100 ease-in-out', thumbSize = 'size-8 md:size-5', thumbBg = 'bg-surface-50-950', thumbRingSize = 'ring-2', thumbRingColor = 'ring-surface-950-50', thumbRounded = 'rounded-full', thumbScale = 'hover:scale-125', thumbCursor = 'hover:cursor-pointer', thumbClasses = '',
17
+ // Markers ---
18
+ markersBase = '', markerslasses = '',
19
+ // Mark ---
20
+ markBase = '', markText = 'text-[10px]', markOpacity = 'opacity-50', markClasses = '',
21
+ // State ---
22
+ stateDisabled = 'disabled', stateReadOnly = 'cursor-not-allowed',
23
+ // Events ---
24
+ onValueChange = noop, onValueChangeEnd = noop,
25
+ // Children ---
26
+ mark,
27
+ // Zag ---
28
+ ...zagProps }) => {
29
+ // Zag
30
+ const [state, send] = useMachine(slider.machine({
31
+ id: useId(),
32
+ onValueChange: (details) => onValueChange(details.value),
33
+ onValueChangeEnd: (details) => onValueChangeEnd(details.value)
34
+ }), { context: zagProps });
35
+ const api = slider.connect(state, send, normalizeProps);
36
+ // Reactive
37
+ const rxDisabled = state.context.disabled ? stateDisabled : '';
38
+ const rxReadOnly = state.context.readOnly ? stateReadOnly : `${thumbScale} ${thumbCursor}`;
39
+ return (_jsxs("div", { ...api.getRootProps(), className: `${base} ${height} ${rxDisabled} ${classes}`, "data-testid": "slider", children: [_jsxs("div", { ...api.getControlProps(), className: `${controlBase} ${controlClasses}`, "data-testid": "slider-control", children: [_jsx("div", { ...api.getTrackProps(), className: `${trackBase} ${trackBg} ${height} ${trackRounded} ${trackClasses}`, "data-testid": "slider-track", children: _jsx("div", { ...api.getRangeProps(), className: `${meterBase} ${height} ${meterBg} ${materRounded} ${meterClasses}`, "data-testid": "slider-meter" }) }), _jsx("div", { className: `${height}`, style: { display: 'flex', alignItems: 'center', transform: 'translateY(-100%)' }, "data-testid": "slider-thumb-wrapper", children: api.value.map((_, index) => (_jsxs("div", { ...api.getThumbProps({ index }), children: [_jsx("div", { className: `${thumbBase} ${thumbSize} ${thumbBg} ${thumbRingSize} ${thumbRingColor} ${thumbRounded} ${rxReadOnly} ${thumbClasses}`, "data-testid": "slider-thumb" }), _jsx("input", { ...api.getHiddenInputProps({ index }), "data-testid": "slider-input" })] }, index))) })] }), markers.length > 0 && (_jsx("div", { ...api.getMarkerGroupProps(), className: `${markersBase} ${markerslasses}`, "data-testid": "slider-markers", children: markers.map((value) => (
40
+ // Mark
41
+ _jsx("span", { ...api.getMarkerProps({ value }), className: `${markBase} ${markText} ${markOpacity} ${markClasses}`, "data-testid": "slider-mark", children: mark ? mark : value }, value))) }))] }));
42
+ };
@@ -0,0 +1,72 @@
1
+ import * as slider from '@zag-js/slider';
2
+ import { ReactNode } from 'react';
3
+ export interface SliderProps extends Omit<slider.Context, 'id' | 'onValueChange' | `onValueChangeEnd` | 'thumbSize'> {
4
+ /** Provide an array of value markers */
5
+ markers?: number[];
6
+ /** Set height classes for the overall slider. */
7
+ height?: string;
8
+ /** Set base classes. */
9
+ base?: string;
10
+ /** Provide arbitrary classes for the root. */
11
+ classes?: string;
12
+ /** Set base classes for the control. */
13
+ controlBase?: string;
14
+ /** Provide arbitrary classes for the control. */
15
+ controlClasses?: string;
16
+ /** Set base classes for the track. */
17
+ trackBase?: string;
18
+ /** Set background classes for the track. */
19
+ trackBg?: string;
20
+ /** Set border radius classes for the track. */
21
+ trackRounded?: string;
22
+ /** Provide arbitrary classes for the track. */
23
+ trackClasses?: string;
24
+ /** Set base classes for the meter. */
25
+ meterBase?: string;
26
+ /** Set background classes for the meter. */
27
+ meterBg?: string;
28
+ /** Set border radius classes for the meter. */
29
+ materRounded?: string;
30
+ /** Provide arbitrary classes for the meter. */
31
+ meterClasses?: string;
32
+ /** Set base classes for the thumb. */
33
+ thumbBase?: string;
34
+ /** Set size classes for the thumb. */
35
+ thumbSize?: string;
36
+ /** Set background classes for the thumb. */
37
+ thumbBg?: string;
38
+ /** Set ring size classes for the thumb. */
39
+ thumbRingSize?: string;
40
+ /** Set ring color classes for the thumb. */
41
+ thumbRingColor?: string;
42
+ /** Set border-radius classes for the thumb. */
43
+ thumbRounded?: string;
44
+ /** Set scale classes for the thumb. */
45
+ thumbScale?: string;
46
+ /** Set cursor classes for the thumb. */
47
+ thumbCursor?: string;
48
+ /** Provide arbitrary classes for the thumb. */
49
+ thumbClasses?: string;
50
+ /** Set base classes for the markers. */
51
+ markersBase?: string;
52
+ /** Provide arbitrary classes for the markers. */
53
+ markerslasses?: string;
54
+ /** Set base classes for each mark. */
55
+ markBase?: string;
56
+ /** Set text size classes for each mark. */
57
+ markText?: string;
58
+ /** Set opacity classes for each mark. */
59
+ markOpacity?: string;
60
+ /** Provide arbitrary classes for each mark. */
61
+ markClasses?: string;
62
+ /** Set disabled state classes for the root element. */
63
+ stateDisabled?: string;
64
+ /** Set read-only state classes for the root element. */
65
+ stateReadOnly?: string;
66
+ /** Triggers when the value state is being changed. */
67
+ onValueChange?: (value: number[]) => void;
68
+ /** Triggers when the value change has ended. */
69
+ onValueChangeEnd?: (value: number[]) => void;
70
+ /** Replace numeric markers with symbol, such as a icon. */
71
+ mark?: ReactNode;
72
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -6,7 +6,9 @@ import { useMachine, normalizeProps } from '@zag-js/react';
6
6
  import { noop } from '../../internal/noop.js';
7
7
  export const Switch = ({ name = '', checked = false, disabled = false, compact = false,
8
8
  // Root (Track)
9
- base = 'inline-flex items-center gap-4', classes = '',
9
+ base = 'inline-flex items-center gap-4',
10
+ // State
11
+ stateFocused = '[&>span]:focused', classes = '',
10
12
  // Control
11
13
  controlBase = 'cursor-pointer transition duration-200', controlInactive = 'preset-filled-surface-200-800', controlActive = 'preset-filled-primary-500', controlDisabled = 'opacity-50 cursor-not-allowed', controlWidth = 'w-10', controlHeight = 'h-6', controlPadding = 'p-0.5', controlRounded = 'rounded-full', controlHover = 'hover:brightness-90 dark:hover:brightness-110', controlClasses = '',
12
14
  // Thumb
@@ -44,5 +46,6 @@ children, inactiveChild, activeChild }) => {
44
46
  const rxTrackState = api.checked ? controlActive : controlInactive;
45
47
  const rxThumbState = api.checked ? `${thumbActive} ${thumbTranslateX}` : thumbInactive;
46
48
  const rxDisabled = api.disabled ? controlDisabled : '';
47
- return (_jsxs("label", { ...api.getRootProps(), className: `${base} ${classes}`, "data-testid": "switch", children: [_jsx("input", { ...api.getHiddenInputProps(), "data-testid": "switch-input" }), _jsx("span", { ...api.getControlProps(), className: `${controlBase} ${rxTrackState} ${controlWidth} ${controlHeight} ${controlPadding} ${controlRounded} ${controlHover} ${rxDisabled} ${controlClasses}`, "data-testid": "switch-control", children: _jsxs("span", { ...api.getThumbProps(), className: `${thumbBase} ${rxThumbState} ${thumbRounded} ${thumbTransition} ${thumbEase} ${thumbDuration} ${thumbClasses}`, "data-testid": "switch-thumb", children: [!checked && inactiveChild ? (_jsx("span", { className: iconInactiveBase, "data-testid": "switch-icon-inactive", children: inactiveChild })) : null, checked && activeChild ? (_jsx("span", { className: iconActiveBase, "data-testid": "switch-icon-active", children: activeChild })) : null] }) }), _jsx("span", { ...api.getLabelProps(), className: `${labelBase} ${labelClasses}`, "data-testid": "switch-label", children: children })] }));
49
+ const rxFocused = api.focused ? stateFocused : '';
50
+ return (_jsxs("label", { ...api.getRootProps(), className: `${base} ${rxFocused} ${classes}`, "data-testid": "switch", children: [_jsx("input", { ...api.getHiddenInputProps(), "data-testid": "switch-input" }), _jsx("span", { ...api.getControlProps(), className: `${controlBase} ${rxTrackState} ${controlWidth} ${controlHeight} ${controlPadding} ${controlRounded} ${controlHover} ${rxDisabled} ${controlClasses}`, "data-testid": "switch-control", children: _jsxs("span", { ...api.getThumbProps(), className: `${thumbBase} ${rxThumbState} ${thumbRounded} ${thumbTransition} ${thumbEase} ${thumbDuration} ${thumbClasses}`, "data-testid": "switch-thumb", children: [!checked && inactiveChild ? (_jsx("span", { className: iconInactiveBase, "data-testid": "switch-icon-inactive", children: inactiveChild })) : null, checked && activeChild ? (_jsx("span", { className: iconActiveBase, "data-testid": "switch-icon-active", children: activeChild })) : null] }) }), _jsx("span", { ...api.getLabelProps(), className: `${labelBase} ${labelClasses}`, "data-testid": "switch-label", children: children })] }));
48
51
  };
@@ -13,6 +13,8 @@ export interface SwitchProps extends React.PropsWithChildren, Omit<zagSwitch.Con
13
13
  base?: string;
14
14
  /** Provide arbitrary classes to the root element. */
15
15
  classes?: string;
16
+ /** Set claseses for the focus state. */
17
+ stateFocused?: string;
16
18
  /** Set base classes for the control element. */
17
19
  controlBase?: string;
18
20
  /** Set inactive state classes for the control element. */
@@ -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
@@ -1,10 +1,15 @@
1
1
  export { Accordion } from './components/Accordion/Accordion.js';
2
2
  export { Avatar } from './components/Avatar/Avatar.js';
3
3
  export { AppBar } from './components/AppBar/AppBar.js';
4
+ export { FileUpload } from './components/FileUpload/FileUpload.js';
4
5
  export { Nav } from './components/Navigation/Navigation.js';
6
+ export { Pagination } from './components/Pagination/Pagination.js';
5
7
  export { Progress } from './components/Progress/Progress.js';
6
8
  export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
7
- export { Switch } from './components/Switch/Switch.js';
9
+ export { Rating } from './components/Rating/Rating.js';
8
10
  export { Segment } from './components/Segment/Segment.js';
11
+ export { Slider } from './components/Slider/Slider.js';
12
+ export { Switch } from './components/Switch/Switch.js';
9
13
  export { Tabs } from './components/Tabs/Tabs.js';
10
- 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
@@ -2,10 +2,14 @@
2
2
  export { Accordion } from './components/Accordion/Accordion.js';
3
3
  export { Avatar } from './components/Avatar/Avatar.js';
4
4
  export { AppBar } from './components/AppBar/AppBar.js';
5
+ export { FileUpload } from './components/FileUpload/FileUpload.js';
5
6
  export { Nav } from './components/Navigation/Navigation.js';
7
+ export { Pagination } from './components/Pagination/Pagination.js';
6
8
  export { Progress } from './components/Progress/Progress.js';
7
9
  export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
8
- export { Switch } from './components/Switch/Switch.js';
10
+ export { Rating } from './components/Rating/Rating.js';
9
11
  export { Segment } from './components/Segment/Segment.js';
12
+ export { Slider } from './components/Slider/Slider.js';
13
+ export { Switch } from './components/Switch/Switch.js';
10
14
  export { Tabs } from './components/Tabs/Tabs.js';
11
- 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.5",
3
+ "version": "1.0.0-next.7",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -29,16 +29,22 @@
29
29
  "!./dist/schemas.d.ts"
30
30
  ],
31
31
  "dependencies": {
32
- "@zag-js/accordion": "^0.65.0",
33
- "@zag-js/avatar": "^0.65.0",
34
- "@zag-js/progress": "^0.65.0",
35
- "@zag-js/radio-group": "^0.65.0",
36
- "@zag-js/rating-group": "^0.65.0",
37
- "@zag-js/react": "^0.65.0",
38
- "@zag-js/switch": "^0.65.0",
39
- "@zag-js/tabs": "^0.65.0",
40
- "react": "^18.3.1",
41
- "react-dom": "^18.3.1"
32
+ "@zag-js/accordion": "^0.65.1",
33
+ "@zag-js/avatar": "^0.65.1",
34
+ "@zag-js/file-upload": "^0.65.1",
35
+ "@zag-js/pagination": "^0.65.1",
36
+ "@zag-js/progress": "^0.65.1",
37
+ "@zag-js/radio-group": "^0.65.1",
38
+ "@zag-js/rating-group": "^0.65.1",
39
+ "@zag-js/react": "^0.65.1",
40
+ "@zag-js/slider": "^0.65.1",
41
+ "@zag-js/switch": "^0.65.1",
42
+ "@zag-js/tabs": "^0.65.1",
43
+ "@zag-js/tags-input": "^0.65.1"
44
+ },
45
+ "peerDependencies": {
46
+ "react": "^18.0.0",
47
+ "react-dom": "^18.0.0"
42
48
  },
43
49
  "devDependencies": {
44
50
  "@tailwindcss/forms": "^0.5.7",
@@ -50,17 +56,19 @@
50
56
  "@vitejs/plugin-react": "^4.3.1",
51
57
  "autoprefixer": "^10.4.19",
52
58
  "jsdom": "^24.1.1",
53
- "lucide-react": "^0.341.0",
59
+ "lucide-react": "^0.436.0",
54
60
  "postcss": "^8.4.39",
61
+ "react": "^18.2.0",
62
+ "react-dom": "^18.2.0",
55
63
  "react-router-dom": "^6.25.1",
56
64
  "tailwindcss": "^3.4.6",
57
- "typescript": "^5.5.3",
65
+ "typescript": "^5.5.4",
58
66
  "typescript-json-schema": "^0.63.0",
59
67
  "vite": "^5.3.4",
60
68
  "vite-plugin-remix-router": "^2.0.0",
61
69
  "vitest": "^1.6.0",
62
- "@skeletonlabs/skeleton": "3.0.0-next.3",
63
- "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.4"
64
72
  },
65
73
  "scripts": {
66
74
  "dev": "vite",