@dloizides/ui-layout 1.15.1 → 1.16.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.16.0
4
+
5
+ **`Heading` supports levels 1-6 instead of `<h1>` only.**
6
+
7
+ `Heading` rendered `<h1>` unconditionally, so any screen needing sub-structure either
8
+ shipped multiple `<h1>`s or avoided the component. The Digital Kin guide editor did the
9
+ latter — styled `<Text>` instead — and shipped **zero headings**: measured on the live
10
+ CMS, `document.querySelectorAll('h1,h2,h3,h4,h5,h6').length === 0` for the entire page.
11
+
12
+ So there was no `<h1>` naming the guide being edited and nothing marking the steps
13
+ section. Screen-reader users could not navigate by heading, and styling was standing in
14
+ for structure.
15
+
16
+ After: `h1` names the guide, `h2` marks the steps section, `h3` per step.
17
+
18
+
3
19
  ## 1.15.1
4
20
 
5
21
  - **Fix (`CopyableId` truncated the value with room to spare).** 1.15.0 gave the value wrapper
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { RefObject } from 'react';
2
- import { ViewStyle, StyleProp, TextStyle, View } from 'react-native';
2
+ import { ViewStyle, Text, StyleProp, TextStyle, View } from 'react-native';
3
3
 
4
4
  /**
5
5
  * Section — a bordered card container that themes its border + surface.
@@ -12,14 +12,43 @@ interface SectionProps {
12
12
  declare const Section: ({ children, style }: SectionProps) => React.ReactElement;
13
13
 
14
14
  /**
15
- * Heading — themed section heading text.
15
+ * Heading — themed section heading text, rendered as a REAL `<h1>`–`<h6>` on web.
16
+ *
17
+ * ## Why `level` exists
18
+ *
19
+ * `accessibilityRole="header"` maps to the ARIA `heading` role, which react-native-web turns
20
+ * into a real heading element — but with no `aria-level` it always emits `<h1>`. A screen
21
+ * having several `<h1>`s and no `<h2>` is a flat document: heading navigation, the primary way
22
+ * assistive-tech users move around a long page, lists every section as a peer of the page title.
23
+ *
24
+ * `level` supplies `aria-level`, which RN-web uses to pick `h{level}`. It defaults to 2 rather
25
+ * than 1 on purpose: a page has exactly ONE `<h1>` (its title) and many section headings, so the
26
+ * common case must be the safe one. A second `<h1>` is a defect that renders identically to a
27
+ * correct heading, so nothing about the page would reveal the mistake.
28
+ *
29
+ * The visual size is deliberately NOT derived from `level`. Heading level is document structure;
30
+ * type scale is design. Tying them together is what pushes authors to pick a level for its font
31
+ * size and break the outline to get the look they want.
16
32
  */
17
33
 
34
+ /** `h1`–`h6`; HTML defines no `h7`. */
35
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
18
36
  interface HeadingProps {
19
37
  text?: string;
20
38
  children?: React.ReactNode;
39
+ /**
40
+ * Document outline depth → `<h1>`–`<h6>` on web, `aria-level` on native. Defaults to 2.
41
+ * Pick it from the page's STRUCTURE, never from how large you want the text to look.
42
+ */
43
+ level?: HeadingLevel;
44
+ /**
45
+ * Merged AFTER the themed base, for the genuine one-off — a page title that needs to be
46
+ * visibly larger than a section heading. Structure stays in `level`; size lives here.
47
+ */
48
+ style?: React.ComponentProps<typeof Text>['style'];
49
+ testID?: string;
21
50
  }
22
- declare const Heading: ({ text, children }: HeadingProps) => React.ReactElement;
51
+ declare const Heading: ({ text, children, level, style, testID, }: HeadingProps) => React.ReactElement;
23
52
 
