@skeletonlabs/skeleton-react 1.0.0-next.2 → 1.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/components/Accordion/Accordion.d.ts +2 -2
  2. package/dist/components/Accordion/Accordion.js +21 -21
  3. package/dist/components/Accordion/types.d.ts +1 -1
  4. package/dist/components/AppBar/AppBar.d.ts +2 -2
  5. package/dist/components/AppBar/AppBar.js +18 -20
  6. package/dist/components/AppBar/types.d.ts +1 -1
  7. package/dist/components/Avatar/Avatar.d.ts +2 -2
  8. package/dist/components/Avatar/Avatar.js +5 -5
  9. package/dist/components/Navigation/Navigation.d.ts +2 -2
  10. package/dist/components/Navigation/Navigation.js +53 -30
  11. package/dist/components/Navigation/types.d.ts +6 -0
  12. package/dist/components/Progress/Progress.d.ts +2 -2
  13. package/dist/components/Progress/Progress.js +6 -6
  14. package/dist/components/ProgressRing/ProgressRing.d.ts +2 -2
  15. package/dist/components/ProgressRing/ProgressRing.js +21 -20
  16. package/dist/components/ProgressRing/types.d.ts +1 -1
  17. package/dist/components/Rating/Rating.d.ts +2 -2
  18. package/dist/components/Rating/Rating.js +40 -37
  19. package/dist/components/Rating/types.d.ts +1 -1
  20. package/dist/components/Segment/Segment.d.ts +6 -0
  21. package/dist/components/Segment/Segment.js +60 -0
  22. package/dist/components/Segment/types.d.ts +56 -0
  23. package/dist/components/Segment/types.js +2 -0
  24. package/dist/components/Switch/Switch.d.ts +2 -2
  25. package/dist/components/Switch/Switch.js +14 -16
  26. package/dist/components/Switch/types.d.ts +2 -2
  27. package/dist/components/Tabs/Tabs.d.ts +4 -4
  28. package/dist/components/Tabs/Tabs.js +35 -28
  29. package/dist/components/Tabs/types.d.ts +19 -15
  30. package/dist/components/Test/Test.js +1 -1
  31. package/dist/index.d.ts +11 -10
  32. package/dist/index.js +11 -10
  33. package/package.json +14 -18
  34. package/dist/utils/react-compose.d.ts +0 -4
  35. package/dist/utils/react-compose.js +0 -3
@@ -1,23 +1,25 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
4
  // Components ---
4
5
  export const Rating = ({ value = 0, max = 5, interactive = false, step = 1,
5
6
  // Root
6
- base = "flex", width = "w-full", justify = "justify-center", spaceX = "space-x-2", classes = "",
7
+ base = 'flex', width = 'w-full', justify = 'justify-center', spaceX = 'space-x-2', classes = '',
7
8
  // Item ---
8
- buttonBase = "w-full h-full", buttonPosition = "relative", buttonAspect = "aspect-square", buttonClasses = "",
9
+ buttonBase = 'w-full h-full', buttonPosition = 'relative', buttonAspect = 'aspect-square', buttonClasses = '',
9
10
  // Icon Empty
10
- emptyBase = "absolute left-0 top-0 flex items-center justify-center", emptyClip = "[clip-path:inset(0_0_0_var(--clipValue))] rtl:[clip-path:inset(0_var(--clipValue)_0_0)]", emptyInteractive = "size-full", emptyStatic = "w-fit", emptyClasses = "",
11
+ emptyBase = 'absolute left-0 top-0 flex items-center justify-center', emptyClip = '[clip-path:inset(0_0_0_var(--clipValue))] rtl:[clip-path:inset(0_var(--clipValue)_0_0)]', emptyInteractive = 'size-full', emptyStatic = 'w-fit', emptyClasses = '',
11
12
  // Icon Full
12
- fullBase = "absolute left-0 top-0 flex items-center justify-center", fullClip = "[clip-path:inset(0_var(--clipValue)_0_0)] rtl:[clip-path:inset(0_0_0_var(--clipValue))]", fullInteractive = "size-full", fullStatic = "w-fit", fullClasses = "",
13
+ fullBase = 'absolute left-0 top-0 flex items-center justify-center', fullClip = '[clip-path:inset(0_var(--clipValue)_0_0)] rtl:[clip-path:inset(0_0_0_var(--clipValue))]', fullInteractive = 'size-full', fullStatic = 'w-fit', fullClasses = '',
13
14
  // Events
14
15
  onMouseDown = () => { }, onKeyDown = () => { }, onValueChange = () => { },
15
16
  // Children
16
- iconEmpty, iconFull, }) => {
17
+ iconEmpty, iconFull }) => {
17
18
  const figureRef = useRef(null);
19
+ const valueRef = useRef(value);
18
20
  const [focusedButtonIndex, setFocusedButtonIndex] = useState(0);
19
- const [rxEmptyInteractive, setRxEmptyInteractive] = useState("");
20
- const [rxFullInteractive, setRxFullInteractive] = useState("");
21
+ const [rxEmptyInteractive, setRxEmptyInteractive] = useState('');
22
+ const [rxFullInteractive, setRxFullInteractive] = useState('');
21
23
  useEffect(() => {
22
24
  const index = Math.max(0, Math.ceil(value - 1));
23
25
  setFocusedButtonIndex(index);
@@ -25,7 +27,7 @@ iconEmpty, iconFull, }) => {
25
27
  useEffect(() => {
26
28
  setRxEmptyInteractive(interactive ? emptyInteractive : emptyStatic);
27
29
  setRxFullInteractive(interactive ? fullInteractive : fullStatic);
28
- }, [interactive]);
30
+ }, [interactive, emptyInteractive, emptyStatic, fullInteractive, fullStatic]);
29
31
  const onRatingMouseDown = useCallback((event, order) => {
30
32
  if (!figureRef.current)
31
33
  return;
@@ -33,47 +35,48 @@ iconEmpty, iconFull, }) => {
33
35
  const fractionWidth = ratingRect.width / step;
34
36
  const left = event.clientX - ratingRect.left;
35
37
  let selectedFraction = Math.floor(left / fractionWidth) + 1;
36
- if (getComputedStyle(figureRef.current).direction === "rtl") {
38
+ if (getComputedStyle(figureRef.current).direction === 'rtl') {
37
39
  selectedFraction = step - selectedFraction + 1;
38
40
  }
39
- value = order + selectedFraction / step;
40
- onValueChange(value);
41
- onMouseDown(event, value);
42
- }, [step]);
41
+ valueRef.current = order + selectedFraction / step;
42
+ onValueChange(valueRef.current);
43
+ onMouseDown(event, valueRef.current);
44
+ }, [step, onMouseDown, onValueChange]);
43
45
  // https://www.w3.org/WAI/ARIA/apg/patterns/radio/examples/radio-rating/#kbd_label
