@nubitio/ui 1.4.0 → 2.1.0

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/README.md CHANGED
@@ -52,7 +52,7 @@ alongside the existing `--surface-*`, `--text-*`, etc. component vocabulary;
52
52
  consumers do not need to rewrite existing components. Source design:
53
53
  `m124loXKRsHFvZcrYkoTbk`, semantic-token frame `11:341`.
54
54
 
55
- - **Primitives** — `Button`, `IconButton`, `Badge`, `Chip`, `Toggle`, `Avatar`, `Skeleton`, `EmptyState`, `StatCard`, `Card`, `CollapsibleSection`
55
+ - **Primitives** — `Button`, `ButtonLink`, `IconButton`, `QuantityStepper`, `Badge`, `Chip`, `Toggle`, `Avatar`, `Skeleton`, `EmptyState`, `StatCard`, `Card`, `CollapsibleSection`
56
56
  - **Overlays** — `AppDialog`, `ConfirmDialog`, `Drawer`, `Popover`, `ContextMenu`, `AppDropdown`
57
57
  - **Form controls** — `TextField`, `TextAreaField`, `SelectField`, `FormField`, `DatePicker`, `DateRangePicker`, `TimePicker`
58
58
  - **Theming** — `ThemeProvider`, `ThemeSwitcher`, `DensityProvider`, `useAccentColor`, `SettingsPanel`
package/dist/index.cjs CHANGED
@@ -185,6 +185,27 @@ const IconButton = (0, react.forwardRef)(function IconButton({ icon, label, vari
185
185
  })
186
186
  });
187
187
  });
188
+ /** A link that looks like a `Button`: use it for navigation, `Button` for actions. */
189
+ const ButtonLink = (0, react.forwardRef)(function ButtonLink({ variant = "secondary", size = "md", fullWidth = false, icon, disabled = false, as, className, children, onClick, ...props }, ref) {
190
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(as ?? "a", {
191
+ ...props,
192
+ ref,
193
+ "aria-disabled": disabled || void 0,
194
+ tabIndex: disabled ? -1 : props.tabIndex,
195
+ onClick: (event) => {
196
+ if (disabled) {
197
+ event.preventDefault();
198
+ return;
199
+ }
200
+ onClick?.(event);
201
+ },
202
+ className: cx$2("nb-button", "nb-button--link", `nb-button--${variant}`, size === "sm" && "nb-button--sm", fullWidth && "nb-button--full", disabled && "nb-button--disabled", className),
203
+ children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
204
+ className: icon,
205
+ "aria-hidden": "true"
206
+ }) : null, children]
207
+ });
208
+ });
188
209
  // packages/ui/UiStrings.tsx
189
210
  const EN_UI_STRINGS = {
190
211
  close: "Close",
@@ -476,6 +497,66 @@ const AppToolbar = ({ title, additionalToolbarContent, showRefreshButton = true,
476
497
  }), children]
477
498
  });
478
499
  };
500
+ // packages/ui/QuantityStepper.tsx
501
+ const decimalsOf = (n) => {
502
+ const [, fraction = ""] = String(n).split(".");
503
+ return fraction.length;
504
+ };
505
+ /** Round away binary float noise (0.1 + 0.2) to the finest decimal place involved. */
506
+ const settle = (value, ...references) => {
507
+ const places = Math.max(...references.map(decimalsOf), decimalsOf(value));
508
+ return Number(value.toFixed(Math.min(places, 6)));
509
+ };
510
+ /**
511
+ * +/- control for a quantity. Clamps to `[min, max]` and lands exactly on `max`
512
+ * when a step would overshoot it, so a 0.5 limit is reachable with `step={1}`.
513
+ */
514
+ function QuantityStepper({ value, onChange, label, min = 0, max, step = 1, disabled = false, unit, format, className }) {
515
+ const clamp = (next) => {
516
+ return settle(Math.max(min, max === void 0 ? next : Math.min(max, next)), step, min, max ?? 0, value);
517
+ };
518
+ const atMin = value <= min;
519
+ const atMax = max !== void 0 && value >= max;
520
+ const shown = format ? format(value) : String(settle(value, step));
521
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
522
+ className: ["nb-quantity-stepper", className].filter(Boolean).join(" "),
523
+ role: "group",
524
+ "aria-label": label,
525
+ children: [
526
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
527
+ type: "button",
528
+ className: "nb-quantity-stepper__button",
529
+ disabled: disabled || atMin,
530
+ "aria-label": `Menos ${label}`,
531
+ onClick: () => onChange(clamp(value - step)),
532
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
533
+ className: "ph ph-minus",
534
+ "aria-hidden": "true"
535
+ })
536
+ }),
537
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("output", {
538
+ className: "nb-quantity-stepper__value",
539
+ "aria-live": "polite",
540
+ "aria-label": label,
541
+ children: [shown, unit ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
542
+ className: "nb-quantity-stepper__unit",
543
+ children: [" ", unit]
544
+ }) : null]
545
+ }),
546
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
547
+ type: "button",
548
+ className: "nb-quantity-stepper__button",
549
+ disabled: disabled || atMax,
550
+ "aria-label": `Más ${label}`,
551
+ onClick: () => onChange(clamp(value + step)),
552
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
553
+ className: "ph ph-plus",
554
+ "aria-hidden": "true"
555
+ })
556
+ })
557
+ ]
558
+ });
559
+ }
479
560
  // packages/ui/layoutUtils.ts
