@dloizides/ui-layout 1.3.0 → 1.5.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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0
4
+
5
+ - `Accordion` / `AccordionItem` gain a `variant` prop (`'plain' | 'boxed'`, default `'plain'`).
6
+ `plain` is the original borderless look (hairline dividers, right-hand chevron flipping 180° on
7
+ open) — existing consumers render **identically**, no change. `boxed` is the AML v1 console
8
+ `<details>` look: each item is its own bordered, rounded box (spaced by a gap) with a **leading
9
+ ▸ marker** that rotates 90° on open and a muted, 600-weight summary. The full API is preserved
10
+ (controlled/uncontrolled, `allowMultiple`, `defaultOpen`, a11y `aria-expanded`/region, the
11
+ open/close LayoutAnimation + chevron rotation). Additive + backward-compatible.
12
+
13
+ ## 1.4.0
14
+
15
+ - Add **`SegmentedControl`** — a single rounded pill *track* holding N mutually-exclusive
16
+ segments (the iOS-style segmented / tab toggle). The selected segment lifts onto a raised
17
+ surface (`colors.surface`) with a subtle shadow; the rest stay transparent over the soft
18
+ track (`colors.background`). Promoted from the v1 AML console's `.lf-mode` mode switch so
19
+ erevna/katalogos/kefi share ONE toggle instead of hand-rolling two primary/ghost buttons.
20
+ - **Generic over the value union** (`SegmentedControl<'peps' | 'leaders'>`) for a typed
21
+ `onChange`; each segment carries its own `label` / `value` / optional `testID` +
22
+ `accessibilityLabel` / `accessibilityHint`.
23
+ - **a11y**: the group renders as a `tablist`, each segment as a `tab` with
24
+ `accessibilityState={{ selected }}` (react-native-web forwards `role` + `aria-selected`).
25
+ - **Themed** entirely from the `@dloizides/ui-feedback` theme (surface / background / border /
26
+ text colours); no colour literal except the selected-segment drop shadow.
27
+ - **Additive / backward-compatible**: purely new exports (`SegmentedControl`,
28
+ `SegmentedControlProps`, `SegmentedOption`). Existing consumers are unaffected.
29
+
3
30
  ## 1.3.0
4
31
 
5
32
  - Add **`Accordion`** + **`AccordionItem`** — a themed expand/collapse disclosure group that
package/dist/index.d.mts CHANGED
@@ -36,6 +36,47 @@ interface StatusBadgeProps {
36
36
  }
37
37
  declare const StatusBadge: ({ label, color, backgroundColor, testID, accessibilityLabel, accessibilityHint, }: StatusBadgeProps) => React.ReactElement;
38
38
 
39
+ /**
40
+ * SegmentedControl — a single rounded pill *track* holding N mutually-exclusive segments
41
+ * (the iOS-style segmented / tab toggle). The selected segment lifts onto a raised surface
42
+ * with a subtle shadow; the rest stay transparent. Promoted from the v1 AML console's
43
+ * `.lf-mode` mode switch so erevna/katalogos/kefi can share ONE toggle instead of
44
+ * hand-rolling two primary/ghost buttons.
45
+ *
46
+ * Contract discipline (same as the rest of `@dloizides/ui-layout`): NO FM/router/store/icon
47
+ * imports. Labels are pre-localized strings; every colour is read from the
48
+ * `@dloizides/ui-feedback` UiProvider theme, so it re-skins on tenant swap. Renders as a
49
+ * `tablist` of `tab`s (`accessibilityRole` + `accessibilityState.selected`, which
50
+ * react-native-web forwards to `role`/`aria-selected` on the DOM).
51
+ */
52
+
53
+ /** One selectable segment. `value` is what `onChange` emits when it's pressed. */
54
+ interface SegmentedOption<V extends string = string> {
55
+ label: string;
56
+ value: V;
57
+ testID?: string;
58
+ accessibilityLabel?: string;
59
+ accessibilityHint?: string;
60
+ }
61
+ interface SegmentedControlProps<V extends string = string> {
62
+ /** The segments, left → right. */
63
+ options: ReadonlyArray<SegmentedOption<V>>;
64
+ /** The currently-selected value. */
65
+ value: V;
66
+ /** Fired with a segment's `value` when it is pressed. */
67
+ onChange: (value: V) => void;
68
+ /** Accessible name for the whole group (the `tablist`). */
69
+ accessibilityLabel: string;
70
+ /** Optional style override merged LAST onto the track. */
71
+ style?: StyleProp<ViewStyle>;
72
+ testID?: string;
73
+ }
74
+ /**
75
+ * A segmented toggle. Generic over the value union so callers get a typed `onChange`
76
+ * (e.g. `SegmentedControl<'peps' | 'leaders'>`).
77
+ */
78
+ declare function SegmentedControl<V extends string = string>({ options, value, onChange, accessibilityLabel, style, testID, }: SegmentedControlProps<V>): React.ReactElement;
79
+
39
80
  /**
40
81
  * UpgradePrompt — shown when a free-tier user hits a feature limit. CTA navigates to the
41
82
  * billing route via the injected navigate (default route overridable).
@@ -118,6 +159,21 @@ interface ModalShellProps {
118
159
  }
119
160
  declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
120
161
 
162
+ /**
163
+ * AccordionVariant — the two visual treatments for an {@link Accordion}.
164
+ *
165
+ * A plain string union (not a const enum) so call sites stay ergonomic
166
+ * (`variant="boxed"`) and the package exposes no cross-boundary const-enum,
167
+ * matching the rest of the shared UI kit (e.g. `ButtonVariant`).
168
+ *
169
+ * - `plain` (default) — borderless rows separated by a hairline divider, with a
170
+ * right-hand chevron that flips 180° on open. Drops cleanly inside a Section / Card.
171
+ * - `boxed` — each item is its own bordered, rounded box with a LEADING ▸ marker that
172
+ * rotates 90° on open and a muted, 600-weight summary. Matches the AML v1 console's
173
+ * `<details>` panels.
174
+ */
175
+ type AccordionVariant = 'plain' | 'boxed';
176
+
121
177
  /**
122
178
  * Accordion — a themed expand/collapse disclosure group.
123
179
  *
@@ -126,7 +182,9 @@ declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, s
126
182
  * (`defaultOpenIds`, plus per-item `defaultOpen`). `allowMultiple` (default) lets any
127
183
  * number of items be open at once; set it false for single-open (radio-like) behaviour.
128
184
  *
129
- * Renders borderless so it drops cleanly inside a `Section` / `Card`.
185
+ * `variant` picks the look: `plain` (default) renders borderless so it drops cleanly inside a
186
+ * `Section` / `Card`; `boxed` renders each item as its own bordered, rounded box with a leading
187
+ * ▸ marker (the AML v1 console `<details>` look).
130
188
  */
