@multiplatform.one/storybook 9.17.0 → 10.0.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/dist/cjs/CreatePreview.cjs +554 -589
- package/dist/cjs/CreatePreview.native.cjs +802 -0
- package/dist/cjs/CreatePreview.native.js +744 -823
- package/dist/cjs/CreatePreview.native.js.map +1 -1
- package/dist/cjs/index.cjs +17 -19
- package/dist/cjs/index.native.cjs +35 -0
- package/dist/cjs/index.native.js +22 -25
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/safeAction.cjs +53 -57
- package/dist/cjs/safeAction.native.cjs +98 -0
- package/dist/cjs/safeAction.native.js +79 -98
- package/dist/cjs/safeAction.native.js.map +1 -1
- package/dist/esm/CreatePreview.mjs +533 -559
- package/dist/esm/CreatePreview.mjs.map +1 -1
- package/dist/esm/CreatePreview.native.js +723 -794
- package/dist/esm/CreatePreview.native.js.map +1 -1
- package/dist/esm/index.mjs +4 -3
- package/dist/esm/index.native.js +9 -8
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/safeAction.mjs +42 -40
- package/dist/esm/safeAction.mjs.map +1 -1
- package/dist/esm/safeAction.native.js +67 -81
- package/dist/esm/safeAction.native.js.map +1 -1
- package/dist/jsx/CreatePreview.mjs +533 -559
- package/dist/jsx/CreatePreview.mjs.map +1 -1
- package/dist/jsx/CreatePreview.native.cjs +802 -0
- package/dist/jsx/CreatePreview.native.js +744 -823
- package/dist/jsx/CreatePreview.native.js.map +1 -1
- package/dist/jsx/index.js +4 -3
- package/dist/jsx/index.mjs +4 -3
- package/dist/jsx/index.native.cjs +35 -0
- package/dist/jsx/index.native.js +22 -25
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/safeAction.mjs +42 -40
- package/dist/jsx/safeAction.mjs.map +1 -1
- package/dist/jsx/safeAction.native.cjs +98 -0
- package/dist/jsx/safeAction.native.js +79 -98
- package/dist/jsx/safeAction.native.js.map +1 -1
- package/package.json +14 -14
- package/src/CreatePreview.consoleErrors.spec.ts +49 -0
- package/src/CreatePreview.spec.tsx +1 -1
- package/src/CreatePreview.tsx +5 -30
- package/types/CreatePreview.d.ts +6 -0
- package/types/CreatePreview.d.ts.map +1 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
|
@@ -5,43 +5,36 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
30
25
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
27
|
var CreatePreview_exports = {};
|
|
35
28
|
__export(CreatePreview_exports, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
accentColorsChannelEvent: () => accentColorsChannelEvent,
|
|
30
|
+
accentOppositeChannelEvent: () => accentOppositeChannelEvent,
|
|
31
|
+
animationNamesChannelEvent: () => animationNamesChannelEvent,
|
|
32
|
+
baseOppositeChannelEvent: () => baseOppositeChannelEvent,
|
|
33
|
+
baseThemeColorsChannelEvent: () => baseThemeColorsChannelEvent,
|
|
34
|
+
createPreview: () => createPreview,
|
|
35
|
+
frappeDebugChannelEvent: () => frappeDebugChannelEvent,
|
|
36
|
+
themeColorsChannelEvent: () => themeColorsChannelEvent,
|
|
37
|
+
themeColorsOppositeChannelEvent: () => themeColorsOppositeChannelEvent
|
|
45
38
|
});
|
|
46
39
|
module.exports = __toCommonJS(CreatePreview_exports);
|
|
47
40
|
var import_react = require("react");
|
|
@@ -60,582 +53,554 @@ const animationNamesChannelEvent = "theme-addon/animation-names";
|
|
|
60
53
|
const frappeDebugChannelEvent = "frappe-addon/debug-state";
|
|
61
54
|
const defaultThemeConfigName = "full";
|
|
62
55
|
const knobOptions = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// LC-40 DISABLED-VISIBLE: the disabled-treatment dial is sweepable so the
|
|
77
|
-
// VERIFY probes (and humans) can flip keepLabel/dimWhole from the toolbar
|
|
78
|
-
// or via URL globals.
|
|
79
|
-
disabledStyle: Object.values(import_theme.DisabledStyle),
|
|
80
|
-
// K4: the one house knob a table sweep has to flip (MPO-132).
|
|
81
|
-
tableZebra: Object.values(import_theme.TableZebra)
|
|
56
|
+
fillStyle: Object.values(import_theme.FillStyle),
|
|
57
|
+
borderRadius: Object.values(import_theme.BorderRadius),
|
|
58
|
+
cornerSmoothing: Object.values(import_theme.CornerSmoothing),
|
|
59
|
+
borderWidth: Object.values(import_theme.BorderWidth),
|
|
60
|
+
elevation: Object.values(import_theme.Elevation),
|
|
61
|
+
textAccent: Object.values(import_theme.TextAccent),
|
|
62
|
+
headingFont: Object.values(import_theme.HeadingFont),
|
|
63
|
+
bodyFont: Object.values(import_theme.BodyFont),
|
|
64
|
+
fontWeight: Object.values(import_theme.FontWeight),
|
|
65
|
+
pageTitleScale: Object.values(import_theme.PageTitleScale),
|
|
66
|
+
animation: ["none", ...import_theme.motionStops],
|
|
67
|
+
disabledStyle: Object.values(import_theme.DisabledStyle),
|
|
68
|
+
tableZebra: Object.values(import_theme.TableZebra)
|
|
82
69
|
};
|
|
83
|
-
const stateKnobFields = [
|
|
70
|
+
const stateKnobFields = [
|
|
71
|
+
"fillStyle",
|
|
72
|
+
"borderRadius",
|
|
73
|
+
"borderWidth",
|
|
74
|
+
"elevation",
|
|
75
|
+
"textAccent",
|
|
76
|
+
"headingFont",
|
|
77
|
+
"bodyFont",
|
|
78
|
+
"fontWeight"
|
|
79
|
+
];
|
|
84
80
|
function parseValue(value) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
if (typeof value !== "string") return value;
|
|
82
|
+
try {
|
|
83
|
+
return JSON.parse(value);
|
|
84
|
+
} catch {
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
91
87
|
}
|
|
92
|
-
const toTitleCase = str => str.replace(/([A-Z])/g, " $1").replace(/^./, s => s.toUpperCase());
|
|
88
|
+
const toTitleCase = (str) => str.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
|
|
93
89
|
function createControl(key) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
})
|
|
110
|
-
};
|
|
90
|
+
const name = toTitleCase(key);
|
|
91
|
+
const values = knobOptions[key] ?? [];
|
|
92
|
+
const serialized = values.map((value) => value);
|
|
93
|
+
const labels = Object.fromEntries(serialized.map((v) => [v, v.replace("$", "")]));
|
|
94
|
+
const fallback = import_theme.defaultKnobs[key];
|
|
95
|
+
return {
|
|
96
|
+
name,
|
|
97
|
+
description: name.toLowerCase(),
|
|
98
|
+
options: serialized,
|
|
99
|
+
control: {
|
|
100
|
+
type: "select",
|
|
101
|
+
labels
|
|
102
|
+
},
|
|
103
|
+
...fallback !== void 0 && { defaultValue: fallback }
|
|
104
|
+
};
|
|
111
105
|
}
|
|
112
|
-
function CanvasBackground({
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
children
|
|
129
|
-
});
|
|
106
|
+
function CanvasBackground({ children }) {
|
|
107
|
+
const tamaguiTheme = (0, import_tamagui.useTheme)();
|
|
108
|
+
const bg = tamaguiTheme.background?.val;
|
|
109
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
110
|
+
if (bg && typeof document !== "undefined") {
|
|
111
|
+
document.body.style.backgroundColor = bg;
|
|
112
|
+
document.documentElement.style.backgroundColor = bg;
|
|
113
|
+
}
|
|
114
|
+
}, [bg]);
|
|
115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
116
|
+
flex: 1,
|
|
117
|
+
minHeight: "100vh",
|
|
118
|
+
backgroundColor: "background",
|
|
119
|
+
id: "mpo-matrix-root",
|
|
120
|
+
children
|
|
121
|
+
});
|
|
130
122
|
}
|
|
131
123
|
let _channelEmit = null;
|
|
132
124
|
function getChannelEmit() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
125
|
+
if (_channelEmit) return _channelEmit;
|
|
126
|
+
try {
|
|
127
|
+
const mod = require("storybook/preview-api");
|
|
128
|
+
const channel = mod.addons.getChannel();
|
|
129
|
+
_channelEmit = (event, data) => channel.emit(event, data);
|
|
130
|
+
return _channelEmit;
|
|
131
|
+
} catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
142
134
|
}
|
|
143
135
|
function AnimationNamesEmitter() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
const emittedRef = (0, import_react.useRef)(false);
|
|
137
|
+
(0, import_react.useEffect)(() => {
|
|
138
|
+
if (emittedRef.current) return;
|
|
139
|
+
emittedRef.current = true;
|
|
140
|
+
getChannelEmit()?.(animationNamesChannelEvent, [...import_theme.motionStops]);
|
|
141
|
+
}, []);
|
|
142
|
+
return null;
|
|
151
143
|
}
|
|
152
144
|
function FrappeDebugEmitter() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}, [tick]);
|
|
201
|
-
return null;
|
|
145
|
+
const prevRef = (0, import_react.useRef)("");
|
|
146
|
+
const syncRef = (0, import_react.useRef)(null);
|
|
147
|
+
const [tick, setTick] = (0, import_react.useState)(0);
|
|
148
|
+
(0, import_react.useEffect)(() => {
|
|
149
|
+
let cancelled = false;
|
|
150
|
+
async function resolve() {
|
|
151
|
+
try {
|
|
152
|
+
const { __getActiveSyncModule } = await import("@multiplatform.one/frappe");
|
|
153
|
+
const sync = __getActiveSyncModule();
|
|
154
|
+
if (sync && !cancelled) {
|
|
155
|
+
syncRef.current = sync;
|
|
156
|
+
setTick((t) => t + 1);
|
|
157
|
+
return sync.subscribeStore(() => {
|
|
158
|
+
if (!cancelled) setTick((t) => t + 1);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} catch {}
|
|
162
|
+
}
|
|
163
|
+
const cleanupPromise = resolve();
|
|
164
|
+
let attempts = 0;
|
|
165
|
+
const interval = setInterval(async () => {
|
|
166
|
+
attempts++;
|
|
167
|
+
if (syncRef.current || cancelled || attempts >= 10) {
|
|
168
|
+
clearInterval(interval);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
await resolve();
|
|
172
|
+
}, 2e3);
|
|
173
|
+
return () => {
|
|
174
|
+
cancelled = true;
|
|
175
|
+
clearInterval(interval);
|
|
176
|
+
cleanupPromise.then((unsub) => unsub?.());
|
|
177
|
+
};
|
|
178
|
+
}, []);
|
|
179
|
+
(0, import_react.useEffect)(() => {
|
|
180
|
+
if (!syncRef.current) return;
|
|
181
|
+
const emit = getChannelEmit();
|
|
182
|
+
if (!emit) return;
|
|
183
|
+
try {
|
|
184
|
+
const state = syncRef.current.__debug();
|
|
185
|
+
const key = JSON.stringify(state);
|
|
186
|
+
if (key === prevRef.current) return;
|
|
187
|
+
prevRef.current = key;
|
|
188
|
+
emit(frappeDebugChannelEvent, state);
|
|
189
|
+
} catch {}
|
|
190
|
+
}, [tick]);
|
|
191
|
+
return null;
|
|
202
192
|
}
|
|
203
193
|
function ThemeColorEmitter() {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
194
|
+
const tamaguiTheme = (0, import_tamagui.useTheme)();
|
|
195
|
+
const prevRef = (0, import_react.useRef)("");
|
|
196
|
+
(0, import_react.useEffect)(() => {
|
|
197
|
+
const colors = [];
|
|
198
|
+
for (let i = 1; i <= 12; i++) {
|
|
199
|
+
const token = tamaguiTheme[`color-${i}`];
|
|
200
|
+
colors.push(token?.val ?? "");
|
|
201
|
+
}
|
|
202
|
+
const key = colors.join("|");
|
|
203
|
+
if (key === prevRef.current) return;
|
|
204
|
+
prevRef.current = key;
|
|
205
|
+
getChannelEmit()?.(themeColorsChannelEvent, colors);
|
|
206
|
+
}, [tamaguiTheme]);
|
|
207
|
+
return null;
|
|
218
208
|
}
|
|
219
209
|
function BaseThemeColorEmitter() {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
210
|
+
const tamaguiTheme = (0, import_tamagui.useTheme)();
|
|
211
|
+
const prevRef = (0, import_react.useRef)("");
|
|
212
|
+
(0, import_react.useEffect)(() => {
|
|
213
|
+
const colors = [];
|
|
214
|
+
for (let i = 1; i <= 12; i++) {
|
|
215
|
+
const token = tamaguiTheme[`color-${i}`];
|
|
216
|
+
colors.push(token?.val ?? "");
|
|
217
|
+
}
|
|
218
|
+
const key = colors.join("|");
|
|
219
|
+
if (key === prevRef.current) return;
|
|
220
|
+
prevRef.current = key;
|
|
221
|
+
getChannelEmit()?.(baseThemeColorsChannelEvent, colors);
|
|
222
|
+
}, [tamaguiTheme]);
|
|
223
|
+
return null;
|
|
234
224
|
}
|
|
235
225
|
function OppositeThemeColorEmitter() {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
226
|
+
const tamaguiTheme = (0, import_tamagui.useTheme)();
|
|
227
|
+
const prevRef = (0, import_react.useRef)("");
|
|
228
|
+
(0, import_react.useEffect)(() => {
|
|
229
|
+
const colors = [];
|
|
230
|
+
for (let i = 1; i <= 12; i++) {
|
|
231
|
+
const token = tamaguiTheme[`color-${i}`];
|
|
232
|
+
colors.push(token?.val ?? "");
|
|
233
|
+
}
|
|
234
|
+
const key = colors.join("|");
|
|
235
|
+
if (key === prevRef.current) return;
|
|
236
|
+
prevRef.current = key;
|
|
237
|
+
getChannelEmit()?.(themeColorsOppositeChannelEvent, colors);
|
|
238
|
+
}, [tamaguiTheme]);
|
|
239
|
+
return null;
|
|
250
240
|
}
|
|
251
|
-
function ColorChannelEmitter({
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
241
|
+
function ColorChannelEmitter({ event, prefix = "color" }) {
|
|
242
|
+
const tamaguiTheme = (0, import_tamagui.useTheme)();
|
|
243
|
+
const prevRef = (0, import_react.useRef)("");
|
|
244
|
+
(0, import_react.useEffect)(() => {
|
|
245
|
+
const colors = [];
|
|
246
|
+
let found = false;
|
|
247
|
+
for (let i = 1; i <= 12; i++) {
|
|
248
|
+
const token = tamaguiTheme[`${prefix}${i}`];
|
|
249
|
+
const val = token?.val ?? "";
|
|
250
|
+
colors.push(val);
|
|
251
|
+
if (val) found = true;
|
|
252
|
+
}
|
|
253
|
+
if (!found) return;
|
|
254
|
+
const key = colors.join("|");
|
|
255
|
+
if (key === prevRef.current) return;
|
|
256
|
+
prevRef.current = key;
|
|
257
|
+
getChannelEmit()?.(event, colors);
|
|
258
|
+
}, [
|
|
259
|
+
tamaguiTheme,
|
|
260
|
+
event,
|
|
261
|
+
prefix
|
|
262
|
+
]);
|
|
263
|
+
return null;
|
|
273
264
|
}
|
|
274
|
-
const tamaguiPropLeakPatterns = ["pressTheme", "scaleIcon", "borderTopRightRadius", "borderBottomRightRadius", "borderTopLeftRadius", "borderBottomLeftRadius"];
|
|
275
|
-
function suppressTamaguiDomWarnings() {
|
|
276
|
-
if (typeof window === "undefined") return;
|
|
277
|
-
const origError = console.error;
|
|
278
|
-
console.error = (...args) => {
|
|
279
|
-
const msg = args.map(a => typeof a === "string" ? a : "").join(" ");
|
|
280
|
-
if (msg.includes("React does not recognize the") && tamaguiPropLeakPatterns.some(p => msg.includes(p))) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
origError(...args);
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
suppressTamaguiDomWarnings();
|
|
287
265
|
function createPreview(options) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
context
|
|
630
|
-
})
|
|
631
|
-
});
|
|
632
|
-
return {
|
|
633
|
-
globalTypes,
|
|
634
|
-
initialGlobals,
|
|
635
|
-
parameters: {
|
|
636
|
-
...defaultParameters,
|
|
637
|
-
...extraParameters
|
|
638
|
-
},
|
|
639
|
-
decorators: [frameworkDecorator, ...extraDecorators]
|
|
640
|
-
};
|
|
641
|
-
}
|
|
266
|
+
const { themeConfig, i18n, AppProvider, setUserScheme, decorators: extraDecorators = [], parameters: extraParameters = {}, globalTypes: extraGlobalTypes = {} } = options;
|
|
267
|
+
const themeConfigsByName = {
|
|
268
|
+
...options.themeConfigs,
|
|
269
|
+
[defaultThemeConfigName]: themeConfig
|
|
270
|
+
};
|
|
271
|
+
const themeConfigNames = [defaultThemeConfigName, ...Object.keys(themeConfigsByName).filter((name) => name !== defaultThemeConfigName)];
|
|
272
|
+
const switchesThemeConfig = themeConfigNames.length > 1;
|
|
273
|
+
if (switchesThemeConfig) (0, import_theme.activateThemeConfig)(themeConfig);
|
|
274
|
+
let activeThemeConfigName = defaultThemeConfigName;
|
|
275
|
+
function useActiveThemeConfigName(requested) {
|
|
276
|
+
const [active, setActive] = (0, import_react.useState)(activeThemeConfigName);
|
|
277
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
278
|
+
if (requested !== activeThemeConfigName) {
|
|
279
|
+
(0, import_theme.activateThemeConfig)(themeConfigsByName[requested]);
|
|
280
|
+
activeThemeConfigName = requested;
|
|
281
|
+
}
|
|
282
|
+
setActive(requested);
|
|
283
|
+
}, [requested]);
|
|
284
|
+
return active;
|
|
285
|
+
}
|
|
286
|
+
const enumKeys = Object.keys(knobOptions);
|
|
287
|
+
const generatedGlobalTypes = {};
|
|
288
|
+
for (const key of enumKeys) {
|
|
289
|
+
generatedGlobalTypes[key] = createControl(key);
|
|
290
|
+
}
|
|
291
|
+
for (const state of [
|
|
292
|
+
"hover",
|
|
293
|
+
"press",
|
|
294
|
+
"focus",
|
|
295
|
+
"focusVisible"
|
|
296
|
+
]) {
|
|
297
|
+
for (const field of stateKnobFields) {
|
|
298
|
+
const stateKey = `${state}.${field}`;
|
|
299
|
+
const values = knobOptions[field] ?? [];
|
|
300
|
+
const serialized = values.map((value) => value);
|
|
301
|
+
const labels = Object.fromEntries(serialized.map((v) => [v, v.replace("$", "")]));
|
|
302
|
+
generatedGlobalTypes[stateKey] = {
|
|
303
|
+
name: `${toTitleCase(state)} ${toTitleCase(field)}`,
|
|
304
|
+
description: `${state} override for ${field}`,
|
|
305
|
+
options: serialized,
|
|
306
|
+
control: {
|
|
307
|
+
type: "select",
|
|
308
|
+
labels
|
|
309
|
+
},
|
|
310
|
+
defaultValue: ""
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const themeColorNames = ["", ...themeConfig.themeColors];
|
|
315
|
+
const themeSwatches = {};
|
|
316
|
+
const allThemes = themeConfig.tamagui.themes;
|
|
317
|
+
if (allThemes) {
|
|
318
|
+
for (const name of themeConfig.themeColors) {
|
|
319
|
+
const theme = allThemes[`light_${name}`] ?? allThemes[name];
|
|
320
|
+
if (!theme) continue;
|
|
321
|
+
const token = theme["color-7"];
|
|
322
|
+
if (typeof token === "string") {
|
|
323
|
+
themeSwatches[name] = token;
|
|
324
|
+
} else if (token && typeof token === "object" && "val" in token) {
|
|
325
|
+
themeSwatches[name] = String(token.val);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
generatedGlobalTypes.color = {
|
|
330
|
+
name: "Theme",
|
|
331
|
+
description: "Theme color palette",
|
|
332
|
+
options: themeColorNames,
|
|
333
|
+
control: {
|
|
334
|
+
type: "select",
|
|
335
|
+
labels: Object.fromEntries(themeColorNames.map((v) => [v, v || "(none)"]))
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
generatedGlobalTypes.scheme = {
|
|
339
|
+
name: "Scheme",
|
|
340
|
+
description: "Color scheme (light/dark/system)",
|
|
341
|
+
options: [
|
|
342
|
+
"system",
|
|
343
|
+
"light",
|
|
344
|
+
"dark"
|
|
345
|
+
],
|
|
346
|
+
control: { type: "select" }
|
|
347
|
+
};
|
|
348
|
+
generatedGlobalTypes.locale = {
|
|
349
|
+
name: "Locale",
|
|
350
|
+
description: "Controls internationalization language",
|
|
351
|
+
options: [...i18n.languages],
|
|
352
|
+
control: { type: "select" },
|
|
353
|
+
toolbar: {
|
|
354
|
+
title: "Locale",
|
|
355
|
+
items: [...i18n.languages],
|
|
356
|
+
dynamicTitle: true
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
if (switchesThemeConfig) {
|
|
360
|
+
generatedGlobalTypes.tamaguiConfig = {
|
|
361
|
+
name: "Tamagui config",
|
|
362
|
+
description: "Tamagui config the story renders under",
|
|
363
|
+
options: themeConfigNames,
|
|
364
|
+
control: { type: "select" },
|
|
365
|
+
toolbar: {
|
|
366
|
+
title: "Tamagui config",
|
|
367
|
+
icon: "paintbrush",
|
|
368
|
+
items: themeConfigNames.map((name) => ({
|
|
369
|
+
value: name,
|
|
370
|
+
title: `${name} config`
|
|
371
|
+
})),
|
|
372
|
+
dynamicTitle: true
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
const globalTypes = {
|
|
377
|
+
...generatedGlobalTypes,
|
|
378
|
+
...extraGlobalTypes
|
|
379
|
+
};
|
|
380
|
+
const initialGlobals = {
|
|
381
|
+
locale: import_platform.config.get("I18N_DEFAULT_LANGUAGE", i18n.defaultLanguage),
|
|
382
|
+
color: "",
|
|
383
|
+
scheme: "system",
|
|
384
|
+
__presetNames: (0, import_theme.getPresetNames)(),
|
|
385
|
+
__presetScales: Object.fromEntries((0, import_theme.getPresetNames)().map((name) => {
|
|
386
|
+
const scale = (0, import_theme.getPreset)(name)?.scale ?? import_theme.defaultScaleInputs;
|
|
387
|
+
return [name, {
|
|
388
|
+
control: scale.control,
|
|
389
|
+
type: scale.type
|
|
390
|
+
}];
|
|
391
|
+
})),
|
|
392
|
+
__themeColors: themeColorNames,
|
|
393
|
+
__themeSwatches: themeSwatches,
|
|
394
|
+
preset: themeConfig.defaultPreset ?? "",
|
|
395
|
+
...switchesThemeConfig && { tamaguiConfig: defaultThemeConfigName }
|
|
396
|
+
};
|
|
397
|
+
for (const key of enumKeys) {
|
|
398
|
+
if (!(key in initialGlobals)) {
|
|
399
|
+
initialGlobals[key] = "";
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
for (const state of [
|
|
403
|
+
"hover",
|
|
404
|
+
"press",
|
|
405
|
+
"focus",
|
|
406
|
+
"focusVisible"
|
|
407
|
+
]) {
|
|
408
|
+
for (const field of stateKnobFields) {
|
|
409
|
+
initialGlobals[`${state}.${field}`] = "";
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
globalThis.__MPO_THEME_AXES__ = {
|
|
413
|
+
schemes: ["light", "dark"],
|
|
414
|
+
themeColors: themeColorNames,
|
|
415
|
+
presets: ["", ...(0, import_theme.getPresetNames)()],
|
|
416
|
+
presetThemes: Object.fromEntries((0, import_theme.getPresetNames)().flatMap((name) => {
|
|
417
|
+
const theme = (0, import_theme.getPreset)(name)?.theme;
|
|
418
|
+
return theme ? [[name, theme]] : [];
|
|
419
|
+
}))
|
|
420
|
+
};
|
|
421
|
+
const defaultParameters = {
|
|
422
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
423
|
+
layout: "padded",
|
|
424
|
+
viewMode: "story",
|
|
425
|
+
controls: {
|
|
426
|
+
expanded: true,
|
|
427
|
+
hideNoControlsWarning: true,
|
|
428
|
+
matchers: {
|
|
429
|
+
color: /(background|color)$/i,
|
|
430
|
+
date: /Date$/
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
backgrounds: { disable: true },
|
|
434
|
+
previewTabs: { "storybook/docs/panel": { hidden: true } },
|
|
435
|
+
a11y: { test: false },
|
|
436
|
+
docs: { codePanel: true },
|
|
437
|
+
darkMode: { stylePreview: true }
|
|
438
|
+
};
|
|
439
|
+
function FrameworkDecoratorInner({ Story, context }) {
|
|
440
|
+
const [knobs, setKnobs] = (0, import_theme.useTheme)();
|
|
441
|
+
const schemeGlobal = context.globals.scheme || "system";
|
|
442
|
+
const [resolvedScheme, setResolvedScheme] = (0, import_react.useState)(() => {
|
|
443
|
+
if (schemeGlobal === "light" || schemeGlobal === "dark") return schemeGlobal;
|
|
444
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
445
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
446
|
+
}
|
|
447
|
+
return "light";
|
|
448
|
+
});
|
|
449
|
+
(0, import_react.useEffect)(() => {
|
|
450
|
+
if (schemeGlobal === "light" || schemeGlobal === "dark") {
|
|
451
|
+
setResolvedScheme(schemeGlobal);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
455
|
+
setResolvedScheme("light");
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
459
|
+
const handler = () => setResolvedScheme(mq.matches ? "dark" : "light");
|
|
460
|
+
handler();
|
|
461
|
+
mq.addEventListener("change", handler);
|
|
462
|
+
return () => mq.removeEventListener("change", handler);
|
|
463
|
+
}, [schemeGlobal]);
|
|
464
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
465
|
+
const setting = schemeGlobal === "light" || schemeGlobal === "dark" ? schemeGlobal : "system";
|
|
466
|
+
setUserScheme?.(setting);
|
|
467
|
+
(0, import_theme.setStoredScheme)(setting);
|
|
468
|
+
}, [schemeGlobal]);
|
|
469
|
+
const colorGlobal = context.globals.color || "";
|
|
470
|
+
const requestedThemeConfig = context.globals.tamaguiConfig;
|
|
471
|
+
const requestedThemeConfigName = requestedThemeConfig && themeConfigNames.includes(requestedThemeConfig) ? requestedThemeConfig : defaultThemeConfigName;
|
|
472
|
+
const themeConfigName = useActiveThemeConfigName(requestedThemeConfigName);
|
|
473
|
+
const storyThemeParams = context.parameters?.theme;
|
|
474
|
+
const activePresetName = context.globals.preset || void 0;
|
|
475
|
+
const activePreset = activePresetName ? (0, import_theme.getPreset)(activePresetName) : void 0;
|
|
476
|
+
const presetTheme = colorGlobal || activePreset?.theme || import_theme.defaultPreset.theme;
|
|
477
|
+
const scaleId = (0, import_theme.useActiveScale)(themeConfigsByName[requestedThemeConfigName], activePresetName);
|
|
478
|
+
const knobUpdate = (0, import_react.useMemo)(() => {
|
|
479
|
+
const result = {};
|
|
480
|
+
const stateKeys = /* @__PURE__ */ new Set([
|
|
481
|
+
"hover",
|
|
482
|
+
"press",
|
|
483
|
+
"focus",
|
|
484
|
+
"focusVisible"
|
|
485
|
+
]);
|
|
486
|
+
for (const key of Object.keys(knobs)) {
|
|
487
|
+
if (stateKeys.has(key)) continue;
|
|
488
|
+
if (storyThemeParams && key in storyThemeParams) {
|
|
489
|
+
result[key] = storyThemeParams[key];
|
|
490
|
+
} else if (key in context.globals && context.globals[key] !== void 0 && context.globals[key] !== "") {
|
|
491
|
+
result[key] = parseValue(context.globals[key]);
|
|
492
|
+
} else if (activePreset && key in activePreset.knobs) {
|
|
493
|
+
result[key] = activePreset.knobs[key];
|
|
494
|
+
} else {
|
|
495
|
+
result[key] = import_theme.defaultKnobs[key];
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
result.animation = (0, import_theme.normalizeAnimationKnob)(result.animation) ?? import_theme.defaultKnobs.animation;
|
|
499
|
+
for (const state of stateKeys) {
|
|
500
|
+
const stateObj = {};
|
|
501
|
+
let hasValues = false;
|
|
502
|
+
for (const field of stateKnobFields) {
|
|
503
|
+
const globalKey = `${state}.${field}`;
|
|
504
|
+
const val = context.globals[globalKey];
|
|
505
|
+
if (val) {
|
|
506
|
+
stateObj[field] = val;
|
|
507
|
+
hasValues = true;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (hasValues) {
|
|
511
|
+
result[state] = stateObj;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return result;
|
|
515
|
+
}, [
|
|
516
|
+
knobs,
|
|
517
|
+
context.globals,
|
|
518
|
+
storyThemeParams,
|
|
519
|
+
activePreset
|
|
520
|
+
]);
|
|
521
|
+
(0, import_react.useEffect)(() => {
|
|
522
|
+
setKnobs(knobUpdate);
|
|
523
|
+
}, [knobUpdate, setKnobs]);
|
|
524
|
+
(0, import_react.useEffect)(() => {
|
|
525
|
+
i18n.instance.changeLanguage(context.globals.locale);
|
|
526
|
+
}, [context.globals.locale]);
|
|
527
|
+
const presetCtxValue = (0, import_react.useMemo)(() => ({
|
|
528
|
+
preset: {
|
|
529
|
+
...(0, import_theme.applyColorTheme)(activePreset ?? import_theme.defaultPreset, colorGlobal),
|
|
530
|
+
theme: presetTheme,
|
|
531
|
+
knobs: {
|
|
532
|
+
...import_theme.defaultKnobs,
|
|
533
|
+
...knobUpdate
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
overrides: void 0,
|
|
537
|
+
presetName: activePresetName,
|
|
538
|
+
scaleId,
|
|
539
|
+
color: colorGlobal || void 0
|
|
540
|
+
}), [
|
|
541
|
+
knobUpdate,
|
|
542
|
+
presetTheme,
|
|
543
|
+
activePreset,
|
|
544
|
+
colorGlobal,
|
|
545
|
+
activePresetName,
|
|
546
|
+
scaleId
|
|
547
|
+
]);
|
|
548
|
+
const animationValue = presetCtxValue.preset.knobs.animation;
|
|
549
|
+
(0, import_react.useEffect)(() => {
|
|
550
|
+
if (typeof document === "undefined") return;
|
|
551
|
+
const ms = `${animationValue === "none" ? 0 : import_theme.animationDurations[animationValue]}ms`;
|
|
552
|
+
document.documentElement.style.setProperty("--mp-transition", ms);
|
|
553
|
+
}, [animationValue]);
|
|
554
|
+
const storyContent = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CanvasBackground, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Story, { ...context }) });
|
|
555
|
+
const oppositeScheme = resolvedScheme === "dark" ? "light" : "dark";
|
|
556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_theme.PresetContext.Provider, {
|
|
557
|
+
value: presetCtxValue,
|
|
558
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AppProvider, {
|
|
559
|
+
themeConfig: themeConfigsByName[themeConfigName],
|
|
560
|
+
systemTheme: resolvedScheme,
|
|
561
|
+
children: [
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimationNamesEmitter, {}),
|
|
563
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrappeDebugEmitter, {}),
|
|
564
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BaseThemeColorEmitter, {}),
|
|
565
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
|
|
566
|
+
name: presetTheme || resolvedScheme,
|
|
567
|
+
children: [
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeColorEmitter, {}),
|
|
569
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
|
|
570
|
+
event: accentColorsChannelEvent,
|
|
571
|
+
prefix: "accent"
|
|
572
|
+
}),
|
|
573
|
+
storyContent
|
|
574
|
+
]
|
|
575
|
+
}),
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
|
|
577
|
+
name: oppositeScheme,
|
|
578
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(OppositeThemeColorEmitter, {}), presetTheme ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
|
|
579
|
+
name: presetTheme,
|
|
580
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ColorChannelEmitter, { event: baseOppositeChannelEvent }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
|
|
581
|
+
event: accentOppositeChannelEvent,
|
|
582
|
+
prefix: "accent"
|
|
583
|
+
})]
|
|
584
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ColorChannelEmitter, { event: baseOppositeChannelEvent }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
|
|
585
|
+
event: accentOppositeChannelEvent,
|
|
586
|
+
prefix: "accent"
|
|
587
|
+
})] })]
|
|
588
|
+
})
|
|
589
|
+
]
|
|
590
|
+
}, `${themeConfigName}:${scaleId}`)
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
const frameworkDecorator = (Story, context) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_cookie.CookiesProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrameworkDecoratorInner, {
|
|
594
|
+
Story,
|
|
595
|
+
context
|
|
596
|
+
}) });
|
|
597
|
+
return {
|
|
598
|
+
globalTypes,
|
|
599
|
+
initialGlobals,
|
|
600
|
+
parameters: {
|
|
601
|
+
...defaultParameters,
|
|
602
|
+
...extraParameters
|
|
603
|
+
},
|
|
604
|
+
decorators: [frameworkDecorator, ...extraDecorators]
|
|
605
|
+
};
|
|
606
|
+
}
|