@storybook/react-native-ui-common 9.0.0-beta.15 → 9.0.0-rc.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.d.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import * as react from 'react';
2
- import { ReactElement, FC, PropsWithChildren, SyntheticEvent, DependencyList, Dispatch, useState } from 'react';
2
+ import { ReactElement, FC, PropsWithChildren, ReactNode, SyntheticEvent, DependencyList, Dispatch, useState } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as _storybook_react_native_theming from '@storybook/react-native-theming';
5
- import { useTheme } from '@storybook/react-native-theming';
5
+ import { useTheme, Theme } from '@storybook/react-native-theming';
6
6
  import * as react_native from 'react-native';
7
7
  import { TouchableOpacityProps, PressableProps, ViewStyle, TextStyle, ImageStyle, StyleProp } from 'react-native';
8
- import { State, StoriesHash, API, IndexHash } from 'storybook/internal/manager-api';
9
- import { StatusesByStoryIdAndTypeId, StatusValue, API_PreparedStoryIndex, StoryIndexV2, StoryIndexV3, API_IndexHash, API_Provider, DocsOptions } from 'storybook/internal/types';
8
+ import { StoryContext, Args } from '@storybook/csf';
9
+ import { ReactRenderer } from '@storybook/react';
10
10
  import * as Fuse from 'fuse.js';
11
+ import { State, StoriesHash, API, IndexHash } from 'storybook/internal/manager-api';
12
+ import { StatusesByStoryIdAndTypeId, StatusValue, API_IndexHash, API_PreparedStoryIndex, StoryIndexV2, StoryIndexV3, API_Provider, DocsOptions } from 'storybook/internal/types';
11
13
 
