@antadesign/anta 0.3.28 → 0.3.30
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/NOTICES.md +32 -1
- package/dist/anta_helpers.d.ts +21 -0
- package/dist/anta_helpers.js +24 -0
- package/dist/box-observation.d.ts +8 -0
- package/dist/box-observation.js +41 -0
- package/dist/box-types.d.ts +2 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +66 -29
- package/dist/components/Box.d.ts +28 -12
- package/dist/components/Box.js +18 -11
- package/dist/components/Breadcrumbs.css +1 -1
- package/dist/components/Breadcrumbs.d.ts +1 -1
- package/dist/components/Button.d.ts +3 -3
- package/dist/components/ButtonCopy.d.ts +1 -1
- package/dist/components/Calendar.js +3 -5
- package/dist/components/Checkbox.d.ts +2 -2
- package/dist/components/Input.d.ts +8 -2
- package/dist/components/Input.js +4 -0
- package/dist/components/InputAutocomplete.js +3 -12
- package/dist/components/InputDate.css +1 -1
- package/dist/components/InputDate.js +2 -0
- package/dist/components/Menu.d.ts +4 -4
- package/dist/components/Menu.js +1 -1
- package/dist/components/Panel.d.ts +17 -0
- package/dist/components/Panel.js +22 -0
- package/dist/components/RadioGroup.d.ts +2 -1
- package/dist/components/Select.d.ts +14 -14
- package/dist/components/Select.js +47 -35
- package/dist/components/SelectFaceted.d.ts +17 -6
- package/dist/components/SelectFaceted.js +61 -41
- package/dist/components/Steps.css +1 -1
- package/dist/components/Switch.d.ts +3 -3
- package/dist/components/TabPanel.d.ts +3 -8
- package/dist/components/TabPanel.js +2 -1
- package/dist/components/Tabs.d.ts +2 -2
- package/dist/components/Tabs.js +2 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/select-parts.css +1 -1
- package/dist/elements/a-avatar.css +1 -1
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-box.css +1 -1
- package/dist/elements/a-box.d.ts +6 -6
- package/dist/elements/a-box.js +76 -23
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-button.d.ts +9 -1
- package/dist/elements/a-button.js +64 -1
- package/dist/elements/a-calendar.css +1 -1
- package/dist/elements/a-capture.css +1 -1
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-checkbox.d.ts +3 -0
- package/dist/elements/a-checkbox.js +17 -1
- package/dist/elements/a-copy.css +1 -1
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-icon.css +1 -1
- package/dist/elements/a-icon.shapes.css +1 -1
- package/dist/elements/a-icon.shapes.d.ts +1 -1
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.d.ts +8 -0
- package/dist/elements/a-input-time.js +115 -8
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +27 -1
- package/dist/elements/a-input.js +176 -35
- package/dist/elements/a-loader.css +1 -1
- package/dist/elements/a-menu-group.css +1 -1
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.js +1 -0
- package/dist/elements/a-menu-separator.css +1 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +8 -13
- package/dist/elements/a-menu.js +146 -45
- package/dist/elements/a-panel.css +1 -0
- package/dist/elements/a-panel.d.ts +16 -0
- package/dist/elements/a-panel.js +153 -0
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-radio-group.css +1 -1
- package/dist/elements/a-radio.css +1 -1
- package/dist/elements/a-radio.d.ts +4 -0
- package/dist/elements/a-radio.js +18 -0
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.d.ts +1 -0
- package/dist/elements/a-slider.js +3 -3
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-switch.d.ts +3 -0
- package/dist/elements/a-switch.js +17 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabpanel.css +1 -1
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-toast.css +1 -1
- package/dist/elements/a-toaster.css +1 -1
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.js +30 -7
- package/dist/elements/focus.d.ts +9 -0
- package/dist/elements/focus.js +41 -0
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/elements/panel-focus.d.ts +10 -0
- package/dist/elements/panel-focus.js +86 -0
- package/dist/elements/shadow-aria.d.ts +10 -0
- package/dist/elements/shadow-aria.js +155 -0
- package/dist/general_types.d.ts +48 -19
- package/dist/generate-icons.mjs +3 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/dist/jsx-runtime.d.ts +20 -1
- package/dist/jsx-runtime.js +12 -0
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +1 -1
- package/dist/theme-antune.css +1 -1
- package/dist/toaster.d.ts +1 -1
- package/dist/tokens.css +1 -1
- package/docs/accessibility.md +4 -2
- package/docs/changelog.md +89 -4
- package/docs/colors.md +6 -6
- package/docs/components/box.md +98 -34
- package/docs/components/breadcrumbs.md +33 -0
- package/docs/components/button.md +2 -2
- package/docs/components/capture.md +8 -8
- package/docs/components/checkbox.md +9 -4
- package/docs/components/input-autocomplete.md +6 -0
- package/docs/components/input-date.md +8 -2
- package/docs/components/input.md +99 -40
- package/docs/components/menu.md +3 -3
- package/docs/components/panel.md +189 -0
- package/docs/components/radio.md +4 -2
- package/docs/components/select-faceted.md +57 -2
- package/docs/components/select.md +63 -51
- package/docs/components/steps.md +4 -4
- package/docs/components/switch.md +12 -6
- package/docs/components/tabs.md +21 -8
- package/docs/components/tooltip.md +6 -4
- package/docs/index.md +2 -0
- package/docs/install-config.md +5 -4
- package/docs/normalization.md +3 -1
- package/docs/packages/plot.md +3771 -0
- package/docs/theming.md +1 -1
- package/package.json +16 -9
package/dist/components/Box.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { BoxContextChange, BoxDisplay, BoxMeasurementChange } from '../box-types';
|
|
1
|
+
import type { BoxContextChange, BoxDisplay, BoxMeasurementChange, BoxObservation } from '../box-types';
|
|
2
2
|
import type { BaseProps } from '../general_types';
|
|
3
3
|
/** JSX props for the observing light-DOM `<a-box>` container. */
|
|
4
4
|
export interface BoxProps extends BaseProps {
|
|
5
|
-
/** Layout model for the host.
|
|
6
|
-
*
|
|
5
|
+
/** Layout model for the host. Sizing, alignment, mask, and shadow properties
|
|
6
|
+
* stay ordinary `className` / `style` CSS on the Box itself.
|
|
7
7
|
* @defaultValue block */
|
|
8
8
|
display?: BoxDisplay;
|
|
9
9
|
/** Fully-round corners (`border-radius: 999px`, clamped to the box). Pass a
|
|
@@ -14,12 +14,28 @@ export interface BoxProps extends BaseProps {
|
|
|
14
14
|
* pixels; a string is any CSS length or two-value gap (`'1rem'`,
|
|
15
15
|
* `'8px 16px'`). Applies while the Box is a flex or grid container. */
|
|
16
16
|
gap?: number | string;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* `
|
|
22
|
-
|
|
17
|
+
/** Inner spacing, matching CSS `padding`. Numbers are pixels; strings accept
|
|
18
|
+
* CSS shorthand, percentages, and custom properties. Omission adds no style. */
|
|
19
|
+
padding?: number | string;
|
|
20
|
+
/** Outer spacing, matching CSS `margin`. Numbers are pixels; strings accept
|
|
21
|
+
* CSS shorthand, `auto`, negative lengths, and custom properties.
|
|
22
|
+
* Omission adds no style. */
|
|
23
|
+
margin?: number | string;
|
|
24
|
+
/** One selection or an array of selections, in any order. `'size'` watches width
|
|
25
|
+
* and height; `'context'` watches rendering context; `'overflow'` watches
|
|
26
|
+
* content dimensions and clipping. `'edges'` reports which edges hide content;
|
|
27
|
+
* `'scroll'` reports offsets, potentially every frame; `'all'` selects everything.
|
|
28
|
+
* Selections are independent: use `['size', 'edges']` to combine them.
|
|
29
|
+
* A measurement handler implies `'size'` when no measurement is selected;
|
|
30
|
+
* a context handler adds `'context'`. Size skips content and scroll observers;
|
|
31
|
+
* overflow adds content observation; hidden edges and scroll add scroll reads.
|
|
32
|
+
* Without handlers or `fade`, omission stays idle. */
|
|
33
|
+
observe?: BoxObservation | readonly BoxObservation[];
|
|
34
|
+
/** Minimum interval between measurement events, in milliseconds. The first
|
|
35
|
+
* report has no added delay; a trailing report delivers the latest values.
|
|
36
|
+
* Active observers and CSS clipping states are not throttled.
|
|
37
|
+
* @defaultValue 0 */
|
|
38
|
+
throttle?: number;
|
|
23
39
|
/** Fades out every edge that currently hides clipped content, and drops the
|
|
24
40
|
* fade from an edge once the reader scrolls to it. */
|
|
25
41
|
fade?: boolean;
|
|
@@ -27,8 +43,8 @@ export interface BoxProps extends BaseProps {
|
|
|
27
43
|
* length.
|
|
28
44
|
* @defaultValue 24 */
|
|
29
45
|
fadeSize?: number | string;
|
|
30
|
-
/** Fired
|
|
31
|
-
*
|
|
46
|
+
/** Fired when a selected measurement field changes. `detail` contains all
|
|
47
|
+
* fields changed since the last event and a full current snapshot. */
|
|
32
48
|
onMeasureChange?: (event: CustomEvent<BoxMeasurementChange>, detail: BoxMeasurementChange) => void;
|
|
33
49
|
/** Fired after Box's browser and local rendering context changes. `detail`
|
|
34
50
|
* contains the changed fields and a full current snapshot. */
|
|
@@ -49,4 +65,4 @@ export interface BoxProps extends BaseProps {
|
|
|
49
65
|
* </Box>
|
|
50
66
|
* ```
|
|
51
67
|
*/
|
|
52
|
-
export declare const Box: ({ display, round, gap, observe, fade, fadeSize, onMeasureChange, onContextChange, className, style, children, ...rest }: BoxProps) => any;
|
|
68
|
+
export declare const Box: ({ display, round, gap, padding, margin, observe, throttle, fade, fadeSize, onMeasureChange, onContextChange, className, style, children, ...rest }: BoxProps) => any;
|
package/dist/components/Box.js
CHANGED
|
@@ -6,19 +6,22 @@ import {
|
|
|
6
6
|
roundAttr,
|
|
7
7
|
roundStyle
|
|
8
8
|
} from "../anta_helpers";
|
|
9
|
+
import { boxObservation } from "../box-observation";
|
|
9
10
|
function observeAttr(observe, onMeasureChange, onContextChange) {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
return void 0;
|
|
11
|
+
const tokens = [...new Set(observe == null ? [] : typeof observe === "string" ? [observe] : observe)];
|
|
12
|
+
const { fields, context } = boxObservation(tokens.join(" ") || null);
|
|
13
|
+
if (onMeasureChange != null && fields.size === 0) tokens.push("size");
|
|
14
|
+
if (onContextChange != null && !context) tokens.push("context");
|
|
15
|
+
return tokens.join(" ") || void 0;
|
|
16
16
|
}
|
|
17
17
|
const Box = ({
|
|
18
18
|
display,
|
|
19
19
|
round,
|
|
20
20
|
gap,
|
|
21
|
+
padding,
|
|
22
|
+
margin,
|
|
21
23
|
observe,
|
|
24
|
+
throttle,
|
|
22
25
|
fade,
|
|
23
26
|
fadeSize,
|
|
24
27
|
onMeasureChange,
|
|
@@ -28,23 +31,27 @@ const Box = ({
|
|
|
28
31
|
children,
|
|
29
32
|
...rest
|
|
30
33
|
}) => {
|
|
34
|
+
let boxStyle = roundStyle(round, "--box-round", style);
|
|
35
|
+
boxStyle = lengthStyle(gap, "--box-gap", boxStyle);
|
|
36
|
+
boxStyle = lengthStyle(padding, "--box-padding", boxStyle);
|
|
37
|
+
boxStyle = lengthStyle(margin, "--box-margin", boxStyle);
|
|
38
|
+
boxStyle = lengthStyle(fade ? fadeSize : void 0, "--box-fade-size", boxStyle);
|
|
31
39
|
return /* @__PURE__ */ jsx(
|
|
32
40
|
"a-box",
|
|
33
41
|
{
|
|
34
42
|
display: display === "block" ? void 0 : display,
|
|
35
43
|
round: roundAttr(round),
|
|
36
44
|
gap: gap != null ? "" : void 0,
|
|
45
|
+
padding: padding != null ? "" : void 0,
|
|
46
|
+
margin: margin != null ? "" : void 0,
|
|
37
47
|
observe: observeAttr(observe, onMeasureChange, onContextChange),
|
|
48
|
+
throttle,
|
|
38
49
|
fade: fade ? "" : void 0,
|
|
39
50
|
"fade-size": fade && fadeSize != null ? cssLength(fadeSize) : void 0,
|
|
40
51
|
onmeasurechange: customEventHandler(onMeasureChange),
|
|
41
52
|
oncontextchange: customEventHandler(onContextChange),
|
|
42
53
|
class: className,
|
|
43
|
-
style:
|
|
44
|
-
fade ? fadeSize : void 0,
|
|
45
|
-
"--box-fade-size",
|
|
46
|
-
lengthStyle(gap, "--box-gap", roundStyle(round, "--box-round", style))
|
|
47
|
-
),
|
|
54
|
+
style: boxStyle,
|
|
48
55
|
...rest,
|
|
49
56
|
children
|
|
50
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta.components{a-breadcrumbs{--breadcrumb-gap: 1px;--breadcrumb-separator-color: var(--text-5);--breadcrumb-separator-icon-size: 16px;--breadcrumb-separator-font-size: 15px;display:flex;align-items:center;gap:var(--breadcrumb-gap);width:max-content;min-width:100%;max-width:100
|
|
1
|
+
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-breadcrumbs{--breadcrumb-gap: 1px;--breadcrumb-separator-color: var(--text-5);--breadcrumb-separator-icon-size: 16px;--breadcrumb-separator-font-size: 15px;display:flex;align-items:center;gap:var(--breadcrumb-gap);width:max-content;min-width:100%;max-width:100%}a-breadcrumbs[data-size=small]{--breadcrumb-separator-icon-size: 14px;--breadcrumb-separator-font-size: 13px}a-breadcrumbs[data-size=large]{--breadcrumb-separator-icon-size: 18px;--breadcrumb-separator-font-size: 17px}a-breadcrumbs[data-paddingless]{--breadcrumb-gap: .75ch}a-breadcrumbs[data-separator-icon]{--breadcrumb-gap: 0}a-breadcrumbs>*{flex:none}a-breadcrumb-separator{display:inline-flex;flex:none;align-items:center;justify-content:center;color:var(--breadcrumb-separator-color);font-family:var(--sans-serif);font-size:var(--breadcrumb-separator-font-size);line-height:1;user-select:none}a-breadcrumb-separator>a-icon{--icon-size: var(--breadcrumb-separator-icon-size)}}
|
|
@@ -123,5 +123,5 @@ export type BreadcrumbsProps = BaseProps & {
|
|
|
123
123
|
* />
|
|
124
124
|
* ```
|
|
125
125
|
*/
|
|
126
|
-
export declare const Breadcrumbs: ({ items, priority, size, separator, maxItems, itemsBeforeCollapse, moreLabel, underline, underlineOnHover, paddingless, className, style,
|
|
126
|
+
export declare const Breadcrumbs: ({ items, priority, size, separator, maxItems, itemsBeforeCollapse, moreLabel, underline, underlineOnHover, paddingless, className, style, 'aria-label': ariaLabel, ...rest }: BreadcrumbsProps) => any;
|
|
127
127
|
export {};
|
|
@@ -113,14 +113,14 @@ export type PriorityMode = {
|
|
|
113
113
|
underline?: never;
|
|
114
114
|
underlineOnHover?: never;
|
|
115
115
|
paddingless?: never;
|
|
116
|
-
} | UnderlineMode & {
|
|
116
|
+
} | (UnderlineMode & {
|
|
117
117
|
priority: 'tertiary';
|
|
118
118
|
paddingless?: never;
|
|
119
|
-
} | UnderlineMode & {
|
|
119
|
+
}) | (UnderlineMode & {
|
|
120
120
|
priority: 'quaternary';
|
|
121
121
|
/** Drops outer padding to zero. */
|
|
122
122
|
paddingless?: boolean;
|
|
123
|
-
};
|
|
123
|
+
});
|
|
124
124
|
export type ButtonProps = BaseButtonProps & PriorityMode & ContentMode & SubmitMode & BaseProps;
|
|
125
125
|
/**
|
|
126
126
|
* Action button.
|
|
@@ -56,4 +56,4 @@ export type ButtonCopyProps = ButtonProps & {
|
|
|
56
56
|
* <ButtonCopy copyUrl label="Copy link" /> // copies location.href
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
export declare const ButtonCopy: ({ icon, iconPlacement, copiedLabel, tone, onCopied, onCopyRequest, copy, copyNode, copyUrl, copyWithUrl, label, children,
|
|
59
|
+
export declare const ButtonCopy: ({ icon, iconPlacement, copiedLabel, tone, onCopied, onCopyRequest, copy, copyNode, copyUrl, copyWithUrl, label, children, 'aria-label': ariaLabel, ...rest }: ButtonCopyProps) => any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import cn from "clsx";
|
|
3
3
|
import { Temporal } from "temporal-polyfill";
|
|
4
|
-
import {
|
|
4
|
+
import { useMemo, useState } from "../jsx-runtime";
|
|
5
5
|
import { nativeStateChange } from "../anta_helpers";
|
|
6
6
|
import { Button } from "./Button";
|
|
7
7
|
import { Menu } from "./Menu";
|
|
@@ -50,7 +50,6 @@ const Calendar = ({
|
|
|
50
50
|
}
|
|
51
51
|
const [focusReq, setFocusReq] = useState(null);
|
|
52
52
|
const [jumpOpen, setJumpOpen] = useState(false);
|
|
53
|
-
const headingId = useId();
|
|
54
53
|
const month = buildMonth({ anchor: effectiveCursor, locale: resolvedLocale, min: minD, max: maxD, selected, today });
|
|
55
54
|
const cursorIso = effectiveCursor.toString();
|
|
56
55
|
const [lastFocusSignal, setLastFocusSignal] = useState(focusSignal);
|
|
@@ -154,7 +153,6 @@ const Calendar = ({
|
|
|
154
153
|
/* @__PURE__ */ jsx(
|
|
155
154
|
Button,
|
|
156
155
|
{
|
|
157
|
-
id: headingId,
|
|
158
156
|
"data-part": "heading",
|
|
159
157
|
priority: "tertiary",
|
|
160
158
|
size,
|
|
@@ -181,8 +179,7 @@ const Calendar = ({
|
|
|
181
179
|
"a-calendar",
|
|
182
180
|
{
|
|
183
181
|
role: "group",
|
|
184
|
-
"aria-
|
|
185
|
-
"aria-label": ariaLabel,
|
|
182
|
+
"aria-label": ariaLabel ?? month.heading,
|
|
186
183
|
name,
|
|
187
184
|
value: controlled ? value : void 0,
|
|
188
185
|
defaultvalue: !controlled ? defaultValue : void 0,
|
|
@@ -212,6 +209,7 @@ const Calendar = ({
|
|
|
212
209
|
disabled: disabled || d.disabled,
|
|
213
210
|
tabIndex: d.iso === cursorIso ? 0 : -1,
|
|
214
211
|
"aria-label": d.label,
|
|
212
|
+
"aria-hidden": d.outside ? "true" : void 0,
|
|
215
213
|
"aria-current": d.today ? "date" : void 0,
|
|
216
214
|
"data-part": "day-cell",
|
|
217
215
|
"data-date": d.iso,
|
|
@@ -27,8 +27,8 @@ export interface CheckboxProps extends BaseProps {
|
|
|
27
27
|
* renders first. Required unless `children` or `aria-label` is provided
|
|
28
28
|
* (a `role="checkbox"` takes its name from the author, not the markup). */
|
|
29
29
|
label?: string;
|
|
30
|
-
/** Secondary text rendered under the label
|
|
31
|
-
*
|
|
30
|
+
/** Secondary text rendered under the label and exposed as the checkbox's
|
|
31
|
+
* accessible description. Not part of the accessible name. */
|
|
32
32
|
hint?: React.ReactNode;
|
|
33
33
|
/** Controlled checked state. When provided the checkbox is controlled — it
|
|
34
34
|
* renders exactly this and never self-applies; `onStateChange` is a *request*
|
|
@@ -102,6 +102,10 @@ export interface InputProps extends BaseProps, DOMEventHandlers {
|
|
|
102
102
|
disabled?: boolean;
|
|
103
103
|
/** Make the field read-only. */
|
|
104
104
|
readOnly?: boolean;
|
|
105
|
+
/** Render the field surface with a native button as its focus target. This is
|
|
106
|
+
* available for Input-styled popup triggers; the value becomes
|
|
107
|
+
* the button text and the placeholder is shown while it is empty. */
|
|
108
|
+
button?: boolean;
|
|
105
109
|
/** Mark the field required (drives native validity). */
|
|
106
110
|
required?: boolean;
|
|
107
111
|
/** Dim the `leading` / `trailing` adornments at rest; they brighten to full
|
|
@@ -153,7 +157,9 @@ export interface InputProps extends BaseProps, DOMEventHandlers {
|
|
|
153
157
|
/** Fires when the field loses focus. */
|
|
154
158
|
onBlur?: (e: any) => void;
|
|
155
159
|
/** ARIA `role` for the field — e.g. `combobox` when the input drives a
|
|
156
|
-
* suggestion `listbox` (see `InputAutocomplete`).
|
|
160
|
+
* suggestion `listbox` (see `InputAutocomplete`). The custom element
|
|
161
|
+
* delegates it, together with standard `aria-*` props, to the focused native
|
|
162
|
+
* shadow control. Left unset by default. */
|
|
157
163
|
role?: string;
|
|
158
164
|
}
|
|
159
165
|
/**
|
|
@@ -173,4 +179,4 @@ export interface InputProps extends BaseProps, DOMEventHandlers {
|
|
|
173
179
|
* <Input label="Email" type="email" placeholder="you@example.com" clearable />
|
|
174
180
|
* ```
|
|
175
181
|
*/
|
|
176
|
-
export declare const Input: ({ label, hint, status, statusIcon, tone, size, round, value, defaultValue, multiline, rows, maxRows, clearable, leading, trailing, type, autoComplete, inputMode, autoFocus, name, placeholder, truncate, disabled, readOnly, required, dimActions, spellCheck, maxLength, minLength, pattern, min, max, step, onInput, onChange, onValueChange, onClearClick, onClearInput, children, className, style, ...rest }: InputProps) => any;
|
|
182
|
+
export declare const Input: ({ label, hint, status, statusIcon, tone, size, round, value, defaultValue, multiline, rows, maxRows, clearable, leading, trailing, type, autoComplete, inputMode, autoFocus, name, placeholder, truncate, disabled, readOnly, button, required, dimActions, spellCheck, maxLength, minLength, pattern, min, max, step, role, onInput, onChange, onValueChange, onClearClick, onClearInput, children, className, style, ...rest }: InputProps) => any;
|
package/dist/components/Input.js
CHANGED
|
@@ -55,6 +55,7 @@ const Input = ({
|
|
|
55
55
|
truncate = true,
|
|
56
56
|
disabled,
|
|
57
57
|
readOnly,
|
|
58
|
+
button,
|
|
58
59
|
required,
|
|
59
60
|
dimActions,
|
|
60
61
|
spellCheck,
|
|
@@ -64,6 +65,7 @@ const Input = ({
|
|
|
64
65
|
min,
|
|
65
66
|
max,
|
|
66
67
|
step,
|
|
68
|
+
role,
|
|
67
69
|
onInput,
|
|
68
70
|
onChange,
|
|
69
71
|
onValueChange,
|
|
@@ -98,6 +100,7 @@ const Input = ({
|
|
|
98
100
|
truncate: presence(truncate),
|
|
99
101
|
disabled: presence(disabled),
|
|
100
102
|
readonly: presence(readOnly),
|
|
103
|
+
button: presence(button),
|
|
101
104
|
required: presence(required),
|
|
102
105
|
"dim-actions": presence(dimActions),
|
|
103
106
|
autocomplete: autoComplete ?? (!multiline && rows == null && type ? AUTOCOMPLETE_BY_TYPE[type] : void 0),
|
|
@@ -111,6 +114,7 @@ const Input = ({
|
|
|
111
114
|
max,
|
|
112
115
|
step,
|
|
113
116
|
"aria-invalid": status === "critical" ? "true" : void 0,
|
|
117
|
+
role: role ?? (isSearch ? "searchbox" : void 0),
|
|
114
118
|
oninput: onInput || onValueChange ? (e) => {
|
|
115
119
|
onInput?.(e);
|
|
116
120
|
onValueChange?.(e, attrsOf(e));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
|
-
import { useState, useMemo
|
|
3
|
-
import {
|
|
2
|
+
import { useState, useMemo } from "../jsx-runtime";
|
|
3
|
+
import { 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";
|
|
@@ -15,12 +15,10 @@ const InputAutocomplete = (props) => {
|
|
|
15
15
|
filter = true,
|
|
16
16
|
...rest
|
|
17
17
|
} = props;
|
|
18
|
-
const rid = useId();
|
|
19
18
|
const controlled = value !== void 0;
|
|
20
19
|
const [internal, setInternal] = useState(defaultValue ?? "");
|
|
21
20
|
const text = controlled ? value : internal;
|
|
22
21
|
const [open, setOpen] = useState(false);
|
|
23
|
-
const [activeId, setActiveId] = useState(null);
|
|
24
22
|
const options = useMemo(() => suggestions.map(normalizeOpt), [suggestions]);
|
|
25
23
|
const custom = typeof filter === "function";
|
|
26
24
|
const queryRe = filter !== false && !custom ? matchQueryRegex(text) : null;
|
|
@@ -44,10 +42,8 @@ const InputAutocomplete = (props) => {
|
|
|
44
42
|
"data-menu-search": "",
|
|
45
43
|
role: "combobox",
|
|
46
44
|
"aria-haspopup": "listbox",
|
|
47
|
-
"aria-controls": `${rid}-list`,
|
|
48
45
|
"aria-expanded": menuOpen ? "true" : "false",
|
|
49
46
|
"aria-autocomplete": "list",
|
|
50
|
-
"aria-activedescendant": menuOpen && activeId ? activeId : void 0,
|
|
51
47
|
onFocus: () => setOpen(true),
|
|
52
48
|
onInput: (e) => {
|
|
53
49
|
setText(e.currentTarget.value);
|
|
@@ -61,23 +57,18 @@ const InputAutocomplete = (props) => {
|
|
|
61
57
|
/* @__PURE__ */ jsx(
|
|
62
58
|
Menu,
|
|
63
59
|
{
|
|
64
|
-
id: `${rid}-list`,
|
|
65
60
|
role: "listbox",
|
|
66
61
|
open: menuOpen,
|
|
67
62
|
onStateChange: (_e, { next }) => {
|
|
68
63
|
setOpen(next);
|
|
69
|
-
if (!next) setActiveId(null);
|
|
70
64
|
},
|
|
71
|
-
onactivedescendant: (e) => setActiveId(nativeStateChange(e).detail?.id ?? null),
|
|
72
65
|
children: visible.map((opt, i) => {
|
|
73
66
|
const { className: optionClassName, style: optionStyle, ...optionAttrs } = optionPresentationAttrs(opt, true);
|
|
74
67
|
return /* @__PURE__ */ jsx(
|
|
75
68
|
MenuItem,
|
|
76
69
|
{
|
|
77
70
|
...optionAttrs,
|
|
78
|
-
id: `${rid}-o${i}`,
|
|
79
71
|
role: "option",
|
|
80
|
-
"aria-selected": activeId === `${rid}-o${i}` ? "true" : "false",
|
|
81
72
|
icon: opt.icon,
|
|
82
73
|
label: highlight(opt.label ?? opt.value, queryRe),
|
|
83
74
|
hint: opt.hint ? highlight(opt.hint, queryRe) : opt.hint,
|
|
@@ -89,7 +80,7 @@ const InputAutocomplete = (props) => {
|
|
|
89
80
|
className: optionClassName,
|
|
90
81
|
style: optionStyle
|
|
91
82
|
},
|
|
92
|
-
`${
|
|
83
|
+
`${opt.value}-${i}`
|
|
93
84
|
);
|
|
94
85
|
})
|
|
95
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta.components{a-input-date-time-container{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:6px;padding-top:8px;border-top:1px solid var(--border-3)}}
|
|
1
|
+
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-input-date-time-container{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:6px;padding-top:8px;border-top:1px solid var(--border-3)}}
|
|
@@ -61,10 +61,10 @@ export interface MenuProps extends BaseProps {
|
|
|
61
61
|
}) => void;
|
|
62
62
|
/** Combobox-mode cursor report (raw element event). Fires when the active
|
|
63
63
|
* option changes as arrow keys move the cursor while focus stays in a
|
|
64
|
-
* `[data-menu-search]` filter field; `detail.id` is
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
64
|
+
* `[data-menu-search]` filter field; `detail.id` is an authored option `id`,
|
|
65
|
+
* or `null`. Built-in Anta Inputs receive the active option through a direct
|
|
66
|
+
* ARIA element relationship; this remains available to custom fields and
|
|
67
|
+
* observers. Passed straight through to the element. */
|
|
68
68
|
onactivedescendant?: (e: CustomEvent<{
|
|
69
69
|
id: string | null;
|
|
70
70
|
}>) => void;
|
package/dist/components/Menu.js
CHANGED
|
@@ -39,7 +39,7 @@ const Menu = ({
|
|
|
39
39
|
round: roundAttr(round),
|
|
40
40
|
"stop-propagation": stopPropagation === void 0 || stopPropagation === false ? void 0 : stopPropagation === true ? "" : Array.isArray(stopPropagation) ? stopPropagation.join(" ") : stopPropagation,
|
|
41
41
|
role,
|
|
42
|
-
"aria-orientation": "vertical",
|
|
42
|
+
"aria-orientation": role === "menu" || role === "listbox" ? "vertical" : void 0,
|
|
43
43
|
class: className,
|
|
44
44
|
style: lengthStyle(inset, "--menu-padding", roundStyle(round, "--menu-round", style)),
|
|
45
45
|
...rest,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseProps, DOMEventHandlers } from '../general_types';
|
|
2
|
+
export interface PanelProps extends BaseProps, DOMEventHandlers {
|
|
3
|
+
/** Fill the browser viewport and contain keyboard focus within the panel.
|
|
4
|
+
* When supplied, the application owns the state. */
|
|
5
|
+
maximized?: boolean;
|
|
6
|
+
/** Initial viewport maximization for an uncontrolled panel, read once on connect. */
|
|
7
|
+
defaultMaximized?: boolean;
|
|
8
|
+
/** Requested maximization change. Update `maximized` to accept a controlled
|
|
9
|
+
* request, or prevent the event to veto an uncontrolled request. */
|
|
10
|
+
onStateChange?: (event: CustomEvent, detail: {
|
|
11
|
+
next: boolean;
|
|
12
|
+
prev: boolean;
|
|
13
|
+
}) => void;
|
|
14
|
+
}
|
|
15
|
+
/** A scroll container that fills its parent and can maximize to the viewport.
|
|
16
|
+
* Percentage height requires a parent with a defined height. */
|
|
17
|
+
export declare const Panel: ({ maximized, defaultMaximized, onStateChange, className, children, ...rest }: PanelProps) => any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
import { nativeStateChange } from "../anta_helpers";
|
|
3
|
+
const Panel = ({ maximized, defaultMaximized, onStateChange, className, children, ...rest }) => /* @__PURE__ */ jsx(
|
|
4
|
+
"a-panel",
|
|
5
|
+
{
|
|
6
|
+
state: maximized === void 0 ? void 0 : maximized ? "maximized" : "normal",
|
|
7
|
+
"default-state": maximized === void 0 && defaultMaximized ? "maximized" : void 0,
|
|
8
|
+
onstatechange: onStateChange ? (event) => {
|
|
9
|
+
const { event: native, detail, isOwn } = nativeStateChange(event);
|
|
10
|
+
if (isOwn && detail) onStateChange(native, {
|
|
11
|
+
next: detail.next === "maximized",
|
|
12
|
+
prev: detail.prev === "maximized"
|
|
13
|
+
});
|
|
14
|
+
} : void 0,
|
|
15
|
+
class: className,
|
|
16
|
+
...rest,
|
|
17
|
+
children
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
export {
|
|
21
|
+
Panel
|
|
22
|
+
};
|
|
@@ -21,7 +21,8 @@ export interface RadioOption extends OptionPresentationProps {
|
|
|
21
21
|
value: string;
|
|
22
22
|
/** The visible label. */
|
|
23
23
|
label?: React.ReactNode;
|
|
24
|
-
/** Secondary text under the label
|
|
24
|
+
/** Secondary text under the label and exposed as this radio option's
|
|
25
|
+
* accessible description. */
|
|
25
26
|
hint?: React.ReactNode;
|
|
26
27
|
/** Disable just this option (skipped by keyboard, dropped from the tab order). */
|
|
27
28
|
disabled?: boolean;
|
|
@@ -163,25 +163,25 @@ export interface SelectCommonProps<V extends OptionValue = string> extends Omit<
|
|
|
163
163
|
indicator?: 'none' | 'check' | 'radio';
|
|
164
164
|
/** Text shown when nothing is selected. */
|
|
165
165
|
placeholder?: string;
|
|
166
|
-
/** Leading icon shown at the left of the field
|
|
167
|
-
* `
|
|
166
|
+
/** Leading icon shown at the left of the field. With a custom
|
|
167
|
+
* `renderTrigger`, it's passed through as
|
|
168
168
|
* `state.icon` instead — the consumer places it. */
|
|
169
169
|
icon?: IconShape;
|
|
170
|
-
/** Content
|
|
170
|
+
/** Content before the default trigger's value, such as a key prefix
|
|
171
171
|
* before the value. It replaces the icon derived from `icon`. Include an
|
|
172
172
|
* `<Icon>` in this content when both are needed. Ignored by `renderTrigger`. */
|
|
173
173
|
leading?: React.ReactNode;
|
|
174
|
-
/** Field label, above the trigger
|
|
174
|
+
/** Field label, above the trigger. */
|
|
175
175
|
label?: string;
|
|
176
|
-
/** Helper text under the field
|
|
176
|
+
/** Helper text under the field. */
|
|
177
177
|
hint?: string;
|
|
178
178
|
/** Field size.
|
|
179
179
|
* @defaultValue medium */
|
|
180
180
|
size?: 'small' | 'medium' | 'large';
|
|
181
|
-
/** Validation/feedback tone for the field
|
|
181
|
+
/** Validation/feedback tone for the field.
|
|
182
182
|
* @defaultValue neutral */
|
|
183
183
|
status?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical';
|
|
184
|
-
/** Glyph shown before the `hint` when `status` is set
|
|
184
|
+
/** Glyph shown before the `hint` when `status` is set.
|
|
185
185
|
* Each status has a default; pass a shape to override, or `false` to drop it. */
|
|
186
186
|
statusIcon?: IconShape | (string & {}) | false;
|
|
187
187
|
/** Round the field corners — `true` for fully round, or a number / CSS length. */
|
|
@@ -234,7 +234,7 @@ export interface SelectCommonProps<V extends OptionValue = string> extends Omit<
|
|
|
234
234
|
* A, B, C` (labels comma-joined) in place of the bare `3 selected`. Applies
|
|
235
235
|
* to the multi-count case only: `All` stays `All`, a single pick stays its
|
|
236
236
|
* own label, and an empty selection stays the `placeholder`. The list flows
|
|
237
|
-
* into the
|
|
237
|
+
* into the Button label, so it ellipsizes at the field's width when long
|
|
238
238
|
* (`3 selected: Engineering, Des… `). `renderSummary` overrides this. */
|
|
239
239
|
verbose?: boolean;
|
|
240
240
|
/** `multiple` only: build the trigger's selection summary text yourself,
|
|
@@ -242,7 +242,7 @@ export interface SelectCommonProps<V extends OptionValue = string> extends Omit<
|
|
|
242
242
|
* the resolved selected options (`selected.length` is the count) and runs only
|
|
243
243
|
* while something is selected — an empty selection still shows the
|
|
244
244
|
* `placeholder`. Return a **string**: it flows into the default trigger's
|
|
245
|
-
*
|
|
245
|
+
* Button label, so a long summary ellipsizes at the field's width just
|
|
246
246
|
* like a long value (`Engineering, Design, … `). Return `undefined` to fall
|
|
247
247
|
* back to the default for that case (e.g. customize only the count, keeping
|
|
248
248
|
* the single-label case built-in). For rich content (chips, multiple nodes)
|
|
@@ -253,9 +253,9 @@ export interface SelectCommonProps<V extends OptionValue = string> extends Omit<
|
|
|
253
253
|
* one focusable element, such as an Anta `Button`. The menu is positioned
|
|
254
254
|
* relative to that element and opens when it is clicked. Do not return a
|
|
255
255
|
* fragment, multiple siblings, or a non-focusable wrapper. Add
|
|
256
|
-
* `aria-haspopup=
|
|
257
|
-
*
|
|
258
|
-
*
|
|
256
|
+
* `aria-haspopup={filter ? 'dialog' : 'menu'}` and
|
|
257
|
+
* `aria-expanded={state.open}` to the returned button. An Anta `Button`
|
|
258
|
+
* already carries the correct role.
|
|
259
259
|
* Field props (`label`, `hint`, `size`, `status`, `placeholder`, and `round`) and
|
|
260
260
|
* `className` / `style` apply only to the default field. Add styling and
|
|
261
261
|
* attributes to the returned element instead. */
|
|
@@ -352,8 +352,8 @@ export type SelectedItem<V extends OptionValue = string> = SelectedOption<V> | S
|
|
|
352
352
|
*/
|
|
353
353
|
export declare function optionsWithSelection<V extends OptionValue = string>(options: SelectItem<V>[], values: V | V[] | undefined): SelectedItem<V>[];
|
|
354
354
|
/**
|
|
355
|
-
* `<Select>` lets people choose one or more options from a dropdown. It uses
|
|
356
|
-
* `<
|
|
355
|
+
* `<Select>` lets people choose one or more options from a dropdown. It uses a
|
|
356
|
+
* `<Button>` as its trigger and a `<Menu>` for its options. `selection` sets behavior:
|
|
357
357
|
* `'single'` (default; `value` is a string, menu closes on pick) or `'multiple'`
|
|
358
358
|
* (checkboxes, `value` is a string array, menu stays open while toggling, the
|
|
359
359
|
* field shows an "N selected" count). For single-select, `indicator` picks the
|