24
53
  /**
25
54
  * StatusBadge — unified status pill. Colours are passed in; domain adapters map their
@@ -525,4 +554,4 @@ declare const LAYOUT_I18N: {
525
554
  readonly copyableIdHint: "common.copyableIdHint";
526
555
  };
527
556
 
528
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
557
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { RefObject } from 'react';
2
- import { ViewStyle, StyleProp, TextStyle, View } from 'react-native';
2
+ import { ViewStyle, Text, StyleProp, TextStyle, View } from 'react-native';
3
3
 
4
4
  /**
5
5
  * Section — a bordered card container that themes its border + surface.
@@ -12,14 +12,43 @@ interface SectionProps {
12
12
  declare const Section: ({ children, style }: SectionProps) => React.ReactElement;
13
13
 
14
14
  /**
15
- * Heading — themed section heading text.
15
+ * Heading — themed section heading text, rendered as a REAL `<h1>`–`<h6>` on web.
16
+ *
17
+ * ## Why `level` exists
18
+ *
19
+ * `accessibilityRole="header"` maps to the ARIA `heading` role, which react-native-web turns
20
+ * into a real heading element — but with no `aria-level` it always emits `<h1>`. A screen
21
+ * having several `<h1>`s and no `<h2>` is a flat document: heading navigation, the primary way
22
+ * assistive-tech users move around a long page, lists every section as a peer of the page title.
23
+ *
24
+ * `level` supplies `aria-level`, which RN-web uses to pick `h{level}`. It defaults to 2 rather
25
+ * than 1 on purpose: a page has exactly ONE `<h1>` (its title) and many section headings, so the
26
+ * common case must be the safe one. A second `<h1>` is a defect that renders identically to a
27
+ * correct heading, so nothing about the page would reveal the mistake.
28
+ *
29
+ * The visual size is deliberately NOT derived from `level`. Heading level is document structure;
30
+ * type scale is design. Tying them together is what pushes authors to pick a level for its font
31
+ * size and break the outline to get the look they want.
16
32
  */
17
33
 
34
+ /** `h1`–`h6`; HTML defines no `h7`. */
35
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
18
36
  interface HeadingProps {
19
37
  text?: string;
20
38
  children?: React.ReactNode;
39
+ /**
40
+ * Document outline depth → `<h1>`–`<h6>` on web, `aria-level` on native. Defaults to 2.
41
+ * Pick it from the page's STRUCTURE, never from how large you want the text to look.
42
+ */
43
+ level?: HeadingLevel;
44
+ /**
45
+ * Merged AFTER the themed base, for the genuine one-off — a page title that needs to be
46
+ * visibly larger than a section heading. Structure stays in `level`; size lives here.
47
+ */
48
+ style?: React.ComponentProps<typeof Text>['style'];
49
+ testID?: string;
21
50
  }
22
- declare const Heading: ({ text, children }: HeadingProps) => React.ReactElement;
51
+ declare const Heading: ({ text, children, level, style, testID, }: HeadingProps) => React.ReactElement;
23
52
 
24
53
  /**
25
54
  * StatusBadge — unified status pill. Colours are passed in; domain adapters map their
@@ -525,4 +554,4 @@ declare const LAYOUT_I18N: {
525
554
  readonly copyableIdHint: "common.copyableIdHint";
526
555
  };
527
556
 
528
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
557
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
package/dist/index.js CHANGED
@@ -88,13 +88,29 @@ var styles2 = reactNative.StyleSheet.create({
88
88
  fontSize: 16
89
89
  }
90
90
  });
91
- var Heading = ({ text, children }) => {
91
+ var DEFAULT_HEADING_LEVEL = 2;
92
+ var Heading = ({
93
+ text,
94
+ children,
95
+ level = DEFAULT_HEADING_LEVEL,
96
+ style,
97
+ testID
98
+ }) => {
92
99
  const { theme } = uiFeedback.useUi();
93
100
  const headingStyle = React8__default.default.useMemo(
94
- () => [styles2.heading, { color: theme.colors.text }],
95
- [theme.colors.text]
101
+ () => [styles2.heading, { color: theme.colors.text }, style],
102
+ [theme.colors.text, style]
103
+ );
104
+ return /* @__PURE__ */ jsxRuntime.jsx(
105
+ reactNative.Text,
106
+ {
107
+ accessibilityRole: "header",
108
+ "aria-level": level,
109
+ style: headingStyle,
110
+ testID: testID ?? LAYOUT_TEST_IDS.headingText,
111
+ children: text ?? children
112
+ }
96
113
  );
97
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: headingStyle, testID: LAYOUT_TEST_IDS.headingText, children: text ?? children });
98
114
  };
99
115
  var DEFAULT_PADDING_H = 10;
100
116
  var DEFAULT_PADDING_V = 4;