@antadesign/anta 0.3.34 → 0.3.35

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 (184) hide show
  1. package/LICENSE.md +14 -1
  2. package/README.md +9 -0
  3. package/dist/anta_helpers.d.ts +46 -30
  4. package/dist/anta_helpers.js +66 -25
  5. package/dist/bundle.css +1 -1
  6. package/dist/bundle.js +2 -1333
  7. package/dist/components/Banner.d.ts +25 -40
  8. package/dist/components/Banner.js +15 -17
  9. package/dist/components/Button.js +1 -0
  10. package/dist/components/ButtonCopy.js +3 -2
  11. package/dist/components/Calendar.js +13 -13
  12. package/dist/components/Card.d.ts +9 -17
  13. package/dist/components/Card.js +50 -46
  14. package/dist/components/Dialog.d.ts +1 -0
  15. package/dist/components/Dialog.js +16 -10
  16. package/dist/components/Expander.d.ts +6 -21
  17. package/dist/components/Expander.js +24 -23
  18. package/dist/components/Icon.d.ts +8 -14
  19. package/dist/components/Input.d.ts +77 -96
  20. package/dist/components/Input.js +23 -27
  21. package/dist/components/InputAutocomplete.d.ts +29 -10
  22. package/dist/components/InputAutocomplete.js +25 -8
  23. package/dist/components/InputDate.js +2 -2
  24. package/dist/components/InputTime.d.ts +10 -4
  25. package/dist/components/InputTime.js +20 -16
  26. package/dist/components/Loader.d.ts +2 -2
  27. package/dist/components/Menu.d.ts +5 -4
  28. package/dist/components/Menu.js +13 -8
  29. package/dist/components/MenuItem.js +1 -14
  30. package/dist/components/MenuItemCopy.js +2 -2
  31. package/dist/components/Panel.d.ts +3 -1
  32. package/dist/components/Panel.js +17 -11
  33. package/dist/components/Progress.d.ts +21 -23
  34. package/dist/components/Progress.js +13 -9
  35. package/dist/components/RadioGroup.js +6 -8
  36. package/dist/components/{select-parts.css → Select.css} +1 -1
  37. package/dist/components/Select.d.ts +53 -35
  38. package/dist/components/Select.js +53 -97
  39. package/dist/components/SelectFaceted.d.ts +7 -3
  40. package/dist/components/SelectFaceted.js +21 -9
  41. package/dist/components/Slider.d.ts +28 -11
  42. package/dist/components/Slider.js +20 -20
  43. package/dist/components/Steps.css +1 -1
  44. package/dist/components/Steps.js +1 -11
  45. package/dist/components/Tabs.d.ts +17 -20
  46. package/dist/components/Tabs.js +5 -8
  47. package/dist/components/Text.d.ts +55 -36
  48. package/dist/components/Text.js +35 -22
  49. package/dist/components/Title.d.ts +16 -26
  50. package/dist/components/Title.js +2 -1
  51. package/dist/components/Toaster.js +9 -2
  52. package/dist/components/Tooltip.d.ts +10 -15
  53. package/dist/components/copy-props.d.ts +14 -3
  54. package/dist/components/copy-props.js +14 -3
  55. package/dist/components/select-tree.d.ts +24 -0
  56. package/dist/components/select-tree.js +35 -0
  57. package/dist/element-base.d.ts +10 -0
  58. package/dist/element-base.js +15 -0
  59. package/dist/elements/a-banner.css +1 -1
  60. package/dist/elements/a-banner.d.ts +4 -1
  61. package/dist/elements/a-banner.js +22 -112
  62. package/dist/elements/a-button.d.ts +2 -1
  63. package/dist/elements/a-button.js +18 -1
  64. package/dist/elements/a-calendar.d.ts +14 -13
  65. package/dist/elements/a-calendar.js +29 -24
  66. package/dist/elements/a-card.css +1 -1
  67. package/dist/elements/a-card.d.ts +0 -9
  68. package/dist/elements/a-card.js +0 -184
  69. package/dist/elements/a-checkbox.css +1 -1
  70. package/dist/elements/a-copy.css +1 -1
  71. package/dist/elements/a-copy.d.ts +1 -5
  72. package/dist/elements/a-copy.js +129 -108
  73. package/dist/elements/a-dialog.css +1 -1
  74. package/dist/elements/a-dialog.d.ts +1 -1
  75. package/dist/elements/a-dialog.js +66 -194
  76. package/dist/elements/a-expander.css +1 -1
  77. package/dist/elements/a-expander.d.ts +4 -30
  78. package/dist/elements/a-expander.js +85 -344
  79. package/dist/elements/a-icon.d.ts +5 -23
  80. package/dist/elements/a-icon.js +1 -2
  81. package/dist/elements/a-input-time.css +1 -1
  82. package/dist/elements/a-input-time.d.ts +2 -1
  83. package/dist/elements/a-input-time.js +101 -168
  84. package/dist/elements/a-input.css +1 -1
  85. package/dist/elements/a-input.d.ts +10 -8
  86. package/dist/elements/a-input.js +155 -230
  87. package/dist/elements/a-loader.d.ts +5 -8
  88. package/dist/elements/a-loader.js +1 -2
  89. package/dist/elements/a-menu-item.css +1 -1
  90. package/dist/elements/a-menu-item.d.ts +5 -3
  91. package/dist/elements/a-menu-item.js +5 -1
  92. package/dist/elements/a-menu.css +1 -1
  93. package/dist/elements/a-menu.d.ts +5 -7
  94. package/dist/elements/a-menu.js +383 -299
  95. package/dist/elements/a-panel.css +1 -1
  96. package/dist/elements/a-panel.js +19 -37
  97. package/dist/elements/a-progress.css +1 -1
  98. package/dist/elements/a-progress.d.ts +0 -22
  99. package/dist/elements/a-progress.js +0 -100
  100. package/dist/elements/a-radio-group.d.ts +1 -1
  101. package/dist/elements/a-radio-group.js +6 -4
  102. package/dist/elements/a-select-faceted.d.ts +1 -1
  103. package/dist/elements/a-select-faceted.js +1 -1
  104. package/dist/elements/a-select.d.ts +1 -1
  105. package/dist/elements/a-select.js +1 -1
  106. package/dist/elements/a-slider.css +1 -1
  107. package/dist/elements/a-slider.d.ts +11 -3
  108. package/dist/elements/a-slider.js +244 -242
  109. package/dist/elements/a-switch.css +1 -1
  110. package/dist/elements/a-tab.css +1 -1
  111. package/dist/elements/a-tabs.css +1 -1
  112. package/dist/elements/a-tabs.d.ts +1 -1
  113. package/dist/elements/a-tabs.js +6 -4
  114. package/dist/elements/a-tag.css +1 -1
  115. package/dist/elements/a-text.css +1 -1
  116. package/dist/elements/a-text.d.ts +6 -43
  117. package/dist/elements/a-text.js +110 -193
  118. package/dist/elements/a-title.css +1 -1
  119. package/dist/elements/a-toast.css +1 -1
  120. package/dist/elements/a-toast.d.ts +10 -45
  121. package/dist/elements/a-toast.js +80 -66
  122. package/dist/elements/a-toaster.css +1 -1
  123. package/dist/elements/a-toaster.js +9 -44
  124. package/dist/elements/a-tooltip.css +1 -1
  125. package/dist/elements/a-tooltip.d.ts +1 -1
  126. package/dist/elements/a-tooltip.js +142 -136
  127. package/dist/elements/copy-behavior.d.ts +1 -1
  128. package/dist/elements/copy-behavior.js +21 -21
  129. package/dist/elements/index.d.ts +3 -3
  130. package/dist/elements/index.js +3 -7
  131. package/dist/elements/input-focus-modality.d.ts +15 -0
  132. package/dist/elements/input-focus-modality.js +44 -0
  133. package/dist/elements/input-trailing-actions.d.ts +5 -0
  134. package/dist/elements/input-trailing-actions.js +38 -0
  135. package/dist/elements/shadow-aria.d.ts +2 -0
  136. package/dist/elements/shadow-aria.js +2 -1
  137. package/dist/elements/value-input.d.ts +3 -0
  138. package/dist/elements/value-input.js +12 -0
  139. package/dist/general_types.d.ts +103 -96
  140. package/dist/index.d.ts +1 -1
  141. package/dist/input-events.d.ts +4 -0
  142. package/dist/input-events.js +15 -0
  143. package/dist/jsx-runtime.d.ts +70 -23
  144. package/dist/jsx-runtime.js +26 -19
  145. package/dist/native-event-props.d.ts +2 -0
  146. package/dist/native-event-props.js +10 -0
  147. package/dist/reset.css +1 -1
  148. package/dist/theme-antithesis.css +10 -1
  149. package/dist/theme-antune.css +1 -1
  150. package/docs/accessibility.md +17 -3
  151. package/docs/changelog.md +348 -2
  152. package/docs/comparison.md +2 -2
  153. package/docs/components/avatar.md +5 -0
  154. package/docs/components/banner.md +117 -187
  155. package/docs/components/button.md +22 -0
  156. package/docs/components/card.md +74 -28
  157. package/docs/components/checkbox.md +9 -10
  158. package/docs/components/dialog.md +83 -32
  159. package/docs/components/expander.md +198 -435
  160. package/docs/components/icon.md +11 -17
  161. package/docs/components/input-autocomplete.md +152 -52
  162. package/docs/components/input-date.md +175 -148
  163. package/docs/components/input-time.md +81 -38
  164. package/docs/components/input.md +343 -349
  165. package/docs/components/loader.md +2 -1
  166. package/docs/components/menu.md +35 -6
  167. package/docs/components/panel.md +18 -0
  168. package/docs/components/progress.md +83 -49
  169. package/docs/components/radio.md +39 -43
  170. package/docs/components/select-faceted.md +54 -7
  171. package/docs/components/select.md +390 -386
  172. package/docs/components/slider.md +136 -19
  173. package/docs/components/steps.md +2 -1
  174. package/docs/components/switch.md +8 -9
  175. package/docs/components/tabs.md +110 -104
  176. package/docs/components/text.md +110 -86
  177. package/docs/components/title.md +47 -33
  178. package/docs/components/toaster.md +242 -84
  179. package/docs/components/tooltip.md +204 -113
  180. package/docs/install-config.md +183 -26
  181. package/docs/packages/plot.md +170 -148
  182. package/docs/theming.md +7 -0
  183. package/package.json +41 -3
  184. package/theme-antithesis-license.md +66 -0
