component-previewer 0.1.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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -0
  3. package/lib/module/PreviewControls.js +177 -0
  4. package/lib/module/PreviewControls.js.map +1 -0
  5. package/lib/module/PreviewList.js +99 -0
  6. package/lib/module/PreviewList.js.map +1 -0
  7. package/lib/module/PreviewStage.js +82 -0
  8. package/lib/module/PreviewStage.js.map +1 -0
  9. package/lib/module/Previewer.js +31 -0
  10. package/lib/module/Previewer.js.map +1 -0
  11. package/lib/module/controls.js +112 -0
  12. package/lib/module/controls.js.map +1 -0
  13. package/lib/module/csf.js +63 -0
  14. package/lib/module/csf.js.map +1 -0
  15. package/lib/module/index.js +10 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/module/registry.js +28 -0
  19. package/lib/module/registry.js.map +1 -0
  20. package/lib/module/shell.js +18 -0
  21. package/lib/module/shell.js.map +1 -0
  22. package/lib/module/types.js +4 -0
  23. package/lib/module/types.js.map +1 -0
  24. package/lib/typescript/package.json +1 -0
  25. package/lib/typescript/src/PreviewControls.d.ts +8 -0
  26. package/lib/typescript/src/PreviewControls.d.ts.map +1 -0
  27. package/lib/typescript/src/PreviewList.d.ts +7 -0
  28. package/lib/typescript/src/PreviewList.d.ts.map +1 -0
  29. package/lib/typescript/src/PreviewStage.d.ts +9 -0
  30. package/lib/typescript/src/PreviewStage.d.ts.map +1 -0
  31. package/lib/typescript/src/Previewer.d.ts +9 -0
  32. package/lib/typescript/src/Previewer.d.ts.map +1 -0
  33. package/lib/typescript/src/controls.d.ts +24 -0
  34. package/lib/typescript/src/controls.d.ts.map +1 -0
  35. package/lib/typescript/src/csf.d.ts +3 -0
  36. package/lib/typescript/src/csf.d.ts.map +1 -0
  37. package/lib/typescript/src/index.d.ts +9 -0
  38. package/lib/typescript/src/index.d.ts.map +1 -0
  39. package/lib/typescript/src/registry.d.ts +8 -0
  40. package/lib/typescript/src/registry.d.ts.map +1 -0
  41. package/lib/typescript/src/shell.d.ts +7 -0
  42. package/lib/typescript/src/shell.d.ts.map +1 -0
  43. package/lib/typescript/src/types.d.ts +49 -0
  44. package/lib/typescript/src/types.d.ts.map +1 -0
  45. package/package.json +88 -0
  46. package/src/PreviewControls.tsx +128 -0
  47. package/src/PreviewList.tsx +71 -0
  48. package/src/PreviewStage.tsx +72 -0
  49. package/src/Previewer.tsx +28 -0
  50. package/src/controls.ts +75 -0
  51. package/src/csf.ts +59 -0
  52. package/src/index.ts +23 -0
  53. package/src/registry.ts +21 -0
  54. package/src/shell.tsx +22 -0
  55. package/src/types.ts +68 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Edmond Ndanji
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # component-previewer
2
+
3
+ Render a single React Native component in isolation, in your app's **real provider shell**, with chosen props/state, without booting the rest of the app. Uses **Storybook-compatible CSF** (`*.stories.tsx`) with **zero setup** (no `.rnstorybook/`, no codegen manifest, no Metro wrapper), and runs on **both surfaces**: the iOS/Android **simulator** (true native) and a **browser** (via react-native-web).
4
+
5
+ The differentiator: your **real `AppShell` wraps every story** (single source of truth, can't drift), and CSF `decorators` run inside it. Edit a story's `args` **live on-device** with the built-in controls panel.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add -D component-previewer # or npm i -D / yarn add -D
11
+ ```
12
+
13
+ Peer dependencies: `react`, `react-native`.
14
+
15
+ ## Use it in your own app (the contract)
16
+
17
+ 1. **Expose your real provider shell** as one component (theme, query client, i18n, safe-area, …):
18
+ ```tsx
19
+ // AppProviders.tsx
20
+ export function AppProviders({ children }) { /* your real providers */ }
21
+ ```
22
+ 2. **Write CSF stories** (`*.stories.tsx`), the exact Storybook format, no import from this tool needed:
23
+ ```tsx
24
+ // Button.stories.tsx
25
+ import { Button } from './Button';
26
+ export default { title: 'Button', component: Button, args: { label: 'Press me' } };
27
+ export const Primary = { args: { label: 'Buy now' } };
28
+ export const Disabled = { args: { disabled: true } };
29
+ // optional per-story providers run INSIDE your real shell:
30
+ // export const Boxed = { args: {...}, decorators: [(Story) => <View>…<Story/></View>] };
31
+ ```
32
+ 3. **Wire the boot flag** at your app root (~10 lines). Discovery is zero-codegen:
33
+ ```tsx
34
+ import { Previewer, fromRequireContext } from 'component-previewer';
35
+
36
+ const ctx = require.context('./', true, /\.stories\.tsx$/); // Metro / native + Expo web
37
+ const PREVIEW = process.env.EXPO_PUBLIC_PREVIEW === '1';
38
+ const Shell = ({ children }) => <AppProviders>{children}</AppProviders>;
39
+
40
+ export default function App() {
41
+ return PREVIEW
42
+ ? <Previewer stories={fromRequireContext(ctx)} shell={Shell} />
43
+ : <YourApp />;
44
+ }
45
+ ```
46
+ On a pure-Vite host, use `fromGlob(import.meta.glob('./**/*.stories.tsx', { eager: true }))` instead of `fromRequireContext`.
47
+
48
+ ## Live props controls
49
+
50
+ Open any story and tap **Controls** to edit its `args` on-device and re-render live (the Storybook-controls equivalent). Control kinds are inferred from the arg **values** with zero config:
51
+
52
+ | value type | control |
53
+ | ---------- | ---------------- |
54
+ | `string` | text field |
55
+ | `number` | numeric field |
56
+ | `boolean` | switch |
57
+
58
+ Functions, objects, arrays, `null`/`undefined` are skipped (passed through untouched). For a dropdown, declare optional **CSF `argTypes`** on a story (also used for ranges):
59
+
60
+ ```tsx
61
+ export default {
62
+ title: 'Badge',
63
+ component: Badge,
64
+ args: { tone: 'neutral' },
65
+ argTypes: { tone: { control: 'select', options: ['neutral', 'success', 'danger'] } },
66
+ };
67
+ // 'range' is supported too and renders as a clamped number field:
68
+ // argTypes: { size: { control: 'range', min: 16, max: 256, step: 8 } }
69
+ ```
70
+
71
+ A **Reset** button restores the story's declared args. Edits never leak between stories.
72
+
73
+ ## Run the example
74
+
75
+ The repo ships an Expo example app.
76
+
77
+ **Native (simulator / device):**
78
+ ```bash
79
+ cd example
80
+ EXPO_PUBLIC_PREVIEW=1 npx expo start # press i, or scan with Expo Go
81
+ ```
82
+ Boots into a searchable picker of discovered stories; selecting one renders it natively inside the real shell. This is the surface that shows Skia/glass/native modules (the example's `BlurCard` story renders a real native blur).
83
+
84
+ **Browser (no simulator):**
85
+ ```bash
86
+ EXPO_PUBLIC_PREVIEW=1 npx expo start --web
87
+ ```
88
+ Same picker via react-native-web. Native modules can't render here (documented cap).
89
+
90
+ Without the flag, the app boots its normal screen instead. Deep-link straight into one story with `EXPO_PUBLIC_PREVIEW_STORY=button--primary`.
91
+
92
+ ## API
93
+
94
+ - `fromRequireContext(ctx)` / `fromGlob(glob)` → `StoryEntry[]` — zero-codegen discovery.
95
+ - `<Previewer stories={…} shell={…} initialStoryId? />` — the picker + stage UI; `initialStoryId` (or `EXPO_PUBLIC_PREVIEW_STORY`) deep-links straight into one story.
96
+ - `inferControls(args, argTypes?)` → `Control[]` — pure; the control descriptors that drive the on-device panel.
97
+ - `composeStory(entry, Shell?, args?)` — `Shell` (outer) > decorators (inner) > story; pure. Pass `args` to render an override (the live-edit path).
98
+ - `parseCsfModule(id, module)` → `StoryEntry[]` — parse one CSF module to entries.
99
+
100
+ Exported types: `StoryEntry`, `Meta`, `Story`, `Args`, `ArgType`, `ArgTypes`, `ControlKind`, `Control`, `Decorator`, `ShellComponent`, `RequireContext`, `GlobModules`, `CsfModule`.
101
+
102
+ ## Develop the library
103
+
104
+ This is a **pnpm workspace**: the `example/` app consumes the library **source** via Metro (bob's metro-config + the `source` export condition), so **editing `src/` hot-reloads in the example, no rebuild or repack**.
105
+
106
+ ```bash
107
+ pnpm install # once — links the workspace
108
+ pnpm lint # eslint (typescript-eslint)
109
+ pnpm typecheck # tsc --noEmit
110
+ pnpm test # vitest (CSF parsing, discovery, shell compose, control inference)
111
+ pnpm build # react-native-builder-bob → lib/module (ESM) + lib/typescript (.d.ts)
112
+ ```
113
+
114
+ Build/packaging: `react-native-builder-bob` (ESM `module` + `typescript` targets), `exports` map with a `source` condition, MIT licensed. See [CONTRIBUTING.md](./CONTRIBUTING.md).
115
+
116
+ ## Status
117
+
118
+ - **Core:** CSF parsing, zero-codegen discovery (`require.context` / `import.meta.glob`), registry, real-shell compose. Pure and unit-tested.
119
+ - **Native backend:** boot-flag entry swap + in-app picker + real-shell render + deep-link, verified on the iOS simulator (including a native `expo-blur` story).
120
+ - **Web backend:** renders the same CSF stories via react-native-web (native-module cap documented).
121
+ - **Live props controls:** value-inferred text/number/boolean + CSF `argTypes` select/range, on-device, live.
122
+ - **Roadmap:** TS-type-driven prop controls (auto-infer from prop types), VS Code extension, more CSF decorator edge cases.
123
+
124
+ ## License
125
+
126
+ [MIT](./LICENSE)
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { Pressable, ScrollView, StyleSheet, Switch, Text, TextInput, View } from 'react-native';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ // Dependency-free controls panel (bottom sheet). Neutral chrome — the host theme
7
+ // applies to the previewed story, not here. Each control edits one arg live.
8
+ export function PreviewControls({
9
+ controls,
10
+ onChange,
11
+ onReset
12
+ }) {
13
+ return /*#__PURE__*/_jsxs(View, {
14
+ style: styles.sheet,
15
+ children: [/*#__PURE__*/_jsxs(View, {
16
+ style: styles.header,
17
+ children: [/*#__PURE__*/_jsx(Text, {
18
+ style: styles.title,
19
+ children: "Props"
20
+ }), /*#__PURE__*/_jsx(Pressable, {
21
+ onPress: onReset,
22
+ accessibilityLabel: "Reset props",
23
+ children: /*#__PURE__*/_jsx(Text, {
24
+ style: styles.reset,
25
+ children: "Reset"
26
+ })
27
+ })]
28
+ }), /*#__PURE__*/_jsx(ScrollView, {
29
+ keyboardShouldPersistTaps: "handled",
30
+ children: controls.map(c => /*#__PURE__*/_jsxs(View, {
31
+ style: styles.row,
32
+ children: [/*#__PURE__*/_jsx(Text, {
33
+ style: styles.label,
34
+ children: c.name
35
+ }), /*#__PURE__*/_jsx(View, {
36
+ style: styles.control,
37
+ children: /*#__PURE__*/_jsx(ControlInput, {
38
+ control: c,
39
+ onChange: v => onChange(c.name, v)
40
+ })
41
+ })]
42
+ }, c.name))
43
+ })]
44
+ });
45
+ }
46
+ function ControlInput({
47
+ control,
48
+ onChange
49
+ }) {
50
+ switch (control.kind) {
51
+ case 'boolean':
52
+ return /*#__PURE__*/_jsx(Switch, {
53
+ value: control.value,
54
+ onValueChange: onChange
55
+ });
56
+ case 'number':
57
+ return /*#__PURE__*/_jsx(TextInput, {
58
+ style: styles.input,
59
+ keyboardType: "numeric",
60
+ value: String(control.value),
61
+ onChangeText: text => {
62
+ const n = Number(text);
63
+ if (text.trim() === '' || Number.isNaN(n)) return; // ignore non-numeric input
64
+ let next = n;
65
+ if (control.min != null) next = Math.max(control.min, next);
66
+ if (control.max != null) next = Math.min(control.max, next);
67
+ onChange(next);
68
+ }
69
+ });
70
+ case 'select':
71
+ return /*#__PURE__*/_jsx(View, {
72
+ style: styles.options,
73
+ children: control.options.map(opt => {
74
+ const selected = opt === control.value;
75
+ return /*#__PURE__*/_jsx(Pressable, {
76
+ style: [styles.pill, selected && styles.pillSelected],
77
+ onPress: () => onChange(opt),
78
+ children: /*#__PURE__*/_jsx(Text, {
79
+ style: [styles.pillText, selected && styles.pillTextSelected],
80
+ children: String(opt)
81
+ })
82
+ }, String(opt));
83
+ })
84
+ });
85
+ default:
86
+ // 'text'
87
+ return /*#__PURE__*/_jsx(TextInput, {
88
+ style: styles.input,
89
+ value: control.value,
90
+ autoCapitalize: "none",
91
+ autoCorrect: false,
92
+ onChangeText: onChange
93
+ });
94
+ }
95
+ }
96
+ const styles = StyleSheet.create({
97
+ sheet: {
98
+ position: 'absolute',
99
+ left: 0,
100
+ right: 0,
101
+ bottom: 0,
102
+ maxHeight: '45%',
103
+ backgroundColor: '#1a1a1c',
104
+ borderTopLeftRadius: 16,
105
+ borderTopRightRadius: 16,
106
+ paddingHorizontal: 16,
107
+ paddingTop: 12,
108
+ paddingBottom: 28,
109
+ borderTopWidth: StyleSheet.hairlineWidth,
110
+ borderTopColor: '#333'
111
+ },
112
+ header: {
113
+ flexDirection: 'row',
114
+ justifyContent: 'space-between',
115
+ alignItems: 'center',
116
+ marginBottom: 8
117
+ },
118
+ title: {
119
+ color: '#fff',
120
+ fontSize: 16,
121
+ fontWeight: '700'
122
+ },
123
+ reset: {
124
+ color: '#7aa2ff',
125
+ fontSize: 14,
126
+ fontWeight: '600'
127
+ },
128
+ row: {
129
+ flexDirection: 'row',
130
+ alignItems: 'center',
131
+ paddingVertical: 8,
132
+ gap: 12
133
+ },
134
+ label: {
135
+ color: '#cbcbd2',
136
+ fontSize: 14,
137
+ width: 96
138
+ },
139
+ control: {
140
+ flex: 1,
141
+ alignItems: 'flex-end'
142
+ },
143
+ input: {
144
+ color: '#fff',
145
+ backgroundColor: '#262629',
146
+ borderRadius: 8,
147
+ paddingHorizontal: 10,
148
+ paddingVertical: 8,
149
+ minWidth: 120,
150
+ width: '100%',
151
+ textAlign: 'right'
152
+ },
153
+ options: {
154
+ flexDirection: 'row',
155
+ flexWrap: 'wrap',
156
+ justifyContent: 'flex-end',
157
+ gap: 6
158
+ },
159
+ pill: {
160
+ backgroundColor: '#262629',
161
+ borderRadius: 999,
162
+ paddingHorizontal: 12,
163
+ paddingVertical: 6
164
+ },
165
+ pillSelected: {
166
+ backgroundColor: '#7aa2ff'
167
+ },
168
+ pillText: {
169
+ color: '#cbcbd2',
170
+ fontSize: 13,
171
+ fontWeight: '600'
172
+ },
173
+ pillTextSelected: {
174
+ color: '#10131a'
175
+ }
176
+ });
177
+ //# sourceMappingURL=PreviewControls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Pressable","ScrollView","StyleSheet","Switch","Text","TextInput","View","jsx","_jsx","jsxs","_jsxs","PreviewControls","controls","onChange","onReset","style","styles","sheet","children","header","title","onPress","accessibilityLabel","reset","keyboardShouldPersistTaps","map","c","row","label","name","control","ControlInput","v","kind","value","onValueChange","input","keyboardType","String","onChangeText","text","n","Number","trim","isNaN","next","min","Math","max","options","opt","selected","pill","pillSelected","pillText","pillTextSelected","autoCapitalize","autoCorrect","create","position","left","right","bottom","maxHeight","backgroundColor","borderTopLeftRadius","borderTopRightRadius","paddingHorizontal","paddingTop","paddingBottom","borderTopWidth","hairlineWidth","borderTopColor","flexDirection","justifyContent","alignItems","marginBottom","color","fontSize","fontWeight","paddingVertical","gap","width","flex","borderRadius","minWidth","textAlign","flexWrap"],"sourceRoot":"../../src","sources":["PreviewControls.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,UAAU,EAAEC,UAAU,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGhG;AACA;AACA,OAAO,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, Text, TextInput, View } from 'react-native';
5
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
6
+ // Neutral, dependency-free picker. The host's theme applies only to the
7
+ // previewed story (via the shell), not this chrome.
8
+ export function PreviewList({
9
+ entries,
10
+ onSelect
11
+ }) {
12
+ const [query, setQuery] = useState('');
13
+ const filtered = useMemo(() => {
14
+ const q = query.trim().toLowerCase();
15
+ if (!q) return entries;
16
+ return entries.filter(e => `${e.title} ${e.name}`.toLowerCase().includes(q));
17
+ }, [entries, query]);
18
+ return /*#__PURE__*/_jsxs(View, {
19
+ style: styles.root,
20
+ children: [/*#__PURE__*/_jsxs(Text, {
21
+ style: styles.heading,
22
+ children: ["Stories (", entries.length, ")"]
23
+ }), /*#__PURE__*/_jsx(TextInput, {
24
+ style: styles.search,
25
+ placeholder: "Filter\u2026",
26
+ placeholderTextColor: "#888",
27
+ autoCapitalize: "none",
28
+ autoCorrect: false,
29
+ value: query,
30
+ onChangeText: setQuery
31
+ }), filtered.length === 0 ? /*#__PURE__*/_jsx(Text, {
32
+ style: styles.empty,
33
+ children: entries.length === 0 ? 'No *.stories.tsx found.' : 'No matches.'
34
+ }) : /*#__PURE__*/_jsx(FlatList, {
35
+ data: filtered,
36
+ keyExtractor: e => e.id,
37
+ renderItem: ({
38
+ item
39
+ }) => /*#__PURE__*/_jsxs(Pressable, {
40
+ style: styles.row,
41
+ onPress: () => onSelect(item),
42
+ children: [/*#__PURE__*/_jsxs(Text, {
43
+ style: styles.rowTitle,
44
+ children: [item.title, " ", /*#__PURE__*/_jsxs(Text, {
45
+ style: styles.rowName,
46
+ children: ["/ ", item.name]
47
+ })]
48
+ }), /*#__PURE__*/_jsx(Text, {
49
+ style: styles.rowId,
50
+ children: item.id
51
+ })]
52
+ })
53
+ })]
54
+ });
55
+ }
56
+ const styles = StyleSheet.create({
57
+ root: {
58
+ flex: 1,
59
+ paddingTop: 64,
60
+ paddingHorizontal: 16,
61
+ backgroundColor: '#111'
62
+ },
63
+ heading: {
64
+ color: '#fff',
65
+ fontSize: 20,
66
+ fontWeight: '600',
67
+ marginBottom: 12
68
+ },
69
+ search: {
70
+ color: '#fff',
71
+ backgroundColor: '#222',
72
+ borderRadius: 10,
73
+ paddingHorizontal: 12,
74
+ paddingVertical: 10,
75
+ marginBottom: 12
76
+ },
77
+ empty: {
78
+ color: '#888',
79
+ marginTop: 24
80
+ },
81
+ row: {
82
+ paddingVertical: 14,
83
+ borderBottomWidth: StyleSheet.hairlineWidth,
84
+ borderBottomColor: '#333'
85
+ },
86
+ rowTitle: {
87
+ color: '#fff',
88
+ fontSize: 16
89
+ },
90
+ rowName: {
91
+ color: '#9a9aa2'
92
+ },
93
+ rowId: {
94
+ color: '#666',
95
+ fontSize: 12,
96
+ marginTop: 2
97
+ }
98
+ });
99
+ //# sourceMappingURL=PreviewList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useMemo","useState","FlatList","Pressable","StyleSheet","Text","TextInput","View","jsxs","_jsxs","jsx","_jsx","PreviewList","entries","onSelect","query","setQuery","filtered","q","trim","toLowerCase","filter","e","title","name","includes","style","styles","root","children","heading","length","search","placeholder","placeholderTextColor","autoCapitalize","autoCorrect","value","onChangeText","empty","data","keyExtractor","id","renderItem","item","row","onPress","rowTitle","rowName","rowId","create","flex","paddingTop","paddingHorizontal","backgroundColor","color","fontSize","fontWeight","marginBottom","borderRadius","paddingVertical","marginTop","borderBottomWidth","hairlineWidth","borderBottomColor"],"sourceRoot":"../../src","sources":["PreviewList.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAChD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,IAAI,QAAQ,cAAc;AAAC,SAAAC,IAAA,IAAAC,KAAA,EAAAC,GAAA,IAAAC,IAAA;AAGtF;AACA;AACA,OAAO,SAASC,WAAWA,CAAC;EAC1BC,OAAO;EACPC;AAIF,C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G,CAAC;EACvChB,GAAG,EAAE;IAAEe,eAAe,EAAE,EAAE;IAAEE,iBAAiB,EAAE1D,UAAU,CAAC2D,aAAa;IAAEC,iBAAiB,EAAE;EAAO,CAAC;EACpGjB,QAAQ,EAAE;IAAEQ,KAAK,EAAE,MAAM;IAAEC,QAAQ,EAAE;EAAG,CAAC;EACzCR,OAAO,EAAE;IAAEO,KAAK,EAAE;EAAU,CAAC;EAC7BN,KAAK,EAAE;IAAEM,KAAK,EAAE,MAAM;IAAEC,QAAQ,EAAE,EAAE;IAAEK,SAAS,EAAE;EAAE;AACrD,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ import React, { useMemo, useState } from 'react';
4
+ import { Pressable, StyleSheet, Text, View } from 'react-native';
5
+ import { inferControls } from "./controls.js";
6
+ import { PreviewControls } from "./PreviewControls.js";
7
+ import { composeStory } from "./shell.js";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ // Renders the selected story full-bleed, composed with the real shell (outer)
10
+ // and the story's decorators (inner). The picker chrome stays outside the shell.
11
+ // Live props controls edit `args` and re-render the story in place.
12
+ export function PreviewStage({
13
+ entry,
14
+ shell,
15
+ onBack
16
+ }) {
17
+ const [args, setArgs] = useState(entry.args);
18
+ const [controlsOpen, setControlsOpen] = useState(false);
19
+ const controls = useMemo(() => inferControls(args, entry.argTypes), [args, entry.argTypes]);
20
+ return /*#__PURE__*/_jsxs(View, {
21
+ style: styles.root,
22
+ children: [/*#__PURE__*/_jsx(View, {
23
+ style: styles.content,
24
+ children: composeStory(entry, shell, args)
25
+ }), /*#__PURE__*/_jsx(Pressable, {
26
+ style: styles.back,
27
+ onPress: onBack,
28
+ accessibilityLabel: "Back to stories",
29
+ children: /*#__PURE__*/_jsxs(Text, {
30
+ style: styles.backText,
31
+ children: ["\u2039 ", entry.title, " / ", entry.name]
32
+ })
33
+ }), controls.length > 0 && /*#__PURE__*/_jsx(Pressable, {
34
+ style: styles.toggle,
35
+ onPress: () => setControlsOpen(v => !v),
36
+ accessibilityLabel: "Toggle props controls",
37
+ children: /*#__PURE__*/_jsx(Text, {
38
+ style: styles.backText,
39
+ children: controlsOpen ? 'Controls ▾' : 'Controls ▴'
40
+ })
41
+ }), controlsOpen && controls.length > 0 && /*#__PURE__*/_jsx(PreviewControls, {
42
+ controls: controls,
43
+ onChange: (name, value) => setArgs(a => ({
44
+ ...a,
45
+ [name]: value
46
+ })),
47
+ onReset: () => setArgs(entry.args)
48
+ })]
49
+ });
50
+ }
51
+ const styles = StyleSheet.create({
52
+ root: {
53
+ flex: 1
54
+ },
55
+ content: {
56
+ flex: 1
57
+ },
58
+ back: {
59
+ position: 'absolute',
60
+ top: 56,
61
+ left: 12,
62
+ backgroundColor: 'rgba(0,0,0,0.6)',
63
+ borderRadius: 999,
64
+ paddingHorizontal: 14,
65
+ paddingVertical: 8
66
+ },
67
+ toggle: {
68
+ position: 'absolute',
69
+ top: 56,
70
+ right: 12,
71
+ backgroundColor: 'rgba(0,0,0,0.6)',
72
+ borderRadius: 999,
73
+ paddingHorizontal: 14,
74
+ paddingVertical: 8
75
+ },
76
+ backText: {
77
+ color: '#fff',
78
+ fontSize: 14,
79
+ fontWeight: '600'
80
+ }
81
+ });
82
+ //# sourceMappingURL=PreviewStage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useMemo","useState","Pressable","StyleSheet","Text","View","inferControls","PreviewControls","composeStory","jsx","_jsx","jsxs","_jsxs","PreviewStage","entry","shell","onBack","args","setArgs","controlsOpen","setControlsOpen","controls","argTypes","style","styles","root","children","content","back","onPress","accessibilityLabel","backText","title","name","length","toggle","v","onChange","value","a","onReset","create","flex","position","top","left","backgroundColor","borderRadius","paddingHorizontal","paddingVertical","right","color","fontSize","fontWeight"],"sourceRoot":"../../src","sources":["PreviewStage.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAChD,SAASC,S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,eAAe,EAAE;EACnB,CAAC;EACDlB,QAAQ,EAAE;IAAEoB,KAAK,EAAE,MAAM;IAAEC,QAAQ,EAAE,EAAE;IAAEC,UAAU,EAAE;EAAM;AAC7D,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ import React, { useState } from 'react';
4
+ import { PreviewList } from "./PreviewList.js";
5
+ import { PreviewStage } from "./PreviewStage.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ // The reusable picker + stage UI. The host builds `stories` via
8
+ // fromRequireContext/fromGlob and passes its real `shell` (AppProviders).
9
+ // `initialStoryId` boots straight into one story (useful for deep links /
10
+ // screenshots / "jump to the thing I'm editing").
11
+ export function Previewer({
12
+ stories,
13
+ shell,
14
+ initialStoryId
15
+ }) {
16
+ const initial = initialStoryId ? stories.find(s => s.id === initialStoryId) ?? null : null;
17
+ const [selected, setSelected] = useState(initial);
18
+ if (selected) {
19
+ // key by story id so live-edited arg state resets cleanly per story.
20
+ return /*#__PURE__*/_jsx(PreviewStage, {
21
+ entry: selected,
22
+ shell: shell,
23
+ onBack: () => setSelected(null)
24
+ }, selected.id);
25
+ }
26
+ return /*#__PURE__*/_jsx(PreviewList, {
27
+ entries: stories,
28
+ onSelect: setSelected
29
+ });
30
+ }
31
+ //# sourceMappingURL=Previewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useState","PreviewList","PreviewStage","jsx","_jsx","Previewer","stories","shell","initialStoryId","initial","find","s","id","selected","setSelected","entry","onBack","entries","onSelect"],"sourceRoot":"../../src","sources":["Previewer.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,YAAY,QAAQ,mBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAI9C;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAC;EACxBC,OAAO;EACPC,KAAK;EACLC;AAKF,CAAC,EAAE;EACD,MAAMC,OAAO,GAAGD,cAAc,GAAIF,OAAO,CAACI,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,EAAE,KAAKJ,cAAc,CAAC,IAAI,IAAI,GAAI,IAAI;EAC9F,MAAM,CAACK,QAAQ,EAAEC,WAAW,CAAC,GAAGd,QAAQ,CAAoBS,OAAO,CAAC;EAEpE,IAAII,QAAQ,EAAE;IACZ;IACA,oBAAOT,IAAA,CAACF,YAAY;MAAmBa,KAAK,EAAEF,QAAS;MAACN,KAAK,EAAEA,KAAM;MAACS,MAAM,EAAEA,CAAA,KAAMF,WAAW,CAAC,IAAI;IAAE,GAA5ED,QAAQ,CAACD,EAAqE,CAAC;EAC3G;EACA,oBAAOR,IAAA,CAACH,WAAW;IAACgB,OAAO,EAAEX,OAAQ;IAACY,QAAQ,EAAEJ;EAAY,CAAE,CAAC;AACjE","ignoreList":[]}