480
561
  function joinClasses(...parts) {
481
562
  return parts.filter(Boolean).join(" ");
@@ -513,12 +594,12 @@ const Card = ({ title, description, variant = "auth", className, children }) =>
513
594
  };
514
595
  // packages/ui/FormControls.tsx
515
596
  const cx$1 = (...values) => values.filter(Boolean).join(" ");
516
- const FormField = ({ label, error, helpText, children, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
597
+ const FormField = ({ label, error, helpText, required, children, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
517
598
  ...props,
518
599
  className: cx$1("nb-form-field", !!error && "nb-form-field--error", className),
519
600
  children: [
520
601
  label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
521
- className: "nb-form-field__label",
602
+ className: cx$1("nb-form-field__label", required && "nb-form-field__label--required"),
522
603
  children: label
523
604
  }),
524
605
  children,
@@ -4015,6 +4096,7 @@ exports.AppToolbar = AppToolbar;
4015
4096
  exports.Avatar = Avatar;
4016
4097
  exports.Badge = Badge;
4017
4098
  exports.Button = Button;
4099
+ exports.ButtonLink = ButtonLink;
4018
4100
  exports.Card = Card;
4019
4101
  exports.Checkbox = Checkbox;
4020
4102
  exports.Chip = Chip;
@@ -4053,6 +4135,7 @@ exports.PageHeader = PageHeader;
4053
4135
  exports.Pagination = Pagination;
4054
4136
  exports.Popover = Popover;
4055
4137
  exports.Progress = Progress;
4138
+ exports.QuantityStepper = QuantityStepper;
4056
4139
  exports.RadioGroup = RadioGroup;
4057
4140
  exports.Row = Row;
4058
4141
  exports.RowActions = RowActions;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import React$1, { ButtonHTMLAttributes, CSSProperties, FieldsetHTMLAttributes, FormHTMLAttributes, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, ProgressHTMLAttributes, ReactElement, ReactNode, RefObject, SelectHTMLAttributes, TextareaHTMLAttributes } from "react";
2
+ import React$1, { ButtonHTMLAttributes, CSSProperties, ComponentPropsWithoutRef, ElementType, FieldsetHTMLAttributes, FormHTMLAttributes, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, ProgressHTMLAttributes, ReactElement, ReactNode, Ref, RefObject, SelectHTMLAttributes, TextareaHTMLAttributes } from "react";
3
3
  import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
4
4
  type AvatarShape = 'circle' | 'square';
5
5
  type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
@@ -93,6 +93,48 @@ interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
93
93
  variant?: 'default' | 'danger';
94
94
  }
95
95
  export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
96
+ interface ButtonLinkOwnProps {
97
+ variant?: ButtonVariant;
98
+ size?: ButtonSize;
99
+ fullWidth?: boolean;
100
+ icon?: string;
101
+ /** Renders a non-interactive, `aria-disabled` link. */
102
+ disabled?: boolean;
103
+ children?: ReactNode;
104
+ }
105
+ type ButtonLinkProps<C extends ElementType = 'a'> = ButtonLinkOwnProps & {
106
+ /**
107
+ * Element or component to render, e.g. a router `Link`. Defaults to `a`. Its own
108
+ * props (`to`, …) are accepted alongside.
109
+ */
110
+ as?: C;
111
+ } & Omit<ComponentPropsWithoutRef<C>, keyof ButtonLinkOwnProps | 'as'>;
112
+ type ButtonLinkComponent = <C extends ElementType = 'a'>(props: ButtonLinkProps<C> & {
113
+ ref?: Ref<Element>;
114
+ }) => ReactElement | null;
115
+ /** A link that looks like a `Button`: use it for navigation, `Button` for actions. */
116
+ export declare const ButtonLink: ButtonLinkComponent;
117
+ interface QuantityStepperProps {
118
+ value: number;
119
+ onChange: (next: number) => void;
120
+ /** Accessible name of the quantity, e.g. the product name. */
121
+ label: string;
122
+ min?: number;
123
+ max?: number;
124
+ /** Amount added or removed per click. Fractions are fine (0.5, 0.25). Default 1. */
125
+ step?: number;
126
+ disabled?: boolean;
127
+ /** Shown next to the value, e.g. "und" or "kg". */
128
+ unit?: ReactNode;
129
+ /** Format the shown value. Defaults to trimming float noise. */
130
+ format?: (value: number) => string;
131
+ className?: string;
132
+ }
133
+ /**
134
+ * +/- control for a quantity. Clamps to `[min, max]` and lands exactly on `max`
135
+ * when a step would overshoot it, so a 0.5 limit is reachable with `step={1}`.
136
+ */
137
+ export declare function QuantityStepper({ value, onChange, label, min, max, step, disabled, unit, format, className }: QuantityStepperProps): import("react").JSX.Element;
96
138
  type CardVariant = 'auth' | 'panel';
97
139
  interface CardProps {
98
140
  title?: string;
@@ -106,9 +148,14 @@ interface FormFieldProps extends LabelHTMLAttributes<HTMLLabelElement> {
106
148
  label?: ReactNode;
107
149
  error?: ReactNode;
108
150
  helpText?: ReactNode;
151
+ /**
152
+ * Marks the label with a required asterisk. Visual only: also set `required`
153
+ * on the control itself so assistive tech and native validation know.
154
+ */
155
+ required?: boolean;
109
156
  children: ReactNode;
110
157
  }
111
- export declare const FormField: ({ label, error, helpText, children, className, ...props }: FormFieldProps) => import("react").JSX.Element;
158
+ export declare const FormField: ({ label, error, helpText, required, children, className, ...props }: FormFieldProps) => import("react").JSX.Element;
112
159
  interface TextFieldProps extends InputHTMLAttributes<HTMLInputElement> {
113
160
  invalid?: boolean;
114
161
  }
@@ -1257,4 +1304,4 @@ interface TreeListProps<T> extends TreeListModelOptions<T> {
1257
1304
  testId?: string;
1258
1305
  }
1259
1306
  export declare function TreeList<T>({ items, columns, getId, getParentId, getChildren, hasChildren, loadChildren, withParent, expandedIds: controlledExpandedIds, defaultExpandedIds, onExpandedIdsChange, selectionMode, selectedIds: controlledSelectedIds, defaultSelectedIds, onSelectedIdsChange, onSelectedItemsChange, selectDescendants, rowActions, onRowActivate, onMove, onEdit, editable, filter: controlledFilter, onFilterChange, filterable, loading, emptyState, error, ariaLabel, className, density, testId }: TreeListProps<T>): React$1.JSX.Element;
1260
- export type { AccentPreset, AlertProps, AlertTone, AppDialogProps, AppDropdownOption, AppDropdownProps, AppDropdownVariant, AppToolbarProps, AvatarProps, AvatarShape, AvatarSize, BadgeProps, BadgeSize, BadgeVariant, ButtonProps, ButtonSize, ButtonVariant, CardProps, CardVariant, CheckboxProps, ChipProps, ClusterProps, CodeProps, ColProps, ColSpan, CollapsibleSectionProps, ComboboxLoader, ComboboxOption, ComboboxPage, ComboboxProps, ConfirmDialogProps, ConfirmRequest, ContextMenuItem, ContextMenuProps, DataTableColumn, DataTableColumnAlign, DataTableProps, DataTableVariant, DatePickerProps, DateRangePickerProps, Density, DensityContextValue, DescriptionListItem, DescriptionListProps, DetailLayoutProps, DrawerProps, DrawerSide, EmptyStateProps, FeatureGateProps, FileDropzoneLabels, FileDropzoneProps, FileDropzoneValue, FilterPanelCategorySection, FilterPanelChipOption, FilterPanelDensity, FilterPanelLayout, FilterPanelProps, FilterPanelStatusSection, FlexAlign, FlexJustify, FormActionsProps, FormFieldProps, FormLayoutProps, FormLayoutVariant, GridCols, GridProps, HubPanelProps, HubPanelVariant, IconButtonProps, KpiMetricDensity, KpiMetricItem, KpiMetricLayout, KpiMetricRowProps, KpiMetricTone, MultiSelectProps, OperationCardAccent, OperationCardGridProps, OperationCardItem, PageHeaderBadge, PageHeaderBreadcrumb, PageHeaderProps, PageProps, PaginationProps, PopoverAlign, PopoverProps, ProgressProps, RadioGroupOption, RadioGroupProps, RowActionsProps, RowProps, ScopeTabOption, ScopeTabsDensity, ScopeTabsProps, SearchableAppDropdownProps, SectionProps, SegmentedControlOption, SegmentedControlProps, SelectFieldProps, SettingsPanelProps, SkeletonProps, SpaceScale, SpinnerProps, StackProps, StatCardProps, TabsItem, TabsProps, TextAreaFieldProps, TextFieldProps, TextProps, TextTone, Theme, ThemeContextValue, ThemeMode, ThemeProviderProps, ThemeSwitcherProps, TimePickerProps, TimelineItemProps, TimelineItemStatus, TimelineItemTone, TimelineOrientation, TimelineProps, TimelineVariant, ToggleProps, TooltipProps, TooltipProviderProps, TreeListColumn, TreeListModelOptions, TreeListMoveEvent, TreeListProps, TreeNode, TreeNodeId, UiStrings, UiStringsProviderProps, UseFloatingPanelOptions, UseFloatingPanelResult };
1307
+ export type { AccentPreset, AlertProps, AlertTone, AppDialogProps, AppDropdownOption, AppDropdownProps, AppDropdownVariant, AppToolbarProps, AvatarProps, AvatarShape, AvatarSize, BadgeProps, BadgeSize, BadgeVariant, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant, CardProps, CardVariant, CheckboxProps, ChipProps, ClusterProps, CodeProps, ColProps, ColSpan, CollapsibleSectionProps, ComboboxLoader, ComboboxOption, ComboboxPage, ComboboxProps, ConfirmDialogProps, ConfirmRequest, ContextMenuItem, ContextMenuProps, DataTableColumn, DataTableColumnAlign, DataTableProps, DataTableVariant, DatePickerProps, DateRangePickerProps, Density, DensityContextValue, DescriptionListItem, DescriptionListProps, DetailLayoutProps, DrawerProps, DrawerSide, EmptyStateProps, FeatureGateProps, FileDropzoneLabels, FileDropzoneProps, FileDropzoneValue, FilterPanelCategorySection, FilterPanelChipOption, FilterPanelDensity, FilterPanelLayout, FilterPanelProps, FilterPanelStatusSection, FlexAlign, FlexJustify, FormActionsProps, FormFieldProps, FormLayoutProps, FormLayoutVariant, GridCols, GridProps, HubPanelProps, HubPanelVariant, IconButtonProps, KpiMetricDensity, KpiMetricItem, KpiMetricLayout, KpiMetricRowProps, KpiMetricTone, MultiSelectProps, OperationCardAccent, OperationCardGridProps, OperationCardItem, PageHeaderBadge, PageHeaderBreadcrumb, PageHeaderProps, PageProps, PaginationProps, PopoverAlign, PopoverProps, ProgressProps, QuantityStepperProps, RadioGroupOption, RadioGroupProps, RowActionsProps, RowProps, ScopeTabOption, ScopeTabsDensity, ScopeTabsProps, SearchableAppDropdownProps, SectionProps, SegmentedControlOption, SegmentedControlProps, SelectFieldProps, SettingsPanelProps, SkeletonProps, SpaceScale, SpinnerProps, StackProps, StatCardProps, TabsItem, TabsProps, TextAreaFieldProps, TextFieldProps, TextProps, TextTone, Theme, ThemeContextValue, ThemeMode, ThemeProviderProps, ThemeSwitcherProps, TimePickerProps, TimelineItemProps, TimelineItemStatus, TimelineItemTone, TimelineOrientation, TimelineProps, TimelineVariant, ToggleProps, TooltipProps, TooltipProviderProps, TreeListColumn, TreeListModelOptions, TreeListMoveEvent, TreeListProps, TreeNode, TreeNodeId, UiStrings, UiStringsProviderProps, UseFloatingPanelOptions, UseFloatingPanelResult };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import React$1, { ButtonHTMLAttributes, CSSProperties, FieldsetHTMLAttributes, FormHTMLAttributes, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, ProgressHTMLAttributes, ReactElement, ReactNode, RefObject, SelectHTMLAttributes, TextareaHTMLAttributes } from "react";
2
+ import React$1, { ButtonHTMLAttributes, CSSProperties, ComponentPropsWithoutRef, ElementType, FieldsetHTMLAttributes, FormHTMLAttributes, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, ProgressHTMLAttributes, ReactElement, ReactNode, Ref, RefObject, SelectHTMLAttributes, TextareaHTMLAttributes } from "react";
3
3
  import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
4
4
  type AvatarShape = 'circle' | 'square';
5
5
  type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
@@ -93,6 +93,48 @@ interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
93
93
  variant?: 'default' | 'danger';
94
94
  }
95
95
  export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
96
+ interface ButtonLinkOwnProps {
97
+ variant?: ButtonVariant;
98
+ size?: ButtonSize;
99
+ fullWidth?: boolean;
100
+ icon?: string;
101
+ /** Renders a non-interactive, `aria-disabled` link. */
102
+ disabled?: boolean;
103
+ children?: ReactNode;
104
+ }
105
+ type ButtonLinkProps<C extends ElementType = 'a'> = ButtonLinkOwnProps & {
106
+ /**
107
+ * Element or component to render, e.g. a router `Link`. Defaults to `a`. Its own
108
+ * props (`to`, …) are accepted alongside.
109
+ */
110
+ as?: C;
111
+ } & Omit<ComponentPropsWithoutRef<C>, keyof ButtonLinkOwnProps | 'as'>;
112
+ type ButtonLinkComponent = <C extends ElementType = 'a'>(props: ButtonLinkProps<C> & {
113
+ ref?: Ref<Element>;
114
+ }) => ReactElement | null;
115
+ /** A link that looks like a `Button`: use it for navigation, `Button` for actions. */
116
+ export declare const ButtonLink: ButtonLinkComponent;
117
+ interface QuantityStepperProps {
118
+ value: number;
119
+ onChange: (next: number) => void;
120
+ /** Accessible name of the quantity, e.g. the product name. */
121
+ label: string;
122
+ min?: number;
123
+ max?: number;
124
+ /** Amount added or removed per click. Fractions are fine (0.5, 0.25). Default 1. */
125
+ step?: number;
126
+ disabled?: boolean;
127
+ /** Shown next to the value, e.g. "und" or "kg". */
128
+ unit?: ReactNode;
129
+ /** Format the shown value. Defaults to trimming float noise. */
130
+ format?: (value: number) => string;
131
+ className?: string;
132
+ }
133
+ /**
134
+ * +/- control for a quantity. Clamps to `[min, max]` and lands exactly on `max`
135
+ * when a step would overshoot it, so a 0.5 limit is reachable with `step={1}`.
136
+ */
137
+ export declare function QuantityStepper({ value, onChange, label, min, max, step, disabled, unit, format, className }: QuantityStepperProps): import("react").JSX.Element;
96
138
  type CardVariant = 'auth' | 'panel';
97
139
  interface CardProps {
98
140
  title?: string;
@@ -106,9 +148,14 @@ interface FormFieldProps extends LabelHTMLAttributes<HTMLLabelElement> {
106
148
  label?: ReactNode;
107
149
  error?: ReactNode;
108
150
  helpText?: ReactNode;
151
+ /**
152
+ * Marks the label with a required asterisk. Visual only: also set `required`
153
+ * on the control itself so assistive tech and native validation know.
154
+ */
155
+ required?: boolean;
109
156
  children: ReactNode;
110
157
  }
111
- export declare const FormField: ({ label, error, helpText, children, className, ...props }: FormFieldProps) => import("react").JSX.Element;
158
+ export declare const FormField: ({ label, error, helpText, required, children, className, ...props }: FormFieldProps) => import("react").JSX.Element;
112
159
  interface TextFieldProps extends InputHTMLAttributes<HTMLInputElement> {
113
160
  invalid?: boolean;
114
161
  }
@@ -1257,4 +1304,4 @@ interface TreeListProps<T> extends TreeListModelOptions<T> {
1257
1304
  testId?: string;
1258
1305
  }
1259
1306
  export declare function TreeList<T>({ items, columns, getId, getParentId, getChildren, hasChildren, loadChildren, withParent, expandedIds: controlledExpandedIds, defaultExpandedIds, onExpandedIdsChange, selectionMode, selectedIds: controlledSelectedIds, defaultSelectedIds, onSelectedIdsChange, onSelectedItemsChange, selectDescendants, rowActions, onRowActivate, onMove, onEdit, editable, filter: controlledFilter, onFilterChange, filterable, loading, emptyState, error, ariaLabel, className, density, testId }: TreeListProps<T>): React$1.JSX.Element;
1260
- export type { AccentPreset, AlertProps, AlertTone, AppDialogProps, AppDropdownOption, AppDropdownProps, AppDropdownVariant, AppToolbarProps, AvatarProps, AvatarShape, AvatarSize, BadgeProps, BadgeSize, BadgeVariant, ButtonProps, ButtonSize, ButtonVariant, CardProps, CardVariant, CheckboxProps, ChipProps, ClusterProps, CodeProps, ColProps, ColSpan, CollapsibleSectionProps, ComboboxLoader, ComboboxOption, ComboboxPage, ComboboxProps, ConfirmDialogProps, ConfirmRequest, ContextMenuItem, ContextMenuProps, DataTableColumn, DataTableColumnAlign, DataTableProps, DataTableVariant, DatePickerProps, DateRangePickerProps, Density, DensityContextValue, DescriptionListItem, DescriptionListProps, DetailLayoutProps, DrawerProps, DrawerSide, EmptyStateProps, FeatureGateProps, FileDropzoneLabels, FileDropzoneProps, FileDropzoneValue, FilterPanelCategorySection, FilterPanelChipOption, FilterPanelDensity, FilterPanelLayout, FilterPanelProps, FilterPanelStatusSection, FlexAlign, FlexJustify, FormActionsProps, FormFieldProps, FormLayoutProps, FormLayoutVariant, GridCols, GridProps, HubPanelProps, HubPanelVariant, IconButtonProps, KpiMetricDensity, KpiMetricItem, KpiMetricLayout, KpiMetricRowProps, KpiMetricTone, MultiSelectProps, OperationCardAccent, OperationCardGridProps, OperationCardItem, PageHeaderBadge, PageHeaderBreadcrumb, PageHeaderProps, PageProps, PaginationProps, PopoverAlign, PopoverProps, ProgressProps, RadioGroupOption, RadioGroupProps, RowActionsProps, RowProps, ScopeTabOption, ScopeTabsDensity, ScopeTabsProps, SearchableAppDropdownProps, SectionProps, SegmentedControlOption, SegmentedControlProps, SelectFieldProps, SettingsPanelProps, SkeletonProps, SpaceScale, SpinnerProps, StackProps, StatCardProps, TabsItem, TabsProps, TextAreaFieldProps, TextFieldProps, TextProps, TextTone, Theme, ThemeContextValue, ThemeMode, ThemeProviderProps, ThemeSwitcherProps, TimePickerProps, TimelineItemProps, TimelineItemStatus, TimelineItemTone, TimelineOrientation, TimelineProps, TimelineVariant, ToggleProps, TooltipProps, TooltipProviderProps, TreeListColumn, TreeListModelOptions, TreeListMoveEvent, TreeListProps, TreeNode, TreeNodeId, UiStrings, UiStringsProviderProps, UseFloatingPanelOptions, UseFloatingPanelResult };
1307
+ export type { AccentPreset, AlertProps, AlertTone, AppDialogProps, AppDropdownOption, AppDropdownProps, AppDropdownVariant, AppToolbarProps, AvatarProps, AvatarShape, AvatarSize, BadgeProps, BadgeSize, BadgeVariant, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant, CardProps, CardVariant, CheckboxProps, ChipProps, ClusterProps, CodeProps, ColProps, ColSpan, CollapsibleSectionProps, ComboboxLoader, ComboboxOption, ComboboxPage, ComboboxProps, ConfirmDialogProps, ConfirmRequest, ContextMenuItem, ContextMenuProps, DataTableColumn, DataTableColumnAlign, DataTableProps, DataTableVariant, DatePickerProps, DateRangePickerProps, Density, DensityContextValue, DescriptionListItem, DescriptionListProps, DetailLayoutProps, DrawerProps, DrawerSide, EmptyStateProps, FeatureGateProps, FileDropzoneLabels, FileDropzoneProps, FileDropzoneValue, FilterPanelCategorySection, FilterPanelChipOption, FilterPanelDensity, FilterPanelLayout, FilterPanelProps, FilterPanelStatusSection, FlexAlign, FlexJustify, FormActionsProps, FormFieldProps, FormLayoutProps, FormLayoutVariant, GridCols, GridProps, HubPanelProps, HubPanelVariant, IconButtonProps, KpiMetricDensity, KpiMetricItem, KpiMetricLayout, KpiMetricRowProps, KpiMetricTone, MultiSelectProps, OperationCardAccent, OperationCardGridProps, OperationCardItem, PageHeaderBadge, PageHeaderBreadcrumb, PageHeaderProps, PageProps, PaginationProps, PopoverAlign, PopoverProps, ProgressProps, QuantityStepperProps, RadioGroupOption, RadioGroupProps, RowActionsProps, RowProps, ScopeTabOption, ScopeTabsDensity, ScopeTabsProps, SearchableAppDropdownProps, SectionProps, SegmentedControlOption, SegmentedControlProps, SelectFieldProps, SettingsPanelProps, SkeletonProps, SpaceScale, SpinnerProps, StackProps, StatCardProps, TabsItem, TabsProps, TextAreaFieldProps, TextFieldProps, TextProps, TextTone, Theme, ThemeContextValue, ThemeMode, ThemeProviderProps, ThemeSwitcherProps, TimePickerProps, TimelineItemProps, TimelineItemStatus, TimelineItemTone, TimelineOrientation, TimelineProps, TimelineVariant, ToggleProps, TooltipProps, TooltipProviderProps, TreeListColumn, TreeListModelOptions, TreeListMoveEvent, TreeListProps, TreeNode, TreeNodeId, UiStrings, UiStringsProviderProps, UseFloatingPanelOptions, UseFloatingPanelResult };
package/dist/index.mjs CHANGED
@@ -162,6 +162,27 @@ const IconButton = forwardRef(function IconButton({ icon, label, variant = "defa
162
162
  })
163
163
  });
164
164
  });
