@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.
- package/LICENSE.md +14 -1
- package/README.md +9 -0
- package/dist/anta_helpers.d.ts +46 -30
- package/dist/anta_helpers.js +66 -25
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +2 -1333
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- package/dist/components/Button.js +1 -0
- package/dist/components/ButtonCopy.js +3 -2
- package/dist/components/Calendar.js +13 -13
- package/dist/components/Card.d.ts +9 -17
- package/dist/components/Card.js +50 -46
- package/dist/components/Dialog.d.ts +1 -0
- package/dist/components/Dialog.js +16 -10
- package/dist/components/Expander.d.ts +6 -21
- package/dist/components/Expander.js +24 -23
- package/dist/components/Icon.d.ts +8 -14
- package/dist/components/Input.d.ts +77 -96
- package/dist/components/Input.js +23 -27
- package/dist/components/InputAutocomplete.d.ts +29 -10
- package/dist/components/InputAutocomplete.js +25 -8
- package/dist/components/InputDate.js +2 -2
- package/dist/components/InputTime.d.ts +10 -4
- package/dist/components/InputTime.js +20 -16
- package/dist/components/Loader.d.ts +2 -2
- package/dist/components/Menu.d.ts +5 -4
- package/dist/components/Menu.js +13 -8
- package/dist/components/MenuItem.js +1 -14
- package/dist/components/MenuItemCopy.js +2 -2
- package/dist/components/Panel.d.ts +3 -1
- package/dist/components/Panel.js +17 -11
- package/dist/components/Progress.d.ts +21 -23
- package/dist/components/Progress.js +13 -9
- package/dist/components/RadioGroup.js +6 -8
- package/dist/components/{select-parts.css → Select.css} +1 -1
- package/dist/components/Select.d.ts +53 -35
- package/dist/components/Select.js +53 -97
- package/dist/components/SelectFaceted.d.ts +7 -3
- package/dist/components/SelectFaceted.js +21 -9
- package/dist/components/Slider.d.ts +28 -11
- package/dist/components/Slider.js +20 -20
- package/dist/components/Steps.css +1 -1
- package/dist/components/Steps.js +1 -11
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +5 -8
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +16 -26
- package/dist/components/Title.js +2 -1
- package/dist/components/Toaster.js +9 -2
- package/dist/components/Tooltip.d.ts +10 -15
- package/dist/components/copy-props.d.ts +14 -3
- package/dist/components/copy-props.js +14 -3
- package/dist/components/select-tree.d.ts +24 -0
- package/dist/components/select-tree.js +35 -0
- package/dist/element-base.d.ts +10 -0
- package/dist/element-base.js +15 -0
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.d.ts +4 -1
- package/dist/elements/a-banner.js +22 -112
- package/dist/elements/a-button.d.ts +2 -1
- package/dist/elements/a-button.js +18 -1
- package/dist/elements/a-calendar.d.ts +14 -13
- package/dist/elements/a-calendar.js +29 -24
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-card.d.ts +0 -9
- package/dist/elements/a-card.js +0 -184
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-copy.css +1 -1
- package/dist/elements/a-copy.d.ts +1 -5
- package/dist/elements/a-copy.js +129 -108
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-dialog.d.ts +1 -1
- package/dist/elements/a-dialog.js +66 -194
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +4 -30
- package/dist/elements/a-expander.js +85 -344
- package/dist/elements/a-icon.d.ts +5 -23
- package/dist/elements/a-icon.js +1 -2
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.d.ts +2 -1
- package/dist/elements/a-input-time.js +101 -168
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +10 -8
- package/dist/elements/a-input.js +155 -230
- package/dist/elements/a-loader.d.ts +5 -8
- package/dist/elements/a-loader.js +1 -2
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.d.ts +5 -3
- package/dist/elements/a-menu-item.js +5 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +5 -7
- package/dist/elements/a-menu.js +383 -299
- package/dist/elements/a-panel.css +1 -1
- package/dist/elements/a-panel.js +19 -37
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-progress.d.ts +0 -22
- package/dist/elements/a-progress.js +0 -100
- package/dist/elements/a-radio-group.d.ts +1 -1
- package/dist/elements/a-radio-group.js +6 -4
- package/dist/elements/a-select-faceted.d.ts +1 -1
- package/dist/elements/a-select-faceted.js +1 -1
- package/dist/elements/a-select.d.ts +1 -1
- package/dist/elements/a-select.js +1 -1
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.d.ts +11 -3
- package/dist/elements/a-slider.js +244 -242
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.d.ts +1 -1
- package/dist/elements/a-tabs.js +6 -4
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-text.d.ts +6 -43
- package/dist/elements/a-text.js +110 -193
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-toast.css +1 -1
- package/dist/elements/a-toast.d.ts +10 -45
- package/dist/elements/a-toast.js +80 -66
- package/dist/elements/a-toaster.css +1 -1
- package/dist/elements/a-toaster.js +9 -44
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +1 -1
- package/dist/elements/a-tooltip.js +142 -136
- package/dist/elements/copy-behavior.d.ts +1 -1
- package/dist/elements/copy-behavior.js +21 -21
- package/dist/elements/index.d.ts +3 -3
- package/dist/elements/index.js +3 -7
- package/dist/elements/input-focus-modality.d.ts +15 -0
- package/dist/elements/input-focus-modality.js +44 -0
- package/dist/elements/input-trailing-actions.d.ts +5 -0
- package/dist/elements/input-trailing-actions.js +38 -0
- package/dist/elements/shadow-aria.d.ts +2 -0
- package/dist/elements/shadow-aria.js +2 -1
- package/dist/elements/value-input.d.ts +3 -0
- package/dist/elements/value-input.js +12 -0
- package/dist/general_types.d.ts +103 -96
- package/dist/index.d.ts +1 -1
- package/dist/input-events.d.ts +4 -0
- package/dist/input-events.js +15 -0
- package/dist/jsx-runtime.d.ts +70 -23
- package/dist/jsx-runtime.js +26 -19
- package/dist/native-event-props.d.ts +2 -0
- package/dist/native-event-props.js +10 -0
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +10 -1
- package/dist/theme-antune.css +1 -1
- package/docs/accessibility.md +17 -3
- package/docs/changelog.md +348 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- package/docs/components/button.md +22 -0
- package/docs/components/card.md +74 -28
- package/docs/components/checkbox.md +9 -10
- package/docs/components/dialog.md +83 -32
- package/docs/components/expander.md +198 -435
- package/docs/components/icon.md +11 -17
- package/docs/components/input-autocomplete.md +152 -52
- package/docs/components/input-date.md +175 -148
- package/docs/components/input-time.md +81 -38
- package/docs/components/input.md +343 -349
- package/docs/components/loader.md +2 -1
- package/docs/components/menu.md +35 -6
- package/docs/components/panel.md +18 -0
- package/docs/components/progress.md +83 -49
- package/docs/components/radio.md +39 -43
- package/docs/components/select-faceted.md +54 -7
- package/docs/components/select.md +390 -386
- package/docs/components/slider.md +136 -19
- package/docs/components/steps.md +2 -1
- package/docs/components/switch.md +8 -9
- package/docs/components/tabs.md +110 -104
- package/docs/components/text.md +110 -86
- package/docs/components/title.md +47 -33
- package/docs/components/toaster.md +242 -84
- package/docs/components/tooltip.md +204 -113
- package/docs/install-config.md +183 -26
- package/docs/packages/plot.md +170 -148
- package/docs/theming.md +7 -0
- package/package.json +41 -3
- 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
|
-
*
|
|
101
|
-
*
|
|
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.
|
|
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
|
-
|
|
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 &&
|
|
83
|
-
icon !== false && /* @__PURE__ */ jsx("
|
|
84
|
-
clearable && //
|
|
85
|
-
|
|
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":
|
|
101
|
+
"data-custom-event": CLEAR_TRIGGER
|
|
98
102
|
}
|
|
99
103
|
) }),
|
|
100
|
-
trailing != null && /* @__PURE__ */ jsx("
|
|
101
|
-
hint != null && /* @__PURE__ */ jsxs("
|
|
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
|
-
*
|
|
31
|
-
*
|
|
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
|
|
43
|
-
*
|
|
44
|
-
*
|
|
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;
|
package/dist/components/Menu.js
CHANGED
|
@@ -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
|
-
|
|
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 {
|
|
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 =
|
|
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;
|
package/dist/components/Panel.js
CHANGED
|
@@ -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 }) =>
|
|
4
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
/**
|
|
4
|
-
*
|
|
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
|
-
/**
|
|
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
|
|
10
|
-
*
|
|
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
|
-
/**
|
|
18
|
-
*
|
|
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
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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
|
-
/**
|
|
26
|
-
* when custom `children`
|
|
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
|
-
*
|
|
31
|
+
* Shows task completion with a percentage, label, and optional hint.
|
|
31
32
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
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={
|
|
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
|
|
7
|
-
const
|
|
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",
|
|
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__ */
|
|
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 {
|
|
3
|
-
import {
|
|
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 [
|
|
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
|
-
|
|
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}}
|