ionbase-ui 0.76.0 → 0.81.1
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/components/Card.d.ts +61 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +37 -0
- package/dist/components/Card.js.map +1 -0
- package/dist/components/CommandPalette.d.ts +76 -0
- package/dist/components/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette.js +194 -0
- package/dist/components/CommandPalette.js.map +1 -0
- package/dist/components/DateField.d.ts +14 -0
- package/dist/components/DateField.d.ts.map +1 -1
- package/dist/components/DateField.js +1 -1
- package/dist/components/DateField.js.map +1 -1
- package/dist/components/DatePicker.d.ts +1 -1
- package/dist/components/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker.js +14 -6
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/DateRangePicker.d.ts +1 -1
- package/dist/components/DateRangePicker.d.ts.map +1 -1
- package/dist/components/DateRangePicker.js +14 -6
- package/dist/components/DateRangePicker.js.map +1 -1
- package/dist/components/Kbd.d.ts +45 -0
- package/dist/components/Kbd.d.ts.map +1 -0
- package/dist/components/Kbd.js +45 -0
- package/dist/components/Kbd.js.map +1 -0
- package/dist/components/Table.d.ts +18 -0
- package/dist/components/Table.d.ts.map +1 -1
- package/dist/components/Table.js +14 -3
- package/dist/components/Table.js.map +1 -1
- package/dist/components/TagGroup.d.ts +51 -0
- package/dist/components/TagGroup.d.ts.map +1 -0
- package/dist/components/TagGroup.js +84 -0
- package/dist/components/TagGroup.js.map +1 -0
- package/dist/components/TimeField.d.ts +72 -0
- package/dist/components/TimeField.d.ts.map +1 -0
- package/dist/components/TimeField.js +102 -0
- package/dist/components/TimeField.js.map +1 -0
- package/dist/components/index.d.ts +14 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/iso-time.d.ts +23 -0
- package/dist/components/iso-time.d.ts.map +1 -0
- package/dist/components/iso-time.js +34 -0
- package/dist/components/iso-time.js.map +1 -0
- package/dist/components/shortcut.d.ts +19 -0
- package/dist/components/shortcut.d.ts.map +1 -0
- package/dist/components/shortcut.js +122 -0
- package/dist/components/shortcut.js.map +1 -0
- package/dist/components/use-table-sort.d.ts +38 -0
- package/dist/components/use-table-sort.d.ts.map +1 -0
- package/dist/components/use-table-sort.js +33 -0
- package/dist/components/use-table-sort.js.map +1 -0
- package/dist/figma-descriptions.json +103 -68
- package/dist/figma-map.json +343 -2
- package/dist/meta/Card.json +153 -0
- package/dist/meta/Checkbox.json +2 -2
- package/dist/meta/CommandPalette.json +178 -0
- package/dist/meta/DatePicker.json +5 -4
- package/dist/meta/DateRangePicker.json +3 -2
- package/dist/meta/Kbd.json +97 -0
- package/dist/meta/Radio.json +2 -2
- package/dist/meta/RadioGroup.json +2 -2
- package/dist/meta/Table.json +4 -1
- package/dist/meta/TableBody.json +3 -0
- package/dist/meta/TableCell.json +49 -5
- package/dist/meta/TableHead.json +3 -0
- package/dist/meta/TableRow.json +3 -0
- package/dist/meta/Tag.json +54 -0
- package/dist/meta/TagGroup.json +211 -0
- package/dist/meta/TimeField.json +224 -0
- package/dist/meta/Toggle.json +2 -2
- package/dist/meta/components.json +1014 -38
- package/dist/meta/contrast.json +1133 -6
- package/dist/meta/index.json +86 -12
- package/dist/meta/patterns/DataTable.json +27 -3
- package/dist/meta/patterns/PageShell.json +15 -2
- package/dist/meta/patterns/index.json +7 -3
- package/dist/styles/agent-activity.css +4 -2
- package/dist/styles/approval-gate.css +4 -3
- package/dist/styles/card.css +75 -0
- package/dist/styles/citation.css +4 -2
- package/dist/styles/command-palette.css +250 -0
- package/dist/styles/confidence-indicator.css +2 -2
- package/dist/styles/index.css +5 -0
- package/dist/styles/kbd.css +47 -0
- package/dist/styles/streaming-text.css +3 -2
- package/dist/styles/table.css +51 -0
- package/dist/styles/tag-group.css +172 -0
- package/dist/styles/time-field.css +31 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Which heading element the title renders as.
|
|
4
|
+
*
|
|
5
|
+
* `h1` is deliberately absent: a card is a section of a page, never the page's
|
|
6
|
+
* own title.
|
|
7
|
+
*/
|
|
8
|
+
export type CardHeadingLevel = 2 | 3 | 4 | 5 | 6;
|
|
9
|
+
/** `danger` marks a card whose actions cannot be undone. */
|
|
10
|
+
export type CardIntent = 'default' | 'danger';
|
|
11
|
+
export interface CardProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
12
|
+
/**
|
|
13
|
+
* The card's heading. With a title the card is a `<section>` named by it;
|
|
14
|
+
* without one it is a plain surface — a `<div>`, for skeletons and for
|
|
15
|
+
* content that already has its own heading.
|
|
16
|
+
*/
|
|
17
|
+
title?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Heading element for the title. Defaults to `h2`: most cards are the
|
|
20
|
+
* first level of section under the page's `h1`. The outline is the page's
|
|
21
|
+
* decision, so it is a prop, not a constant.
|
|
22
|
+
*/
|
|
23
|
+
headingLevel?: CardHeadingLevel;
|
|
24
|
+
/** One line under the title — what the card holds or when changes apply. */
|
|
25
|
+
description?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* One control at the end of the title row: a standalone Link ("All runs")
|
|
28
|
+
* or a small Button. More than one belongs in the body.
|
|
29
|
+
*/
|
|
30
|
+
action?: React.ReactNode;
|
|
31
|
+
/** `danger` for a card of irreversible actions — the danger zone. */
|
|
32
|
+
intent?: CardIntent;
|
|
33
|
+
/**
|
|
34
|
+
* Whether a titled card is a landmark. Defaults to `true`. Set `false`
|
|
35
|
+
* when the card's only content is itself a landmark named by the same
|
|
36
|
+
* words — a Table's scroll region — or the page gets two regions with one
|
|
37
|
+
* name. The heading still renders; only the `<section>` becomes a `<div>`.
|
|
38
|
+
*/
|
|
39
|
+
isRegion?: boolean;
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Card — a bordered surface that groups one part of a page.
|
|
44
|
+
*
|
|
45
|
+
* Promoted from the demo app, where the same surface was hand-written as
|
|
46
|
+
* `.demo-panel` in nine screens: a settings group, a chart panel, a runs log,
|
|
47
|
+
* the danger zone. For a feature row with media use FullCard; for one
|
|
48
|
+
* headline figure use StatTile.
|
|
49
|
+
*
|
|
50
|
+
* THE TITLE DECIDES THE ELEMENT
|
|
51
|
+
*
|
|
52
|
+
* A titled card is a `<section aria-labelledby>` — a named region, so a
|
|
53
|
+
* screen reader user can jump between cards the way a sighted one scans
|
|
54
|
+
* them. An untitled card is a `<div>`: a `<section>` with no name is not a
|
|
55
|
+
* landmark at all, and pretending otherwise only adds noise.
|
|
56
|
+
*
|
|
57
|
+
* No `'use client'`: `useId` resolves on the server, and nothing here is
|
|
58
|
+
* interactive. Interactive parts arrive through `action` and `children`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLElement>>;
|
|
61
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE9C,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EACjC,OAAO,CACR;IACC;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,4EAA4E;IAC5E,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,qEAAqE;IACrE,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI,+EAwDhB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Card — a bordered surface that groups one part of a page.
|
|
5
|
+
*
|
|
6
|
+
* Promoted from the demo app, where the same surface was hand-written as
|
|
7
|
+
* `.demo-panel` in nine screens: a settings group, a chart panel, a runs log,
|
|
8
|
+
* the danger zone. For a feature row with media use FullCard; for one
|
|
9
|
+
* headline figure use StatTile.
|
|
10
|
+
*
|
|
11
|
+
* THE TITLE DECIDES THE ELEMENT
|
|
12
|
+
*
|
|
13
|
+
* A titled card is a `<section aria-labelledby>` — a named region, so a
|
|
14
|
+
* screen reader user can jump between cards the way a sighted one scans
|
|
15
|
+
* them. An untitled card is a `<div>`: a `<section>` with no name is not a
|
|
16
|
+
* landmark at all, and pretending otherwise only adds noise.
|
|
17
|
+
*
|
|
18
|
+
* No `'use client'`: `useId` resolves on the server, and nothing here is
|
|
19
|
+
* interactive. Interactive parts arrive through `action` and `children`.
|
|
20
|
+
*/
|
|
21
|
+
export const Card = forwardRef(({ title, headingLevel = 2, description, action, intent = 'default', isRegion = true, className, children, ...rest }, ref) => {
|
|
22
|
+
const titleId = useId();
|
|
23
|
+
const Heading = `h${headingLevel}`;
|
|
24
|
+
const hasTitle = title != null && title !== false;
|
|
25
|
+
const Root = hasTitle && isRegion ? 'section' : 'div';
|
|
26
|
+
return (_jsxs(Root, { ...rest, ref: ref, "aria-labelledby": Root === 'section'
|
|
27
|
+
? (rest['aria-labelledby'] ?? titleId)
|
|
28
|
+
: rest['aria-labelledby'], className: [
|
|
29
|
+
'ion-card',
|
|
30
|
+
intent === 'danger' && 'ion-card--danger',
|
|
31
|
+
className,
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join(' '), children: [(hasTitle || action) && (_jsxs("div", { className: "ion-card__header", children: [hasTitle && (_jsxs("div", { className: "ion-card__heading", children: [_jsx(Heading, { id: titleId, className: "ion-card__title", children: title }), description && (_jsx("p", { className: "ion-card__description", children: description }))] })), action && _jsx("div", { className: "ion-card__action", children: action })] })), children] }));
|
|
35
|
+
});
|
|
36
|
+
Card.displayName = 'Card';
|
|
37
|
+
//# sourceMappingURL=Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAgDjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC5B,CACE,EACE,KAAK,EACL,YAAY,GAAG,CAAC,EAChB,WAAW,EACX,MAAM,EACN,MAAM,GAAG,SAAS,EAClB,QAAQ,GAAG,IAAI,EACf,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACR,EACD,GAAG,EACH,EAAE;IACF,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,IAAI,YAAY,EAAW,CAAC;IAC5C,MAAM,QAAQ,GAAG,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC;IAClD,MAAM,IAAI,GAAG,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;IAEtD,OAAO,CACL,MAAC,IAAI,OACC,IAAI,EACR,GAAG,EAAE,GAAgC,qBAEnC,IAAI,KAAK,SAAS;YAChB,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC;YACtC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAE7B,SAAS,EAAE;YACT,UAAU;YACV,MAAM,KAAK,QAAQ,IAAI,kBAAkB;YACzC,SAAS;SACV;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEX,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CACvB,eAAK,SAAS,EAAC,kBAAkB,aAC9B,QAAQ,IAAI,CACX,eAAK,SAAS,EAAC,mBAAmB,aAChC,KAAC,OAAO,IAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,YAC9C,KAAK,GACE,EACT,WAAW,IAAI,CACd,YAAG,SAAS,EAAC,uBAAuB,YAAE,WAAW,GAAK,CACvD,IACG,CACP,EACA,MAAM,IAAI,cAAK,SAAS,EAAC,kBAAkB,YAAE,MAAM,GAAO,IACvD,CACP,EACA,QAAQ,IACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CommandPaletteItem {
|
|
3
|
+
/** Passed to `onAction`. Unique within the palette. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** What the row says — a verb first: "Create agent", "Go to Runs". */
|
|
6
|
+
label: string;
|
|
7
|
+
/** A second line. Searchable. */
|
|
8
|
+
description?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The heading this command is listed under. Sections appear in the order
|
|
11
|
+
* their first command does; commands without one come first, unheaded.
|
|
12
|
+
*/
|
|
13
|
+
section?: string;
|
|
14
|
+
/** Leading icon. Decorative — the label names the command. */
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* The command's own shortcut, shown as a hint: `mod+shift+n`. Shown, NOT
|
|
18
|
+
* bound — the palette does not listen for it. Bind it where the command
|
|
19
|
+
* lives, or the hint promises a key that does nothing.
|
|
20
|
+
*/
|
|
21
|
+
shortcut?: string;
|
|
22
|
+
/** Other words that should find it: "delete" for "Remove agent". */
|
|
23
|
+
keywords?: readonly string[];
|
|
24
|
+
/** Listed but not runnable, and skipped by the arrow keys. */
|
|
25
|
+
isDisabled?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface CommandPaletteProps {
|
|
28
|
+
/** Every command. Filtering happens here, against what is typed. */
|
|
29
|
+
commands: readonly CommandPaletteItem[];
|
|
30
|
+
/**
|
|
31
|
+
* Runs the chosen command. Called AFTER the palette has closed and handed
|
|
32
|
+
* focus back, so an action that moves focus — to a search field, into a
|
|
33
|
+
* form — keeps it.
|
|
34
|
+
*/
|
|
35
|
+
onAction: (id: string) => void;
|
|
36
|
+
isOpen?: boolean;
|
|
37
|
+
defaultOpen?: boolean;
|
|
38
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
39
|
+
/**
|
|
40
|
+
* The shortcut that opens it from anywhere on the page, and closes it again.
|
|
41
|
+
* Defaults to `mod+k` — ⌘K on a Mac, Ctrl+K elsewhere. `null` turns it off,
|
|
42
|
+
* for a page that opens the palette some other way.
|
|
43
|
+
*/
|
|
44
|
+
openShortcut?: string | null;
|
|
45
|
+
/** Names the dialog and the search field. */
|
|
46
|
+
label?: string;
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
/** Shown in place of the list when nothing matches. */
|
|
49
|
+
emptyLabel?: React.ReactNode;
|
|
50
|
+
className?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* CommandPalette — every action in the product, one search away.
|
|
54
|
+
*
|
|
55
|
+
* ⌘K (Ctrl+K elsewhere) opens it from anywhere; typing filters; Enter runs.
|
|
56
|
+
* Mount it once, near the root, and hand it every command the product has.
|
|
57
|
+
*
|
|
58
|
+
* WHY NOT A MODAL WITH A COMBOBOX IN IT
|
|
59
|
+
*
|
|
60
|
+
* A Combobox's list is a popover that opens and closes on its own rules, and
|
|
61
|
+
* it SELECTS a value that stays selected. A palette's list is always open and
|
|
62
|
+
* each row is RUN, once, and the palette goes away. The ARIA shape is the same
|
|
63
|
+
* — a combobox driving a listbox through `aria-activedescendant` — so this
|
|
64
|
+
* uses it, without the parts of Combobox that exist for choosing a value.
|
|
65
|
+
*
|
|
66
|
+
* NOT A NAVIGATION MENU
|
|
67
|
+
*
|
|
68
|
+
* Everything in the palette must also be reachable without it. It is a faster
|
|
69
|
+
* route for people who know what they want, and a shortcut nobody told you
|
|
70
|
+
* about is not a route at all.
|
|
71
|
+
*/
|
|
72
|
+
export declare function CommandPalette({ commands, onAction, isOpen, defaultOpen, onOpenChange, openShortcut, label, placeholder, emptyLabel, className, }: CommandPaletteProps): React.JSX.Element | null;
|
|
73
|
+
export declare namespace CommandPalette {
|
|
74
|
+
var displayName: string;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=CommandPalette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandPalette.d.ts","sourceRoot":"","sources":["../../src/components/CommandPalette.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAa3E,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACxC;;;;OAIG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAuTD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,WAAW,EACX,YAAY,EACZ,YAAsB,EACtB,KAAyB,EACzB,WAAyC,EACzC,UAAmC,EACnC,SAAS,GACV,EAAE,mBAAmB,4BA2DrB;yBAtEe,cAAc"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { Overlay, useDialog, useFilter, useModalOverlay, mergeProps, } from 'react-aria';
|
|
5
|
+
import { useOverlayTriggerState } from 'react-stately';
|
|
6
|
+
import { Kbd, useIsMac } from './Kbd.js';
|
|
7
|
+
import { matchesShortcut, parseShortcut } from './shortcut.js';
|
|
8
|
+
const SearchIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: [_jsx("circle", { cx: "11", cy: "11", r: "7" }), _jsx("path", { d: "m20 20-3.5-3.5" })] }));
|
|
9
|
+
/** Groups in first-appearance order; unsectioned commands lead, unheaded. */
|
|
10
|
+
function toSections(commands) {
|
|
11
|
+
const bySection = new Map([
|
|
12
|
+
[undefined, []],
|
|
13
|
+
]);
|
|
14
|
+
for (const c of commands) {
|
|
15
|
+
const list = bySection.get(c.section);
|
|
16
|
+
if (list)
|
|
17
|
+
list.push(c);
|
|
18
|
+
else
|
|
19
|
+
bySection.set(c.section, [c]);
|
|
20
|
+
}
|
|
21
|
+
return [...bySection]
|
|
22
|
+
.filter(([, list]) => list.length > 0)
|
|
23
|
+
.map(([title, list]) => ({ title, commands: list }));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The dialog, mounted only while open — AGENTS.md's overlay rule: `useDialog`
|
|
27
|
+
* resolves its focus and name in effects that run when the CALLER mounts.
|
|
28
|
+
* Mounting fresh on every open also empties the query and resets the active
|
|
29
|
+
* row, which is what a palette should do.
|
|
30
|
+
*/
|
|
31
|
+
function CommandPalettePanel({ state, commands, onRun, label, placeholder, emptyLabel, className, }) {
|
|
32
|
+
const panelRef = useRef(null);
|
|
33
|
+
const inputRef = useRef(null);
|
|
34
|
+
const listRef = useRef(null);
|
|
35
|
+
const baseId = useId();
|
|
36
|
+
const listId = `${baseId}-list`;
|
|
37
|
+
const { modalProps, underlayProps } = useModalOverlay({ isDismissable: true }, state, panelRef);
|
|
38
|
+
const { dialogProps } = useDialog({ 'aria-label': label }, panelRef);
|
|
39
|
+
const [query, setQuery] = useState('');
|
|
40
|
+
const { contains } = useFilter({ sensitivity: 'base' });
|
|
41
|
+
const sections = useMemo(() => {
|
|
42
|
+
const q = query.trim();
|
|
43
|
+
const matched = q
|
|
44
|
+
? commands.filter((c) => contains([c.label, c.description, c.section, ...(c.keywords ?? [])]
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join(' '), q))
|
|
47
|
+
: commands;
|
|
48
|
+
return toSections(matched);
|
|
49
|
+
}, [commands, contains, query]);
|
|
50
|
+
/* The rows the arrow keys move through, in display order. */
|
|
51
|
+
const rows = useMemo(() => sections.flatMap((s) => s.commands), [sections]);
|
|
52
|
+
const runnable = useMemo(() => rows.filter((c) => !c.isDisabled), [rows]);
|
|
53
|
+
const [activeId, setActiveId] = useState(null);
|
|
54
|
+
/*
|
|
55
|
+
* The active row follows the query: a new query highlights its first
|
|
56
|
+
* runnable result, so Enter after typing runs the best match. Derived rather
|
|
57
|
+
* than set in an effect, so the highlight and the list never disagree for a
|
|
58
|
+
* frame.
|
|
59
|
+
*/
|
|
60
|
+
const active = runnable.find((c) => c.id === activeId) ?? runnable[0] ?? null;
|
|
61
|
+
const optionId = (c) => `${baseId}-${rows.indexOf(c)}`;
|
|
62
|
+
// Keep the keyboard's row in view as it moves past the list's edge.
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!active)
|
|
65
|
+
return;
|
|
66
|
+
document
|
|
67
|
+
.getElementById(optionId(active))
|
|
68
|
+
?.scrollIntoView?.({ block: 'nearest' });
|
|
69
|
+
// optionId is a pure function of rows, which `active` already follows.
|
|
70
|
+
}, [active]);
|
|
71
|
+
const move = (by) => {
|
|
72
|
+
if (!runnable.length)
|
|
73
|
+
return;
|
|
74
|
+
const at = active ? runnable.indexOf(active) : -1;
|
|
75
|
+
const next = (at + by + runnable.length) % runnable.length;
|
|
76
|
+
setActiveId(runnable[next].id);
|
|
77
|
+
};
|
|
78
|
+
const onKeyDown = (e) => {
|
|
79
|
+
if (e.nativeEvent.isComposing)
|
|
80
|
+
return;
|
|
81
|
+
switch (e.key) {
|
|
82
|
+
case 'ArrowDown':
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
move(1);
|
|
85
|
+
break;
|
|
86
|
+
case 'ArrowUp':
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
move(-1);
|
|
89
|
+
break;
|
|
90
|
+
case 'Enter':
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
if (active)
|
|
93
|
+
onRun(active.id);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const count = runnable.length;
|
|
98
|
+
return (_jsx("div", { ...underlayProps, className: "ion-command-palette__scrim", children: _jsxs("div", { ...mergeProps(modalProps, dialogProps), ref: panelRef, className: ['ion-command-palette', className || '']
|
|
99
|
+
.filter(Boolean)
|
|
100
|
+
.join(' '), children: [_jsxs("div", { className: "ion-command-palette__search", children: [_jsx("span", { className: "ion-command-palette__search-icon", "aria-hidden": "true", children: _jsx(SearchIcon, {}) }), _jsx("input", { ref: inputRef, className: "ion-command-palette__input", type: "text", role: "combobox", "aria-label": label, "aria-expanded": "true", "aria-controls": listId, "aria-autocomplete": "list", "aria-activedescendant": active ? optionId(active) : undefined, autoComplete: "off", autoCorrect: "off", spellCheck: false,
|
|
101
|
+
// A palette exists to be typed into; focus starts in the field.
|
|
102
|
+
autoFocus: true, placeholder: placeholder, value: query, onChange: (e) => {
|
|
103
|
+
setQuery(e.target.value);
|
|
104
|
+
setActiveId(null);
|
|
105
|
+
}, onKeyDown: onKeyDown })] }), _jsx("div", { ref: listRef, id: listId, role: "listbox", "aria-label": label, className: "ion-command-palette__list", children: sections.map((section, s) => {
|
|
106
|
+
const headingId = `${baseId}-section-${s}`;
|
|
107
|
+
const options = section.commands.map((c) => {
|
|
108
|
+
const isActive = c === active;
|
|
109
|
+
return (_jsxs("div", { id: optionId(c), role: "option", "aria-selected": isActive, "aria-disabled": c.isDisabled || undefined, className: "ion-command-palette__option", "data-focused": isActive || undefined, "data-disabled": c.isDisabled || undefined,
|
|
110
|
+
/*
|
|
111
|
+
* pointermove, not pointerenter: a list scrolled by the
|
|
112
|
+
* keyboard slides rows under a resting pointer, and enter
|
|
113
|
+
* would hand the highlight to whatever landed there.
|
|
114
|
+
*/
|
|
115
|
+
onPointerMove: () => {
|
|
116
|
+
if (!c.isDisabled && !isActive)
|
|
117
|
+
setActiveId(c.id);
|
|
118
|
+
},
|
|
119
|
+
// Keep focus in the field; a click must not blur it first.
|
|
120
|
+
onMouseDown: (e) => e.preventDefault(), onClick: () => {
|
|
121
|
+
if (!c.isDisabled)
|
|
122
|
+
onRun(c.id);
|
|
123
|
+
}, children: [c.icon && (_jsx("span", { className: "ion-command-palette__icon", "aria-hidden": "true", children: c.icon })), _jsxs("span", { className: "ion-command-palette__text", children: [_jsx("span", { className: "ion-command-palette__label", children: c.label }), c.description && (_jsx("span", { className: "ion-command-palette__description", children: c.description }))] }), c.shortcut && (_jsx(Kbd, { shortcut: c.shortcut, className: "ion-command-palette__shortcut" }))] }, c.id));
|
|
124
|
+
});
|
|
125
|
+
return section.title ? (_jsxs("div", { role: "group", "aria-labelledby": headingId, className: "ion-command-palette__section", children: [_jsx("div", { id: headingId, role: "presentation", className: "ion-command-palette__heading", children: section.title }), options] }, section.title)) : (_jsx(React.Fragment, { children: options }, ""));
|
|
126
|
+
}) }), rows.length === 0 && (_jsx("div", { className: "ion-command-palette__empty", children: emptyLabel })), _jsx("div", { className: "ion-visually-hidden", role: "status", "aria-live": "polite", children: query ? `${count} ${count === 1 ? 'command' : 'commands'}` : '' }), _jsxs("div", { className: "ion-command-palette__footer", "aria-hidden": "true", children: [_jsxs("span", { className: "ion-command-palette__hint", children: [_jsx(Kbd, { shortcut: "up" }), _jsx(Kbd, { shortcut: "down" }), "to move"] }), _jsxs("span", { className: "ion-command-palette__hint", children: [_jsx(Kbd, { shortcut: "enter" }), "to run"] }), _jsxs("span", { className: "ion-command-palette__hint", children: [_jsx(Kbd, { shortcut: "esc" }), "to close"] })] })] }) }));
|
|
127
|
+
}
|
|
128
|
+
/* ---------------------------------------------------------------- palette */
|
|
129
|
+
/**
|
|
130
|
+
* CommandPalette — every action in the product, one search away.
|
|
131
|
+
*
|
|
132
|
+
* ⌘K (Ctrl+K elsewhere) opens it from anywhere; typing filters; Enter runs.
|
|
133
|
+
* Mount it once, near the root, and hand it every command the product has.
|
|
134
|
+
*
|
|
135
|
+
* WHY NOT A MODAL WITH A COMBOBOX IN IT
|
|
136
|
+
*
|
|
137
|
+
* A Combobox's list is a popover that opens and closes on its own rules, and
|
|
138
|
+
* it SELECTS a value that stays selected. A palette's list is always open and
|
|
139
|
+
* each row is RUN, once, and the palette goes away. The ARIA shape is the same
|
|
140
|
+
* — a combobox driving a listbox through `aria-activedescendant` — so this
|
|
141
|
+
* uses it, without the parts of Combobox that exist for choosing a value.
|
|
142
|
+
*
|
|
143
|
+
* NOT A NAVIGATION MENU
|
|
144
|
+
*
|
|
145
|
+
* Everything in the palette must also be reachable without it. It is a faster
|
|
146
|
+
* route for people who know what they want, and a shortcut nobody told you
|
|
147
|
+
* about is not a route at all.
|
|
148
|
+
*/
|
|
149
|
+
export function CommandPalette({ commands, onAction, isOpen, defaultOpen, onOpenChange, openShortcut = 'mod+k', label = 'Command palette', placeholder = 'Type a command or search…', emptyLabel = 'No matching commands', className, }) {
|
|
150
|
+
const state = useOverlayTriggerState({ isOpen, defaultOpen, onOpenChange });
|
|
151
|
+
const isMac = useIsMac();
|
|
152
|
+
// Parsed during render so a malformed shortcut throws where it is written.
|
|
153
|
+
const parsed = useMemo(() => (openShortcut ? parseShortcut(openShortcut) : null), [openShortcut]);
|
|
154
|
+
/*
|
|
155
|
+
* The listener lives on the document, not on the panel, because it has to
|
|
156
|
+
* work while the palette is closed — and while it is open, the same key
|
|
157
|
+
* closes it. Kept in a ref so re-renders do not re-subscribe.
|
|
158
|
+
*/
|
|
159
|
+
const toggle = useRef(state.toggle);
|
|
160
|
+
toggle.current = state.toggle;
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
if (!parsed)
|
|
163
|
+
return;
|
|
164
|
+
const onKeyDown = (e) => {
|
|
165
|
+
if (e.repeat || !matchesShortcut(e, parsed, isMac))
|
|
166
|
+
return;
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
toggle.current();
|
|
169
|
+
};
|
|
170
|
+
document.addEventListener('keydown', onKeyDown);
|
|
171
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
172
|
+
}, [parsed, isMac]);
|
|
173
|
+
/*
|
|
174
|
+
* The command runs once the palette is gone, not from inside it. While the
|
|
175
|
+
* dialog is mounted its focus scope pulls any focus that leaves it straight
|
|
176
|
+
* back, so an action that focuses a field would lose that focus to the
|
|
177
|
+
* palette's own search box. After unmount, React Aria only restores focus to
|
|
178
|
+
* the trigger if nothing else has claimed it.
|
|
179
|
+
*/
|
|
180
|
+
const pending = useRef(null);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
if (state.isOpen || pending.current === null)
|
|
183
|
+
return;
|
|
184
|
+
const id = pending.current;
|
|
185
|
+
pending.current = null;
|
|
186
|
+
onAction(id);
|
|
187
|
+
});
|
|
188
|
+
return state.isOpen ? (_jsx(Overlay, { children: _jsx(CommandPalettePanel, { state: state, commands: commands, onRun: (id) => {
|
|
189
|
+
pending.current = id;
|
|
190
|
+
state.close();
|
|
191
|
+
}, label: label, placeholder: placeholder, emptyLabel: emptyLabel, className: className }) })) : null;
|
|
192
|
+
}
|
|
193
|
+
CommandPalette.displayName = 'CommandPalette';
|
|
194
|
+
//# sourceMappingURL=CommandPalette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandPalette.js","sourceRoot":"","sources":["../../src/components/CommandPalette.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,eAAe,EACf,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,GAAG,EAAE,QA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AAE;gBACZ,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;gBACrB,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,CAAC,EACD,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,GACpB,GACM,CACX,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC"}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { AriaDatePickerProps, DateValue } from 'react-aria';
|
|
3
|
+
import type { DateFieldState, DateSegment } from 'react-stately';
|
|
3
4
|
interface DateFieldProps extends AriaDatePickerProps<DateValue> {
|
|
4
5
|
className?: string;
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* One segment — a month, a day, a year, or a literal separator.
|
|
9
|
+
*
|
|
10
|
+
* The literal is rendered by the same component rather than being filtered out
|
|
11
|
+
* before the map. `useDateSegment` returns the separator's own props, including
|
|
12
|
+
* the `aria-hidden` that keeps `/` and `.` out of the announcement, and
|
|
13
|
+
* re-deriving that here would mean re-deriving it wrongly the first time a
|
|
14
|
+
* locale used a separator nobody tested.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Segment({ segment, state, }: {
|
|
17
|
+
segment: DateSegment;
|
|
18
|
+
state: DateFieldState;
|
|
19
|
+
}): React.JSX.Element;
|
|
6
20
|
/**
|
|
7
21
|
* The field itself. Rendered inside the picker's `.ion-input` box, which owns
|
|
8
22
|
* the border, the background and the states — exactly as Combobox reuses it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../src/components/DateField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAItC,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../src/components/DateField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAItC,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA2DjE,UAAU,cAAe,SAAQ,mBAAmB,CAAC,SAAS,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,KAAK,GACN,EAAE;IACD,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;CACvB,qBAsCA;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,qBAqChE;yBArCe,SAAS"}
|
|
@@ -13,7 +13,7 @@ import { createCalendar } from '@internationalized/date';
|
|
|
13
13
|
* re-deriving that here would mean re-deriving it wrongly the first time a
|
|
14
14
|
* locale used a separator nobody tested.
|
|
15
15
|
*/
|
|
16
|
-
function Segment({ segment, state, }) {
|
|
16
|
+
export function Segment({ segment, state, }) {
|
|
17
17
|
const ref = useRef(null);
|
|
18
18
|
const { segmentProps } = useDateSegment(segment, state, ref);
|
|
19
19
|
return (_jsx("div", { ...segmentProps, ref: ref, className: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../src/components/DateField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MA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AAE,SAAS,EAAE,GAAG,KAAK,EAAkB;IAC/D;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAE/B,MAAM,KAAK,GAAG,iBAAiB,CAAC;QAC9B,GAAG,KAAK;QACR,MAAM;QACN;;;;;WAKG;QACH,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAEvD,OAAO,CACL,iBACM,UAAU,EACd,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAEjE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,iEAAiE;QACjE,kEAAkE;QAClE,2CAA2C;QAC3C,KAAC,OAAO,IAAS,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,IAAjC,CAAC,CAAoC,CACpD,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAED,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC"}
|
|
@@ -6,7 +6,7 @@ export interface DatePickerProps {
|
|
|
6
6
|
label?: React.ReactNode;
|
|
7
7
|
/** Helper text below the field. */
|
|
8
8
|
description?: React.ReactNode;
|
|
9
|
-
/** Replaces the helper text
|
|
9
|
+
/** Replaces the helper text while the field is invalid — `isInvalid`, or its own bounds check. */
|
|
10
10
|
errorMessage?: React.ReactNode;
|
|
11
11
|
isInvalid?: boolean;
|
|
12
12
|
isDisabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../src/components/DatePicker.tsx"],"names":[],"mappings":"AAEA,OAAO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ACnB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;IAC/C,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,IAAW,EACX,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,IAAI,EACJ,aAA+B,EAC/B,SAAS,EACT,gBAAgB,EAChB,EAAE,GACH,EAAE,eAAe,qBA2JjB;yBA/Ke,UAAU"}
|
|
@@ -73,10 +73,20 @@ export function DatePicker({ label, description, errorMessage, isInvalid, isDisa
|
|
|
73
73
|
const buttonRef = useRef(null);
|
|
74
74
|
const { groupProps, labelProps, fieldProps, buttonProps: triggerProps, dialogProps, calendarProps, descriptionProps, errorMessageProps, } = useDatePicker({ ...ariaProps, id }, state, groupRef);
|
|
75
75
|
const { buttonProps } = useButton(triggerProps, buttonRef);
|
|
76
|
-
|
|
76
|
+
/*
|
|
77
|
+
* Invalid is the prop OR the picker's own validation — TimeField's rule.
|
|
78
|
+
* Left to the prop alone, a date before `minValue` or after `maxValue` marked the segments
|
|
79
|
+
* aria-invalid and left the box looking valid. With no `errorMessage`,
|
|
80
|
+
* React Aria's own localized message says what is wrong.
|
|
81
|
+
*/
|
|
82
|
+
const { isInvalid: failsValidation, validationErrors } = state.displayValidation;
|
|
83
|
+
const invalid = !!isInvalid || failsValidation;
|
|
84
|
+
const error = errorMessage ??
|
|
85
|
+
(validationErrors.length ? validationErrors.join(' ') : null);
|
|
86
|
+
const helper = invalid && error ? error : description;
|
|
77
87
|
return (_jsxs("div", { className: [
|
|
78
88
|
'ion-field',
|
|
79
|
-
|
|
89
|
+
invalid ? 'ion-field--error' : '',
|
|
80
90
|
wrapperClassName || '',
|
|
81
91
|
]
|
|
82
92
|
.filter(Boolean)
|
|
@@ -88,15 +98,13 @@ export function DatePicker({ label, description, errorMessage, isInvalid, isDisa
|
|
|
88
98
|
'ion-input',
|
|
89
99
|
'ion-date-picker',
|
|
90
100
|
size !== 'md' ? `ion-input--${size}` : '',
|
|
91
|
-
|
|
101
|
+
invalid ? 'ion-input--invalid' : '',
|
|
92
102
|
isDisabled ? 'ion-input--disabled' : '',
|
|
93
103
|
isReadOnly ? 'ion-input--readonly' : '',
|
|
94
104
|
className || '',
|
|
95
105
|
]
|
|
96
106
|
.filter(Boolean)
|
|
97
|
-
.join(' '), "data-open": state.isOpen || undefined, "data-invalid":
|
|
98
|
-
? errorMessageProps
|
|
99
|
-
: descriptionProps), className: "ion-field__helper", children: helper }))] }));
|
|
107
|
+
.join(' '), "data-open": state.isOpen || undefined, "data-invalid": invalid || undefined, "data-disabled": isDisabled || undefined, children: [_jsx(DateField, { ...fieldProps }), name && (_jsx("input", { type: "hidden", name: name, value: state.value ? toIso(state.value) : '' })), _jsx("button", { ...buttonProps, ref: buttonRef, type: "button", "aria-labelledby": undefined, "aria-label": calendarLabel, className: "ion-date-picker__button", children: _jsx(CalendarIcon, {}) })] }), state.isOpen && !isDisabled && !isReadOnly && (_jsx(CalendarPopover, { state: state, triggerRef: groupRef, dialogProps: dialogProps, children: _jsx(SingleCalendar, { ...calendarProps }) })), helper && (_jsx("span", { ...(invalid && error ? errorMessageProps : descriptionProps), className: "ion-field__helper", children: helper }))] }));
|
|
100
108
|
}
|
|
101
109
|
DatePicker.displayName = 'DatePicker';
|
|
102
110
|
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../src/components/DatePicker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKvE,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CACzB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,6FAA6F,EAC/F,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AA+CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,IAAI,GAAG,IAAI,EACX,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,IAAI,EACJ,aAAa,GAAG,eAAe,EAC/B,SAAS,EACT,gBAAgB,EAChB,EAAE,GACc;IAChB;;;;;;;OAOG;IACH,MAAM,SAAS,GAAG;QAChB,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC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I,EAAC,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAC5C,CACH,EAED,oBACM,WAAW,EACf,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,qBAOI,SAAS,gBACd,aAAa,EACzB,SAAS,EAAC,yBAAyB,YAEnC,KAAC,YAAY,KAAG,GACT,IACL,EAEL,KAAK,CAAC,MAAM,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,IAAI,CAC7C,KAAC,eAAe,IACd,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,QAAQ,EACpB,WAAW,EAAE,WAAW,YAExB,KAAC,cAAc,OAAK,aAAa,GAAI,GACrB,CACnB,EAEA,MAAM,IAAI,CACT,kBACM,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAC7D,SAAS,EAAC,mBAAmB,YAE5B,MAAM,GACF,CACR,IACG,CACP,CAAC;AACJ,CAAC;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -30,7 +30,7 @@ export interface DateRangePickerProps {
|
|
|
30
30
|
label?: React.ReactNode;
|
|
31
31
|
/** Helper text below the field. */
|
|
32
32
|
description?: React.ReactNode;
|
|
33
|
-
/** Replaces the helper text
|
|
33
|
+
/** Replaces the helper text while the field is invalid — `isInvalid`, or its own bounds check. */
|
|
34
34
|
errorMessage?: React.ReactNode;
|
|
35
35
|
isInvalid?: boolean;
|
|
36
36
|
isDisabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.d.ts","sourceRoot":"","sources":["../../src/components/DateRangePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAO/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAA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AC9B,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,IAAW,EACX,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,OAAO,EACP,aAAiB,EACjB,WAAkB,EAClB,IAAI,EACJ,aAA+B,EAC/B,UAAoB,EACpB,YAAqC,EACrC,SAAS,EACT,gBAAgB,EAChB,EAAE,GACH,EAAE,oBAAoB,qBAiQtB;yBA1Re,eAAe"}
|
|
@@ -99,7 +99,17 @@ export function DateRangePicker({ label, description, errorMessage, isInvalid, i
|
|
|
99
99
|
start: toIso(state.value.start),
|
|
100
100
|
end: toIso(state.value.end),
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
/*
|
|
103
|
+
* Invalid is the prop OR the picker's own validation — TimeField's rule.
|
|
104
|
+
* Left to the prop alone, a date outside `minValue`/`maxValue`, or an end before the start, marked the segments
|
|
105
|
+
* aria-invalid and left the box looking valid. With no `errorMessage`,
|
|
106
|
+
* React Aria's own localized message says what is wrong.
|
|
107
|
+
*/
|
|
108
|
+
const { isInvalid: failsValidation, validationErrors } = state.displayValidation;
|
|
109
|
+
const invalid = !!isInvalid || failsValidation;
|
|
110
|
+
const error = errorMessage ??
|
|
111
|
+
(validationErrors.length ? validationErrors.join(' ') : null);
|
|
112
|
+
const helper = invalid && error ? error : description;
|
|
103
113
|
const rail = resolvedPresets.length ? (_jsx("div", { className: "ion-range-presets", role: "group", "aria-label": presetsLabel, children: resolvedPresets.map((p) => {
|
|
104
114
|
const isSelected = selectedIso?.start === p.start && selectedIso?.end === p.end;
|
|
105
115
|
return (_jsx("button", { type: "button", className: "ion-range-presets__item", "aria-pressed": isSelected, "data-selected": isSelected || undefined, onClick: () => {
|
|
@@ -127,7 +137,7 @@ export function DateRangePicker({ label, description, errorMessage, isInvalid, i
|
|
|
127
137
|
}, children: clearLabel }) })) : null;
|
|
128
138
|
return (_jsxs("div", { className: [
|
|
129
139
|
'ion-field',
|
|
130
|
-
|
|
140
|
+
invalid ? 'ion-field--error' : '',
|
|
131
141
|
wrapperClassName || '',
|
|
132
142
|
]
|
|
133
143
|
.filter(Boolean)
|
|
@@ -138,15 +148,13 @@ export function DateRangePicker({ label, description, errorMessage, isInvalid, i
|
|
|
138
148
|
'ion-input',
|
|
139
149
|
'ion-date-range-picker',
|
|
140
150
|
size !== 'md' ? `ion-input--${size}` : '',
|
|
141
|
-
|
|
151
|
+
invalid ? 'ion-input--invalid' : '',
|
|
142
152
|
isDisabled ? 'ion-input--disabled' : '',
|
|
143
153
|
isReadOnly ? 'ion-input--readonly' : '',
|
|
144
154
|
className || '',
|
|
145
155
|
]
|
|
146
156
|
.filter(Boolean)
|
|
147
|
-
.join(' '), "data-open": state.isOpen || undefined, "data-invalid":
|
|
148
|
-
? errorMessageProps
|
|
149
|
-
: descriptionProps), className: "ion-field__helper", children: helper }))] }));
|
|
157
|
+
.join(' '), "data-open": state.isOpen || undefined, "data-invalid": invalid || undefined, "data-disabled": isDisabled || undefined, children: [_jsx(DateField, { ...startFieldProps }), _jsx("span", { className: "ion-date-range-picker__dash", "aria-hidden": "true", children: "\u2013" }), _jsx(DateField, { ...endFieldProps }), name && (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: `${name}-start`, value: state.value?.start ? toIso(state.value.start) : '' }), _jsx("input", { type: "hidden", name: `${name}-end`, value: state.value?.end ? toIso(state.value.end) : '' })] })), _jsx("button", { ...buttonProps, ref: buttonRef, type: "button", "aria-labelledby": undefined, "aria-label": calendarLabel, className: "ion-date-range-picker__button", children: _jsx(CalendarIcon, {}) })] }), state.isOpen && !isDisabled && !isReadOnly && (_jsx(CalendarPopover, { state: state, triggerRef: groupRef, dialogProps: dialogProps, className: "ion-calendar-popover--range", children: _jsx(RangeCalendar, { ...calendarProps, visibleMonths: visibleMonths, aside: rail, footer: footer }) })), helper && (_jsx("span", { ...(invalid && error ? errorMessageProps : descriptionProps), className: "ion-field__helper", children: helper }))] }));
|
|
150
158
|
}
|
|
151
159
|
DateRangePicker.displayName = 'DateRangePicker';
|
|
152
160
|
//# sourceMappingURL=DateRangePicker.js.map
|