@apliteni/apliteni-ui 0.63.0 → 0.64.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.63.0",
3
+ "version": "0.64.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
package/react/README.md CHANGED
@@ -69,6 +69,20 @@ for a small inline control: `<Button size="xs" variant="ghost" icon="copy" iconO
69
69
  Its glyph is 13px and its icon-only target is 24×24px; labelled xs buttons use
70
70
  `--text-xs`. The other sizes keep 16px glyphs.
71
71
 
72
+ `Button href="/reports"` renders a native link and forwards an anchor ref. Without
73
+ `href`, it remains a native button. `leading={<VendorMark />}` puts decorative
74
+ caller artwork before the label and takes precedence over `icon`; artwork must
75
+ contain no focusable elements. Use visible children or an explicit accessible name.
76
+ Disabled links leave the tab order; busy links keep focus. Both remove their href
77
+ and block activation until enabled. Anchor attributes such as `target`, `rel`,
78
+ and `download` pass through. The kit does not supply vendor artwork.
79
+
80
+ A `className` you pass is added to the kit's classes rather than swapped for them,
81
+ and the component's own `aria-busy`, `aria-disabled` and `data-btn-*` attributes win
82
+ over anything you spread in, so a busy control cannot be made to read as idle. An
83
+ icon-only control with no children, no `icon` and no label ships nameless on purpose:
84
+ the gap then shows up in an accessibility check instead of reading as satisfied.
85
+
72
86
  `CommandPalette` renders the kit's `commandPalette()` markup, class for class, and imports the
73
87
  kit's ranking rather than repeating it — so a palette a server rendered and the same palette
74
88
  after a keystroke put the same row first. Two differences from the vanilla one follow from
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { InputHTMLAttributes, ReactNode, ButtonHTMLAttributes, HTMLAttributes, RefObject, MouseEvent, ElementType, ComponentPropsWithoutRef, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react';
2
+ import { InputHTMLAttributes, ReactNode, ButtonHTMLAttributes, RefAttributes, ReactElement, AnchorHTMLAttributes, HTMLAttributes, RefObject, MouseEvent, ElementType, ComponentPropsWithoutRef, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react';
3
3
 
4
4
  declare function Icon({ name }: {
5
5
  name: string;
@@ -21,10 +21,12 @@ declare const Switch: react.ForwardRefExoticComponent<Omit<InputHTMLAttributes<H
21
21
  label: string;
22
22
  } & react.RefAttributes<HTMLInputElement>>;
23
23
 
24
- type ButtonProps = {
24
+ type ButtonOptions = {
25
25
  variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
26
26
  size?: 'xs' | 'sm' | 'md' | 'lg';
27
27
  icon?: string;
28
+ /** Decorative caller artwork, before the label; takes precedence over icon. */
29
+ leading?: ReactNode;
28
30
  iconRight?: string;
29
31
  iconOnly?: boolean;
30
32
  block?: boolean;
@@ -33,20 +35,22 @@ type ButtonProps = {
33
35
  /** Message after busy ends; an empty string leaves outcome announcements to the caller. */
34
36
  completionMessage?: string;
35
37
  children?: ReactNode;
36
- } & ButtonHTMLAttributes<HTMLButtonElement>;
37
- declare const Button: react.ForwardRefExoticComponent<{
38
- variant?: "primary" | "secondary" | "ghost" | "danger";
39
- size?: "xs" | "sm" | "md" | "lg";
40
- icon?: string;
41
- iconRight?: string;
42
- iconOnly?: boolean;
43
- block?: boolean;
44
- /** In flight: keeps focus, blocks activation, announces progress, and shows dots. */
45
- busy?: boolean;
46
- /** Message after busy ends; an empty string leaves outcome announcements to the caller. */
47
- completionMessage?: string;
48
- children?: ReactNode;
49
- } & ButtonHTMLAttributes<HTMLButtonElement> & react.RefAttributes<HTMLButtonElement>>;
38
+ };
39
+ type NativeButtonProps = ButtonOptions & ButtonHTMLAttributes<HTMLButtonElement> & {
40
+ href?: never;
41
+ };
42
+ type ButtonLinkProps = ButtonOptions & AnchorHTMLAttributes<HTMLAnchorElement> & {
43
+ href: string;
44
+ disabled?: boolean;
45
+ };
46
+ type ButtonProps = NativeButtonProps | ButtonLinkProps;
47
+ type ButtonElement = HTMLButtonElement | HTMLAnchorElement;
48
+ declare const Button: {
49
+ (props: NativeButtonProps & RefAttributes<HTMLButtonElement>): ReactElement;
50
+ (props: ButtonLinkProps & RefAttributes<HTMLAnchorElement>): ReactElement;
51
+ (props: ButtonProps & RefAttributes<ButtonElement>): ReactElement;
52
+ displayName?: string;
53
+ };
50
54
 
51
55
  declare function Badge({ variant, children }: {
52
56
  variant?: string;
@@ -728,4 +732,4 @@ declare const SidebarNav: react.ForwardRefExoticComponent<Omit<Omit<react.Detail
728
732
  declare const PAGE_SIZES: readonly number[];
729
733
  declare const DEFAULT_PAGE_SIZE: number;
730
734
 
731
- export { AppShell, type AppShellProps, type AppShellSection, BackLink, type BackLinkOwnProps, type BackLinkProps, Badge, BusyRegion, type BusyRegionProps, Button, type ButtonProps, Callout, type CalloutProps, type CalloutVariant, Card, Checkbox, type CheckboxProps, type Column, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, Confirm, type ConfirmProps, DEFAULT_PAGE_SIZE, DataTable, type DataTableProps, DeltaValue, type DeltaValueProps, Denied, type DeniedProps, Drawer, type DrawerProps, DrawerSection, type DrawerSectionProps, Dropdown, type DropdownBadge, type DropdownEntry, type DropdownItem, type DropdownProps, type DropdownRowProps, type DropdownSearch, type DropdownSection, type DropdownSeparator, EmptyState, type EmptyStateProps, type EmptyStateVariant, Field, type FieldControlProps, type FieldProps, FileField, type FileFieldProps, type Filter, FilterBar, type FilterBarProps, Icon, KeyValueList, type KeyValueListProps, type KeyValueRow, Modal, type ModalProps, NumericValue, type NumericValueProps, PAGE_SIZES, Pagination, type PaginationProps, Pill, type PillProps, RowIdentity, type RowIdentityProps, type SegmentOption, Segmented, type SegmentedProps, SelectField, type SelectFieldProps, SidebarNav, type SidebarNavBadge, type SidebarNavItem, type SidebarNavLeaf, type SidebarNavProps, type SidebarNavSection, Skeleton, type SkeletonProps, SkeletonTable, type SkeletonTableProps, Snippet, type SnippetProps, StatBand, type StatBandProps, type StatDelta, type StatFigure, type StatTone, type StatVariant, StatusDot, type StatusDotProps, Switch, type SwitchProps, THEME_INIT_SCRIPT, type TabItem, type TableSort, Tabs, type TabsProps, TextArea, type TextAreaProps, TextField, type TextFieldProps, ThemeToggle, type ThemeToggleProps, Timeline, type TimelineEvent, type TimelineEventKind, type TimelineProps, Toast, type ToastNotice, type ToastProps, Tooltip, type TooltipProps, sortTableRows, useToast };
735
+ export { AppShell, type AppShellProps, type AppShellSection, BackLink, type BackLinkOwnProps, type BackLinkProps, Badge, BusyRegion, type BusyRegionProps, Button, type ButtonLinkProps, type ButtonProps, Callout, type CalloutProps, type CalloutVariant, Card, Checkbox, type CheckboxProps, type Column, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, Confirm, type ConfirmProps, DEFAULT_PAGE_SIZE, DataTable, type DataTableProps, DeltaValue, type DeltaValueProps, Denied, type DeniedProps, Drawer, type DrawerProps, DrawerSection, type DrawerSectionProps, Dropdown, type DropdownBadge, type DropdownEntry, type DropdownItem, type DropdownProps, type DropdownRowProps, type DropdownSearch, type DropdownSection, type DropdownSeparator, EmptyState, type EmptyStateProps, type EmptyStateVariant, Field, type FieldControlProps, type FieldProps, FileField, type FileFieldProps, type Filter, FilterBar, type FilterBarProps, Icon, KeyValueList, type KeyValueListProps, type KeyValueRow, Modal, type ModalProps, type NativeButtonProps, NumericValue, type NumericValueProps, PAGE_SIZES, Pagination, type PaginationProps, Pill, type PillProps, RowIdentity, type RowIdentityProps, type SegmentOption, Segmented, type SegmentedProps, SelectField, type SelectFieldProps, SidebarNav, type SidebarNavBadge, type SidebarNavItem, type SidebarNavLeaf, type SidebarNavProps, type SidebarNavSection, Skeleton, type SkeletonProps, SkeletonTable, type SkeletonTableProps, Snippet, type SnippetProps, StatBand, type StatBandProps, type StatDelta, type StatFigure, type StatTone, type StatVariant, StatusDot, type StatusDotProps, Switch, type SwitchProps, THEME_INIT_SCRIPT, type TabItem, type TableSort, Tabs, type TabsProps, TextArea, type TextAreaProps, TextField, type TextFieldProps, ThemeToggle, type ThemeToggleProps, Timeline, type TimelineEvent, type TimelineEventKind, type TimelineProps, Toast, type ToastNotice, type ToastProps, Tooltip, type TooltipProps, sortTableRows, useToast };
@@ -80,6 +80,7 @@ var Button = forwardRef3(function Button2({
80
80
  variant = "secondary",
81
81
  size = "md",
82
82
  icon: icon6,
83
+ leading,
83
84
  iconRight,
84
85
  iconOnly,
85
86
  block,
@@ -87,7 +88,12 @@ var Button = forwardRef3(function Button2({
87
88
  completionMessage,
88
89
  children,
89
90
  type = "button",
91
+ href,
90
92
  disabled,
93
+ className,
94
+ tabIndex,
95
+ onAuxClick,
96
+ onAuxClickCapture,
91
97
  onClick,
92
98
  onClickCapture,
93
99
  onKeyDown,
@@ -97,7 +103,7 @@ var Button = forwardRef3(function Button2({
97
103
  ...rest
98
104
  }, forwardedRef) {
99
105
  const buttonRef = useRef(null);
100
- useImperativeHandle(forwardedRef, () => buttonRef.current, []);
106
+ useImperativeHandle(forwardedRef, () => buttonRef.current, [href !== void 0]);
101
107
  const labelRef = useRef(null);
102
108
  const announcer = useRef(null);
103
109
  const hasBeenBusy = useRef(false);
@@ -122,35 +128,47 @@ var Button = forwardRef3(function Button2({
122
128
  previous.current = null;
123
129
  }, []);
124
130
  const blockActivation = (event) => {
125
- if (!busy) return false;
131
+ if (!busy && !disabled) return false;
126
132
  event.preventDefault();
127
133
  event.stopPropagation();
128
134
  return true;
129
135
  };
130
- const blockKey = (event) => (event.key === "Enter" || event.key === " ") && blockActivation(event);
136
+ const blockKey = (event) => (event.key === "Enter" || event.key === " " && href === void 0) && blockActivation(event);
131
137
  const cls = cx(
132
138
  "ui-btn",
133
139
  variant && `ui-btn--${variant}`,
134
140
  size !== "md" && `ui-btn--${size}`,
135
141
  block && "ui-btn--block",
136
- iconOnly && "ui-btn--icon"
142
+ iconOnly && "ui-btn--icon",
143
+ className
137
144
  );
138
145
  const labelled = rest["aria-label"] != null || rest["aria-labelledby"] != null;
139
146
  const fallback = typeof children === "string" && children.trim() ? children.trim() : icon6;
140
147
  const named = iconOnly && !labelled && fallback ? { "aria-label": fallback, title: rest.title ?? fallback } : {};
148
+ const Root = href === void 0 ? "button" : "a";
141
149
  return /* @__PURE__ */ jsxs3(
142
- "button",
150
+ Root,
143
151
  {
152
+ ...rest,
144
153
  ref: buttonRef,
145
154
  "data-btn-wired": "",
146
155
  "data-btn-ready": !busy && hasBeenBusy.current ? "" : void 0,
147
- type,
156
+ type: href === void 0 ? type : void 0,
157
+ href: disabled || busy ? void 0 : href,
158
+ role: href !== void 0 ? "link" : rest.role,
159
+ tabIndex: href !== void 0 && disabled ? -1 : href !== void 0 ? tabIndex ?? 0 : tabIndex,
160
+ "data-btn-disabled": disabled ? "" : void 0,
148
161
  className: cls,
149
- disabled,
162
+ disabled: href === void 0 ? disabled : void 0,
150
163
  "aria-disabled": disabled || busy ? true : void 0,
151
164
  "aria-busy": busy ? true : void 0,
152
- ...rest,
153
165
  ...named,
166
+ onAuxClickCapture: (event) => {
167
+ if (!blockActivation(event)) onAuxClickCapture?.(event);
168
+ },
169
+ onAuxClick: (event) => {
170
+ if (!blockActivation(event)) onAuxClick?.(event);
171
+ },
154
172
  onClickCapture: (event) => {
155
173
  if (!blockActivation(event)) onClickCapture?.(event);
156
174
  },
@@ -170,7 +188,7 @@ var Button = forwardRef3(function Button2({
170
188
  if (!blockKey(event)) onKeyUp?.(event);
171
189
  },
172
190
  children: [
173
- icon6 && /* @__PURE__ */ jsx4(Icon, { name: icon6 }),
191
+ leading != null ? /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: leading }) : icon6 && /* @__PURE__ */ jsx4(Icon, { name: icon6 }),
174
192
  !iconOnly && renderedChildren != null && /* @__PURE__ */ jsx4("span", { className: "ui-btn__label-slot", children: /* @__PURE__ */ jsx4("span", { className: "ui-btn__label", ref: labelRef, children: renderedChildren }) }),
175
193
  iconRight && /* @__PURE__ */ jsx4(Icon, { name: iconRight }),
176
194
  busy && /* @__PURE__ */ jsxs3("span", { className: "ui-btn__dots", "aria-hidden": "true", children: [