12
14
  interface ButtonProps extends TouchableOpacityProps {
13
15
  asChild?: boolean;
@@ -49,6 +51,15 @@ type LayoutContextType = {
49
51
  declare const LayoutProvider: FC<PropsWithChildren>;
50
52
  declare const useLayout: () => LayoutContextType;
51
53
 
54
+ interface Storage {
55
+ getItem: (key: string) => Promise<string | null>;
56
+ setItem: (key: string, value: string) => Promise<void>;
57
+ }
58
+ declare const StorageProvider: FC<PropsWithChildren<{
59
+ storage: Storage;
60
+ }>>;
61
+ declare const useStorage: () => Storage;
62
+
52
63
  type Refs = State['refs'];
53
64
  type RefType = Refs[keyof Refs] & {
54
65
  allStatuses?: StatusesByStoryIdAndTypeId;
@@ -99,16 +110,15 @@ type SearchChildrenFn = (args: {
99
110
  closeMenu: (cb?: () => void) => void;
100
111
  getItemProps: GetSearchItemProps;
101
112
  highlightedIndex: number | null;
102
- }) => React.ReactNode;
103
-
104
- interface Storage {
105
- getItem: (key: string) => Promise<string | null>;
106
- setItem: (key: string, value: string) => Promise<void>;
107
- }
108
- declare const StorageProvider: FC<PropsWithChildren<{
113
+ }) => ReactNode;
114
+ type SBUI = (props: {
115
+ story?: StoryContext<ReactRenderer, Args>;
116
+ storyHash: API_IndexHash;
117
+ setStory: (storyId: string) => void;
109
118
  storage: Storage;
110
- }>>;
111
- declare const useStorage: () => Storage;
119
+ theme: Theme;
120
+ children: ReactElement;
121
+ }) => ReactElement;
112
122
 
113
123
  type ToStoriesHashOptions = {
114
124
  provider: API_Provider<API>;
@@ -179,4 +189,4 @@ declare const useLastViewed: (selection: Selection) => {
179
189
 
180
190
  declare const useStoreBooleanState: (key: string, defaultValue: boolean) => ReturnType<typeof useState<boolean>>;
181
191
 
182
- export { Button, ButtonIcon, ButtonProps, ButtonText, CombinedDataset, Dataset, ExpandAction, ExpandType, ExpandedProps, ExpandedState, GetSearchItemProps, Highlight, IconButton, Item, ItemRef, LayoutProvider, RefType, Refs, SearchChildrenFn, SearchItem, SearchResult, SearchResultProps, Selection, Storage, StorageProvider, StoryRef, createId, cycle, get, getAncestorIds, getDescendantIds, getParent, getParents, getPath, getStateType, intersect, isAncestor, isExpandType, isStoryHoistable, merge, noArrayMerge, prevent, removeNoiseFromName, searchItem, transformStoryIndexToStoriesHash, transformStoryIndexV2toV3, transformStoryIndexV3toV4, transformStoryIndexV4toV5, useExpanded, useLastViewed, useLayout, useStorage, useStoreBooleanState, useStyle };
192
+ export { Button, ButtonIcon, ButtonProps, ButtonText, CombinedDataset, Dataset, ExpandAction, ExpandType, ExpandedProps, ExpandedState, GetSearchItemProps, Highlight, IconButton, Item, ItemRef, LayoutProvider, RefType, Refs, SBUI, SearchChildrenFn, SearchItem, SearchResult, SearchResultProps, Selection, Storage, StorageProvider, StoryRef, createId, cycle, get, getAncestorIds, getDescendantIds, getParent, getParents, getPath, getStateType, intersect, isAncestor, isExpandType, isStoryHoistable, merge, noArrayMerge, prevent, removeNoiseFromName, searchItem, transformStoryIndexToStoriesHash, transformStoryIndexV2toV3, transformStoryIndexV3toV4, transformStoryIndexV4toV5, useExpanded, useLastViewed, useLayout, useStorage, useStoreBooleanState, useStyle };
package/dist/index.js CHANGED
@@ -252,8 +252,8 @@ var LayoutProvider = ({ children }) => {
252
252
  var useLayout = () => (0, import_react3.useContext)(LayoutContext);
253
253
 
254
254
  // src/types.ts
255
- function isExpandType(x2) {
256
- return !!(x2 && x2.showAll);
255
+ function isExpandType(x) {
256
+ return !!(x && x.showAll);
257
257
  }
258
258
 
259
259
  // src/StorageProvider.tsx
@@ -272,92 +272,8 @@ var StorageProvider = ({
272
272
  };
273
273
  var useStorage = () => (0, import_react4.useContext)(StorageContext);
274
274
 
275
- // ../../node_modules/@storybook/csf/dist/index.mjs
276
- var C = Object.create;
277
- var u = Object.defineProperty;
278
- var B = Object.getOwnPropertyDescriptor;
279
- var F = Object.getOwnPropertyNames;
280
- var h = Object.getPrototypeOf;
281
- var w = Object.prototype.hasOwnProperty;
282
- var E = (r, e) => () => (e || r((e = { exports: {} }).exports, e), e.exports);
283
- var v = (r, e, n, t) => {
284
- if (e && typeof e == "object" || typeof e == "function")
285
- for (let a of F(e))
286
- !w.call(r, a) && a !== n && u(r, a, { get: () => e[a], enumerable: !(t = B(e, a)) || t.enumerable });
287
- return r;
288
- };
289
- var I = (r, e, n) => (n = r != null ? C(h(r)) : {}, v(e || !r || !r.__esModule ? u(n, "default", { value: r, enumerable: true }) : n, r));
290
- var x = E((T) => {
291
- Object.defineProperty(T, "__esModule", { value: true }), T.isEqual = function() {
292
- var r = Object.prototype.toString, e = Object.getPrototypeOf, n = Object.getOwnPropertySymbols ? function(t) {
293
- return Object.keys(t).concat(Object.getOwnPropertySymbols(t));
294
- } : Object.keys;
295
- return function(t, a) {
296
- return function i(o, s, p) {
297
- var g, y, d, c = r.call(o), b = r.call(s);
298
- if (o === s)
299
- return true;
300
- if (o == null || s == null)
301
- return false;
302
- if (p.indexOf(o) > -1 && p.indexOf(s) > -1)
303
- return true;
304
- if (p.push(o, s), c != b || (g = n(o), y = n(s), g.length != y.length || g.some(function(A) {
305
- return !i(o[A], s[A], p);
306
- })))
307
- return false;
308
- switch (c.slice(8, -1)) {
309
- case "Symbol":
310
- return o.valueOf() == s.valueOf();
311
- case "Date":
312
- case "Number":
313
- return +o == +s || +o != +o && +s != +s;
314
- case "RegExp":
315
- case "Function":
316
- case "String":
317
- case "Boolean":
318
- return "" + o == "" + s;
319
- case "Set":
320
- case "Map":
321
- g = o.entries(), y = s.entries();
322
- do
323
- if (!i((d = g.next()).value, y.next().value, p))
324
- return false;
325
- while (!d.done);
326
- return true;
327
- case "ArrayBuffer":
328
- o = new Uint8Array(o), s = new Uint8Array(s);
329
- case "DataView":
330
- o = new Uint8Array(o.buffer), s = new Uint8Array(s.buffer);
331
- case "Float32Array":
332
- case "Float64Array":
333
- case "Int8Array":
334
- case "Int16Array":
335
- case "Int32Array":
336
- case "Uint8Array":
337
- case "Uint16Array":
338
- case "Uint32Array":
339
- case "Uint8ClampedArray":
340
- case "Arguments":
341
- case "Array":
342
- if (o.length != s.length)
343
- return false;
344
- for (d = 0; d < o.length; d++)
345
- if ((d in o || d in s) && (d in o != d in s || !i(o[d], s[d], p)))
346
- return false;
347
- return true;
348
- case "Object":
349
- return i(e(o), e(s), p);
350
- default:
351
- return false;
352
- }
353
- }(t, a, []);
354
- };
355
- }();
356
- });
357
- var l = I(x());
358
- var O = (r) => r.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
359
-
360
275
  // src/util/StoryHash.ts
276
+ var import_csf = require("@storybook/csf");
361
277
  var import_ts_dedent = require("ts-dedent");
362
278
  var import_client_logger = require("storybook/internal/client-logger");
363
279
  var import_es_toolkit = require("es-toolkit");
@@ -469,7 +385,7 @@ var transformStoryIndexToStoriesHash = (input, { provider, docsOptions, filters,
469
385
  const names = [...root, ...groups];
470
386
  const paths = names.reduce((list, name, idx) => {
471
387
  const parent = idx > 0 && list[idx - 1];
472
- const id = O(parent ? `${parent}-${name}` : name);
388
+ const id = (0, import_csf.sanitize)(parent ? `${parent}-${name}` : name);
473
389
  if (name.trim() === "") {
474
390
  throw new Error(import_ts_dedent.dedent`Invalid title ${title} ending in slash.`);
475
391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native-ui-common",
3
- "version": "9.0.0-beta.15",
3
+ "version": "9.0.0-rc.4",
4
4
  "description": "common ui components for react native storybook",
5
5
  "keywords": [
6
6
  "react",
@@ -57,8 +57,9 @@
57
57
  "typescript": "~5.8.3"
58
58
  },
59
59
  "dependencies": {
60
- "@storybook/react": "9.0.0-beta.10",
61
- "@storybook/react-native-theming": "^9.0.0-beta.15",
60
+ "@storybook/csf": "^0.1.13",
61
+ "@storybook/react": "9.0.0-rc.4",
62
+ "@storybook/react-native-theming": "^9.0.0-rc.4",
62
63
  "es-toolkit": "^1.38.0",
63
64
  "fuse.js": "^7.0.0",
64
65
  "memoizerific": "^1.11.3",
@@ -69,7 +70,7 @@
69
70
  "peerDependencies": {
70
71
  "react": "*",
71
72
  "react-native": ">=0.57.0",
72
- "storybook": "9.0.0-beta.10"
73
+ "storybook": "9.0.0-rc.4"
73
74
  },
74
75
  "engines": {
75
76
  "node": ">=18.0.0"
@@ -77,5 +78,5 @@
77
78
  "publishConfig": {
78
79
  "access": "public"
79
80
  },
80
- "gitHead": "905adcca4ea272933c7f0fa16f10dda201da9a5f"
81
+ "gitHead": "1d0249371caed6a6a90f42530d722040eb18c9dc"
81
82
  }
@@ -18,6 +18,8 @@ export const LayoutProvider: FC<PropsWithChildren> = ({ children }) => {
18
18
  const isDesktop = width >= BREAKPOINT;
19
19
  const isMobile = !isDesktop;
20
20
 
21
+ // console.log({ isDesktop, isMobile, breakpoint: BREAKPOINT, width });
22
+
21
23
  const contextValue = useMemo(
22
24
  () => ({
23
25
  isDesktop,
package/src/types.ts CHANGED
@@ -1,7 +1,16 @@
1
- import type { StoriesHash, State } from 'storybook/internal/manager-api';
2
- import type { StatusValue, StatusesByStoryIdAndTypeId } from 'storybook/internal/types';
1
+ import type { Args, StoryContext } from '@storybook/csf';
2
+ import type { ReactRenderer } from '@storybook/react';
3
+ import { Theme } from '@storybook/react-native-theming';
4
+ import { Storage } from './StorageProvider';
3
5
  import * as Fuse from 'fuse.js';
6
+ import { ReactElement, ReactNode } from 'react';
4
7
  import { PressableProps } from 'react-native';
8
+ import type { State, StoriesHash } from 'storybook/internal/manager-api';
9
+ import type {
10
+ API_IndexHash,
11
+ StatusesByStoryIdAndTypeId,
12
+ StatusValue,
13
+ } from 'storybook/internal/types';
5
14
 
6
15
  export type Refs = State['refs'];
7
16
  export type RefType = Refs[keyof Refs] & { allStatuses?: StatusesByStoryIdAndTypeId };
@@ -63,4 +72,13 @@ export type SearchChildrenFn = (args: {
63
72
  closeMenu: (cb?: () => void) => void;
64
73
  getItemProps: GetSearchItemProps;
65
74
  highlightedIndex: number | null;
66
- }) => React.ReactNode;
75
+ }) => ReactNode;
76
+
77
+ export type SBUI = (props: {
78
+ story?: StoryContext<ReactRenderer, Args>;
79
+ storyHash: API_IndexHash;
80
+ setStory: (storyId: string) => void;
81
+ storage: Storage;
82
+ theme: Theme;
83
+ children: ReactElement;
84
+ }) => ReactElement;