@makeswift/runtime 0.0.0-a500663

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.
@@ -0,0 +1,821 @@
1
+ import type * as Slate from 'slate'
2
+ import type { Element, Data } from '../state/react-page'
3
+
4
+ // See https://github.com/microsoft/TypeScript/issues/15300
5
+ export type IndexSignatureHack<T> = T extends Record<string, any>
6
+ ? { [K in keyof T]: IndexSignatureHack<T[K]> }
7
+ : T
8
+
9
+ export type Device = 'desktop' | 'tablet' | 'mobile'
10
+
11
+ export type DeviceOverride<T> = { deviceId: Device; value: T }
12
+
13
+ export type ResponsiveValue<T> = DeviceOverride<T>[]
14
+
15
+ export type ResponsiveValueType<T> = T extends ResponsiveValue<infer U> ? U : never
16
+
17
+ type Color = { swatchId: string; alpha: number }
18
+
19
+ type IconName =
20
+ | 'HeightAuto16'
21
+ | 'HeightMatch16'
22
+ | 'VerticalAlignStart16'
23
+ | 'VerticalAlignMiddle16'
24
+ | 'VerticalAlignEnd16'
25
+ | 'VerticalAlignSpaceBetween16'
26
+ | 'ButtonPill16'
27
+ | 'ButtonRounded16'
28
+ | 'ButtonSquare16'
29
+ | 'SizeSmall16'
30
+ | 'SizeMedium16'
31
+ | 'SizeLarge16'
32
+ | 'ArrowInside16'
33
+ | 'ArrowCenter16'
34
+ | 'ArrowOutside16'
35
+ | 'CountdownSolid16'
36
+ | 'CountdownSolidSplit16'
37
+ | 'CountdownOutline16'
38
+ | 'CountdownOutlineSplit16'
39
+ | 'CountdownNaked16'
40
+ | 'Sun16'
41
+ | 'Moon16'
42
+ | 'AlignLeft16'
43
+ | 'AlignCenter16'
44
+ | 'AlignRight16'
45
+ | 'Star16'
46
+ | 'StarCircle16'
47
+ | 'StarRoundedSquare16'
48
+ | 'StarSquare16'
49
+
50
+ type Gap = { value: number; unit: 'px' }
51
+
52
+ export type Length = { value: number; unit: 'px' | '%' }
53
+
54
+ type OpenPageLink = {
55
+ type: 'OPEN_PAGE'
56
+ payload: { pageId: string | null | undefined; openInNewTab: boolean }
57
+ }
58
+
59
+ type OpenURLLink = { type: 'OPEN_URL'; payload: { url: string; openInNewTab: boolean } }
60
+
61
+ type SendEmailLink = {
62
+ type: 'SEND_EMAIL'
63
+ payload: { to: string; subject?: string; body?: string }
64
+ }
65
+
66
+ type CallPhoneLink = { type: 'CALL_PHONE'; payload: { phoneNumber: string } }
67
+
68
+ type ScrollToElementLink = {
69
+ type: 'SCROLL_TO_ELEMENT'
70
+ payload: {
71
+ elementIdConfig: { elementKey: string; propName: string } | null | undefined
72
+ block: 'start' | 'center' | 'end'
73
+ }
74
+ }
75
+
76
+ type Link = OpenPageLink | OpenURLLink | SendEmailLink | CallPhoneLink | ScrollToElementLink
77
+
78
+ type TextStyle = {
79
+ fontFamily?: string | null | undefined
80
+ letterSpacing: number | null | undefined
81
+ fontSize: { value: number; unit: 'px' } | null | undefined
82
+ fontWeight: number | null | undefined
83
+ textTransform: 'uppercase'[]
84
+ fontStyle: 'italic'[]
85
+ }
86
+
87
+ export const Types = {
88
+ Backgrounds: 'Backgrounds',
89
+ Border: 'Border',
90
+ BorderRadius: 'BorderRadius',
91
+ Checkbox: 'Checkbox',
92
+ Date: 'Date',
93
+ ElementID: 'ElementID',
94
+ Font: 'Font',
95
+ GapX: 'GapX',
96
+ GapY: 'GapY',
97
+ Grid: 'Grid',
98
+ Image: 'Image',
99
+ Images: 'Images',
100
+ Link: 'Link',
101
+ Margin: 'Margin',
102
+ NavigationLinks: 'NavigationLinks',
103
+ Number: 'Number',
104
+ Padding: 'Padding',
105
+ ResponsiveColor: 'ResponsiveColor',
106
+ ResponsiveIconRadioGroup: 'ResponsiveIconRadioGroup',
107
+ ResponsiveLength: 'ResponsiveLength',
108
+ ResponsiveNumber: 'ResponsiveNumber',
109
+ ResponsiveOpacity: 'ResponsiveOpacity',
110
+ ResponsiveSelect: 'ResponsiveSelect',
111
+ RichText: 'RichText',
112
+ Shadows: 'Shadows',
113
+ SocialLinks: 'SocialLinks',
114
+ Table: 'Table',
115
+ TableFormFields: 'TableFormFields',
116
+ TextArea: 'TextArea',
117
+ TextInput: 'TextInput',
118
+ TextStyle: 'TextStyle',
119
+ Video: 'Video',
120
+ Width: 'Width',
121
+ } as const
122
+
123
+ type Options<T> = T | ((props: Record<string, unknown>, decideMode: Device) => T)
124
+
125
+ type ColorBackground = { type: 'color'; id: string; payload: Color | null }
126
+
127
+ type GradientStop = { id: string; location: number; color: Color | null }
128
+
129
+ type Gradient = { angle?: number; isRadial?: boolean; stops: GradientStop[] }
130
+
131
+ type GradientBackground = { type: 'gradient'; id: string; payload: Gradient }
132
+
133
+ type BackgroundImagePosition = { x: number; y: number }
134
+
135
+ type BackgroundImageSize = 'cover' | 'contain' | 'auto'
136
+
137
+ type BackgroundImageRepeat = 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat'
138
+
139
+ type BackgroundImage = {
140
+ imageId: string
141
+ position: BackgroundImagePosition
142
+ size?: BackgroundImageSize
143
+ repeat?: BackgroundImageRepeat
144
+ opacity?: number
145
+ parallax?: number
146
+ }
147
+
148
+ type ImageBackground = { type: 'image'; id: string; payload: BackgroundImage }
149
+
150
+ type BackgroundVideoAspectRatio = 'wide' | 'standard'
151
+
152
+ type BackgroundVideo = {
153
+ url?: string
154
+ maskColor?: Color | null
155
+ opacity?: number
156
+ zoom?: number
157
+ aspectRatio?: BackgroundVideoAspectRatio
158
+ parallax?: number
159
+ }
160
+
161
+ type VideoBackground = { type: 'video'; id: string; payload: BackgroundVideo }
162
+
163
+ type Background = ColorBackground | GradientBackground | ImageBackground | VideoBackground
164
+
165
+ export type BackgroundsValue = ResponsiveValue<Background[]>
166
+
167
+ type BackgroundsOptions = Options<Record<string, never>>
168
+
169
+ type BackgroundsDescriptor<_T = BackgroundsValue> = {
170
+ type: typeof Types.Backgrounds
171
+ options: BackgroundsOptions
172
+ }
173
+
174
+ export function Backgrounds(options: BackgroundsOptions = {}): BackgroundsDescriptor {
175
+ return { type: Types.Backgrounds, options }
176
+ }
177
+
178
+ type BorderSideStyle = 'dashed' | 'dotted' | 'solid'
179
+
180
+ type BorderSide = { width: number | null | undefined; style: BorderSideStyle; color?: Color | null }
181
+
182
+ type Border = {
183
+ [K in 'top' | 'right' | 'bottom' | 'left' as `border${Capitalize<K>}`]:
184
+ | BorderSide
185
+ | null
186
+ | undefined
187
+ }
188
+
189
+ export type BorderValue = ResponsiveValue<Border>
190
+
191
+ type BorderOptions = Options<Record<string, never>>
192
+
193
+ type BorderDescriptor<_T = BorderValue> = { type: typeof Types.Border; options: BorderOptions }
194
+
195
+ export function Border(options: BorderOptions = {}): BorderDescriptor {
196
+ return { type: Types.Border, options }
197
+ }
198
+
199
+ type BorderRadius = {
200
+ [K in 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' as `border${Capitalize<K>}Radius`]:
201
+ | Length
202
+ | null
203
+ | undefined
204
+ }
205
+
206
+ export type BorderRadiusValue = ResponsiveValue<BorderRadius>
207
+
208
+ type BorderRadiusOptions = Options<Record<string, never>>
209
+
210
+ type BorderRadiusDescriptor<_T = BorderRadiusValue> = {
211
+ type: typeof Types.BorderRadius
212
+ options: BorderRadiusOptions
213
+ }
214
+
215
+ export function BorderRadius(options: BorderRadiusOptions = {}): BorderRadiusDescriptor {
216
+ return { type: Types.BorderRadius, options }
217
+ }
218
+
219
+ export type CheckboxValue = boolean
220
+
221
+ type CheckboxOptions = Options<{
222
+ preset?: CheckboxValue
223
+ label: string
224
+ hidden?: boolean
225
+ }>
226
+
227
+ type CheckboxDescriptor<_T = CheckboxValue> = {
228
+ type: typeof Types.Checkbox
229
+ options: CheckboxOptions
230
+ }
231
+
232
+ export function Checkbox(options: CheckboxOptions): CheckboxDescriptor {
233
+ return { type: Types.Checkbox, options }
234
+ }
235
+
236
+ export type DateValue = string
237
+
238
+ type DateOptions = Options<{ preset?: DateValue }>
239
+
240
+ type DateDescriptor<_T = DateValue> = { type: typeof Types.Date; options: DateOptions }
241
+
242
+ export function Date(options: DateOptions = {}): DateDescriptor {
243
+ return { type: Types.Date, options }
244
+ }
245
+
246
+ export type ElementIDValue = string
247
+
248
+ type ElementIDOptions = Options<Record<string, never>>
249
+
250
+ type ElementIDDescriptor<_T = ElementIDValue> = {
251
+ type: typeof Types.ElementID
252
+ options: ElementIDOptions
253
+ }
254
+
255
+ export function ElementID(options: ElementIDOptions = {}): ElementIDDescriptor {
256
+ return { type: Types.ElementID, options }
257
+ }
258
+
259
+ export type FontValue = ResponsiveValue<string>
260
+
261
+ type FontOptions = Options<{ preset?: FontValue; label?: string }>
262
+
263
+ type FontDescriptor<_T = FontValue> = { type: typeof Types.Font; options: FontOptions }
264
+
265
+ export function Font(options: FontOptions = {}): FontDescriptor {
266
+ return { type: Types.Font, options }
267
+ }
268
+
269
+ export type GapXValue = ResponsiveValue<Gap>
270
+
271
+ type GapXOptions = Options<{
272
+ preset?: GapXValue
273
+ label?: string
274
+ defaultValue?: Gap
275
+ min?: number
276
+ max?: number
277
+ step?: number
278
+ hidden?: boolean
279
+ }>
280
+
281
+ type GapXDescriptor<_T = GapXValue> = { type: typeof Types.GapX; options: GapXOptions }
282
+
283
+ export function GapX(options: GapXOptions = {}): GapXDescriptor {
284
+ return { type: Types.GapX, options }
285
+ }
286
+
287
+ export type GapYValue = ResponsiveValue<Gap>
288
+
289
+ type GapYOptions = Options<{
290
+ preset?: GapYValue
291
+ label?: string
292
+ defaultValue?: Gap
293
+ step?: number
294
+ min?: number
295
+ max?: number
296
+ hidden?: boolean
297
+ }>
298
+
299
+ type GapYDescriptor<_T = GapYValue> = { type: typeof Types.GapY; options: GapYOptions }
300
+
301
+ export function GapY(options: GapYOptions = {}): GapYDescriptor {
302
+ return { type: Types.GapY, options }
303
+ }
304
+
305
+ type GridColumn = { count: number; spans: number[][] }
306
+
307
+ export type GridValue = { elements: Element[]; columns: ResponsiveValue<GridColumn> }
308
+
309
+ type GridOptions = Options<Record<string, never>>
310
+
311
+ type GridDescriptor<_T = GridValue> = { type: typeof Types.Grid; options: GridOptions }
312
+
313
+ export function Grid(options: GridOptions = {}): GridDescriptor {
314
+ return { type: Types.Grid, options }
315
+ }
316
+
317
+ export type ImageValue = string
318
+
319
+ type ImageOptions = Options<{ label?: string; hidden?: boolean }>
320
+
321
+ type ImageDescriptor<_T = ImageValue> = { type: typeof Types.Image; options: ImageOptions }
322
+
323
+ export function Image(options: ImageOptions = {}): ImageDescriptor {
324
+ return { type: Types.Image, options }
325
+ }
326
+
327
+ export type ImagesValue = { key: string; props: { link?: Link; file?: string; altText?: string } }[]
328
+
329
+ type ImagesOptions = Options<{ preset?: ImagesValue }>
330
+
331
+ type ImagesDescriptor<_T = ImagesValue> = { type: typeof Types.Images; options: ImagesOptions }
332
+
333
+ export function Images(options: ImagesOptions = {}): ImagesDescriptor {
334
+ return { type: Types.Images, options }
335
+ }
336
+
337
+ export type LinkValue = Link
338
+
339
+ type LinkOptions = Options<{
340
+ preset?: LinkValue
341
+ label?: string
342
+ defaultValue?: Link
343
+ options?: { value: Link['type']; label: string }[]
344
+ hidden?: boolean
345
+ }>
346
+
347
+ type LinkDescriptor<_T = LinkValue> = { type: typeof Types.Link; options: LinkOptions }
348
+
349
+ export function Link(options: LinkOptions = {}): LinkDescriptor {
350
+ return { type: Types.Link, options }
351
+ }
352
+
353
+ type MarginSide = { value: number; unit: 'px' } | 'auto'
354
+
355
+ type Margin = {
356
+ [K in 'top' | 'right' | 'bottom' | 'left' as `margin${Capitalize<K>}`]:
357
+ | MarginSide
358
+ | null
359
+ | undefined
360
+ }
361
+
362
+ export type MarginValue = ResponsiveValue<Margin>
363
+
364
+ type MarginOptions = Options<{ preset?: MarginValue }>
365
+
366
+ type MarginDescriptor<_T = MarginValue> = { type: typeof Types.Margin; options: MarginOptions }
367
+
368
+ export function Margin(options: MarginOptions = {}): MarginDescriptor {
369
+ return { type: Types.Margin, options }
370
+ }
371
+
372
+ type ButtonVariant = 'flat' | 'outline' | 'shadow' | 'clear' | 'blocky' | 'bubbly' | 'skewed'
373
+
374
+ type ButtonShape = 'pill' | 'rounded' | 'square'
375
+
376
+ type ButtonSize = 'small' | 'medium' | 'large'
377
+
378
+ type NavigationButton = {
379
+ id: string
380
+ type: 'button'
381
+ payload: {
382
+ label: string
383
+ link?: Link
384
+ variant?: ResponsiveValue<ButtonVariant>
385
+ shape?: ResponsiveValue<ButtonShape>
386
+ size?: ResponsiveValue<ButtonSize>
387
+ textColor?: ResponsiveValue<Color>
388
+ color?: ResponsiveValue<Color>
389
+ textStyle?: ResponsiveValue<TextStyle>
390
+ }
391
+ }
392
+
393
+ type NavigationDropdownCaretType = 'caret' | 'plus' | 'arrow-down' | 'chevron-down'
394
+
395
+ type NavigationDropdownLink = {
396
+ id: string
397
+ payload: {
398
+ label: string
399
+ link?: Link
400
+ color?: ResponsiveValue<Color>
401
+ textStyle?: ResponsiveValue<TextStyle>
402
+ }
403
+ }
404
+
405
+ type NavigationDropdown = {
406
+ id: string
407
+ type: 'dropdown'
408
+ payload: {
409
+ label: string
410
+ caret?: NavigationDropdownCaretType
411
+ links?: NavigationDropdownLink[]
412
+ variant?: ResponsiveValue<ButtonVariant>
413
+ shape?: ResponsiveValue<ButtonShape>
414
+ size?: ResponsiveValue<ButtonSize>
415
+ textColor?: ResponsiveValue<Color>
416
+ color?: ResponsiveValue<Color>
417
+ textStyle?: ResponsiveValue<TextStyle>
418
+ }
419
+ }
420
+
421
+ export type NavigationLinksValue = (NavigationButton | NavigationDropdown)[]
422
+
423
+ type NavigationLinksOptions = Options<Record<string, never>>
424
+
425
+ type NavigationLinksDescriptor<_T = NavigationLinksValue> = {
426
+ type: typeof Types.NavigationLinks
427
+ options: NavigationLinksOptions
428
+ }
429
+
430
+ export function NavigationLinks(options: NavigationLinksOptions = {}): NavigationLinksDescriptor {
431
+ return { type: Types.NavigationLinks, options }
432
+ }
433
+
434
+ export type NumberValue = number
435
+
436
+ type NumberOptions = Options<{
437
+ preset?: NumberValue
438
+ label?: string
439
+ defaultValue?: number
440
+ min?: number
441
+ max?: number
442
+ step?: number
443
+ suffix?: string
444
+ hidden?: boolean
445
+ }>
446
+
447
+ type NumberDescriptor<_T = NumberValue> = { type: typeof Types.Number; options: NumberOptions }
448
+
449
+ export function Number(options: NumberOptions = {}): NumberDescriptor {
450
+ return { type: Types.Number, options }
451
+ }
452
+
453
+ type PaddingSide = { value: number; unit: 'px' }
454
+
455
+ type Padding = {
456
+ [K in 'top' | 'right' | 'bottom' | 'left' as `padding${Capitalize<K>}`]:
457
+ | PaddingSide
458
+ | null
459
+ | undefined
460
+ }
461
+
462
+ export type PaddingValue = ResponsiveValue<Padding>
463
+
464
+ type PaddingOptions = Options<{ preset?: PaddingValue }>
465
+
466
+ type PaddingDescriptor<_T = PaddingValue> = { type: typeof Types.Padding; options: PaddingOptions }
467
+
468
+ export function Padding(options: PaddingOptions = {}): PaddingDescriptor {
469
+ return { type: Types.Padding, options }
470
+ }
471
+
472
+ export type ResponsiveColorValue = ResponsiveValue<Color>
473
+
474
+ type ResponsiveColorOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>
475
+
476
+ type ResponsiveColorDescriptor<_T = ResponsiveColorValue> = {
477
+ type: typeof Types.ResponsiveColor
478
+ options: ResponsiveColorOptions
479
+ }
480
+
481
+ export function ResponsiveColor(options: ResponsiveColorOptions = {}): ResponsiveColorDescriptor {
482
+ return { type: Types.ResponsiveColor, options }
483
+ }
484
+
485
+ type IconRadioGroupOption<T extends string> = { value: T; label: string; icon: IconName }
486
+
487
+ export type ResponsiveIconRadioGroupValue<T extends string> = ResponsiveValue<T>
488
+
489
+ type ResponsiveIconRadioGroupOptions<T extends string, U extends T = T> = Options<{
490
+ label?: string
491
+ options: IconRadioGroupOption<T>[]
492
+ defaultValue?: U
493
+ hidden?: boolean
494
+ }>
495
+
496
+ type ResponsiveIconRadioGroupDescriptor<T extends ResponsiveIconRadioGroupValue<string>> = {
497
+ type: typeof Types.ResponsiveIconRadioGroup
498
+ options: ResponsiveIconRadioGroupOptions<ResponsiveValueType<T>>
499
+ }
500
+
501
+ // HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the
502
+ // values provided would undergo type widening. For some reason, the extra layer of indirection
503
+ // reuslts in TypeScript not widening types. Note, this only happens when the returned value of this
504
+ // function is passed to another as an argument, which is common with the `registerComponent` API.
505
+ export function ResponsiveIconRadioGroup<_T extends string, T extends _T, U extends T>(
506
+ options: ResponsiveIconRadioGroupOptions<T, U>,
507
+ ): ResponsiveIconRadioGroupDescriptor<ResponsiveIconRadioGroupValue<T>> {
508
+ return { type: Types.ResponsiveIconRadioGroup, options }
509
+ }
510
+
511
+ export type ResponsiveLengthValue = ResponsiveValue<Length>
512
+
513
+ type LengthOption =
514
+ | { value: 'px'; label: 'Pixels'; icon: 'Px16' }
515
+ | { value: '%'; label: 'Percentage'; icon: 'Percent16' }
516
+
517
+ type ResponsiveLengthOptions = Options<{
518
+ label?: string
519
+ options?: LengthOption[]
520
+ defaultValue?: Length
521
+ hidden?: boolean
522
+ }>
523
+
524
+ type ResponsiveLengthDescriptor<_T = ResponsiveLengthValue> = {
525
+ type: typeof Types.ResponsiveLength
526
+ options: ResponsiveLengthOptions
527
+ }
528
+
529
+ export function ResponsiveLength(
530
+ options: ResponsiveLengthOptions = {},
531
+ ): ResponsiveLengthDescriptor {
532
+ return { type: Types.ResponsiveLength, options }
533
+ }
534
+
535
+ export type ResponsiveNumberValue = ResponsiveValue<number>
536
+
537
+ type ResponsiveNumberOptions = Options<{
538
+ label?: string
539
+ defaultValue?: number
540
+ min?: number
541
+ max?: number
542
+ step?: number
543
+ suffix?: string
544
+ hidden?: boolean
545
+ }>
546
+
547
+ type ResponsiveNumberDescriptor<_T = ResponsiveNumberValue> = {
548
+ type: typeof Types.ResponsiveNumber
549
+ options: ResponsiveNumberOptions
550
+ }
551
+
552
+ export function ResponsiveNumber(
553
+ options: ResponsiveNumberOptions = {},
554
+ ): ResponsiveNumberDescriptor {
555
+ return { type: Types.ResponsiveNumber, options }
556
+ }
557
+
558
+ export type ResponsiveOpacityValue = ResponsiveValue<number>
559
+
560
+ type ResponsiveOpacityOptions = Options<Record<string, never>>
561
+
562
+ type ResponsiveOpacityDescriptor<_T = ResponsiveOpacityValue> = {
563
+ type: typeof Types.ResponsiveOpacity
564
+ options: ResponsiveOpacityOptions
565
+ }
566
+
567
+ export function ResponsiveOpacity(
568
+ options: ResponsiveOpacityOptions = {},
569
+ ): ResponsiveOpacityDescriptor {
570
+ return { type: Types.ResponsiveOpacity, options }
571
+ }
572
+
573
+ export type ResponsiveSelectValue<T extends string> = ResponsiveValue<T>
574
+
575
+ type SelectLabelOrientation = 'vertical' | 'horizontal'
576
+
577
+ type SelectOption<T extends string> = { value: T; label: string }
578
+
579
+ type ResponsiveSelectOptions<T extends string, U extends T = T> = Options<{
580
+ label?: string
581
+ labelOrientation?: SelectLabelOrientation
582
+ options: SelectOption<T>[]
583
+ defaultValue?: U
584
+ hidden?: boolean
585
+ }>
586
+
587
+ type ResponsiveSelectDescriptor<T extends ResponsiveSelectValue<string>> = {
588
+ type: typeof Types.ResponsiveSelect
589
+ options: ResponsiveSelectOptions<ResponsiveValueType<T>>
590
+ }
591
+
592
+ // HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the
593
+ // values provided would undergo type widening. For some reason, the extra layer of indirection
594
+ // reuslts in TypeScript not widening types. Note, this only happens when the returned value of this
595
+ // function is passed to another as an argument, which is common with the `registerComponent` API.
596
+ export function ResponsiveSelect<_T extends string, T extends _T, U extends T>(
597
+ options: ResponsiveSelectOptions<T, U>,
598
+ ): ResponsiveSelectDescriptor<ResponsiveSelectValue<T>> {
599
+ return { type: Types.ResponsiveSelect, options }
600
+ }
601
+
602
+ export type RichTextValue = IndexSignatureHack<Slate.ValueJSON>
603
+
604
+ type RichTextOptions = Options<{ preset?: RichTextValue }>
605
+
606
+ type RichTextDescriptor<_T extends Data = RichTextValue> = {
607
+ type: typeof Types.RichText
608
+ options: RichTextOptions
609
+ }
610
+
611
+ export function RichText(options: RichTextOptions = {}): RichTextDescriptor {
612
+ return { type: Types.RichText, options }
613
+ }
614
+
615
+ type Shadow = {
616
+ color?: Color | null
617
+ blurRadius?: number
618
+ spreadRadius?: number
619
+ offsetX?: number
620
+ offsetY?: number
621
+ inset?: boolean
622
+ }
623
+
624
+ type Shadows = { id: string; payload: Shadow }[]
625
+
626
+ export type ShadowsValue = ResponsiveValue<Shadows>
627
+
628
+ type ShadowsOptions = Options<Record<string, never>>
629
+
630
+ type ShadowsDescriptor<_T = ShadowsValue> = { type: typeof Types.Shadows; options: ShadowsOptions }
631
+
632
+ export function Shadows(options: ShadowsOptions = {}): ShadowsDescriptor {
633
+ return { type: Types.Shadows, options }
634
+ }
635
+
636
+ type SocialLinkType =
637
+ | 'angellist'
638
+ | 'codepen'
639
+ | 'dribbble'
640
+ | 'facebook'
641
+ | 'github'
642
+ | 'instagram'
643
+ | 'linkedin'
644
+ | 'medium'
645
+ | 'pinterest'
646
+ | 'reddit'
647
+ | 'rss'
648
+ | 'snapchat'
649
+ | 'soundcloud'
650
+ | 'spotify'
651
+ | 'telegram'
652
+ | 'tumblr'
653
+ | 'twitch'
654
+ | 'twitter'
655
+ | 'vimeo'
656
+ | 'whatsapp'
657
+ | 'yelp'
658
+ | 'youtube'
659
+
660
+ type SocialLink = { type: SocialLinkType; url: string }
661
+
662
+ type SocialLinksLink = { id: string; payload: SocialLink }
663
+
664
+ export type SocialLinksValue = { links: SocialLinksLink[]; openInNewTab: boolean }
665
+
666
+ type SocialLinksOptions = Options<{ preset?: SocialLinksValue }>
667
+
668
+ type SocialLinksDescriptor<_T = SocialLinksValue> = {
669
+ type: typeof Types.SocialLinks
670
+ options: SocialLinksOptions
671
+ }
672
+
673
+ export function SocialLinks(options: SocialLinksOptions = {}): SocialLinksDescriptor {
674
+ return { type: Types.SocialLinks, options }
675
+ }
676
+
677
+ export type TableValue = string
678
+
679
+ type TableOptions = Options<{ preset?: TableValue }>
680
+
681
+ type TableDescriptor<_T = TableValue> = { type: typeof Types.Table; options: TableOptions }
682
+
683
+ export function Table(options: TableOptions = {}): TableDescriptor {
684
+ return { type: Types.Table, options }
685
+ }
686
+
687
+ type TableFormField = {
688
+ id: string
689
+ tableColumnId: string
690
+ label?: string
691
+ placeholder?: string
692
+ defaultValue?: string | boolean | string[]
693
+ required?: boolean
694
+ hidden?: boolean
695
+ type?: 'select' | 'radio'
696
+ hideLabel?: boolean
697
+ autofill?: boolean
698
+ }
699
+
700
+ type Grid = { count: number; spans: number[][] }
701
+
702
+ export type TableFormFieldsValue = { fields: TableFormField[]; grid: ResponsiveValue<Grid> }
703
+
704
+ type TableFormFieldsOptions = Options<{ preset?: TableFormFieldsValue }>
705
+
706
+ type TableFormFieldsDescriptor<_T = TableFormFieldsValue> = {
707
+ type: typeof Types.TableFormFields
708
+ options: TableFormFieldsOptions
709
+ }
710
+
711
+ export function TableFormFields(options: TableFormFieldsOptions = {}): TableFormFieldsDescriptor {
712
+ return { type: Types.TableFormFields, options }
713
+ }
714
+
715
+ export type TextAreaValue = string
716
+
717
+ type TextAreaOptions = Options<{ preset?: TextAreaValue; label?: string; rows?: number }>
718
+
719
+ type TextAreaDescriptor<_T = TextAreaValue> = {
720
+ type: typeof Types.TextArea
721
+ options: TextAreaOptions
722
+ }
723
+
724
+ export function TextArea(options: TextAreaOptions = {}): TextAreaDescriptor {
725
+ return { type: Types.TextArea, options }
726
+ }
727
+
728
+ export type TextInputValue = string
729
+
730
+ type TextInputOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>
731
+
732
+ type TextInputDescriptor<_T = TextInputValue> = {
733
+ type: typeof Types.TextInput
734
+ options: TextInputOptions
735
+ }
736
+
737
+ export function TextInput(options: TextInputOptions = {}): TextInputDescriptor {
738
+ return { type: Types.TextInput, options }
739
+ }
740
+
741
+ export type TextStyleValue = ResponsiveValue<TextStyle>
742
+
743
+ type TextStyleOptions = Options<{ preset?: TextStyleValue; label?: string; hidden?: boolean }>
744
+
745
+ type TextStyleDescriptor<_T = TextStyleValue> = {
746
+ type: typeof Types.TextStyle
747
+ options: TextStyleOptions
748
+ }
749
+
750
+ export function TextStyle(options: TextStyleOptions = {}): TextStyleDescriptor {
751
+ return { type: Types.TextStyle, options }
752
+ }
753
+
754
+ type Video = {
755
+ url?: string
756
+ muted?: boolean
757
+ playing?: boolean
758
+ loop?: boolean
759
+ controls?: boolean
760
+ }
761
+
762
+ export type VideoValue = Video
763
+
764
+ type VideoOptions = Options<{ preset?: VideoValue }>
765
+
766
+ type VideoDescriptor<_T = VideoValue> = { type: typeof Types.Video; options: VideoOptions }
767
+
768
+ export function Video(options: VideoOptions = {}): VideoDescriptor {
769
+ return { type: Types.Video, options }
770
+ }
771
+
772
+ export type WidthValue = ResponsiveValue<Length>
773
+
774
+ type WidthOptions = Options<{ preset?: WidthValue; defaultValue?: Length }>
775
+
776
+ type WidthDescriptor<_T = WidthValue> = { type: typeof Types.Width; options: WidthOptions }
777
+
778
+ export function Width(options: WidthOptions = {}): WidthDescriptor {
779
+ return { type: Types.Width, options }
780
+ }
781
+
782
+ export type Descriptor<T extends Data = Data> =
783
+ | BackgroundsDescriptor<T>
784
+ | BorderDescriptor<T>
785
+ | BorderRadiusDescriptor<T>
786
+ | CheckboxDescriptor<T>
787
+ | DateDescriptor<T>
788
+ | ElementIDDescriptor<T>
789
+ | FontDescriptor<T>
790
+ | GapXDescriptor<T>
791
+ | GapYDescriptor<T>
792
+ | GridDescriptor<T>
793
+ | ImageDescriptor<T>
794
+ | ImagesDescriptor<T>
795
+ | LinkDescriptor<T>
796
+ | MarginDescriptor<T>
797
+ | NavigationLinksDescriptor<T>
798
+ | NumberDescriptor<T>
799
+ | PaddingDescriptor<T>
800
+ | ResponsiveColorDescriptor<T>
801
+ | ResponsiveIconRadioGroupDescriptor<
802
+ T extends ResponsiveIconRadioGroupValue<string> ? T : ResponsiveIconRadioGroupValue<string>
803
+ >
804
+ | ResponsiveLengthDescriptor<T>
805
+ | ResponsiveNumberDescriptor<T>
806
+ | ResponsiveOpacityDescriptor<T>
807
+ | ResponsiveSelectDescriptor<
808
+ T extends ResponsiveSelectValue<string> ? T : ResponsiveSelectValue<string>
809
+ >
810
+ | RichTextDescriptor<T>
811
+ | ShadowsDescriptor<T>
812
+ | SocialLinksDescriptor<T>
813
+ | TableDescriptor<T>
814
+ | TableFormFieldsDescriptor<T>
815
+ | TextAreaDescriptor<T>
816
+ | TextInputDescriptor<T>
817
+ | TextStyleDescriptor<T>
818
+ | VideoDescriptor<T>
819
+ | WidthDescriptor<T>
820
+
821
+ export type DescriptorValueType<T extends Descriptor> = T extends Descriptor<infer U> ? U : never