@multiplatform.one/storybook 9.17.0 → 10.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.
- 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
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { BodyFont, BorderRadius, BorderWidth, CornerSmoothing, DisabledStyle, Elevation, FillStyle, FontWeight, HeadingFont, PageTitleScale,
|
|
3
|
+
import { BodyFont, BorderRadius, BorderWidth, CornerSmoothing, DisabledStyle, Elevation, FillStyle, FontWeight, HeadingFont, PageTitleScale, PresetContext, TableZebra, TextAccent, activateThemeConfig, animationDurations, applyColorTheme, defaultKnobs, defaultPreset, defaultScaleInputs, getPreset, getPresetNames, motionStops, normalizeAnimationKnob, setStoredScheme, useActiveScale, useTheme } from "@multiplatform.one/theme";
|
|
4
4
|
import { config } from "@multiplatform.one/platform";
|
|
5
5
|
import { CookiesProvider } from "react-cookie";
|
|
6
|
-
import { Theme, YStack, useTheme as
|
|
7
|
-
function _type_of(obj) {
|
|
8
|
-
"@swc/helpers - typeof";
|
|
6
|
+
import { Theme, YStack, useTheme as useTheme$1 } from "tamagui";
|
|
9
7
|
|
|
10
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
11
|
-
}
|
|
12
8
|
var themeColorsChannelEvent = "theme-addon/theme-colors";
|
|
13
9
|
var themeColorsOppositeChannelEvent = "theme-addon/theme-colors-opposite";
|
|
14
10
|
var baseThemeColorsChannelEvent = "theme-addon/base-theme-colors";
|
|
@@ -19,818 +15,751 @@ var animationNamesChannelEvent = "theme-addon/animation-names";
|
|
|
19
15
|
var frappeDebugChannelEvent = "frappe-addon/debug-state";
|
|
20
16
|
var defaultThemeConfigName = "full";
|
|
21
17
|
var knobOptions = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// LC-40 DISABLED-VISIBLE: the disabled-treatment dial is sweepable so the
|
|
36
|
-
// VERIFY probes (and humans) can flip keepLabel/dimWhole from the toolbar
|
|
37
|
-
// or via URL globals.
|
|
38
|
-
disabledStyle: Object.values(DisabledStyle),
|
|
39
|
-
// K4: the one house knob a table sweep has to flip (MPO-132).
|
|
40
|
-
tableZebra: Object.values(TableZebra)
|
|
18
|
+
fillStyle: Object.values(FillStyle),
|
|
19
|
+
borderRadius: Object.values(BorderRadius),
|
|
20
|
+
cornerSmoothing: Object.values(CornerSmoothing),
|
|
21
|
+
borderWidth: Object.values(BorderWidth),
|
|
22
|
+
elevation: Object.values(Elevation),
|
|
23
|
+
textAccent: Object.values(TextAccent),
|
|
24
|
+
headingFont: Object.values(HeadingFont),
|
|
25
|
+
bodyFont: Object.values(BodyFont),
|
|
26
|
+
fontWeight: Object.values(FontWeight),
|
|
27
|
+
pageTitleScale: Object.values(PageTitleScale),
|
|
28
|
+
animation: ["none", ...motionStops],
|
|
29
|
+
disabledStyle: Object.values(DisabledStyle),
|
|
30
|
+
tableZebra: Object.values(TableZebra)
|
|
41
31
|
};
|
|
42
|
-
var stateKnobFields = [
|
|
32
|
+
var stateKnobFields = [
|
|
33
|
+
"fillStyle",
|
|
34
|
+
"borderRadius",
|
|
35
|
+
"borderWidth",
|
|
36
|
+
"elevation",
|
|
37
|
+
"textAccent",
|
|
38
|
+
"headingFont",
|
|
39
|
+
"bodyFont",
|
|
40
|
+
"fontWeight"
|
|
41
|
+
];
|
|
43
42
|
function parseValue(value) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
if (typeof value !== "string") return value;
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(value);
|
|
46
|
+
} catch (unused) {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
50
49
|
}
|
|
51
50
|
var toTitleCase = function toTitleCase2(str) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
return str.replace(/([A-Z])/g, " $1").replace(/^./, function(s) {
|
|
52
|
+
return s.toUpperCase();
|
|
53
|
+
});
|
|
55
54
|
};
|
|
56
55
|
function createControl(key) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
};
|
|
56
|
+
var _knobOptions_key;
|
|
57
|
+
var name = toTitleCase(key);
|
|
58
|
+
var values = (_knobOptions_key = knobOptions[key]) !== null && _knobOptions_key !== void 0 ? _knobOptions_key : [];
|
|
59
|
+
var serialized = values.map(function(value) {
|
|
60
|
+
return value;
|
|
61
|
+
});
|
|
62
|
+
var labels = Object.fromEntries(serialized.map(function(v) {
|
|
63
|
+
return [v, v.replace("$", "")];
|
|
64
|
+
}));
|
|
65
|
+
var fallback = defaultKnobs[key];
|
|
66
|
+
return {
|
|
67
|
+
name,
|
|
68
|
+
description: name.toLowerCase(),
|
|
69
|
+
options: serialized,
|
|
70
|
+
control: {
|
|
71
|
+
type: "select",
|
|
72
|
+
labels
|
|
73
|
+
},
|
|
74
|
+
...fallback !== void 0 && { defaultValue: fallback }
|
|
75
|
+
};
|
|
79
76
|
}
|
|
80
77
|
function CanvasBackground(param) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// children include the Tamagui `<Theme>` host, which appears only
|
|
99
|
-
// when a colour global is set — capturing there reports a remount as
|
|
100
|
-
// geometry drift and a dead colour axis.
|
|
101
|
-
id: "mpo-matrix-root",
|
|
102
|
-
children
|
|
103
|
-
});
|
|
78
|
+
var { children } = param;
|
|
79
|
+
var _tamaguiTheme_background;
|
|
80
|
+
var tamaguiTheme = useTheme$1();
|
|
81
|
+
var bg = (_tamaguiTheme_background = tamaguiTheme.background) === null || _tamaguiTheme_background === void 0 ? void 0 : _tamaguiTheme_background.val;
|
|
82
|
+
useLayoutEffect(function() {
|
|
83
|
+
if (bg && typeof document !== "undefined") {
|
|
84
|
+
document.body.style.backgroundColor = bg;
|
|
85
|
+
document.documentElement.style.backgroundColor = bg;
|
|
86
|
+
}
|
|
87
|
+
}, [bg]);
|
|
88
|
+
return /* @__PURE__ */ jsx(YStack, {
|
|
89
|
+
flex: 1,
|
|
90
|
+
minHeight: "100vh",
|
|
91
|
+
backgroundColor: "background",
|
|
92
|
+
id: "mpo-matrix-root",
|
|
93
|
+
children
|
|
94
|
+
});
|
|
104
95
|
}
|
|
105
96
|
var _channelEmit = null;
|
|
106
97
|
function getChannelEmit() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
98
|
+
if (_channelEmit) return _channelEmit;
|
|
99
|
+
try {
|
|
100
|
+
var mod = require("storybook/preview-api");
|
|
101
|
+
var channel = mod.addons.getChannel();
|
|
102
|
+
_channelEmit = function _channelEmit2(event, data) {
|
|
103
|
+
return channel.emit(event, data);
|
|
104
|
+
};
|
|
105
|
+
return _channelEmit;
|
|
106
|
+
} catch (unused) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
118
109
|
}
|
|
119
110
|
function AnimationNamesEmitter() {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
111
|
+
var emittedRef = useRef(false);
|
|
112
|
+
useEffect(function() {
|
|
113
|
+
var _getChannelEmit;
|
|
114
|
+
if (emittedRef.current) return;
|
|
115
|
+
emittedRef.current = true;
|
|
116
|
+
(_getChannelEmit = getChannelEmit()) === null || _getChannelEmit === void 0 ? void 0 : _getChannelEmit(animationNamesChannelEvent, [...motionStops]);
|
|
117
|
+
}, []);
|
|
118
|
+
return null;
|
|
128
119
|
}
|
|
129
120
|
function FrappeDebugEmitter() {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
// debug not available
|
|
185
|
-
[tick]);
|
|
186
|
-
return null;
|
|
121
|
+
var prevRef = useRef("");
|
|
122
|
+
var syncRef = useRef(null);
|
|
123
|
+
var [tick, setTick] = useState(0);
|
|
124
|
+
useEffect(function() {
|
|
125
|
+
var cancelled = false;
|
|
126
|
+
async function resolve() {
|
|
127
|
+
try {
|
|
128
|
+
var { __getActiveSyncModule } = await import("@multiplatform.one/frappe");
|
|
129
|
+
var sync = __getActiveSyncModule();
|
|
130
|
+
if (sync && !cancelled) {
|
|
131
|
+
syncRef.current = sync;
|
|
132
|
+
setTick(function(t) {
|
|
133
|
+
return t + 1;
|
|
134
|
+
});
|
|
135
|
+
return sync.subscribeStore(function() {
|
|
136
|
+
if (!cancelled) setTick(function(t) {
|
|
137
|
+
return t + 1;
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} catch (unused) {}
|
|
142
|
+
}
|
|
143
|
+
var cleanupPromise = resolve();
|
|
144
|
+
var attempts = 0;
|
|
145
|
+
var interval = setInterval(async function() {
|
|
146
|
+
attempts++;
|
|
147
|
+
if (syncRef.current || cancelled || attempts >= 10) {
|
|
148
|
+
clearInterval(interval);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
await resolve();
|
|
152
|
+
}, 2e3);
|
|
153
|
+
return function() {
|
|
154
|
+
cancelled = true;
|
|
155
|
+
clearInterval(interval);
|
|
156
|
+
cleanupPromise.then(function(unsub) {
|
|
157
|
+
return unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
}, []);
|
|
161
|
+
useEffect(function() {
|
|
162
|
+
if (!syncRef.current) return;
|
|
163
|
+
var emit = getChannelEmit();
|
|
164
|
+
if (!emit) return;
|
|
165
|
+
try {
|
|
166
|
+
var state = syncRef.current.__debug();
|
|
167
|
+
var key = JSON.stringify(state);
|
|
168
|
+
if (key === prevRef.current) return;
|
|
169
|
+
prevRef.current = key;
|
|
170
|
+
emit(frappeDebugChannelEvent, state);
|
|
171
|
+
} catch (unused) {}
|
|
172
|
+
}, [tick]);
|
|
173
|
+
return null;
|
|
187
174
|
}
|
|
188
175
|
function ThemeColorEmitter() {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
176
|
+
var tamaguiTheme = useTheme$1();
|
|
177
|
+
var prevRef = useRef("");
|
|
178
|
+
useEffect(function() {
|
|
179
|
+
var _getChannelEmit;
|
|
180
|
+
var colors = [];
|
|
181
|
+
for (var i = 1; i <= 12; i++) {
|
|
182
|
+
var _ref;
|
|
183
|
+
var token = tamaguiTheme[`color-${i}`];
|
|
184
|
+
colors.push((_ref = token === null || token === void 0 ? void 0 : token.val) !== null && _ref !== void 0 ? _ref : "");
|
|
185
|
+
}
|
|
186
|
+
var key = colors.join("|");
|
|
187
|
+
if (key === prevRef.current) return;
|
|
188
|
+
prevRef.current = key;
|
|
189
|
+
(_getChannelEmit = getChannelEmit()) === null || _getChannelEmit === void 0 ? void 0 : _getChannelEmit(themeColorsChannelEvent, colors);
|
|
190
|
+
}, [tamaguiTheme]);
|
|
191
|
+
return null;
|
|
205
192
|
}
|
|
206
193
|
function BaseThemeColorEmitter() {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
194
|
+
var tamaguiTheme = useTheme$1();
|
|
195
|
+
var prevRef = useRef("");
|
|
196
|
+
useEffect(function() {
|
|
197
|
+
var _getChannelEmit;
|
|
198
|
+
var colors = [];
|
|
199
|
+
for (var i = 1; i <= 12; i++) {
|
|
200
|
+
var _ref;
|
|
201
|
+
var token = tamaguiTheme[`color-${i}`];
|
|
202
|
+
colors.push((_ref = token === null || token === void 0 ? void 0 : token.val) !== null && _ref !== void 0 ? _ref : "");
|
|
203
|
+
}
|
|
204
|
+
var key = colors.join("|");
|
|
205
|
+
if (key === prevRef.current) return;
|
|
206
|
+
prevRef.current = key;
|
|
207
|
+
(_getChannelEmit = getChannelEmit()) === null || _getChannelEmit === void 0 ? void 0 : _getChannelEmit(baseThemeColorsChannelEvent, colors);
|
|
208
|
+
}, [tamaguiTheme]);
|
|
209
|
+
return null;
|
|
223
210
|
}
|
|
224
211
|
function OppositeThemeColorEmitter() {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
212
|
+
var tamaguiTheme = useTheme$1();
|
|
213
|
+
var prevRef = useRef("");
|
|
214
|
+
useEffect(function() {
|
|
215
|
+
var _getChannelEmit;
|
|
216
|
+
var colors = [];
|
|
217
|
+
for (var i = 1; i <= 12; i++) {
|
|
218
|
+
var _ref;
|
|
219
|
+
var token = tamaguiTheme[`color-${i}`];
|
|
220
|
+
colors.push((_ref = token === null || token === void 0 ? void 0 : token.val) !== null && _ref !== void 0 ? _ref : "");
|
|
221
|
+
}
|
|
222
|
+
var key = colors.join("|");
|
|
223
|
+
if (key === prevRef.current) return;
|
|
224
|
+
prevRef.current = key;
|
|
225
|
+
(_getChannelEmit = getChannelEmit()) === null || _getChannelEmit === void 0 ? void 0 : _getChannelEmit(themeColorsOppositeChannelEvent, colors);
|
|
226
|
+
}, [tamaguiTheme]);
|
|
227
|
+
return null;
|
|
241
228
|
}
|
|
242
229
|
function ColorChannelEmitter(param) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
var tamaguiPropLeakPatterns = ["pressTheme", "scaleIcon", "borderTopRightRadius", "borderBottomRightRadius", "borderTopLeftRadius", "borderBottomLeftRadius"];
|
|
269
|
-
function suppressTamaguiDomWarnings() {
|
|
270
|
-
if (typeof window === "undefined") return;
|
|
271
|
-
var origError = console.error;
|
|
272
|
-
console.error = function () {
|
|
273
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
274
|
-
args[_key] = arguments[_key];
|
|
275
|
-
}
|
|
276
|
-
var msg = args.map(function (a) {
|
|
277
|
-
return typeof a === "string" ? a : "";
|
|
278
|
-
}).join(" ");
|
|
279
|
-
if (msg.includes("React does not recognize the") && tamaguiPropLeakPatterns.some(function (p) {
|
|
280
|
-
return msg.includes(p);
|
|
281
|
-
})) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
origError(...args);
|
|
285
|
-
};
|
|
230
|
+
var { event, prefix = "color" } = param;
|
|
231
|
+
var tamaguiTheme = useTheme$1();
|
|
232
|
+
var prevRef = useRef("");
|
|
233
|
+
useEffect(function() {
|
|
234
|
+
var _getChannelEmit;
|
|
235
|
+
var colors = [];
|
|
236
|
+
var found = false;
|
|
237
|
+
for (var i = 1; i <= 12; i++) {
|
|
238
|
+
var _ref;
|
|
239
|
+
var token = tamaguiTheme[`${prefix}${i}`];
|
|
240
|
+
var val = (_ref = token === null || token === void 0 ? void 0 : token.val) !== null && _ref !== void 0 ? _ref : "";
|
|
241
|
+
colors.push(val);
|
|
242
|
+
if (val) found = true;
|
|
243
|
+
}
|
|
244
|
+
if (!found) return;
|
|
245
|
+
var key = colors.join("|");
|
|
246
|
+
if (key === prevRef.current) return;
|
|
247
|
+
prevRef.current = key;
|
|
248
|
+
(_getChannelEmit = getChannelEmit()) === null || _getChannelEmit === void 0 ? void 0 : _getChannelEmit(event, colors);
|
|
249
|
+
}, [
|
|
250
|
+
tamaguiTheme,
|
|
251
|
+
event,
|
|
252
|
+
prefix
|
|
253
|
+
]);
|
|
254
|
+
return null;
|
|
286
255
|
}
|
|
287
|
-
suppressTamaguiDomWarnings();
|
|
288
256
|
function createPreview(options) {
|
|
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
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
}), /* Opposite scheme emitters */
|
|
795
|
-
/* @__PURE__ */_jsxs(Theme, {
|
|
796
|
-
name: oppositeScheme,
|
|
797
|
-
children: [/* @__PURE__ */_jsx(OppositeThemeColorEmitter, {}), presetTheme ? /* @__PURE__ */_jsxs(Theme, {
|
|
798
|
-
name: presetTheme,
|
|
799
|
-
children: [/* @__PURE__ */_jsx(ColorChannelEmitter, {
|
|
800
|
-
event: baseOppositeChannelEvent
|
|
801
|
-
}), /* @__PURE__ */_jsx(ColorChannelEmitter, {
|
|
802
|
-
event: accentOppositeChannelEvent,
|
|
803
|
-
prefix: "accent"
|
|
804
|
-
})]
|
|
805
|
-
}) : /* @__PURE__ */_jsxs(_Fragment, {
|
|
806
|
-
children: [/* @__PURE__ */_jsx(ColorChannelEmitter, {
|
|
807
|
-
event: baseOppositeChannelEvent
|
|
808
|
-
}), /* @__PURE__ */_jsx(ColorChannelEmitter, {
|
|
809
|
-
event: accentOppositeChannelEvent,
|
|
810
|
-
prefix: "accent"
|
|
811
|
-
})]
|
|
812
|
-
})]
|
|
813
|
-
})]
|
|
814
|
-
}, `${themeConfigName}:${scaleId}`)
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
var frameworkDecorator = function frameworkDecorator2(Story, context) {
|
|
818
|
-
return /* @__PURE__ */_jsx(CookiesProvider, {
|
|
819
|
-
children: /* @__PURE__ */_jsx(FrameworkDecoratorInner, {
|
|
820
|
-
Story,
|
|
821
|
-
context
|
|
822
|
-
})
|
|
823
|
-
});
|
|
824
|
-
};
|
|
825
|
-
return {
|
|
826
|
-
globalTypes,
|
|
827
|
-
initialGlobals,
|
|
828
|
-
parameters: {
|
|
829
|
-
...defaultParameters,
|
|
830
|
-
...extraParameters
|
|
831
|
-
},
|
|
832
|
-
decorators: [frameworkDecorator, ...extraDecorators]
|
|
833
|
-
};
|
|
257
|
+
var _themeConfig_defaultPreset;
|
|
258
|
+
var { themeConfig, i18n, AppProvider, setUserScheme, decorators: extraDecorators = [], parameters: extraParameters = {}, globalTypes: extraGlobalTypes = {} } = options;
|
|
259
|
+
var themeConfigsByName = {
|
|
260
|
+
...options.themeConfigs,
|
|
261
|
+
[defaultThemeConfigName]: themeConfig
|
|
262
|
+
};
|
|
263
|
+
var themeConfigNames = [defaultThemeConfigName, ...Object.keys(themeConfigsByName).filter(function(name2) {
|
|
264
|
+
return name2 !== defaultThemeConfigName;
|
|
265
|
+
})];
|
|
266
|
+
var switchesThemeConfig = themeConfigNames.length > 1;
|
|
267
|
+
if (switchesThemeConfig) activateThemeConfig(themeConfig);
|
|
268
|
+
var activeThemeConfigName = defaultThemeConfigName;
|
|
269
|
+
function useActiveThemeConfigName(requested) {
|
|
270
|
+
var [active, setActive] = useState(activeThemeConfigName);
|
|
271
|
+
useLayoutEffect(function() {
|
|
272
|
+
if (requested !== activeThemeConfigName) {
|
|
273
|
+
activateThemeConfig(themeConfigsByName[requested]);
|
|
274
|
+
activeThemeConfigName = requested;
|
|
275
|
+
}
|
|
276
|
+
setActive(requested);
|
|
277
|
+
}, [requested]);
|
|
278
|
+
return active;
|
|
279
|
+
}
|
|
280
|
+
var enumKeys = Object.keys(knobOptions);
|
|
281
|
+
var generatedGlobalTypes = {};
|
|
282
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
283
|
+
try {
|
|
284
|
+
for (var _iterator = enumKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
285
|
+
var key = _step.value;
|
|
286
|
+
generatedGlobalTypes[key] = createControl(key);
|
|
287
|
+
}
|
|
288
|
+
} catch (err) {
|
|
289
|
+
_didIteratorError = true;
|
|
290
|
+
_iteratorError = err;
|
|
291
|
+
} finally {
|
|
292
|
+
try {
|
|
293
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
294
|
+
_iterator.return();
|
|
295
|
+
}
|
|
296
|
+
} finally {
|
|
297
|
+
if (_didIteratorError) {
|
|
298
|
+
throw _iteratorError;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
for (var _i = 0, _iter = [
|
|
303
|
+
"hover",
|
|
304
|
+
"press",
|
|
305
|
+
"focus",
|
|
306
|
+
"focusVisible"
|
|
307
|
+
]; _i < _iter.length; _i++) {
|
|
308
|
+
var state = _iter[_i];
|
|
309
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
310
|
+
try {
|
|
311
|
+
for (var _iterator1 = stateKnobFields[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
312
|
+
var field = _step1.value;
|
|
313
|
+
var _knobOptions_field;
|
|
314
|
+
var stateKey = `${state}.${field}`;
|
|
315
|
+
var values = (_knobOptions_field = knobOptions[field]) !== null && _knobOptions_field !== void 0 ? _knobOptions_field : [];
|
|
316
|
+
var serialized = values.map(function(value) {
|
|
317
|
+
return value;
|
|
318
|
+
});
|
|
319
|
+
var labels = Object.fromEntries(serialized.map(function(v) {
|
|
320
|
+
return [v, v.replace("$", "")];
|
|
321
|
+
}));
|
|
322
|
+
generatedGlobalTypes[stateKey] = {
|
|
323
|
+
name: `${toTitleCase(state)} ${toTitleCase(field)}`,
|
|
324
|
+
description: `${state} override for ${field}`,
|
|
325
|
+
options: serialized,
|
|
326
|
+
control: {
|
|
327
|
+
type: "select",
|
|
328
|
+
labels
|
|
329
|
+
},
|
|
330
|
+
defaultValue: ""
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
} catch (err) {
|
|
334
|
+
_didIteratorError1 = true;
|
|
335
|
+
_iteratorError1 = err;
|
|
336
|
+
} finally {
|
|
337
|
+
try {
|
|
338
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
339
|
+
_iterator1.return();
|
|
340
|
+
}
|
|
341
|
+
} finally {
|
|
342
|
+
if (_didIteratorError1) {
|
|
343
|
+
throw _iteratorError1;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
var themeColorNames = ["", ...themeConfig.themeColors];
|
|
349
|
+
var themeSwatches = {};
|
|
350
|
+
var allThemes = themeConfig.tamagui.themes;
|
|
351
|
+
if (allThemes) {
|
|
352
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
353
|
+
try {
|
|
354
|
+
for (var _iterator2 = themeConfig.themeColors[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
355
|
+
var name = _step2.value;
|
|
356
|
+
var _allThemes_;
|
|
357
|
+
var theme = (_allThemes_ = allThemes[`light_${name}`]) !== null && _allThemes_ !== void 0 ? _allThemes_ : allThemes[name];
|
|
358
|
+
if (!theme) continue;
|
|
359
|
+
var token = theme["color-7"];
|
|
360
|
+
if (typeof token === "string") {
|
|
361
|
+
themeSwatches[name] = token;
|
|
362
|
+
} else if (token && typeof token === "object" && "val" in token) {
|
|
363
|
+
themeSwatches[name] = String(token.val);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} catch (err) {
|
|
367
|
+
_didIteratorError2 = true;
|
|
368
|
+
_iteratorError2 = err;
|
|
369
|
+
} finally {
|
|
370
|
+
try {
|
|
371
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
372
|
+
_iterator2.return();
|
|
373
|
+
}
|
|
374
|
+
} finally {
|
|
375
|
+
if (_didIteratorError2) {
|
|
376
|
+
throw _iteratorError2;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
generatedGlobalTypes.color = {
|
|
382
|
+
name: "Theme",
|
|
383
|
+
description: "Theme color palette",
|
|
384
|
+
options: themeColorNames,
|
|
385
|
+
control: {
|
|
386
|
+
type: "select",
|
|
387
|
+
labels: Object.fromEntries(themeColorNames.map(function(v) {
|
|
388
|
+
return [v, v || "(none)"];
|
|
389
|
+
}))
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
generatedGlobalTypes.scheme = {
|
|
393
|
+
name: "Scheme",
|
|
394
|
+
description: "Color scheme (light/dark/system)",
|
|
395
|
+
options: [
|
|
396
|
+
"system",
|
|
397
|
+
"light",
|
|
398
|
+
"dark"
|
|
399
|
+
],
|
|
400
|
+
control: { type: "select" }
|
|
401
|
+
};
|
|
402
|
+
generatedGlobalTypes.locale = {
|
|
403
|
+
name: "Locale",
|
|
404
|
+
description: "Controls internationalization language",
|
|
405
|
+
options: [...i18n.languages],
|
|
406
|
+
control: { type: "select" },
|
|
407
|
+
toolbar: {
|
|
408
|
+
title: "Locale",
|
|
409
|
+
items: [...i18n.languages],
|
|
410
|
+
dynamicTitle: true
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
if (switchesThemeConfig) {
|
|
414
|
+
generatedGlobalTypes.tamaguiConfig = {
|
|
415
|
+
name: "Tamagui config",
|
|
416
|
+
description: "Tamagui config the story renders under",
|
|
417
|
+
options: themeConfigNames,
|
|
418
|
+
control: { type: "select" },
|
|
419
|
+
toolbar: {
|
|
420
|
+
title: "Tamagui config",
|
|
421
|
+
icon: "paintbrush",
|
|
422
|
+
items: themeConfigNames.map(function(name2) {
|
|
423
|
+
return {
|
|
424
|
+
value: name2,
|
|
425
|
+
title: `${name2} config`
|
|
426
|
+
};
|
|
427
|
+
}),
|
|
428
|
+
dynamicTitle: true
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
var globalTypes = {
|
|
433
|
+
...generatedGlobalTypes,
|
|
434
|
+
...extraGlobalTypes
|
|
435
|
+
};
|
|
436
|
+
var initialGlobals = {
|
|
437
|
+
locale: config.get("I18N_DEFAULT_LANGUAGE", i18n.defaultLanguage),
|
|
438
|
+
color: "",
|
|
439
|
+
scheme: "system",
|
|
440
|
+
__presetNames: getPresetNames(),
|
|
441
|
+
__presetScales: Object.fromEntries(getPresetNames().map(function(name2) {
|
|
442
|
+
var _ref;
|
|
443
|
+
var _getPreset;
|
|
444
|
+
var scale = (_ref = (_getPreset = getPreset(name2)) === null || _getPreset === void 0 ? void 0 : _getPreset.scale) !== null && _ref !== void 0 ? _ref : defaultScaleInputs;
|
|
445
|
+
return [name2, {
|
|
446
|
+
control: scale.control,
|
|
447
|
+
type: scale.type
|
|
448
|
+
}];
|
|
449
|
+
})),
|
|
450
|
+
__themeColors: themeColorNames,
|
|
451
|
+
__themeSwatches: themeSwatches,
|
|
452
|
+
preset: (_themeConfig_defaultPreset = themeConfig.defaultPreset) !== null && _themeConfig_defaultPreset !== void 0 ? _themeConfig_defaultPreset : "",
|
|
453
|
+
...switchesThemeConfig && { tamaguiConfig: defaultThemeConfigName }
|
|
454
|
+
};
|
|
455
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
456
|
+
try {
|
|
457
|
+
for (var _iterator3 = enumKeys[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
458
|
+
var key1 = _step3.value;
|
|
459
|
+
if (!(key1 in initialGlobals)) {
|
|
460
|
+
initialGlobals[key1] = "";
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
} catch (err) {
|
|
464
|
+
_didIteratorError3 = true;
|
|
465
|
+
_iteratorError3 = err;
|
|
466
|
+
} finally {
|
|
467
|
+
try {
|
|
468
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
469
|
+
_iterator3.return();
|
|
470
|
+
}
|
|
471
|
+
} finally {
|
|
472
|
+
if (_didIteratorError3) {
|
|
473
|
+
throw _iteratorError3;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
for (var _i1 = 0, _iter1 = [
|
|
478
|
+
"hover",
|
|
479
|
+
"press",
|
|
480
|
+
"focus",
|
|
481
|
+
"focusVisible"
|
|
482
|
+
]; _i1 < _iter1.length; _i1++) {
|
|
483
|
+
var state1 = _iter1[_i1];
|
|
484
|
+
var _iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = void 0;
|
|
485
|
+
try {
|
|
486
|
+
for (var _iterator4 = stateKnobFields[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
487
|
+
var field1 = _step4.value;
|
|
488
|
+
initialGlobals[`${state1}.${field1}`] = "";
|
|
489
|
+
}
|
|
490
|
+
} catch (err) {
|
|
491
|
+
_didIteratorError4 = true;
|
|
492
|
+
_iteratorError4 = err;
|
|
493
|
+
} finally {
|
|
494
|
+
try {
|
|
495
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
496
|
+
_iterator4.return();
|
|
497
|
+
}
|
|
498
|
+
} finally {
|
|
499
|
+
if (_didIteratorError4) {
|
|
500
|
+
throw _iteratorError4;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
globalThis.__MPO_THEME_AXES__ = {
|
|
506
|
+
schemes: ["light", "dark"],
|
|
507
|
+
themeColors: themeColorNames,
|
|
508
|
+
presets: ["", ...getPresetNames()],
|
|
509
|
+
presetThemes: Object.fromEntries(getPresetNames().flatMap(function(name2) {
|
|
510
|
+
var _getPreset;
|
|
511
|
+
var theme2 = (_getPreset = getPreset(name2)) === null || _getPreset === void 0 ? void 0 : _getPreset.theme;
|
|
512
|
+
return theme2 ? [[name2, theme2]] : [];
|
|
513
|
+
}))
|
|
514
|
+
};
|
|
515
|
+
var defaultParameters = {
|
|
516
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
517
|
+
layout: "padded",
|
|
518
|
+
viewMode: "story",
|
|
519
|
+
controls: {
|
|
520
|
+
expanded: true,
|
|
521
|
+
hideNoControlsWarning: true,
|
|
522
|
+
matchers: {
|
|
523
|
+
color: /(background|color)$/i,
|
|
524
|
+
date: /Date$/
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
backgrounds: { disable: true },
|
|
528
|
+
previewTabs: { "storybook/docs/panel": { hidden: true } },
|
|
529
|
+
a11y: { test: false },
|
|
530
|
+
docs: { codePanel: true },
|
|
531
|
+
darkMode: { stylePreview: true }
|
|
532
|
+
};
|
|
533
|
+
function FrameworkDecoratorInner(param) {
|
|
534
|
+
var { Story, context } = param;
|
|
535
|
+
var _context_parameters;
|
|
536
|
+
var [knobs, setKnobs] = useTheme();
|
|
537
|
+
var schemeGlobal = context.globals.scheme || "system";
|
|
538
|
+
var [resolvedScheme, setResolvedScheme] = useState(function() {
|
|
539
|
+
if (schemeGlobal === "light" || schemeGlobal === "dark") return schemeGlobal;
|
|
540
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
541
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
542
|
+
}
|
|
543
|
+
return "light";
|
|
544
|
+
});
|
|
545
|
+
useEffect(function() {
|
|
546
|
+
if (schemeGlobal === "light" || schemeGlobal === "dark") {
|
|
547
|
+
setResolvedScheme(schemeGlobal);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
551
|
+
setResolvedScheme("light");
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
var mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
555
|
+
var handler = function handler2() {
|
|
556
|
+
return setResolvedScheme(mq.matches ? "dark" : "light");
|
|
557
|
+
};
|
|
558
|
+
handler();
|
|
559
|
+
mq.addEventListener("change", handler);
|
|
560
|
+
return function() {
|
|
561
|
+
return mq.removeEventListener("change", handler);
|
|
562
|
+
};
|
|
563
|
+
}, [schemeGlobal]);
|
|
564
|
+
useLayoutEffect(function() {
|
|
565
|
+
var setting = schemeGlobal === "light" || schemeGlobal === "dark" ? schemeGlobal : "system";
|
|
566
|
+
setUserScheme === null || setUserScheme === void 0 ? void 0 : setUserScheme(setting);
|
|
567
|
+
setStoredScheme(setting);
|
|
568
|
+
}, [schemeGlobal]);
|
|
569
|
+
var colorGlobal = context.globals.color || "";
|
|
570
|
+
var requestedThemeConfig = context.globals.tamaguiConfig;
|
|
571
|
+
var requestedThemeConfigName = requestedThemeConfig && themeConfigNames.includes(requestedThemeConfig) ? requestedThemeConfig : defaultThemeConfigName;
|
|
572
|
+
var themeConfigName = useActiveThemeConfigName(requestedThemeConfigName);
|
|
573
|
+
var storyThemeParams = (_context_parameters = context.parameters) === null || _context_parameters === void 0 ? void 0 : _context_parameters.theme;
|
|
574
|
+
var activePresetName = context.globals.preset || void 0;
|
|
575
|
+
var activePreset = activePresetName ? getPreset(activePresetName) : void 0;
|
|
576
|
+
var presetTheme = colorGlobal || (activePreset === null || activePreset === void 0 ? void 0 : activePreset.theme) || defaultPreset.theme;
|
|
577
|
+
var scaleId = useActiveScale(themeConfigsByName[requestedThemeConfigName], activePresetName);
|
|
578
|
+
var knobUpdate = useMemo(function() {
|
|
579
|
+
var _normalizeAnimationKnob;
|
|
580
|
+
var result = {};
|
|
581
|
+
var stateKeys = /* @__PURE__ */ new Set([
|
|
582
|
+
"hover",
|
|
583
|
+
"press",
|
|
584
|
+
"focus",
|
|
585
|
+
"focusVisible"
|
|
586
|
+
]);
|
|
587
|
+
var _iteratorNormalCompletion5 = true, _didIteratorError5 = false, _iteratorError5 = void 0;
|
|
588
|
+
try {
|
|
589
|
+
for (var _iterator5 = Object.keys(knobs)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
590
|
+
var key2 = _step5.value;
|
|
591
|
+
if (stateKeys.has(key2)) continue;
|
|
592
|
+
if (storyThemeParams && key2 in storyThemeParams) {
|
|
593
|
+
result[key2] = storyThemeParams[key2];
|
|
594
|
+
} else if (key2 in context.globals && context.globals[key2] !== void 0 && context.globals[key2] !== "") {
|
|
595
|
+
result[key2] = parseValue(context.globals[key2]);
|
|
596
|
+
} else if (activePreset && key2 in activePreset.knobs) {
|
|
597
|
+
result[key2] = activePreset.knobs[key2];
|
|
598
|
+
} else {
|
|
599
|
+
result[key2] = defaultKnobs[key2];
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
} catch (err) {
|
|
603
|
+
_didIteratorError5 = true;
|
|
604
|
+
_iteratorError5 = err;
|
|
605
|
+
} finally {
|
|
606
|
+
try {
|
|
607
|
+
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
608
|
+
_iterator5.return();
|
|
609
|
+
}
|
|
610
|
+
} finally {
|
|
611
|
+
if (_didIteratorError5) {
|
|
612
|
+
throw _iteratorError5;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
result.animation = (_normalizeAnimationKnob = normalizeAnimationKnob(result.animation)) !== null && _normalizeAnimationKnob !== void 0 ? _normalizeAnimationKnob : defaultKnobs.animation;
|
|
617
|
+
var _iteratorNormalCompletion12 = true, _didIteratorError12 = false, _iteratorError12 = void 0;
|
|
618
|
+
try {
|
|
619
|
+
for (var _iterator12 = stateKeys[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
620
|
+
var state2 = _step12.value;
|
|
621
|
+
var stateObj = {};
|
|
622
|
+
var hasValues = false;
|
|
623
|
+
var _iteratorNormalCompletion22 = true, _didIteratorError22 = false, _iteratorError22 = void 0;
|
|
624
|
+
try {
|
|
625
|
+
for (var _iterator22 = stateKnobFields[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
|
|
626
|
+
var field2 = _step22.value;
|
|
627
|
+
var globalKey = `${state2}.${field2}`;
|
|
628
|
+
var val = context.globals[globalKey];
|
|
629
|
+
if (val) {
|
|
630
|
+
stateObj[field2] = val;
|
|
631
|
+
hasValues = true;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
} catch (err) {
|
|
635
|
+
_didIteratorError22 = true;
|
|
636
|
+
_iteratorError22 = err;
|
|
637
|
+
} finally {
|
|
638
|
+
try {
|
|
639
|
+
if (!_iteratorNormalCompletion22 && _iterator22.return != null) {
|
|
640
|
+
_iterator22.return();
|
|
641
|
+
}
|
|
642
|
+
} finally {
|
|
643
|
+
if (_didIteratorError22) {
|
|
644
|
+
throw _iteratorError22;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (hasValues) {
|
|
649
|
+
result[state2] = stateObj;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
} catch (err) {
|
|
653
|
+
_didIteratorError12 = true;
|
|
654
|
+
_iteratorError12 = err;
|
|
655
|
+
} finally {
|
|
656
|
+
try {
|
|
657
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
658
|
+
_iterator12.return();
|
|
659
|
+
}
|
|
660
|
+
} finally {
|
|
661
|
+
if (_didIteratorError12) {
|
|
662
|
+
throw _iteratorError12;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return result;
|
|
667
|
+
}, [
|
|
668
|
+
knobs,
|
|
669
|
+
context.globals,
|
|
670
|
+
storyThemeParams,
|
|
671
|
+
activePreset
|
|
672
|
+
]);
|
|
673
|
+
useEffect(function() {
|
|
674
|
+
setKnobs(knobUpdate);
|
|
675
|
+
}, [knobUpdate, setKnobs]);
|
|
676
|
+
useEffect(function() {
|
|
677
|
+
i18n.instance.changeLanguage(context.globals.locale);
|
|
678
|
+
}, [context.globals.locale]);
|
|
679
|
+
var presetCtxValue = useMemo(function() {
|
|
680
|
+
return {
|
|
681
|
+
preset: {
|
|
682
|
+
...applyColorTheme(activePreset !== null && activePreset !== void 0 ? activePreset : defaultPreset, colorGlobal),
|
|
683
|
+
theme: presetTheme,
|
|
684
|
+
knobs: {
|
|
685
|
+
...defaultKnobs,
|
|
686
|
+
...knobUpdate
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
overrides: void 0,
|
|
690
|
+
presetName: activePresetName,
|
|
691
|
+
scaleId,
|
|
692
|
+
color: colorGlobal || void 0
|
|
693
|
+
};
|
|
694
|
+
}, [
|
|
695
|
+
knobUpdate,
|
|
696
|
+
presetTheme,
|
|
697
|
+
activePreset,
|
|
698
|
+
colorGlobal,
|
|
699
|
+
activePresetName,
|
|
700
|
+
scaleId
|
|
701
|
+
]);
|
|
702
|
+
var animationValue = presetCtxValue.preset.knobs.animation;
|
|
703
|
+
useEffect(function() {
|
|
704
|
+
if (typeof document === "undefined") return;
|
|
705
|
+
var ms = `${animationValue === "none" ? 0 : animationDurations[animationValue]}ms`;
|
|
706
|
+
document.documentElement.style.setProperty("--mp-transition", ms);
|
|
707
|
+
}, [animationValue]);
|
|
708
|
+
var storyContent = /* @__PURE__ */ jsx(CanvasBackground, { children: /* @__PURE__ */ jsx(Story, { ...context }) });
|
|
709
|
+
var oppositeScheme = resolvedScheme === "dark" ? "light" : "dark";
|
|
710
|
+
return /* @__PURE__ */ jsx(PresetContext.Provider, {
|
|
711
|
+
value: presetCtxValue,
|
|
712
|
+
children: /* @__PURE__ */ jsxs(AppProvider, {
|
|
713
|
+
themeConfig: themeConfigsByName[themeConfigName],
|
|
714
|
+
systemTheme: resolvedScheme,
|
|
715
|
+
children: [
|
|
716
|
+
/* @__PURE__ */ jsx(AnimationNamesEmitter, {}),
|
|
717
|
+
/* @__PURE__ */ jsx(FrappeDebugEmitter, {}),
|
|
718
|
+
/* @__PURE__ */ jsx(BaseThemeColorEmitter, {}),
|
|
719
|
+
/* @__PURE__ */ jsxs(Theme, {
|
|
720
|
+
name: presetTheme || resolvedScheme,
|
|
721
|
+
children: [
|
|
722
|
+
/* @__PURE__ */ jsx(ThemeColorEmitter, {}),
|
|
723
|
+
/* @__PURE__ */ jsx(ColorChannelEmitter, {
|
|
724
|
+
event: accentColorsChannelEvent,
|
|
725
|
+
prefix: "accent"
|
|
726
|
+
}),
|
|
727
|
+
storyContent
|
|
728
|
+
]
|
|
729
|
+
}),
|
|
730
|
+
/* @__PURE__ */ jsxs(Theme, {
|
|
731
|
+
name: oppositeScheme,
|
|
732
|
+
children: [/* @__PURE__ */ jsx(OppositeThemeColorEmitter, {}), presetTheme ? /* @__PURE__ */ jsxs(Theme, {
|
|
733
|
+
name: presetTheme,
|
|
734
|
+
children: [/* @__PURE__ */ jsx(ColorChannelEmitter, { event: baseOppositeChannelEvent }), /* @__PURE__ */ jsx(ColorChannelEmitter, {
|
|
735
|
+
event: accentOppositeChannelEvent,
|
|
736
|
+
prefix: "accent"
|
|
737
|
+
})]
|
|
738
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ColorChannelEmitter, { event: baseOppositeChannelEvent }), /* @__PURE__ */ jsx(ColorChannelEmitter, {
|
|
739
|
+
event: accentOppositeChannelEvent,
|
|
740
|
+
prefix: "accent"
|
|
741
|
+
})] })]
|
|
742
|
+
})
|
|
743
|
+
]
|
|
744
|
+
}, `${themeConfigName}:${scaleId}`)
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
var frameworkDecorator = function frameworkDecorator2(Story, context) {
|
|
748
|
+
return /* @__PURE__ */ jsx(CookiesProvider, { children: /* @__PURE__ */ jsx(FrameworkDecoratorInner, {
|
|
749
|
+
Story,
|
|
750
|
+
context
|
|
751
|
+
}) });
|
|
752
|
+
};
|
|
753
|
+
return {
|
|
754
|
+
globalTypes,
|
|
755
|
+
initialGlobals,
|
|
756
|
+
parameters: {
|
|
757
|
+
...defaultParameters,
|
|
758
|
+
...extraParameters
|
|
759
|
+
},
|
|
760
|
+
decorators: [frameworkDecorator, ...extraDecorators]
|
|
761
|
+
};
|
|
834
762
|
}
|
|
763
|
+
|
|
835
764
|
export { accentColorsChannelEvent, accentOppositeChannelEvent, animationNamesChannelEvent, baseOppositeChannelEvent, baseThemeColorsChannelEvent, createPreview, frappeDebugChannelEvent, themeColorsChannelEvent, themeColorsOppositeChannelEvent };
|
|
836
765
|
//# sourceMappingURL=CreatePreview.native.js.map
|