165
+ /** A link that looks like a `Button`: use it for navigation, `Button` for actions. */
166
+ const ButtonLink = forwardRef(function ButtonLink({ variant = "secondary", size = "md", fullWidth = false, icon, disabled = false, as, className, children, onClick, ...props }, ref) {
167
+ return /* @__PURE__ */ jsxs(as ?? "a", {
168
+ ...props,
169
+ ref,
170
+ "aria-disabled": disabled || void 0,
171
+ tabIndex: disabled ? -1 : props.tabIndex,
172
+ onClick: (event) => {
173
+ if (disabled) {
174
+ event.preventDefault();
175
+ return;
176
+ }
177
+ onClick?.(event);
178
+ },
179
+ className: cx$2("nb-button", "nb-button--link", `nb-button--${variant}`, size === "sm" && "nb-button--sm", fullWidth && "nb-button--full", disabled && "nb-button--disabled", className),
180
+ children: [icon ? /* @__PURE__ */ jsx("i", {
181
+ className: icon,
182
+ "aria-hidden": "true"
183
+ }) : null, children]
184
+ });
185
+ });
165
186
  // packages/ui/UiStrings.tsx
166
187
  const EN_UI_STRINGS = {
167
188
  close: "Close",
@@ -453,6 +474,66 @@ const AppToolbar = ({ title, additionalToolbarContent, showRefreshButton = true,
453
474
  }), children]
