ionbase-ui 0.81.1 → 0.86.0
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/Checkbox.d.ts +39 -0
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +77 -4
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Fieldset.d.ts +62 -0
- package/dist/components/Fieldset.d.ts.map +1 -0
- package/dist/components/Fieldset.js +58 -0
- package/dist/components/Fieldset.js.map +1 -0
- package/dist/components/Menu.d.ts +87 -24
- package/dist/components/Menu.d.ts.map +1 -1
- package/dist/components/Menu.js +245 -28
- package/dist/components/Menu.js.map +1 -1
- package/dist/components/PageHeader.d.ts +59 -0
- package/dist/components/PageHeader.d.ts.map +1 -0
- package/dist/components/PageHeader.js +29 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/Radio.d.ts +14 -0
- package/dist/components/Radio.d.ts.map +1 -1
- package/dist/components/Radio.js +15 -4
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/SearchField.d.ts +36 -0
- package/dist/components/SearchField.d.ts.map +1 -0
- package/dist/components/SearchField.js +76 -0
- package/dist/components/SearchField.js.map +1 -0
- package/dist/components/index.d.ts +10 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -2
- package/dist/components/index.js.map +1 -1
- package/dist/figma-descriptions.json +96 -76
- package/dist/figma-map.json +272 -39
- package/dist/meta/Checkbox.json +8 -6
- package/dist/meta/CheckboxGroup.json +268 -0
- package/dist/meta/Divider.json +2 -2
- package/dist/meta/Fieldset.json +162 -0
- package/dist/meta/Menu.json +201 -27
- package/dist/meta/MenuItem.json +137 -17
- package/dist/meta/MenuSection.json +90 -0
- package/dist/meta/MenuTrigger.json +177 -0
- package/dist/meta/PageHeader.json +169 -0
- package/dist/meta/Radio.json +0 -1
- package/dist/meta/RadioGroup.json +59 -7
- package/dist/meta/SearchField.json +487 -0
- package/dist/meta/Stepper.json +2 -2
- package/dist/meta/Tabs.json +3 -3
- package/dist/meta/components.json +1917 -217
- package/dist/meta/contrast.json +594 -90
- package/dist/meta/index.json +89 -10
- package/dist/meta/patterns/DataTable.json +14 -6
- package/dist/meta/patterns/Form.json +27 -2
- package/dist/meta/patterns/PageShell.json +18 -5
- package/dist/meta/patterns/index.json +5 -2
- package/dist/styles/fieldset.css +65 -0
- package/dist/styles/index.css +3 -0
- package/dist/styles/menu.css +153 -32
- package/dist/styles/page-header.css +94 -0
- package/dist/styles/radio.css +0 -20
- package/dist/styles/search-field.css +70 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type FieldsetOrientation } from './Fieldset.js';
|
|
2
3
|
import { type SelectionProps } from './resolve-selection.js';
|
|
3
4
|
export type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
4
5
|
export type CheckboxIntent = 'brand' | 'neutral' | 'danger';
|
|
@@ -34,4 +35,42 @@ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
34
35
|
* declaratively and it must be written after every render.
|
|
35
36
|
*/
|
|
36
37
|
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
38
|
+
export interface CheckboxGroupProps extends Omit<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, 'onChange' | 'defaultValue' | 'disabled'> {
|
|
39
|
+
/** The question the options answer. Renders as the `<legend>`. */
|
|
40
|
+
label?: React.ReactNode;
|
|
41
|
+
/** Help text beneath the options. Replaced by `errorMessage` while invalid. */
|
|
42
|
+
description?: React.ReactNode;
|
|
43
|
+
/** Shown in the description's place while `isInvalid` is set. */
|
|
44
|
+
errorMessage?: React.ReactNode;
|
|
45
|
+
/** Marks every box invalid and shows `errorMessage`. */
|
|
46
|
+
isInvalid?: boolean;
|
|
47
|
+
/** At least one option must be selected — enforced by native validation. */
|
|
48
|
+
isRequired?: boolean;
|
|
49
|
+
/** The selected values (controlled). */
|
|
50
|
+
value?: readonly string[];
|
|
51
|
+
/** The initially selected values (uncontrolled). */
|
|
52
|
+
defaultValue?: readonly string[];
|
|
53
|
+
/** Receives the whole new selection, in the order the options were ticked. */
|
|
54
|
+
onChange?: (value: string[]) => void;
|
|
55
|
+
/** Shared input name, so a form submits every ticked value under it. */
|
|
56
|
+
name?: string;
|
|
57
|
+
size?: CheckboxSize;
|
|
58
|
+
intent?: CheckboxIntent;
|
|
59
|
+
/** Whether every checkbox in the group is disabled. */
|
|
60
|
+
isDisabled?: boolean;
|
|
61
|
+
orientation?: FieldsetOrientation;
|
|
62
|
+
/** Checkboxes, each with a `value`. */
|
|
63
|
+
children?: React.ReactNode;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A set of checkboxes that answers one question — "notify me when…", "which
|
|
67
|
+
* regions". Owns the selected values, the group's label, help text and error,
|
|
68
|
+
* and "select at least one".
|
|
69
|
+
*
|
|
70
|
+
* A row of loose Checkboxes can do none of that accessibly: the question is
|
|
71
|
+
* not announced with the options, an error has nothing to attach to, and
|
|
72
|
+
* "at least one" has no native expression at all. See the `required` note in
|
|
73
|
+
* Checkbox for how that last one is done.
|
|
74
|
+
*/
|
|
75
|
+
export declare const CheckboxGroup: React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
37
76
|
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAoB,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CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,uCAAuC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,gGA+DxB,CAAC"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef,
|
|
3
|
+
import { createContext, forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState, } from 'react';
|
|
4
|
+
import { FieldsetShell, useFieldsetHelper, } from './Fieldset.js';
|
|
4
5
|
import { resolveDisabled } from './resolve-disabled.js';
|
|
5
6
|
import { resolveSelection } from './resolve-selection.js';
|
|
7
|
+
/**
|
|
8
|
+
* Lets CheckboxGroup own the selected values the way RadioGroup owns the
|
|
9
|
+
* selected value: each Checkbox reads whether its `value` is in the set and
|
|
10
|
+
* reports its toggles, and the caller wires one `onChange` instead of one per
|
|
11
|
+
* option.
|
|
12
|
+
*/
|
|
13
|
+
const CheckboxGroupContext = createContext(null);
|
|
6
14
|
/** Figma's check glyph. Inlined for the same reason as Select's chevron: it is
|
|
7
15
|
* part of the control, not a slot a caller fills. */
|
|
8
16
|
const CheckMark = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "m5 13 4 4L19 7", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
@@ -20,9 +28,35 @@ const DashMark = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", "aria-
|
|
|
20
28
|
* declaratively and it must be written after every render.
|
|
21
29
|
*/
|
|
22
30
|
export const Checkbox = forwardRef((props, forwardedRef) => {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
31
|
+
const group = useContext(CheckboxGroupContext);
|
|
32
|
+
const { size = group?.size ?? 'md', intent = group?.intent ?? 'brand', isIndeterminate = false, className, children, isDisabled, disabled, isSelected, checked, onChange, onSelectionChange, name = group?.name, 'aria-describedby': describedBy, ...rest } = props;
|
|
33
|
+
const resolvedDisabled = resolveDisabled(isDisabled, disabled) ?? group?.isDisabled;
|
|
25
34
|
const selection = resolveSelection(isSelected, checked, onChange, onSelectionChange);
|
|
35
|
+
/*
|
|
36
|
+
* Inside a group the group owns `checked`, and the box's own handlers still
|
|
37
|
+
* fire after it — the contract RadioGroup settled on, so neither control
|
|
38
|
+
* honours a handler in one mode and drops it in the other.
|
|
39
|
+
*/
|
|
40
|
+
const value = rest.value === undefined ? '' : String(rest.value);
|
|
41
|
+
const groupSelection = group
|
|
42
|
+
? {
|
|
43
|
+
checked: group.selected.includes(value),
|
|
44
|
+
onChange: (event) => {
|
|
45
|
+
group.toggle(value, event.target.checked);
|
|
46
|
+
selection.onChange?.(event);
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
: selection;
|
|
50
|
+
/*
|
|
51
|
+
* "Select at least one", in the platform's own words. `required` on a
|
|
52
|
+
* checkbox means "this one must be ticked", so it is set on every box while
|
|
53
|
+
* none is and dropped from all of them the moment one is: native
|
|
54
|
+
* validation then blocks the submit with the browser's localised message,
|
|
55
|
+
* and each box announces "required" exactly while the rule is unmet.
|
|
56
|
+
*/
|
|
57
|
+
const required = group?.isRequired
|
|
58
|
+
? group.selected.length === 0
|
|
59
|
+
: rest.required;
|
|
26
60
|
const domRef = useRef(null);
|
|
27
61
|
useImperativeHandle(forwardedRef, () => domRef.current);
|
|
28
62
|
useEffect(() => {
|
|
@@ -38,7 +72,46 @@ export const Checkbox = forwardRef((props, forwardedRef) => {
|
|
|
38
72
|
]
|
|
39
73
|
.filter(Boolean)
|
|
40
74
|
.join(' ');
|
|
41
|
-
return (_jsxs("label", { className: classNames, children: [_jsx("input", { ...rest, ref: domRef, type: "checkbox", checked:
|
|
75
|
+
return (_jsxs("label", { className: classNames, children: [_jsx("input", { ...rest, ref: domRef, type: "checkbox", name: name, required: required, checked: groupSelection.checked, onChange: groupSelection.onChange, disabled: resolvedDisabled, "aria-invalid": group?.isInvalid || rest['aria-invalid'], "aria-describedby": [describedBy, group?.helperId].filter(Boolean).join(' ') ||
|
|
76
|
+
undefined, className: "ion-checkbox__input" }), _jsx("span", { className: "ion-checkbox__indicator", "aria-hidden": "true", children: _jsx("span", { className: "ion-checkbox__mark", children: isIndeterminate ? _jsx(DashMark, {}) : _jsx(CheckMark, {}) }) }), children && _jsx("span", { className: "ion-checkbox__label", children: children })] }));
|
|
42
77
|
});
|
|
43
78
|
Checkbox.displayName = 'Checkbox';
|
|
79
|
+
/**
|
|
80
|
+
* A set of checkboxes that answers one question — "notify me when…", "which
|
|
81
|
+
* regions". Owns the selected values, the group's label, help text and error,
|
|
82
|
+
* and "select at least one".
|
|
83
|
+
*
|
|
84
|
+
* A row of loose Checkboxes can do none of that accessibly: the question is
|
|
85
|
+
* not announced with the options, an error has nothing to attach to, and
|
|
86
|
+
* "at least one" has no native expression at all. See the `required` note in
|
|
87
|
+
* Checkbox for how that last one is done.
|
|
88
|
+
*/
|
|
89
|
+
export const CheckboxGroup = forwardRef((props, ref) => {
|
|
90
|
+
const { value: controlledValue, defaultValue, onChange, name, size, intent, isDisabled, isRequired, description, errorMessage, ...rest } = props;
|
|
91
|
+
const [uncontrolled, setUncontrolled] = useState(defaultValue ?? []);
|
|
92
|
+
const selected = controlledValue ?? uncontrolled;
|
|
93
|
+
const toggle = (value, isSelected) => {
|
|
94
|
+
const next = isSelected
|
|
95
|
+
? selected.includes(value)
|
|
96
|
+
? [...selected]
|
|
97
|
+
: [...selected, value]
|
|
98
|
+
: selected.filter((v) => v !== value);
|
|
99
|
+
if (controlledValue === undefined)
|
|
100
|
+
setUncontrolled(next);
|
|
101
|
+
onChange?.(next);
|
|
102
|
+
};
|
|
103
|
+
const { helper, helperId } = useFieldsetHelper(description, errorMessage, rest.isInvalid);
|
|
104
|
+
return (_jsx(CheckboxGroupContext.Provider, { value: {
|
|
105
|
+
name,
|
|
106
|
+
selected,
|
|
107
|
+
toggle,
|
|
108
|
+
size,
|
|
109
|
+
intent,
|
|
110
|
+
isDisabled,
|
|
111
|
+
isInvalid: rest.isInvalid,
|
|
112
|
+
isRequired,
|
|
113
|
+
helperId,
|
|
114
|
+
}, children: _jsx(FieldsetShell, { ...rest, ref: ref, disabled: isDisabled, isChoiceGroup: true, helper: helper, helperId: helperId }) }));
|
|
115
|
+
});
|
|
116
|
+
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
44
117
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EACZ,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EACZ,aAAa,EACb,UAAU,EACV,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,aAAa,EACb,iBAAiB,GAElB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAuB,MAAM,wBAAwB,CAAC;AAiB/E;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,aAAa,CACxC,IAAI,CACL,CAAC;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export interface FieldsetProps extends Omit<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, 'disabled'> {
|
|
4
|
+
/** The question the fields answer. Renders as the `<legend>`. */
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
/** Help text beneath the fields. Replaced by `errorMessage` while invalid. */
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
/** Shown in the description's place while `isInvalid` is set. */
|
|
9
|
+
errorMessage?: React.ReactNode;
|
|
10
|
+
/** Whether the group as a whole fails validation. */
|
|
11
|
+
isInvalid?: boolean;
|
|
12
|
+
/** How the fields flow. Horizontal wraps rather than overflowing. */
|
|
13
|
+
orientation?: FieldsetOrientation;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The ids a group hands down to its own controls. Kept separate from the
|
|
18
|
+
* rendering so CheckboxGroup and RadioGroup can give every checkbox and radio
|
|
19
|
+
* the same `aria-describedby` the fieldset carries — see FieldsetShell.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useFieldsetHelper(description: React.ReactNode, errorMessage: React.ReactNode, isInvalid: boolean | undefined): {
|
|
22
|
+
helper: React.ReactNode;
|
|
23
|
+
helperId: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
interface FieldsetShellProps extends Omit<FieldsetProps, 'description' | 'errorMessage'> {
|
|
26
|
+
/** Only the choice groups may disable natively — see Fieldset. */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** Choice groups space their options at 8, not a form's 16. */
|
|
29
|
+
isChoiceGroup?: boolean;
|
|
30
|
+
/** The description or the error, whichever shows — see useFieldsetHelper. */
|
|
31
|
+
helper: React.ReactNode;
|
|
32
|
+
helperId: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The rendering shared by Fieldset, CheckboxGroup and RadioGroup.
|
|
36
|
+
*
|
|
37
|
+
* A real `<fieldset>`: the legend names the group for assistive technology and
|
|
38
|
+
* the inputs stay grouped for form submission, neither of which a div with
|
|
39
|
+
* `role="group"` gets for free.
|
|
40
|
+
*
|
|
41
|
+
* The fieldset is `display: block` on purpose. A rendered `<legend>` is not a
|
|
42
|
+
* flex item — browsers lay it out in the fieldset's border, outside the flex
|
|
43
|
+
* container — so a flex column here would put `gap` everywhere but under the
|
|
44
|
+
* legend. The fields get a flex wrapper of their own instead.
|
|
45
|
+
*/
|
|
46
|
+
export declare const FieldsetShell: React.ForwardRefExoticComponent<FieldsetShellProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
47
|
+
/**
|
|
48
|
+
* Groups related fields under one label, with one description and one error —
|
|
49
|
+
* an address, a date range typed as two fields, a set of limits.
|
|
50
|
+
*
|
|
51
|
+
* For checkboxes use CheckboxGroup and for radios RadioGroup: both render this
|
|
52
|
+
* same shell, and add the selection state it deliberately does not own.
|
|
53
|
+
*
|
|
54
|
+
* There is no `isDisabled`. A native `disabled` fieldset does disable every
|
|
55
|
+
* control inside, but Input, Select and the rest draw their disabled state from
|
|
56
|
+
* their own prop, so the fields would stop working while still looking live.
|
|
57
|
+
* Disable the fields themselves; the choice groups can cascade because their
|
|
58
|
+
* checkboxes and radios style off `:disabled`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const Fieldset: React.ForwardRefExoticComponent<FieldsetProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=Fieldset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fieldset.d.ts","sourceRoot":"","sources":["../../src/components/Fieldset.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,YAAY,CAAC;AAE5D,MAAM,WAAW,aAAc,SAAQ,IAAI,CACzC,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EACjD,UAAU,CACX;IACC,iEAAiE;IACjE,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,iEAAiE;IACjE,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,KAAK,CAAC,SAAS,EAC5B,YAAY,EAAE,KAAK,CAAC,SAAS,EAC7B,SAAS,EAAE,OAAO,GAAG,SAAS;;;EAM/B;AAED,UAAU,kBAAmB,SAAQ,IAAI,CACvC,aAAa,EACb,aAAa,GAAG,cAAc,CAC/B;IACC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,6EAA6E;IAC7E,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,gGA4CxB,CAAC;AAIH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,2FAYpB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The ids a group hands down to its own controls. Kept separate from the
|
|
5
|
+
* rendering so CheckboxGroup and RadioGroup can give every checkbox and radio
|
|
6
|
+
* the same `aria-describedby` the fieldset carries — see FieldsetShell.
|
|
7
|
+
*/
|
|
8
|
+
export function useFieldsetHelper(description, errorMessage, isInvalid) {
|
|
9
|
+
const helperId = useId();
|
|
10
|
+
// Input's convention: the error takes the helper's slot, it does not stack.
|
|
11
|
+
const helper = isInvalid && errorMessage ? errorMessage : description;
|
|
12
|
+
return { helper, helperId: helper ? helperId : undefined };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The rendering shared by Fieldset, CheckboxGroup and RadioGroup.
|
|
16
|
+
*
|
|
17
|
+
* A real `<fieldset>`: the legend names the group for assistive technology and
|
|
18
|
+
* the inputs stay grouped for form submission, neither of which a div with
|
|
19
|
+
* `role="group"` gets for free.
|
|
20
|
+
*
|
|
21
|
+
* The fieldset is `display: block` on purpose. A rendered `<legend>` is not a
|
|
22
|
+
* flex item — browsers lay it out in the fieldset's border, outside the flex
|
|
23
|
+
* container — so a flex column here would put `gap` everywhere but under the
|
|
24
|
+
* legend. The fields get a flex wrapper of their own instead.
|
|
25
|
+
*/
|
|
26
|
+
export const FieldsetShell = forwardRef((props, ref) => {
|
|
27
|
+
const { label, isInvalid, orientation = 'vertical', isChoiceGroup = false, helper, helperId, className, children, 'aria-describedby': describedBy, ...rest } = props;
|
|
28
|
+
return (_jsxs("fieldset", { ...rest, ref: ref, "aria-describedby": [describedBy, helperId].filter(Boolean).join(' ') || undefined, "data-invalid": isInvalid || undefined, className: [
|
|
29
|
+
'ion-fieldset',
|
|
30
|
+
isChoiceGroup ? 'ion-fieldset--choices' : '',
|
|
31
|
+
orientation === 'horizontal' ? 'ion-fieldset--horizontal' : '',
|
|
32
|
+
isInvalid ? 'ion-fieldset--error' : '',
|
|
33
|
+
className || '',
|
|
34
|
+
]
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.join(' '), children: [label && _jsx("legend", { className: "ion-fieldset__legend", children: label }), _jsx("div", { className: "ion-fieldset__content", children: children }), helper && (_jsx("span", { id: helperId, className: "ion-fieldset__helper", children: helper }))] }));
|
|
37
|
+
});
|
|
38
|
+
FieldsetShell.displayName = 'FieldsetShell';
|
|
39
|
+
/**
|
|
40
|
+
* Groups related fields under one label, with one description and one error —
|
|
41
|
+
* an address, a date range typed as two fields, a set of limits.
|
|
42
|
+
*
|
|
43
|
+
* For checkboxes use CheckboxGroup and for radios RadioGroup: both render this
|
|
44
|
+
* same shell, and add the selection state it deliberately does not own.
|
|
45
|
+
*
|
|
46
|
+
* There is no `isDisabled`. A native `disabled` fieldset does disable every
|
|
47
|
+
* control inside, but Input, Select and the rest draw their disabled state from
|
|
48
|
+
* their own prop, so the fields would stop working while still looking live.
|
|
49
|
+
* Disable the fields themselves; the choice groups can cascade because their
|
|
50
|
+
* checkboxes and radios style off `:disabled`.
|
|
51
|
+
*/
|
|
52
|
+
export const Fieldset = forwardRef((props, ref) => {
|
|
53
|
+
const { description, errorMessage, ...rest } = props;
|
|
54
|
+
const { helper, helperId } = useFieldsetHelper(description, errorMessage, rest.isInvalid);
|
|
55
|
+
return (_jsx(FieldsetShell, { ...rest, ref: ref, helper: helper, helperId: helperId }));
|
|
56
|
+
});
|
|
57
|
+
Fieldset.displayName = 'Fieldset';
|
|
58
|
+
//# sourceMappingURL=Fieldset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fieldset.js","sourceRoot":"","sources":["../../src/components/Fieldset.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAqBjD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,WAA4B,EAC5B,YAA6B,EAC7B,SAA8B;IAE9B,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAC;IACzB,4EAA4E;IAC5E,MAAM,MAAM,GAAG,SAAS,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;IACtE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC;AAeD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,U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;IACrD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,iBAAiB,CAC5C,WAAW,EACX,YAAY,EACZ,IAAI,CAAC,SAAS,CACf,CAAC;IACF,OAAO,CACL,KAAC,aAAa,OAAK,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAC1E,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC"}
|
|
@@ -1,35 +1,98 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { type AriaMenuProps } from 'react-aria';
|
|
3
|
+
import { Section } from '@react-stately/collections';
|
|
4
|
+
import type { ItemProps } from '@react-types/shared';
|
|
5
|
+
export interface MenuProps<T extends object> extends AriaMenuProps<T> {
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
4
8
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* hard half to unpick later.
|
|
13
|
-
*
|
|
14
|
-
* `role="menu"` is deliberately NOT set. A real ARIA menu owes the user
|
|
15
|
-
* roving-tabindex arrow navigation, typeahead and focus containment; claiming
|
|
16
|
-
* the role without them is worse for a screen-reader user than an honest list,
|
|
17
|
-
* because it promises interactions that are not there. When the popover exists,
|
|
18
|
-
* the role comes with it.
|
|
19
|
-
*/
|
|
20
|
-
export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLUListElement>>;
|
|
21
|
-
export interface MenuItemProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
22
|
-
/** Figma's `Selected` / `Selected-hover` states. Shows the trailing check. */
|
|
23
|
-
isSelected?: boolean;
|
|
9
|
+
export interface MenuItemProps<T extends object = object> extends ItemProps<T> {
|
|
10
|
+
/**
|
|
11
|
+
* Only on a row that opens a submenu: the row's label. Its children are then
|
|
12
|
+
* the submenu's MenuItems rather than its label. Submenus open only inside a
|
|
13
|
+
* MenuTrigger — a standalone Menu has nothing to open them from.
|
|
14
|
+
*/
|
|
15
|
+
title?: React.ReactNode;
|
|
24
16
|
/** Figma's `Show Leading Icon` + `Leading Icon` swap. */
|
|
25
17
|
icon?: React.ReactNode;
|
|
26
|
-
/** Whether the item is disabled. */
|
|
18
|
+
/** Whether the item is disabled. Listed, skipped by the arrow keys. */
|
|
27
19
|
isDisabled?: boolean;
|
|
28
20
|
/**
|
|
29
21
|
* @deprecated Use `isDisabled`. Accepted as an alias for one minor version.
|
|
30
22
|
*/
|
|
31
23
|
disabled?: boolean;
|
|
32
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Put the item's key in Menu's `selectedKeys`. Accepted for one
|
|
26
|
+
* minor version: when no item's key is in `selectedKeys` and Menu is given
|
|
27
|
+
* neither `selectedKeys` nor `defaultSelectedKeys`, the items passing this
|
|
28
|
+
* become the selection.
|
|
29
|
+
*/
|
|
30
|
+
isSelected?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One row of a Menu. A collection element, like TabItem: it renders nothing
|
|
34
|
+
* itself — Menu reads its props and draws the row — so it only means anything
|
|
35
|
+
* as a direct child of Menu or MenuSection. Give it a `key`; that key is what
|
|
36
|
+
* `onAction` and `selectedKeys` speak in.
|
|
37
|
+
*/
|
|
38
|
+
export declare function MenuItem<T extends object>(_props: MenuItemProps<T>): React.ReactElement | null;
|
|
39
|
+
export declare namespace MenuItem {
|
|
40
|
+
var displayName: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A named group of MenuItems. `title` is Figma's `Menu Section Title`; without
|
|
44
|
+
* one, pass `aria-label` and the group is set off by a rule instead.
|
|
45
|
+
*/
|
|
46
|
+
export { Section as MenuSection };
|
|
47
|
+
/**
|
|
48
|
+
* Menu — Figma `Menu` (82:306), `Menu Item` and `Menu Section Title`.
|
|
49
|
+
*
|
|
50
|
+
* A real ARIA menu: `role="menu"`, one tab stop, arrow keys, Home and End,
|
|
51
|
+
* typeahead, and disabled rows listed but skipped. Figma's `Type` is
|
|
52
|
+
* `selectionMode` — Single draws one check, Multi draws several — and with
|
|
53
|
+
* a selection mode the rows become `menuitemradio` / `menuitemcheckbox` and
|
|
54
|
+
* announce their checked state.
|
|
55
|
+
*
|
|
56
|
+
* On its own it is the surface only, rendered in flow. Inside a MenuTrigger it
|
|
57
|
+
* floats, opens and closes, is named by its trigger, and can open submenus.
|
|
58
|
+
*/
|
|
59
|
+
export declare const Menu: <T extends object>(props: MenuProps<T> & {
|
|
60
|
+
ref?: React.Ref<HTMLUListElement>;
|
|
61
|
+
}) => React.ReactElement;
|
|
62
|
+
export type MenuTriggerPlacement = 'bottom start' | 'bottom end' | 'top start' | 'top end';
|
|
63
|
+
export interface MenuTriggerProps {
|
|
64
|
+
/**
|
|
65
|
+
* Exactly two children: the Button that opens the menu, then the Menu. The
|
|
66
|
+
* Button must accept a ref and react-aria press props — IonBase's Button
|
|
67
|
+
* does; a plain `<button>` does not.
|
|
68
|
+
*/
|
|
69
|
+
children: [React.ReactElement, React.ReactElement];
|
|
70
|
+
/**
|
|
71
|
+
* Where the menu opens, relative to the trigger. A preference, not a
|
|
72
|
+
* guarantee: it flips when there is no room.
|
|
73
|
+
*/
|
|
74
|
+
placement?: MenuTriggerPlacement;
|
|
75
|
+
/** Whether the trigger is disabled. */
|
|
76
|
+
isDisabled?: boolean;
|
|
77
|
+
isOpen?: boolean;
|
|
78
|
+
defaultOpen?: boolean;
|
|
79
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* MenuTrigger — a Button that opens a Menu.
|
|
83
|
+
*
|
|
84
|
+
* The "⋯" overflow menu is this with an icon-only Button; there is no separate
|
|
85
|
+
* component for it, because the only difference is the Button's content and
|
|
86
|
+
* its required aria-label.
|
|
87
|
+
*
|
|
88
|
+
* `useMenuTrigger` does what a Popover wrapped round a Menu could not: the
|
|
89
|
+
* trigger announces `aria-haspopup="menu"` and `aria-expanded`, the menu is
|
|
90
|
+
* named by the trigger, ArrowDown and ArrowUp open it with focus on the first
|
|
91
|
+
* or last row, and choosing an action closes it and returns focus to the
|
|
92
|
+
* trigger.
|
|
93
|
+
*/
|
|
94
|
+
export declare function MenuTrigger({ children, placement, isDisabled, ...stateProps }: MenuTriggerProps): React.JSX.Element;
|
|
95
|
+
export declare namespace MenuTrigger {
|
|
96
|
+
var displayName: string;
|
|
33
97
|
}
|
|
34
|
-
export declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
35
98
|
//# sourceMappingURL=Menu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../src/components/Menu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../src/components/Menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EAYL,KAAK,aAAa,EAEnB,MAAM,YAAY,CAAC;AAQpB,OAAO,EAGL,OAAO,EAER,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AAG3E,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC5E;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,yDAAyD;IACzD,I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