@multiplatform.one/storybook 7.34.3 → 7.35.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.
@@ -65,11 +65,6 @@ const knobOptions = {
65
65
  cornerSmoothing: Object.values(import_theme.CornerSmoothing),
66
66
  borderWidth: Object.values(import_theme.BorderWidth),
67
67
  elevation: Object.values(import_theme.Elevation),
68
- space: Object.values(import_theme.Space),
69
- size: Object.values(import_theme.Size),
70
- // LC-76 TWO-AXES: density is its own dial (compact steps space only), so
71
- // the size × density matrix is sweepable from the toolbar / URL globals.
72
- density: Object.values(import_theme.Density),
73
68
  textAccent: Object.values(import_theme.TextAccent),
74
69
  headingFont: Object.values(import_theme.HeadingFont),
75
70
  bodyFont: Object.values(import_theme.BodyFont),
@@ -77,7 +72,7 @@ const knobOptions = {
77
72
  // D-11 hero-H1 dial: the page-title step is sweepable so the VERIFY probes
78
73
  // (and humans) can flip moderate/display from the toolbar or URL globals.
79
74
  pageTitleScale: Object.values(import_theme.PageTitleScale),
80
- animation: ["none", ...import_theme.animationNames],
75
+ animation: ["none", ...import_theme.motionStops],
81
76
  // LC-40 DISABLED-VISIBLE: the disabled-treatment dial is sweepable so the
82
77
  // VERIFY probes (and humans) can flip keepLabel/dimWhole from the toolbar
83
78
  // or via URL globals.
@@ -85,7 +80,7 @@ const knobOptions = {
85
80
  // K4: the one house knob a table sweep has to flip (MPO-132).
86
81
  tableZebra: Object.values(import_theme.TableZebra)
87
82
  };
88
- const stateKnobFields = ["fillStyle", "borderRadius", "borderWidth", "elevation", "space", "size", "textAccent", "headingFont", "bodyFont", "fontWeight"];
83
+ const stateKnobFields = ["fillStyle", "borderRadius", "borderWidth", "elevation", "textAccent", "headingFont", "bodyFont", "fontWeight"];
89
84
  function parseValue(value) {
90
85
  if (typeof value !== "string") return value;
91
86
  try {
@@ -150,7 +145,7 @@ function AnimationNamesEmitter() {
150
145
  (0, import_react.useEffect)(() => {
151
146
  if (emittedRef.current) return;
152
147
  emittedRef.current = true;
153
- getChannelEmit()?.(animationNamesChannelEvent, import_theme.animationNames);
148
+ getChannelEmit()?.(animationNamesChannelEvent, [...import_theme.motionStops]);
154
149
  }, []);
155
150
  return null;
156
151
  }
@@ -416,6 +411,15 @@ function createPreview(options) {
416
411
  // Publish registered preset names so the manager-side ThemePanel can
417
412
  // render a preset selector without importing the theme package.
418
413
  __presetNames: (0, import_theme.getPresetNames)(),
414
+ // Each preset's token scale (control / type px), so the picker can say
415
+ // what a switch does to sizes and spacing.
416
+ __presetScales: Object.fromEntries((0, import_theme.getPresetNames)().map(name => {
417
+ const scale = (0, import_theme.getPreset)(name)?.scale ?? import_theme.defaultScaleInputs;
418
+ return [name, {
419
+ control: scale.control,
420
+ type: scale.type
421
+ }];
422
+ })),
419
423
  // Publish available theme color names so the ThemePanel can show only
420
424
  // colors that actually have registered Tamagui sub-themes.
421
425
  __themeColors: themeColorNames,
@@ -438,7 +442,11 @@ function createPreview(options) {
438
442
  globalThis.__MPO_THEME_AXES__ = {
439
443
  schemes: ["light", "dark"],
440
444
  themeColors: themeColorNames,
441
- presets: ["", ...(0, import_theme.getPresetNames)()]
445
+ presets: ["", ...(0, import_theme.getPresetNames)()],
446
+ presetThemes: Object.fromEntries((0, import_theme.getPresetNames)().flatMap(name => {
447
+ const theme = (0, import_theme.getPreset)(name)?.theme;
448
+ return theme ? [[name, theme]] : [];
449
+ }))
442
450
  };
443
451
  const defaultParameters = {
444
452
  actions: {
@@ -508,10 +516,13 @@ function createPreview(options) {
508
516
  }, [schemeGlobal]);
509
517
  const colorGlobal = context.globals.color || "";
510
518
  const requestedThemeConfig = context.globals.tamaguiConfig;
511
- const themeConfigName = useActiveThemeConfigName(requestedThemeConfig && themeConfigNames.includes(requestedThemeConfig) ? requestedThemeConfig : defaultThemeConfigName);
519
+ const requestedThemeConfigName = requestedThemeConfig && themeConfigNames.includes(requestedThemeConfig) ? requestedThemeConfig : defaultThemeConfigName;
520
+ const themeConfigName = useActiveThemeConfigName(requestedThemeConfigName);
512
521
  const storyThemeParams = context.parameters?.theme;
513
- const activePresetName = context.globals.preset;
522
+ const activePresetName = context.globals.preset || void 0;
514
523
  const activePreset = activePresetName ? (0, import_theme.getPreset)(activePresetName) : void 0;
524
+ const presetTheme = colorGlobal || activePreset?.theme || import_theme.defaultPreset.theme;
525
+ const scaleId = (0, import_theme.useActiveScale)(themeConfigsByName[requestedThemeConfigName], activePresetName);
515
526
  const knobUpdate = (0, import_react.useMemo)(() => {
516
527
  const result = {};
517
528
  const stateKeys = /* @__PURE__ */new Set(["hover", "press", "focus", "focusVisible"]);
@@ -527,6 +538,7 @@ function createPreview(options) {
527
538
  result[key] = import_theme.defaultKnobs[key];
528
539
  }
529
540
  }
541
+ result.animation = (0, import_theme.normalizeAnimationKnob)(result.animation) ?? import_theme.defaultKnobs.animation;
530
542
  for (const state of stateKeys) {
531
543
  const stateObj = {};
532
544
  let hasValues = false;
@@ -553,17 +565,19 @@ function createPreview(options) {
553
565
  const presetCtxValue = (0, import_react.useMemo)(() => ({
554
566
  preset: {
555
567
  ...import_theme.defaultPreset,
556
- theme: colorGlobal || import_theme.defaultPreset.theme,
568
+ theme: presetTheme,
557
569
  knobs: {
558
570
  ...import_theme.defaultKnobs,
559
571
  ...knobUpdate
560
572
  }
561
573
  },
562
- overrides: void 0
563
- }), [knobUpdate, colorGlobal]);
574
+ overrides: void 0,
575
+ presetName: activePresetName,
576
+ scaleId
577
+ }), [knobUpdate, presetTheme, activePresetName, scaleId]);
564
578
  const animationValue = presetCtxValue.preset.knobs.animation;
565
579
  (0, import_react.useEffect)(() => {
566
- const ms = animationValue === "none" ? "0ms" : animationValue === "quick" ? "100ms" : animationValue === "medium" ? "200ms" : animationValue === "slow" || animationValue === "lazy" ? "350ms" : animationValue === "bouncy" ? "300ms" : "200ms";
580
+ const ms = `${animationValue === "none" ? 0 : import_theme.animationDurations[animationValue]}ms`;
567
581
  document.documentElement.style.setProperty("--mp-transition", ms);
568
582
  }, [animationValue]);
569
583
  const storyContent = /* @__PURE__ */(0, import_jsx_runtime.jsx)(CanvasBackground, {
@@ -578,15 +592,15 @@ function createPreview(options) {
578
592
  themeConfig: themeConfigsByName[themeConfigName],
579
593
  systemTheme: resolvedScheme,
580
594
  children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimationNamesEmitter, {}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(FrappeDebugEmitter, {}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(BaseThemeColorEmitter, {}), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
581
- name: colorGlobal || resolvedScheme,
595
+ name: presetTheme || resolvedScheme,
582
596
  children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(ThemeColorEmitter, {}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
583
597
  event: accentColorsChannelEvent,
584
598
  prefix: "accent"
585
599
  }), storyContent]
586
600
  }), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
587
601
  name: oppositeScheme,
588
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(OppositeThemeColorEmitter, {}), colorGlobal ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
589
- name: colorGlobal,
602
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(OppositeThemeColorEmitter, {}), presetTheme ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
603
+ name: presetTheme,
590
604
  children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
591
605
  event: baseOppositeChannelEvent
592
606
  }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
@@ -602,7 +616,7 @@ function createPreview(options) {
602
616
  })]
603
617
  })]
604
618
  })]
