@nexo-labs/payload-lexical-blocks-builder 1.6.1
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/LexicalDecoratorNode-C9hMKfgk.d.mts +2241 -0
- package/dist/LexicalDecoratorNode-C9hMKfgk.d.mts.map +1 -0
- package/dist/builder-BhjgvNFy.d.mts +25956 -0
- package/dist/builder-BhjgvNFy.d.mts.map +1 -0
- package/dist/builder.d.mts +3 -0
- package/dist/builder.mjs +15 -0
- package/dist/builder.mjs.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +1 -0
- package/dist/renderer-Y62qi9KC.d.mts +678 -0
- package/dist/renderer-Y62qi9KC.d.mts.map +1 -0
- package/dist/renderer.d.mts +3 -0
- package/dist/renderer.mjs +6 -0
- package/dist/renderer.mjs.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import { o as SerializedEditorState } from "./LexicalDecoratorNode-C9hMKfgk.mjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/@storybook+core@8.6.11_prettier@3.5.3_storybook@8.6.11_prettier@3.5.3_/node_modules/@storybook/core/dist/csf/index.d.ts
|
|
5
|
+
declare global {
|
|
6
|
+
interface SymbolConstructor {
|
|
7
|
+
readonly observable: symbol;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
@see Simplify
|
|
13
|
+
*/
|
|
14
|
+
interface SimplifyOptions {
|
|
15
|
+
/**
|
|
16
|
+
Do the simplification recursively.
|
|
17
|
+
@default false
|
|
18
|
+
*/
|
|
19
|
+
deep?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Flatten a type without worrying about the result.
|
|
23
|
+
type Flatten<AnyType, Options extends SimplifyOptions = {}> = Options['deep'] extends true ? { [KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options> } : { [KeyType in keyof AnyType]: AnyType[KeyType] };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
27
|
+
|
|
28
|
+
@example
|
|
29
|
+
```
|
|
30
|
+
import type {Simplify} from 'type-fest';
|
|
31
|
+
|
|
32
|
+
type PositionProps = {
|
|
33
|
+
top: number;
|
|
34
|
+
left: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type SizeProps = {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
43
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
47
|
+
|
|
48
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
49
|
+
|
|
50
|
+
@example
|
|
51
|
+
```
|
|
52
|
+
import type {Simplify} from 'type-fest';
|
|
53
|
+
|
|
54
|
+
interface SomeInterface {
|
|
55
|
+
foo: number;
|
|
56
|
+
bar?: string;
|
|
57
|
+
baz: number | undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type SomeType = {
|
|
61
|
+
foo: number;
|
|
62
|
+
bar?: string;
|
|
63
|
+
baz: number | undefined;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
67
|
+
const someType: SomeType = literal;
|
|
68
|
+
const someInterface: SomeInterface = literal;
|
|
69
|
+
|
|
70
|
+
function fn(object: Record<string, unknown>): void {}
|
|
71
|
+
|
|
72
|
+
fn(literal); // Good: literal object type is sealed
|
|
73
|
+
fn(someType); // Good: type is sealed
|
|
74
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
75
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
79
|
+
|
|
80
|
+
@category Object
|
|
81
|
+
*/
|
|
82
|
+
type Simplify<AnyType, Options extends SimplifyOptions = {}> = Flatten<AnyType> extends AnyType ? Flatten<AnyType, Options> : AnyType;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
Remove any index signatures from the given object type, so that only explicitly defined properties remain.
|
|
86
|
+
|
|
87
|
+
Use-cases:
|
|
88
|
+
- Remove overly permissive signatures from third-party types.
|
|
89
|
+
|
|
90
|
+
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
91
|
+
|
|
92
|
+
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
93
|
+
|
|
94
|
+
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
const indexed: Record<string, unknown> = {}; // Allowed
|
|
98
|
+
|
|
99
|
+
const keyed: Record<'foo', unknown> = {}; // Error
|
|
100
|
+
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
type Indexed = {} extends Record<string, unknown>
|
|
107
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
108
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
109
|
+
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
110
|
+
|
|
111
|
+
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
112
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
113
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
114
|
+
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
121
|
+
|
|
122
|
+
type RemoveIndexSignature<ObjectType> = {
|
|
123
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
124
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
132
|
+
|
|
133
|
+
type RemoveIndexSignature<ObjectType> = {
|
|
134
|
+
[KeyType in keyof ObjectType
|
|
135
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
136
|
+
as {} extends Record<KeyType, unknown>
|
|
137
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
138
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
139
|
+
]: ObjectType[KeyType];
|
|
140
|
+
};
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
147
|
+
|
|
148
|
+
type RemoveIndexSignature<ObjectType> = {
|
|
149
|
+
[KeyType in keyof ObjectType
|
|
150
|
+
as {} extends Record<KeyType, unknown>
|
|
151
|
+
? never // => Remove this `KeyType`.
|
|
152
|
+
: KeyType // => Keep this `KeyType` as it is.
|
|
153
|
+
]: ObjectType[KeyType];
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
@example
|
|
158
|
+
```
|
|
159
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
160
|
+
|
|
161
|
+
interface Example {
|
|
162
|
+
// These index signatures will be removed.
|
|
163
|
+
[x: string]: any
|
|
164
|
+
[x: number]: any
|
|
165
|
+
[x: symbol]: any
|
|
166
|
+
[x: `head-${string}`]: string
|
|
167
|
+
[x: `${string}-tail`]: string
|
|
168
|
+
[x: `head-${string}-tail`]: string
|
|
169
|
+
[x: `${bigint}`]: string
|
|
170
|
+
[x: `embedded-${number}`]: string
|
|
171
|
+
|
|
172
|
+
// These explicitly defined keys will remain.
|
|
173
|
+
foo: 'bar';
|
|
174
|
+
qux?: 'baz';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
|
|
178
|
+
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
@category Object
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
interface SBBaseType {
|
|
185
|
+
required?: boolean;
|
|
186
|
+
raw?: string;
|
|
187
|
+
}
|
|
188
|
+
type SBScalarType = SBBaseType & {
|
|
189
|
+
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
|
|
190
|
+
};
|
|
191
|
+
type SBArrayType = SBBaseType & {
|
|
192
|
+
name: 'array';
|
|
193
|
+
value: SBType;
|
|
194
|
+
};
|
|
195
|
+
type SBObjectType = SBBaseType & {
|
|
196
|
+
name: 'object';
|
|
197
|
+
value: Record<string, SBType>;
|
|
198
|
+
};
|
|
199
|
+
type SBEnumType = SBBaseType & {
|
|
200
|
+
name: 'enum';
|
|
201
|
+
value: (string | number)[];
|
|
202
|
+
};
|
|
203
|
+
type SBIntersectionType = SBBaseType & {
|
|
204
|
+
name: 'intersection';
|
|
205
|
+
value: SBType[];
|
|
206
|
+
};
|
|
207
|
+
type SBUnionType = SBBaseType & {
|
|
208
|
+
name: 'union';
|
|
209
|
+
value: SBType[];
|
|
210
|
+
};
|
|
211
|
+
type SBOtherType = SBBaseType & {
|
|
212
|
+
name: 'other';
|
|
213
|
+
value: string;
|
|
214
|
+
};
|
|
215
|
+
type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType;
|
|
216
|
+
type StoryId = string;
|
|
217
|
+
type ComponentId = string;
|
|
218
|
+
type ComponentTitle = string;
|
|
219
|
+
type StoryName = string;
|
|
220
|
+
/** @deprecated */
|
|
221
|
+
|
|
222
|
+
type Tag = string;
|
|
223
|
+
interface StoryIdentifier {
|
|
224
|
+
componentId: ComponentId;
|
|
225
|
+
title: ComponentTitle;
|
|
226
|
+
/** @deprecated */
|
|
227
|
+
kind: ComponentTitle;
|
|
228
|
+
id: StoryId;
|
|
229
|
+
name: StoryName;
|
|
230
|
+
/** @deprecated */
|
|
231
|
+
story: StoryName;
|
|
232
|
+
tags: Tag[];
|
|
233
|
+
}
|
|
234
|
+
interface Parameters {
|
|
235
|
+
[name: string]: any;
|
|
236
|
+
}
|
|
237
|
+
type ControlType = 'object' | 'boolean' | 'check' | 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select' | 'number' | 'range' | 'file' | 'color' | 'date' | 'text';
|
|
238
|
+
type ConditionalTest = {
|
|
239
|
+
truthy?: boolean;
|
|
240
|
+
} | {
|
|
241
|
+
exists: boolean;
|
|
242
|
+
} | {
|
|
243
|
+
eq: any;
|
|
244
|
+
} | {
|
|
245
|
+
neq: any;
|
|
246
|
+
};
|
|
247
|
+
type ConditionalValue = {
|
|
248
|
+
arg: string;
|
|
249
|
+
} | {
|
|
250
|
+
global: string;
|
|
251
|
+
};
|
|
252
|
+
type Conditional = ConditionalValue & ConditionalTest;
|
|
253
|
+
interface ControlBase {
|
|
254
|
+
[key: string]: any;
|
|
255
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controltype */
|
|
256
|
+
type?: ControlType;
|
|
257
|
+
disable?: boolean;
|
|
258
|
+
}
|
|
259
|
+
interface Report$1 {
|
|
260
|
+
type: string;
|
|
261
|
+
version?: number;
|
|
262
|
+
result: unknown;
|
|
263
|
+
status: 'failed' | 'passed' | 'warning';
|
|
264
|
+
}
|
|
265
|
+
interface ReportingAPI {
|
|
266
|
+
reports: Report$1[];
|
|
267
|
+
addReport: (report: Report$1) => void;
|
|
268
|
+
}
|
|
269
|
+
type Control = ControlType | false | (ControlBase & (ControlBase | {
|
|
270
|
+
type: 'color';
|
|
271
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors */
|
|
272
|
+
presetColors?: string[];
|
|
273
|
+
} | {
|
|
274
|
+
type: 'file';
|
|
275
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlaccept */
|
|
276
|
+
accept?: string;
|
|
277
|
+
} | {
|
|
278
|
+
type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
|
|
279
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controllabels */
|
|
280
|
+
labels?: {
|
|
281
|
+
[options: string]: string;
|
|
282
|
+
};
|
|
283
|
+
} | {
|
|
284
|
+
type: 'number' | 'range';
|
|
285
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlmax */
|
|
286
|
+
max?: number;
|
|
287
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlmin */
|
|
288
|
+
min?: number;
|
|
289
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlstep */
|
|
290
|
+
step?: number;
|
|
291
|
+
}));
|
|
292
|
+
interface InputType {
|
|
293
|
+
/** @see https://storybook.js.org/docs/api/arg-types#control */
|
|
294
|
+
control?: Control;
|
|
295
|
+
/** @see https://storybook.js.org/docs/api/arg-types#description */
|
|
296
|
+
description?: string;
|
|
297
|
+
/** @see https://storybook.js.org/docs/api/arg-types#if */
|
|
298
|
+
if?: Conditional;
|
|
299
|
+
/** @see https://storybook.js.org/docs/api/arg-types#mapping */
|
|
300
|
+
mapping?: {
|
|
301
|
+
[key: string]: any;
|
|
302
|
+
};
|
|
303
|
+
/** @see https://storybook.js.org/docs/api/arg-types#name */
|
|
304
|
+
name?: string;
|
|
305
|
+
/** @see https://storybook.js.org/docs/api/arg-types#options */
|
|
306
|
+
options?: readonly any[];
|
|
307
|
+
/** @see https://storybook.js.org/docs/api/arg-types#table */
|
|
308
|
+
table?: {
|
|
309
|
+
[key: string]: unknown;
|
|
310
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tablecategory */
|
|
311
|
+
category?: string;
|
|
312
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue */
|
|
313
|
+
defaultValue?: {
|
|
314
|
+
summary?: string;
|
|
315
|
+
detail?: string;
|
|
316
|
+
};
|
|
317
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tabledisable */
|
|
318
|
+
disable?: boolean;
|
|
319
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tablesubcategory */
|
|
320
|
+
subcategory?: string;
|
|
321
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tabletype */
|
|
322
|
+
type?: {
|
|
323
|
+
summary?: string;
|
|
324
|
+
detail?: string;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
/** @see https://storybook.js.org/docs/api/arg-types#type */
|
|
328
|
+
type?: SBType | SBScalarType['name'];
|
|
329
|
+
/**
|
|
330
|
+
* @deprecated Use `table.defaultValue.summary` instead.
|
|
331
|
+
* @see https://storybook.js.org/docs/api/arg-types#defaultvalue
|
|
332
|
+
*/
|
|
333
|
+
defaultValue?: any;
|
|
334
|
+
[key: string]: any;
|
|
335
|
+
}
|
|
336
|
+
interface StrictInputType extends InputType {
|
|
337
|
+
name: string;
|
|
338
|
+
type?: SBType;
|
|
339
|
+
}
|
|
340
|
+
interface Args {
|
|
341
|
+
[name: string]: any;
|
|
342
|
+
}
|
|
343
|
+
/** @see https://storybook.js.org/docs/api/arg-types#argtypes */
|
|
344
|
+
type ArgTypes<TArgs$1 = Args> = { [name in keyof TArgs$1]: InputType };
|
|
345
|
+
type StrictArgTypes<TArgs$1 = Args> = { [name in keyof TArgs$1]: StrictInputType };
|
|
346
|
+
interface Globals {
|
|
347
|
+
[name: string]: any;
|
|
348
|
+
}
|
|
349
|
+
interface GlobalTypes {
|
|
350
|
+
[name: string]: InputType;
|
|
351
|
+
}
|
|
352
|
+
interface StrictGlobalTypes {
|
|
353
|
+
[name: string]: StrictInputType;
|
|
354
|
+
}
|
|
355
|
+
interface Renderer {
|
|
356
|
+
/** What is the type of the `component` annotation in this renderer? */
|
|
357
|
+
component: any;
|
|
358
|
+
/** What does the story function return in this renderer? */
|
|
359
|
+
storyResult: any;
|
|
360
|
+
/** What type of element does this renderer render to? */
|
|
361
|
+
canvasElement: any;
|
|
362
|
+
mount(): Promise<Canvas>;
|
|
363
|
+
T?: any;
|
|
364
|
+
}
|
|
365
|
+
/** @deprecated - Use `Renderer` */
|
|
366
|
+
|
|
367
|
+
interface StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs$1 = Args> extends StoryIdentifier {
|
|
368
|
+
component?: (TRenderer & {
|
|
369
|
+
T: any;
|
|
370
|
+
})['component'];
|
|
371
|
+
subcomponents?: Record<string, (TRenderer & {
|
|
372
|
+
T: any;
|
|
373
|
+
})['component']>;
|
|
374
|
+
parameters: Parameters;
|
|
375
|
+
initialArgs: TArgs$1;
|
|
376
|
+
argTypes: StrictArgTypes<TArgs$1>;
|
|
377
|
+
}
|
|
378
|
+
type ArgsEnhancer<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (context: StoryContextForEnhancers<TRenderer, TArgs$1>) => TArgs$1;
|
|
379
|
+
type ArgTypesEnhancer<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = ((context: StoryContextForEnhancers<TRenderer, TArgs$1>) => StrictArgTypes<TArgs$1>) & {
|
|
380
|
+
secondPass?: boolean;
|
|
381
|
+
};
|
|
382
|
+
interface StoryContextUpdate<TArgs$1 = Args> {
|
|
383
|
+
args?: TArgs$1;
|
|
384
|
+
globals?: Globals;
|
|
385
|
+
[key: string]: any;
|
|
386
|
+
}
|
|
387
|
+
type ViewMode = 'story' | 'docs';
|
|
388
|
+
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (context: StoryContextForLoaders<TRenderer, TArgs$1>) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
|
389
|
+
type Awaitable<T$1> = T$1 | PromiseLike<T$1>;
|
|
390
|
+
type CleanupCallback = () => Awaitable<unknown>;
|
|
391
|
+
type BeforeAll = () => Awaitable<CleanupCallback | void>;
|
|
392
|
+
type BeforeEach<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (context: StoryContext<TRenderer, TArgs$1>) => Awaitable<CleanupCallback | void>;
|
|
393
|
+
type AfterEach<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (context: StoryContext<TRenderer, TArgs$1>) => Awaitable<void>;
|
|
394
|
+
interface Canvas {}
|
|
395
|
+
interface StoryContext<TRenderer extends Renderer = Renderer, TArgs$1 = Args> extends StoryContextForEnhancers<TRenderer, TArgs$1>, Required<StoryContextUpdate<TArgs$1>> {
|
|
396
|
+
loaded: Record<string, any>;
|
|
397
|
+
abortSignal: AbortSignal;
|
|
398
|
+
canvasElement: TRenderer['canvasElement'];
|
|
399
|
+
hooks: unknown;
|
|
400
|
+
originalStoryFn: StoryFn<TRenderer>;
|
|
401
|
+
viewMode: ViewMode;
|
|
402
|
+
step: StepFunction<TRenderer, TArgs$1>;
|
|
403
|
+
context: this;
|
|
404
|
+
canvas: Canvas;
|
|
405
|
+
mount: TRenderer['mount'];
|
|
406
|
+
reporting: ReportingAPI;
|
|
407
|
+
}
|
|
408
|
+
/** @deprecated Use {@link StoryContext} instead. */
|
|
409
|
+
interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs$1 = Args> extends StoryContext<TRenderer, TArgs$1> {}
|
|
410
|
+
/** @deprecated Use {@link StoryContext} instead. */
|
|
411
|
+
interface PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs$1 = Args> extends StoryContext<TRenderer, TArgs$1> {}
|
|
412
|
+
type StepLabel = string;
|
|
413
|
+
type StepFunction<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs$1>) => Promise<void> | void;
|
|
414
|
+
type PlayFunction<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (context: PlayFunctionContext<TRenderer, TArgs$1>) => Promise<void> | void;
|
|
415
|
+
type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (update?: StoryContextUpdate<Partial<TArgs$1>>) => TRenderer['storyResult'];
|
|
416
|
+
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (context: StoryContext<TRenderer, TArgs$1>) => TRenderer['storyResult'];
|
|
417
|
+
type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (args: TArgs$1, context: StoryContext<TRenderer, TArgs$1>) => (TRenderer & {
|
|
418
|
+
T: TArgs$1;
|
|
419
|
+
})['storyResult'];
|
|
420
|
+
type StoryFn<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = LegacyStoryFn<TRenderer, TArgs$1> | ArgsStoryFn<TRenderer, TArgs$1>;
|
|
421
|
+
type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (fn: PartialStoryFn<TRenderer, TArgs$1>, c: StoryContext<TRenderer, TArgs$1>) => TRenderer['storyResult'];
|
|
422
|
+
type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (storyFn: LegacyStoryFn<TRenderer, TArgs$1>, decorators: DecoratorFunction<TRenderer, TArgs$1>[]) => LegacyStoryFn<TRenderer, TArgs$1>;
|
|
423
|
+
type StepRunner<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs$1>, context: StoryContext<TRenderer, TArgs$1>) => Promise<void>;
|
|
424
|
+
interface BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs$1 = Args> {
|
|
425
|
+
/**
|
|
426
|
+
* Wrapper components or Storybook decorators that wrap a story.
|
|
427
|
+
*
|
|
428
|
+
* Decorators defined in Meta will be applied to every story variation.
|
|
429
|
+
*
|
|
430
|
+
* @see [Decorators](https://storybook.js.org/docs/writing-stories/decorators)
|
|
431
|
+
*/
|
|
432
|
+
decorators?: DecoratorFunction<TRenderer, Simplify<TArgs$1>>[] | DecoratorFunction<TRenderer, Simplify<TArgs$1>>;
|
|
433
|
+
/**
|
|
434
|
+
* Custom metadata for a story.
|
|
435
|
+
*
|
|
436
|
+
* @see [Parameters](https://storybook.js.org/docs/writing-stories/parameters)
|
|
437
|
+
*/
|
|
438
|
+
parameters?: Parameters;
|
|
439
|
+
/**
|
|
440
|
+
* Dynamic data that are provided (and possibly updated by) Storybook and its addons.
|
|
441
|
+
*
|
|
442
|
+
* @see [Args](https://storybook.js.org/docs/writing-stories/args)
|
|
443
|
+
*/
|
|
444
|
+
args?: Partial<TArgs$1>;
|
|
445
|
+
/**
|
|
446
|
+
* ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an
|
|
447
|
+
* arg. These get automatically filled in by Storybook Docs.
|
|
448
|
+
*
|
|
449
|
+
* @see [ArgTypes](https://storybook.js.org/docs/api/arg-types)
|
|
450
|
+
*/
|
|
451
|
+
argTypes?: Partial<ArgTypes<TArgs$1>>;
|
|
452
|
+
/**
|
|
453
|
+
* Asynchronous functions which provide data for a story.
|
|
454
|
+
*
|
|
455
|
+
* @see [Loaders](https://storybook.js.org/docs/writing-stories/loaders)
|
|
456
|
+
*/
|
|
457
|
+
loaders?: LoaderFunction<TRenderer, TArgs$1>[] | LoaderFunction<TRenderer, TArgs$1>;
|
|
458
|
+
/**
|
|
459
|
+
* Function to be called before each story. When the function is async, it will be awaited.
|
|
460
|
+
*
|
|
461
|
+
* `beforeEach` can be added to preview, the default export and to a specific story. They are run
|
|
462
|
+
* (and awaited) in the order: preview, default export, story
|
|
463
|
+
*
|
|
464
|
+
* A cleanup function can be returned.
|
|
465
|
+
*/
|
|
466
|
+
beforeEach?: BeforeEach<TRenderer, TArgs$1>[] | BeforeEach<TRenderer, TArgs$1>;
|
|
467
|
+
/**
|
|
468
|
+
* Function to be called after each play function for post-test assertions. Don't use this
|
|
469
|
+
* function for cleaning up state. You can use the return callback of `beforeEach` for that, which
|
|
470
|
+
* is run when switching stories. When the function is async, it will be awaited.
|
|
471
|
+
*
|
|
472
|
+
* `afterEach` can be added to preview, the default export and to a specific story. They are run
|
|
473
|
+
* (and awaited) reverse order: preview, default export, story
|
|
474
|
+
*/
|
|
475
|
+
experimental_afterEach?: AfterEach<TRenderer, TArgs$1>[] | AfterEach<TRenderer, TArgs$1>;
|
|
476
|
+
/**
|
|
477
|
+
* Define a custom render function for the story(ies). If not passed, a default render function by
|
|
478
|
+
* the renderer will be used.
|
|
479
|
+
*/
|
|
480
|
+
render?: ArgsStoryFn<TRenderer, TArgs$1>;
|
|
481
|
+
/** Named tags for a story, used to filter stories in different contexts. */
|
|
482
|
+
tags?: Tag[];
|
|
483
|
+
mount?: (context: StoryContext<TRenderer, TArgs$1>) => TRenderer['mount'];
|
|
484
|
+
}
|
|
485
|
+
interface ProjectAnnotations<TRenderer extends Renderer = Renderer, TArgs$1 = Args> extends BaseAnnotations<TRenderer, TArgs$1> {
|
|
486
|
+
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
|
|
487
|
+
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
|
|
488
|
+
/**
|
|
489
|
+
* Lifecycle hook which runs once, before any loaders, decorators or stories, and may rerun when
|
|
490
|
+
* configuration changes or when reinitializing (e.g. between test runs). The function may be
|
|
491
|
+
* synchronous or asynchronous, and may return a cleanup function which may also be synchronous or
|
|
492
|
+
* asynchronous. The cleanup function is not guaranteed to run (e.g. when the browser closes), but
|
|
493
|
+
* runs when configuration changes or when reinitializing. This hook may only be defined globally
|
|
494
|
+
* (i.e. not on component or story level). When multiple hooks are specified, they are to be
|
|
495
|
+
* executed sequentially (and awaited) in the following order:
|
|
496
|
+
*
|
|
497
|
+
* - Addon hooks (in order of addons array in e.g. .storybook/main.js)
|
|
498
|
+
* - Annotation hooks (in order of previewAnnotations array in e.g. .storybook/main.js)
|
|
499
|
+
* - Preview hook (via e.g. .storybook/preview.js) Cleanup functions are executed sequentially in
|
|
500
|
+
* reverse order of initialization.
|
|
501
|
+
*/
|
|
502
|
+
beforeAll?: BeforeAll;
|
|
503
|
+
/** @deprecated Project `globals` renamed to `initiaGlobals` */
|
|
504
|
+
globals?: Globals;
|
|
505
|
+
initialGlobals?: Globals;
|
|
506
|
+
globalTypes?: GlobalTypes;
|
|
507
|
+
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
|
|
508
|
+
runStep?: StepRunner<TRenderer, TArgs$1>;
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region ../../node_modules/.pnpm/@storybook+core@8.6.11_prettier@3.5.3_storybook@8.6.11_prettier@3.5.3_/node_modules/@storybook/core/dist/types/index.d.ts
|
|
512
|
+
declare global {
|
|
513
|
+
var globalProjectAnnotations: NormalizedProjectAnnotations<any>;
|
|
514
|
+
var defaultProjectAnnotations: ProjectAnnotations$1<any>;
|
|
515
|
+
}
|
|
516
|
+
type WrappedStoryRef = {
|
|
517
|
+
__pw_type: 'jsx' | 'importRef';
|
|
518
|
+
};
|
|
519
|
+
type UnwrappedJSXStoryRef = {
|
|
520
|
+
__pw_type: 'jsx';
|
|
521
|
+
type: UnwrappedImportStoryRef;
|
|
522
|
+
};
|
|
523
|
+
type UnwrappedImportStoryRef = ComposedStoryFn;
|
|
524
|
+
declare global {
|
|
525
|
+
function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
|
|
526
|
+
}
|
|
527
|
+
interface Report<T$1 = unknown> {
|
|
528
|
+
type: string;
|
|
529
|
+
version?: number;
|
|
530
|
+
result: T$1;
|
|
531
|
+
status: 'failed' | 'passed' | 'warning';
|
|
532
|
+
}
|
|
533
|
+
declare class ReporterAPI {
|
|
534
|
+
reports: Report[];
|
|
535
|
+
addReport(report: Report): Promise<void>;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* A URL pathname, beginning with a /.
|
|
540
|
+
*
|
|
541
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
|
|
542
|
+
*/
|
|
543
|
+
|
|
544
|
+
declare global {
|
|
545
|
+
interface SymbolConstructor {
|
|
546
|
+
readonly observable: symbol;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
552
|
+
|
|
553
|
+
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
554
|
+
|
|
555
|
+
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
556
|
+
|
|
557
|
+
@example
|
|
558
|
+
```
|
|
559
|
+
import type {LiteralUnion} from 'type-fest';
|
|
560
|
+
|
|
561
|
+
// Before
|
|
562
|
+
|
|
563
|
+
type Pet = 'dog' | 'cat' | string;
|
|
564
|
+
|
|
565
|
+
const pet: Pet = '';
|
|
566
|
+
// Start typing in your TypeScript-enabled IDE.
|
|
567
|
+
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
568
|
+
|
|
569
|
+
// After
|
|
570
|
+
|
|
571
|
+
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
572
|
+
|
|
573
|
+
const pet: Pet2 = '';
|
|
574
|
+
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
@category Type
|
|
578
|
+
*/
|
|
579
|
+
|
|
580
|
+
interface Renderer$1 extends Renderer {}
|
|
581
|
+
type MaybePromise<T$1> = Promise<T$1> | T$1;
|
|
582
|
+
type TeardownRenderToCanvas = () => MaybePromise<void>;
|
|
583
|
+
type RenderToCanvas<TRenderer extends Renderer$1> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
|
|
584
|
+
interface ProjectAnnotations$1<TRenderer extends Renderer$1> extends ProjectAnnotations<TRenderer> {
|
|
585
|
+
addons?: ProjectAnnotations$1<TRenderer>[];
|
|
586
|
+
testingLibraryRender?: (...args: never[]) => {
|
|
587
|
+
unmount: () => void;
|
|
588
|
+
};
|
|
589
|
+
renderToCanvas?: RenderToCanvas<TRenderer>;
|
|
590
|
+
renderToDOM?: RenderToCanvas<TRenderer>;
|
|
591
|
+
}
|
|
592
|
+
type NormalizedProjectAnnotations<TRenderer extends Renderer$1 = Renderer$1> = Omit<ProjectAnnotations$1<TRenderer>, 'decorators' | 'loaders' | 'runStep' | 'beforeAll'> & {
|
|
593
|
+
argTypes?: StrictArgTypes;
|
|
594
|
+
globalTypes?: StrictGlobalTypes;
|
|
595
|
+
decorators?: DecoratorFunction<TRenderer>[];
|
|
596
|
+
loaders?: LoaderFunction<TRenderer>[];
|
|
597
|
+
runStep: StepRunner<TRenderer>;
|
|
598
|
+
beforeAll: BeforeAll;
|
|
599
|
+
};
|
|
600
|
+
declare type RenderContext<TRenderer extends Renderer$1 = Renderer$1> = StoryIdentifier & {
|
|
601
|
+
showMain: () => void;
|
|
602
|
+
showError: (error: {
|
|
603
|
+
title: string;
|
|
604
|
+
description: string;
|
|
605
|
+
}) => void;
|
|
606
|
+
showException: (err: Error) => void;
|
|
607
|
+
forceRemount: boolean;
|
|
608
|
+
storyContext: StoryContext<TRenderer>;
|
|
609
|
+
storyFn: PartialStoryFn<TRenderer>;
|
|
610
|
+
unboundStoryFn: LegacyStoryFn<TRenderer>;
|
|
611
|
+
};
|
|
612
|
+
/** A story function with partial args, used internally by composeStory */
|
|
613
|
+
type PartialArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = (args?: TArgs$1) => (TRenderer & {
|
|
614
|
+
T: TArgs$1;
|
|
615
|
+
})['storyResult'];
|
|
616
|
+
/**
|
|
617
|
+
* A story that got recomposed for portable stories, containing all the necessary data to be
|
|
618
|
+
* rendered in external environments
|
|
619
|
+
*/
|
|
620
|
+
type ComposedStoryFn<TRenderer extends Renderer = Renderer, TArgs$1 = Args> = PartialArgsStoryFn<TRenderer, TArgs$1> & {
|
|
621
|
+
args: TArgs$1;
|
|
622
|
+
id: StoryId;
|
|
623
|
+
play?: (context?: Partial<StoryContext<TRenderer, Partial<TArgs$1>>>) => Promise<void>;
|
|
624
|
+
run: (context?: Partial<StoryContext<TRenderer, Partial<TArgs$1>>>) => Promise<void>;
|
|
625
|
+
load: () => Promise<void>;
|
|
626
|
+
storyName: string;
|
|
627
|
+
parameters: Parameters;
|
|
628
|
+
argTypes: StrictArgTypes<TArgs$1>;
|
|
629
|
+
reporting: ReporterAPI;
|
|
630
|
+
tags: Tag[];
|
|
631
|
+
globals: Globals;
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Based on a module of stories, it returns all stories within it, filtering non-stories Each story
|
|
635
|
+
* will have partial props, as their props should be handled when composing stories
|
|
636
|
+
*/
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region ../../node_modules/.pnpm/@storybook+react@8.6.11_@storybook+test@8.6.11_storybook@8.6.11_prettier@3.5.3___react-_eab940b44d3237e7dadfcaf195cb715a/node_modules/@storybook/react/dist/public-types-f2c70f25.d.ts
|
|
639
|
+
declare global {
|
|
640
|
+
interface SymbolConstructor {
|
|
641
|
+
readonly observable: symbol;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
Returns a boolean for whether the two given types are equal.
|
|
647
|
+
|
|
648
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
649
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
650
|
+
*/
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region src/renderer.d.ts
|
|
653
|
+
interface LexicalBlockProps<T$1> {
|
|
654
|
+
node: {
|
|
655
|
+
fields: T$1;
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
type BlockRendererFunction = ({
|
|
659
|
+
node
|
|
660
|
+
}: LexicalBlockProps<any>) => Promise<any> | any;
|
|
661
|
+
type BlocksRendererFunctions<T$1 extends string> = Record<T$1, BlockRendererFunction>;
|
|
662
|
+
interface GenericStory<P$1> {
|
|
663
|
+
argTypes?: Partial<ArgTypes<{
|
|
664
|
+
node: {
|
|
665
|
+
fields: P$1;
|
|
666
|
+
};
|
|
667
|
+
}>>;
|
|
668
|
+
}
|
|
669
|
+
type StoryArgs<T$1> = T$1 extends GenericStory<infer P> ? P : never;
|
|
670
|
+
declare const generateStoryForLexicalBlock: <T$1 extends GenericStory<any>>(args: StoryArgs<T$1>) => {
|
|
671
|
+
args: LexicalBlockProps<StoryArgs<T$1>>;
|
|
672
|
+
};
|
|
673
|
+
type ExtendedSerializedEditorState = SerializedEditorState & {
|
|
674
|
+
[k: string]: unknown;
|
|
675
|
+
};
|
|
676
|
+
//#endregion
|
|
677
|
+
export { LexicalBlockProps as a, GenericStory as i, BlocksRendererFunctions as n, StoryArgs as o, ExtendedSerializedEditorState as r, generateStoryForLexicalBlock as s, BlockRendererFunction as t };
|
|
678
|
+
//# sourceMappingURL=renderer-Y62qi9KC.d.mts.map
|