@doscientos/ui 0.1.14 → 0.1.16

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.d.cts CHANGED
@@ -2,7 +2,7 @@ import * as React$1 from 'react';
2
2
  import { RefCallback, ReactNode, ComponentPropsWithRef } from 'react';
3
3
  import { ClassValue } from 'clsx';
4
4
  import * as react_aria_components from 'react-aria-components';
5
- import { DisclosureGroupProps, DisclosurePanelProps, DisclosureProps, ButtonProps as ButtonProps$1, LinkProps, Breadcrumb as Breadcrumb$1, Link, Breadcrumbs as Breadcrumbs$1, Separator as Separator$1, CheckboxProps as CheckboxProps$1, ComboBoxProps, Key, Popover as Popover$1, InputProps as InputProps$1, ListBoxItemProps, ListBoxProps, Input as Input$1, ListBox, ModalOverlayProps, Menu as Menu$1, MenuSectionProps, MenuItemProps, Header, SubmenuTrigger, MenuTrigger as MenuTrigger$1, TextAreaProps, MenuProps, PopoverProps as PopoverProps$1, DialogTrigger, NumberFieldProps, SearchFieldProps, SelectProps, SelectValue as SelectValue$1, Modal, Text, Heading, DialogTriggerProps, SwitchFieldProps, SwitchButtonRenderProps, TabPanelProps as TabPanelProps$1, TabProps as TabProps$1, TabsProps as TabsProps$1, TabListProps, TabPanelsProps, Tooltip as Tooltip$1, TooltipTrigger as TooltipTrigger$1 } from 'react-aria-components';
5
+ import { DisclosureGroupProps, DisclosurePanelProps, DisclosureProps, ButtonProps as ButtonProps$1, LinkProps, Breadcrumb as Breadcrumb$1, Link, Breadcrumbs as Breadcrumbs$1, Separator as Separator$1, CheckboxProps as CheckboxProps$1, ComboBoxProps, Key, Popover as Popover$1, InputProps as InputProps$1, ListBoxItemProps, ListBoxProps, Input as Input$1, ListBox, ModalOverlayProps, Menu as Menu$1, MenuSectionProps, MenuItemProps, Header, SubmenuTrigger, MenuTrigger as MenuTrigger$1, TextAreaProps, MenuProps, PopoverProps as PopoverProps$1, DialogTrigger, NumberFieldProps, SearchFieldProps, SelectProps, SelectValue as SelectValue$1, Modal, Text, Heading, DialogTriggerProps, SwitchProps as SwitchProps$1, TabPanelProps as TabPanelProps$1, TabProps as TabProps$1, TabsProps as TabsProps$1, TabListProps, TabPanelsProps, Tooltip as Tooltip$1, TooltipTrigger as TooltipTrigger$1 } from 'react-aria-components';
6
6
  export { ComboBoxProps, ComboBoxValue as ComboboxValue, DialogTriggerProps as PopoverTriggerProps, SearchFieldProps, SelectProps, DialogProps as SheetPrimitiveProps, DialogTriggerProps as SheetTriggerPrimitiveProps } from 'react-aria-components';
7
7
  import * as class_variance_authority_types from 'class-variance-authority/types';
8
8
  import { VariantProps } from 'class-variance-authority';
@@ -516,11 +516,32 @@ interface SubmitButtonProps extends Omit<ButtonProps, "type"> {
516
516
  }
517
517
  declare function SubmitButton({ pendingLabel, loading, children, isDisabled, size, ...props }: SubmitButtonProps): React$1.JSX.Element;
518
518
 
