@vitus-labs/rocketstories 2.6.0 → 2.6.2
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/lib/index.js +68 -86
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -476,30 +476,28 @@ var text_default = {
|
|
|
476
476
|
* and component-specific default controls.
|
|
477
477
|
*/
|
|
478
478
|
/** Normalizes user-supplied control shorthand (string or object) into full ControlConfiguration objects. */
|
|
479
|
-
const createControls = (props) =>
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
[key]
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return acc;
|
|
489
|
-
}, {});
|
|
479
|
+
const createControls = (props) => {
|
|
480
|
+
const result = {};
|
|
481
|
+
for (const key in props) {
|
|
482
|
+
const value = props[key];
|
|
483
|
+
if (typeof value === "string") result[key] = { type: value };
|
|
484
|
+
else if (typeof value === "object" && value !== null) result[key] = value;
|
|
485
|
+
}
|
|
486
|
+
return result;
|
|
487
|
+
};
|
|
490
488
|
/** Converts rocketstyle dimension metadata into select/multi-select Storybook controls. */
|
|
491
|
-
const convertDimensionsToControls = ({ dimensions, multiKeys }) =>
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
}
|
|
489
|
+
const convertDimensionsToControls = ({ dimensions, multiKeys }) => {
|
|
490
|
+
const result = {};
|
|
491
|
+
for (const key in dimensions) {
|
|
492
|
+
const value = dimensions[key];
|
|
493
|
+
result[key] = {
|
|
494
|
+
type: multiKeys[key] ? "multi-select" : "select",
|
|
495
|
+
options: Object.keys(value),
|
|
496
|
+
group: "Dimensions [Rocketstyle (Vitus-Labs)]"
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
return result;
|
|
500
|
+
};
|
|
503
501
|
/** Returns pre-defined controls based on the component's Vitus Labs type (Element, List, Text, Overlay). */
|
|
504
502
|
const getDefaultVitusLabsControls = (component) => {
|
|
505
503
|
const { IS_ROCKETSTYLE, VITUS_LABS__COMPONENT } = component;
|
|
@@ -531,18 +529,13 @@ const makeStorybookControls = (obj, props) => Object.entries(obj).reduce((acc, [
|
|
|
531
529
|
};
|
|
532
530
|
return acc;
|
|
533
531
|
}, {});
|
|
534
|
-
const disableControl = (name) => ({ [name]: { table: { disable: true } } });
|
|
535
532
|
const disableDimensionControls = (dimensions, dimensionName) => {
|
|
536
|
-
const result = dimensionName ?
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
};
|
|
543
|
-
});
|
|
544
|
-
return acc;
|
|
545
|
-
}, result);
|
|
533
|
+
const result = dimensionName ? { [dimensionName]: { table: { disable: true } } } : {};
|
|
534
|
+
for (const key in dimensions) {
|
|
535
|
+
const value = dimensions[key];
|
|
536
|
+
for (const item in value) result[item] = { table: { disable: true } };
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
546
539
|
};
|
|
547
540
|
|
|
548
541
|
//#endregion
|
|
@@ -633,42 +626,34 @@ const Wrapper = config.styled("div")`
|
|
|
633
626
|
display: flex;
|
|
634
627
|
font-size: 32px;
|
|
635
628
|
`;
|
|
636
|
-
const component$
|
|
637
|
-
component$
|
|
629
|
+
const component$1 = () => /* @__PURE__ */ jsx(Wrapper, { children: "Nothing here" });
|
|
630
|
+
component$1.displayName = "@vitus-labs/rocketstories/Empty";
|
|
638
631
|
|
|
639
632
|
//#endregion
|
|
640
633
|
//#region src/utils/code.ts
|
|
641
|
-
const parseProps = (props) =>
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
"boolean"
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
if (type && options && defaultValue) return {
|
|
662
|
-
...acc,
|
|
663
|
-
[key]: defaultValue || options
|
|
664
|
-
};
|
|
665
|
-
return {
|
|
666
|
-
...acc,
|
|
667
|
-
[key]: value
|
|
668
|
-
};
|
|
634
|
+
const parseProps = (props) => {
|
|
635
|
+
const result = {};
|
|
636
|
+
for (const key in props) {
|
|
637
|
+
const value = props[key];
|
|
638
|
+
if (value === null) continue;
|
|
639
|
+
const valueType = typeof value;
|
|
640
|
+
if (valueType === "string" || valueType === "number" || valueType === "boolean" || valueType === "bigint") {
|
|
641
|
+
result[key] = value;
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (Array.isArray(value)) {
|
|
645
|
+
result[key] = value;
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
if (valueType === "object") {
|
|
649
|
+
const type = get(value, "type");
|
|
650
|
+
const options = get(value, "options");
|
|
651
|
+
const defaultValue = get(value, "value");
|
|
652
|
+
result[key] = type && options && defaultValue ? defaultValue || options : value;
|
|
653
|
+
}
|
|
669
654
|
}
|
|
670
|
-
return
|
|
671
|
-
}
|
|
655
|
+
return result;
|
|
656
|
+
};
|
|
672
657
|
const stringifyArray = (props) => {
|
|
673
658
|
let result = "[";
|
|
674
659
|
const arrayLength = props.length;
|
|
@@ -789,7 +774,7 @@ const Provider = ({ children, ...props }) => /* @__PURE__ */ jsx(ContextProvider
|
|
|
789
774
|
* Retrieves the component from context and renders it with the given
|
|
790
775
|
* props, optionally prefixed by a level2 Heading showing the item title.
|
|
791
776
|
*/
|
|
792
|
-
const
|
|
777
|
+
const Item = ({ title, ...props }) => {
|
|
793
778
|
const { component } = useContext$1();
|
|
794
779
|
return /* @__PURE__ */ jsxs("div", { children: [title && /* @__PURE__ */ jsx(Heading_default, {
|
|
795
780
|
level2: true,
|
|
@@ -807,7 +792,7 @@ const pseudo = [
|
|
|
807
792
|
];
|
|
808
793
|
const component = ({ itemProps }) => /* @__PURE__ */ jsx(Fragment, { children: pseudo.map((item) => {
|
|
809
794
|
const pseudoProps = { [item]: true };
|
|
810
|
-
return /* @__PURE__ */ jsx(
|
|
795
|
+
return /* @__PURE__ */ jsx(Item, {
|
|
811
796
|
title: item,
|
|
812
797
|
...itemProps,
|
|
813
798
|
...pseudoProps
|
|
@@ -822,9 +807,9 @@ const component = ({ itemProps }) => /* @__PURE__ */ jsx(Fragment, { children: p
|
|
|
822
807
|
* PseudoList when pseudo-state visualization is enabled). Generates
|
|
823
808
|
* corresponding JSX code snippets and Storybook controls.
|
|
824
809
|
*/
|
|
825
|
-
const renderDimension = (dimension, { name, component: component$
|
|
826
|
-
const statics = component$
|
|
827
|
-
const defaultAttrs = component$
|
|
810
|
+
const renderDimension = (dimension, { name, component: component$2, attrs = {}, controls, storyOptions = {}, ignore = [], theme = {} }) => {
|
|
811
|
+
const statics = component$2.getStaticDimensions(theme);
|
|
812
|
+
const defaultAttrs = component$2.getDefaultAttrs(attrs, theme, "light");
|
|
828
813
|
const { dimensions, useBooleans, multiKeys } = statics;
|
|
829
814
|
const finalAttrs = {
|
|
830
815
|
...defaultAttrs,
|
|
@@ -832,11 +817,11 @@ const renderDimension = (dimension, { name, component: component$3, attrs = {},
|
|
|
832
817
|
};
|
|
833
818
|
const currentDimension = dimensions[dimension];
|
|
834
819
|
const isMultiKey = !!multiKeys[dimension];
|
|
835
|
-
if (isEmpty(currentDimension)) return component$
|
|
820
|
+
if (isEmpty(currentDimension)) return component$1;
|
|
836
821
|
const createdControls = createControls(controls);
|
|
837
822
|
const dimensionControls = convertDimensionsToControls(statics);
|
|
838
823
|
const storybookControls = makeStorybookControls({
|
|
839
|
-
...getDefaultVitusLabsControls(component$
|
|
824
|
+
...getDefaultVitusLabsControls(component$2),
|
|
840
825
|
...createdControls,
|
|
841
826
|
...dimensionControls
|
|
842
827
|
}, defaultAttrs);
|
|
@@ -878,7 +863,7 @@ const renderDimension = (dimension, { name, component: component$3, attrs = {},
|
|
|
878
863
|
contentDirection: storyOptions.direction,
|
|
879
864
|
contentAlignY: "top",
|
|
880
865
|
children: /* @__PURE__ */ jsx(Provider, {
|
|
881
|
-
component: component$
|
|
866
|
+
component: component$2,
|
|
882
867
|
children: /* @__PURE__ */ jsx(component, { itemProps: {
|
|
883
868
|
...props,
|
|
884
869
|
[dimension]: isMultiKey ? [item] : item
|
|
@@ -889,8 +874,8 @@ const renderDimension = (dimension, { name, component: component$3, attrs = {},
|
|
|
889
874
|
return /* @__PURE__ */ jsx(WrapElement, {
|
|
890
875
|
...storyProps,
|
|
891
876
|
children: /* @__PURE__ */ jsx(Provider, {
|
|
892
|
-
component: component$
|
|
893
|
-
children: /* @__PURE__ */ jsx(
|
|
877
|
+
component: component$2,
|
|
878
|
+
children: /* @__PURE__ */ jsx(Item, {
|
|
894
879
|
...props,
|
|
895
880
|
[dimension]: isMultiKey ? [item] : item
|
|
896
881
|
})
|
|
@@ -914,16 +899,13 @@ const renderDimension = (dimension, { name, component: component$3, attrs = {},
|
|
|
914
899
|
//#region src/utils/dimensions.ts
|
|
915
900
|
const extractDefaultBooleanProps = ({ dimensions, multiKeys, useBooleans }) => {
|
|
916
901
|
if (!useBooleans) return null;
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
}
|
|
925
|
-
return acc;
|
|
926
|
-
}, {});
|
|
902
|
+
const result = {};
|
|
903
|
+
for (const key in dimensions) if (!multiKeys[key]) {
|
|
904
|
+
const value = dimensions[key];
|
|
905
|
+
const propName = Object.keys(value)[0];
|
|
906
|
+
result[propName] = true;
|
|
907
|
+
}
|
|
908
|
+
return result;
|
|
927
909
|
};
|
|
928
910
|
|
|
929
911
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/rocketstories",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@storybook/react": "^10.3.6",
|
|
68
|
-
"@vitus-labs/core": "^2.6.
|
|
69
|
-
"@vitus-labs/rocketstyle": "^2.6.
|
|
70
|
-
"@vitus-labs/unistyle": "^2.6.
|
|
68
|
+
"@vitus-labs/core": "^2.6.2",
|
|
69
|
+
"@vitus-labs/rocketstyle": "^2.6.2",
|
|
70
|
+
"@vitus-labs/unistyle": "^2.6.2",
|
|
71
71
|
"react": ">= 19"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
@@ -76,9 +76,9 @@
|
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@vitus-labs/core": "workspace:*",
|
|
78
78
|
"@vitus-labs/rocketstyle": "workspace:*",
|
|
79
|
-
"@vitus-labs/tools-rolldown": "2.3.
|
|
80
|
-
"@vitus-labs/tools-storybook": "2.3.
|
|
81
|
-
"@vitus-labs/tools-typescript": "2.3.
|
|
79
|
+
"@vitus-labs/tools-rolldown": "2.3.1",
|
|
80
|
+
"@vitus-labs/tools-storybook": "2.3.1",
|
|
81
|
+
"@vitus-labs/tools-typescript": "2.3.1",
|
|
82
82
|
"@vitus-labs/unistyle": "workspace:*"
|
|
83
83
|
}
|
|
84
84
|
}
|