@@ -56,6 +56,9 @@ export interface InputTimeProps extends BaseProps, DOMEventHandlers {
56
56
  name?: string;
57
57
  /** Disable the field. */
58
58
  disabled?: boolean;
59
+ /** Keep the time selectable and focusable while preventing edits. Blur emits
60
+ * `change` only if an edit was pending when the field became read-only. */
61
+ readOnly?: boolean;
59
62
  /** Mark the field required (drives native validity). */
60
63
  required?: boolean;
61
64
  /** Leading icon at the start of the field — the clock affordance. Pass another
@@ -74,8 +77,11 @@ export interface InputTimeProps extends BaseProps, DOMEventHandlers {
74
77
  autoFocus?: boolean;
75
78
  /** Fires on every edit (`input`), with the native event + an `attrs` snapshot
76
79
  * (`value`, `name`, `empty`, `valid`, `validationMessage`). Also fires on
77
- * `change` (blur) and on clear. */
80
+ * `change` (blur) and on clear. Read-only blur is silent unless committing
81
+ * an edit made before the field became read-only. */
78
82
  onValueChange?: (event: any, attrs: InputTimeChangeAttrs) => void;
83
+ /** Fires before clearing. Call `preventDefault()` synchronously to keep the value. */
84
+ onClearClick?: (e: CustomEvent) => void;
79
85
  /** Fires after the built-in clear button has cleared the field. */
80
86
  onClearInput?: (e: CustomEvent) => void;
81
87
  /** Fires when the field gains focus. */
@@ -97,12 +103,12 @@ export interface InputTimeProps extends BaseProps, DOMEventHandlers {
97
103
  * (`value` + `onValueChange`) or uncontrolled (`defaultValue`), submitting under
98
104
  * `name`.
99
105
  *
100
- * Requires `@antadesign/anta/elements` (client-side only). Reads
101
- * `navigator.language` at render, so render client-side (not SSR-safe).
106
+ * Import element behavior in the browser. The wrapper supports server rendering;
107
+ * the owned segments resolve the locale when the element connects.
102
108
  *
103
109
  * @example
104
110
  * ```tsx
105
111
  * <InputTime label="Start" defaultValue="09:30" onValueChange={(_, { value }) => save(value)} />
106
112
  * ```
107
113
  */
108
- export declare const InputTime: ({ label, hint, status, statusIcon, tone, size, round, value, defaultValue, locale, hour12, min, max, name, disabled, required, icon, clearable, dimActions, trailing, autoFocus, onValueChange, onClearInput, children, className, style, ...rest }: InputTimeProps) => any;
114
+ export declare const InputTime: ({ label, hint, status, statusIcon, tone, size, round, value, defaultValue, locale, hour12, min, max, name, disabled, readOnly, required, icon, clearable, dimActions, trailing, autoFocus, onValueChange, onClearClick, onClearInput, children, className, style, ...rest }: InputTimeProps) => any;
@@ -1,15 +1,16 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
+ import { CLEAR_TRIGGER } from "../input-events";
3
+ import { useNativeEventProps } from "../native-event-props";
2
4
  import { nativeStateChange, neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
5
  import { Button } from "./Button";
4
6
  import { Icon } from "./Icon";
5
7
  const presence = (on) => on ? "" : void 0;
6
- const isStringish = (n) => typeof n === "string" || typeof n === "number";
7
8
  const attrsOf = (e) => {
8
9
  const el = e?.target ?? {};
9
10
  const value = el.value ?? "";
10
11
  return {
11
12
  value,
12
- name: el.getAttribute?.("name") ?? void 0,
13
+ name: el.name || void 0,
13
14
  empty: !value,
14
15
  valid: el.validity ? el.validity.valid : void 0,
15
16
  validationMessage: el.validationMessage ?? ""
@@ -38,6 +39,7 @@ const InputTime = ({
38
39
  max,
39
40
  name,
40
41
  disabled,
42
+ readOnly,
41
43
  required,
42
44
  icon,
43
45
  clearable,
@@ -45,12 +47,19 @@ const InputTime = ({
45
47
  trailing,
46
48
  autoFocus,
47
49
  onValueChange,
50
+ onClearClick,
48
51
  onClearInput,
49
52
  children,
50
53
  className,
51
54
  style,
52
55
  ...rest
53
56
  }) => {
57
+ const eventProps = useNativeEventProps({
58
+ oninput: onValueChange ? (e) => onValueChange(e, attrsOf(e)) : void 0,
59
+ onchange: onValueChange ? (e) => onValueChange(e, attrsOf(e)) : void 0,
60
+ onclearclick: onClearClick ? (e) => onClearClick(nativeStateChange(e).event) : void 0,
61
+ onclearinput: onClearInput ? (e) => onClearInput(nativeStateChange(e).event) : void 0
62
+ });
54
63
  const statusTone = status && status !== "neutral" ? status : void 0;
55
64
  const glyph = statusIcon === void 0 ? statusTone ? STATUS_ICON[statusTone] : void 0 : statusIcon;
56
65
  return /* @__PURE__ */ jsxs(
@@ -68,25 +77,20 @@ const InputTime = ({
68
77
  tone: neutralToneAttr(tone),
69
78
  name,
70
79
  disabled: presence(disabled),
80
+ readonly: presence(readOnly),
71
81
  required: presence(required),
72
82
  "dim-actions": presence(dimActions),
73
83
  autofocus: autoFocus ? true : void 0,
74
84
  "aria-invalid": status === "critical" ? "true" : void 0,
75
- oninput: onValueChange ? (e) => onValueChange(e, attrsOf(e)) : void 0,
76
- onchange: onValueChange ? (e) => onValueChange(e, attrsOf(e)) : void 0,
77
- onclearinput: onClearInput ? (e) => onClearInput(nativeStateChange(e).event) : void 0,
85
+ ...eventProps,
78
86
  class: className,
79
87
  style: roundStyle(round, "--input-time-round", toneStyle(tone, "--input-time-tone-source", style)),
80
88
  ...rest,
81
89
  children: [
82
- label != null && (isStringish(label) ? /* @__PURE__ */ jsx("span", { slot: "label", children: label }) : /* @__PURE__ */ jsx("span", { slot: "label", style: { display: "contents" }, children: label })),
83
- icon !== false && /* @__PURE__ */ jsx("span", { slot: "leading", style: { display: "contents" }, children: /* @__PURE__ */ jsx(Icon, { shape: icon ?? "clock" }) }),
84
- clearable && // Real <a-button> in the element's `clear` slot; the element controls its
85
- // visibility (shown only when filled). It fires `clearrequest`, which the
86
- // element turns into clear(). CONTRACT: `data-custom-event` MUST match
87
- // CLEAR_TRIGGER in src/elements/a-input-time.ts (string duplicated, not
88
- // shared, to keep the wrapper/element decoupled).
89
- /* @__PURE__ */ jsx("span", { slot: "clear", style: { display: "contents" }, children: /* @__PURE__ */ jsx(
90
+ label != null && /* @__PURE__ */ jsx("a-input-time-label", { slot: "label", children: label }),
91
+ icon !== false && /* @__PURE__ */ jsx("a-input-time-leading", { slot: "leading", children: /* @__PURE__ */ jsx(Icon, { shape: icon ?? "clock" }) }),
92
+ clearable && // The UI element handles the clear lifecycle before framework hydration.
93
+ /* @__PURE__ */ jsx("a-input-time-clear", { slot: "clear", children: /* @__PURE__ */ jsx(
90
94
  Button,
91
95
  {
92
96
  priority: "tertiary",
@@ -94,11 +98,11 @@ const InputTime = ({
94
98
  round: !!round,
95
99
  icon: "x",
96
100
  "aria-label": "Clear",
97
- "data-custom-event": "clearrequest"
101
+ "data-custom-event": CLEAR_TRIGGER
98
102
  }
99
103
  ) }),
100
- trailing != null && /* @__PURE__ */ jsx("span", { slot: "trailing", style: { display: "contents" }, children: trailing }),
101
- hint != null && /* @__PURE__ */ jsxs("span", { slot: "hint", style: { display: "contents" }, children: [
104
+ trailing != null && /* @__PURE__ */ jsx("a-input-time-trailing", { slot: "trailing", children: trailing }),
105
+ hint != null && /* @__PURE__ */ jsxs("a-input-time-hint", { slot: "hint", children: [
102
106
  glyph && /* @__PURE__ */ jsx(Icon, { shape: glyph, "aria-hidden": "true" }),
103
107
  /* @__PURE__ */ jsx("span", { children: hint })
104
108
  ] }),
@@ -27,8 +27,8 @@ export interface LoaderProps extends BaseProps {
27
27
  * to the current proportion. `shape="loader"` provides the indeterminate
28
28
  * visual for string-only icon props such as `Button`'s `icon`.
29
29
  *
30
- * Requires `@antadesign/anta/elements` to be imported (client-side only) to
31
- * register the underlying custom element.
30
+ * Loader needs CSS without element registration. See
31
+ * [Install and configure](https://anta.design/install/) for stylesheet setup.
32
32
  *
33
33
  * @example Indeterminate
34
34
  * ```tsx
@@ -39,9 +39,10 @@ export interface MenuProps extends BaseProps {
39
39
  * in response. Submenus are always uncontrolled regardless of this. See
40
40
  * STATEFUL-COMPONENTS.md. */
41
41
  open?: boolean;
42
- /** Round the menu: the container softens to a 20px radius and its items go
43
- * fully round. A `number` (px) or CSS length string tunes the container radius
44
- * only — items stay full pills. */
42
+ /** Round the menu container to a 20px radius. A `number` (px) or CSS length
43
+ * string sets a custom container radius. Items use the container radius minus
44
+ * `inset`, clamped to zero. Nested submenus inherit the container radius unless
45
+ * they set their own `round` value. */
45
46
  round?: boolean | number | string;
46
47
  /** Contain events so they don't bubble out of the menu to ancestor handlers
47
48
  * (e.g. a clickable row the menu sits in). Selecting an item is always
@@ -101,4 +102,4 @@ export interface MenuProps extends BaseProps {
101
102
  * </Menu>
102
103
  * ```
103
104
  */
104
- export declare const Menu: ({ placement, context, coord, nohover, offset, autoWidth, inset, open, onStateChange, round, stopPropagation, role, className, style, children, ...rest }: MenuProps) => any;
105
+ export declare const Menu: ({ placement, context, coord, nohover, offset, autoWidth, inset, open, onStateChange, onactivedescendant, round, stopPropagation, role, className, style, children, ...rest }: MenuProps) => any;
@@ -1,5 +1,6 @@
1
1
  import { jsx } from "@antadesign/anta/jsx-runtime";
2
2
  import { nativeStateChange, lengthStyle, roundStyle, roundAttr } from "../anta_helpers";
3
+ import { useNativeEventProps } from "../native-event-props";
3
4
  const Menu = ({
4
5
  placement,
5
6
  context,
@@ -10,6 +11,7 @@ const Menu = ({
10
11
  inset,
11
12
  open,
12
13
  onStateChange,
14
+ onactivedescendant,
13
15
  round,
14
16
  stopPropagation,
15
17
  role = "menu",
@@ -18,6 +20,16 @@ const Menu = ({
18
20
  children,
19
21
  ...rest
20
22
  }) => {
23
+ const events = useNativeEventProps({
24
+ onstatechange: onStateChange ? (e) => {
25
+ const { event, detail, isOwn } = nativeStateChange(e);
26
+ if (isOwn && detail) onStateChange(event, {
27
+ next: detail.next === "open",
28
+ prev: detail.prev === "open"
29
+ });
30
+ } : void 0,
31
+ onactivedescendant
32
+ });
21
33
  return /* @__PURE__ */ jsx(
22
34
  "a-menu",
23
35
  {
@@ -28,14 +40,7 @@ const Menu = ({
28
40
  offset: offset != null ? String(offset) : void 0,
29
41
  autowidth: autoWidth ? "" : void 0,
30
42
  state: open === void 0 ? void 0 : open ? "open" : "closed",
31
- onstatechange: onStateChange ? (e) => {
32
- const { event, detail, isOwn } = nativeStateChange(e);
33
- if (isOwn && detail)
34
- onStateChange(event, {
35
- next: detail.next === "open",
36
- prev: detail.prev === "open"
37
- });
38
- } : void 0,
43
+ ...events,
39
44
  round: roundAttr(round),
40
45
  "stop-propagation": stopPropagation === void 0 || stopPropagation === false ? void 0 : stopPropagation === true ? "" : Array.isArray(stopPropagation) ? stopPropagation.join(" ") : stopPropagation,
41
46
  role,
@@ -152,20 +152,7 @@ const MenuItem = ({
152
152
  ...rest,
153
153
  ...switchBehavior,
154
154
  children: [
155
- indicator != null ? (
156
- // `min-height: 1lh` makes the wrapper one text line tall and centers the node
157
- // in it, so a small indicator aligns with the label's first line in a hinted
158
- // (top-aligned) row instead of riding at the top.
159
- /* @__PURE__ */ jsx(
160
- "span",
161
- {
162
- "aria-hidden": "true",
163
- "data-indicator": "",
164
- style: { flex: "none", display: "inline-flex", alignItems: "center", minHeight: "1lh", pointerEvents: "none" },
165
- children: indicator
166
- }
167
- )
168
- ) : selectionIndicator === "checkbox" ? /* @__PURE__ */ jsx(
155
+ indicator != null ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", "data-indicator": "", children: indicator }) : selectionIndicator === "checkbox" ? /* @__PURE__ */ jsx(
169
156
  "a-checkbox",
170
157
  {
171
158
  "aria-hidden": "true",
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
2
  import { MenuItem } from "./MenuItem";
3
3
  import { useCopyFeedback } from "../anta_helpers";
4
- import { copyElementProps, isNodeCopy } from "./copy-props";
4
+ import { useCopyElementProps, isNodeCopy } from "./copy-props";
5
5
  const MenuItemCopy = ({
6
6
  label = "Copy",
7
7
  icon = "copy",
@@ -20,7 +20,7 @@ const MenuItemCopy = ({
20
20
  const restingIcon = iconPlacement === "none" ? void 0 : icon;
21
21
  const { shownIcon, shownTone, handleCopied } = useCopyFeedback(restingIcon, tone, onCopied);
22
22
  const iconSlot = iconPlacement === "trailing" ? { iconTrailing: shownIcon } : iconPlacement === "none" ? {} : { icon: shownIcon };
23
- const copyAttrs = copyElementProps({
23
+ const copyAttrs = useCopyElementProps({
24
24
  copy,
25
25
  copyNode,
26
26
  copyUrl,
@@ -13,5 +13,7 @@ export interface PanelProps extends BaseProps, DOMEventHandlers {
13
13
  }) => void;
14
14
  }
15
15
  /** A scroll container that fills its parent and can maximize to the viewport.
16
- * Percentage height requires a parent with a defined height. */
16
+ * Percentage height requires a parent with a defined height.
17
+ * Inside another shadow root, load `@antadesign/anta/elements/a-panel.css`
18
+ * there through a stylesheet link so its part rules can reach Panel. */
17
19
  export declare const Panel: ({ maximized, defaultMaximized, onStateChange, className, children, ...rest }: PanelProps) => any;
@@ -1,22 +1,28 @@
1
1
  import { jsx } from "@antadesign/anta/jsx-runtime";
2
+ import { useNativeEventProps } from "../native-event-props";
2
3
  import { nativeStateChange } from "../anta_helpers";
3
- const Panel = ({ maximized, defaultMaximized, onStateChange, className, children, ...rest }) => /* @__PURE__ */ jsx(
4
- "a-panel",
5
- {
6
- state: maximized === void 0 ? void 0 : maximized ? "maximized" : "normal",
7
- "default-state": maximized === void 0 && defaultMaximized ? "maximized" : void 0,
4
+ const Panel = ({ maximized, defaultMaximized, onStateChange, className, children, ...rest }) => {
5
+ const events = useNativeEventProps({
8
6
  onstatechange: onStateChange ? (event) => {
9
7
  const { event: native, detail, isOwn } = nativeStateChange(event);
10
8
  if (isOwn && detail) onStateChange(native, {
11
9
  next: detail.next === "maximized",
12
10
  prev: detail.prev === "maximized"
13
11
  });
14
- } : void 0,
15
- class: className,
16
- ...rest,
17
- children
18
- }
19
- );
12
+ } : void 0
13
+ });
14
+ return /* @__PURE__ */ jsx(
15
+ "a-panel",
16
+ {
17
+ state: maximized === void 0 ? void 0 : maximized ? "maximized" : "normal",
18
+ "default-state": maximized === void 0 && defaultMaximized ? "maximized" : void 0,
19
+ ...events,
20
+ class: className,
21
+ ...rest,
22
+ children
23
+ }
24
+ );
25
+ };
20
26
  export {
21
27
  Panel
22
28
  };
@@ -1,51 +1,49 @@
1
1
  import type { BaseProps } from "../general_types";
2
2
  export interface ProgressProps extends BaseProps {
3
- /** Current progress value. Omit this prop, or pass `false`, to show
4
- * indeterminate progress. Negative values are clamped to 0. */
3
+ /** Completed amount relative to `max`. Omit this prop or pass `false` to show
4
+ * a loading animation without a percentage. Values are clamped to the range;
5
+ * non-finite values show zero completion. */
5
6
  value?: number | false;
6
- /** Upper bound of the range.
7
+ /** Total amount to complete. Use a positive number to show a count, such as
8
+ * 3 of 7 files. When `value` is supplied, a non-positive or non-finite total
9
+ * shows an empty fill.
7
10
  * @defaultValue 100 */
8
11
  max?: number;
9
- /** Color variant, or any literal CSS color for a one-off custom tone (the
10
- * surface / indicator / text are derived from it in oklch). Named tones track
11
- * light/dark automatically.
12
+ /** Color for the track, fill, and label row. Pass a named tone or a CSS color.
13
+ * Named tones follow the current theme.
12
14
  * @defaultValue 'neutral' */
13
15
  tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
14
16
  /** Size variant. Scales the track and the default label row together.
15
17
  * @defaultValue medium */
16
18
  size?: 'small' | 'medium' | 'large';
17
- /** Fully-round track (`border-radius: 999px`); the fill is clipped to it. Pass a
18
- * `number` (px) or a CSS length string for a custom radius. */
19
+ /** Pill-shaped track. Pass a number in pixels or a CSS length for a custom
20
+ * corner radius. */
19
21
  round?: boolean | number | string;
20
- /** Text label displayed after the percentage, or on its own for
21
- * indeterminate progress. When you provide custom `children` (which replace
22
- * the default label row), `label` is no longer rendered — but it still
23
- * supplies the progressbar's accessible name. */
22
+ /** Task name shown after the percentage, or on its own during loading.
23
+ * Custom `children` replace the label row; this prop still supplies the
24
+ * progressbar's accessible name. */
24
25
  label?: string;
25
- /** Right-aligned hint text (e.g. "3 of 7"). Like `label`, it's not rendered
26
- * when custom `children` are provided but still feeds the accessible name. */
26
+ /** Details shown at the end of the row, such as "3 of 7" or a time estimate.
27
+ * Included in the accessible name even when custom `children` replace the row. */
27
28
  hint?: string;
28
29
  }
29
30
  /**
30
- * Progress indicator for task completion and indeterminate work.
31
+ * Shows task completion with a percentage, label, and optional hint.
31
32
  *
32
- * Renders an `<a-progress>` web component with an optional label area
33
- * showing percentage, text label, and hint.
34
- *
35
- * Requires `@antadesign/anta/elements` to be imported (client-side only)
36
- * to register the underlying custom element.
33
+ * Use `value` and `max` when the total is known. Omit `value` for a loading
34
+ * animation. Custom children replace the default label row while `label` and
35
+ * `hint` retain an accessible description of the task.
37
36
  *
38
37
  * @example Basic usage
39
38
  * ```tsx
40
- * import { Progress } from '@antadesign/anta'
41
- * import '@antadesign/anta/elements'
39
+ * import { Progress } from '@antadesign/anta/bundle'
42
40
  *
43
41
  * <Progress value={60} />
44
42
  * ```
45
43
  *
46
44
  * @example With label and hint
47
45
  * ```tsx
48
- * <Progress value={42} label="Uploading files..." hint="3 of 7" />
46
+ * <Progress value={3} max={7} label="Uploading files..." hint="3 of 7" />
49
47
  * ```
50
48
  *
51
49
  * @example Indeterminate
@@ -2,10 +2,17 @@ import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
2
  import { hasChildren, neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
3
  const Progress = ({ value, max = 100, tone, size, round, label, hint, className, style, children, ...rest }) => {
4
4
  const indeterminate = value == null || value === false;
5
- const numericValue = typeof value === "number" ? value : 0;
6
- const percent = max > 0 ? Math.round(Math.min(100, Math.max(0, numericValue / max * 100))) : 0;
7
- const clampedValue = max > 0 ? Math.min(max, Math.max(0, numericValue)) : 0;
5
+ const numericValue = typeof value === "number" && Number.isFinite(value) ? value : 0;
6
+ const validMax = Number.isFinite(max) && max > 0;
7
+ const fillPercent = validMax ? Math.min(100, Math.max(0, numericValue / max * 100)) : 0;
8
+ const percent = Math.round(fillPercent);
9
+ const clampedValue = validMax ? Math.min(max, Math.max(0, numericValue)) : 0;
8
10
  const ariaLabel = [label, !indeterminate && `${percent}%`, hint].filter(Boolean).join(" \xB7 ") || (indeterminate ? "Loading" : void 0);
11
+ const progressStyle = indeterminate ? style : {
12
+ "--progress-value": numericValue,
13
+ "--progress-max": validMax ? max : 0,
14
+ ...style
15
+ };
9
16
  return /* @__PURE__ */ jsx(
10
17
  "a-progress",
11
18
  {
@@ -17,16 +24,13 @@ const Progress = ({ value, max = 100, tone, size, round, label, hint, className,
17
24
  role: "progressbar",
18
25
  "aria-valuenow": indeterminate ? void 0 : clampedValue,
19
26
  "aria-valuemin": indeterminate ? void 0 : 0,
20
- "aria-valuemax": indeterminate ? void 0 : max,
27
+ "aria-valuemax": indeterminate ? void 0 : validMax ? max : 100,
21
28
  "aria-label": ariaLabel,
22
29
  class: className,
23
- style: roundStyle(round, "--progress-round", toneStyle(tone, "--progress-tone-source", style)),
30
+ style: roundStyle(round, "--progress-round", toneStyle(tone, "--progress-tone-source", progressStyle)),
24
31
  ...rest,
25
32
  children: hasChildren(children) ? children : /* @__PURE__ */ jsxs("a-progress-label", { children: [
26
- !indeterminate && /* @__PURE__ */ jsxs("a-progress-number", { children: [
27
- percent,
28
- "%"
29
- ] }),
33
+ !indeterminate && /* @__PURE__ */ jsx("a-progress-number", { children: `${percent}%` }),
30
34
  label != null && /* @__PURE__ */ jsx("a-progress-text", { children: label }),
31
35
  hint != null && /* @__PURE__ */ jsx("a-progress-hint", { children: hint })
32
36
  ] })
@@ -1,6 +1,7 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { useId, useState } from "../jsx-runtime";
3
- import { nativeStateChange, neutralToneAttr, optionPresentationAttrs, toneStyle } from "../anta_helpers";
2
+ import { useNativeEventProps } from "../native-event-props";
3
+ import { useId } from "../jsx-runtime";
4
+ import { nativeStateChange, neutralToneAttr, optionPresentationAttrs, toneStyle, useSelectionMirror } from "../anta_helpers";
4
5
  const radioAttrsOf = (el) => ({
5
6
  value: el?.value ?? null,
6
7
  name: el?.getAttribute?.("name") ?? void 0
@@ -28,8 +29,7 @@ const RadioGroup = ({
28
29
  ...rest
29
30
  }) => {
30
31
  const controlled = value !== void 0;
31
- const [internalValue, setInternalValue] = useState(defaultValue);
32
- const currentValue = controlled ? value : internalValue;
32
+ const [currentValue, setInternalValue] = useSelectionMirror(value, defaultValue);
33
33
  const seen = /* @__PURE__ */ new Set();
34
34
  for (const o of options) {
35
35
  if (seen.has(o.value))
@@ -51,6 +51,7 @@ const RadioGroup = ({
51
51
  onChange?.(e);
52
52
  onValueChange?.(e, radioAttrsOf(e.currentTarget));
53
53
  } : void 0;
54
+ const events = useNativeEventProps({ onstatechange, onchange, onfocusin: onFocus, onfocusout: onBlur });
54
55
  return /* @__PURE__ */ jsxs(
55
56
  "a-radio-group",
56
57
  {
@@ -68,10 +69,7 @@ const RadioGroup = ({
68
69
  size: size && size !== "medium" ? size : void 0,
69
70
  disabled: disabled ? "" : void 0,
70
71
  orientation: orientation && orientation !== "vertical" ? orientation : void 0,
71
- onstatechange,
72
- onchange,
73
- onfocusin: onFocus,
74
- onfocusout: onBlur,
72
+ ...events,
75
73
  class: className,
76
74
  style: toneStyle(tone, "--radio-tone-source", toneStyle(tone, "--radio-off-tone-source", style)),
77
75
  children: [
@@ -1 +1 @@
1
- @layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-select-field{display:grid;grid-template-columns:minmax(0,1fr);gap:4px;--select-text: var(--text-1);--select-bg: var(--bg-1);--select-border: var(--border-2);--select-hint: var(--text-3);--select-fs: 15px;--select-lh: 20px;font-family:var(--sans-serif);font-size:var(--select-fs);line-height:var(--select-lh)}a-select-field[size=small]{--select-fs: 13px;--select-lh: 16px}a-select-field[size=large]{--select-fs: 17px;--select-lh: 22px}a-select-label{color:var(--text-3);font-weight:500}a-select-hint{display:flex;align-items:start;gap:4px;padding-inline:1px;color:var(--select-hint);font-size:calc(var(--select-fs) - 1px);line-height:var(--select-lh)}a-select-field>a-button{width:100%;min-width:0;box-sizing:border-box;padding-inline:7px;color:var(--select-text);background:var(--select-bg);box-shadow:inset 0 0 0 .5px var(--select-border);font-size:var(--select-fs);line-height:var(--select-lh);font-weight:400;letter-spacing:normal}a-select-field>a-button>a-button-label{flex:1;text-align:start;line-height:var(--select-lh);padding:0}a-select-field>a-button>a-button-label[data-placeholder]{color:var(--text-4)}a-select-field>a-button:focus-visible{box-shadow:inset 0 0 0 1px var(--select-border)}@media(hover:hover)and (pointer:fine){a-select-field>a-button:hover:not([disabled]){box-shadow:inset 0 0 0 1px var(--select-border)}}a-select-leading,a-select-chevron{flex:none;color:var(--text-3)}a-select-leading{display:inline-flex;align-items:center}a-select-field[size=small] a-icon{--icon-size: 14px}a-select-field[size=large] a-icon{--icon-size: 18px}a-select-field[status=critical]{--select-status-source: var(--anta-seed-critical);--select-bg: var(--bg-2-critical);--select-hint: var(--text-2-critical)}a-select-field[status=warning]{--select-status-source: var(--anta-seed-warning);--select-bg: var(--bg-2-warning);--select-hint: var(--text-2-warning)}a-select-field[status=success]{--select-status-source: var(--anta-seed-success);--select-bg: var(--bg-2-success);--select-hint: var(--text-2-success)}a-select-field[status=info]{--select-status-source: var(--anta-seed-info);--select-bg: var(--bg-2-info);--select-hint: var(--text-2-info)}a-select-field[status=brand]{--select-status-source: var(--anta-seed-brand);--select-bg: var(--bg-2-brand);--select-hint: var(--text-2-brand)}a-select-field[status]:not([status=neutral]){--select-border: light-dark(oklch(from var(--select-status-source) .58 c h), oklch(from var(--select-status-source) .52 c h))}a-select-field[status]:not([status=neutral])>a-button{box-shadow:inset 0 0 0 1px var(--select-border)}a-select-field[disabled]{--select-text: var(--text-4);--select-hint: var(--text-5);--select-bg: color-mix(in oklch, var(--text-1) 5%, transparent);--select-border: var(--border-2)}a-select-field[disabled]>a-select-label{color:var(--text-4)}a-select-chevron{display:inline-flex;transition:transform .15s ease}a-select-chevron[open]{transform:rotate(180deg)}a-select-faceted-summary{display:block;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}
1
+ @layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-select-field{display:grid;grid-template-columns:minmax(0,1fr);gap:4px;--select-text: var(--text-1);--select-bg: var(--bg-1);--select-border: var(--border-2);--select-hint: var(--text-3);--select-fs: 15px;--select-lh: 20px;font-family:var(--sans-serif);font-size:var(--select-fs);line-height:var(--select-lh)}a-select-field[size=small]{--select-fs: 13px;--select-lh: 16px}a-select-field[size=large]{--select-fs: 17px;--select-lh: 22px}a-select-label{color:var(--text-3);font-weight:500}a-select-hint{display:flex;align-items:start;gap:4px;padding-inline:1px;color:var(--select-hint);font-size:calc(var(--select-fs) - 1px);line-height:var(--select-lh)}a-select-field>a-button{width:100%;min-width:0;box-sizing:border-box;padding-inline:7px;color:var(--select-text);background:var(--select-bg);box-shadow:inset 0 0 0 .5px var(--select-border);font-size:var(--select-fs);line-height:var(--select-lh);font-weight:400;letter-spacing:normal}a-select-field>a-button>a-button-label{flex:1;text-align:start;line-height:var(--select-lh);padding:0}a-select-field>a-button>a-button-label[data-placeholder]{color:var(--text-4)}a-select-field>a-button:focus-visible{box-shadow:inset 0 0 0 1px var(--select-border)}@media(hover:hover)and (pointer:fine){a-select-field>a-button:hover:not([disabled]){box-shadow:inset 0 0 0 1px var(--select-border)}}a-select-leading,a-select-chevron{flex:none;color:var(--text-3)}a-select-leading{display:inline-flex;align-items:center}a-select-field[size=small] a-icon{--icon-size: 14px}a-select-field[size=large] a-icon{--icon-size: 18px}a-select-field[status=critical]{--select-status-source: var(--anta-seed-critical);--select-bg: var(--bg-2-critical);--select-hint: var(--text-2-critical)}a-select-field[status=warning]{--select-status-source: var(--anta-seed-warning);--select-bg: var(--bg-2-warning);--select-hint: var(--text-2-warning)}a-select-field[status=success]{--select-status-source: var(--anta-seed-success);--select-bg: var(--bg-2-success);--select-hint: var(--text-2-success)}a-select-field[status=info]{--select-status-source: var(--anta-seed-info);--select-bg: var(--bg-2-info);--select-hint: var(--text-2-info)}a-select-field[status=brand]{--select-status-source: var(--anta-seed-brand);--select-bg: var(--bg-2-brand);--select-hint: var(--text-2-brand)}a-select-field[status]:not([status=neutral]){--select-border: light-dark(oklch(from var(--select-status-source) .58 c h), oklch(from var(--select-status-source) .52 c h))}a-select-field[status]:not([status=neutral])>a-button{box-shadow:inset 0 0 0 1px var(--select-border)}a-select-field[disabled]{--select-text: var(--text-4);--select-hint: var(--text-5);--select-bg: color-mix(in oklch, var(--text-1) 5%, transparent);--select-border: var(--border-2)}a-select-field[disabled]>a-select-label{color:var(--text-4)}a-select-chevron{display:inline-flex;transition:transform .15s ease}a-select-chevron[open]{transform:rotate(180deg)}a-select-faceted-text{display:block;padding:4px}a-select-faceted-summary{display:block;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}