@antadesign/anta 0.3.20 → 0.3.22
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/dist/anta_helpers.d.ts +9 -0
- package/dist/anta_helpers.js +9 -0
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +12 -5
- package/dist/components/Checkbox.js +6 -2
- package/dist/components/Input.d.ts +2 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/InputAutocomplete.js +24 -18
- package/dist/components/InputDate.js +1 -0
- package/dist/components/Menu.d.ts +6 -1
- package/dist/components/Menu.js +2 -0
- package/dist/components/RadioGroup.d.ts +2 -2
- package/dist/components/RadioGroup.js +25 -6
- package/dist/components/Select.d.ts +5 -3
- package/dist/components/Select.js +6 -1
- package/dist/components/SelectFaceted.d.ts +4 -2
- package/dist/components/SelectFaceted.js +5 -1
- package/dist/components/TabPanel.d.ts +1 -2
- package/dist/components/TabPanel.js +0 -1
- package/dist/components/Tabs.d.ts +2 -2
- package/dist/components/Tabs.js +5 -2
- package/dist/components/Text.d.ts +5 -3
- package/dist/components/Text.js +7 -3
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.js +1 -1
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.js +1 -1
- package/dist/elements/a-menu.d.ts +5 -10
- package/dist/elements/a-menu.js +123 -44
- package/dist/elements/a-radio.css +1 -1
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-text.d.ts +4 -0
- package/dist/elements/a-text.js +10 -3
- package/dist/elements/a-tooltip.d.ts +7 -0
- package/dist/elements/a-tooltip.js +87 -14
- package/dist/general_types.d.ts +17 -0
- package/dist/theme-anta.css +1 -1
- package/docs/changelog.md +45 -0
- package/docs/components/input.md +2 -2
- package/docs/components/menu.md +33 -0
- package/docs/components/radio.md +4 -0
- package/docs/components/select-faceted.md +4 -2
- package/docs/components/select.md +6 -1
- package/docs/components/text.md +27 -3
- package/docs/install-config.md +5 -0
- package/docs/theming.md +15 -0
- package/package.json +3 -8
package/dist/anta_helpers.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { IconShape } from "./elements/a-icon.shapes";
|
|
2
|
+
import type { OptionPresentationProps } from "./general_types";
|
|
2
3
|
export declare function hasChildren(children: React.ReactNode): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Select the safe presentation attributes from a data-rendered option. Option
|
|
6
|
+
* objects often carry application data, so wrappers must never spread them onto
|
|
7
|
+
* their rendered element. Menu rows also own `data-menu-*`: those attributes
|
|
8
|
+
* control closing and combobox navigation, and letting an option replace them
|
|
9
|
+
* would desynchronize its selection behavior.
|
|
10
|
+
*/
|
|
11
|
+
export declare function optionPresentationAttrs(option: OptionPresentationProps, menu?: boolean): OptionPresentationProps;
|
|
3
12
|
/**
|
|
4
13
|
* Normalize a wrapper's label content the way `Button` / `Tabs` do: a bare string
|
|
5
14
|
* or number becomes a `<tag>` — the ellipsis-capable label part (`a-button-label`,
|
package/dist/anta_helpers.js
CHANGED
|
@@ -2,6 +2,14 @@ import { jsx, useState, useMemo } from "./jsx-runtime";
|
|
|
2
2
|
function hasChildren(children) {
|
|
3
3
|
return Array.isArray(children) ? children.length > 0 : children != null;
|
|
4
4
|
}
|
|
5
|
+
function optionPresentationAttrs(option, menu = false) {
|
|
6
|
+
const attrs = {};
|
|
7
|
+
for (const [name, value] of Object.entries(option)) {
|
|
8
|
+
if (name === "className" || name === "style" || name.startsWith("data-") && (!menu || !name.startsWith("data-menu-") && name !== "data-anta-menu-item"))
|
|
9
|
+
attrs[name] = value;
|
|
10
|
+
}
|
|
11
|
+
return attrs;
|
|
12
|
+
}
|
|
5
13
|
function wrapLabel(kids, tag) {
|
|
6
14
|
if (kids == null) return kids;
|
|
7
15
|
const arr = Array.isArray(kids) ? kids : [kids];
|
|
@@ -158,6 +166,7 @@ export {
|
|
|
158
166
|
isMenuOpen,
|
|
159
167
|
lengthStyle,
|
|
160
168
|
nativeStateChange,
|
|
169
|
+
optionPresentationAttrs,
|
|
161
170
|
parseOpenState,
|
|
162
171
|
roundAttr,
|
|
163
172
|
roundStyle,
|
|
@@ -135,4 +135,4 @@ export type ButtonProps = BaseButtonProps & PriorityMode & ContentMode & SubmitM
|
|
|
135
135
|
* <Button href="/docs" target="_blank" label="Read the docs" />
|
|
136
136
|
* ```
|
|
137
137
|
*/
|
|
138
|
-
export declare const Button: ({ priority, tone, underline, icon, iconTrailing, paddingless, label, size, loading, disabled, selected, round, href, target, rel, download, ping, type, form, className, style, children, ...rest }: ButtonProps) => any;
|
|
138
|
+
export declare const Button: ({ priority, tone, underline, icon, iconTrailing, paddingless, label, size, loading, disabled, selected, round, onClick, href, target, rel, download, ping, type, form, className, style, children, ...rest }: ButtonProps) => any;
|
|
@@ -13,6 +13,7 @@ const Button = ({
|
|
|
13
13
|
disabled,
|
|
14
14
|
selected,
|
|
15
15
|
round,
|
|
16
|
+
onClick,
|
|
16
17
|
href,
|
|
17
18
|
target,
|
|
18
19
|
rel,
|
|
@@ -26,6 +27,7 @@ const Button = ({
|
|
|
26
27
|
...rest
|
|
27
28
|
}) => {
|
|
28
29
|
const toneAttr = tone || void 0;
|
|
30
|
+
const unavailable = disabled || loading;
|
|
29
31
|
const computedStyle = roundStyle(round, "--button-round", toneStyle(toneAttr, "--button-tone-source", style));
|
|
30
32
|
const isIconOnly = icon != null && label == null && children == null && iconTrailing == null;
|
|
31
33
|
const sharedAttrs = {
|
|
@@ -53,8 +55,8 @@ const Button = ({
|
|
|
53
55
|
// Disabled AND loading both leave the keyboard tab order — a loading
|
|
54
56
|
// button blocks the mouse (pointer-events), so it must block Enter/Space
|
|
55
57
|
// activation too, else the loading guard would be mouse-only.
|
|
56
|
-
tabIndex:
|
|
57
|
-
"aria-disabled":
|
|
58
|
+
tabIndex: unavailable ? -1 : 0,
|
|
59
|
+
"aria-disabled": unavailable ? "true" : void 0,
|
|
58
60
|
"aria-busy": loading ? "true" : void 0,
|
|
59
61
|
"aria-pressed": selected ? "true" : void 0,
|
|
60
62
|
// Icon-only buttons get an accessible name from the icon shape. Consumer's
|
|
@@ -62,7 +64,8 @@ const Button = ({
|
|
|
62
64
|
// ButtonCopy uses to name an icon-only copy button "Copy".
|
|
63
65
|
"aria-label": isIconOnly ? icon : void 0,
|
|
64
66
|
class: className,
|
|
65
|
-
style: computedStyle
|
|
67
|
+
style: computedStyle,
|
|
68
|
+
onClick: unavailable ? void 0 : onClick
|
|
66
69
|
};
|
|
67
70
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
68
71
|
icon && /* @__PURE__ */ jsx("a-icon", { shape: icon, "aria-hidden": "true" }),
|
|
@@ -71,16 +74,20 @@ const Button = ({
|
|
|
71
74
|
iconTrailing && /* @__PURE__ */ jsx("a-icon", { shape: iconTrailing, "aria-hidden": "true" })
|
|
72
75
|
] });
|
|
73
76
|
if (href != null) {
|
|
77
|
+
const anchorAttrs = {
|
|
78
|
+
...sharedAttrs,
|
|
79
|
+
disabled: unavailable || void 0
|
|
80
|
+
};
|
|
74
81
|
return /* @__PURE__ */ jsx(
|
|
75
82
|
"a",
|
|
76
83
|
{
|
|
77
|
-
href,
|
|
84
|
+
href: unavailable ? void 0 : href,
|
|
78
85
|
"data-anta": "",
|
|
79
86
|
target,
|
|
80
87
|
rel,
|
|
81
88
|
download,
|
|
82
89
|
ping,
|
|
83
|
-
...
|
|
90
|
+
...anchorAttrs,
|
|
84
91
|
...rest,
|
|
85
92
|
children: inner
|
|
86
93
|
}
|
|
@@ -33,7 +33,11 @@ const Checkbox = ({
|
|
|
33
33
|
toneStyle(
|
|
34
34
|
toneSelected,
|
|
35
35
|
"--checkbox-tone-source",
|
|
36
|
-
toneStyle(
|
|
36
|
+
toneStyle(
|
|
37
|
+
tone,
|
|
38
|
+
"--checkbox-off-tone-source",
|
|
39
|
+
toneSelected == null ? toneStyle(tone, "--checkbox-tone-source", style) : style
|
|
40
|
+
)
|
|
37
41
|
)
|
|
38
42
|
);
|
|
39
43
|
const explicitAriaLabel = rest["aria-label"];
|
|
@@ -64,7 +68,7 @@ const Checkbox = ({
|
|
|
64
68
|
"default-state": defaultStateAttr,
|
|
65
69
|
disabled: disabled ? "" : void 0,
|
|
66
70
|
tone: tone && tone !== "neutral" ? tone : void 0,
|
|
67
|
-
"tone-selected": toneSelected
|
|
71
|
+
"tone-selected": toneSelected || void 0,
|
|
68
72
|
size: size && size !== "medium" ? size : void 0,
|
|
69
73
|
round: roundAttr(round),
|
|
70
74
|
tabIndex: disabled ? -1 : tabIndex ?? 0,
|
|
@@ -93,7 +93,8 @@ export interface InputProps extends BaseProps, DOMEventHandlers {
|
|
|
93
93
|
/** Placeholder shown when empty. */
|
|
94
94
|
placeholder?: string;
|
|
95
95
|
/** Ellipsize an overflowing single-line value. Read-only inputs already do
|
|
96
|
-
* this;
|
|
96
|
+
* this; pass `false` when an editable field should show the full value.
|
|
97
|
+
* @defaultValue true */
|
|
97
98
|
truncate?: boolean;
|
|
98
99
|
/** Disable the field. */
|
|
99
100
|
disabled?: boolean;
|
package/dist/components/Input.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import { useState, useMemo, useId } from "../jsx-runtime";
|
|
3
|
-
import { nativeStateChange } from "../anta_helpers";
|
|
3
|
+
import { nativeStateChange, optionPresentationAttrs } from "../anta_helpers";
|
|
4
4
|
import { normalizeOpt, matchQueryRegex, matchesQuery, highlight } from "./select-options";
|
|
5
5
|
import { Input } from "./Input";
|
|
6
6
|
import { Menu } from "./Menu";
|
|
@@ -69,23 +69,29 @@ const InputAutocomplete = (props) => {
|
|
|
69
69
|
if (!next) setActiveId(null);
|
|
70
70
|
},
|
|
71
71
|
onactivedescendant: (e) => setActiveId(nativeStateChange(e).detail?.id ?? null),
|
|
72
|
-
children: visible.map((opt, i) =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
children: visible.map((opt, i) => {
|
|
73
|
+
const { className: optionClassName, style: optionStyle, ...optionAttrs } = optionPresentationAttrs(opt, true);
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
MenuItem,
|
|
76
|
+
{
|
|
77
|
+
...optionAttrs,
|
|
78
|
+
id: `${rid}-o${i}`,
|
|
79
|
+
role: "option",
|
|
80
|
+
"aria-selected": activeId === `${rid}-o${i}` ? "true" : "false",
|
|
81
|
+
icon: opt.icon,
|
|
82
|
+
label: highlight(opt.label ?? opt.value, queryRe),
|
|
83
|
+
hint: opt.hint ? highlight(opt.hint, queryRe) : opt.hint,
|
|
84
|
+
tone: opt.tone,
|
|
85
|
+
disabled: opt.disabled,
|
|
86
|
+
value: opt.value,
|
|
87
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
88
|
+
onSelect: () => pick(opt),
|
|
89
|
+
className: optionClassName,
|
|
90
|
+
style: optionStyle
|
|
91
|
+
},
|
|
92
|
+
`${rid}-${opt.value}-${i}`
|
|
93
|
+
);
|
|
94
|
+
})
|
|
89
95
|
}
|
|
90
96
|
)
|
|
91
97
|
] });
|
|
@@ -43,6 +43,11 @@ export interface MenuProps extends BaseProps {
|
|
|
43
43
|
* fully round. A `number` (px) or CSS length string tunes the container radius
|
|
44
44
|
* only — items stay full pills. */
|
|
45
45
|
round?: boolean | number | string;
|
|
46
|
+
/** Contain events so they don't bubble out of the menu to ancestor handlers
|
|
47
|
+
* (e.g. a clickable row the menu sits in). Selecting an item is always
|
|
48
|
+
* contained; this extends it to whole event types. `true` contains `click`;
|
|
49
|
+
* pass an event name or list (`"click pointerdown"`) to contain those. */
|
|
50
|
+
stopPropagation?: boolean | string | string[];
|
|
46
51
|
/** Fired before the open state changes — on open, and on every dismiss (Esc,
|
|
47
52
|
* outside-click, scroll, selecting an item). `event` is the cancelable
|
|
48
53
|
* `statechange`; `detail.next`/`detail.prev` are the requested/previous open
|
|
@@ -96,4 +101,4 @@ export interface MenuProps extends BaseProps {
|
|
|
96
101
|
* </Menu>
|
|
97
102
|
* ```
|
|
98
103
|
*/
|
|
99
|
-
export declare const Menu: ({ placement, context, coord, nohover, offset, autoWidth, inset, open, onStateChange, round, role, className, style, children, ...rest }: MenuProps) => any;
|
|
104
|
+
export declare const Menu: ({ placement, context, coord, nohover, offset, autoWidth, inset, open, onStateChange, round, stopPropagation, role, className, style, children, ...rest }: MenuProps) => any;
|
package/dist/components/Menu.js
CHANGED
|
@@ -11,6 +11,7 @@ const Menu = ({
|
|
|
11
11
|
open,
|
|
12
12
|
onStateChange,
|
|
13
13
|
round,
|
|
14
|
+
stopPropagation,
|
|
14
15
|
role = "menu",
|
|
15
16
|
className,
|
|
16
17
|
style,
|
|
@@ -36,6 +37,7 @@ const Menu = ({
|
|
|
36
37
|
});
|
|
37
38
|
} : void 0,
|
|
38
39
|
round: roundAttr(round),
|
|
40
|
+
"stop-propagation": stopPropagation === void 0 || stopPropagation === false ? void 0 : stopPropagation === true ? "" : Array.isArray(stopPropagation) ? stopPropagation.join(" ") : stopPropagation,
|
|
39
41
|
role,
|
|
40
42
|
"aria-orientation": "vertical",
|
|
41
43
|
class: className,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseProps } from "../general_types";
|
|
1
|
+
import type { BaseProps, OptionPresentationProps } 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";
|
|
@@ -15,7 +15,7 @@ export interface RadioChangeAttrs {
|
|
|
15
15
|
name?: string;
|
|
16
16
|
}
|
|
17
17
|
/** One option in a `<RadioGroup>`. The wrapper renders an `<a-radio>` per entry. */
|
|
18
|
-
export interface RadioOption {
|
|
18
|
+
export interface RadioOption extends OptionPresentationProps {
|
|
19
19
|
/** This option's identity and the value submitted when it's selected.
|
|
20
20
|
* Must be unique within the group (a dev-only warning fires on duplicates). */
|
|
21
21
|
value: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import { useId, useState } from "../jsx-runtime";
|
|
3
|
-
import { nativeStateChange, toneStyle } from "../anta_helpers";
|
|
3
|
+
import { nativeStateChange, optionPresentationAttrs, toneStyle } from "../anta_helpers";
|
|
4
4
|
const radioAttrsOf = (el) => ({
|
|
5
5
|
value: el?.value ?? null,
|
|
6
6
|
name: el?.getAttribute?.("name") ?? void 0
|
|
@@ -64,7 +64,7 @@ const RadioGroup = ({
|
|
|
64
64
|
name,
|
|
65
65
|
status: status && status !== "neutral" ? status : void 0,
|
|
66
66
|
tone: tone && tone !== "neutral" ? tone : void 0,
|
|
67
|
-
"tone-selected": toneSelected
|
|
67
|
+
"tone-selected": toneSelected || void 0,
|
|
68
68
|
size: size && size !== "medium" ? size : void 0,
|
|
69
69
|
disabled: disabled ? "" : void 0,
|
|
70
70
|
orientation: orientation && orientation !== "vertical" ? orientation : void 0,
|
|
@@ -73,24 +73,43 @@ const RadioGroup = ({
|
|
|
73
73
|
onfocusin: onFocus,
|
|
74
74
|
onfocusout: onBlur,
|
|
75
75
|
class: className,
|
|
76
|
-
style: toneStyle(
|
|
76
|
+
style: toneStyle(
|
|
77
|
+
toneSelected,
|
|
78
|
+
"--radio-tone-source",
|
|
79
|
+
toneStyle(
|
|
80
|
+
tone,
|
|
81
|
+
"--radio-off-tone-source",
|
|
82
|
+
toneSelected == null ? toneStyle(tone, "--radio-tone-source", style) : style
|
|
83
|
+
)
|
|
84
|
+
),
|
|
77
85
|
children: [
|
|
78
86
|
label && /* @__PURE__ */ jsx("a-radio-group-label", { id: labelId, children: label }),
|
|
79
87
|
hint && /* @__PURE__ */ jsx("a-radio-group-hint", { id: hintId, children: hint }),
|
|
80
88
|
/* @__PURE__ */ jsx("a-radio-list", { children: options.map((o) => {
|
|
81
89
|
const optDisabled = disabled || o.disabled;
|
|
90
|
+
const { className: optionClassName, style: optionStyle, ...optionAttrs } = optionPresentationAttrs(o);
|
|
82
91
|
return /* @__PURE__ */ jsxs(
|
|
83
92
|
"a-radio",
|
|
84
93
|
{
|
|
94
|
+
...optionAttrs,
|
|
85
95
|
role: "radio",
|
|
86
96
|
value: o.value,
|
|
87
97
|
"aria-disabled": optDisabled ? "true" : void 0,
|
|
88
98
|
tabIndex: o.value === tabStopValue ? 0 : -1,
|
|
89
|
-
tone: o.tone
|
|
90
|
-
"tone-selected": o.toneSelected
|
|
99
|
+
tone: o.tone || void 0,
|
|
100
|
+
"tone-selected": o.toneSelected || void 0,
|
|
91
101
|
size: o.size && o.size !== "medium" ? o.size : void 0,
|
|
92
102
|
disabled: o.disabled ? "" : void 0,
|
|
93
|
-
|
|
103
|
+
class: optionClassName,
|
|
104
|
+
style: toneStyle(
|
|
105
|
+
o.toneSelected,
|
|
106
|
+
"--radio-tone-source",
|
|
107
|
+
toneStyle(
|
|
108
|
+
o.tone,
|
|
109
|
+
"--radio-off-tone-source",
|
|
110
|
+
o.toneSelected == null ? toneStyle(o.tone, "--radio-tone-source", optionStyle) : optionStyle
|
|
111
|
+
)
|
|
112
|
+
),
|
|
94
113
|
children: [
|
|
95
114
|
/* @__PURE__ */ jsx("a-radio-label", { children: o.label }),
|
|
96
115
|
o.hint != null && /* @__PURE__ */ jsx("a-radio-hint", { children: o.hint })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseProps } from '../general_types';
|
|
1
|
+
import type { BaseProps, OptionPresentationProps } from '../general_types';
|
|
2
2
|
import type { IconShape } from '../elements/a-icon.shapes';
|
|
3
3
|
import { type MenuProps } from './Menu';
|
|
4
4
|
import './select-parts.css';
|
|
@@ -14,7 +14,7 @@ export type OptionValue = string | number | boolean;
|
|
|
14
14
|
*
|
|
15
15
|
* Generic in the value type `V` (defaults to `string`): `Select` infers `V` from your
|
|
16
16
|
* `options`, so `{ value: 365 }` round-trips as `number` through `onValueChange`. */
|
|
17
|
-
export interface SelectOption<V extends OptionValue = string> {
|
|
17
|
+
export interface SelectOption<V extends OptionValue = string> extends OptionPresentationProps {
|
|
18
18
|
/** The option's value (`V`) — its identity, what `value` / `defaultValue` name, and
|
|
19
19
|
* what `onValueChange` reports. Unique across the whole `options` tree (selection is
|
|
20
20
|
* value-keyed and global across groups / submenus). */
|
|
@@ -248,7 +248,9 @@ export interface SelectCommonProps<V extends OptionValue = string> extends Omit<
|
|
|
248
248
|
* one focusable element, such as an Anta `Button`. The menu is positioned
|
|
249
249
|
* relative to that element and opens when it is clicked. Do not return a
|
|
250
250
|
* fragment, multiple siblings, or a non-focusable wrapper. Add
|
|
251
|
-
* `aria-haspopup="menu"` and `aria-expanded={state.open}` to the element
|
|
251
|
+
* `aria-haspopup="menu"` and `aria-expanded={state.open}` to the element, on a
|
|
252
|
+
* role that supports them (an Anta `Button` already carries `role="button"`;
|
|
253
|
+
* otherwise add `role="combobox"`).
|
|
252
254
|
* Field props (`label`, `hint`, `size`, `status`, `placeholder`, and `round`) and
|
|
253
255
|
* `className` / `style` apply only to the default field. Add styling and
|
|
254
256
|
* attributes to the returned element instead. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import { useState, useId } from "../jsx-runtime";
|
|
3
|
-
import { ISOLATE_HINT } from "../anta_helpers";
|
|
3
|
+
import { ISOLATE_HINT, optionPresentationAttrs } from "../anta_helpers";
|
|
4
4
|
import { normalizeOpt, matchQueryRegex, matchesQuery, highlight } from "./select-options";
|
|
5
5
|
import { Input } from "./Input";
|
|
6
6
|
import { Icon } from "./Icon";
|
|
@@ -164,6 +164,7 @@ const Select = (props) => {
|
|
|
164
164
|
emit?.(next, { all: true, selected: false });
|
|
165
165
|
};
|
|
166
166
|
const renderOptionRow = (o, disabled2) => {
|
|
167
|
+
const { className: optionClassName, style: optionStyle, ...optionAttrs } = optionPresentationAttrs(o, true);
|
|
167
168
|
const optState = { value: o.value, selected: isSelected(o.value), disabled: disabled2 };
|
|
168
169
|
const custom = renderOption?.(o, optState);
|
|
169
170
|
const customMark = renderIndicator?.(optState);
|
|
@@ -174,6 +175,7 @@ const Select = (props) => {
|
|
|
174
175
|
return /* @__PURE__ */ jsxs(
|
|
175
176
|
MenuItem,
|
|
176
177
|
{
|
|
178
|
+
...optionAttrs,
|
|
177
179
|
id: `${uid}-opt-${o.value}`,
|
|
178
180
|
selectionIndicator: menuItemIndicator,
|
|
179
181
|
...ariaSelectable,
|
|
@@ -187,6 +189,8 @@ const Select = (props) => {
|
|
|
187
189
|
disabled: disabled2 || void 0,
|
|
188
190
|
"data-menu-open": multiple ? "" : void 0,
|
|
189
191
|
onSelect: (e) => choose(o, e),
|
|
192
|
+
className: optionClassName,
|
|
193
|
+
style: optionStyle,
|
|
190
194
|
children: [
|
|
191
195
|
custom,
|
|
192
196
|
tip && /* @__PURE__ */ jsx(Tooltip, { follow: true, ...hintOnly ? { delay: 700 } : {}, children: tip })
|
|
@@ -266,6 +270,7 @@ const Select = (props) => {
|
|
|
266
270
|
status,
|
|
267
271
|
statusIcon,
|
|
268
272
|
round,
|
|
273
|
+
role: "combobox",
|
|
269
274
|
"aria-haspopup": "menu",
|
|
270
275
|
"aria-expanded": open ? "true" : "false",
|
|
271
276
|
trailing: (
|
|
@@ -165,8 +165,10 @@ export interface SelectFacetedProps extends Omit<BaseProps, 'children'> {
|
|
|
165
165
|
* Receives a `SelectFacetedTriggerState`. Return exactly one focusable element:
|
|
166
166
|
* the menu is positioned relative to that element and opens when it is clicked.
|
|
167
167
|
* Add `aria-haspopup="menu"` and `aria-expanded={state.open}` to the returned
|
|
168
|
-
* element
|
|
169
|
-
*
|
|
168
|
+
* element, on a role that supports them (an Anta `Button` already carries
|
|
169
|
+
* `role="button"`; otherwise add `role="combobox"`). `className`, `style`, and
|
|
170
|
+
* other trigger props apply only to the default Button, so add styling and
|
|
171
|
+
* attributes to the returned element. */
|
|
170
172
|
renderTrigger?: (state: SelectFacetedTriggerState) => React.ReactNode;
|
|
171
173
|
}
|
|
172
174
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import { useState, useMemo } from "../jsx-runtime";
|
|
3
|
-
import { nativeStateChange, ISOLATE_HINT } from "../anta_helpers";
|
|
3
|
+
import { nativeStateChange, ISOLATE_HINT, optionPresentationAttrs } from "../anta_helpers";
|
|
4
4
|
import { normalizeOpt, matchQueryRegex, matchesQuery } from "./select-options";
|
|
5
5
|
import { Button } from "./Button";
|
|
6
6
|
import { Menu } from "./Menu";
|
|
@@ -118,13 +118,17 @@ const SelectFaceted = (props) => {
|
|
|
118
118
|
}
|
|
119
119
|
) }) : null;
|
|
120
120
|
const optionRow = (facet, opt, keyPrefix = "") => {
|
|
121
|
+
const { className: optionClassName, style: optionStyle, ...optionAttrs } = optionPresentationAttrs(opt, true);
|
|
121
122
|
const shared = {
|
|
123
|
+
...optionAttrs,
|
|
122
124
|
icon: opt.icon,
|
|
123
125
|
label: opt.label ?? String(opt.value),
|
|
124
126
|
hint: opt.hint,
|
|
125
127
|
tone: opt.tone,
|
|
126
128
|
toneSelected,
|
|
127
129
|
disabled: opt.disabled,
|
|
130
|
+
className: optionClassName,
|
|
131
|
+
style: optionStyle,
|
|
128
132
|
"data-menu-open": ""
|
|
129
133
|
};
|
|
130
134
|
if (facet.kind === "single") {
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* finds its `<a-tabs>` (its flat sibling under the same parent — `Tabs` renders the
|
|
4
4
|
* strip and panels with no wrapper), matches by `value`, and shows/hides itself
|
|
5
5
|
* off-DOM. This wrapper is a pure projection: it sets the static ARIA (`role`,
|
|
6
|
-
* `
|
|
7
|
-
* or toggles it.
|
|
6
|
+
* `value`) and passes `children` straight through; `Tabs` never reads or toggles it.
|
|
8
7
|
*
|
|
9
8
|
* Use it as a direct child of `<Tabs>`, paired to an `options` entry by `value`.
|
|
10
9
|
* For a strip and panels in different layout regions (no shared parent), or to
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseProps } from "../general_types";
|
|
1
|
+
import type { BaseProps, OptionPresentationProps } from "../general_types";
|
|
2
2
|
import type { IconShape } from "../elements/a-icon.shapes";
|
|
3
3
|
/** The element's `statechange` payload — `next`/`prev` are tab values (`null` = none). */
|
|
4
4
|
type StateDetail = {
|
|
@@ -14,7 +14,7 @@ export interface TabsChangeAttrs {
|
|
|
14
14
|
* renders its strip from (like `RadioGroup`'s `options`). `Tabs` reads these fields to
|
|
15
15
|
* render the underlying `<a-tab>` (`tabindex`, `role`, and selection are all `Tabs`'
|
|
16
16
|
* job, published off-DOM by the element). */
|
|
17
|
-
export interface TabOption {
|
|
17
|
+
export interface TabOption extends OptionPresentationProps {
|
|
18
18
|
/** This tab's identity — pairs it with the `<TabPanel value="…">` of the same
|
|
19
19
|
* value, and the value reported by `onStateChange` / `onChange`. Unique per strip. */
|
|
20
20
|
value: string;
|
package/dist/components/Tabs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import { useState } from "../jsx-runtime";
|
|
3
|
-
import { nativeStateChange, toneStyle, roundStyle, roundAttr, wrapLabel } from "../anta_helpers";
|
|
3
|
+
import { nativeStateChange, optionPresentationAttrs, toneStyle, roundStyle, roundAttr, wrapLabel } from "../anta_helpers";
|
|
4
4
|
import { Tooltip } from "./Tooltip";
|
|
5
5
|
const Tabs = ({
|
|
6
6
|
children,
|
|
@@ -75,17 +75,20 @@ const Tabs = ({
|
|
|
75
75
|
children: tabs.map((p) => {
|
|
76
76
|
const tabDisabled = disabled || p.disabled;
|
|
77
77
|
const isSelected = p.value === currentValue;
|
|
78
|
+
const { className: optionClassName, style: optionStyle, ...optionAttrs } = optionPresentationAttrs(p);
|
|
78
79
|
return /* @__PURE__ */ jsxs(
|
|
79
80
|
"a-tab",
|
|
80
81
|
{
|
|
82
|
+
...optionAttrs,
|
|
81
83
|
role: "tab",
|
|
82
84
|
value: p.value,
|
|
83
85
|
tone: p.tone && p.tone !== "neutral" ? p.tone : void 0,
|
|
84
|
-
style: toneStyle(p.tone, "--tabs-tone-source", void 0),
|
|
85
86
|
"aria-disabled": tabDisabled ? "true" : void 0,
|
|
86
87
|
tabIndex: tabDisabled && !isSelected ? -1 : 0,
|
|
87
88
|
disabled: tabDisabled ? "" : void 0,
|
|
88
89
|
round: roundAttr(round) ?? roundAttr(p.round),
|
|
90
|
+
class: optionClassName,
|
|
91
|
+
style: toneStyle(p.tone, "--tabs-tone-source", optionStyle),
|
|
89
92
|
children: [
|
|
90
93
|
p.icon && /* @__PURE__ */ jsx("a-icon", { shape: p.icon, "aria-hidden": "true" }),
|
|
91
94
|
wrapLabel(p.label != null ? p.label : p.children, "a-tab-label"),
|
|
@@ -36,9 +36,11 @@ export type TextProps = BaseProps & {
|
|
|
36
36
|
inline?: boolean;
|
|
37
37
|
/** Truncate with a trailing ellipsis. `true` (or `1`) clamps to a
|
|
38
38
|
* single line; any integer ≥ 2 clamps to that many lines; `0` or a
|
|
39
|
-
* negative value means no truncation.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* negative value means no truncation. A clipped, non-expandable JSX
|
|
40
|
+
* `Text` shows its text content in a tooltip by default. Nest a
|
|
41
|
+
* `<Tooltip>` to provide your own tooltip instead. Uses the
|
|
42
|
+
* `-webkit-line-clamp` technique, supported in all major browsers
|
|
43
|
+
* (Firefox 68+, Chrome, Safari, Edge). */
|
|
42
44
|
truncate?: boolean | number;
|
|
43
45
|
} & ExpandMode;
|
|
44
46
|
/**
|
package/dist/components/Text.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import { toneStyle } from "../anta_helpers";
|
|
3
|
+
import { Tooltip } from "./Tooltip";
|
|
3
4
|
const Text = ({ priority, tone, size, inline, truncate, expandable, collapsible, className, style, children, ...rest }) => {
|
|
4
5
|
const n = typeof truncate === "number" ? truncate : truncate ? 1 : null;
|
|
5
6
|
const lineCount = n != null && n >= 1 ? n : null;
|
|
@@ -10,7 +11,7 @@ const Text = ({ priority, tone, size, inline, truncate, expandable, collapsible,
|
|
|
10
11
|
lineCount != null ? { ...style, ["--line-clamp"]: lineCount } : style
|
|
11
12
|
);
|
|
12
13
|
const canExpand = expandable && lineCount != null;
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
14
15
|
"a-text",
|
|
15
16
|
{
|
|
16
17
|
priority,
|
|
@@ -23,7 +24,10 @@ const Text = ({ priority, tone, size, inline, truncate, expandable, collapsible,
|
|
|
23
24
|
class: className,
|
|
24
25
|
style: computedStyle,
|
|
25
26
|
...rest,
|
|
26
|
-
children
|
|
27
|
+
children: [
|
|
28
|
+
children,
|
|
29
|
+
lineCount != null && !canExpand && /* @__PURE__ */ jsx(Tooltip, { truncatedOnly: true, "data-anta-text-tooltip": "" })
|
|
30
|
+
]
|
|
27
31
|
}
|
|
28
32
|
);
|
|
29
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta{a-checkbox{--checkbox-gap: 8px;--checkbox-box-size: 16px;--checkbox-bg: var(--bg-1);--checkbox-tone-source: var(--anta-seed-neutral);--_tone-l-rest: .6;--_tone-l-hover: .45;--_tone-l-active: .4;--checkbox-bg-selected: oklch(from var(--checkbox-tone-source) var(--_tone-l-rest) c h);--checkbox-bg-selected-hover: oklch(from var(--checkbox-tone-source) var(--_tone-l-hover) c h);--checkbox-bg-selected-active: oklch(from var(--checkbox-tone-source) var(--_tone-l-active) c h);--checkbox-border-neutral: var(--border-3);--checkbox-border: var(--checkbox-border-neutral);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-icon: #f6f4f6;--checkbox-icon-disabled: #c1b9c1;--checkbox-bg-disabled: color-mix(in oklch, #44374b 10%, transparent);--checkbox-border-disabled: color-mix(in oklch, #44374b 10%, transparent);--checkbox-mask-size: 12px;--checkbox-mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");--checkbox-mask-indeterminate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");--checkbox-label-color: var(--text-2);--checkbox-label-color-disabled: var(--text-4);--checkbox-hint-color: var(--text-3);--checkbox-label-fs: 15px;--checkbox-label-lh: 20px;--checkbox-hint-fs: 13px;--checkbox-hint-lh: 16px;display:inline-grid;grid-template-columns:auto 1fr;align-items:start;column-gap:var(--checkbox-gap);vertical-align:middle;cursor:pointer;user-select:none;-webkit-user-drag:none;outline:none;color:var(--checkbox-label-color);font-family:var(--sans-serif);font-size:var(--checkbox-label-fs);line-height:var(--checkbox-label-lh);font-feature-settings:"ss02","ss05","tnum";&:before{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);box-sizing:border-box;inline-size:16px;block-size:16px;border-radius:4px;background:var(--checkbox-bg);border:1.5px solid var(--checkbox-border);transition:background-color .15s ease-out,border-color .15s ease-out}&[round]{--checkbox-round: attr(round type(<length>), 999px)}&[round]:before{border-radius:var(--checkbox-round, 999px)}&:after{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);inline-size:16px;block-size:16px;background-color:transparent;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:var(--checkbox-mask-size);mask-size:var(--checkbox-mask-size)}@media(hover:hover)and (pointer:fine){&:not(:disabled):hover:before{border-color:var(--checkbox-border-hover);transition:background-color 75ms ease-in,border-color 75ms ease-in}&:not(:disabled):hover:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-hover);border-color:var(--checkbox-bg-selected-hover)}}&:not(:disabled):active:before{border-color:var(--checkbox-border-active);transition:background-color 50ms linear,border-color 50ms linear}&:not(:disabled):active:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-active);border-color:var(--checkbox-bg-selected-active)}&:is(:state(checked),:state(indeterminate)){&:before{background:var(--checkbox-bg-selected);border-color:var(--checkbox-bg-selected)}&:after{background-color:var(--checkbox-icon)}}&:state(checked):after{-webkit-mask-image:var(--checkbox-mask-check);mask-image:var(--checkbox-mask-check)}&:state(indeterminate):after{-webkit-mask-image:var(--checkbox-mask-indeterminate);mask-image:var(--checkbox-mask-indeterminate)}&:focus-visible:before{outline:1px solid var(--focus-ring);outline-offset:1px}&:disabled{cursor:not-allowed;color:var(--checkbox-label-color-disabled);&:before{background:var(--checkbox-bg-disabled);border-color:var(--checkbox-border-disabled);transition:none}&:is(:state(checked),:state(indeterminate)):after{background-color:var(--checkbox-icon-disabled)}a-checkbox-hint{color:var(--checkbox-label-color-disabled)}}&[size=small]{--checkbox-gap: 6px;--checkbox-box-size: 14px;--checkbox-label-fs: 13px;--checkbox-label-lh: 16px;--checkbox-hint-fs: 12px;--checkbox-hint-lh: 14px;--checkbox-mask-size: 10px;&:before,&:after{inline-size:14px;block-size:14px}}&[size=large]{--checkbox-box-size: 18px;--checkbox-label-fs: 17px;--checkbox-label-lh: 22px;--checkbox-hint-fs: 15px;--checkbox-hint-lh: 19px;--checkbox-mask-size: 14px;&:before,&:after{inline-size:18px;block-size:18px}}}.dark a-checkbox{--checkbox-mask-size: 13px}.dark a-checkbox[size=small]{--checkbox-mask-size: 11px}.dark a-checkbox[size=large]{--checkbox-mask-size: 15px}a-checkbox-label,a-checkbox-hint{display:block;grid-column:2;min-width:0}a-checkbox-hint{color:var(--checkbox-hint-color);font-size:var(--checkbox-hint-fs);line-height:var(--checkbox-hint-lh);margin-block-start:2px}a-checkbox[tone]:not([tone=""],[tone=neutral]),a-checkbox[tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_tone-l-rest: .5;--_tone-l-hover: .45;--_tone-l-active: .4}a-checkbox[tone=brand],a-checkbox[tone-selected=brand]{--checkbox-tone-source: var(--anta-seed-brand)}a-checkbox[tone=info],a-checkbox[tone-selected=info]{--checkbox-tone-source: var(--anta-seed-info)}a-checkbox[tone=success],a-checkbox[tone-selected=success]{--checkbox-tone-source: var(--anta-seed-success)}a-checkbox[tone=warning],a-checkbox[tone-selected=warning]{--checkbox-tone-source: var(--anta-seed-warning)}a-checkbox[tone=critical],a-checkbox[tone-selected=critical]{--checkbox-tone-source: var(--anta-seed-critical)}a-checkbox[tone=neutral],a-checkbox[tone-selected=neutral]{--checkbox-tone-source: var(--anta-seed-neutral)}a-checkbox[tone]:not([tone=""],[tone=neutral]){--checkbox-bg: oklch(from var(--checkbox-tone-source) .99 calc(c*.03) h);--_checkbox-border-base: color-mix(in oklch, var(--checkbox-bg-selected) 70%, var(--checkbox-border-neutral));--checkbox-border: oklch(from var(--_checkbox-border-base) calc(l + .17) c h);--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: var(--_checkbox-border-base)}a-checkbox[tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--checkbox-tone-source: attr(tone type(<color>), transparent)}a-checkbox[tone-selected]:not([tone-selected=""],[tone-selected=brand],[tone-selected=neutral],[tone-selected=info],[tone-selected=success],[tone-selected=warning],[tone-selected=critical]){--checkbox-tone-source: attr(tone-selected type(<color>), transparent)}.dark a-checkbox{--checkbox-border-neutral: var(--border-3);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-icon: #ece9ec;--checkbox-icon-disabled: #534c57;--checkbox-bg-disabled: color-mix(in oklch, #e4d1ef 10%, transparent);--checkbox-border-disabled: color-mix(in oklch, #e4d1ef 10%, transparent);--_tone-l-rest: .42;--_tone-l-hover: .45;--_tone-l-active: .5}.dark a-checkbox[tone]:not([tone=""],[tone=neutral]),.dark a-checkbox[tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_tone-l-rest: .45;--_tone-l-hover: .5;--_tone-l-active: .57}.dark a-checkbox[tone]:not([tone=""],[tone=neutral]){--checkbox-bg: oklch(from var(--checkbox-tone-source) .15 calc(c*.18) h);--checkbox-border: var(--_checkbox-border-base);--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: oklch(from var(--_checkbox-border-base) calc(l + .17) c h)}label:has(>input[data-anta][type=checkbox]){display:inline-flex;align-items:center;gap:8px;color:var(--text-2);font-family:var(--sans-serif);font-feature-settings:"ss02","ss05","tnum";font-size:15px;line-height:20px}input[data-anta][type=checkbox]{--native-choice-size: 16px;--native-choice-mark-size: 12px;--native-choice-round: 4px;--native-choice-bg: var(--bg-1);--native-choice-border-neutral: var(--border-3);--native-choice-border: var(--native-choice-border-neutral);--native-choice-border-hover: var(--border-2);--native-choice-border-active: var(--border-1);--native-choice-tone-source: var(--anta-seed-neutral);--_native-choice-l-rest: .6;--_native-choice-l-hover: .45;--_native-choice-l-active: .4;--native-choice-selected: oklch(from var(--native-choice-tone-source) var(--_native-choice-l-rest) c h);--native-choice-selected-hover: oklch(from var(--native-choice-tone-source) var(--_native-choice-l-hover) c h);--native-choice-selected-active: oklch(from var(--native-choice-tone-source) var(--_native-choice-l-active) c h);box-sizing:border-box;flex:0 0 var(--native-choice-size);inline-size:var(--native-choice-size);block-size:var(--native-choice-size);margin:0;appearance:none;-webkit-appearance:none;border:1.5px solid var(--native-choice-border);border-radius:var(--native-choice-round);background-color:var(--native-choice-bg);background-repeat:no-repeat;background-position:center;background-size:var(--native-choice-mark-size);cursor:pointer;vertical-align:middle;transition:background-color .15s ease-out,border-color .15s ease-out}label:has(>input[data-anta][type=checkbox][size=small]){gap:6px;font-size:13px;line-height:16px}label:has(>input[data-anta][type=checkbox][size=large]){font-size:17px;line-height:22px}input[data-anta][type=checkbox][size=small]{--native-choice-size: 14px;--native-choice-mark-size: 10px}input[data-anta][type=checkbox][size=large]{--native-choice-size: 18px;--native-choice-mark-size: 14px}input[data-anta][type=checkbox][round]{--native-choice-round: attr(round type(<length>), 999px)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]),input[data-anta][type=checkbox][tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_native-choice-l-rest: .5;--_native-choice-l-hover: .45;--_native-choice-l-active: .4}input[data-anta][type=checkbox][tone=brand],input[data-anta][type=checkbox][tone-selected=brand]{--native-choice-tone-source: var(--anta-seed-brand)}input[data-anta][type=checkbox][tone=info],input[data-anta][type=checkbox][tone-selected=info]{--native-choice-tone-source: var(--anta-seed-info)}input[data-anta][type=checkbox][tone=success],input[data-anta][type=checkbox][tone-selected=success]{--native-choice-tone-source: var(--anta-seed-success)}input[data-anta][type=checkbox][tone=warning],input[data-anta][type=checkbox][tone-selected=warning]{--native-choice-tone-source: var(--anta-seed-warning)}input[data-anta][type=checkbox][tone=critical],input[data-anta][type=checkbox][tone-selected=critical]{--native-choice-tone-source: var(--anta-seed-critical)}input[data-anta][type=checkbox][tone=neutral],input[data-anta][type=checkbox][tone-selected=neutral]{--native-choice-tone-source: var(--anta-seed-neutral)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]){--native-choice-bg: oklch(from var(--native-choice-tone-source) .99 calc(c*.03) h);--_native-choice-border-base: color-mix(in oklch, var(--native-choice-selected) 70%, var(--native-choice-border-neutral));--native-choice-border: oklch(from var(--_native-choice-border-base) calc(l + .17) c h);--native-choice-border-hover: oklch(from var(--_native-choice-border-base) calc(l + .1) c h);--native-choice-border-active: var(--_native-choice-border-base)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--native-choice-tone-source: attr(tone type(<color>), var(--anta-seed-neutral))}input[data-anta][type=checkbox][tone-selected]:not([tone-selected=""],[tone-selected=brand],[tone-selected=neutral],[tone-selected=info],[tone-selected=success],[tone-selected=warning],[tone-selected=critical]){--native-choice-tone-source: attr(tone-selected type(<color>), var(--anta-seed-neutral))}@media(hover:hover)and (pointer:fine){input[data-anta][type=checkbox]:not(:disabled):hover{border-color:var(--native-choice-border-hover)}input[data-anta][type=checkbox]:not(:disabled):hover:is(:checked,:indeterminate){background-color:var(--native-choice-selected-hover);border-color:var(--native-choice-selected-hover)}}input[data-anta][type=checkbox]:not(:disabled):active{border-color:var(--native-choice-border-active)}input[data-anta][type=checkbox]:not(:disabled):active:is(:checked,:indeterminate){background-color:var(--native-choice-selected-active);border-color:var(--native-choice-selected-active)}input[data-anta][type=checkbox]:is(:checked,:indeterminate){background-color:var(--native-choice-selected);border-color:var(--native-choice-selected)}input[data-anta][type=checkbox]:checked{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:indeterminate{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}input[data-anta][type=checkbox]:disabled{border-color:color-mix(in oklch,var(--text-1) 10%,transparent);background-color:color-mix(in oklch,var(--text-1) 10%,transparent);cursor:not-allowed}input[data-anta][type=checkbox]:disabled:is(:checked,:indeterminate){background-color:color-mix(in oklch,var(--text-1) 10%,transparent)}.dark input[data-anta][type=checkbox]{--_native-choice-l-rest: .42;--_native-choice-l-hover: .45;--_native-choice-l-active: .5}.dark input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]),.dark input[data-anta][type=checkbox][tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_native-choice-l-rest: .45;--_native-choice-l-hover: .5;--_native-choice-l-active: .57}.dark input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]){--native-choice-bg: oklch(from var(--native-choice-tone-source) .15 calc(c*.18) h);--native-choice-border: var(--_native-choice-border-base);--native-choice-border-hover: oklch(from var(--_native-choice-border-base) calc(l + .1) c h);--native-choice-border-active: oklch(from var(--_native-choice-border-base) calc(l + .17) c h)}@media(forced-colors:active){a-checkbox:is(:state(checked),:state(indeterminate)):before{forced-color-adjust:none;background-color:Highlight;border-color:Highlight}a-checkbox:is(:state(checked),:state(indeterminate)):after{forced-color-adjust:none;background-color:HighlightText}a-checkbox:disabled:before{background-color:Canvas;border-color:GrayText}a-checkbox:disabled:is(:state(checked),:state(indeterminate)):after{background-color:GrayText}}}
|
|
1
|
+
@layer anta{a-checkbox{--checkbox-gap: 8px;--checkbox-box-size: 16px;--checkbox-bg: var(--bg-1);--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral);--_tone-l-rest: .6;--_tone-l-hover: .45;--_tone-l-active: .4;--checkbox-bg-selected: oklch(from var(--checkbox-tone-source) var(--_tone-l-rest) c h);--checkbox-bg-selected-hover: oklch(from var(--checkbox-tone-source) var(--_tone-l-hover) c h);--checkbox-bg-selected-active: oklch(from var(--checkbox-tone-source) var(--_tone-l-active) c h);--checkbox-border-neutral: var(--border-3);--checkbox-border: var(--checkbox-border-neutral);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-icon: #f6f4f6;--checkbox-icon-disabled: #c1b9c1;--checkbox-bg-disabled: color-mix(in oklch, #44374b 10%, transparent);--checkbox-border-disabled: color-mix(in oklch, #44374b 10%, transparent);--checkbox-mask-size: 12px;--checkbox-mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");--checkbox-mask-indeterminate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");--checkbox-label-color: var(--text-2);--checkbox-label-color-disabled: var(--text-4);--checkbox-hint-color: var(--text-3);--checkbox-label-fs: 15px;--checkbox-label-lh: 20px;--checkbox-hint-fs: 13px;--checkbox-hint-lh: 16px;display:inline-grid;grid-template-columns:auto 1fr;align-items:start;column-gap:var(--checkbox-gap);vertical-align:middle;cursor:pointer;user-select:none;-webkit-user-drag:none;outline:none;color:var(--checkbox-label-color);font-family:var(--sans-serif);font-size:var(--checkbox-label-fs);line-height:var(--checkbox-label-lh);font-feature-settings:"ss02","ss05","tnum";&:before{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);box-sizing:border-box;inline-size:16px;block-size:16px;border-radius:4px;background:var(--checkbox-bg);border:1.5px solid var(--checkbox-border);transition:background-color .15s ease-out,border-color .15s ease-out}&[round]{--checkbox-round: attr(round type(<length>), 999px)}&[round]:before{border-radius:var(--checkbox-round, 999px)}&:after{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);inline-size:16px;block-size:16px;background-color:transparent;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:var(--checkbox-mask-size);mask-size:var(--checkbox-mask-size)}@media(hover:hover)and (pointer:fine){&:not(:disabled):hover:before{border-color:var(--checkbox-border-hover);transition:background-color 75ms ease-in,border-color 75ms ease-in}&:not(:disabled):hover:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-hover);border-color:var(--checkbox-bg-selected-hover)}}&:not(:disabled):active:before{border-color:var(--checkbox-border-active);transition:background-color 50ms linear,border-color 50ms linear}&:not(:disabled):active:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-active);border-color:var(--checkbox-bg-selected-active)}&:is(:state(checked),:state(indeterminate)){&:before{background:var(--checkbox-bg-selected);border-color:var(--checkbox-bg-selected)}&:after{background-color:var(--checkbox-icon)}}&:state(checked):after{-webkit-mask-image:var(--checkbox-mask-check);mask-image:var(--checkbox-mask-check)}&:state(indeterminate):after{-webkit-mask-image:var(--checkbox-mask-indeterminate);mask-image:var(--checkbox-mask-indeterminate)}&:focus-visible{outline:none}&:focus-visible:before{outline:1px solid var(--focus-ring);outline-offset:1px}&:disabled{cursor:not-allowed;color:var(--checkbox-label-color-disabled);&:before{background:var(--checkbox-bg-disabled);border-color:var(--checkbox-border-disabled);transition:none}&:is(:state(checked),:state(indeterminate)):after{background-color:var(--checkbox-icon-disabled)}a-checkbox-hint{color:var(--checkbox-label-color-disabled)}}&[size=small]{--checkbox-gap: 6px;--checkbox-box-size: 14px;--checkbox-label-fs: 13px;--checkbox-label-lh: 16px;--checkbox-hint-fs: 12px;--checkbox-hint-lh: 14px;--checkbox-mask-size: 10px;&:before,&:after{inline-size:14px;block-size:14px}}&[size=large]{--checkbox-box-size: 18px;--checkbox-label-fs: 17px;--checkbox-label-lh: 22px;--checkbox-hint-fs: 15px;--checkbox-hint-lh: 19px;--checkbox-mask-size: 14px;&:before,&:after{inline-size:18px;block-size:18px}}}.dark a-checkbox{--checkbox-mask-size: 13px}.dark a-checkbox[size=small]{--checkbox-mask-size: 11px}.dark a-checkbox[size=large]{--checkbox-mask-size: 15px}a-checkbox-label,a-checkbox-hint{display:block;grid-column:2;min-width:0}a-checkbox-hint{color:var(--checkbox-hint-color);font-size:var(--checkbox-hint-fs);line-height:var(--checkbox-hint-lh);margin-block-start:2px}a-checkbox[tone]:not([tone=""],[tone=neutral]),a-checkbox[tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_tone-l-rest: .5;--_tone-l-hover: .45;--_tone-l-active: .4}a-checkbox[tone=brand]{--checkbox-tone-source: var(--anta-seed-brand);--checkbox-off-tone-source: var(--anta-seed-brand)}a-checkbox[tone=info]{--checkbox-tone-source: var(--anta-seed-info);--checkbox-off-tone-source: var(--anta-seed-info)}a-checkbox[tone=success]{--checkbox-tone-source: var(--anta-seed-success);--checkbox-off-tone-source: var(--anta-seed-success)}a-checkbox[tone=warning]{--checkbox-tone-source: var(--anta-seed-warning);--checkbox-off-tone-source: var(--anta-seed-warning)}a-checkbox[tone=critical]{--checkbox-tone-source: var(--anta-seed-critical);--checkbox-off-tone-source: var(--anta-seed-critical)}a-checkbox[tone=neutral]{--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral)}a-checkbox[tone]:not([tone=""],[tone=neutral]){--checkbox-bg: oklch(from var(--checkbox-off-tone-source) .99 calc(c*.03) h);--_checkbox-off-bg-selected: oklch(from var(--checkbox-off-tone-source) var(--_tone-l-rest) c h);--_checkbox-border-base: color-mix(in oklch, var(--_checkbox-off-bg-selected) 70%, var(--checkbox-border-neutral));--checkbox-border: oklch(from var(--_checkbox-border-base) calc(l + .17) c h);--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: var(--_checkbox-border-base)}a-checkbox[tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--checkbox-tone-source: attr(tone type(<color>), transparent);--checkbox-off-tone-source: attr(tone type(<color>), transparent)}a-checkbox[tone-selected=brand]{--checkbox-tone-source: var(--anta-seed-brand)}a-checkbox[tone-selected=info]{--checkbox-tone-source: var(--anta-seed-info)}a-checkbox[tone-selected=success]{--checkbox-tone-source: var(--anta-seed-success)}a-checkbox[tone-selected=warning]{--checkbox-tone-source: var(--anta-seed-warning)}a-checkbox[tone-selected=critical]{--checkbox-tone-source: var(--anta-seed-critical)}a-checkbox[tone-selected=neutral]{--checkbox-tone-source: var(--anta-seed-neutral);--_tone-l-rest: .6;--_tone-l-hover: .45;--_tone-l-active: .4}a-checkbox[tone-selected]:not([tone-selected=""],[tone-selected=brand],[tone-selected=neutral],[tone-selected=info],[tone-selected=success],[tone-selected=warning],[tone-selected=critical]){--checkbox-tone-source: attr(tone-selected type(<color>), transparent)}.dark a-checkbox{--checkbox-border-neutral: var(--border-3);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-icon: #ece9ec;--checkbox-icon-disabled: #534c57;--checkbox-bg-disabled: color-mix(in oklch, #e4d1ef 10%, transparent);--checkbox-border-disabled: color-mix(in oklch, #e4d1ef 10%, transparent);--_tone-l-rest: .42;--_tone-l-hover: .45;--_tone-l-active: .5}.dark a-checkbox[tone]:not([tone=""],[tone=neutral]),.dark a-checkbox[tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_tone-l-rest: .45;--_tone-l-hover: .5;--_tone-l-active: .57}.dark a-checkbox[tone]:not([tone=""],[tone=neutral]){--checkbox-bg: oklch(from var(--checkbox-off-tone-source) .15 calc(c*.18) h);--checkbox-border: var(--_checkbox-border-base);--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: oklch(from var(--_checkbox-border-base) calc(l + .17) c h)}.dark a-checkbox[tone-selected=neutral]{--_tone-l-rest: .42;--_tone-l-hover: .45;--_tone-l-active: .5}label:has(>input[data-anta][type=checkbox]){display:inline-flex;align-items:center;gap:8px;color:var(--text-2);font-family:var(--sans-serif);font-feature-settings:"ss02","ss05","tnum";font-size:15px;line-height:20px}input[data-anta][type=checkbox]{--native-choice-size: 16px;--native-choice-mark-size: 12px;--native-choice-round: 4px;--native-choice-bg: var(--bg-1);--native-choice-border-neutral: var(--border-3);--native-choice-border: var(--native-choice-border-neutral);--native-choice-border-hover: var(--border-2);--native-choice-border-active: var(--border-1);--native-choice-tone-source: var(--anta-seed-neutral);--native-choice-off-tone-source: var(--anta-seed-neutral);--_native-choice-l-rest: .6;--_native-choice-l-hover: .45;--_native-choice-l-active: .4;--native-choice-selected: oklch(from var(--native-choice-tone-source) var(--_native-choice-l-rest) c h);--native-choice-selected-hover: oklch(from var(--native-choice-tone-source) var(--_native-choice-l-hover) c h);--native-choice-selected-active: oklch(from var(--native-choice-tone-source) var(--_native-choice-l-active) c h);box-sizing:border-box;flex:0 0 var(--native-choice-size);inline-size:var(--native-choice-size);block-size:var(--native-choice-size);margin:0;appearance:none;-webkit-appearance:none;border:1.5px solid var(--native-choice-border);border-radius:var(--native-choice-round);background-color:var(--native-choice-bg);background-repeat:no-repeat;background-position:center;background-size:var(--native-choice-mark-size);cursor:pointer;vertical-align:middle;transition:background-color .15s ease-out,border-color .15s ease-out}label:has(>input[data-anta][type=checkbox][size=small]){gap:6px;font-size:13px;line-height:16px}label:has(>input[data-anta][type=checkbox][size=large]){font-size:17px;line-height:22px}input[data-anta][type=checkbox][size=small]{--native-choice-size: 14px;--native-choice-mark-size: 10px}input[data-anta][type=checkbox][size=large]{--native-choice-size: 18px;--native-choice-mark-size: 14px}input[data-anta][type=checkbox][round]{--native-choice-round: attr(round type(<length>), 999px)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]),input[data-anta][type=checkbox][tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_native-choice-l-rest: .5;--_native-choice-l-hover: .45;--_native-choice-l-active: .4}input[data-anta][type=checkbox][tone=brand]{--native-choice-tone-source: var(--anta-seed-brand);--native-choice-off-tone-source: var(--anta-seed-brand)}input[data-anta][type=checkbox][tone=info]{--native-choice-tone-source: var(--anta-seed-info);--native-choice-off-tone-source: var(--anta-seed-info)}input[data-anta][type=checkbox][tone=success]{--native-choice-tone-source: var(--anta-seed-success);--native-choice-off-tone-source: var(--anta-seed-success)}input[data-anta][type=checkbox][tone=warning]{--native-choice-tone-source: var(--anta-seed-warning);--native-choice-off-tone-source: var(--anta-seed-warning)}input[data-anta][type=checkbox][tone=critical]{--native-choice-tone-source: var(--anta-seed-critical);--native-choice-off-tone-source: var(--anta-seed-critical)}input[data-anta][type=checkbox][tone=neutral]{--native-choice-tone-source: var(--anta-seed-neutral);--native-choice-off-tone-source: var(--anta-seed-neutral)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]){--native-choice-bg: oklch(from var(--native-choice-off-tone-source) .99 calc(c*.03) h);--_native-choice-off-selected: oklch(from var(--native-choice-off-tone-source) var(--_native-choice-l-rest) c h);--_native-choice-border-base: color-mix(in oklch, var(--_native-choice-off-selected) 70%, var(--native-choice-border-neutral));--native-choice-border: oklch(from var(--_native-choice-border-base) calc(l + .17) c h);--native-choice-border-hover: oklch(from var(--_native-choice-border-base) calc(l + .1) c h);--native-choice-border-active: var(--_native-choice-border-base)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--native-choice-tone-source: attr(tone type(<color>), var(--anta-seed-neutral));--native-choice-off-tone-source: attr(tone type(<color>), var(--anta-seed-neutral))}input[data-anta][type=checkbox][tone-selected=brand]{--native-choice-tone-source: var(--anta-seed-brand)}input[data-anta][type=checkbox][tone-selected=info]{--native-choice-tone-source: var(--anta-seed-info)}input[data-anta][type=checkbox][tone-selected=success]{--native-choice-tone-source: var(--anta-seed-success)}input[data-anta][type=checkbox][tone-selected=warning]{--native-choice-tone-source: var(--anta-seed-warning)}input[data-anta][type=checkbox][tone-selected=critical]{--native-choice-tone-source: var(--anta-seed-critical)}input[data-anta][type=checkbox][tone-selected=neutral]{--native-choice-tone-source: var(--anta-seed-neutral);--_native-choice-l-rest: .6;--_native-choice-l-hover: .45;--_native-choice-l-active: .4}input[data-anta][type=checkbox][tone-selected]:not([tone-selected=""],[tone-selected=brand],[tone-selected=neutral],[tone-selected=info],[tone-selected=success],[tone-selected=warning],[tone-selected=critical]){--native-choice-tone-source: attr(tone-selected type(<color>), var(--anta-seed-neutral))}@media(hover:hover)and (pointer:fine){input[data-anta][type=checkbox]:not(:disabled):hover{border-color:var(--native-choice-border-hover)}input[data-anta][type=checkbox]:not(:disabled):hover:is(:checked,:indeterminate){background-color:var(--native-choice-selected-hover);border-color:var(--native-choice-selected-hover)}}input[data-anta][type=checkbox]:not(:disabled):active{border-color:var(--native-choice-border-active)}input[data-anta][type=checkbox]:not(:disabled):active:is(:checked,:indeterminate){background-color:var(--native-choice-selected-active);border-color:var(--native-choice-selected-active)}input[data-anta][type=checkbox]:is(:checked,:indeterminate){background-color:var(--native-choice-selected);border-color:var(--native-choice-selected)}input[data-anta][type=checkbox]:checked{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:indeterminate{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}input[data-anta][type=checkbox]:disabled{border-color:color-mix(in oklch,var(--text-1) 10%,transparent);background-color:color-mix(in oklch,var(--text-1) 10%,transparent);cursor:not-allowed}input[data-anta][type=checkbox]:disabled:is(:checked,:indeterminate){background-color:color-mix(in oklch,var(--text-1) 10%,transparent)}.dark input[data-anta][type=checkbox]{--_native-choice-l-rest: .42;--_native-choice-l-hover: .45;--_native-choice-l-active: .5}.dark input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]),.dark input[data-anta][type=checkbox][tone-selected]:not([tone-selected=""],[tone-selected=neutral]){--_native-choice-l-rest: .45;--_native-choice-l-hover: .5;--_native-choice-l-active: .57}.dark input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]){--native-choice-bg: oklch(from var(--native-choice-off-tone-source) .15 calc(c*.18) h);--native-choice-border: var(--_native-choice-border-base);--native-choice-border-hover: oklch(from var(--_native-choice-border-base) calc(l + .1) c h);--native-choice-border-active: oklch(from var(--_native-choice-border-base) calc(l + .17) c h)}.dark input[data-anta][type=checkbox][tone-selected=neutral]{--_native-choice-l-rest: .42;--_native-choice-l-hover: .45;--_native-choice-l-active: .5}@media(forced-colors:active){a-checkbox:is(:state(checked),:state(indeterminate)):before{forced-color-adjust:none;background-color:Highlight;border-color:Highlight}a-checkbox:is(:state(checked),:state(indeterminate)):after{forced-color-adjust:none;background-color:HighlightText}a-checkbox:disabled:before{background-color:Canvas;border-color:GrayText}a-checkbox:disabled:is(:state(checked),:state(indeterminate)):after{background-color:GrayText}}}
|