131
189
 
132
190
  interface AccordionProps {
@@ -140,16 +198,22 @@ interface AccordionProps {
140
198
  onOpenChange?: (openIds: string[]) => void;
141
199
  /** Allow several items open at once (default true). False = single-open. */
142
200
  allowMultiple?: boolean;
201
+ /** Visual treatment: `plain` (default, borderless) or `boxed` (bordered ▸ boxes). */
202
+ variant?: AccordionVariant;
143
203
  testID?: string;
144
204
  style?: ViewStyle | ViewStyle[];
145
205
  }
146
- declare const Accordion: ({ children, openIds, defaultOpenIds, onOpenChange, allowMultiple, testID, style, }: AccordionProps) => React.ReactElement;
206
+ declare const Accordion: ({ children, openIds, defaultOpenIds, onOpenChange, allowMultiple, variant, testID, style, }: AccordionProps) => React.ReactElement;
147
207
 
148
208
  /**
149
- * AccordionItem — one disclosure row: a pressable header (title left, optional right
209
+ * AccordionItem — one disclosure row: a pressable header (title, optional right
150
210
  * adornment/badge slot, a rotating chevron) plus a collapsible body region.
151
211
  *
152
- * Reads its open state + toggle from the enclosing {@link Accordion} via context.
212
+ * Reads its open state, toggle and `variant` from the enclosing {@link Accordion} via context.
213
+ * - `plain` (default): a borderless row with the title left and a right-hand chevron that
214
+ * flips 180° on open, separated from the previous item by a hairline divider.
215
+ * - `boxed`: the item is its own bordered, rounded box with a LEADING ▸ marker that rotates
216
+ * 90° on open and a muted, 600-weight summary (the AML v1 console `<details>` look).
153
217
  */
154
218
 
155
219
  interface AccordionItemProps {
@@ -190,4 +254,4 @@ declare const LAYOUT_TEST_IDS: {
190
254
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
191
255
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
192
256
 
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 };
257
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
package/dist/index.d.ts CHANGED
@@ -36,6 +36,47 @@ interface StatusBadgeProps {
36
36
  }
37
37
  declare const StatusBadge: ({ label, color, backgroundColor, testID, accessibilityLabel, accessibilityHint, }: StatusBadgeProps) => React.ReactElement;
38
38
 
39
+ /**
40
+ * SegmentedControl — a single rounded pill *track* holding N mutually-exclusive segments
41
+ * (the iOS-style segmented / tab toggle). The selected segment lifts onto a raised surface
42
+ * with a subtle shadow; the rest stay transparent. Promoted from the v1 AML console's
43
+ * `.lf-mode` mode switch so erevna/katalogos/kefi can share ONE toggle instead of
44
+ * hand-rolling two primary/ghost buttons.
45
+ *
46
+ * Contract discipline (same as the rest of `@dloizides/ui-layout`): NO FM/router/store/icon
47
+ * imports. Labels are pre-localized strings; every colour is read from the
48
+ * `@dloizides/ui-feedback` UiProvider theme, so it re-skins on tenant swap. Renders as a
49
+ * `tablist` of `tab`s (`accessibilityRole` + `accessibilityState.selected`, which
50
+ * react-native-web forwards to `role`/`aria-selected` on the DOM).
51
+ */
52
+
53
+ /** One selectable segment. `value` is what `onChange` emits when it's pressed. */
54
+ interface SegmentedOption<V extends string = string> {
55
+ label: string;
56
+ value: V;
57
+ testID?: string;
58
+ accessibilityLabel?: string;
59
+ accessibilityHint?: string;
60
+ }
61
+ interface SegmentedControlProps<V extends string = string> {
62
+ /** The segments, left → right. */
63
+ options: ReadonlyArray<SegmentedOption<V>>;
64
+ /** The currently-selected value. */
65
+ value: V;
66
+ /** Fired with a segment's `value` when it is pressed. */
67
+ onChange: (value: V) => void;
68
+ /** Accessible name for the whole group (the `tablist`). */
69
+ accessibilityLabel: string;
70
+ /** Optional style override merged LAST onto the track. */
71
+ style?: StyleProp<ViewStyle>;
72
+ testID?: string;
73
+ }
74
+ /**
75
+ * A segmented toggle. Generic over the value union so callers get a typed `onChange`
76
+ * (e.g. `SegmentedControl<'peps' | 'leaders'>`).
77
+ */
78
+ declare function SegmentedControl<V extends string = string>({ options, value, onChange, accessibilityLabel, style, testID, }: SegmentedControlProps<V>): React.ReactElement;
79
+
39
80
  /**
40
81
  * UpgradePrompt — shown when a free-tier user hits a feature limit. CTA navigates to the
41
82
  * billing route via the injected navigate (default route overridable).
@@ -118,6 +159,21 @@ interface ModalShellProps {
118
159
  }
119
160
  declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
120
161
 
162
+ /**
163
+ * AccordionVariant — the two visual treatments for an {@link Accordion}.
164
+ *
165
+ * A plain string union (not a const enum) so call sites stay ergonomic
166
+ * (`variant="boxed"`) and the package exposes no cross-boundary const-enum,
167
+ * matching the rest of the shared UI kit (e.g. `ButtonVariant`).
168
+ *
169
+ * - `plain` (default) — borderless rows separated by a hairline divider, with a
170
+ * right-hand chevron that flips 180° on open. Drops cleanly inside a Section / Card.
171
+ * - `boxed` — each item is its own bordered, rounded box with a LEADING ▸ marker that
172
+ * rotates 90° on open and a muted, 600-weight summary. Matches the AML v1 console's
173
+ * `<details>` panels.
174
+ */
175
+ type AccordionVariant = 'plain' | 'boxed';
176
+
121
177
  /**
122
178
  * Accordion — a themed expand/collapse disclosure group.
123
179
  *
@@ -126,7 +182,9 @@ declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, s
126
182
  * (`defaultOpenIds`, plus per-item `defaultOpen`). `allowMultiple` (default) lets any
127
183
  * number of items be open at once; set it false for single-open (radio-like) behaviour.
128
184
  *
129
- * Renders borderless so it drops cleanly inside a `Section` / `Card`.
185
+ * `variant` picks the look: `plain` (default) renders borderless so it drops cleanly inside a
186
+ * `Section` / `Card`; `boxed` renders each item as its own bordered, rounded box with a leading
187
+ * ▸ marker (the AML v1 console `<details>` look).
130
188
  */
131
189
 
132
190
  interface AccordionProps {
@@ -140,16 +198,22 @@ interface AccordionProps {
140
198
  onOpenChange?: (openIds: string[]) => void;
141
199
  /** Allow several items open at once (default true). False = single-open. */
142
200
  allowMultiple?: boolean;
201
+ /** Visual treatment: `plain` (default, borderless) or `boxed` (bordered ▸ boxes). */
202
+ variant?: AccordionVariant;
143
203
  testID?: string;
144
204
  style?: ViewStyle | ViewStyle[];
145
205
  }
146
- declare const Accordion: ({ children, openIds, defaultOpenIds, onOpenChange, allowMultiple, testID, style, }: AccordionProps) => React.ReactElement;
206
+ declare const Accordion: ({ children, openIds, defaultOpenIds, onOpenChange, allowMultiple, variant, testID, style, }: AccordionProps) => React.ReactElement;
147
207
 
148
208
  /**
149
- * AccordionItem — one disclosure row: a pressable header (title left, optional right
209
+ * AccordionItem — one disclosure row: a pressable header (title, optional right
150
210
  * adornment/badge slot, a rotating chevron) plus a collapsible body region.
151
211
  *
152
- * Reads its open state + toggle from the enclosing {@link Accordion} via context.
212
+ * Reads its open state, toggle and `variant` from the enclosing {@link Accordion} via context.
213
+ * - `plain` (default): a borderless row with the title left and a right-hand chevron that
214
+ * flips 180° on open, separated from the previous item by a hairline divider.
215
+ * - `boxed`: the item is its own bordered, rounded box with a LEADING ▸ marker that rotates
216
+ * 90° on open and a muted, 600-weight summary (the AML v1 console `<details>` look).
153
217
  */
154
218
 
155
219
  interface AccordionItemProps {
@@ -190,4 +254,4 @@ declare const LAYOUT_TEST_IDS: {
190
254
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
191
255
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
192
256
 
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 };
257
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };