@repobuddy/storybook 2.5.0 → 2.6.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/esm/index.d.ts +14 -2
- package/package.json +2 -2
- package/src/arg-types/fn-to-arg-types.ts +24 -0
- package/src/index.ts +1 -0
package/esm/index.d.ts
CHANGED
|
@@ -2,12 +2,24 @@
|
|
|
2
2
|
import { UserConfig } from "htmlfy";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
import { AnyFunction, CreateTuple, IsStringLiteral, Properties, Tail } from "type-plus";
|
|
5
6
|
import { ClassNameProps, StyleProps } from "@just-web/css";
|
|
6
7
|
import { Args, DecoratorFunction, Renderer } from "storybook/internal/csf";
|
|
7
8
|
import { Decorator, Meta, StoryContext, StoryObj, StrictArgs } from "@storybook/react-vite";
|
|
8
|
-
import { IsStringLiteral } from "type-plus";
|
|
9
9
|
export * from "@repobuddy/test";
|
|
10
10
|
|
|
11
|
+
//#region src/arg-types/fn-to-arg-types.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Converts a function's parameter types to `Args` type for Storybook.
|
|
14
|
+
* Each name maps to the parameter type at the same index in F.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* type F = (a: number, b: string) => void
|
|
18
|
+
* type R = FnToArgTypes<F, ['x', 'y']> // { x: number; y: string }
|
|
19
|
+
*/
|
|
20
|
+
type FnToArgTypes<F extends AnyFunction, Names extends CreateTuple<Parameters<F>['length'], string> = CreateTuple<Parameters<F>['length'], string>> = Properties<ReduceToRecord<Parameters<F>, Names>>;
|
|
21
|
+
type ReduceToRecord<Params extends Array<any>, Names extends Array<any>> = Names['length'] extends 0 ? unknown : Names['length'] extends 1 ? Names extends [infer K extends string] ? { [I in K]: Params[0] } : never : Names extends [infer K extends string, ...infer Rest] ? { [I in K]: Params[0] } & ReduceToRecord<Tail<Params>, Rest> : never;
|
|
22
|
+
//#endregion
|
|
11
23
|
//#region src/components/show_html.d.ts
|
|
12
24
|
type ShowHtmlProps = ClassNameProps & StyleProps & {
|
|
13
25
|
selector?: string | undefined;
|
|
@@ -786,4 +798,4 @@ type ExtendsStoryObj<S extends {
|
|
|
786
798
|
tags?: ExtractStringLiterals<NonNullable<S['tags']>[number]> extends infer MT ? IsStringLiteral<MT> extends true ? Array<(string & {}) | MT | E['tag']> | undefined : Array<(string & {}) | E['tag']> | undefined : never;
|
|
787
799
|
};
|
|
788
800
|
//#endregion
|
|
789
|
-
export { ActionsParam, BackgroundsParam, DocsParam, ExtendMeta, ExtendStoryObj, ExtendsMeta, ExtendsStoryObj, GlobalApiBackgroundsParam, GlobalApiViewportParam, LayoutParam, ShowHtml, ShowHtmlProps, SourceProps, StorySortParam, StorybookBuiltInParams, TestParam, Viewport, ViewportParam, WithStoryCardProps, defineActionsParam, defineBackgroundsParam, defineDocsParam, defineLayoutParam, defineParameters, defineTestParam, defineViewportParam, showDocSource, whenRunningInTest, withStoryCard };
|
|
801
|
+
export { ActionsParam, BackgroundsParam, DocsParam, ExtendMeta, ExtendStoryObj, ExtendsMeta, ExtendsStoryObj, FnToArgTypes, GlobalApiBackgroundsParam, GlobalApiViewportParam, LayoutParam, ShowHtml, ShowHtmlProps, SourceProps, StorySortParam, StorybookBuiltInParams, TestParam, Viewport, ViewportParam, WithStoryCardProps, defineActionsParam, defineBackgroundsParam, defineDocsParam, defineLayoutParam, defineParameters, defineTestParam, defineViewportParam, showDocSource, whenRunningInTest, withStoryCard };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Storybook repo buddy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"class-variance-authority": "^0.7.1",
|
|
56
56
|
"htmlfy": "^1.0.0",
|
|
57
57
|
"tailwind-merge": "^3.4.0",
|
|
58
|
-
"type-plus": "8.0.0-beta.
|
|
58
|
+
"type-plus": "8.0.0-beta.8"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@repobuddy/vitest": "^2.0.0",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AnyFunction, CreateTuple, Properties, Tail } from 'type-plus'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a function's parameter types to `Args` type for Storybook.
|
|
5
|
+
* Each name maps to the parameter type at the same index in F.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* type F = (a: number, b: string) => void
|
|
9
|
+
* type R = FnToArgTypes<F, ['x', 'y']> // { x: number; y: string }
|
|
10
|
+
*/
|
|
11
|
+
export type FnToArgTypes<
|
|
12
|
+
F extends AnyFunction,
|
|
13
|
+
Names extends CreateTuple<Parameters<F>['length'], string> = CreateTuple<Parameters<F>['length'], string>
|
|
14
|
+
> = Properties<ReduceToRecord<Parameters<F>, Names>>
|
|
15
|
+
|
|
16
|
+
type ReduceToRecord<Params extends Array<any>, Names extends Array<any>> = Names['length'] extends 0
|
|
17
|
+
? unknown
|
|
18
|
+
: Names['length'] extends 1
|
|
19
|
+
? Names extends [infer K extends string]
|
|
20
|
+
? { [I in K]: Params[0] }
|
|
21
|
+
: never
|
|
22
|
+
: Names extends [infer K extends string, ...infer Rest]
|
|
23
|
+
? { [I in K]: Params[0] } & ReduceToRecord<Tail<Params>, Rest>
|
|
24
|
+
: never
|