454
475
  });
455
476
  };
477
+ // packages/ui/QuantityStepper.tsx
478
+ const decimalsOf = (n) => {
479
+ const [, fraction = ""] = String(n).split(".");
480
+ return fraction.length;
481
+ };
482
+ /** Round away binary float noise (0.1 + 0.2) to the finest decimal place involved. */
483
+ const settle = (value, ...references) => {
484
+ const places = Math.max(...references.map(decimalsOf), decimalsOf(value));
485
+ return Number(value.toFixed(Math.min(places, 6)));
486
+ };
487
+ /**
488
+ * +/- control for a quantity. Clamps to `[min, max]` and lands exactly on `max`
489
+ * when a step would overshoot it, so a 0.5 limit is reachable with `step={1}`.
490
+ */
491
+ function QuantityStepper({ value, onChange, label, min = 0, max, step = 1, disabled = false, unit, format, className }) {
492
+ const clamp = (next) => {
493
+ return settle(Math.max(min, max === void 0 ? next : Math.min(max, next)), step, min, max ?? 0, value);
494
+ };
495
+ const atMin = value <= min;
496
+ const atMax = max !== void 0 && value >= max;
497
+ const shown = format ? format(value) : String(settle(value, step));
498
+ return /* @__PURE__ */ jsxs("div", {
499
+ className: ["nb-quantity-stepper", className].filter(Boolean).join(" "),
500
+ role: "group",
501
+ "aria-label": label,
502
+ children: [
503
+ /* @__PURE__ */ jsx("button", {
504
+ type: "button",
505
+ className: "nb-quantity-stepper__button",
506
+ disabled: disabled || atMin,
507
+ "aria-label": `Menos ${label}`,
508
+ onClick: () => onChange(clamp(value - step)),
509
+ children: /* @__PURE__ */ jsx("i", {
510
+ className: "ph ph-minus",
511
+ "aria-hidden": "true"
512
+ })
513
+ }),
514
+ /* @__PURE__ */ jsxs("output", {
515
+ className: "nb-quantity-stepper__value",
516
+ "aria-live": "polite",
517
+ "aria-label": label,
518
+ children: [shown, unit ? /* @__PURE__ */ jsxs("span", {
519
+ className: "nb-quantity-stepper__unit",
520
+ children: [" ", unit]
521
+ }) : null]
522
+ }),
523
+ /* @__PURE__ */ jsx("button", {
524
+ type: "button",
525
+ className: "nb-quantity-stepper__button",
526
+ disabled: disabled || atMax,
527
+ "aria-label": `Más ${label}`,
528
+ onClick: () => onChange(clamp(value + step)),
529
+ children: /* @__PURE__ */ jsx("i", {
530
+ className: "ph ph-plus",
531
+ "aria-hidden": "true"
532
+ })
533
+ })
534
+ ]
535
+ });
536
+ }
456
537
  // packages/ui/layoutUtils.ts