519
- type SwitchProps = Omit<SwitchFieldProps, "className"> & {
520
- className?: string | ((values: SwitchButtonRenderProps) => string);
521
- size?: "sm" | "md";
519
+ declare const switchSizes: {
520
+ readonly sm: {
521
+ readonly control: "h-4 w-[1.875rem] p-0.5";
522
+ readonly thumb: "h-3 w-4";
523
+ readonly offset: "0.625rem";
524
+ };
525
+ readonly md: {
526
+ readonly control: "h-5 w-9 p-0.5";
527
+ readonly thumb: "h-4 w-5";
528
+ readonly offset: "0.75rem";
529
+ };
530
+ readonly lg: {
531
+ readonly control: "h-6 w-11 p-0.5";
532
+ readonly thumb: "h-5 w-6";
533
+ readonly offset: "1rem";
534
+ };
535
+ };
536
+ type SwitchProps = Omit<SwitchProps$1, "className"> & {
537
+ className?: string;
538
+ size?: keyof typeof switchSizes;
539
+ description?: ReactNode;
540
+ icon?: ReactNode;
541
+ selectedIcon?: ReactNode;
522
542
  };
523
- declare function Switch({ className, children, size, ...props }: SwitchProps): React$1.JSX.Element;
543
+ /** Accessible React Aria switch with semantic tokens and a compact capsule thumb. */
544
+ declare function Switch({ className, children, description, icon, inputRef, isDisabled, isReadOnly, selectedIcon, size, ...props }: SwitchProps): React$1.JSX.Element;
524
545
 
525
546
  /** Presentational table primitives. Sorting, pagination and data state stay in the application. */
526
547
  declare function Table({ className, ...props }: React$1.ComponentProps<"table">): React$1.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as React$1 from 'react';
2
2
  import { RefCallback, ReactNode, ComponentPropsWithRef } from 'react';
3
3
  import { ClassValue } from 'clsx';
4
4
  import * as react_aria_components from 'react-aria-components';
5
- import { DisclosureGroupProps, DisclosurePanelProps, DisclosureProps, ButtonProps as ButtonProps$1, LinkProps, Breadcrumb as Breadcrumb$1, Link, Breadcrumbs as Breadcrumbs$1, Separator as Separator$1, CheckboxProps as CheckboxProps$1, ComboBoxProps, Key, Popover as Popover$1, InputProps as InputProps$1, ListBoxItemProps, ListBoxProps, Input as Input$1, ListBox, ModalOverlayProps, Menu as Menu$1, MenuSectionProps, MenuItemProps, Header, SubmenuTrigger, MenuTrigger as MenuTrigger$1, TextAreaProps, MenuProps, PopoverProps as PopoverProps$1, DialogTrigger, NumberFieldProps, SearchFieldProps, SelectProps, SelectValue as SelectValue$1, Modal, Text, Heading, DialogTriggerProps, SwitchFieldProps, SwitchButtonRenderProps, TabPanelProps as TabPanelProps$1, TabProps as TabProps$1, TabsProps as TabsProps$1, TabListProps, TabPanelsProps, Tooltip as Tooltip$1, TooltipTrigger as TooltipTrigger$1 } from 'react-aria-components';
5
+ import { DisclosureGroupProps, DisclosurePanelProps, DisclosureProps, ButtonProps as ButtonProps$1, LinkProps, Breadcrumb as Breadcrumb$1, Link, Breadcrumbs as Breadcrumbs$1, Separator as Separator$1, CheckboxProps as CheckboxProps$1, ComboBoxProps, Key, Popover as Popover$1, InputProps as InputProps$1, ListBoxItemProps, ListBoxProps, Input as Input$1, ListBox, ModalOverlayProps, Menu as Menu$1, MenuSectionProps, MenuItemProps, Header, SubmenuTrigger, MenuTrigger as MenuTrigger$1, TextAreaProps, MenuProps, PopoverProps as PopoverProps$1, DialogTrigger, NumberFieldProps, SearchFieldProps, SelectProps, SelectValue as SelectValue$1, Modal, Text, Heading, DialogTriggerProps, SwitchProps as SwitchProps$1, TabPanelProps as TabPanelProps$1, TabProps as TabProps$1, TabsProps as TabsProps$1, TabListProps, TabPanelsProps, Tooltip as Tooltip$1, TooltipTrigger as TooltipTrigger$1 } from 'react-aria-components';
6
6
  export { ComboBoxProps, ComboBoxValue as ComboboxValue, DialogTriggerProps as PopoverTriggerProps, SearchFieldProps, SelectProps, DialogProps as SheetPrimitiveProps, DialogTriggerProps as SheetTriggerPrimitiveProps } from 'react-aria-components';
7
7
  import * as class_variance_authority_types from 'class-variance-authority/types';
8
8
  import { VariantProps } from 'class-variance-authority';
@@ -516,11 +516,32 @@ interface SubmitButtonProps extends Omit<ButtonProps, "type"> {
516
516
  }
517
517
  declare function SubmitButton({ pendingLabel, loading, children, isDisabled, size, ...props }: SubmitButtonProps): React$1.JSX.Element;
518
518
 
519
- type SwitchProps = Omit<SwitchFieldProps, "className"> & {
520
- className?: string | ((values: SwitchButtonRenderProps) => string);
521
- size?: "sm" | "md";
519
+ declare const switchSizes: {
520
+ readonly sm: {
521
+ readonly control: "h-4 w-[1.875rem] p-0.5";
522
+ readonly thumb: "h-3 w-4";
523
+ readonly offset: "0.625rem";
524
+ };
525
+ readonly md: {
526
+ readonly control: "h-5 w-9 p-0.5";
527
+ readonly thumb: "h-4 w-5";
528
+ readonly offset: "0.75rem";
529
+ };
530
+ readonly lg: {
531
+ readonly control: "h-6 w-11 p-0.5";
532
+ readonly thumb: "h-5 w-6";
533
+ readonly offset: "1rem";
534
+ };
535
+ };
536
+ type SwitchProps = Omit<SwitchProps$1, "className"> & {
537
+ className?: string;
538
+ size?: keyof typeof switchSizes;
539
+ description?: ReactNode;
540
+ icon?: ReactNode;
541
+ selectedIcon?: ReactNode;
522
542
  };
523
- declare function Switch({ className, children, size, ...props }: SwitchProps): React$1.JSX.Element;
543
+ /** Accessible React Aria switch with semantic tokens and a compact capsule thumb. */
544
+ declare function Switch({ className, children, description, icon, inputRef, isDisabled, isReadOnly, selectedIcon, size, ...props }: SwitchProps): React$1.JSX.Element;
524
545
 
525
546
  /** Presentational table primitives. Sorting, pagination and data state stay in the application. */
526
547
  declare function Table({ className, ...props }: React$1.ComponentProps<"table">): React$1.JSX.Element;
package/dist/index.js CHANGED
@@ -142,6 +142,7 @@ function getTextMatchParts(text, query) {
142
142
  }
143
143
 
144
144
  // src/ui/accordion/accordion.tsx
145
+ import "react";
145
146
  import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";
146
147
  import {
147
148
  DisclosurePanel as AccordionContentPrimitive,
@@ -156,7 +157,7 @@ function Accordion({ className, ...props }) {
156
157
  AccordionPrimitive,
157
158
  {
158
159
  "data-slot": "accordion",
159
- className: cn("flex w-full flex-col", className),
160
+ className: cn("flex w-full flex-col text-foreground", className),
160
161
  ...props
161
162
  }
162
163
  );
@@ -182,7 +183,7 @@ function AccordionTrigger({
182
183
  slot: "trigger",
183
184
  "data-slot": "accordion-trigger",
184
185
  className: cn(
185
- "group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring disabled:pointer-events-none disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",
186
+ "group/accordion-trigger relative flex flex-1 items-start justify-between gap-3 rounded-lg border border-transparent px-2.5 py-2.5 text-left text-sm font-medium text-foreground transition-colors outline-none hover:bg-muted/50 aria-expanded:bg-muted/50 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",
186
187
  className
187
188
  ),
188
189
  ...props,
@@ -206,18 +207,22 @@ function AccordionTrigger({
206
207
  }
207
208
  ) });
208
209
  }
209
- function AccordionContent({ className, children, ...props }) {
210
+ function AccordionContent({
211
+ className,
212
+ children,
213
+ ...props
214
+ }) {
210
215
  return /* @__PURE__ */ jsx(
211
216
  AccordionContentPrimitive,
212
217
  {
213
218
  "data-slot": "accordion-content",
214
- className: "h-(--disclosure-panel-height) overflow-clip text-sm transition-[height] data-open:animate-accordion-down data-closed:animate-accordion-up",
219
+ className: "h-(--disclosure-panel-height) overflow-clip text-sm text-muted-foreground transition-[height] data-open:animate-accordion-down data-closed:animate-accordion-up",
215
220
  ...props,
216
221
  children: /* @__PURE__ */ jsx(
217
222
  "div",
218
223
  {
219
224
  className: cn(
220
- "pt-0 pb-2.5 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",
225
+ "px-2.5 pt-0 pb-3 [&_a]:text-foreground [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-primary [&_p:not(:last-child)]:mb-4",
221
226
  className
222
227
  ),
223
228
  children
@@ -1479,7 +1484,7 @@ function FormRow({ label, htmlFor, required, hint, error, className, children })
1479
1484
  import { Link as Link2 } from "react-aria-components";
1480
1485
 
1481
1486
  // src/ui/tooltip/tooltip.tsx
1482
- import * as React2 from "react";
1487
+ import * as React3 from "react";
1483
1488
  import {
1484
1489
  Focusable,
1485
1490
  OverlayArrow,
@@ -1492,7 +1497,7 @@ function TooltipTrigger({
1492
1497
  children,
1493
1498
  ...props
1494
1499
  }) {
1495
- const [trigger, tooltip] = React2.Children.toArray(children);
1500
+ const [trigger, tooltip] = React3.Children.toArray(children);
1496
1501
  return /* @__PURE__ */ jsxs10(
1497
1502
  TooltipTriggerPrimitive,
1498
1503
  {
@@ -2442,62 +2447,110 @@ function SubmitButton({ pendingLabel = "Guardando\u2026", loading = false, child
2442
2447
  }
2443
2448
 
2444
2449
  // src/ui/switch/switch.tsx
2450
+ import { useEffect as useEffect5, useRef as useRef5 } from "react";
2445
2451
  import {
2446
- SwitchButton as AriaSwitchButton,
2447
- SwitchField as AriaSwitchField
2452
+ Switch as AriaSwitch
2448
2453
  } from "react-aria-components";
2449
2454
  import { Fragment as Fragment10, jsx as jsx42, jsxs as jsxs20 } from "react/jsx-runtime";
2450
- var sizeStyles = {
2451
- sm: { track: "h-5 w-9 p-0.5", thumb: "size-4", travel: "group-data-selected/switch:translate-x-4" },
2452
- md: { track: "h-6 w-11 p-0.5", thumb: "size-5", travel: "group-data-selected/switch:translate-x-5" }
2455
+ var switchSizes = {
2456
+ sm: {
2457
+ control: "h-4 w-[1.875rem] p-0.5",
2458
+ thumb: "h-3 w-4",
2459
+ offset: "0.625rem"
2460
+ },
2461
+ md: {
2462
+ control: "h-5 w-9 p-0.5",
2463
+ thumb: "h-4 w-5",
2464
+ offset: "0.75rem"
2465
+ },
2466
+ lg: {
2467
+ control: "h-6 w-11 p-0.5",
2468
+ thumb: "h-5 w-6",
2469
+ offset: "1rem"
2470
+ }
2453
2471
  };
2454
- function Switch({ className, children, size = "sm", ...props }) {
2455
- const styles = sizeStyles[size];
2456
- return /* @__PURE__ */ jsx42(AriaSwitchField, { ...props, children: /* @__PURE__ */ jsx42(
2457
- AriaSwitchButton,
2472
+ function Switch({
2473
+ className,
2474
+ children,
2475
+ description,
2476
+ icon,
2477
+ inputRef,
2478
+ isDisabled,
2479
+ isReadOnly,
2480
+ selectedIcon,
2481
+ size = "sm",
2482
+ ...props
2483
+ }) {
2484
+ const styles = switchSizes[size];
2485
+ const fallbackInputRef = useRef5(null);
2486
+ const resolvedInputRef = inputRef ?? fallbackInputRef;
2487
+ useEffect5(() => {
2488
+ const input = resolvedInputRef.current;
2489
+ if (!input) return;
2490
+ const handleDirectionalKey = (event) => {
2491
+ if (event.target !== input || event.defaultPrevented || isDisabled || isReadOnly || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
2492
+ const nextSelected = event.key === "ArrowRight" ? true : event.key === "ArrowLeft" ? false : null;
2493
+ if (nextSelected === null) return;
2494
+ event.preventDefault();
2495
+ if (input.checked !== nextSelected) input.click();
2496
+ };
2497
+ const ownerDocument = input.ownerDocument;
2498
+ ownerDocument.addEventListener("keydown", handleDirectionalKey);
2499
+ return () => ownerDocument.removeEventListener("keydown", handleDirectionalKey);
2500
+ }, [isDisabled, isReadOnly, resolvedInputRef]);
2501
+ return /* @__PURE__ */ jsx42(
2502
+ AriaSwitch,
2458
2503
  {
2459
2504
  "data-slot": "switch",
2460
2505
  "data-size": size,
2461
- className: (state) => cn(
2462
- "group/switch inline-flex w-max items-center gap-2 text-sm text-foreground outline-none",
2506
+ inputRef: resolvedInputRef,
2507
+ isDisabled,
2508
+ isReadOnly,
2509
+ className: cn(
2510
+ "group/switch inline-flex cursor-pointer items-center gap-3 text-sm text-foreground outline-none select-none",
2463
2511
  "data-disabled:cursor-not-allowed data-disabled:opacity-50",
2464
- typeof className === "function" ? className(state) : className
2512
+ className
2465
2513
  ),
2514
+ ...props,
2466
2515
  children: (state) => /* @__PURE__ */ jsxs20(Fragment10, { children: [
2467
2516
  /* @__PURE__ */ jsx42(
2468
2517
  "span",
2469
2518
  {
2470
2519
  "aria-hidden": "true",
2520
+ "data-slot": "switch-control",
2471
2521
  className: cn(
2472
- "relative inline-flex shrink-0 items-center rounded-full border border-transparent bg-secondary",
2473
- "shadow-[inset_0_1px_2px_rgb(0_0_0/0.08)]",
2474
- "transition-[background-color,box-shadow] duration-200 ease-out",
2475
- "group-data-selected/switch:bg-primary group-data-hovered/switch:bg-secondary/80",
2476
- "group-data-selected/switch:group-data-hovered/switch:bg-primary/90",
2477
- "group-data-focus-visible/switch:ring-3 group-data-focus-visible/switch:ring-ring/40",
2478
- "group-data-pressed/switch:ring-4 group-data-pressed/switch:ring-primary/10",
2479
- "motion-reduce:transition-none",
2480
- styles.track
2522
+ "relative inline-flex shrink-0 items-center overflow-hidden rounded-full border border-border bg-input shadow-inner",
2523
+ "transition-[background-color,border-color,box-shadow] duration-200 ease-out motion-reduce:transition-none",
2524
+ "group-data-hovered/switch:bg-muted-foreground/25",
2525
+ "group-data-selected/switch:border-primary group-data-selected/switch:bg-primary",
2526
+ "group-data-selected/switch:group-data-hovered/switch:bg-primary/85",
2527
+ "group-data-focus-visible/switch:ring-3 group-data-focus-visible/switch:ring-ring/50",
2528
+ styles.control
2481
2529
  ),
2482
2530
  children: /* @__PURE__ */ jsx42(
2483
2531
  "span",
2484
2532
  {
2533
+ "data-slot": "switch-thumb",
2534
+ style: { transform: state.isSelected ? `translate3d(${styles.offset}, 0, 0)` : "translate3d(0, 0, 0)" },
2485
2535
  className: cn(
2486
- "pointer-events-none block rounded-full bg-background shadow-[0_1px_2px_rgb(0_0_0/0.18)]",
2487
- "transition-[transform,background-color,box-shadow] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]",
2488
- "group-data-selected/switch:bg-primary-foreground group-data-selected/switch:shadow-[0_1px_3px_rgb(0_0_0/0.22)]",
2489
- "group-data-pressed/switch:scale-[0.94] motion-reduce:transition-none",
2490
- styles.travel,
2536
+ "grid shrink-0 place-items-center rounded-full border border-border/60 bg-background text-[0.625rem] text-muted-foreground shadow-sm",
2537
+ "will-change-transform transition-[transform,background-color,color,border-color] duration-[240ms] ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none",
2538
+ "group-data-selected/switch:border-primary-foreground/20",
2539
+ "group-data-selected/switch:bg-primary-foreground group-data-selected/switch:text-primary",
2491
2540
  styles.thumb
2492
- )
2541
+ ),
2542
+ children: state.isSelected ? selectedIcon ?? icon : icon
2493
2543
  }
2494
2544
  )
2495
2545
  }
2496
2546
  ),
2497
- children != null && /* @__PURE__ */ jsx42("span", { className: "select-none font-medium leading-5 text-foreground", children: typeof children === "function" ? children(state) : children })
2547
+ children || description ? /* @__PURE__ */ jsxs20("span", { className: "grid gap-0.5 leading-tight", children: [
2548
+ children ? /* @__PURE__ */ jsx42("span", { "data-slot": "switch-label", className: "font-medium", children: typeof children === "function" ? children(state) : children }) : null,
2549
+ description ? /* @__PURE__ */ jsx42("span", { "data-slot": "switch-description", className: "text-xs font-normal text-muted-foreground", children: description }) : null
2550
+ ] }) : null
2498
2551
  ] })
2499
2552
  }
2500
- ) });
2553
+ );
2501
2554
  }
2502
2555
 
2503
2556
  // src/ui/table/table.tsx
@@ -2609,7 +2662,7 @@ function TabsContent({ className, ...props }) {
2609
2662
  }
2610
2663
 
2611
2664
  // src/ui/toast/toast.tsx
2612
- import { useEffect as useEffect5 } from "react";
2665
+ import { useEffect as useEffect6 } from "react";
2613
2666
  import { sileo, Toaster as SileoToaster } from "sileo";
2614
2667
  import { Fragment as Fragment11, jsx as jsx45, jsxs as jsxs21 } from "react/jsx-runtime";
2615
2668
  function toSileoOptions({ title, description, duration, position, action }) {
@@ -2664,7 +2717,7 @@ function ToastViewport({ position, visiblePosition, className }) {
2664
2717
  return /* @__PURE__ */ jsx45(Toaster, { position });
2665
2718
  }
2666
2719
  function Toast({ id, title, description, variant = "default", action, state = "open", duration = 0, position, onDismiss }) {
2667
- useEffect5(() => {
2720
+ useEffect6(() => {
2668
2721
  if (state !== "open") return;
2669
2722
  const toastId = create({ title, description, variant, action, duration, position });
2670
2723
  return () => {