@vitus-labs/rocketstories 2.6.1 → 2.7.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/lib/index.d.ts +5 -6
- package/lib/index.js +56 -74
- package/package.json +9 -11
package/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type T_CONTROL_TYPES = (typeof CONTROL_TYPES)[number];
|
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/types.d.ts
|
|
10
10
|
type TObj = Record<string, unknown>;
|
|
11
|
-
type
|
|
11
|
+
type StoryExtractProps<TComponentOrTProps> = TComponentOrTProps extends ComponentType<infer TProps> ? TProps : TComponentOrTProps;
|
|
12
12
|
type StoryComponent<P = {}> = FC<P> & Partial<{
|
|
13
13
|
args: Record<string, unknown>;
|
|
14
14
|
argTypes: Record<string, unknown>;
|
|
@@ -54,7 +54,6 @@ type StorybookControl = {
|
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
-
type ExtractDimensions<C extends RocketType> = keyof C['$$rocketstyle'];
|
|
58
57
|
type RocketDimensions = keyof RocketType['$$rocketstyle'];
|
|
59
58
|
type Decorator = (Story: any) => ReactNode;
|
|
60
59
|
type Configuration = {
|
|
@@ -144,7 +143,7 @@ interface IRocketStories<OA extends TObj = {}, RA extends TObj | unknown = unkno
|
|
|
144
143
|
controls: (options: Partial<{ [I in keyof OA]: Control }>) => IRocketStories<OA, RA, ISRS>;
|
|
145
144
|
config: <P extends Partial<Omit<Configuration, 'attrs'>>>(params: P) => IRocketStories<OA, RA, ISRS>;
|
|
146
145
|
attrs: <P extends Partial<OA>>(params: P) => IRocketStories<OA, RA, ISRS>;
|
|
147
|
-
replaceComponent: <P extends Configuration['component']>(param: P) => P extends RocketType ? IRocketStories<
|
|
146
|
+
replaceComponent: <P extends Configuration['component']>(param: P) => P extends RocketType ? IRocketStories<StoryExtractProps<P>, P['$$rocketstyle'], true> : IRocketStories<StoryExtractProps<P>, unknown, false>;
|
|
148
147
|
decorators: <P extends Configuration['decorators']>(param: P) => IRocketStories<OA, RA, ISRS>;
|
|
149
148
|
}
|
|
150
149
|
//#endregion
|
|
@@ -160,7 +159,7 @@ type InitParams = Partial<Omit<Configuration, 'component' | 'attrs' | 'theme'>>
|
|
|
160
159
|
* Pass `theme` to set the global theme at runtime (alternative to
|
|
161
160
|
* configuring it via `vl-tools.config`).
|
|
162
161
|
*/
|
|
163
|
-
type Init = <P extends InitParams>(params: P) => <T extends Configuration['component']>(component: T) => T extends RocketType ? IRocketStories<
|
|
162
|
+
type Init = <P extends InitParams>(params: P) => <T extends Configuration['component']>(component: T) => T extends RocketType ? IRocketStories<StoryExtractProps<T>, T['$$rocketstyle'], true> : IRocketStories<StoryExtractProps<T>, unknown, false>;
|
|
164
163
|
/** @see {@link Init} */
|
|
165
164
|
declare const init: Init;
|
|
166
165
|
/**
|
|
@@ -170,9 +169,9 @@ declare const init: Init;
|
|
|
170
169
|
*/
|
|
171
170
|
type Rocketstories = <C extends Configuration['component']>(component: C, options?: Partial<Omit<Configuration, 'component' | 'attrs' | 'theme'>> & {
|
|
172
171
|
theme?: Record<string, unknown>;
|
|
173
|
-
}) => C extends RocketType ? IRocketStories<
|
|
172
|
+
}) => C extends RocketType ? IRocketStories<StoryExtractProps<C>, C['$$rocketstyle'], true> : IRocketStories<StoryExtractProps<C>, unknown, false>;
|
|
174
173
|
/** @see {@link Rocketstories} */
|
|
175
174
|
declare const rocketstories: Rocketstories;
|
|
176
175
|
//#endregion
|
|
177
|
-
export { type Configuration, type Control, type ControlTypes, type Controls, type ElementType, type
|
|
176
|
+
export { type Configuration, type Control, type ControlTypes, type Controls, type ElementType, type IRocketStories, type Init, type PartialControls, type RocketStoryConfiguration, type RocketType, type Rocketstories, type StoryComponent, type StoryConfiguration, type StorybookControl, init as default, init, rocketstories };
|
|
178
177
|
//# sourceMappingURL=index2.d.ts.map
|
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
|
|
@@ -638,37 +631,29 @@ 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;
|
|
@@ -914,16 +899,13 @@ const renderDimension = (dimension, { name, component: component$2, 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.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -64,21 +64,19 @@
|
|
|
64
64
|
"typecheck": "tsc --noEmit"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@
|
|
68
|
-
"@vitus-labs/
|
|
69
|
-
"@vitus-labs/rocketstyle": "^2.
|
|
70
|
-
"@vitus-labs/unistyle": "^2.
|
|
67
|
+
"@vitus-labs/core": "^2.7.0",
|
|
68
|
+
"@vitus-labs/elements": "^2.7.0",
|
|
69
|
+
"@vitus-labs/rocketstyle": "^2.7.0",
|
|
70
|
+
"@vitus-labs/unistyle": "^2.7.0",
|
|
71
71
|
"react": ">= 19"
|
|
72
72
|
},
|
|
73
|
-
"dependencies": {
|
|
74
|
-
"@vitus-labs/elements": "workspace:*"
|
|
75
|
-
},
|
|
76
73
|
"devDependencies": {
|
|
77
74
|
"@vitus-labs/core": "workspace:*",
|
|
75
|
+
"@vitus-labs/elements": "workspace:*",
|
|
78
76
|
"@vitus-labs/rocketstyle": "workspace:*",
|
|
79
|
-
"@vitus-labs/tools-rolldown": "2.
|
|
80
|
-
"@vitus-labs/tools-storybook": "2.
|
|
81
|
-
"@vitus-labs/tools-typescript": "2.
|
|
77
|
+
"@vitus-labs/tools-rolldown": "2.5.0",
|
|
78
|
+
"@vitus-labs/tools-storybook": "2.5.0",
|
|
79
|
+
"@vitus-labs/tools-typescript": "2.5.0",
|
|
82
80
|
"@vitus-labs/unistyle": "workspace:*"
|
|
83
81
|
}
|
|
84
82
|
}
|