@dloizides/ui-layout 1.1.0 → 1.3.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/CHANGELOG.md +37 -0
- package/README.md +84 -1
- package/dist/index.d.mts +92 -4
- package/dist/index.d.ts +92 -4
- package/dist/index.js +480 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +467 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
- Add **`Accordion`** + **`AccordionItem`** — a themed expand/collapse disclosure group that
|
|
6
|
+
replaces per-app hand-rolled `<details>` / expanders (AML "More options" + expandable
|
|
7
|
+
matched-candidate rows, Erevna survey groups, Katalogos menu sections…).
|
|
8
|
+
- Compound API: an `Accordion` container owns the open state and shares it with `AccordionItem`
|
|
9
|
+
children via context. Each item = a pressable header (title left, optional `right`
|
|
10
|
+
adornment/badge slot, a rotating chevron) over a collapsible body `region`.
|
|
11
|
+
- **Controlled** (`openIds` + `onOpenChange`) **and uncontrolled** (`defaultOpenIds`, plus
|
|
12
|
+
per-item `defaultOpen`). `allowMultiple` (default `true`) vs single-open. Per-item `disabled`.
|
|
13
|
+
- **a11y**: header is an accessible `button` (`accessibilityRole="button"`,
|
|
14
|
+
`accessibilityState={{ expanded }}`, web `aria-expanded` + `aria-controls`); body is a
|
|
15
|
+
`role="region"`. Renders as a native `<button>`, so **Enter / Space toggle** it.
|
|
16
|
+
- **Themed** entirely from the `@dloizides/ui-feedback` theme (border / surface / text colours),
|
|
17
|
+
no hardcoded palette; renders borderless so it nests inside a `Section` / `Card`.
|
|
18
|
+
- **Animated** open/close via a guarded `LayoutAnimation` (web- and native-safe no-op fallback,
|
|
19
|
+
never throws) + an `Animated` chevron rotation. Hook-safe (lazy `useState`, no ref reads in render).
|
|
20
|
+
- **Additive / backward-compatible**: purely new exports (`Accordion`, `AccordionItem`,
|
|
21
|
+
`AccordionProps`, `AccordionItemProps`). Existing consumers (erevna / katalogos / aml-v2) are
|
|
22
|
+
unaffected.
|
|
23
|
+
|
|
24
|
+
## 1.2.0
|
|
25
|
+
|
|
26
|
+
- `ModalDropdown` can now render as an **inline anchored menu** (native `<select>` feel), not only a
|
|
27
|
+
modal. New `variant?: DropdownVariant` prop (`Menu` | `Modal`) selects the presentation per screen.
|
|
28
|
+
- **Responsive default** (when `variant` is omitted): inline `Menu` on wide/desktop web
|
|
29
|
+
(viewport ≥ 768px), `Modal` on narrow/mobile and on any native platform. An explicit `variant`
|
|
30
|
+
overrides the auto choice.
|
|
31
|
+
- The inline menu anchors under the trigger, is dismissible via click-outside / `Esc`, is
|
|
32
|
+
keyboard-navigable (↑/↓, `Home`/`End`, `Enter`), scrolls when long, and does not push layout.
|
|
33
|
+
The modal path is unchanged. Both variants share the same option-rendering/selection logic
|
|
34
|
+
(`OptionRow`), so nothing is duplicated.
|
|
35
|
+
- **Additive / backward-compatible**: existing `ModalDropdown` callers (erevna / katalogos / aml-v2)
|
|
36
|
+
keep their exact API and now get the inline-on-desktop menu automatically. New export:
|
|
37
|
+
`DropdownVariant` (a runtime enum — deliberately not `const enum`, which cannot cross a published
|
|
38
|
+
package boundary under `isolatedModules`).
|
|
39
|
+
|
|
3
40
|
## 1.1.0
|
|
4
41
|
|
|
5
42
|
- Add `ModalShell` — slide-up full-screen modal with a themed header (title + close) and scrollable body.
|
package/README.md
CHANGED
|
@@ -11,9 +11,92 @@ Read theme + translations from the shared `@dloizides/ui-feedback` context (`use
|
|
|
11
11
|
| `Heading` | Themed section heading text. |
|
|
12
12
|
| `StatusBadge` | Status pill — caller supplies `label`/`color`/`backgroundColor`. |
|
|
13
13
|
| `UpgradePrompt` | Free-tier upgrade nudge; CTA navigates to the billing route via `useUi().navigate`. |
|
|
14
|
-
| `ModalDropdown` | Generic
|
|
14
|
+
| `ModalDropdown` | Generic dropdown selector. **Responsive by default**: an inline anchored menu on wide/desktop web, a modal on narrow/mobile — override per screen with `variant`. |
|
|
15
|
+
| `DropdownVariant` | Enum (`Menu` / `Modal`) to force a `ModalDropdown` rendering variant. |
|
|
16
|
+
| `Accordion` / `AccordionItem` | Themed expand/collapse disclosure group (replaces hand-rolled `<details>`/expanders). Controlled or uncontrolled, single- or multi-open, animated, keyboard + screen-reader accessible. |
|
|
15
17
|
| `useFocusTrap` | Web keyboard focus-trap hook (no-op on native). |
|
|
16
18
|
|
|
19
|
+
### `Accordion`
|
|
20
|
+
|
|
21
|
+
A compound component: an `Accordion` container that owns the open state + `AccordionItem`
|
|
22
|
+
children that read it via context. Each item is a pressable header (title left, optional
|
|
23
|
+
`right` adornment/badge slot, a rotating chevron) over a collapsible body `region`.
|
|
24
|
+
|
|
25
|
+
- **Controlled** — pass `openIds` + `onOpenChange`.
|
|
26
|
+
- **Uncontrolled** — pass `defaultOpenIds` on the container and/or `defaultOpen` per item.
|
|
27
|
+
- **`allowMultiple`** (default `true`) keeps any number of items open; `false` = single-open.
|
|
28
|
+
- **Per-item `disabled`.**
|
|
29
|
+
- **a11y** — header is an accessible `button` (`accessibilityRole="button"`,
|
|
30
|
+
`accessibilityState={{ expanded }}`, web `aria-expanded` + `aria-controls`); the body is a
|
|
31
|
+
`role="region"`. The header renders as a native `<button>`, so **Enter / Space toggle** it.
|
|
32
|
+
- **Themed** entirely from the active `useUi()` theme (border / surface / text colours). Renders
|
|
33
|
+
borderless so it drops cleanly inside a `Section` / `Card`.
|
|
34
|
+
- **Animated** open/close via guarded `LayoutAnimation` (a no-op where unavailable — never errors
|
|
35
|
+
on web or native) plus an `Animated` chevron rotation.
|
|
36
|
+
- **testIDs** — container `testID` (default `accordion`); per item the header is
|
|
37
|
+
`testID` (default `accordion-item-<id>`), the body `<header>-body`, the chevron `<header>-chevron`.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { Accordion, AccordionItem, Section, StatusBadge } from '@dloizides/ui-layout';
|
|
41
|
+
|
|
42
|
+
// 1) A form "More options" disclosure (single collapsible section, starts closed):
|
|
43
|
+
<Section>
|
|
44
|
+
<Accordion>
|
|
45
|
+
<AccordionItem id="more" title="More options">
|
|
46
|
+
<FuzzinessSlider />
|
|
47
|
+
<DatasetPicker />
|
|
48
|
+
</AccordionItem>
|
|
49
|
+
</Accordion>
|
|
50
|
+
</Section>
|
|
51
|
+
|
|
52
|
+
// 2) An expandable list row per matched candidate (single-open, badge in the right slot):
|
|
53
|
+
<Accordion allowMultiple={false} onOpenChange={(ids) => setOpenRow(ids[0])}>
|
|
54
|
+
{candidates.map((c) => (
|
|
55
|
+
<AccordionItem
|
|
56
|
+
key={c.id}
|
|
57
|
+
id={c.id}
|
|
58
|
+
title={c.name}
|
|
59
|
+
right={<StatusBadge label={c.tier} color={c.fg} backgroundColor={c.bg} />}
|
|
60
|
+
>
|
|
61
|
+
<CandidateDetail candidate={c} />
|
|
62
|
+
</AccordionItem>
|
|
63
|
+
))}
|
|
64
|
+
</Accordion>
|
|
65
|
+
|
|
66
|
+
// Controlled variant:
|
|
67
|
+
<Accordion openIds={openIds} onOpenChange={setOpenIds}>{/* …items… */}</Accordion>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The apps supply the header hint string via the shared translate: key `common.accordionToggleHint`.
|
|
71
|
+
|
|
72
|
+
### `ModalDropdown` variants
|
|
73
|
+
|
|
74
|
+
`ModalDropdown` picks its presentation automatically:
|
|
75
|
+
|
|
76
|
+
- **Wide / desktop web** (viewport ≥ 768px) → an **inline anchored menu** that opens directly
|
|
77
|
+
under the trigger (native `<select>` feel): dismissible via click-outside / `Esc`,
|
|
78
|
+
keyboard-navigable (↑/↓, `Home`/`End`, `Enter`), scrolls when long, and never pushes layout.
|
|
79
|
+
- **Narrow / mobile, or any native platform** → the original **modal** / bottom-sheet.
|
|
80
|
+
|
|
81
|
+
Pass `variant` to force either behaviour regardless of viewport — the prop overrides the auto choice:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { ModalDropdown, DropdownVariant } from '@dloizides/ui-layout';
|
|
85
|
+
|
|
86
|
+
// Responsive (default): inline menu on desktop, modal on mobile.
|
|
87
|
+
<ModalDropdown testID="risk" accessibilityLabel="Risk" accessibilityHint="Pick a risk level"
|
|
88
|
+
value={risk} options={riskOptions} onChange={setRisk} />
|
|
89
|
+
|
|
90
|
+
// Force the inline menu everywhere:
|
|
91
|
+
<ModalDropdown /* …props… */ variant={DropdownVariant.Menu} />
|
|
92
|
+
|
|
93
|
+
// Force the modal everywhere:
|
|
94
|
+
<ModalDropdown /* …props… */ variant={DropdownVariant.Modal} />
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The public API is additive — callers that never pass `variant` keep working and now
|
|
98
|
+
get the inline-on-desktop menu for free.
|
|
99
|
+
|
|
17
100
|
## Install
|
|
18
101
|
|
|
19
102
|
```bash
|
package/dist/index.d.mts
CHANGED
|
@@ -54,14 +54,39 @@ interface UpgradePromptProps {
|
|
|
54
54
|
declare const UpgradePrompt: ({ requiredTier, currentTier, onDismiss, billingRoute, }: UpgradePromptProps) => React.ReactElement;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* How a {@link ModalDropdown} renders its list of options.
|
|
58
|
+
*
|
|
59
|
+
* Exported as a regular (non-`const`) enum on purpose: `const enum` values are
|
|
60
|
+
* inlined at compile time and cannot cross a published-package boundary when the
|
|
61
|
+
* consumer bundles with `isolatedModules` (esbuild / vite / babel — i.e. every
|
|
62
|
+
* app that consumes this package). A regular enum emits a runtime object that is
|
|
63
|
+
* safe to import and compare in any consumer.
|
|
59
64
|
*/
|
|
65
|
+
declare enum DropdownVariant {
|
|
66
|
+
/** Inline popover anchored directly under the trigger — the native `<select>` feel. */
|
|
67
|
+
Menu = "menu",
|
|
68
|
+
/** Full modal / bottom-sheet overlay with a scrim (the original behaviour). */
|
|
69
|
+
Modal = "modal"
|
|
70
|
+
}
|
|
60
71
|
|
|
72
|
+
/** Shared option shape for the ModalDropdown family (kept separate to avoid import cycles). */
|
|
61
73
|
interface DropdownOption<T> {
|
|
62
74
|
readonly label: string;
|
|
63
75
|
readonly value: T;
|
|
64
76
|
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* ModalDropdown — generic dropdown selector (any value type via generics).
|
|
80
|
+
*
|
|
81
|
+
* Renders as either an inline anchored menu (web-native `<select>` feel) or a
|
|
82
|
+
* modal / bottom-sheet, selectable per screen via the `variant` prop. When
|
|
83
|
+
* `variant` is omitted the choice is **responsive**: inline menu on wide/desktop
|
|
84
|
+
* web, modal on narrow/mobile (and always modal on native). Existing callers that
|
|
85
|
+
* never passed `variant` therefore get the inline-on-desktop behaviour for free.
|
|
86
|
+
*
|
|
87
|
+
* Both variants share {@link OptionRow} for option rendering + selection.
|
|
88
|
+
*/
|
|
89
|
+
|
|
65
90
|
interface ModalDropdownProps<T> {
|
|
66
91
|
testID: string;
|
|
67
92
|
accessibilityLabel: string;
|
|
@@ -69,8 +94,14 @@ interface ModalDropdownProps<T> {
|
|
|
69
94
|
value: T;
|
|
70
95
|
options: ReadonlyArray<DropdownOption<T>>;
|
|
71
96
|
onChange: (value: T) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Force a rendering variant. When omitted the dropdown is **responsive**:
|
|
99
|
+
* an inline anchored menu on wide/desktop web, a modal on narrow/mobile
|
|
100
|
+
* (and always a modal on native). An explicit value overrides the auto choice.
|
|
101
|
+
*/
|
|
102
|
+
variant?: DropdownVariant;
|
|
72
103
|
}
|
|
73
|
-
declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, }: ModalDropdownProps<T>) => React.ReactElement;
|
|
104
|
+
declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, }: ModalDropdownProps<T>) => React.ReactElement;
|
|
74
105
|
|
|
75
106
|
/**
|
|
76
107
|
* ModalShell — a slide-up full-screen modal with a themed header (title + close button)
|
|
@@ -87,6 +118,62 @@ interface ModalShellProps {
|
|
|
87
118
|
}
|
|
88
119
|
declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
|
|
89
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Accordion — a themed expand/collapse disclosure group.
|
|
123
|
+
*
|
|
124
|
+
* Owns the open-item state and shares it with its {@link AccordionItem} children via
|
|
125
|
+
* context. Works controlled (`openIds` + `onOpenChange`) or uncontrolled
|
|
126
|
+
* (`defaultOpenIds`, plus per-item `defaultOpen`). `allowMultiple` (default) lets any
|
|
127
|
+
* number of items be open at once; set it false for single-open (radio-like) behaviour.
|
|
128
|
+
*
|
|
129
|
+
* Renders borderless so it drops cleanly inside a `Section` / `Card`.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
interface AccordionProps {
|
|
133
|
+
/** `AccordionItem` children. */
|
|
134
|
+
children?: React.ReactNode;
|
|
135
|
+
/** Controlled open ids. When provided, the accordion is controlled. */
|
|
136
|
+
openIds?: readonly string[];
|
|
137
|
+
/** Initial open ids in uncontrolled mode. */
|
|
138
|
+
defaultOpenIds?: readonly string[];
|
|
139
|
+
/** Fired with the next open-id set whenever an item toggles. */
|
|
140
|
+
onOpenChange?: (openIds: string[]) => void;
|
|
141
|
+
/** Allow several items open at once (default true). False = single-open. */
|
|
142
|
+
allowMultiple?: boolean;
|
|
143
|
+
testID?: string;
|
|
144
|
+
style?: ViewStyle | ViewStyle[];
|
|
145
|
+
}
|
|
146
|
+
declare const Accordion: ({ children, openIds, defaultOpenIds, onOpenChange, allowMultiple, testID, style, }: AccordionProps) => React.ReactElement;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* AccordionItem — one disclosure row: a pressable header (title left, optional right
|
|
150
|
+
* adornment/badge slot, a rotating chevron) plus a collapsible body region.
|
|
151
|
+
*
|
|
152
|
+
* Reads its open state + toggle from the enclosing {@link Accordion} via context.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
interface AccordionItemProps {
|
|
156
|
+
/** Stable unique id used for open-state tracking + derived testIDs. */
|
|
157
|
+
id: string;
|
|
158
|
+
/** Header title — a string (rendered as themed text) or custom node. */
|
|
159
|
+
title: string | React.ReactNode;
|
|
160
|
+
/** Optional right-hand adornment (badge, count, icon…) shown before the chevron. */
|
|
161
|
+
right?: React.ReactNode;
|
|
162
|
+
/** Collapsible body content. */
|
|
163
|
+
children?: React.ReactNode;
|
|
164
|
+
/** Start open in uncontrolled mode (ignored when the container is controlled). */
|
|
165
|
+
defaultOpen?: boolean;
|
|
166
|
+
/** Disable toggling for this item. */
|
|
167
|
+
disabled?: boolean;
|
|
168
|
+
/** testID for the header button. Body = `${testID}-body`, chevron = `${testID}-chevron`. */
|
|
169
|
+
testID?: string;
|
|
170
|
+
/** Accessible name for the header button (defaults to `title` when it is a string). */
|
|
171
|
+
accessibilityLabel?: string;
|
|
172
|
+
/** Accessible hint for the header button. */
|
|
173
|
+
accessibilityHint?: string;
|
|
174
|
+
}
|
|
175
|
+
declare const AccordionItem: ({ id, title, right, children, defaultOpen: _defaultOpen, disabled, testID, accessibilityLabel, accessibilityHint, }: AccordionItemProps) => React.ReactElement;
|
|
176
|
+
|
|
90
177
|
declare function useFocusTrap(containerRef: RefObject<View | null>, enabled: boolean): void;
|
|
91
178
|
|
|
92
179
|
/** Default testIDs — match the apps' existing values so Playwright selectors keep working. */
|
|
@@ -98,8 +185,9 @@ declare const LAYOUT_TEST_IDS: {
|
|
|
98
185
|
readonly upgradePromptDismiss: "upgrade-prompt-dismiss";
|
|
99
186
|
readonly modalShell: "template-modal";
|
|
100
187
|
readonly modalShellClose: "cancel-button";
|
|
188
|
+
readonly accordion: "accordion";
|
|
101
189
|
};
|
|
102
190
|
/** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
|
|
103
191
|
declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
104
192
|
|
|
105
|
-
export { DEFAULT_BILLING_ROUTE, type DropdownOption, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
|
|
193
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, DEFAULT_BILLING_ROUTE, type DropdownOption, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,14 +54,39 @@ interface UpgradePromptProps {
|
|
|
54
54
|
declare const UpgradePrompt: ({ requiredTier, currentTier, onDismiss, billingRoute, }: UpgradePromptProps) => React.ReactElement;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* How a {@link ModalDropdown} renders its list of options.
|
|
58
|
+
*
|
|
59
|
+
* Exported as a regular (non-`const`) enum on purpose: `const enum` values are
|
|
60
|
+
* inlined at compile time and cannot cross a published-package boundary when the
|
|
61
|
+
* consumer bundles with `isolatedModules` (esbuild / vite / babel — i.e. every
|
|
62
|
+
* app that consumes this package). A regular enum emits a runtime object that is
|
|
63
|
+
* safe to import and compare in any consumer.
|
|
59
64
|
*/
|
|
65
|
+
declare enum DropdownVariant {
|
|
66
|
+
/** Inline popover anchored directly under the trigger — the native `<select>` feel. */
|
|
67
|
+
Menu = "menu",
|
|
68
|
+
/** Full modal / bottom-sheet overlay with a scrim (the original behaviour). */
|
|
69
|
+
Modal = "modal"
|
|
70
|
+
}
|
|
60
71
|
|
|
72
|
+
/** Shared option shape for the ModalDropdown family (kept separate to avoid import cycles). */
|
|
61
73
|
interface DropdownOption<T> {
|
|
62
74
|
readonly label: string;
|
|
63
75
|
readonly value: T;
|
|
64
76
|
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* ModalDropdown — generic dropdown selector (any value type via generics).
|
|
80
|
+
*
|
|
81
|
+
* Renders as either an inline anchored menu (web-native `<select>` feel) or a
|
|
82
|
+
* modal / bottom-sheet, selectable per screen via the `variant` prop. When
|
|
83
|
+
* `variant` is omitted the choice is **responsive**: inline menu on wide/desktop
|
|
84
|
+
* web, modal on narrow/mobile (and always modal on native). Existing callers that
|
|
85
|
+
* never passed `variant` therefore get the inline-on-desktop behaviour for free.
|
|
86
|
+
*
|
|
87
|
+
* Both variants share {@link OptionRow} for option rendering + selection.
|
|
88
|
+
*/
|
|
89
|
+
|
|
65
90
|
interface ModalDropdownProps<T> {
|
|
66
91
|
testID: string;
|
|
67
92
|
accessibilityLabel: string;
|
|
@@ -69,8 +94,14 @@ interface ModalDropdownProps<T> {
|
|
|
69
94
|
value: T;
|
|
70
95
|
options: ReadonlyArray<DropdownOption<T>>;
|
|
71
96
|
onChange: (value: T) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Force a rendering variant. When omitted the dropdown is **responsive**:
|
|
99
|
+
* an inline anchored menu on wide/desktop web, a modal on narrow/mobile
|
|
100
|
+
* (and always a modal on native). An explicit value overrides the auto choice.
|
|
101
|
+
*/
|
|
102
|
+
variant?: DropdownVariant;
|
|
72
103
|
}
|
|
73
|
-
declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, }: ModalDropdownProps<T>) => React.ReactElement;
|
|
104
|
+
declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, }: ModalDropdownProps<T>) => React.ReactElement;
|
|
74
105
|
|
|
75
106
|
/**
|
|
76
107
|
* ModalShell — a slide-up full-screen modal with a themed header (title + close button)
|
|
@@ -87,6 +118,62 @@ interface ModalShellProps {
|
|
|
87
118
|
}
|
|
88
119
|
declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
|
|
89
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Accordion — a themed expand/collapse disclosure group.
|
|
123
|
+
*
|
|
124
|
+
* Owns the open-item state and shares it with its {@link AccordionItem} children via
|
|
125
|
+
* context. Works controlled (`openIds` + `onOpenChange`) or uncontrolled
|
|
126
|
+
* (`defaultOpenIds`, plus per-item `defaultOpen`). `allowMultiple` (default) lets any
|
|
127
|
+
* number of items be open at once; set it false for single-open (radio-like) behaviour.
|
|
128
|
+
*
|
|
129
|
+
* Renders borderless so it drops cleanly inside a `Section` / `Card`.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
interface AccordionProps {
|
|
133
|
+
/** `AccordionItem` children. */
|
|
134
|
+
children?: React.ReactNode;
|
|
135
|
+
/** Controlled open ids. When provided, the accordion is controlled. */
|
|
136
|
+
openIds?: readonly string[];
|
|
137
|
+
/** Initial open ids in uncontrolled mode. */
|
|
138
|
+
defaultOpenIds?: readonly string[];
|
|
139
|
+
/** Fired with the next open-id set whenever an item toggles. */
|
|
140
|
+
onOpenChange?: (openIds: string[]) => void;
|
|
141
|
+
/** Allow several items open at once (default true). False = single-open. */
|
|
142
|
+
allowMultiple?: boolean;
|
|
143
|
+
testID?: string;
|
|
144
|
+
style?: ViewStyle | ViewStyle[];
|
|
145
|
+
}
|
|
146
|
+
declare const Accordion: ({ children, openIds, defaultOpenIds, onOpenChange, allowMultiple, testID, style, }: AccordionProps) => React.ReactElement;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* AccordionItem — one disclosure row: a pressable header (title left, optional right
|
|
150
|
+
* adornment/badge slot, a rotating chevron) plus a collapsible body region.
|
|
151
|
+
*
|
|
152
|
+
* Reads its open state + toggle from the enclosing {@link Accordion} via context.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
interface AccordionItemProps {
|
|
156
|
+
/** Stable unique id used for open-state tracking + derived testIDs. */
|
|
157
|
+
id: string;
|
|
158
|
+
/** Header title — a string (rendered as themed text) or custom node. */
|
|
159
|
+
title: string | React.ReactNode;
|
|
160
|
+
/** Optional right-hand adornment (badge, count, icon…) shown before the chevron. */
|
|
161
|
+
right?: React.ReactNode;
|
|
162
|
+
/** Collapsible body content. */
|
|
163
|
+
children?: React.ReactNode;
|
|
164
|
+
/** Start open in uncontrolled mode (ignored when the container is controlled). */
|
|
165
|
+
defaultOpen?: boolean;
|
|
166
|
+
/** Disable toggling for this item. */
|
|
167
|
+
disabled?: boolean;
|
|
168
|
+
/** testID for the header button. Body = `${testID}-body`, chevron = `${testID}-chevron`. */
|
|
169
|
+
testID?: string;
|
|
170
|
+
/** Accessible name for the header button (defaults to `title` when it is a string). */
|
|
171
|
+
accessibilityLabel?: string;
|
|
172
|
+
/** Accessible hint for the header button. */
|
|
173
|
+
accessibilityHint?: string;
|
|
174
|
+
}
|
|
175
|
+
declare const AccordionItem: ({ id, title, right, children, defaultOpen: _defaultOpen, disabled, testID, accessibilityLabel, accessibilityHint, }: AccordionItemProps) => React.ReactElement;
|
|
176
|
+
|
|
90
177
|
declare function useFocusTrap(containerRef: RefObject<View | null>, enabled: boolean): void;
|
|
91
178
|
|
|
92
179
|
/** Default testIDs — match the apps' existing values so Playwright selectors keep working. */
|
|
@@ -98,8 +185,9 @@ declare const LAYOUT_TEST_IDS: {
|
|
|
98
185
|
readonly upgradePromptDismiss: "upgrade-prompt-dismiss";
|
|
99
186
|
readonly modalShell: "template-modal";
|
|
100
187
|
readonly modalShellClose: "cancel-button";
|
|
188
|
+
readonly accordion: "accordion";
|
|
101
189
|
};
|
|
102
190
|
/** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
|
|
103
191
|
declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
104
192
|
|
|
105
|
-
export { DEFAULT_BILLING_ROUTE, type DropdownOption, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
|
|
193
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, DEFAULT_BILLING_ROUTE, type DropdownOption, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
|