@antadesign/anta 0.3.26 → 0.3.28

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 (133) hide show
  1. package/README.md +26 -28
  2. package/dist/anta_helpers.d.ts +8 -0
  3. package/dist/anta_helpers.js +18 -0
  4. package/dist/box-types.d.ts +1 -1
  5. package/dist/bundle.css +1 -1
  6. package/dist/bundle.js +36 -42
  7. package/dist/capture-types.d.ts +156 -0
  8. package/dist/components/Banner.js +2 -2
  9. package/dist/components/Box.d.ts +15 -0
  10. package/dist/components/Box.js +3 -11
  11. package/dist/components/Button.js +2 -2
  12. package/dist/components/Capture.d.ts +39 -0
  13. package/dist/components/Capture.js +36 -0
  14. package/dist/components/Card.js +2 -2
  15. package/dist/components/Checkbox.d.ts +10 -11
  16. package/dist/components/Checkbox.js +5 -13
  17. package/dist/components/Expander.js +2 -2
  18. package/dist/components/Input.js +2 -2
  19. package/dist/components/InputTime.js +2 -2
  20. package/dist/components/Loader.js +2 -1
  21. package/dist/components/MenuItem.d.ts +7 -8
  22. package/dist/components/MenuItem.js +4 -4
  23. package/dist/components/Progress.js +2 -2
  24. package/dist/components/RadioGroup.d.ts +12 -13
  25. package/dist/components/RadioGroup.js +7 -23
  26. package/dist/components/Select.d.ts +12 -7
  27. package/dist/components/Select.js +4 -3
  28. package/dist/components/SelectFaceted.d.ts +7 -5
  29. package/dist/components/SelectFaceted.js +4 -3
  30. package/dist/components/Slider.js +3 -3
  31. package/dist/components/Steps.css +1 -1
  32. package/dist/components/Switch.d.ts +7 -8
  33. package/dist/components/Switch.js +3 -11
  34. package/dist/components/Tabs.js +2 -2
  35. package/dist/components/Tag.d.ts +7 -9
  36. package/dist/components/Tag.js +2 -2
  37. package/dist/components/Text.js +2 -2
  38. package/dist/components/Title.js +2 -2
  39. package/dist/components/capture-props.d.ts +30 -0
  40. package/dist/components/capture-props.js +44 -0
  41. package/dist/elements/a-avatar.css +1 -1
  42. package/dist/elements/a-banner.css +1 -1
  43. package/dist/elements/a-box.d.ts +1 -1
  44. package/dist/elements/a-box.js +11 -3
  45. package/dist/elements/a-button.css +1 -1
  46. package/dist/elements/a-button.d.ts +7 -9
  47. package/dist/elements/a-calendar.css +1 -1
  48. package/dist/elements/a-capture.css +1 -0
  49. package/dist/elements/a-capture.d.ts +10 -0
  50. package/dist/elements/a-capture.js +24 -0
  51. package/dist/elements/a-card.css +1 -1
  52. package/dist/elements/a-checkbox.css +1 -1
  53. package/dist/elements/a-checkbox.js +4 -4
  54. package/dist/elements/a-dialog.css +1 -1
  55. package/dist/elements/a-expander.css +1 -1
  56. package/dist/elements/a-expander.js +1 -0
  57. package/dist/elements/a-input-time.css +1 -1
  58. package/dist/elements/a-input-time.js +5 -7
  59. package/dist/elements/a-input.css +1 -1
  60. package/dist/elements/a-input.js +4 -6
  61. package/dist/elements/a-menu-item.css +1 -1
  62. package/dist/elements/a-menu.css +1 -1
  63. package/dist/elements/a-progress.css +1 -1
  64. package/dist/elements/a-radio.css +1 -1
  65. package/dist/elements/a-slider.css +1 -1
  66. package/dist/elements/a-slider.js +6 -9
  67. package/dist/elements/a-switch.css +1 -1
  68. package/dist/elements/a-tab.css +1 -1
  69. package/dist/elements/a-tabs.css +1 -1
  70. package/dist/elements/a-tag.css +1 -1
  71. package/dist/elements/a-text.css +1 -1
  72. package/dist/elements/a-text.js +1 -0
  73. package/dist/elements/a-title.css +1 -1
  74. package/dist/elements/a-tooltip.css +1 -1
  75. package/dist/elements/a-tooltip.d.ts +3 -4
  76. package/dist/elements/a-tooltip.js +0 -1
  77. package/dist/elements/capture-input.d.ts +5 -0
  78. package/dist/elements/capture-input.js +609 -0
  79. package/dist/elements/index.d.ts +1 -0
  80. package/dist/elements/index.js +3 -0
  81. package/dist/general_types.d.ts +56 -23
  82. package/dist/index.d.ts +4 -1
  83. package/dist/index.js +2 -0
  84. package/dist/jsx-runtime.d.ts +2 -1
  85. package/dist/reset.css +1 -1
  86. package/dist/theme-antithesis.css +1 -0
  87. package/dist/theme-antune.css +1 -0
  88. package/dist/tokens.css +1 -1
  89. package/docs/accessibility.md +24 -0
  90. package/docs/changelog.md +79 -0
  91. package/docs/colors.md +141 -0
  92. package/docs/comparison.md +463 -28
  93. package/docs/components/avatar.md +13 -17
  94. package/docs/components/banner.md +13 -27
  95. package/docs/components/box.md +226 -154
  96. package/docs/components/breadcrumbs.md +49 -12
  97. package/docs/components/button.md +48 -37
  98. package/docs/components/capture.md +345 -0
  99. package/docs/components/card.md +17 -38
  100. package/docs/components/checkbox.md +27 -50
  101. package/docs/components/dialog.md +14 -36
  102. package/docs/components/expander.md +15 -40
  103. package/docs/components/icon.md +111 -9
  104. package/docs/components/input-autocomplete.md +9 -11
  105. package/docs/components/input-date.md +33 -23
  106. package/docs/components/input-time.md +15 -23
  107. package/docs/components/input.md +27 -76
  108. package/docs/components/loader.md +7 -5
  109. package/docs/components/menu.md +75 -80
  110. package/docs/components/progress.md +10 -14
  111. package/docs/components/radio.md +28 -46
  112. package/docs/components/select-faceted.md +8 -25
  113. package/docs/components/select.md +33 -105
  114. package/docs/components/slider.md +16 -21
  115. package/docs/components/steps.md +38 -8
  116. package/docs/components/switch.md +16 -19
  117. package/docs/components/tabs.md +52 -40
  118. package/docs/components/tag.md +15 -24
  119. package/docs/components/text.md +10 -23
  120. package/docs/components/title.md +7 -8
  121. package/docs/components/toaster.md +6 -3
  122. package/docs/components/tooltip.md +13 -23
  123. package/docs/index.md +3 -1
  124. package/docs/install-config.md +42 -8
  125. package/docs/normalization.md +48 -3
  126. package/docs/packages/stickers.md +56 -0
  127. package/docs/theming.md +362 -14
  128. package/package.json +7 -4
  129. package/dist/components/InputDate.module.css +0 -1
  130. package/dist/components/Select.module.css +0 -1
  131. package/dist/components/SelectFaceted.module.css +0 -1
  132. package/dist/theme-anta.css +0 -1
  133. /package/dist/{search-index.json → capture-types.js} +0 -0
