@storybook/react-native-ui-lite 10.2.2-alpha.3 → 10.2.2-alpha.4

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/index.js CHANGED
@@ -464,10 +464,22 @@ var useSelectedNode = () => (0, import_react3.useContext)(SelectedNodeContext);
464
464
 
465
465
  // src/Tree.tsx
466
466
  var import_jsx_runtime4 = require("react/jsx-runtime");
467
- var TextItem = import_react_native_theming3.styled.Text(({ theme }) => ({
468
- fontSize: theme.typography.size.s2 + 1,
469
- color: theme.color.defaultText
470
- }));
467
+ var CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
468
+ function words(str) {
469
+ return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
470
+ }
471
+ function startCase(str) {
472
+ const words$1 = words(str.trim());
473
+ let result = "";
474
+ for (let i = 0; i < words$1.length; i++) {
475
+ const word = words$1[i];
476
+ if (result) {
477
+ result += " ";
478
+ }
479
+ result += word[0].toUpperCase() + word.slice(1).toLowerCase();
480
+ }
481
+ return result;
482
+ }
471
483
  var Node = import_react4.default.memo(function Node2({
472
484
  item,
473
485
  refId,
@@ -512,7 +524,7 @@ var Node = import_react4.default.memo(function Node2({
512
524
  "aria-expanded": isExpanded,
513
525
  children: [
514
526
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CollapseIcon, { isExpanded }),
515
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TextItem, { children: item.renderLabel?.(item, {}) || item.name })
527
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RootNodeText, { children: startCase(item.name) })
516
528
  ]
517
529
  }
518
530
  ),
@@ -548,7 +560,7 @@ var Node = import_react4.default.memo(function Node2({
548
560
  event.preventDefault();
549
561
  setExpanded({ ids: [item.id], value: !isExpanded });
550
562
  },
551
- children: item.renderLabel?.(item) || item.name
563
+ children: startCase(item.name)
552
564
  },
553
565
  id
554
566
  );
@@ -577,7 +589,7 @@ var RootNode = import_react_native_theming3.styled.View(() => ({
577
589
  minHeight: 34
578
590
  }));
579
591
  var RootNodeText = import_react_native_theming3.styled.Text(({ theme }) => ({
580
- fontSize: theme.typography.size.s1 - 1,
592
+ fontSize: theme.typography.size.s2,
581
593
  fontWeight: theme.typography.weight.bold,
582
594
  color: theme.textMutedColor,
583
595
  lineHeight: 16,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native-ui-lite",
3
- "version": "10.2.2-alpha.3",
3
+ "version": "10.2.2-alpha.4",
4
4
  "description": "lightweight ui components for react native storybook",
5
5
  "keywords": [
6
6
  "react",
@@ -42,8 +42,8 @@
42
42
  "@legendapp/list": "3.0.0-beta.31",
43
43
  "@nozbe/microfuzz": "^1.0.0",
44
44
  "@storybook/react": "^10.2.2",
45
- "@storybook/react-native-theming": "^10.2.2-alpha.3",
46
- "@storybook/react-native-ui-common": "^10.2.2-alpha.3",
45
+ "@storybook/react-native-theming": "^10.2.2-alpha.4",
46
+ "@storybook/react-native-ui-common": "^10.2.2-alpha.4",
47
47
  "polished": "^4.3.1",
48
48
  "react-native-safe-area-context": "^5"
49
49
  },
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "b996f5156b78ae94b967434130a6af1bee2876a2"
61
+ "gitHead": "f96bb7e3c60928bed07cae53a833fede3a65498a"
62
62
  }
package/src/Tree.tsx CHANGED
@@ -40,10 +40,26 @@ interface NodeProps {
40
40
  status: State['status'][keyof State['status']];
41
41
  }
42
42
 
43
- const TextItem = styled.Text(({ theme }) => ({
44
- fontSize: theme.typography.size.s2 + 1,
45
- color: theme.color.defaultText,
46
- }));
43
+ // from estookit/string
44
+ const CASE_SPLIT_PATTERN =
45
+ /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
46
+ // from estookit/string
47
+ function words(str: string) {
48
+ return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
49
+ }
50
+ // from estookit/string
51
+ function startCase(str: string) {
52
+ const words$1 = words(str.trim());
53
+ let result = '';
54
+ for (let i = 0; i < words$1.length; i++) {
55
+ const word = words$1[i];
56
+ if (result) {
57
+ result += ' ';
58
+ }
59
+ result += word[0].toUpperCase() + word.slice(1).toLowerCase();
60
+ }
61
+ return result;
62
+ }
47
63
 
48
64
  export const Node = React.memo<NodeProps>(function Node({
49
65
  item,
@@ -92,7 +108,7 @@ export const Node = React.memo<NodeProps>(function Node({
92
108
  aria-expanded={isExpanded}
93
109
  >
94
110
  <CollapseIcon isExpanded={isExpanded} />
95
- <TextItem>{item.renderLabel?.(item, {}) || item.name}</TextItem>
111
+ <RootNodeText>{startCase(item.name)}</RootNodeText>
96
112
  </CollapseButton>
97
113
  {isExpanded && (
98
114
  <IconButton
@@ -129,7 +145,7 @@ export const Node = React.memo<NodeProps>(function Node({
129
145
  setExpanded({ ids: [item.id], value: !isExpanded });
130
146
  }}
131
147
  >
132
- {(item.renderLabel as (i: typeof item) => React.ReactNode)?.(item) || item.name}
148
+ {startCase(item.name)}
133
149
  </BranchNode>
134
150
  );
135
151
  }
@@ -161,7 +177,7 @@ export const RootNode = styled.View(() => ({
161
177
  }));
162
178
 
163
179
  export const RootNodeText = styled.Text(({ theme }) => ({
164
- fontSize: theme.typography.size.s1 - 1,
180
+ fontSize: theme.typography.size.s2,
165
181
  fontWeight: theme.typography.weight.bold,
166
182
  color: theme.textMutedColor,
167
183
  lineHeight: 16,