457
538
  function joinClasses(...parts) {
458
539
  return parts.filter(Boolean).join(" ");
@@ -490,12 +571,12 @@ const Card = ({ title, description, variant = "auth", className, children }) =>
490
571
  };
491
572
  // packages/ui/FormControls.tsx
492
573
  const cx$1 = (...values) => values.filter(Boolean).join(" ");
493
- const FormField = ({ label, error, helpText, children, className, ...props }) => /* @__PURE__ */ jsxs("label", {
574
+ const FormField = ({ label, error, helpText, required, children, className, ...props }) => /* @__PURE__ */ jsxs("label", {
494
575
  ...props,
495
576
  className: cx$1("nb-form-field", !!error && "nb-form-field--error", className),
496
577
  children: [
497
578
  label && /* @__PURE__ */ jsx("span", {
498
- className: "nb-form-field__label",
579
+ className: cx$1("nb-form-field__label", required && "nb-form-field__label--required"),
499
580
  children: label
500
581
  }),
501
582
  children,
@@ -3984,4 +4065,4 @@ function TreeList({ items, columns, getId, getParentId, getChildren, hasChildren
3984
4065
  ]
3985
4066
  });
3986
4067
  }
3987
- export { ACCENT_PRESETS, Alert, AppDialog, AppDropdown, AppToolbar, Avatar, Badge, Button, Card, Checkbox, Chip, Cluster, Code, Col, CollapsibleSection, Combobox, ConfirmDialog, ContextMenu, DataTable, DatePicker, DateRangePicker, DensityContext, DensityProvider, DescriptionList, DetailLayout, Drawer, EN_UI_STRINGS, ES_UI_STRINGS, EmptyState, FeatureGate, FileDropzone, FilterPanel, FormActions, FormField, FormLayout, Grid, HubPanel, IconButton, KpiMetricRow, MultiSelect, OperationCardGrid, Page, PageHeader, Pagination, Popover, Progress, RadioGroup, Row, RowActions, ScopeTabs, SearchableAppDropdown, Section, SegmentedControl, SelectField, SettingsPanel, Skeleton, Spinner, Stack, StatCard, Tabs, Text, TextAreaField, TextField, ThemeContext, ThemeProvider, ThemeSwitcher, TimePicker, Timeline, TimelineItem, Toggle, Tooltip, TooltipProvider, TreeList, UiStringsProvider, buildTreeListModel, flattenVisibleTree, getAvatarHue, getAvatarInitials, getDescendantIds, useAccentColor, useConfirm, useDensity, useFloatingPanel, useOverlayContainer, useTheme, useUiStrings };
4068
+ export { ACCENT_PRESETS, Alert, AppDialog, AppDropdown, AppToolbar, Avatar, Badge, Button, ButtonLink, Card, Checkbox, Chip, Cluster, Code, Col, CollapsibleSection, Combobox, ConfirmDialog, ContextMenu, DataTable, DatePicker, DateRangePicker, DensityContext, DensityProvider, DescriptionList, DetailLayout, Drawer, EN_UI_STRINGS, ES_UI_STRINGS, EmptyState, FeatureGate, FileDropzone, FilterPanel, FormActions, FormField, FormLayout, Grid, HubPanel, IconButton, KpiMetricRow, MultiSelect, OperationCardGrid, Page, PageHeader, Pagination, Popover, Progress, QuantityStepper, RadioGroup, Row, RowActions, ScopeTabs, SearchableAppDropdown, Section, SegmentedControl, SelectField, SettingsPanel, Skeleton, Spinner, Stack, StatCard, Tabs, Text, TextAreaField, TextField, ThemeContext, ThemeProvider, ThemeSwitcher, TimePicker, Timeline, TimelineItem, Toggle, Tooltip, TooltipProvider, TreeList, UiStringsProvider, buildTreeListModel, flattenVisibleTree, getAvatarHue, getAvatarInitials, getDescendantIds, useAccentColor, useConfirm, useDensity, useFloatingPanel, useOverlayContainer, useTheme, useUiStrings };
package/dist/style.css CHANGED
@@ -566,6 +566,14 @@ samp {
566
566
  transform: rotate(360deg);
567
567
  }
568
568
  }
569
+ .nb-button--link {
570
+ text-decoration: none;
571
+ }
572
+ .nb-button--link.nb-button--disabled {
573
+ cursor: default;
574
+ opacity: 0.6;
575
+ pointer-events: none;
576
+ }
569
577
  @keyframes dialog-enter {
570
578
  from {
571
579
  opacity: 0;
@@ -773,6 +781,48 @@ html[data-density=compact] .nb-dialog__footer {
773
781
  letter-spacing: -0.015em;
774
782
  line-height: var(--line-height-tight);
775
783
  }
784
+ .nb-quantity-stepper {
785
+ align-items: center;
786
+ display: inline-flex;
787
+ gap: var(--space-1);
788
+ }
789
+
790
+ .nb-quantity-stepper__button {
791
+ align-items: center;
792
+ background: var(--surface-1);
793
+ border: 1px solid var(--border-color);
794
+ border-radius: var(--radius-md);
795
+ color: var(--text-primary);
796
+ cursor: pointer;
797
+ display: inline-flex;
798
+ height: var(--control-height);
799
+ justify-content: center;
800
+ padding: 0;
801
+ width: var(--control-height);
802
+ }
803
+ .nb-quantity-stepper__button:focus-visible {
804
+ box-shadow: 0 0 0 3px var(--focus-ring-color);
805
+ outline: none;
806
+ }
807
+ .nb-quantity-stepper__button:not(:disabled):hover {
808
+ border-color: var(--accent-color);
809
+ color: var(--accent-color);
810
+ }
811
+ .nb-quantity-stepper__button:disabled {
812
+ cursor: default;
813
+ opacity: 0.5;
814
+ }
815
+
816
+ .nb-quantity-stepper__value {
817
+ color: var(--text-primary);
818
+ font-variant-numeric: tabular-nums;
819
+ min-width: 3ch;
820
+ text-align: center;
821
+ }
822
+
823
+ .nb-quantity-stepper__unit {
824
+ color: var(--text-muted);
825
+ }
776
826
  .nb-card {
777
827
  display: flex;
778
828
  height: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubitio/ui",
3
- "version": "1.4.0",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "description": "Visual primitives and theme system for the Nubit admin stack (dialogs, cards, toolbar, light/dark theme).",
6
6
  "license": "MIT",