@@ -0,0 +1,156 @@
1
+ /** Directions of wheel or scroll deltas. Positive Y is down; positive X is right. */
2
+ export type CaptureInputDirection = 'up' | 'down' | 'left' | 'right';
3
+ /** `true` accepts every direction; omitted object entries decline that direction. */
4
+ export type CaptureInputDirections = boolean | Partial<Record<CaptureInputDirection, boolean>>;
5
+ /** `none` accepts unmodified input; a named modifier must be pressed. */
6
+ export type CaptureInputModifier = 'none' | 'any' | 'alt' | 'ctrl' | 'meta' | 'shift';
7
+ export type CaptureWheelActivation = 'hover' | 'settled' | 'focus' | 'settled-or-focus';
8
+ export type CaptureWheelActivationReason = 'immediate' | 'settled' | 'focus';
9
+ export interface CaptureWheelSettle {
10
+ /** Pointer dwell time in milliseconds.
11
+ * @defaultValue 150 */
12
+ delay?: number;
13
+ /** Maximum movement from the dwell anchor on either axis, in CSS pixels.
14
+ * @defaultValue 5 */
15
+ tolerance?: number;
16
+ /** Restart dwell after movement beyond tolerance, including after activation.
17
+ * @defaultValue false */
18
+ resetOnMove?: boolean;
19
+ }
20
+ export type CapturePointerType = 'mouse' | 'pen' | 'touch';
21
+ export interface CapturePointerCapture {
22
+ /** Accepted pointer devices. One primary pointer is tracked per Capture.
23
+ * @defaultValue ['mouse', 'pen', 'touch'] */
24
+ pointerTypes?: readonly CapturePointerType[];
25
+ /** Accepted initiating buttons, using PointerEvent.button values.
26
+ * @defaultValue [0] */
27
+ buttons?: readonly number[];
28
+ /** Movement required before activation, in viewport CSS pixels.
29
+ * @defaultValue 0 */
30
+ threshold?: number;
31
+ /** Modifier required to start a capture session.
32
+ * @defaultValue any */
33
+ modifier?: CaptureInputModifier;
34
+ /** Allow capture to start on nested native or ARIA controls, links, or editable regions.
35
+ * @defaultValue false */
36
+ includeInteractive?: boolean;
37
+ }
38
+ export interface CapturePanInertia {
39
+ /** Exponential velocity decay time constant in milliseconds.
40
+ * @defaultValue 325 */
41
+ timeConstant?: number;
42
+ /** Stop when speed on both axes falls below this value, in CSS pixels/ms.
43
+ * @defaultValue 0.02 */
44
+ minVelocity?: number;
45
+ }
46
+ export interface CapturePan {
47
+ /** Accepted pointer devices.
48
+ * @defaultValue ['touch'] */
49
+ pointerTypes?: readonly CapturePointerType[];
50
+ /** Axes handled by custom panning. CSS touch-action leaves the other axis to the browser.
51
+ * @defaultValue both */
52
+ axis?: 'x' | 'y' | 'both';
53
+ /** Movement required before activation, in viewport CSS pixels.
54
+ * @defaultValue 3 */
55
+ threshold?: number;
56
+ /** Allowed scroll directions. Updating these can stop motion at application bounds.
57
+ * @defaultValue true */
58
+ directions?: CaptureInputDirections;
59
+ /** Continue panning after release with browser-side velocity decay.
60
+ * @defaultValue false */
61
+ inertia?: boolean | CapturePanInertia;
62
+ }
63
+ /** Plain event data. DOM targets, methods, and browser objects are excluded. */
64
+ export interface SerializedMouseEvent {
65
+ type: string;
66
+ timeStamp: number;
67
+ isTrusted: boolean;
68
+ cancelable: boolean;
69
+ defaultPrevented: boolean;
70
+ altKey: boolean;
71
+ ctrlKey: boolean;
72
+ metaKey: boolean;
73
+ shiftKey: boolean;
74
+ button: number;
75
+ buttons: number;
76
+ clientX: number;
77
+ clientY: number;
78
+ pageX: number;
79
+ pageY: number;
80
+ screenX: number;
81
+ screenY: number;
82
+ /** Coordinates relative to the original event target's padding edge. */
83
+ offsetX: number;
84
+ offsetY: number;
85
+ }
86
+ /** Original wheel values, including their original units and signs. */
87
+ export interface SerializedWheelEvent extends SerializedMouseEvent {
88
+ deltaX: number;
89
+ deltaY: number;
90
+ deltaZ: number;
91
+ deltaMode: number;
92
+ }
93
+ export interface SerializedPointerEvent extends SerializedMouseEvent {
94
+ pointerId: number;
95
+ pointerType: string;
96
+ isPrimary: boolean;
97
+ width: number;
98
+ height: number;
99
+ pressure: number;
100
+ tangentialPressure: number;
101
+ tiltX: number;
102
+ tiltY: number;
103
+ twist: number;
104
+ }
105
+ /** Geometry measured at delivery. CSS transforms are included in the viewport rectangle. */
106
+ export interface CaptureInputGeometry {
107
+ /** Pointer position relative to the viewport bounding rectangle's top-left, in CSS pixels. */
108
+ localX: number;
109
+ localY: number;
110
+ /** Dimensions of the same viewport bounding rectangle, in CSS pixels. */
111
+ boxWidth: number;
112
+ boxHeight: number;
113
+ /** Whether the pointer is inside that rectangle. Capture can continue outside it. */
114
+ inside: boolean;
115
+ focusWithin: boolean;
116
+ }
117
+ /** An accepted wheel input. Cancellation has already happened on the browser thread. */
118
+ export interface CaptureWheelInput extends CaptureInputGeometry {
119
+ wheelEvent: SerializedWheelEvent;
120
+ activationReason: CaptureWheelActivationReason;
121
+ }
122
+ export type CapturePointerActivationReason = 'pointer-down' | 'drag-threshold';
123
+ export type CaptureInputCancelReason = 'pointer-cancel' | 'lost-capture' | 'disabled' | 'disconnected' | 'blur' | 'interrupted';
124
+ export interface CapturePointerStart extends CaptureInputGeometry {
125
+ pointerEvent: SerializedPointerEvent;
126
+ }
127
+ /** A captured pointer session. Positive movement follows the pointer right/down. */
128
+ export interface CapturePointerInput extends CaptureInputGeometry {
129
+ phase: 'start' | 'move' | 'end' | 'cancel';
130
+ /** Null when cancellation comes from lifecycle or configuration changes. */
131
+ pointerEvent: SerializedPointerEvent | null;
132
+ start: CapturePointerStart;
133
+ /** Movement since the previous delivered sample, in viewport CSS pixels. */
134
+ deltaX: number;
135
+ deltaY: number;
136
+ /** Total movement from the initial press, in viewport CSS pixels. */
137
+ movementX: number;
138
+ movementY: number;
139
+ activationReason: CapturePointerActivationReason;
140
+ cancelReason?: CaptureInputCancelReason;
141
+ }
142
+ /** Custom scroll motion. Deltas have the opposite sign to finger movement. */
143
+ export interface CapturePanInput extends CaptureInputGeometry {
144
+ phase: 'start' | 'move' | 'release' | 'inertia' | 'end' | 'cancel';
145
+ /** Null during momentum or cancellation without a pointer event. */
146
+ pointerEvent: SerializedPointerEvent | null;
147
+ start: CapturePointerStart;
148
+ /** Incremental scroll motion in viewport CSS pixels. */
149
+ deltaX: number;
150
+ deltaY: number;
151
+ /** Scroll velocity in viewport CSS pixels/ms. */
152
+ velocityX: number;
153
+ velocityY: number;
154
+ activationReason: CapturePointerActivationReason;
155
+ cancelReason?: CaptureInputCancelReason;
156
+ }
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { nativeStateChange, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
2
+ import { nativeStateChange, neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
3
  import { Button } from "./Button";
4
4
  const Banner = ({
5
5
  message,
@@ -29,7 +29,7 @@ const Banner = ({
29
29
  {
30
30
  state: controlled ? dismissed ? "closed" : "open" : void 0,
31
31
  "default-state": !controlled ? defaultDismissed ? "closed" : "open" : void 0,
32
- tone: tone && tone !== "neutral" ? tone : void 0,
32
+ tone: neutralToneAttr(tone),
33
33
  align: align === "center" ? "center" : void 0,
34
34
  round: roundAttr(round),
35
35
  role,
@@ -34,4 +34,19 @@ export interface BoxProps extends BaseProps {
34
34
  * contains the changed fields and a full current snapshot. */
35
35
  onContextChange?: (event: CustomEvent<BoxContextChange>, detail: BoxContextChange) => void;
36
36
  }
37
+ /**
38
+ * A light-DOM CSS box with browser-owned observation. `Box` is deliberately a
39
+ * thin JSX projection: it never holds a DOM ref. The element measures itself,
40
+ * tracks clipping and focus within, and emits native custom events so this works
41
+ * with React, Preact, and DOMs reconciled outside the UI thread.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * <Box display="grid" onMeasureChange={(event, { current }) => {
46
+ * console.log(current.width, current.clippedX)
47
+ * }}>
48
+ * <Text truncate>Long content</Text>
49
+ * </Box>
50
+ * ```
51
+ */
37
52
  export declare const Box: ({ display, round, gap, observe, fade, fadeSize, onMeasureChange, onContextChange, className, style, children, ...rest }: BoxProps) => any;
@@ -1,8 +1,8 @@
1
1
  import { jsx } from "@antadesign/anta/jsx-runtime";
2
2
  import {
3
3
  cssLength,
4
+ customEventHandler,
4
5
  lengthStyle,
5
- nativeStateChange,
6
6
  roundAttr,
7
7
  roundStyle
8
8
  } from "../anta_helpers";
@@ -28,14 +28,6 @@ const Box = ({
28
28
  children,
29
29
  ...rest
30
30
  }) => {
31
- const measureHandler = onMeasureChange ? (input) => {
32
- const { event, detail } = nativeStateChange(input);
33
- if (detail) onMeasureChange(event, detail);
34
- } : void 0;
35
- const contextHandler = onContextChange ? (input) => {
36
- const { event, detail } = nativeStateChange(input);
37
- if (detail) onContextChange(event, detail);
38
- } : void 0;
39
31
  return /* @__PURE__ */ jsx(
40
32
  "a-box",
41
33
  {
@@ -45,8 +37,8 @@ const Box = ({
45
37
  observe: observeAttr(observe, onMeasureChange, onContextChange),
46
38
  fade: fade ? "" : void 0,
47
39
  "fade-size": fade && fadeSize != null ? cssLength(fadeSize) : void 0,
48
- onmeasurechange: measureHandler,
49
- oncontextchange: contextHandler,
40
+ onmeasurechange: customEventHandler(onMeasureChange),
41
+ oncontextchange: customEventHandler(onContextChange),
50
42
  class: className,
51
43
  style: lengthStyle(
52
44
  fade ? fadeSize : void 0,
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { toneStyle, roundStyle, roundAttr, wrapLabel } from "../anta_helpers";
2
+ import { neutralToneAttr, toneStyle, roundStyle, roundAttr, wrapLabel } from "../anta_helpers";
3
3
  const Button = ({
4
4
  priority,
5
5
  tone,
@@ -27,7 +27,7 @@ const Button = ({
27
27
  children,
28
28
  ...rest
29
29
  }) => {
30
- const toneAttr = tone || void 0;
30
+ const toneAttr = neutralToneAttr(tone);
31
31
  const unavailable = disabled || loading;
32
32
  const computedStyle = roundStyle(round, "--button-round", toneStyle(toneAttr, "--button-tone-source", style));
33
33
  const isIconOnly = icon != null && label == null && children == null && iconTrailing == null;
@@ -0,0 +1,39 @@
1
+ import type { BaseProps } from '../general_types';
2
+ import type { CaptureInputDirections, CaptureInputModifier, CapturePan, CapturePanInput, CapturePointerCapture, CapturePointerInput, CaptureWheelActivation, CaptureWheelInput, CaptureWheelSettle } from '../capture-types';
3
+ /** Opt-in input ownership for the light-DOM capture surface. */
4
+ export interface CaptureProps extends BaseProps {
5
+ /** Capture wheel input in the enabled directions and emit `onWheelInput`.
6
+ * `true` accepts all directions. Omit or pass `false` to leave wheel input alone.
7
+ * Nested native wheel controls and Anta menus are excluded.
8
+ * All-false direction bounds preserve pointer settling while declining input.
9
+ * A listener alone never enables capture. */
10
+ wheelCapture?: CaptureInputDirections;
11
+ /** Pointer or focus condition required before wheel input can be captured.
12
+ * Focus applies only to input targeted within this Capture.
13
+ * @defaultValue settled */
14
+ wheelActivation?: CaptureWheelActivation;
15
+ /** Required modifier for wheel capture. `none` preserves browser Ctrl/pinch zoom.
16
+ * @defaultValue none */
17
+ wheelModifier?: CaptureInputModifier;
18
+ /** Dwell delay, movement tolerance, and whether movement resets eligibility.
19
+ * @defaultValue { delay: 150, tolerance: 5, resetOnMove: false } */
20
+ wheelSettle?: CaptureWheelSettle;
21
+ /** Accepted wheel input, with a serialized original event, Capture-relative
22
+ * geometry, focus state, and activation reason. Cancellation is already complete. */
23
+ onWheelInput?: (event: CustomEvent<CaptureWheelInput>, detail: CaptureWheelInput) => void;
24
+ /** Emit raw data for a primary pointer until release or cancellation. An options object
25
+ * filters devices/buttons and configures activation. Nested interactive controls
26
+ * are excluded unless explicitly included. A listener alone enables nothing. */
27
+ pointerCapture?: boolean | CapturePointerCapture;
28
+ /** Start, movement, end, and cancellation of an opted-in pointer session. */
29
+ onPointerInput?: (event: CustomEvent<CapturePointerInput>, detail: CapturePointerInput) => void;
30
+ /** Emit custom pan motion. `true` enables touch panning on both axes without
31
+ * momentum. Options select devices, axes, bounds directions, and optional inertia.
32
+ * Captures the pointer internally; `pointerCapture` is not required.
33
+ * Sets CSS touch-action through attributes before the gesture starts. */
34
+ pan?: boolean | CapturePan;
35
+ /** Custom pan motion and its lifecycle. Inertial samples have no native pointer event. */
36
+ onPanInput?: (event: CustomEvent<CapturePanInput>, detail: CapturePanInput) => void;
37
+ }
38
+ /** A browser-thread input surface. Nothing is captured until a capability is enabled. */
39
+ export declare const Capture: ({ wheelCapture, wheelActivation, wheelModifier, wheelSettle, onWheelInput, pointerCapture, onPointerInput, pan, onPanInput, className, children, ...rest }: CaptureProps) => any;
@@ -0,0 +1,36 @@
1
+ import { jsx } from "@antadesign/anta/jsx-runtime";
2
+ import { customEventHandler } from "../anta_helpers";
3
+ import { directionAttribute, panAttributes, pointerCaptureAttributes, wheelSettleAttributes } from "./capture-props";
4
+ const Capture = ({
5
+ wheelCapture,
6
+ wheelActivation,
7
+ wheelModifier,
8
+ wheelSettle,
9
+ onWheelInput,
10
+ pointerCapture,
11
+ onPointerInput,
12
+ pan,
13
+ onPanInput,
14
+ className,
15
+ children,
16
+ ...rest
17
+ }) => /* @__PURE__ */ jsx(
18
+ "a-capture",
19
+ {
20
+ "wheel-capture": directionAttribute(wheelCapture),
21
+ "wheel-activation": wheelCapture ? wheelActivation : void 0,
22
+ "wheel-modifier": wheelCapture ? wheelModifier : void 0,
23
+ ...wheelSettleAttributes(wheelCapture ? wheelSettle : void 0),
24
+ ...pointerCaptureAttributes(pointerCapture),
25
+ ...panAttributes(pan),
26
+ onwheelinput: customEventHandler(onWheelInput),
27
+ onpointerinput: customEventHandler(onPointerInput),
28
+ onpaninput: customEventHandler(onPanInput),
29
+ class: className,
30
+ ...rest,
31
+ children
32
+ }
33
+ );
34
+ export {
35
+ Capture
36
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { toneStyle, roundStyle, roundAttr } from "../anta_helpers";
2
+ import { neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
3
  import { Title } from "./Title";
4
4
  import { Text } from "./Text";
5
5
  import { Icon } from "./Icon";
@@ -25,7 +25,7 @@ const Card = ({
25
25
  children,
26
26
  ...rest
27
27
  }) => {
28
- const toneAttr = tone || void 0;
28
+ const toneAttr = neutralToneAttr(tone);
29
29
  const computedStyle = roundStyle(
30
30
  round,
31
31
  "--card-round",
@@ -1,4 +1,4 @@
1
- import type { BaseProps } from "../general_types";
1
+ import type { BaseProps, ToneScope } from "../general_types";
2
2
  /** The wrapper-level checked value: a boolean for the binary axis, the string
3
3
  * `'indeterminate'` for the third state. Mirrors Radix's `Checkbox.Root`. */
4
4
  export type CheckboxValue = boolean | 'indeterminate';
@@ -51,21 +51,20 @@ export interface CheckboxProps extends BaseProps {
51
51
  /** Value submitted with the form when checked — like a native checkbox.
52
52
  * @defaultValue "on" */
53
53
  value?: string;
54
- /** Color of the **mark** in every state — the checked-box fill *and* the
55
- * unselected box border. A named tone or any literal CSS color (`'#ff1493'`,
54
+ /** Color of the **mark**. In the default `all` scope this colors the checked-box
55
+ * fill and unselected box border. A named tone or any literal CSS color (`'#ff1493'`,
56
56
  * `'rebeccapurple'`) for a one-off custom tone. Named tones track light/dark mode
57
57
  * automatically; a custom color keeps its hue + chroma and pins lightness to the
58
- * fill curve. Use `toneSelected` instead to tone only the checked mark and leave
58
+ * fill curve. Set `toneScope="selected"` to tone only the checked mark and leave
59
59
  * the empty box neutral. The label + hint stay neutral — recolor them in plain
60
60
  * CSS via the theme-aware `--text-N-{tone}` tokens.
61
61
  * @defaultValue 'neutral' */
62
62
  tone?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
63
- /** Like `tone`, but colored onto the **checked mark only** — the empty box stays
64
- * neutral grey until it's checked. Prefer this over `tone` when a resting tinted
65
- * border would read as a validation state. Same value set as `tone`; if both are
66
- * set, `tone` governs the off-state border and `toneSelected` the checked fill.
67
- * @defaultValue 'neutral' */
68
- toneSelected?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
63
+ /** Apply `tone` to every state, or only while checked so the empty box stays
64
+ * neutral. `selected` is useful when a tinted resting border would read as a
65
+ * validation state.
66
+ * @defaultValue 'all' */
67
+ toneScope?: ToneScope;
69
68
  /** Size variant. small=14px, medium=16px, large=18px box.
70
69
  * @defaultValue 'medium' */
71
70
  size?: 'small' | 'medium' | 'large';
@@ -98,5 +97,5 @@ export interface CheckboxProps extends BaseProps {
98
97
  * <Checkbox defaultChecked label="Remember me" hint="On this device" />
99
98
  * ```
100
99
  */
101
- export declare const Checkbox: ({ checked, defaultChecked, disabled, tone, toneSelected, size, round, onStateChange, onChange, onValueChange, label, hint, className, style, children, tabIndex, ...rest }: CheckboxProps) => any;
100
+ export declare const Checkbox: ({ checked, defaultChecked, disabled, tone, toneScope, size, round, onStateChange, onChange, onValueChange, label, hint, className, style, children, tabIndex, ...rest }: CheckboxProps) => any;
102
101
  export {};
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { nativeStateChange, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
2
+ import { nativeStateChange, neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
3
  const valueToState = (v) => v === "indeterminate" ? "indeterminate" : v ? "checked" : "unchecked";
4
4
  const stateToValue = (s) => s === "indeterminate" ? "indeterminate" : s === "checked";
5
5
  const checkboxAttrsOf = (el) => ({
@@ -13,7 +13,7 @@ const Checkbox = ({
13
13
  defaultChecked,
14
14
  disabled,
15
15
  tone,
16
- toneSelected,
16
+ toneScope,
17
17
  size,
18
18
  round,
19
19
  onStateChange,
@@ -30,15 +30,7 @@ const Checkbox = ({
30
30
  const computedStyle = roundStyle(
31
31
  round,
32
32
  "--checkbox-round",
33
- toneStyle(
34
- toneSelected,
35
- "--checkbox-tone-source",
36
- toneStyle(
37
- tone,
38
- "--checkbox-off-tone-source",
39
- toneSelected == null ? toneStyle(tone, "--checkbox-tone-source", style) : style
40
- )
41
- )
33
+ toneStyle(tone, "--checkbox-tone-source", toneStyle(tone, "--checkbox-off-tone-source", style))
42
34
  );
43
35
  const explicitAriaLabel = rest["aria-label"];
44
36
  const ariaLabel = (typeof explicitAriaLabel === "string" ? explicitAriaLabel : void 0) ?? label ?? (typeof children === "string" ? children : void 0);
@@ -67,8 +59,8 @@ const Checkbox = ({
67
59
  state: stateAttr,
68
60
  "default-state": defaultStateAttr,
69
61
  disabled: disabled ? "" : void 0,
70
- tone: tone && tone !== "neutral" ? tone : void 0,
71
- "tone-selected": toneSelected || void 0,
62
+ tone: neutralToneAttr(tone),
63
+ "tone-scope": toneScope && toneScope !== "all" ? toneScope : void 0,
72
64
  size: size && size !== "medium" ? size : void 0,
73
65
  round: roundAttr(round),
74
66
  tabIndex: disabled ? -1 : tabIndex ?? 0,
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { nativeStateChange, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
2
+ import { nativeStateChange, neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
3
  const Expander = ({
4
4
  title,
5
5
  level,
@@ -26,7 +26,7 @@ const Expander = ({
26
26
  state: controlled ? open ? "open" : "closed" : void 0,
27
27
  "default-state": !controlled && defaultOpen ? "open" : void 0,
28
28
  level: level != null ? String(level) : void 0,
29
- tone: tone && tone !== "neutral" ? tone : void 0,
29
+ tone: neutralToneAttr(tone),
30
30
  priority: priority && priority !== "secondary" ? priority : void 0,
31
31
  outdent: outdent ? "" : void 0,
32
32
  round: roundAttr(round),
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { nativeStateChange, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
2
+ import { nativeStateChange, neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
3
  import { Button } from "./Button";
4
4
  import { Icon } from "./Icon";
5
5
  const presence = (on) => on ? "" : void 0;
@@ -91,7 +91,7 @@ const Input = ({
91
91
  rows: rows != null ? String(rows) : void 0,
92
92
  maxrows: maxRows != null ? String(maxRows) : void 0,
93
93
  status: statusTone,
94
- tone: tone || void 0,
94
+ tone: neutralToneAttr(tone),
95
95
  type: !multiline && rows == null ? nativeType : void 0,
96
96
  name,
97
97
  placeholder,
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { nativeStateChange, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
2
+ import { nativeStateChange, neutralToneAttr, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
3
3
  import { Button } from "./Button";
4
4
  import { Icon } from "./Icon";
5
5
  const presence = (on) => on ? "" : void 0;
@@ -65,7 +65,7 @@ const InputTime = ({
65
65
  min,
66
66
  max,
67
67
  status: statusTone,
68
- tone: tone || void 0,
68
+ tone: neutralToneAttr(tone),
69
69
  name,
70
70
  disabled: presence(disabled),
71
71
  required: presence(required),
@@ -1,4 +1,5 @@
1
1
  import { jsx } from "@antadesign/anta/jsx-runtime";
2
+ import { neutralToneAttr } from "../anta_helpers";
2
3
  const Loader = ({ tone, value, max = 100, size, speed, label, className, style, ...rest }) => {
3
4
  const determinate = typeof value === "number" && Number.isFinite(value);
4
5
  const safeMax = Number.isFinite(max) && max > 0 ? max : 100;
@@ -20,7 +21,7 @@ const Loader = ({ tone, value, max = 100, size, speed, label, className, style,
20
21
  return /* @__PURE__ */ jsx(
21
22
  "a-loader",
22
23
  {
23
- tone,
24
+ tone: neutralToneAttr(tone),
24
25
  ...determinate ? { value: clampedValue } : {},
25
26
  class: className,
26
27
  style: computedStyle,
@@ -1,4 +1,4 @@
1
- import type { BaseProps } from '../general_types';
1
+ import type { BaseProps, ToneScope } from '../general_types';
2
2
  import type { IconShape } from '../elements/a-icon.shapes';
3
3
  /** Props shared by every menu item, link or not. */
4
4
  export interface MenuItemCommonProps extends BaseProps {
@@ -39,12 +39,11 @@ export interface MenuItemCommonProps extends BaseProps {
39
39
  * gray.
40
40
  * @defaultValue neutral */
41
41
  tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
42
- /** Like `tone`, but applied only while the row is `selected` — an unselected row
43
- * stays neutral. The whole selected row (label, icon, tint, and the `checkbox` /
44
- * `radio` indicator) takes the tone. Same value set as `tone`; on a selected row
45
- * `toneSelected` wins over `tone` when both are set.
46
- * @defaultValue neutral */
47
- toneSelected?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
42
+ /** Apply `tone` to every row state, or only while the row is selected. In
43
+ * `selected` scope, an unselected row and its checkbox/radio indicator stay
44
+ * neutral.
45
+ * @defaultValue 'all' */
46
+ toneScope?: ToneScope;
48
47
  /** An opaque value identifying this item, handed back in `onSelect`'s detail
49
48
  * so a shared handler can tell which row was chosen without a per-item
50
49
  * closure. */
@@ -139,4 +138,4 @@ export type MenuItemProps = MenuItemCommonProps & (MenuItemLinkMode | MenuItemAc
139
138
  * </MenuItem>
140
139
  * ```
141
140
  */
142
- export declare const MenuItem: ({ icon, label, hint, kbd, iconTrailing, disabled, selected, selectionIndicator, indeterminate, indicator, tone, toneSelected, submenu, value, onSelect, href, target, rel, download, ping, role: roleOverride, className, style, children, ...rest }: MenuItemProps) => any;
141
+ export declare const MenuItem: ({ icon, label, hint, kbd, iconTrailing, disabled, selected, selectionIndicator, indeterminate, indicator, tone, toneScope, submenu, value, onSelect, href, target, rel, download, ping, role: roleOverride, className, style, children, ...rest }: MenuItemProps) => any;
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { toneStyle } from "../anta_helpers";
2
+ import { neutralToneAttr, toneStyle } from "../anta_helpers";
3
3
  const SHORTCUT_KEYS = {
4
4
  "\u2318": "Meta",
5
5
  cmd: "Meta",
@@ -77,7 +77,7 @@ const MenuItem = ({
77
77
  indeterminate,
78
78
  indicator,
79
79
  tone,
80
- toneSelected,
80
+ toneScope,
81
81
  submenu,
82
82
  value,
83
83
  onSelect,
@@ -97,8 +97,8 @@ const MenuItem = ({
97
97
  const role = selectionIndicator === "checkbox" ? "menuitemcheckbox" : selectionIndicator === "radio" || selectionIndicator === "check" ? "menuitemradio" : "menuitem";
98
98
  const ariaChecked = !checkable ? void 0 : selectionIndicator === "checkbox" && indeterminate ? "mixed" : selected ? "true" : "false";
99
99
  const keepTint = selected && (selectionIndicator === void 0 || selectionIndicator === "check");
100
- const effectiveTone = selected && toneSelected || tone;
101
- const toneAttr = effectiveTone && effectiveTone !== "neutral" ? effectiveTone : void 0;
100
+ const effectiveTone = toneScope === "selected" && !selected ? void 0 : tone;
101
+ const toneAttr = neutralToneAttr(effectiveTone);
102
102
  const declaredShortcuts = rest["aria-keyshortcuts"];
103
103
  const keyShortcuts = kbd ? shortcutLabel(kbd) : void 0;
104
104
  const kbdNode = kbd ? /* @__PURE__ */ jsx("kbd", { "aria-hidden": declaredShortcuts ?? keyShortcuts ? "true" : void 0, children: kbd }) : null;
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
- import { hasChildren, toneStyle, roundStyle, roundAttr } from "../anta_helpers";
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
5
  const numericValue = typeof value === "number" ? value : 0;
@@ -11,7 +11,7 @@ const Progress = ({ value, max = 100, tone, size, round, label, hint, className,
11
11
  {
12
12
  value: indeterminate ? false : numericValue,
13
13
  max,
14
- tone: tone && tone !== "neutral" ? tone : void 0,
14
+ tone: neutralToneAttr(tone),
15
15
  size: size && size !== "medium" ? size : void 0,
16
16
  round: roundAttr(round),
17
17
  role: "progressbar",
@@ -1,4 +1,4 @@
1
- import type { BaseProps, OptionPresentationProps } from "../general_types";
1
+ import type { BaseProps, OptionPresentationProps, ToneScope } from "../general_types";
2
2
  /** The element's `statechange` payload. `next`/`prev` are values (`null` = nothing
3
3
  * selected); `reason` distinguishes a user pick from a form reset / bfcache restore. */
4
4
  type StateReason = "user" | "reset" | "restore";
@@ -27,8 +27,8 @@ export interface RadioOption extends OptionPresentationProps {
27
27
  disabled?: boolean;
28
28
  /** Override this one option's mark tone (defaults to the group's `tone`). */
29
29
  tone?: "brand" | "neutral" | "info" | "success" | "warning" | "critical" | (string & {});
30
- /** Override this one option's `toneSelected` (defaults to the group's). */
31
- toneSelected?: "brand" | "neutral" | "info" | "success" | "warning" | "critical" | (string & {});
30
+ /** Override this option's tone scope. The group scope is inherited when omitted. */
31
+ toneScope?: ToneScope;
32
32
  /** Override this one option's size (defaults to the group's `size`). */
33
33
  size?: "small" | "medium" | "large";
34
34
  }
@@ -78,18 +78,17 @@ export interface RadioGroupProps extends Omit<BaseProps, "children" | "onChange"
78
78
  * @defaultValue 'neutral' */
79
79
  status?: "neutral" | "brand" | "info" | "success" | "warning" | "critical";
80
80
  /** Mark tone applied to every option (an option's own `tone` wins), or any literal
81
- * CSS color for a one-off custom tone. Colors the selected-ring fill + dot *and*
82
- * the unselected ring border. Named tones track light/dark mode. Use `toneSelected`
83
- * instead to tone only the selected option and leave the rest neutral. The option
81
+ * CSS color for a one-off custom tone. In the default `all` scope it colors the
82
+ * selected-ring fill + dot and the unselected ring border. Named tones track
83
+ * light/dark mode. Set `toneScope="selected"` to tone only the selected option
84
+ * and leave the rest neutral. The option
84
85
  * text stays neutral — recolor it in plain CSS via the `--text-N-{tone}` tokens.
85
86
  * @defaultValue 'neutral' */
86
87
  tone?: "brand" | "neutral" | "info" | "success" | "warning" | "critical" | (string & {});
87
- /** Like `tone`, but colored onto the **selected option only** — every unselected
88
- * ring stays neutral grey. Applied to every option (an option's own `toneSelected`
89
- * wins). Prefer this over `tone` when a resting tinted border would read as a
90
- * validation state.
91
- * @defaultValue 'neutral' */
92
- toneSelected?: "brand" | "neutral" | "info" | "success" | "warning" | "critical" | (string & {});
88
+ /** Apply `tone` to every state, or only to the selected option so unselected
89
+ * rings stay neutral. An option's own `toneScope` wins.
90
+ * @defaultValue 'all' */
91
+ toneScope?: ToneScope;
93
92
  /** Size applied to every option (an option's own `size` wins).
94
93
  * @defaultValue 'medium' */
95
94
  size?: "small" | "medium" | "large";
@@ -116,5 +115,5 @@ export interface RadioGroupProps extends Omit<BaseProps, "children" | "onChange"
116
115
  *
117
116
  * Requires `@antadesign/anta/elements` (client-side only).
118
117
  */
119
- export declare const RadioGroup: ({ options, value, defaultValue, onStateChange, onChange, onValueChange, onFocus, onBlur, name, label, hint, status, tone, toneSelected, size, disabled, orientation, className, style, ...rest }: RadioGroupProps) => any;
118
+ export declare const RadioGroup: ({ options, value, defaultValue, onStateChange, onChange, onValueChange, onFocus, onBlur, name, label, hint, status, tone, toneScope, size, disabled, orientation, className, style, ...rest }: RadioGroupProps) => any;
120
119
  export {};