44
46
  const onRatingKeyDown = useCallback((event) => {
47
+ // If functions are not used outside of an effect/callback, they need to be defined in the effect/callback
48
+ function increaseValue() {
49
+ valueRef.current = Math.min(max, valueRef.current + 1 / step);
50
+ onValueChange(valueRef.current);
51
+ refreshFocus();
52
+ }
53
+ function decreaseValue() {
54
+ valueRef.current = Math.max(0, valueRef.current - 1 / step);
55
+ onValueChange(valueRef.current);
56
+ refreshFocus();
57
+ }
58
+ function refreshFocus() {
59
+ if (!figureRef.current)
60
+ return;
61
+ const buttons = figureRef.current.querySelectorAll('button');
62
+ buttons[Math.max(0, Math.ceil(valueRef.current - 1))].focus();
63
+ }
45
64
  if (!figureRef.current)
46
65
  return;
47
- const rtl = getComputedStyle(figureRef.current).direction === "rtl";
48
- if (["ArrowLeft", "ArrowUp"].includes(event.key)) {
66
+ const rtl = getComputedStyle(figureRef.current).direction === 'rtl';
67
+ if (['ArrowLeft', 'ArrowUp'].includes(event.key)) {
49
68
  event.preventDefault();
50
69
  rtl ? increaseValue() : decreaseValue();
51
70
  }
52
- if (["ArrowRight", "ArrowDown"].includes(event.key)) {
71
+ if (['ArrowRight', 'ArrowDown'].includes(event.key)) {
53
72
  event.preventDefault();
54
73
  rtl ? decreaseValue() : increaseValue();
55
74
  }
56
75
  onKeyDown(event);
57
- }, []);
58
- function refreshFocus() {
59
- if (!figureRef.current)
60
- return;
61
- const buttons = figureRef.current.querySelectorAll("button");
62
- buttons[Math.max(0, Math.ceil(value - 1))].focus();
63
- }
64
- function increaseValue() {
65
- value = Math.min(max, value + 1 / step);
66
- onValueChange(value);
67
- refreshFocus();
68
- }
69
- function decreaseValue() {
70
- value = Math.max(0, value - 1 / step);
71
- onValueChange(value);
72
- refreshFocus();
73
- }
74
- return (_jsx("figure", { ref: figureRef, className: `${base} ${width} ${justify} ${spaceX} ${classes}`, "data-testid": "rating", children: [...Array(max)].map((_, order) => (_jsxs("button", { className: `${buttonBase} ${buttonPosition} ${buttonAspect} ${buttonClasses} ${interactive ? undefined : "pointer-events-none"}`, tabIndex: interactive && order === focusedButtonIndex ? 0 : -1, onMouseDown: (event) => interactive ? onRatingMouseDown(event, order) : undefined, onKeyDown: (event) => interactive ? onRatingKeyDown(event) : undefined, type: "button", children: [_jsx("span", { className: `${emptyBase} ${emptyClip} ${rxEmptyInteractive} ${emptyClasses}`, style: {
75
- "--clipValue": `${(value - order) * 100}%`,
76
+ }, [onKeyDown, max, onValueChange, step]);
77
+ return (_jsx("figure", { ref: figureRef, className: `${base} ${width} ${justify} ${spaceX} ${classes}`, "data-testid": "rating", children: [...Array(max)].map((_, order) => (_jsxs("button", { className: `${buttonBase} ${buttonPosition} ${buttonAspect} ${buttonClasses} ${interactive ? undefined : 'pointer-events-none'}`, tabIndex: interactive && order === focusedButtonIndex ? 0 : -1, onMouseDown: (event) => (interactive ? onRatingMouseDown(event, order) : undefined), onKeyDown: (event) => (interactive ? onRatingKeyDown(event) : undefined), type: "button", children: [_jsx("span", { className: `${emptyBase} ${emptyClip} ${rxEmptyInteractive} ${emptyClasses}`, style: {
78
+ '--clipValue': `${(value - order) * 100}%`
76
79
  }, "data-testid": "rating-iconempty", children: iconEmpty }), _jsx("span", { className: `${fullBase} ${fullClip} ${rxFullInteractive} ${fullClasses}`, style: {
77
- "--clipValue": `${100 - (value - order) * 100}%`,
80
+ '--clipValue': `${100 - (value - order) * 100}%`
78
81
  }, "data-testid": "rating-iconfull", children: iconFull })] }, order))) }));
79
82
  };
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from "react";
1
+ import React, { ReactNode } from 'react';
2
2
  export interface RatingProps {
3
3
  /** Sets the rating value. */
4
4
  value?: number;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { SegmentContextState, SegmentProps, SegmentItemsProps } from './types.js';
3
+ export declare const SegmentContext: React.Context<SegmentContextState>;
4
+ export declare const Segment: React.FC<SegmentProps> & {
5
+ Item: React.FC<SegmentItemsProps>;
6
+ };
@@ -0,0 +1,60 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createContext, useContext, useEffect, useState } from 'react';
4
+ // Contexts ---
5
+ export const SegmentContext = createContext({
6
+ value: '',
7
+ name: '',
8
+ onSelectionHandler: () => { }
9
+ });
10
+ // Components ---
11
+ const SegmentRoot = ({ value = '', name = '',
12
+ // Root
13
+ base = 'inline-flex items-stretch overflow-hidden', background = 'preset-outlined-surface-200-800', border = 'p-2', flexDirection = 'flex-row', // vertical: flex-col
14
+ gap = 'gap-2', padding = '', rounded = 'rounded-container', width = '', classes = '',
15
+ // Events
16
+ onChange,
17
+ // Children
18
+ children }) => {
19
+ function onSelectionHandler(newValue) {
20
+ value = newValue;
21
+ if (onChange)
22
+ onChange(newValue);
23
+ }
24
+ // Set Context
25
+ const ctx = {
26
+ value,
27
+ name,
28
+ onSelectionHandler
29
+ };
30
+ return (_jsx("div", { role: "radiogroup", className: `${base} ${flexDirection} ${background} ${border} ${padding} ${gap} ${rounded} ${width} ${classes}`, "data-testid": "segment", children: _jsx(SegmentContext.Provider, { value: ctx, children: children }) }));
31
+ };
32
+ const SegmentItem = ({ id, value, title, disabled = false,
33
+ // Root
34
+ base = 'btn', active = 'preset-filled', hover = 'hover:preset-tonal', classes = '',
35
+ // Label
36
+ labelBase = 'pointer-events-none', labelClasses = '',
37
+ // Events
38
+ onClick,
39
+ // Children
40
+ children }) => {
41
+ // Get Context
42
+ const ctx = useContext(SegmentContext);
43
+ // Reactive
44
+ const [selected, setSelected] = useState(value === ctx.value);
45
+ const [rxActive, setRxActive] = useState(selected ? active : hover);
46
+ useEffect(() => {
47
+ setSelected(value === ctx.value);
48
+ }, [value, ctx.value]);
49
+ useEffect(() => {
50
+ setRxActive(selected ? active : hover);
51
+ }, [selected, active, hover]);
52
+ function onClickHandler() {
53
+ ctx.onSelectionHandler(value);
54
+ onClick?.(value);
55
+ }
56
+ return (_jsxs("button", { role: "radio", "aria-checked": selected, onClick: onClickHandler, type: "button", className: `${base} ${rxActive} ${classes}`, title: title, disabled: disabled, "data-testid": "segment-item", children: [selected ? _jsx("input", { type: "hidden", name: ctx.name, id: id, value: value }) : null, _jsx("label", { className: `${labelBase} ${labelClasses}`, children: children })] }));
57
+ };
58
+ export const Segment = Object.assign(SegmentRoot, {
59
+ Item: SegmentItem
60
+ });
@@ -0,0 +1,56 @@
1
+ /// <reference types="react" />
2
+ export interface SegmentContextState {
3
+ value: string;
4
+ name: string;
5
+ onSelectionHandler: (value: string) => void;
6
+ }
7
+ export interface SegmentProps extends React.PropsWithChildren {
8
+ /** Set the group value, which determines selection state. */
9
+ value?: string;
10
+ /** Provide the shared input name. */
11
+ name: string;
12
+ /** Sets base classes. */
13
+ base?: string;
14
+ /** Set background classes. */
15
+ background?: string;
16
+ /** Set border classes. */
17
+ border?: string;
18
+ /** Set flex direction classes. */
19
+ flexDirection?: string;
20
+ /** Set gap classes. */
21
+ gap?: string;
22
+ /** Set padding classes. */
23
+ padding?: string;
24
+ /** Set rounded classes. */
25
+ rounded?: string;
26
+ /** Set width classes. */
27
+ width?: string;
28
+ /** Provide arbitrary CSS classes. */
29
+ classes?: string;
30
+ /** Triggers when the value state is changed. */
31
+ onChange?: (value: string) => void;
32
+ }
33
+ export interface SegmentItemsProps extends React.PropsWithChildren {
34
+ /** Provide a unique ID. */
35
+ id: string;
36
+ /** Provide the unique segment value. */
37
+ value: string;
38
+ /** Provide a hover title attribute. */
39
+ title?: string;
40
+ /** Set the disabled state. */
41
+ disabled?: boolean;
42
+ /** Sets base classes. */
43
+ base?: string;
44
+ /** Sets active state classes. */
45
+ active?: string;
46
+ /** Sets hover state classes. */
47
+ hover?: string;
48
+ /** Provide arbitrary CSS classes. */
49
+ classes?: string;
50
+ /** Sets base classes for the label element. */
51
+ labelBase?: string;
52
+ /** Provide arbitrary CSS classes for the label element. */
53
+ labelClasses?: string;
54
+ /** Triggers on items click event. */
55
+ onClick?: (group: string) => void;
56
+ }
@@ -0,0 +1,2 @@
1
+ // Segment Control Types
2
+ export {};
@@ -1,3 +1,3 @@
1
- import React from "react";
2
- import { SwitchProps } from "./types.js";
1
+ import React from 'react';
2
+ import { SwitchProps } from './types.js';
3
3
  export declare const Switch: React.FC<SwitchProps>;
@@ -1,41 +1,39 @@
1
- "use client";
1
+ 'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- export const Switch = ({ id = "", name = "", checked = false, disabled = false, compact = false,
3
+ export const Switch = ({ id = '', name = '', checked = false, disabled = false, compact = false,
4
4
  // Aria
5
5
  labelledby = undefined, describedby = undefined,
6
6
  // Root (Track)
7
- base = "flex cursor-pointer transition duration-200", stateInactive = "preset-filled-surface-200-800", stateActive = "preset-filled-primary-500", stateDisabled = "opacity-50 cursor-not-allowed", width = "w-10", height = "h-6", padding = "p-0.5", rounded = "rounded-full", hover = "hover:brightness-90 dark:hover:brightness-110", classes = "",
7
+ base = 'flex cursor-pointer transition duration-200', stateInactive = 'preset-filled-surface-200-800', stateActive = 'preset-filled-primary-500', stateDisabled = 'opacity-50 cursor-not-allowed', width = 'w-10', height = 'h-6', padding = 'p-0.5', rounded = 'rounded-full', hover = 'hover:brightness-90 dark:hover:brightness-110', classes = '',
8
8
  // Thumb
9
- thumbBase = "right-0 aspect-square h-full flex justify-center items-center text-right", thumbInactive = "preset-filled-surface-50-950", thumbActive = "bg-surface-50 text-surface-contrast-50", thumbRounded = "rounded-full", thumbTranslateX = "translate-x-4", thumbTransition = "transition", thumbEase = "ease-in-out", thumbDuration = "duration-200", thumbClasses = "",
9
+ thumbBase = 'right-0 aspect-square h-full flex justify-center items-center text-right', thumbInactive = 'preset-filled-surface-50-950', thumbActive = 'bg-surface-50 text-surface-contrast-50', thumbRounded = 'rounded-full', thumbTranslateX = 'translate-x-4', thumbTransition = 'transition', thumbEase = 'ease-in-out', thumbDuration = 'duration-200', thumbClasses = '',
10
10
  // Icons
11
- iconInactiveBase = "pointer-events-none", iconActiveBase = "pointer-events-none",
11
+ iconInactiveBase = 'pointer-events-none', iconActiveBase = 'pointer-events-none',
12
12
  // Events
13
- onCheckedChange = () => { },
13
+ onChange = () => { },
14
14
  // Children
15
- inactiveChild, activeChild, }) => {
15
+ inactiveChild, activeChild }) => {
16
16
  // Set Compact Mode
17
17
  if (compact) {
18
18
  base = thumbBase;
19
19
  // Removes the height class
20
- height = "";
20
+ height = '';
21
21
  // Thumb inherits track styles
22
22
  thumbInactive = stateInactive;
23
23
  thumbActive = stateActive;
24
24
  // Remove X-axis translate
25
- thumbTranslateX = "";
25
+ thumbTranslateX = '';
26
26
  // Remove padding
27
- padding = "";
27
+ padding = '';
28
28
  }
29
29
  function toggle() {
30
30
  if (disabled)
31
31
  return;
32
32
  checked = !checked;
33
- onCheckedChange(checked);
33
+ onChange(checked);
34
34
  }
35
35
  const rxTrackState = checked ? stateActive : stateInactive;
36
- const rxThumbState = checked
37
- ? `${thumbActive} ${thumbTranslateX}`
38
- : thumbInactive;
39
- const rxDisabled = disabled ? stateDisabled : "";
40
- return (_jsxs("button", { type: "button", className: `${base} ${rxTrackState} ${width} ${height} ${padding} ${rounded} ${hover} ${rxDisabled} ${classes}`, role: "switch", "aria-checked": checked, "aria-labelledby": labelledby, "aria-describedby": describedby, onClick: toggle, "data-testid": "switch", children: [_jsx("input", { type: "checkbox", id: id, name: name, checked: checked, onChange: () => { }, className: "hidden", disabled: disabled }), _jsxs("div", { className: `${thumbBase} ${rxThumbState} ${thumbRounded} ${thumbTransition} ${thumbEase} ${thumbDuration} ${thumbClasses}`, children: [!checked && inactiveChild ? (_jsx("span", { className: iconInactiveBase, children: inactiveChild })) : null, checked && activeChild ? (_jsx("span", { className: iconActiveBase, children: activeChild })) : null] })] }));
36
+ const rxThumbState = checked ? `${thumbActive} ${thumbTranslateX}` : thumbInactive;
37
+ const rxDisabled = disabled ? stateDisabled : '';
38
+ return (_jsxs("button", { type: "button", className: `${base} ${rxTrackState} ${width} ${height} ${padding} ${rounded} ${hover} ${rxDisabled} ${classes}`, role: "switch", "aria-checked": checked, "aria-labelledby": labelledby, "aria-describedby": describedby, onClick: toggle, "data-testid": "switch", children: [checked ?? _jsx("input", { type: "hidden", id: id, name: name, value: "on", disabled: disabled }), _jsxs("div", { className: `${thumbBase} ${rxThumbState} ${thumbRounded} ${thumbTransition} ${thumbEase} ${thumbDuration} ${thumbClasses}`, children: [!checked && inactiveChild ? _jsx("span", { className: iconInactiveBase, children: inactiveChild }) : null, checked && activeChild ? _jsx("span", { className: iconActiveBase, children: activeChild }) : null] })] }));
41
39
  };
@@ -1,4 +1,4 @@
1
- import { ReactNode } from "react";
1
+ import { ReactNode } from 'react';
2
2
  export interface SwitchProps {
3
3
  /** Set a unique ID for the switch input. */
4
4
  id: string;
@@ -57,7 +57,7 @@ export interface SwitchProps {
57
57
  /** Set base classes for the active icon child. */
58
58
  iconActiveBase?: string;
59
59
  /** Triggers when the switch is toggled. */
60
- onCheckedChange?: (event: boolean) => void;
60
+ onChange?: (event: boolean) => void;
61
61
  /** The inactive state children. */
62
62
  inactiveChild?: ReactNode;
63
63
  /** The active state children. */
@@ -1,8 +1,8 @@
1
- import React from "react";
2
- import { TabsProps, TabsListProps, TabsControlProps, TabsControlItemProps, TabsPanelItemProps } from "./types.js";
1
+ import React from 'react';
2
+ import { TabsProps, TabsListProps, TabsControlProps, TabPanelsProps, TabsPanelProps } from './types.js';
3
3
  export declare const Tabs: React.FC<TabsProps> & {
4
4
  List: React.FC<TabsListProps>;
5
5
  Control: React.FC<TabsControlProps>;
6
- Panel: React.FC<TabsPanelItemProps>;
7
- Item: React.FC<TabsControlItemProps>;
6
+ Panels: React.FC<TabPanelsProps>;
7
+ Panel: React.FC<TabsPanelProps>;
8
8
  };
@@ -1,29 +1,34 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from "react";
3
- // Components ---
4
- const TabsRoot = ({ id = "",
3
+ import { useEffect, useRef, useState } from 'react';
4
+ /** The root Tab component. */
5
+ const TabsRoot = ({ id = '',
5
6
  // Root
6
- base = "w-full", spaceY = "space-y-4", classes = "",
7
+ base = 'w-full', spaceY = 'space-y-4', classes = '',
7
8
  // Children
8
- children, }) => {
9
+ children }) => {
9
10
  return (_jsx("div", { id: id, className: `${base} ${spaceY} ${classes}`, "data-testid": "tabs", children: children }));
10
11
  };
12
+ /** The list of `<Tab.Control>` components. */
11
13
  const TabsList = ({
12
14
  // Root
13
- base = "flex", justify = "justify-start", gap = "gap-2", border = "border-b border-surface-200-800", classes = "",
15
+ base = 'flex', justify = 'justify-start', gap = 'gap-2', border = 'border-b border-surface-200-800', classes = '',
14
16
  // Children
15
- children, }) => {
17
+ children }) => {
16
18
  return (_jsx("div", { className: `${base} ${gap} ${justify} ${border} ${classes}`, role: "tablist", children: children }));
17
19
  };
18
- const TabsControl = ({ id = "", name, group, title = "",
20
+ /** The individual Tab control component. */
21
+ const TabsControl = ({ id = '', name, group, title = '',
19
22
  // A11y
20
- label = "", controls = "",
23
+ label = '', controls = '',
21
24
  // Root
22
- base = "group", width = "", active = "text-surface-950-50 border-surface-950-50", inactive = "text-surface-600-400 border-transparent", flex = "flex justify-center items-center", background = "", border = "border-b", text = "type-scale-3", padding = "pb-2", rounded = "", gap = "gap-1", cursor = "cursor-pointer", classes = "",
25
+ base = 'group', width = '', active = 'text-surface-950-50 border-surface-950-50', inactive = 'text-surface-600-400 border-transparent', flex = 'flex justify-center items-center', background = '', border = 'border-b', text = 'type-scale-3', padding = 'pb-2', rounded = '', gap = 'gap-1', cursor = 'cursor-pointer', classes = '',
26
+ // Content
27
+ contentBase = 'w-full', contentFlex = 'flex justify-center items-center', contentGap = 'gap-2', contentBg = 'group-hover:preset-tonal-primary', contentPadding = 'p-2 px-4', contentRounded = 'rounded-container', contentClasses = '',
23
28
  // Events
24
29
  onClick = () => { }, onKeydown = () => { }, onKeyup = () => { }, onChange = () => { },
25
30
  // Children
26
- children, }) => {
31
+ children }) => {
27
32
  const [selected, setSelected] = useState(group === name);
28
33
  useEffect(() => {
29
34
  setSelected(group === name);
@@ -40,7 +45,7 @@ children, }) => {
40
45
  // Fire Event Handler
41
46
  onKeydown(event);
42
47
  // If select key events
43
- if (!["ArrowRight", "ArrowLeft", "Home", "End"].includes(event.code))
48
+ if (!['ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(event.code))
44
49
  return;
45
50
  const elemInput = elemInputRef.current;
46
51
  if (!elemInput)
@@ -55,7 +60,7 @@ children, }) => {
55
60
  if (!tabList)
56
61
  return;
57
62
  // Get RTL mode
58
- const isRTL = getComputedStyle(tabList).direction === "rtl";
63
+ const isRTL = getComputedStyle(tabList).direction === 'rtl';
59
64
  // Get list of tab elements
60
65
  const tabs = Array.from(tabList.querySelectorAll('[role="tab"]'));
61
66
  // Get a reference to the current tab
@@ -63,24 +68,24 @@ children, }) => {
63
68
  // Determine the index of the next tab
64
69
  let nextIndex = -1;
65
70
  switch (event.code) {
66
- case "ArrowRight":
71
+ case 'ArrowRight':
67
72
  if (isRTL) {
68
73
  nextIndex = currIndex - 1 < 0 ? tabs.length - 1 : currIndex - 1;
69
74
  break;
70
75
  }
71
76
  nextIndex = currIndex + 1 >= tabs.length ? 0 : currIndex + 1;
72
77
  break;
73
- case "ArrowLeft":
78
+ case 'ArrowLeft':
74
79
  if (isRTL) {
75
80
  nextIndex = currIndex + 1 >= tabs.length ? 0 : currIndex + 1;
76
81
  break;
77
82
  }
78
83
  nextIndex = currIndex - 1 < 0 ? tabs.length - 1 : currIndex - 1;
79
84
  break;
80
- case "Home":
85
+ case 'Home':
81
86
  nextIndex = 0;
82
87
  break;
83
- case "End":
88
+ case 'End':
84
89
  nextIndex = tabs.length - 1;
85
90
  break;
86
91
  }
@@ -88,34 +93,36 @@ children, }) => {
88
93
  return;
89
94
  // Set Active Tab
90
95
  const nextTab = tabs[nextIndex];
91
- const nextTabInput = nextTab?.querySelector("input");
96
+ const nextTabInput = nextTab?.querySelector('input');
92
97
  if (nextTabInput) {
93
98
  nextTabInput.click();
94
99
  nextTab.focus();
95
100
  }
96
101
  }
97
- return (_jsx("label", { id: id, className: `${base} ${width} ${rxActive} ${flex} ${background} ${border} ${text} ${padding} ${rounded} ${gap} ${cursor} ${classes}`, "aria-label": label, title: title, children: _jsxs("div", { className: "size-full", role: "tab", "aria-controls": controls, "aria-selected": selected, "data-testid": "tabs-control", tabIndex: selected ? 0 : -1, onKeyDown: onKeyDownHandler, onKeyUp: onKeyup, children: [_jsx("div", { className: "h-0 w-0 flex-none overflow-hidden", children: _jsx("input", { ref: elemInputRef, type: "radio", name: name, value: name, checked: selected, onChange: handleOnChange, onClick: onClick, tabIndex: -1 }) }), children] }) }));
102
+ return (_jsx("label", { id: id, className: `${base} ${width} ${rxActive} ${flex} ${background} ${border} ${text} ${padding} ${rounded} ${gap} ${cursor} ${classes}`, "aria-label": label, title: title, children: _jsxs("div", { className: "size-full", role: "tab", "aria-controls": controls, "aria-selected": selected, "data-testid": "tabs-control", tabIndex: selected ? 0 : -1, onKeyDown: onKeyDownHandler, onKeyUp: onKeyup, children: [_jsx("div", { className: "h-0 w-0 flex-none overflow-hidden", children: _jsx("input", { ref: elemInputRef, type: "radio", name: name, value: name, checked: selected, onChange: handleOnChange, onClick: onClick, tabIndex: -1 }) }), children && (_jsx("div", { className: `${contentBase} ${contentFlex} ${contentGap} ${contentBg} ${contentPadding} ${contentRounded} ${contentClasses}`, children: children }))] }) }));
98
103
  };
99
- const TabsControlItem = ({
104
+ /** The list of `<Tab.Panel>` components. */
105
+ const TabPanels = ({
100
106
  // Root
101
- base = "w-full", flex = "flex justify-center items-center", gap = "gap-2", background = "group-hover:preset-tonal-primary", padding = "p-2 px-4", rounded = "rounded-container", classes = "",
107
+ base = '', classes = '',
102
108
  // Children
103
- children, }) => {
104
- return (_jsx("div", { className: `${base} ${flex} ${gap} ${background} ${padding} ${rounded} ${classes}`, children: children }));
109
+ children }) => {
110
+ return _jsx("div", { className: `${base} ${classes}`, children: children });
105
111
  };
106
- const TabsPanelItem = ({ id = "", value, group,
112
+ /** The individual Panel component. */
113
+ const TabsPanel = ({ id = '', value, group,
107
114
  // A11y
108
115
  labelledBy,
109
116
  // Root
110
- classes = "",
117
+ classes = '',
111
118
  // Children
112
- children, }) => {
119
+ children }) => {
113
120
  return (value === group &&
114
121
  children && (_jsx("div", { id: id, role: "tabpanel", tabIndex: 0, "aria-labelledby": labelledBy, className: classes, children: children })));
115
122
  };
116
123
  export const Tabs = Object.assign(TabsRoot, {
117
124
  List: TabsList,
118
125
  Control: TabsControl,
119
- Panel: TabsPanelItem,
120
- Item: TabsControlItem,
126
+ Panels: TabPanels,
127
+ Panel: TabsPanel
121
128
  });
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
  export interface TabsProps extends React.PropsWithChildren {
3
3
  /** Provide a unique ID. */
4
4
  id?: string;
@@ -60,6 +60,20 @@ export interface TabsControlProps extends React.PropsWithChildren {
60
60
  cursor?: string;
61
61
  /** Provide arbitrary CSS classes. */
62
62
  classes?: string;
63
+ /** Sets tab content base styles. */
64
+ contentBase?: string;
65
+ /** Sets tab content flex styles. */
66
+ contentFlex?: string;
67
+ /** Sets the tab content gap styles. */
68
+ contentGap?: string;
69
+ /** Sets the tab content background styles. */
70
+ contentBg?: string;
71
+ /** Sets the tab content padding styles. */
72
+ contentPadding?: string;
73
+ /** Sets the tab content rounded styles. */
74
+ contentRounded?: string;
75
+ /** Provide arbitrary CSS classes for the tab content. */
76
+ contentClasses?: string;
63
77
  /** Triggers on Tab Control click. */
64
78
  onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;
65
79
  /** Triggers on Tab Control key down. */
@@ -69,23 +83,13 @@ export interface TabsControlProps extends React.PropsWithChildren {
69
83
  /** Triggers on Tab Control group change. */
70
84
  onChange?: (group: string) => void;
71
85
  }
72
- export interface TabsControlItemProps extends React.PropsWithChildren {
73
- /** Sets base styles. */
86
+ export interface TabPanelsProps extends React.PropsWithChildren {
87
+ /** Sets wrapping panel base styles. */
74
88
  base?: string;
75
- /** Sets flex styles. */
76
- flex?: string;
77
- /** Sets gap styles. */
78
- gap?: string;
79
- /** Sets background styles. */
80
- background?: string;
81
- /** Sets padding styles. */
82
- padding?: string;
83
- /** Sets rounded styles. */
84
- rounded?: string;
85
- /** Provide arbitrary CSS classes. */
89
+ /** Provide arbitrary CSS classes to the wrapping panel element. */
86
90
  classes?: string;
87
91
  }
88
- export interface TabsPanelItemProps extends React.PropsWithChildren {
92
+ export interface TabsPanelProps extends React.PropsWithChildren {
89
93
  /** Provide a unique ID. */
90
94
  id?: string;
91
95
  /** Provide the tab panel value. */
@@ -1,5 +1,5 @@
1
1
  import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import { useState } from 'react';
3
3
  function Test() {
4
4
  const [count, setCount] = useState(0);
5
5
  function countUp() {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export { default as TestReact } from "./components/Test/Test.js";
2
- export { Accordion } from "./components/Accordion/Accordion.js";
3
- export { Avatar } from "./components/Avatar/Avatar.js";
4
- export { AppBar } from "./components/AppBar/AppBar.js";
5
- export { Nav } from "./components/Navigation/Navigation.js";
6
- export { Progress } from "./components/Progress/Progress.js";
7
- export { ProgressRing } from "./components/ProgressRing/ProgressRing.js";
8
- export { Switch } from "./components/Switch/Switch.js";
9
- export { Tabs } from "./components/Tabs/Tabs.js";
10
- export { Rating } from "./components/Rating/Rating.js";
1
+ export { default as TestReact } from './components/Test/Test.js';
2
+ export { Accordion } from './components/Accordion/Accordion.js';
3
+ export { Avatar } from './components/Avatar/Avatar.js';
4
+ export { AppBar } from './components/AppBar/AppBar.js';
5
+ export { Nav } from './components/Navigation/Navigation.js';
6
+ export { Progress } from './components/Progress/Progress.js';
7
+ export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
8
+ export { Switch } from './components/Switch/Switch.js';
9
+ export { Segment } from './components/Segment/Segment.js';
10
+ export { Tabs } from './components/Tabs/Tabs.js';
11
+ export { Rating } from './components/Rating/Rating.js';
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
- export { default as TestReact } from "./components/Test/Test.js";
1
+ export { default as TestReact } from './components/Test/Test.js';
2
2
  // Components
3
- export { Accordion } from "./components/Accordion/Accordion.js";
4
- export { Avatar } from "./components/Avatar/Avatar.js";
5
- export { AppBar } from "./components/AppBar/AppBar.js";
6
- export { Nav } from "./components/Navigation/Navigation.js";
7
- export { Progress } from "./components/Progress/Progress.js";
8
- export { ProgressRing } from "./components/ProgressRing/ProgressRing.js";
9
- export { Switch } from "./components/Switch/Switch.js";
10
- export { Tabs } from "./components/Tabs/Tabs.js";
11
- export { Rating } from "./components/Rating/Rating.js";
3
+ export { Accordion } from './components/Accordion/Accordion.js';
4
+ export { Avatar } from './components/Avatar/Avatar.js';
5
+ export { AppBar } from './components/AppBar/AppBar.js';
6
+ export { Nav } from './components/Navigation/Navigation.js';
7
+ export { Progress } from './components/Progress/Progress.js';
8
+ export { ProgressRing } from './components/ProgressRing/ProgressRing.js';
9
+ export { Switch } from './components/Switch/Switch.js';
10
+ export { Segment } from './components/Segment/Segment.js';
11
+ export { Tabs } from './components/Tabs/Tabs.js';
12
+ export { Rating } from './components/Rating/Rating.js';