605
- }, themeConfigName)
619
+ }, `${themeConfigName}:${scaleId}`)
606
620
  });
607
621
  }
608
622
  const frameworkDecorator = (Story, context) => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_cookie.CookiesProvider, {
@@ -72,11 +72,6 @@ var knobOptions = {
72
72
  cornerSmoothing: Object.values(import_theme.CornerSmoothing),
73
73
  borderWidth: Object.values(import_theme.BorderWidth),
74
74
  elevation: Object.values(import_theme.Elevation),
75
- space: Object.values(import_theme.Space),
76
- size: Object.values(import_theme.Size),
77
- // LC-76 TWO-AXES: density is its own dial (compact steps space only), so
78
- // the size × density matrix is sweepable from the toolbar / URL globals.
79
- density: Object.values(import_theme.Density),
80
75
  textAccent: Object.values(import_theme.TextAccent),
81
76
  headingFont: Object.values(import_theme.HeadingFont),
82
77
  bodyFont: Object.values(import_theme.BodyFont),
@@ -84,7 +79,7 @@ var knobOptions = {
84
79
  // D-11 hero-H1 dial: the page-title step is sweepable so the VERIFY probes
85
80
  // (and humans) can flip moderate/display from the toolbar or URL globals.
86
81
  pageTitleScale: Object.values(import_theme.PageTitleScale),
87
- animation: ["none", ...import_theme.animationNames],
82
+ animation: ["none", ...import_theme.motionStops],
88
83
  // LC-40 DISABLED-VISIBLE: the disabled-treatment dial is sweepable so the
89
84
  // VERIFY probes (and humans) can flip keepLabel/dimWhole from the toolbar
90
85
  // or via URL globals.
@@ -92,7 +87,7 @@ var knobOptions = {
92
87
  // K4: the one house knob a table sweep has to flip (MPO-132).
93
88
  tableZebra: Object.values(import_theme.TableZebra)
94
89
  };
95
- var stateKnobFields = ["fillStyle", "borderRadius", "borderWidth", "elevation", "space", "size", "textAccent", "headingFont", "bodyFont", "fontWeight"];
90
+ var stateKnobFields = ["fillStyle", "borderRadius", "borderWidth", "elevation", "textAccent", "headingFont", "bodyFont", "fontWeight"];
96
91
  function parseValue(value) {
97
92
  if (typeof value !== "string") return value;
98
93
  try {
@@ -175,7 +170,7 @@ function AnimationNamesEmitter() {
175
170
  var _getChannelEmit;
176
171
  if (emittedRef.current) return;
177
172
  emittedRef.current = true;
178
- (_getChannelEmit = getChannelEmit()) === null || _getChannelEmit === void 0 ? void 0 : _getChannelEmit(animationNamesChannelEvent, import_theme.animationNames);
173
+ (_getChannelEmit = getChannelEmit()) === null || _getChannelEmit === void 0 ? void 0 : _getChannelEmit(animationNamesChannelEvent, [...import_theme.motionStops]);
179
174
  }, []);
180
175
  return null;
181
176
  }
@@ -536,6 +531,17 @@ function createPreview(options) {
536
531
  // Publish registered preset names so the manager-side ThemePanel can
537
532
  // render a preset selector without importing the theme package.
538
533
  __presetNames: (0, import_theme.getPresetNames)(),
534
+ // Each preset's token scale (control / type px), so the picker can say
535
+ // what a switch does to sizes and spacing.
536
+ __presetScales: Object.fromEntries((0, import_theme.getPresetNames)().map(function (name2) {
537
+ var _ref;
538
+ var _getPreset;
539
+ var scale = (_ref = (_getPreset = (0, import_theme.getPreset)(name2)) === null || _getPreset === void 0 ? void 0 : _getPreset.scale) !== null && _ref !== void 0 ? _ref : import_theme.defaultScaleInputs;
540
+ return [name2, {
541
+ control: scale.control,
542
+ type: scale.type
543
+ }];
544
+ })),
539
545
  // Publish available theme color names so the ThemePanel can show only
540
546
  // colors that actually have registered Tamagui sub-themes.
541
547
  __themeColors: themeColorNames,
@@ -597,7 +603,12 @@ function createPreview(options) {
597
603
  globalThis.__MPO_THEME_AXES__ = {
598
604
  schemes: ["light", "dark"],
599
605
  themeColors: themeColorNames,
600
- presets: ["", ...(0, import_theme.getPresetNames)()]
606
+ presets: ["", ...(0, import_theme.getPresetNames)()],
607
+ presetThemes: Object.fromEntries((0, import_theme.getPresetNames)().flatMap(function (name2) {
608
+ var _getPreset;
609
+ var theme2 = (_getPreset = (0, import_theme.getPreset)(name2)) === null || _getPreset === void 0 ? void 0 : _getPreset.theme;
610
+ return theme2 ? [[name2, theme2]] : [];
611
+ }))
601
612
  };
602
613
  var defaultParameters = {
603
614
  actions: {
@@ -673,11 +684,15 @@ function createPreview(options) {
673
684
  }, [schemeGlobal]);
674
685
  var colorGlobal = context.globals.color || "";
675
686
  var requestedThemeConfig = context.globals.tamaguiConfig;
676
- var themeConfigName = useActiveThemeConfigName(requestedThemeConfig && themeConfigNames.includes(requestedThemeConfig) ? requestedThemeConfig : defaultThemeConfigName);
687
+ var requestedThemeConfigName = requestedThemeConfig && themeConfigNames.includes(requestedThemeConfig) ? requestedThemeConfig : defaultThemeConfigName;
688
+ var themeConfigName = useActiveThemeConfigName(requestedThemeConfigName);
677
689
  var storyThemeParams = (_context_parameters = context.parameters) === null || _context_parameters === void 0 ? void 0 : _context_parameters.theme;
678
- var activePresetName = context.globals.preset;
690
+ var activePresetName = context.globals.preset || void 0;
679
691
  var activePreset = activePresetName ? (0, import_theme.getPreset)(activePresetName) : void 0;
692
+ var presetTheme = colorGlobal || (activePreset === null || activePreset === void 0 ? void 0 : activePreset.theme) || import_theme.defaultPreset.theme;
693
+ var scaleId = (0, import_theme.useActiveScale)(themeConfigsByName[requestedThemeConfigName], activePresetName);
680
694
  var knobUpdate = (0, import_react.useMemo)(function () {
695
+ var _normalizeAnimationKnob;
681
696
  var result = {};
682
697
  var stateKeys = /* @__PURE__ */new Set(["hover", "press", "focus", "focusVisible"]);
683
698
  var _iteratorNormalCompletion5 = true,
@@ -711,6 +726,7 @@ function createPreview(options) {
711
726
  }
712
727
  }
713
728
  }
729
+ result.animation = (_normalizeAnimationKnob = (0, import_theme.normalizeAnimationKnob)(result.animation)) !== null && _normalizeAnimationKnob !== void 0 ? _normalizeAnimationKnob : import_theme.defaultKnobs.animation;
714
730
  var _iteratorNormalCompletion12 = true,
715
731
  _didIteratorError12 = false,
716
732
  _iteratorError12 = void 0;
@@ -776,18 +792,20 @@ function createPreview(options) {
776
792
  return {
777
793
  preset: {
778
794
  ...import_theme.defaultPreset,
779
- theme: colorGlobal || import_theme.defaultPreset.theme,
795
+ theme: presetTheme,
780
796
  knobs: {
781
797
  ...import_theme.defaultKnobs,
782
798
  ...knobUpdate
783
799
  }
784
800
  },
785
- overrides: void 0
801
+ overrides: void 0,
802
+ presetName: activePresetName,
803
+ scaleId
786
804
  };
787
- }, [knobUpdate, colorGlobal]);
805
+ }, [knobUpdate, presetTheme, activePresetName, scaleId]);
788
806
  var animationValue = presetCtxValue.preset.knobs.animation;
789
807
  (0, import_react.useEffect)(function () {
790
- var ms = animationValue === "none" ? "0ms" : animationValue === "quick" ? "100ms" : animationValue === "medium" ? "200ms" : animationValue === "slow" || animationValue === "lazy" ? "350ms" : animationValue === "bouncy" ? "300ms" : "200ms";
808
+ var ms = `${animationValue === "none" ? 0 : import_theme.animationDurations[animationValue]}ms`;
791
809
  document.documentElement.style.setProperty("--mp-transition", ms);
792
810
  }, [animationValue]);
793
811
  var storyContent = /* @__PURE__ */(0, import_jsx_runtime.jsx)(CanvasBackground, {
@@ -808,11 +826,11 @@ function createPreview(options) {
808
826
  /* @__PURE__ */
809
827
  (0, import_jsx_runtime.jsx)(AnimationNamesEmitter, {}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(FrappeDebugEmitter, {}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(BaseThemeColorEmitter, {}),
810
828
  /* Always wrap in Theme so the host node exists on the default
811
- colour cell too. An empty colour global keeps the scheme
829
+ colour cell too. An empty preset theme keeps the scheme
812
830
  theme; a named colour is the Tamagui subtheme. */
813
831
  /* @__PURE__ */
814
832
  (0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
815
- name: colorGlobal || resolvedScheme,
833
+ name: presetTheme || resolvedScheme,
816
834
  children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(ThemeColorEmitter, {}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
817
835
  event: accentColorsChannelEvent,
818
836
  prefix: "accent"
@@ -820,8 +838,8 @@ function createPreview(options) {
820
838
  }), /* Opposite scheme emitters */
821
839
  /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
822
840
  name: oppositeScheme,
823
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(OppositeThemeColorEmitter, {}), colorGlobal ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
824
- name: colorGlobal,
841
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(OppositeThemeColorEmitter, {}), presetTheme ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.Theme, {
842
+ name: presetTheme,
825
843
  children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
826
844
  event: baseOppositeChannelEvent
827
845
  }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(ColorChannelEmitter, {
@@ -837,7 +855,7 @@ function createPreview(options) {
837
855
  })]
838
856
  })]
839
857
  })]
840
- }, themeConfigName)
858
+ }, `${themeConfigName}:${scaleId}`)
841
859
  });
842
860
  }
843
861
  var frameworkDecorator = function frameworkDecorator2(Story, context) {