@dloizides/ui-layout 1.4.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,15 @@
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
+
3
13
  ## 1.4.0
4
14
 
5
15
  - Add **`SegmentedControl`** — a single rounded pill *track* holding N mutually-exclusive
package/dist/index.d.mts CHANGED
@@ -159,6 +159,21 @@ interface ModalShellProps {
159
159
  }
160
160
  declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
161
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
+
162
177
  /**
163
178
  * Accordion — a themed expand/collapse disclosure group.
164
179
  *
@@ -167,7 +182,9 @@ declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, s
167
182
  * (`defaultOpenIds`, plus per-item `defaultOpen`). `allowMultiple` (default) lets any
168
183
  * number of items be open at once; set it false for single-open (radio-like) behaviour.
169
184
  *
170
- * 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).
171
188
  */
172
189
 
173
190
  interface AccordionProps {
@@ -181,16 +198,22 @@ interface AccordionProps {
181
198
  onOpenChange?: (openIds: string[]) => void;
182
199
  /** Allow several items open at once (default true). False = single-open. */
183
200
  allowMultiple?: boolean;
201
+ /** Visual treatment: `plain` (default, borderless) or `boxed` (bordered ▸ boxes). */
202
+ variant?: AccordionVariant;
184
203
  testID?: string;
185
204
  style?: ViewStyle | ViewStyle[];
186
205
  }
187
- 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;
188
207
 
189
208
  /**
190
- * AccordionItem — one disclosure row: a pressable header (title left, optional right
209
+ * AccordionItem — one disclosure row: a pressable header (title, optional right
191
210
  * adornment/badge slot, a rotating chevron) plus a collapsible body region.
192
211
  *
193
- * 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).
194
217
  */
195
218
 
196
219
  interface AccordionItemProps {
@@ -231,4 +254,4 @@ declare const LAYOUT_TEST_IDS: {
231
254
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
232
255
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
233
256
 
234
- 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, SegmentedControl, type SegmentedControlProps, type SegmentedOption, 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
@@ -159,6 +159,21 @@ interface ModalShellProps {
159
159
  }
160
160
  declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
161
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
+
162
177
  /**
163
178
  * Accordion — a themed expand/collapse disclosure group.
164
179
  *
@@ -167,7 +182,9 @@ declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, s
167
182
  * (`defaultOpenIds`, plus per-item `defaultOpen`). `allowMultiple` (default) lets any
168
183
  * number of items be open at once; set it false for single-open (radio-like) behaviour.
169
184
  *
170
- * 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).
171
188
  */
172
189
 
173
190
  interface AccordionProps {
@@ -181,16 +198,22 @@ interface AccordionProps {
181
198
  onOpenChange?: (openIds: string[]) => void;
182
199
  /** Allow several items open at once (default true). False = single-open. */
183
200
  allowMultiple?: boolean;
201
+ /** Visual treatment: `plain` (default, borderless) or `boxed` (bordered ▸ boxes). */
202
+ variant?: AccordionVariant;
184
203
  testID?: string;
185
204
  style?: ViewStyle | ViewStyle[];
186
205
  }
187
- 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;
188
207
 
189
208
  /**
190
- * AccordionItem — one disclosure row: a pressable header (title left, optional right
209
+ * AccordionItem — one disclosure row: a pressable header (title, optional right
191
210
  * adornment/badge slot, a rotating chevron) plus a collapsible body region.
192
211
  *
193
- * 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).
194
217
  */
195
218
 
196
219
  interface AccordionItemProps {
@@ -231,4 +254,4 @@ declare const LAYOUT_TEST_IDS: {
231
254
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
232
255
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
233
256
 
234
- 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, SegmentedControl, type SegmentedControlProps, type SegmentedOption, 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.js CHANGED
@@ -740,8 +740,10 @@ function animateNextLayout() {
740
740
  } catch {
741
741
  }
742
742
  }
743
+ var BOXED_GAP = 12;
743
744
  var styles10 = reactNative.StyleSheet.create({
744
- container: { alignSelf: "stretch" }
745
+ container: { alignSelf: "stretch" },
746
+ boxed: { gap: BOXED_GAP }
745
747
  });
746
748
  function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
747
749
  const ids = new Set(defaultOpenIds ?? []);
@@ -764,6 +766,7 @@ var Accordion = ({
764
766
  defaultOpenIds,
765
767
  onOpenChange,
766
768
  allowMultiple = true,
769
+ variant = "plain",
767
770
  testID = "accordion",
768
771
  style
769
772
  }) => {
@@ -792,13 +795,14 @@ var Accordion = ({
792
795
  [allowMultiple, isControlled, onOpenChange, openSet]
793
796
  );
794
797
  const contextValue = React8.useMemo(
795
- () => ({ openIds: openSet, toggle, allowMultiple }),
796
- [openSet, toggle, allowMultiple]
797
- );
798
- const containerStyle = React8.useMemo(
799
- () => style === void 0 ? [styles10.container] : [styles10.container, ...Array.isArray(style) ? style : [style]],
800
- [style]
798
+ () => ({ openIds: openSet, toggle, allowMultiple, variant }),
799
+ [openSet, toggle, allowMultiple, variant]
801
800
  );
801
+ const containerStyle = React8.useMemo(() => {
802
+ const base = variant === "boxed" ? [styles10.container, styles10.boxed] : [styles10.container];
803
+ if (style === void 0) return base;
804
+ return [...base, ...Array.isArray(style) ? style : [style]];
805
+ }, [style, variant]);
802
806
  return /* @__PURE__ */ jsxRuntime.jsx(AccordionContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: containerStyle, testID, children }) });
803
807
  };
804
808
  var HEADER_PADDING_H = 16;
@@ -813,12 +817,23 @@ var ROTATE_DURATION_MS = 160;
813
817
  var ROTATE_COLLAPSED = 0;
814
818
  var ROTATE_EXPANDED = 1;
815
819
  var COLLAPSED_DEG = "0deg";
816
- var EXPANDED_DEG = "180deg";
820
+ var PLAIN_EXPANDED_DEG = "180deg";
821
+ var BOXED_EXPANDED_DEG = "90deg";
817
822
  var DISABLED_OPACITY = 0.5;
818
823
  var FULL_OPACITY = 1;
819
824
  var ROLE_REGION = "region";
825
+ var BOX_BORDER_RADIUS = 10;
826
+ var BOX_PADDING_H = 14;
827
+ var BOX_HEADER_PADDING_V = 8;
828
+ var BOX_BODY_PADDING_BOTTOM = 10;
829
+ var BOX_BODY_PADDING_TOP = 2;
830
+ var BOX_TITLE_FONT_SIZE = 14;
831
+ var BOX_MARKER_FONT_SIZE = 13;
832
+ var BOX_MARKER_GAP = 6;
833
+ var BOX_MARKER = "\u25B8";
820
834
  var styles11 = reactNative.StyleSheet.create({
821
835
  item: { borderTopWidth: reactNative.StyleSheet.hairlineWidth },
836
+ boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
822
837
  header: {
823
838
  flexDirection: "row",
824
839
  alignItems: "center",
@@ -826,11 +841,17 @@ var styles11 = reactNative.StyleSheet.create({
826
841
  paddingHorizontal: HEADER_PADDING_H,
827
842
  paddingVertical: HEADER_PADDING_V
828
843
  },
844
+ boxHeader: { paddingHorizontal: 0, paddingVertical: BOX_HEADER_PADDING_V },
829
845
  headerLeft: { flexShrink: 1, flexGrow: 1 },
846
+ headerLeftRow: { flexDirection: "row", alignItems: "center" },
830
847
  headerRight: { flexDirection: "row", alignItems: "center", marginLeft: HEADER_GAP },
831
848
  title: { fontSize: TITLE_FONT_SIZE2, fontWeight: TITLE_FONT_WEIGHT },
849
+ boxTitle: { fontSize: BOX_TITLE_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
832
850
  chevron: { marginLeft: HEADER_GAP },
833
- body: { paddingHorizontal: BODY_PADDING_H, paddingBottom: BODY_PADDING_V }
851
+ marker: { marginRight: BOX_MARKER_GAP },
852
+ markerText: { fontSize: BOX_MARKER_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
853
+ body: { paddingHorizontal: BODY_PADDING_H, paddingBottom: BODY_PADDING_V },
854
+ boxBody: { paddingHorizontal: 0, paddingBottom: BOX_BODY_PADDING_BOTTOM, paddingTop: BOX_BODY_PADDING_TOP }
834
855
  });
835
856
  var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
836
857
  var AccordionItem = ({
@@ -847,7 +868,8 @@ var AccordionItem = ({
847
868
  }) => {
848
869
  const { theme, t } = uiFeedback.useUi();
849
870
  const { colors } = theme;
850
- const { openIds, toggle } = useAccordionContext();
871
+ const { openIds, toggle, variant } = useAccordionContext();
872
+ const boxed = variant === "boxed";
851
873
  const expanded = openIds.has(id);
852
874
  const headerTestID = testID ?? `accordion-item-${id}`;
853
875
  const bodyTestID = `${headerTestID}-body`;
@@ -863,7 +885,7 @@ var AccordionItem = ({
863
885
  }, [expanded, rotation]);
864
886
  const rotate = rotation.interpolate({
865
887
  inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
866
- outputRange: [COLLAPSED_DEG, EXPANDED_DEG]
888
+ outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
867
889
  });
868
890
  const handlePress = React8.useCallback(() => {
869
891
  if (!disabled) toggle(id);
@@ -881,14 +903,19 @@ var AccordionItem = ({
881
903
  );
882
904
  const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
883
905
  const itemStyle = React8.useMemo(
884
- () => [styles11.item, { borderTopColor: colors.border }],
885
- [colors.border]
906
+ () => boxed ? [styles11.boxItem, { borderColor: colors.border }] : [styles11.item, { borderTopColor: colors.border }],
907
+ [boxed, colors.border]
886
908
  );
887
909
  const headerStyle = React8.useMemo(
888
- () => [styles11.header, { opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }],
889
- [disabled]
910
+ () => [
911
+ styles11.header,
912
+ ...boxed ? [styles11.boxHeader] : [],
913
+ { opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
914
+ ],
915
+ [boxed, disabled]
890
916
  );
891
917
  const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
918
+ const titleNode = typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [boxed ? styles11.boxTitle : styles11.title, { color: boxed ? colors.textSecondary : colors.text }], children: title }) : title;
892
919
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: itemStyle, children: [
893
920
  /* @__PURE__ */ jsxRuntime.jsxs(
894
921
  reactNative.Pressable,
@@ -905,15 +932,28 @@ var AccordionItem = ({
905
932
  onPress: handlePress,
906
933
  ...keyboardProps,
907
934
  children: [
908
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles11.headerLeft, children: typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles11.title, { color: colors.text }], children: title }) : title }),
935
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles11.headerLeft, boxed ? styles11.headerLeftRow : null], children: [
936
+ boxed ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles11.marker, { transform: [{ rotate }] }], testID: chevronTestID, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles11.markerText, { color: colors.textSecondary }], children: BOX_MARKER }) }) : null,
937
+ titleNode
938
+ ] }),
909
939
  /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles11.headerRight, children: [
910
940
  right,
911
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles11.chevron, { transform: [{ rotate }] }], children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID }) })
941
+ boxed ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles11.chevron, { transform: [{ rotate }] }], children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID }) })
912
942
  ] })
913
943
  ]
914
944
  }
915
945
  ),
916
- expanded ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityLabel: resolvedLabel, nativeID: bodyTestID, role: ROLE_REGION, style: styles11.body, testID: bodyTestID, children }) : null
946
+ expanded ? /* @__PURE__ */ jsxRuntime.jsx(
947
+ reactNative.View,
948
+ {
949
+ accessibilityLabel: resolvedLabel,
950
+ nativeID: bodyTestID,
951
+ role: ROLE_REGION,
952
+ style: boxed ? styles11.boxBody : styles11.body,
953
+ testID: bodyTestID,
954
+ children
955
+ }
956
+ ) : null
917
957
  ] });
918
958
  };
919
959