@makeswift/runtime 0.0.0-602aed3 → 0.0.0-67a73fb

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.
@@ -59,4 +59,12 @@ exports.cssTextStyle = react.cssTextStyle;
59
59
  exports.cssWidth = react.cssWidth;
60
60
  exports.registerBuiltinComponents = react.registerBuiltinComponents;
61
61
  exports.registerComponent = react.registerComponent;
62
+ exports.useBackgrounds = react.useBackgrounds;
63
+ exports.useBorder = react.useBorder;
64
+ exports.useBoxShadow = react.useBoxShadow;
65
+ exports.useColor = react.useColor;
66
+ exports.useFile = react.useFile;
67
+ exports.useMediaQuery = react.useMediaQuery;
68
+ exports.usePage = react.usePage;
69
+ exports.useTable = react.useTable;
62
70
  //# sourceMappingURL=components.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- export { B as Box, c as Button, C as Carousel, d as Countdown, j as DEFAULT_BOX_ANIMATE_DELAY, k as DEFAULT_BOX_ANIMATE_DURATION, i as DEFAULT_BOX_ANIMATE_TYPE, m as DEFAULT_ITEM_ANIMATE_DELAY, n as DEFAULT_ITEM_ANIMATE_DURATION, l as DEFAULT_ITEM_ANIMATE_TYPE, o as DEFAULT_ITEM_STAGGER_DURATION, e as Divider, f as Embed, F as Form, I as Image, N as Navigation, g as Root, S as SocialLinks, T as Text, v as cssBorder, w as cssBorderRadius, x as cssBoxShadow, y as cssGridItem, s as cssMargin, p as cssMediaRules, t as cssPadding, z as cssTextStyle, q as cssWidth, r as registerBuiltinComponents, h as registerComponent } from "./react.es2.js";
1
+ export { B as Box, c as Button, C as Carousel, d as Countdown, j as DEFAULT_BOX_ANIMATE_DELAY, k as DEFAULT_BOX_ANIMATE_DURATION, i as DEFAULT_BOX_ANIMATE_TYPE, m as DEFAULT_ITEM_ANIMATE_DELAY, n as DEFAULT_ITEM_ANIMATE_DURATION, l as DEFAULT_ITEM_ANIMATE_TYPE, o as DEFAULT_ITEM_STAGGER_DURATION, e as Divider, f as Embed, F as Form, I as Image, N as Navigation, g as Root, S as SocialLinks, T as Text, v as cssBorder, w as cssBorderRadius, x as cssBoxShadow, y as cssGridItem, s as cssMargin, p as cssMediaRules, t as cssPadding, z as cssTextStyle, q as cssWidth, r as registerBuiltinComponents, h as registerComponent, A as useBackgrounds, G as useBorder, H as useBoxShadow, J as useColor, K as useFile, L as useMediaQuery, M as usePage, O as useTable } from "./react.es2.js";
2
2
  import "react";
3
3
  import "use-sync-external-store/shim/with-selector";
4
4
  import "@apollo/client";
@@ -42,19 +42,52 @@ function deserializeFunction(serializedFunction) {
42
42
  });
43
43
  };
44
44
  }
45
+ function serializeShapeControl(control) {
46
+ const { type } = control.options;
47
+ const transferables = [];
48
+ const serializedType = {};
49
+ Object.entries(type).forEach(([key, control2]) => {
50
+ const [serializedControl, serializedControlTransferables] = serializeControl(control2);
51
+ serializedType[key] = serializedControl;
52
+ transferables.push(...serializedControlTransferables);
53
+ });
54
+ return [__spreadProps(__spreadValues({}, control), { options: __spreadProps(__spreadValues({}, control.options), { type: serializedType }) }), transferables];
55
+ }
56
+ function deserializeShapeControl(control) {
57
+ const { type } = control.options;
58
+ const deserializedType = {};
59
+ Object.entries(type).forEach(([key, control2]) => {
60
+ deserializedType[key] = deserializeControl(control2);
61
+ });
62
+ return __spreadProps(__spreadValues({}, control), { options: __spreadProps(__spreadValues({}, control.options), { type: deserializedType }) });
63
+ }
45
64
  function serializeListControl(control) {
46
- const { getItemLabel } = control.options;
65
+ const { type, getItemLabel } = control.options;
66
+ const transferables = [];
67
+ const [serializedType, serializedTypeTransferables] = serializeControl(type);
47
68
  const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel);
69
+ transferables.push(...serializedTypeTransferables);
70
+ if (serializedGetItemLabel != null)
71
+ transferables.push(serializedGetItemLabel);
48
72
  return [
49
- __spreadProps(__spreadValues({}, control), { options: __spreadProps(__spreadValues({}, control.options), { getItemLabel: serializedGetItemLabel }) }),
50
- serializedGetItemLabel == null ? [] : [serializedGetItemLabel]
73
+ __spreadProps(__spreadValues({}, control), {
74
+ options: __spreadProps(__spreadValues({}, control.options), {
75
+ type: serializedType,
76
+ getItemLabel: serializedGetItemLabel
77
+ })
78
+ }),
79
+ transferables
51
80
  ];
52
81
  }
53
82
  function deserializeListControl(serializedControl) {
54
- const { getItemLabel } = serializedControl.options;
83
+ const { type, getItemLabel } = serializedControl.options;
84
+ const deserializedType = deserializeControl(type);
55
85
  const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel);
56
86
  return __spreadProps(__spreadValues({}, serializedControl), {
57
- options: __spreadProps(__spreadValues({}, serializedControl.options), { getItemLabel: deserializedGetItemLabel })
87
+ options: __spreadProps(__spreadValues({}, serializedControl.options), {
88
+ type: deserializedType,
89
+ getItemLabel: deserializedGetItemLabel
90
+ })
58
91
  });
59
92
  }
60
93
  function serializeTypeaheadControl(control) {
@@ -76,6 +109,8 @@ function serializeControl(control) {
76
109
  switch (control.type) {
77
110
  case descriptors.Types.List:
78
111
  return serializeListControl(control);
112
+ case descriptors.Types.Shape:
113
+ return serializeShapeControl(control);
79
114
  case descriptors.Types.Typeahead:
80
115
  return serializeTypeaheadControl(control);
81
116
  default:
@@ -86,6 +121,8 @@ function deserializeControl(serializedControl) {
86
121
  switch (serializedControl.type) {
87
122
  case descriptors.Types.List:
88
123
  return deserializeListControl(serializedControl);
124
+ case descriptors.Types.Shape:
125
+ return deserializeShapeControl(serializedControl);
89
126
  case descriptors.Types.Typeahead:
90
127
  return deserializeTypeaheadControl(serializedControl);
91
128
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"control-serialization.cjs.js","sources":["../src/builder/serialization/function-serialization.ts","../src/builder/serialization/control-serialization.ts"],"sourcesContent":["declare const SerializedFunctionTag: unique symbol\n\ntype AnyFunction = (...args: any) => any\n\nexport type SerializedFunction<T extends AnyFunction> = MessagePort & {\n readonly [SerializedFunctionTag]: T\n}\n\ntype SerializedFunctionReturnType<T extends AnyFunction> = Awaited<ReturnType<T>>\n\nexport type DeserializedFunction<T extends AnyFunction> = (\n ...args: Parameters<T>\n) => Promise<SerializedFunctionReturnType<T>>\n\ntype CallID = number\n\nexport function serializeFunction<T extends AnyFunction>(func: T): SerializedFunction<T> {\n type CallMessageEvent = MessageEvent<[CallID, Parameters<T>]>\n\n const messageChannel = new MessageChannel()\n\n messageChannel.port1.onmessage = ({ data: [callId, args] }: CallMessageEvent) => {\n Promise.resolve()\n .then(() => func.apply(null, args))\n .then(result => messageChannel.port1.postMessage([callId, result]))\n }\n\n return messageChannel.port2 as SerializedFunction<T>\n}\n\nexport function deserializeFunction<T extends AnyFunction>(\n serializedFunction: SerializedFunction<T>,\n): DeserializedFunction<T> {\n type Result = SerializedFunctionReturnType<T>\n type ResultMessageEvent = MessageEvent<[CallID, Result]>\n type ResolveCallPromise = (value: Result | PromiseLike<Result>) => void\n\n let nextCallId = 0\n const calls = new Map<CallID, ResolveCallPromise>()\n\n serializedFunction.onmessage = ({ data: [callId, result] }: ResultMessageEvent) => {\n calls.get(callId)?.(result)\n\n calls.delete(callId)\n }\n\n return function deserializedFunction(...args) {\n return new Promise(resolve => {\n const callId = nextCallId++\n\n calls.set(callId, resolve)\n\n serializedFunction.postMessage([callId, args])\n })\n }\n}\n\nif (import.meta.vitest) {\n const { describe, test, expect } = import.meta.vitest\n\n describe.concurrent('serializeFunction & deserializeFunction', () => {\n test('simple call', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const result = await add(2, 2)\n\n // Assert\n expect(result).toBe(4)\n })\n\n test('multiple synchronous calls', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const results = await Promise.all(Array.from({ length: 5 }, (_, i) => add(1, i)))\n\n // Assert\n expect(results).toEqual([1, 2, 3, 4, 5])\n })\n })\n}\n","import {\n Data,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n PanelDescriptor,\n PropControllerDescriptor as Control,\n Props as Controls,\n} from '../../prop-controllers'\nimport {\n DeserializedFunction,\n deserializeFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\ntype SerializedListControlConfig<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: SerializedListControlConfig<T[number]['value']>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { getItemLabel } = control.options\n\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n return [\n { ...control, options: { ...control.options, getItemLabel: serializedGetItemLabel } },\n serializedGetItemLabel == null ? [] : [serializedGetItemLabel],\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: DeserializedListControlConfig<T[number]['value']>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { getItemLabel } = serializedControl.options\n\n const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItemLabel: deserializedGetItemLabel },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = getItems && deserializeFunction(getItems)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\nexport type SerializedControl =\n | Exclude<Control, ListControl | TypeaheadControl>\n | SerializedListControl\n | SerializedTypeaheadControl\n\nexport type DeserializedControl =\n | Exclude<Control, ListControl | TypeaheadControl>\n | DeserializedListControl\n | DeserializedTypeaheadControl\n\nfunction serializeControl(control: Control): [SerializedControl, Transferable[]] {\n switch (control.type) {\n case Controls.Types.List:\n return serializeListControl(control)\n\n case Controls.Types.Typeahead:\n return serializeTypeaheadControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction deserializeControl(serializedControl: SerializedControl): DeserializedControl {\n switch (serializedControl.type) {\n case Controls.Types.List:\n return deserializeListControl(serializedControl)\n\n case Controls.Types.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport function serializeControls(\n controls: Record<string, Control>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, SerializedControl>,\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n return { ...deserializedControls, [key]: deserializeControl(serializedControl) }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"names":["Controls.Types"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBO,2BAAkD,MAAgC;AAGjF,QAAA,iBAAiB,IAAI;AAE3B,iBAAe,MAAM,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,YAA8B;AAC/E,YAAQ,QACL,EAAA,KAAK,MAAM,KAAK,MAAM,MAAM,IAAI,CAAC,EACjC,KAAK,CAAA,WAAU,eAAe,MAAM,YAAY,CAAC,QAAQ,MAAM,CAAC,CAAC;AAAA,EAAA;AAGtE,SAAO,eAAe;AACxB;AAEO,6BACL,oBACyB;AAKzB,MAAI,aAAa;AACX,QAAA,4BAAY;AAElB,qBAAmB,YAAY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AAYA,0BAA0B,SAAuD;AAC/E,UAAQ,QAAQ;AAAA,SACTA,YAAe,MAAA;AAClB,aAAO,qBAAqB,OAAO;AAAA,SAEhCA,YAAe,MAAA;AAClB,aAAO,0BAA0B,OAAO;AAAA;AAGjC,aAAA,CAAC,SAAS,CAAA,CAAE;AAAA;AAEzB;AAEA,4BAA4B,mBAA2D;AACrF,UAAQ,kBAAkB;AAAA,SACnBA,YAAe,MAAA;AAClB,aAAO,uBAAuB,iBAAiB;AAAA,SAE5CA,YAAe,MAAA;AAClB,aAAO,4BAA4B,iBAAiB;AAAA;AAG7C,aAAA;AAAA;AAEb;AAEO,2BACL,UACqD;AAC9C,SAAA,OAAO,QAAQ,QAAQ,EAAE,OAC9B,CAAC,CAAC,aAAa,mBAAmB,CAAC,KAAK,aAAa;AACnD,UAAM,CAAC,mBAAmB,iBAAiB,iBAAiB,OAAO;AAE5D,WAAA,CAAC,iCAAK,cAAL,GAAmB,MAAM,sBAAqB,CAAC,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAAA,EAAA,GAE/F,CAAC,CAAA,GAAI,CAAE,CAAA,CACT;AACF;AAEO,6BACL,oBACqC;AAC9B,SAAA,OAAO,QAAQ,kBAAkB,EAAE,OACxC,CAAC,sBAAsB,CAAC,KAAK,uBAAuB;AAClD,WAAO,iCAAK,uBAAL,GAA4B,MAAM,mBAAmB,iBAAiB;EAC/E,GACA,CACF,CAAA;AACF;;;;;"}
1
+ {"version":3,"file":"control-serialization.cjs.js","sources":["../src/builder/serialization/function-serialization.ts","../src/builder/serialization/control-serialization.ts"],"sourcesContent":["declare const SerializedFunctionTag: unique symbol\n\ntype AnyFunction = (...args: any) => any\n\nexport type SerializedFunction<T extends AnyFunction> = MessagePort & {\n readonly [SerializedFunctionTag]: T\n}\n\ntype SerializedFunctionReturnType<T extends AnyFunction> = Awaited<ReturnType<T>>\n\nexport type DeserializedFunction<T extends AnyFunction> = (\n ...args: Parameters<T>\n) => Promise<SerializedFunctionReturnType<T>>\n\ntype CallID = number\n\nexport function serializeFunction<T extends AnyFunction>(func: T): SerializedFunction<T> {\n type CallMessageEvent = MessageEvent<[CallID, Parameters<T>]>\n\n const messageChannel = new MessageChannel()\n\n messageChannel.port1.onmessage = ({ data: [callId, args] }: CallMessageEvent) => {\n Promise.resolve()\n .then(() => func.apply(null, args))\n .then(result => messageChannel.port1.postMessage([callId, result]))\n }\n\n return messageChannel.port2 as SerializedFunction<T>\n}\n\nexport function deserializeFunction<T extends AnyFunction>(\n serializedFunction: SerializedFunction<T>,\n): DeserializedFunction<T> {\n type Result = SerializedFunctionReturnType<T>\n type ResultMessageEvent = MessageEvent<[CallID, Result]>\n type ResolveCallPromise = (value: Result | PromiseLike<Result>) => void\n\n let nextCallId = 0\n const calls = new Map<CallID, ResolveCallPromise>()\n\n serializedFunction.onmessage = ({ data: [callId, result] }: ResultMessageEvent) => {\n calls.get(callId)?.(result)\n\n calls.delete(callId)\n }\n\n return function deserializedFunction(...args) {\n return new Promise(resolve => {\n const callId = nextCallId++\n\n calls.set(callId, resolve)\n\n serializedFunction.postMessage([callId, args])\n })\n }\n}\n\nif (import.meta.vitest) {\n const { describe, test, expect } = import.meta.vitest\n\n describe.concurrent('serializeFunction & deserializeFunction', () => {\n test('simple call', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const result = await add(2, 2)\n\n // Assert\n expect(result).toBe(4)\n })\n\n test('multiple synchronous calls', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const results = await Promise.all(Array.from({ length: 5 }, (_, i) => add(1, i)))\n\n // Assert\n expect(results).toEqual([1, 2, 3, 4, 5])\n })\n })\n}\n","import {\n Data,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n ShapeDescriptor as ShapeControl,\n ShapeValue as ShapeControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n PanelDescriptor as PanelControl,\n PanelDescriptorType as PanelControlType,\n PanelDescriptorValueType as PanelControlValueType,\n PropControllerDescriptor as Control,\n Props as Controls,\n} from '../../prop-controllers'\nimport {\n DeserializedFunction,\n deserializeFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\ntype SerializedShapeControlConfig<T extends Record<string, SerializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: SerializedPanelControlValueType<T[K]> }\n}\n\ntype SerializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n> = {\n type: typeof Controls.Types.Shape\n options: SerializedShapeControlConfig<U>\n}\n\nfunction serializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, PanelControl>,\n>(\n control: ShapeControl<T, U>,\n): [\n SerializedShapeControl<\n T,\n { [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>> }\n >,\n Transferable[],\n] {\n const { type } = control.options\n const transferables: Transferable[] = []\n const serializedType = {} as {\n [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n const [serializedControl, serializedControlTransferables] = serializeControl(control)\n\n serializedType[key as keyof typeof type] = serializedControl as SerializedPanelControl\n transferables.push(...serializedControlTransferables)\n })\n\n // @ts-expect-error: preset types are incompatible\n return [{ ...control, options: { ...control.options, type: serializedType } }, transferables]\n}\n\ntype DeserializedShapeControlConfig<T extends Record<string, DeserializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: DeserializedPanelControlValueType<T[K]> }\n}\n\ntype DeserializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, DeserializedPanelControl>,\n> = {\n type: typeof Controls.Types.Shape\n options: DeserializedShapeControlConfig<U>\n}\n\nfunction deserializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n>(\n control: SerializedShapeControl<T, U>,\n): DeserializedShapeControl<\n T,\n { [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>> }\n> {\n const { type } = control.options\n const deserializedType = {} as {\n [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n deserializedType[key as keyof typeof type] = deserializeControl(\n control,\n ) as DeserializedPanelControl\n })\n\n // @ts-expect-error: preset types are incompatible\n return { ...control, options: { ...control.options, type: deserializedType } }\n}\n\ntype SerializedListControlConfig<T extends Data> = {\n type: SerializedPanelControl<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: SerializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { type, getItemLabel } = control.options\n const transferables: Transferable[] = []\n\n const [serializedType, serializedTypeTransferables] = serializeControl(type)\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n transferables.push(...serializedTypeTransferables)\n if (serializedGetItemLabel != null) transferables.push(serializedGetItemLabel)\n\n return [\n {\n ...control,\n options: {\n ...control.options,\n type: serializedType as SerializedPanelControl,\n getItemLabel: serializedGetItemLabel,\n },\n },\n transferables,\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: DeserializedPanelControl<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: DeserializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { type, getItemLabel } = serializedControl.options\n\n const deserializedType = deserializeControl(type) as DeserializedPanelControl\n const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel)\n\n return {\n ...serializedControl,\n options: {\n ...serializedControl.options,\n type: deserializedType,\n getItemLabel: deserializedGetItemLabel,\n },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = getItems && deserializeFunction(getItems)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\nexport type SerializedControl<T extends Data = Data> =\n | Exclude<\n Control<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n >\n | SerializedListControl<T extends ListControlValue ? T : ListControlValue>\n | SerializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | SerializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n\ntype SerializedPanelControl<T extends Data = Data> = Extract<\n SerializedControl<T>,\n { type: PanelControlType }\n>\n\ntype SerializedPanelControlValueType<T extends SerializedPanelControl> =\n T extends SerializedPanelControl<infer U> ? U : never\n\nexport type DeserializedControl<T extends Data = Data> =\n | Exclude<\n Control<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n >\n | DeserializedListControl<T extends ListControlValue ? T : ListControlValue>\n | DeserializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | DeserializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n\ntype DeserializedPanelControl<T extends Data = Data> = Extract<\n DeserializedControl<T>,\n { type: PanelControlType }\n>\n\ntype DeserializedPanelControlValueType<T extends DeserializedPanelControl> =\n T extends DeserializedPanelControl<infer U> ? U : never\n\nfunction serializeControl<T extends Data>(\n control: Control<T>,\n): [SerializedControl<T>, Transferable[]] {\n switch (control.type) {\n case Controls.Types.List:\n return serializeListControl(control)\n\n case Controls.Types.Shape:\n return serializeShapeControl(control)\n\n case Controls.Types.Typeahead:\n return serializeTypeaheadControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n): DeserializedControl<T> {\n switch (serializedControl.type) {\n case Controls.Types.List:\n return deserializeListControl(serializedControl)\n\n case Controls.Types.Shape:\n return deserializeShapeControl(serializedControl)\n\n case Controls.Types.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport function serializeControls(\n controls: Record<string, Control>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, SerializedControl>,\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n return { ...deserializedControls, [key]: deserializeControl(serializedControl) }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"names":["Controls.Types"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBO,2BAAkD,MAAgC;AAGjF,QAAA,iBAAiB,IAAI;AAE3B,iBAAe,MAAM,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,YAA8B;AAC/E,YAAQ,QACL,EAAA,KAAK,MAAM,KAAK,MAAM,MAAM,IAAI,CAAC,EACjC,KAAK,CAAA,WAAU,eAAe,MAAM,YAAY,CAAC,QAAQ,MAAM,CAAC,CAAC;AAAA,EAAA;AAGtE,SAAO,eAAe;AACxB;AAEO,6BACL,oBACyB;AAKzB,MAAI,aAAa;AACX,QAAA,4BAAY;AAElB,qBAAmB,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,cAAkC;;AAC3E,gBAAA,IAAI,MAAM,MAAV,mBAAc;AAEpB,UAAM,OAAO,MAAM;AAAA,EAAA;AAGrB,SAAO,iCAAiC,MAAM;AACrC,WAAA,IAAI,QAAQ,CAAW,YAAA;AAC5B,YAAM,SAAS;AAET,YAAA,IAAI,QAAQ,OAAO;AAEzB,yBAAmB,YAAY,CAAC,QAAQ,IAAI,CAAC;AAAA,IAAA,CAC9C;AAAA,EAAA;AAEL;ACnBA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,WAAA,CAAC,iCAAK,cAAL,GAAmB,MAAM,sBAAqB,CAAC,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAAA,EAAA,GAE/F,CAAC,CAAA,GAAI,CAAE,CAAA,CACT;AACF;AAEO,6BACL,oBACqC;AAC9B,SAAA,OAAO,QAAQ,kBAAkB,EAAE,OACxC,CAAC,sBAAsB,CAAC,KAAK,uBAAuB;AAClD,WAAO,iCAAK,uBAAL,GAA4B,MAAM,mBAAmB,iBAAiB;EAC/E,GACA,CACF,CAAA;AACF;;;;;"}
@@ -41,19 +41,52 @@ function deserializeFunction(serializedFunction) {
41
41
  });
42
42
  };
43
43
  }
44
+ function serializeShapeControl(control) {
45
+ const { type } = control.options;
46
+ const transferables = [];
47
+ const serializedType = {};
48
+ Object.entries(type).forEach(([key, control2]) => {
49
+ const [serializedControl, serializedControlTransferables] = serializeControl(control2);
50
+ serializedType[key] = serializedControl;
51
+ transferables.push(...serializedControlTransferables);
52
+ });
53
+ return [__spreadProps(__spreadValues({}, control), { options: __spreadProps(__spreadValues({}, control.options), { type: serializedType }) }), transferables];
54
+ }
55
+ function deserializeShapeControl(control) {
56
+ const { type } = control.options;
57
+ const deserializedType = {};
58
+ Object.entries(type).forEach(([key, control2]) => {
59
+ deserializedType[key] = deserializeControl(control2);
60
+ });
61
+ return __spreadProps(__spreadValues({}, control), { options: __spreadProps(__spreadValues({}, control.options), { type: deserializedType }) });
62
+ }
44
63
  function serializeListControl(control) {
45
- const { getItemLabel } = control.options;
64
+ const { type, getItemLabel } = control.options;
65
+ const transferables = [];
66
+ const [serializedType, serializedTypeTransferables] = serializeControl(type);
46
67
  const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel);
68
+ transferables.push(...serializedTypeTransferables);
69
+ if (serializedGetItemLabel != null)
70
+ transferables.push(serializedGetItemLabel);
47
71
  return [
48
- __spreadProps(__spreadValues({}, control), { options: __spreadProps(__spreadValues({}, control.options), { getItemLabel: serializedGetItemLabel }) }),
49
- serializedGetItemLabel == null ? [] : [serializedGetItemLabel]
72
+ __spreadProps(__spreadValues({}, control), {
73
+ options: __spreadProps(__spreadValues({}, control.options), {
74
+ type: serializedType,
75
+ getItemLabel: serializedGetItemLabel
76
+ })
77
+ }),
78
+ transferables
50
79
  ];
51
80
  }
52
81
  function deserializeListControl(serializedControl) {
53
- const { getItemLabel } = serializedControl.options;
82
+ const { type, getItemLabel } = serializedControl.options;
83
+ const deserializedType = deserializeControl(type);
54
84
  const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel);
55
85
  return __spreadProps(__spreadValues({}, serializedControl), {
56
- options: __spreadProps(__spreadValues({}, serializedControl.options), { getItemLabel: deserializedGetItemLabel })
86
+ options: __spreadProps(__spreadValues({}, serializedControl.options), {
87
+ type: deserializedType,
88
+ getItemLabel: deserializedGetItemLabel
89
+ })
57
90
  });
58
91
  }
59
92
  function serializeTypeaheadControl(control) {
@@ -75,6 +108,8 @@ function serializeControl(control) {
75
108
  switch (control.type) {
76
109
  case Types.List:
77
110
  return serializeListControl(control);
111
+ case Types.Shape:
112
+ return serializeShapeControl(control);
78
113
  case Types.Typeahead:
79
114
  return serializeTypeaheadControl(control);
80
115
  default:
@@ -85,6 +120,8 @@ function deserializeControl(serializedControl) {
85
120
  switch (serializedControl.type) {
86
121
  case Types.List:
87
122
  return deserializeListControl(serializedControl);
123
+ case Types.Shape:
124
+ return deserializeShapeControl(serializedControl);
88
125
  case Types.Typeahead:
89
126
  return deserializeTypeaheadControl(serializedControl);
90
127
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"control-serialization.es.js","sources":["../src/builder/serialization/function-serialization.ts","../src/builder/serialization/control-serialization.ts"],"sourcesContent":["declare const SerializedFunctionTag: unique symbol\n\ntype AnyFunction = (...args: any) => any\n\nexport type SerializedFunction<T extends AnyFunction> = MessagePort & {\n readonly [SerializedFunctionTag]: T\n}\n\ntype SerializedFunctionReturnType<T extends AnyFunction> = Awaited<ReturnType<T>>\n\nexport type DeserializedFunction<T extends AnyFunction> = (\n ...args: Parameters<T>\n) => Promise<SerializedFunctionReturnType<T>>\n\ntype CallID = number\n\nexport function serializeFunction<T extends AnyFunction>(func: T): SerializedFunction<T> {\n type CallMessageEvent = MessageEvent<[CallID, Parameters<T>]>\n\n const messageChannel = new MessageChannel()\n\n messageChannel.port1.onmessage = ({ data: [callId, args] }: CallMessageEvent) => {\n Promise.resolve()\n .then(() => func.apply(null, args))\n .then(result => messageChannel.port1.postMessage([callId, result]))\n }\n\n return messageChannel.port2 as SerializedFunction<T>\n}\n\nexport function deserializeFunction<T extends AnyFunction>(\n serializedFunction: SerializedFunction<T>,\n): DeserializedFunction<T> {\n type Result = SerializedFunctionReturnType<T>\n type ResultMessageEvent = MessageEvent<[CallID, Result]>\n type ResolveCallPromise = (value: Result | PromiseLike<Result>) => void\n\n let nextCallId = 0\n const calls = new Map<CallID, ResolveCallPromise>()\n\n serializedFunction.onmessage = ({ data: [callId, result] }: ResultMessageEvent) => {\n calls.get(callId)?.(result)\n\n calls.delete(callId)\n }\n\n return function deserializedFunction(...args) {\n return new Promise(resolve => {\n const callId = nextCallId++\n\n calls.set(callId, resolve)\n\n serializedFunction.postMessage([callId, args])\n })\n }\n}\n\nif (import.meta.vitest) {\n const { describe, test, expect } = import.meta.vitest\n\n describe.concurrent('serializeFunction & deserializeFunction', () => {\n test('simple call', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const result = await add(2, 2)\n\n // Assert\n expect(result).toBe(4)\n })\n\n test('multiple synchronous calls', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const results = await Promise.all(Array.from({ length: 5 }, (_, i) => add(1, i)))\n\n // Assert\n expect(results).toEqual([1, 2, 3, 4, 5])\n })\n })\n}\n","import {\n Data,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n PanelDescriptor,\n PropControllerDescriptor as Control,\n Props as Controls,\n} from '../../prop-controllers'\nimport {\n DeserializedFunction,\n deserializeFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\ntype SerializedListControlConfig<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: SerializedListControlConfig<T[number]['value']>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { getItemLabel } = control.options\n\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n return [\n { ...control, options: { ...control.options, getItemLabel: serializedGetItemLabel } },\n serializedGetItemLabel == null ? [] : [serializedGetItemLabel],\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: DeserializedListControlConfig<T[number]['value']>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { getItemLabel } = serializedControl.options\n\n const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItemLabel: deserializedGetItemLabel },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = getItems && deserializeFunction(getItems)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\nexport type SerializedControl =\n | Exclude<Control, ListControl | TypeaheadControl>\n | SerializedListControl\n | SerializedTypeaheadControl\n\nexport type DeserializedControl =\n | Exclude<Control, ListControl | TypeaheadControl>\n | DeserializedListControl\n | DeserializedTypeaheadControl\n\nfunction serializeControl(control: Control): [SerializedControl, Transferable[]] {\n switch (control.type) {\n case Controls.Types.List:\n return serializeListControl(control)\n\n case Controls.Types.Typeahead:\n return serializeTypeaheadControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction deserializeControl(serializedControl: SerializedControl): DeserializedControl {\n switch (serializedControl.type) {\n case Controls.Types.List:\n return deserializeListControl(serializedControl)\n\n case Controls.Types.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport function serializeControls(\n controls: Record<string, Control>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, SerializedControl>,\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n return { ...deserializedControls, [key]: deserializeControl(serializedControl) }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"names":["Controls.Types"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBO,2BAAkD,MAAgC;AAGjF,QAAA,iBAAiB,IAAI;AAE3B,iBAAe,MAAM,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,YAA8B;AAC/E,YAAQ,QACL,EAAA,KAAK,MAAM,KAAK,MAAM,MAAM,IAAI,CAAC,EACjC,KAAK,CAAA,WAAU,eAAe,MAAM,YAAY,CAAC,QAAQ,MAAM,CAAC,CAAC;AAAA,EAAA;AAGtE,SAAO,eAAe;AACxB;AAEO,6BACL,oBACyB;AAKzB,MAAI,aAAa;AACX,QAAA,4BAAY;AAElB,qBAAmB,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,cAAkC;;AAC3E,gBAAA,IAAI,MAAM,MAAV,mBAAc;AAEpB,UAAM,OAAO,MAAM;AAAA,EAAA;AAGrB,SAAO,iCAAiC,MAAM;AACrC,WAAA,IAAI,QAAQ,CAAW,YAAA;AAC5B,YAAM,SAAS;AAET,YAAA,IAAI,QAAQ,OAAO;AAEzB,yBAAmB,YAAY,CAAC,QAAQ,IAAI,CAAC;AAAA,IAAA,CAC9C;AAAA,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AAClB,aAAO,4BAA4B,iBAAiB;AAAA;AAG7C,aAAA;AAAA;AAEb;AAEO,2BACL,UACqD;AAC9C,SAAA,OAAO,QAAQ,QAAQ,EAAE,OAC9B,CAAC,CAAC,aAAa,mBAAmB,CAAC,KAAK,aAAa;AACnD,UAAM,CAAC,mBAAmB,iBAAiB,iBAAiB,OAAO;AAE5D,WAAA,CAAC,iCAAK,cAAL,GAAmB,MAAM,sBAAqB,CAAC,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAAA,EAAA,GAE/F,CAAC,CAAA,GAAI,CAAE,CAAA,CACT;AACF;AAEO,6BACL,oBACqC;AAC9B,SAAA,OAAO,QAAQ,kBAAkB,EAAE,OACxC,CAAC,sBAAsB,CAAC,KAAK,uBAAuB;AAClD,WAAO,iCAAK,uBAAL,GAA4B,MAAM,mBAAmB,iBAAiB;EAC/E,GACA,CACF,CAAA;AACF;;"}
1
+ {"version":3,"file":"control-serialization.es.js","sources":["../src/builder/serialization/function-serialization.ts","../src/builder/serialization/control-serialization.ts"],"sourcesContent":["declare const SerializedFunctionTag: unique symbol\n\ntype AnyFunction = (...args: any) => any\n\nexport type SerializedFunction<T extends AnyFunction> = MessagePort & {\n readonly [SerializedFunctionTag]: T\n}\n\ntype SerializedFunctionReturnType<T extends AnyFunction> = Awaited<ReturnType<T>>\n\nexport type DeserializedFunction<T extends AnyFunction> = (\n ...args: Parameters<T>\n) => Promise<SerializedFunctionReturnType<T>>\n\ntype CallID = number\n\nexport function serializeFunction<T extends AnyFunction>(func: T): SerializedFunction<T> {\n type CallMessageEvent = MessageEvent<[CallID, Parameters<T>]>\n\n const messageChannel = new MessageChannel()\n\n messageChannel.port1.onmessage = ({ data: [callId, args] }: CallMessageEvent) => {\n Promise.resolve()\n .then(() => func.apply(null, args))\n .then(result => messageChannel.port1.postMessage([callId, result]))\n }\n\n return messageChannel.port2 as SerializedFunction<T>\n}\n\nexport function deserializeFunction<T extends AnyFunction>(\n serializedFunction: SerializedFunction<T>,\n): DeserializedFunction<T> {\n type Result = SerializedFunctionReturnType<T>\n type ResultMessageEvent = MessageEvent<[CallID, Result]>\n type ResolveCallPromise = (value: Result | PromiseLike<Result>) => void\n\n let nextCallId = 0\n const calls = new Map<CallID, ResolveCallPromise>()\n\n serializedFunction.onmessage = ({ data: [callId, result] }: ResultMessageEvent) => {\n calls.get(callId)?.(result)\n\n calls.delete(callId)\n }\n\n return function deserializedFunction(...args) {\n return new Promise(resolve => {\n const callId = nextCallId++\n\n calls.set(callId, resolve)\n\n serializedFunction.postMessage([callId, args])\n })\n }\n}\n\nif (import.meta.vitest) {\n const { describe, test, expect } = import.meta.vitest\n\n describe.concurrent('serializeFunction & deserializeFunction', () => {\n test('simple call', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const result = await add(2, 2)\n\n // Assert\n expect(result).toBe(4)\n })\n\n test('multiple synchronous calls', async () => {\n // Arrange\n const add = deserializeFunction(serializeFunction((a, b) => a + b))\n\n // Act\n const results = await Promise.all(Array.from({ length: 5 }, (_, i) => add(1, i)))\n\n // Assert\n expect(results).toEqual([1, 2, 3, 4, 5])\n })\n })\n}\n","import {\n Data,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n ShapeDescriptor as ShapeControl,\n ShapeValue as ShapeControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n PanelDescriptor as PanelControl,\n PanelDescriptorType as PanelControlType,\n PanelDescriptorValueType as PanelControlValueType,\n PropControllerDescriptor as Control,\n Props as Controls,\n} from '../../prop-controllers'\nimport {\n DeserializedFunction,\n deserializeFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\ntype SerializedShapeControlConfig<T extends Record<string, SerializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: SerializedPanelControlValueType<T[K]> }\n}\n\ntype SerializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n> = {\n type: typeof Controls.Types.Shape\n options: SerializedShapeControlConfig<U>\n}\n\nfunction serializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, PanelControl>,\n>(\n control: ShapeControl<T, U>,\n): [\n SerializedShapeControl<\n T,\n { [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>> }\n >,\n Transferable[],\n] {\n const { type } = control.options\n const transferables: Transferable[] = []\n const serializedType = {} as {\n [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n const [serializedControl, serializedControlTransferables] = serializeControl(control)\n\n serializedType[key as keyof typeof type] = serializedControl as SerializedPanelControl\n transferables.push(...serializedControlTransferables)\n })\n\n // @ts-expect-error: preset types are incompatible\n return [{ ...control, options: { ...control.options, type: serializedType } }, transferables]\n}\n\ntype DeserializedShapeControlConfig<T extends Record<string, DeserializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: DeserializedPanelControlValueType<T[K]> }\n}\n\ntype DeserializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, DeserializedPanelControl>,\n> = {\n type: typeof Controls.Types.Shape\n options: DeserializedShapeControlConfig<U>\n}\n\nfunction deserializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n>(\n control: SerializedShapeControl<T, U>,\n): DeserializedShapeControl<\n T,\n { [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>> }\n> {\n const { type } = control.options\n const deserializedType = {} as {\n [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n deserializedType[key as keyof typeof type] = deserializeControl(\n control,\n ) as DeserializedPanelControl\n })\n\n // @ts-expect-error: preset types are incompatible\n return { ...control, options: { ...control.options, type: deserializedType } }\n}\n\ntype SerializedListControlConfig<T extends Data> = {\n type: SerializedPanelControl<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: SerializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { type, getItemLabel } = control.options\n const transferables: Transferable[] = []\n\n const [serializedType, serializedTypeTransferables] = serializeControl(type)\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n transferables.push(...serializedTypeTransferables)\n if (serializedGetItemLabel != null) transferables.push(serializedGetItemLabel)\n\n return [\n {\n ...control,\n options: {\n ...control.options,\n type: serializedType as SerializedPanelControl,\n getItemLabel: serializedGetItemLabel,\n },\n },\n transferables,\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: DeserializedPanelControl<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof Controls.Types.List\n options: DeserializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { type, getItemLabel } = serializedControl.options\n\n const deserializedType = deserializeControl(type) as DeserializedPanelControl\n const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel)\n\n return {\n ...serializedControl,\n options: {\n ...serializedControl.options,\n type: deserializedType,\n getItemLabel: deserializedGetItemLabel,\n },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof Controls.Types.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = getItems && deserializeFunction(getItems)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\nexport type SerializedControl<T extends Data = Data> =\n | Exclude<\n Control<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n >\n | SerializedListControl<T extends ListControlValue ? T : ListControlValue>\n | SerializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | SerializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n\ntype SerializedPanelControl<T extends Data = Data> = Extract<\n SerializedControl<T>,\n { type: PanelControlType }\n>\n\ntype SerializedPanelControlValueType<T extends SerializedPanelControl> =\n T extends SerializedPanelControl<infer U> ? U : never\n\nexport type DeserializedControl<T extends Data = Data> =\n | Exclude<\n Control<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n >\n | DeserializedListControl<T extends ListControlValue ? T : ListControlValue>\n | DeserializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | DeserializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n\ntype DeserializedPanelControl<T extends Data = Data> = Extract<\n DeserializedControl<T>,\n { type: PanelControlType }\n>\n\ntype DeserializedPanelControlValueType<T extends DeserializedPanelControl> =\n T extends DeserializedPanelControl<infer U> ? U : never\n\nfunction serializeControl<T extends Data>(\n control: Control<T>,\n): [SerializedControl<T>, Transferable[]] {\n switch (control.type) {\n case Controls.Types.List:\n return serializeListControl(control)\n\n case Controls.Types.Shape:\n return serializeShapeControl(control)\n\n case Controls.Types.Typeahead:\n return serializeTypeaheadControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n): DeserializedControl<T> {\n switch (serializedControl.type) {\n case Controls.Types.List:\n return deserializeListControl(serializedControl)\n\n case Controls.Types.Shape:\n return deserializeShapeControl(serializedControl)\n\n case Controls.Types.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport function serializeControls(\n controls: Record<string, Control>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, SerializedControl>,\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n return { ...deserializedControls, [key]: deserializeControl(serializedControl) }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"names":["Controls.Types"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBO,2BAAkD,MAAgC;AAGjF,QAAA,iBAAiB,IAAI;AAE3B,iBAAe,MAAM,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,YAA8B;AAC/E,YAAQ,QACL,EAAA,KAAK,MAAM,KAAK,MAAM,MAAM,IAAI,CAAC,EACjC,KAAK,CAAA,WAAU,eAAe,MAAM,YAAY,CAAC,QAAQ,MAAM,CAAC,CAAC;AAAA,EAAA;AAGtE,SAAO,eAAe;AACxB;AAEO,6BACL,oBACyB;AAKzB,MAAI,aAAa;AACX,QAAA,4BAAY;AAElB,qBAAmB,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,cAAkC;;AAC3E,gBAAA,IAAI,MAAM,MAAV,mBAAc;AAEpB,UAAM,OAAO,MAAM;AAAA,EAAA;AAGrB,SAAO,iCAAiC,MAAM;AACrC,WAAA,IAAI,QAAQ,CAAW,YAAA;AAC5B,YAAM,SAAS;AAET,YAAA,IAAI,QAAQ,OAAO;AAEzB,yBAAmB,YAAY,CAAC,QAAQ,IAAI,CAAC;AAAA,IAAA,CAC9C;AAAA,EAAA;AAEL;ACnBA,+BAIE,SAOA;AACM,QAAA,EAAE,SAAS,QAAQ;AACzB,QAAM,gBAAgC,CAAA;AACtC,QAAM,iBAAiB,CAAA;AAIvB,SAAO,QAAQ,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,cAAa;AAC/C,UAAM,CAAC,mBAAmB,kCAAkC,iBAAiB,QAAO;AAEpF,mBAAe,OAA4B;AAC7B,kBAAA,KAAK,GAAG,8BAA8B;AAAA,EAAA,CACrD;AAGM,SAAA,CAAC,iCAAK,UAAL,EAAc,SAAS,iCAAK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cjs.js","sources":["../src/prop-controllers/descriptors.ts"],"sourcesContent":["import type * as Slate from 'slate'\nimport type { Element, Data } from '../state/react-page'\n\nexport type { Data }\n\n// See https://github.com/microsoft/TypeScript/issues/15300\nexport type IndexSignatureHack<T> = T extends Record<string, any>\n ? { [K in keyof T]: IndexSignatureHack<T[K]> }\n : T\n\nexport type Device = 'desktop' | 'tablet' | 'mobile'\n\nexport type DeviceOverride<T> = { deviceId: Device; value: T }\n\nexport type ResponsiveValue<T> = DeviceOverride<T>[]\n\nexport type ResponsiveValueType<T> = T extends ResponsiveValue<infer U> ? U : never\n\ntype Color = { swatchId: string; alpha: number }\n\ntype IconName =\n | 'HeightAuto16'\n | 'HeightMatch16'\n | 'VerticalAlignStart16'\n | 'VerticalAlignMiddle16'\n | 'VerticalAlignEnd16'\n | 'VerticalAlignSpaceBetween16'\n | 'ButtonPill16'\n | 'ButtonRounded16'\n | 'ButtonSquare16'\n | 'SizeSmall16'\n | 'SizeMedium16'\n | 'SizeLarge16'\n | 'ArrowInside16'\n | 'ArrowCenter16'\n | 'ArrowOutside16'\n | 'CountdownSolid16'\n | 'CountdownSolidSplit16'\n | 'CountdownOutline16'\n | 'CountdownOutlineSplit16'\n | 'CountdownNaked16'\n | 'Sun16'\n | 'Moon16'\n | 'AlignLeft16'\n | 'AlignCenter16'\n | 'AlignRight16'\n | 'Star16'\n | 'StarCircle16'\n | 'StarRoundedSquare16'\n | 'StarSquare16'\n\ntype Gap = { value: number; unit: 'px' }\n\nexport type Length = { value: number; unit: 'px' | '%' }\n\ntype OpenPageLink = {\n type: 'OPEN_PAGE'\n payload: { pageId: string | null | undefined; openInNewTab: boolean }\n}\n\ntype OpenURLLink = { type: 'OPEN_URL'; payload: { url: string; openInNewTab: boolean } }\n\ntype SendEmailLink = {\n type: 'SEND_EMAIL'\n payload: { to: string; subject?: string; body?: string }\n}\n\ntype CallPhoneLink = { type: 'CALL_PHONE'; payload: { phoneNumber: string } }\n\ntype ScrollToElementLink = {\n type: 'SCROLL_TO_ELEMENT'\n payload: {\n elementIdConfig: { elementKey: string; propName: string } | null | undefined\n block: 'start' | 'center' | 'end'\n }\n}\n\ntype Link = OpenPageLink | OpenURLLink | SendEmailLink | CallPhoneLink | ScrollToElementLink\n\ntype TextStyle = {\n fontFamily?: string | null | undefined\n letterSpacing: number | null | undefined\n fontSize: { value: number; unit: 'px' } | null | undefined\n fontWeight: number | null | undefined\n textTransform: 'uppercase'[]\n fontStyle: 'italic'[]\n}\n\nexport const Types = {\n Backgrounds: 'Backgrounds',\n Border: 'Border',\n BorderRadius: 'BorderRadius',\n Checkbox: 'Checkbox',\n Date: 'Date',\n ElementID: 'ElementID',\n Font: 'Font',\n GapX: 'GapX',\n GapY: 'GapY',\n Grid: 'Grid',\n Image: 'Image',\n Images: 'Images',\n Link: 'Link',\n List: 'List',\n Margin: 'Margin',\n NavigationLinks: 'NavigationLinks',\n Number: 'Number',\n Padding: 'Padding',\n ResponsiveColor: 'ResponsiveColor',\n ResponsiveIconRadioGroup: 'ResponsiveIconRadioGroup',\n ResponsiveLength: 'ResponsiveLength',\n ResponsiveNumber: 'ResponsiveNumber',\n ResponsiveOpacity: 'ResponsiveOpacity',\n ResponsiveSelect: 'ResponsiveSelect',\n RichText: 'RichText',\n Shadows: 'Shadows',\n Shape: 'Shape',\n SocialLinks: 'SocialLinks',\n Table: 'Table',\n TableFormFields: 'TableFormFields',\n Typeahead: 'Typeahead',\n TextArea: 'TextArea',\n TextInput: 'TextInput',\n TextStyle: 'TextStyle',\n Video: 'Video',\n Width: 'Width',\n} as const\n\ntype Options<T> = T | ((props: Record<string, unknown>, decideMode: Device) => T)\n\ntype ColorBackground = { type: 'color'; id: string; payload: Color | null }\n\ntype GradientStop = { id: string; location: number; color: Color | null }\n\ntype Gradient = { angle?: number; isRadial?: boolean; stops: GradientStop[] }\n\ntype GradientBackground = { type: 'gradient'; id: string; payload: Gradient }\n\ntype BackgroundImagePosition = { x: number; y: number }\n\ntype BackgroundImageSize = 'cover' | 'contain' | 'auto'\n\ntype BackgroundImageRepeat = 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat'\n\ntype BackgroundImage = {\n imageId: string\n position: BackgroundImagePosition\n size?: BackgroundImageSize\n repeat?: BackgroundImageRepeat\n opacity?: number\n parallax?: number\n}\n\ntype ImageBackground = { type: 'image'; id: string; payload: BackgroundImage }\n\ntype BackgroundVideoAspectRatio = 'wide' | 'standard'\n\ntype BackgroundVideo = {\n url?: string\n maskColor?: Color | null\n opacity?: number\n zoom?: number\n aspectRatio?: BackgroundVideoAspectRatio\n parallax?: number\n}\n\ntype VideoBackground = { type: 'video'; id: string; payload: BackgroundVideo }\n\ntype Background = ColorBackground | GradientBackground | ImageBackground | VideoBackground\n\nexport type BackgroundsValue = ResponsiveValue<Background[]>\n\ntype BackgroundsOptions = Options<Record<string, never>>\n\ntype BackgroundsDescriptor<_T = BackgroundsValue> = {\n type: typeof Types.Backgrounds\n options: BackgroundsOptions\n}\n\nexport function Backgrounds(options: BackgroundsOptions = {}): BackgroundsDescriptor {\n return { type: Types.Backgrounds, options }\n}\n\ntype BorderSideStyle = 'dashed' | 'dotted' | 'solid'\n\ntype BorderSide = { width: number | null | undefined; style: BorderSideStyle; color?: Color | null }\n\ntype Border = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `border${Capitalize<K>}`]:\n | BorderSide\n | null\n | undefined\n}\n\nexport type BorderValue = ResponsiveValue<Border>\n\ntype BorderOptions = Options<Record<string, never>>\n\ntype BorderDescriptor<_T = BorderValue> = { type: typeof Types.Border; options: BorderOptions }\n\nexport function Border(options: BorderOptions = {}): BorderDescriptor {\n return { type: Types.Border, options }\n}\n\ntype BorderRadius = {\n [K in 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' as `border${Capitalize<K>}Radius`]:\n | Length\n | null\n | undefined\n}\n\nexport type BorderRadiusValue = ResponsiveValue<BorderRadius>\n\ntype BorderRadiusOptions = Options<Record<string, never>>\n\ntype BorderRadiusDescriptor<_T = BorderRadiusValue> = {\n type: typeof Types.BorderRadius\n options: BorderRadiusOptions\n}\n\nexport function BorderRadius(options: BorderRadiusOptions = {}): BorderRadiusDescriptor {\n return { type: Types.BorderRadius, options }\n}\n\nexport type CheckboxValue = boolean\n\ntype CheckboxOptions = Options<{\n preset?: CheckboxValue\n label: string\n hidden?: boolean\n}>\n\ntype CheckboxDescriptor<_T = CheckboxValue> = {\n type: typeof Types.Checkbox\n options: CheckboxOptions\n}\n\nexport function Checkbox(options: CheckboxOptions): CheckboxDescriptor {\n return { type: Types.Checkbox, options }\n}\n\nexport type DateValue = string\n\ntype DateOptions = Options<{ preset?: DateValue }>\n\ntype DateDescriptor<_T = DateValue> = { type: typeof Types.Date; options: DateOptions }\n\nexport function Date(options: DateOptions = {}): DateDescriptor {\n return { type: Types.Date, options }\n}\n\nexport type ElementIDValue = string\n\ntype ElementIDOptions = Options<Record<string, never>>\n\ntype ElementIDDescriptor<_T = ElementIDValue> = {\n type: typeof Types.ElementID\n options: ElementIDOptions\n}\n\nexport function ElementID(options: ElementIDOptions = {}): ElementIDDescriptor {\n return { type: Types.ElementID, options }\n}\n\nexport type FontValue = ResponsiveValue<string>\n\ntype FontOptions = Options<{ preset?: FontValue; label?: string }>\n\ntype FontDescriptor<_T = FontValue> = { type: typeof Types.Font; options: FontOptions }\n\nexport function Font(options: FontOptions = {}): FontDescriptor {\n return { type: Types.Font, options }\n}\n\nexport type GapXValue = ResponsiveValue<Gap>\n\ntype GapXOptions = Options<{\n preset?: GapXValue\n label?: string\n defaultValue?: Gap\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}>\n\ntype GapXDescriptor<_T = GapXValue> = { type: typeof Types.GapX; options: GapXOptions }\n\nexport function GapX(options: GapXOptions = {}): GapXDescriptor {\n return { type: Types.GapX, options }\n}\n\nexport type GapYValue = ResponsiveValue<Gap>\n\ntype GapYOptions = Options<{\n preset?: GapYValue\n label?: string\n defaultValue?: Gap\n step?: number\n min?: number\n max?: number\n hidden?: boolean\n}>\n\ntype GapYDescriptor<_T = GapYValue> = { type: typeof Types.GapY; options: GapYOptions }\n\nexport function GapY(options: GapYOptions = {}): GapYDescriptor {\n return { type: Types.GapY, options }\n}\n\ntype GridColumn = { count: number; spans: number[][] }\n\nexport type GridValue = { elements: Element[]; columns: ResponsiveValue<GridColumn> }\n\ntype GridOptions = Options<Record<string, never>>\n\ntype GridDescriptor<_T = GridValue> = { type: typeof Types.Grid; options: GridOptions }\n\nexport function Grid(options: GridOptions = {}): GridDescriptor {\n return { type: Types.Grid, options }\n}\n\nexport type ImageValue = string\n\ntype ImageOptions = Options<{ label?: string; hidden?: boolean }>\n\ntype ImageDescriptor<_T = ImageValue> = { type: typeof Types.Image; options: ImageOptions }\n\nexport function Image(options: ImageOptions = {}): ImageDescriptor {\n return { type: Types.Image, options }\n}\n\nexport type ImagesValue = { key: string; props: { link?: Link; file?: string; altText?: string } }[]\n\ntype ImagesOptions = Options<{ preset?: ImagesValue }>\n\ntype ImagesDescriptor<_T = ImagesValue> = { type: typeof Types.Images; options: ImagesOptions }\n\nexport function Images(options: ImagesOptions = {}): ImagesDescriptor {\n return { type: Types.Images, options }\n}\n\nexport type LinkValue = Link\n\ntype LinkOptions = Options<{\n preset?: LinkValue\n label?: string\n defaultValue?: Link\n options?: { value: Link['type']; label: string }[]\n hidden?: boolean\n}>\n\ntype LinkDescriptor<_T = LinkValue> = { type: typeof Types.Link; options: LinkOptions }\n\nexport function Link(options: LinkOptions = {}): LinkDescriptor {\n return { type: Types.Link, options }\n}\n\ntype ListValueItem<T extends Data> = { id: string; value?: T }\n\nexport type ListValue<T extends Data = Data> = ListValueItem<T>[]\n\nexport type ListOptions<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: ((value: T | undefined) => string) | ((value: T | undefined) => Promise<string>)\n preset?: ListValue<T>\n defaultValue?: ListValue<T>\n}\n\nexport type ListDescriptor<T extends ListValue = ListValue> = {\n type: typeof Types.List\n options: ListOptions<T extends ListValue<infer U> ? U : never>\n}\n\nexport function List<T extends Data>(options: ListOptions<T>): ListDescriptor<ListValue<T>> {\n return { type: Types.List, options }\n}\n\ntype MarginSide = { value: number; unit: 'px' } | 'auto'\n\ntype Margin = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `margin${Capitalize<K>}`]:\n | MarginSide\n | null\n | undefined\n}\n\nexport type MarginValue = ResponsiveValue<Margin>\n\ntype MarginOptions = Options<{ preset?: MarginValue }>\n\ntype MarginDescriptor<_T = MarginValue> = { type: typeof Types.Margin; options: MarginOptions }\n\nexport function Margin(options: MarginOptions = {}): MarginDescriptor {\n return { type: Types.Margin, options }\n}\n\ntype ButtonVariant = 'flat' | 'outline' | 'shadow' | 'clear' | 'blocky' | 'bubbly' | 'skewed'\n\ntype ButtonShape = 'pill' | 'rounded' | 'square'\n\ntype ButtonSize = 'small' | 'medium' | 'large'\n\ntype NavigationButton = {\n id: string\n type: 'button'\n payload: {\n label: string\n link?: Link\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdownCaretType = 'caret' | 'plus' | 'arrow-down' | 'chevron-down'\n\ntype NavigationDropdownLink = {\n id: string\n payload: {\n label: string\n link?: Link\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdown = {\n id: string\n type: 'dropdown'\n payload: {\n label: string\n caret?: NavigationDropdownCaretType\n links?: NavigationDropdownLink[]\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\nexport type NavigationLinksValue = (NavigationButton | NavigationDropdown)[]\n\ntype NavigationLinksOptions = Options<Record<string, never>>\n\ntype NavigationLinksDescriptor<_T = NavigationLinksValue> = {\n type: typeof Types.NavigationLinks\n options: NavigationLinksOptions\n}\n\nexport function NavigationLinks(options: NavigationLinksOptions = {}): NavigationLinksDescriptor {\n return { type: Types.NavigationLinks, options }\n}\n\nexport type NumberValue = number\n\ntype NumberOptions = Options<{\n preset?: NumberValue\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype NumberDescriptor<_T = NumberValue> = { type: typeof Types.Number; options: NumberOptions }\n\nexport function Number(options: NumberOptions = {}): NumberDescriptor {\n return { type: Types.Number, options }\n}\n\ntype PaddingSide = { value: number; unit: 'px' }\n\ntype Padding = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `padding${Capitalize<K>}`]:\n | PaddingSide\n | null\n | undefined\n}\n\nexport type PaddingValue = ResponsiveValue<Padding>\n\ntype PaddingOptions = Options<{ preset?: PaddingValue }>\n\ntype PaddingDescriptor<_T = PaddingValue> = { type: typeof Types.Padding; options: PaddingOptions }\n\nexport function Padding(options: PaddingOptions = {}): PaddingDescriptor {\n return { type: Types.Padding, options }\n}\n\nexport type ResponsiveColorValue = ResponsiveValue<Color>\n\ntype ResponsiveColorOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype ResponsiveColorDescriptor<_T = ResponsiveColorValue> = {\n type: typeof Types.ResponsiveColor\n options: ResponsiveColorOptions\n}\n\nexport function ResponsiveColor(options: ResponsiveColorOptions = {}): ResponsiveColorDescriptor {\n return { type: Types.ResponsiveColor, options }\n}\n\ntype IconRadioGroupOption<T extends string> = { value: T; label: string; icon: IconName }\n\nexport type ResponsiveIconRadioGroupValue<T extends string> = ResponsiveValue<T>\n\ntype ResponsiveIconRadioGroupOptions<T extends string, U extends T = T> = Options<{\n label?: string\n options: IconRadioGroupOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveIconRadioGroupDescriptor<T extends ResponsiveIconRadioGroupValue<string>> = {\n type: typeof Types.ResponsiveIconRadioGroup\n options: ResponsiveIconRadioGroupOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveIconRadioGroup<_T extends string, T extends _T, U extends T>(\n options: ResponsiveIconRadioGroupOptions<T, U>,\n): ResponsiveIconRadioGroupDescriptor<ResponsiveIconRadioGroupValue<T>> {\n return { type: Types.ResponsiveIconRadioGroup, options }\n}\n\nexport type ResponsiveLengthValue = ResponsiveValue<Length>\n\ntype LengthOption =\n | { value: 'px'; label: 'Pixels'; icon: 'Px16' }\n | { value: '%'; label: 'Percentage'; icon: 'Percent16' }\n\ntype ResponsiveLengthOptions = Options<{\n label?: string\n options?: LengthOption[]\n defaultValue?: Length\n hidden?: boolean\n}>\n\ntype ResponsiveLengthDescriptor<_T = ResponsiveLengthValue> = {\n type: typeof Types.ResponsiveLength\n options: ResponsiveLengthOptions\n}\n\nexport function ResponsiveLength(\n options: ResponsiveLengthOptions = {},\n): ResponsiveLengthDescriptor {\n return { type: Types.ResponsiveLength, options }\n}\n\nexport type ResponsiveNumberValue = ResponsiveValue<number>\n\ntype ResponsiveNumberOptions = Options<{\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype ResponsiveNumberDescriptor<_T = ResponsiveNumberValue> = {\n type: typeof Types.ResponsiveNumber\n options: ResponsiveNumberOptions\n}\n\nexport function ResponsiveNumber(\n options: ResponsiveNumberOptions = {},\n): ResponsiveNumberDescriptor {\n return { type: Types.ResponsiveNumber, options }\n}\n\nexport type ResponsiveOpacityValue = ResponsiveValue<number>\n\ntype ResponsiveOpacityOptions = Options<Record<string, never>>\n\ntype ResponsiveOpacityDescriptor<_T = ResponsiveOpacityValue> = {\n type: typeof Types.ResponsiveOpacity\n options: ResponsiveOpacityOptions\n}\n\nexport function ResponsiveOpacity(\n options: ResponsiveOpacityOptions = {},\n): ResponsiveOpacityDescriptor {\n return { type: Types.ResponsiveOpacity, options }\n}\n\nexport type ResponsiveSelectValue<T extends string> = ResponsiveValue<T>\n\ntype SelectLabelOrientation = 'vertical' | 'horizontal'\n\ntype SelectOption<T extends string> = { value: T; label: string }\n\ntype ResponsiveSelectOptions<T extends string, U extends T = T> = Options<{\n label?: string\n labelOrientation?: SelectLabelOrientation\n options: SelectOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveSelectDescriptor<T extends ResponsiveSelectValue<string>> = {\n type: typeof Types.ResponsiveSelect\n options: ResponsiveSelectOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveSelect<_T extends string, T extends _T, U extends T>(\n options: ResponsiveSelectOptions<T, U>,\n): ResponsiveSelectDescriptor<ResponsiveSelectValue<T>> {\n return { type: Types.ResponsiveSelect, options }\n}\n\nexport type RichTextValue = IndexSignatureHack<Slate.ValueJSON>\n\ntype RichTextOptions = Options<{ preset?: RichTextValue }>\n\nexport type RichTextDescriptor<_T extends Data = RichTextValue> = {\n type: typeof Types.RichText\n options: RichTextOptions\n}\n\nexport function RichText(options: RichTextOptions = {}): RichTextDescriptor {\n return { type: Types.RichText, options }\n}\n\ntype Shadow = {\n color?: Color | null\n blurRadius?: number\n spreadRadius?: number\n offsetX?: number\n offsetY?: number\n inset?: boolean\n}\n\ntype Shadows = { id: string; payload: Shadow }[]\n\nexport type ShadowsValue = ResponsiveValue<Shadows>\n\ntype ShadowsOptions = Options<Record<string, never>>\n\ntype ShadowsDescriptor<_T = ShadowsValue> = { type: typeof Types.Shadows; options: ShadowsOptions }\n\nexport function Shadows(options: ShadowsOptions = {}): ShadowsDescriptor {\n return { type: Types.Shadows, options }\n}\n\nexport type ShapeValue<T extends Data = Data> = Record<string, T>\n\ntype ShapeOptions<T extends Record<string, Descriptor>> = {\n type: T\n preset?: { [K in keyof T]?: DescriptorValueType<T[K]> }\n}\n\ntype ShapeDescriptor<_T extends Record<string, Data>, U extends Record<string, Descriptor>> = {\n type: typeof Types.Shape\n options: ShapeOptions<U>\n}\n\nexport function Shape<T extends Record<string, Descriptor>>(\n options: ShapeOptions<T>,\n): ShapeDescriptor<{ [K in keyof T]?: DescriptorValueType<T[K]> }, T> {\n return { type: Types.Shape, options }\n}\n\ntype SocialLinkType =\n | 'angellist'\n | 'codepen'\n | 'dribbble'\n | 'facebook'\n | 'github'\n | 'instagram'\n | 'linkedin'\n | 'medium'\n | 'pinterest'\n | 'reddit'\n | 'rss'\n | 'snapchat'\n | 'soundcloud'\n | 'spotify'\n | 'telegram'\n | 'tumblr'\n | 'twitch'\n | 'twitter'\n | 'vimeo'\n | 'whatsapp'\n | 'yelp'\n | 'youtube'\n\ntype SocialLink = { type: SocialLinkType; url: string }\n\ntype SocialLinksLink = { id: string; payload: SocialLink }\n\nexport type SocialLinksValue = { links: SocialLinksLink[]; openInNewTab: boolean }\n\ntype SocialLinksOptions = Options<{ preset?: SocialLinksValue }>\n\ntype SocialLinksDescriptor<_T = SocialLinksValue> = {\n type: typeof Types.SocialLinks\n options: SocialLinksOptions\n}\n\nexport function SocialLinks(options: SocialLinksOptions = {}): SocialLinksDescriptor {\n return { type: Types.SocialLinks, options }\n}\n\nexport type TableValue = string\n\ntype TableOptions = Options<{ preset?: TableValue }>\n\ntype TableDescriptor<_T = TableValue> = { type: typeof Types.Table; options: TableOptions }\n\nexport function Table(options: TableOptions = {}): TableDescriptor {\n return { type: Types.Table, options }\n}\n\ntype TableFormField = {\n id: string\n tableColumnId: string\n label?: string\n placeholder?: string\n defaultValue?: string | boolean | string[]\n required?: boolean\n hidden?: boolean\n type?: 'select' | 'radio'\n hideLabel?: boolean\n autofill?: boolean\n}\n\ntype Grid = { count: number; spans: number[][] }\n\nexport type TableFormFieldsValue = { fields: TableFormField[]; grid: ResponsiveValue<Grid> }\n\ntype TableFormFieldsOptions = Options<{ preset?: TableFormFieldsValue }>\n\nexport type TableFormFieldsDescriptor<_T = TableFormFieldsValue> = {\n type: typeof Types.TableFormFields\n options: TableFormFieldsOptions\n}\n\nexport function TableFormFields(options: TableFormFieldsOptions = {}): TableFormFieldsDescriptor {\n return { type: Types.TableFormFields, options }\n}\n\nexport type TypeaheadValue<T extends Data = Data> = {\n id: string\n label: string\n value: T\n}\n\nexport type TypeaheadOptions<T extends Data> = {\n getItems: (query: string) => Promise<TypeaheadValue<T>[]>\n label?: string\n preset?: TypeaheadValue<T>\n defaultValue?: TypeaheadValue<T>\n}\n\nexport type TypeaheadDescriptor<T extends TypeaheadValue = TypeaheadValue> = {\n type: typeof Types.Typeahead\n options: TypeaheadOptions<T extends TypeaheadValue<infer U> ? U : never>\n}\n\nexport function Typeahead<T extends Data>(\n options: TypeaheadOptions<T>,\n): TypeaheadDescriptor<TypeaheadValue<T>> {\n return { type: Types.Typeahead, options }\n}\n\nexport type TextAreaValue = string\n\ntype TextAreaOptions = Options<{ preset?: TextAreaValue; label?: string; rows?: number }>\n\ntype TextAreaDescriptor<_T = TextAreaValue> = {\n type: typeof Types.TextArea\n options: TextAreaOptions\n}\n\nexport function TextArea(options: TextAreaOptions = {}): TextAreaDescriptor {\n return { type: Types.TextArea, options }\n}\n\nexport type TextInputValue = string\n\ntype TextInputOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype TextInputDescriptor<_T = TextInputValue> = {\n type: typeof Types.TextInput\n options: TextInputOptions\n}\n\nexport function TextInput(options: TextInputOptions = {}): TextInputDescriptor {\n return { type: Types.TextInput, options }\n}\n\nexport type TextStyleValue = ResponsiveValue<TextStyle>\n\ntype TextStyleOptions = Options<{ preset?: TextStyleValue; label?: string; hidden?: boolean }>\n\ntype TextStyleDescriptor<_T = TextStyleValue> = {\n type: typeof Types.TextStyle\n options: TextStyleOptions\n}\n\nexport function TextStyle(options: TextStyleOptions = {}): TextStyleDescriptor {\n return { type: Types.TextStyle, options }\n}\n\ntype Video = {\n url?: string\n muted?: boolean\n playing?: boolean\n loop?: boolean\n controls?: boolean\n}\n\nexport type VideoValue = Video\n\ntype VideoOptions = Options<{ preset?: VideoValue }>\n\ntype VideoDescriptor<_T = VideoValue> = { type: typeof Types.Video; options: VideoOptions }\n\nexport function Video(options: VideoOptions = {}): VideoDescriptor {\n return { type: Types.Video, options }\n}\n\nexport type WidthValue = ResponsiveValue<Length>\n\ntype WidthOptions = Options<{ preset?: WidthValue; defaultValue?: Length }>\n\ntype WidthDescriptor<_T = WidthValue> = { type: typeof Types.Width; options: WidthOptions }\n\nexport function Width(options: WidthOptions = {}): WidthDescriptor {\n return { type: Types.Width, options }\n}\n\nexport type Descriptor<T extends Data = Data> =\n | BackgroundsDescriptor<T>\n | BorderDescriptor<T>\n | BorderRadiusDescriptor<T>\n | CheckboxDescriptor<T>\n | DateDescriptor<T>\n | ElementIDDescriptor<T>\n | FontDescriptor<T>\n | GapXDescriptor<T>\n | GapYDescriptor<T>\n | GridDescriptor<T>\n | ImageDescriptor<T>\n | ImagesDescriptor<T>\n | LinkDescriptor<T>\n | ListDescriptor<T extends ListValue ? T : ListValue>\n | MarginDescriptor<T>\n | NavigationLinksDescriptor<T>\n | NumberDescriptor<T>\n | PaddingDescriptor<T>\n | ResponsiveColorDescriptor<T>\n | ResponsiveIconRadioGroupDescriptor<\n T extends ResponsiveIconRadioGroupValue<string> ? T : ResponsiveIconRadioGroupValue<string>\n >\n | ResponsiveLengthDescriptor<T>\n | ResponsiveNumberDescriptor<T>\n | ResponsiveOpacityDescriptor<T>\n | ResponsiveSelectDescriptor<\n T extends ResponsiveSelectValue<string> ? T : ResponsiveSelectValue<string>\n >\n | RichTextDescriptor<T>\n | ShadowsDescriptor<T>\n | ShapeDescriptor<T extends ShapeValue ? T : ShapeValue, any>\n | SocialLinksDescriptor<T>\n | TableDescriptor<T>\n | TableFormFieldsDescriptor<T>\n | TypeaheadDescriptor<T extends TypeaheadValue ? T : TypeaheadValue>\n | TextAreaDescriptor<T>\n | TextInputDescriptor<T>\n | TextStyleDescriptor<T>\n | VideoDescriptor<T>\n | WidthDescriptor<T>\n\ntype PanelDescriptorType =\n | typeof Types.Backgrounds\n | typeof Types.ResponsiveIconRadioGroup\n | typeof Types.Margin\n | typeof Types.Padding\n | typeof Types.Border\n | typeof Types.Shadows\n | typeof Types.GapY\n | typeof Types.GapX\n | typeof Types.BorderRadius\n | typeof Types.Checkbox\n | typeof Types.TextInput\n | typeof Types.Link\n | typeof Types.List\n | typeof Types.Shape\n | typeof Types.ResponsiveSelect\n | typeof Types.ResponsiveColor\n | typeof Types.TextStyle\n | typeof Types.Images\n | typeof Types.ResponsiveNumber\n | typeof Types.Number\n | typeof Types.Date\n | typeof Types.Font\n | typeof Types.TextArea\n | typeof Types.Table\n | typeof Types.Typeahead\n | typeof Types.RichText\n | typeof Types.Image\n | typeof Types.ResponsiveOpacity\n | typeof Types.SocialLinks\n | typeof Types.Video\n | typeof Types.NavigationLinks\n\nexport type PanelDescriptor<T extends Data = Data> = Extract<\n Descriptor<T>,\n { type: PanelDescriptorType }\n>\n\nexport type DescriptorValueType<T extends Descriptor> = T extends Descriptor<infer U> ? U : never\n"],"names":[],"mappings":";AAwFO,MAAM,QAAQ;AAAA,EACnB,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,UAAU;AAAA,EACV,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,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B,IAA2B;AACnF,SAAO,EAAE,MAAM,MAAM,aAAa,QAAQ;AAC5C;AAQsB,eAAA,UAAwB,IAAqB;AACjE,SAAO,EAAE,MAAM,MAAM,OAAO,QAAQ;AACtC;AA0BgC,yBAAA,UAAkC,IAA+B;AAC/F,SAAO,EAAE,MAAM,MAAM,iBAAiB,QAAQ;AAChD;AAoBO,mBACL,SACwC;AACxC,SAAO,EAAE,MAAM,MAAM,WAAW,QAAQ;AAC1C;AAWyB,kBAAA,UAA2B,IAAwB;AAC1E,SAAO,EAAE,MAAM,MAAM,UAAU,QAAQ;AACzC;AAW0B,mBAAA,UAA4B,IAAyB;AAC7E,SAAO,EAAE,MAAM,MAAM,WAAW,QAAQ;AAC1C;AAW0B,mBAAA,UAA4B,IAAyB;AAC7E,SAAO,EAAE,MAAM,MAAM,WAAW,QAAQ;AAC1C;AAgBsB,eAAA,UAAwB,IAAqB;AACjE,SAAO,EAAE,MAAM,MAAM,OAAO,QAAQ;AACtC;AAQsB,eAAA,UAAwB,IAAqB;AACjE,SAAO,EAAE,MAAM,MAAM,OAAO,QAAQ;AACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"descriptors.cjs.js","sources":["../src/prop-controllers/descriptors.ts"],"sourcesContent":["import type * as Slate from 'slate'\nimport type { Element, Data } from '../state/react-page'\n\nexport type { Data }\n\n// See https://github.com/microsoft/TypeScript/issues/15300\nexport type IndexSignatureHack<T> = T extends Record<string, any>\n ? { [K in keyof T]: IndexSignatureHack<T[K]> }\n : T\n\nexport type Device = 'desktop' | 'tablet' | 'mobile'\n\nexport type DeviceOverride<T> = { deviceId: Device; value: T }\n\nexport type ResponsiveValue<T> = DeviceOverride<T>[]\n\nexport type ResponsiveValueType<T> = T extends ResponsiveValue<infer U> ? U : never\n\ntype Color = { swatchId: string; alpha: number }\n\ntype IconName =\n | 'HeightAuto16'\n | 'HeightMatch16'\n | 'VerticalAlignStart16'\n | 'VerticalAlignMiddle16'\n | 'VerticalAlignEnd16'\n | 'VerticalAlignSpaceBetween16'\n | 'ButtonPill16'\n | 'ButtonRounded16'\n | 'ButtonSquare16'\n | 'SizeSmall16'\n | 'SizeMedium16'\n | 'SizeLarge16'\n | 'ArrowInside16'\n | 'ArrowCenter16'\n | 'ArrowOutside16'\n | 'CountdownSolid16'\n | 'CountdownSolidSplit16'\n | 'CountdownOutline16'\n | 'CountdownOutlineSplit16'\n | 'CountdownNaked16'\n | 'Sun16'\n | 'Moon16'\n | 'AlignLeft16'\n | 'AlignCenter16'\n | 'AlignRight16'\n | 'Star16'\n | 'StarCircle16'\n | 'StarRoundedSquare16'\n | 'StarSquare16'\n\ntype Gap = { value: number; unit: 'px' }\n\nexport type Length = { value: number; unit: 'px' | '%' }\n\ntype OpenPageLink = {\n type: 'OPEN_PAGE'\n payload: { pageId: string | null | undefined; openInNewTab: boolean }\n}\n\ntype OpenURLLink = { type: 'OPEN_URL'; payload: { url: string; openInNewTab: boolean } }\n\ntype SendEmailLink = {\n type: 'SEND_EMAIL'\n payload: { to: string; subject?: string; body?: string }\n}\n\ntype CallPhoneLink = { type: 'CALL_PHONE'; payload: { phoneNumber: string } }\n\ntype ScrollToElementLink = {\n type: 'SCROLL_TO_ELEMENT'\n payload: {\n elementIdConfig: { elementKey: string; propName: string } | null | undefined\n block: 'start' | 'center' | 'end'\n }\n}\n\ntype Link = OpenPageLink | OpenURLLink | SendEmailLink | CallPhoneLink | ScrollToElementLink\n\ntype TextStyle = {\n fontFamily?: string | null | undefined\n letterSpacing: number | null | undefined\n fontSize: { value: number; unit: 'px' } | null | undefined\n fontWeight: number | null | undefined\n textTransform: 'uppercase'[]\n fontStyle: 'italic'[]\n}\n\nexport const Types = {\n Backgrounds: 'Backgrounds',\n Border: 'Border',\n BorderRadius: 'BorderRadius',\n Checkbox: 'Checkbox',\n Date: 'Date',\n ElementID: 'ElementID',\n Font: 'Font',\n GapX: 'GapX',\n GapY: 'GapY',\n Grid: 'Grid',\n Image: 'Image',\n Images: 'Images',\n Link: 'Link',\n List: 'List',\n Margin: 'Margin',\n NavigationLinks: 'NavigationLinks',\n Number: 'Number',\n Padding: 'Padding',\n ResponsiveColor: 'ResponsiveColor',\n ResponsiveIconRadioGroup: 'ResponsiveIconRadioGroup',\n ResponsiveLength: 'ResponsiveLength',\n ResponsiveNumber: 'ResponsiveNumber',\n ResponsiveOpacity: 'ResponsiveOpacity',\n ResponsiveSelect: 'ResponsiveSelect',\n RichText: 'RichText',\n Shadows: 'Shadows',\n Shape: 'Shape',\n SocialLinks: 'SocialLinks',\n Table: 'Table',\n TableFormFields: 'TableFormFields',\n Typeahead: 'Typeahead',\n TextArea: 'TextArea',\n TextInput: 'TextInput',\n TextStyle: 'TextStyle',\n Video: 'Video',\n Width: 'Width',\n} as const\n\ntype Options<T> = T | ((props: Record<string, unknown>, decideMode: Device) => T)\n\ntype ColorBackground = { type: 'color'; id: string; payload: Color | null }\n\ntype GradientStop = { id: string; location: number; color: Color | null }\n\ntype Gradient = { angle?: number; isRadial?: boolean; stops: GradientStop[] }\n\ntype GradientBackground = { type: 'gradient'; id: string; payload: Gradient }\n\ntype BackgroundImagePosition = { x: number; y: number }\n\ntype BackgroundImageSize = 'cover' | 'contain' | 'auto'\n\ntype BackgroundImageRepeat = 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat'\n\ntype BackgroundImage = {\n imageId: string\n position: BackgroundImagePosition\n size?: BackgroundImageSize\n repeat?: BackgroundImageRepeat\n opacity?: number\n parallax?: number\n}\n\ntype ImageBackground = { type: 'image'; id: string; payload: BackgroundImage }\n\ntype BackgroundVideoAspectRatio = 'wide' | 'standard'\n\ntype BackgroundVideo = {\n url?: string\n maskColor?: Color | null\n opacity?: number\n zoom?: number\n aspectRatio?: BackgroundVideoAspectRatio\n parallax?: number\n}\n\ntype VideoBackground = { type: 'video'; id: string; payload: BackgroundVideo }\n\ntype Background = ColorBackground | GradientBackground | ImageBackground | VideoBackground\n\nexport type BackgroundsValue = ResponsiveValue<Background[]>\n\ntype BackgroundsOptions = Options<Record<string, never>>\n\ntype BackgroundsDescriptor<_T = BackgroundsValue> = {\n type: typeof Types.Backgrounds\n options: BackgroundsOptions\n}\n\nexport function Backgrounds(options: BackgroundsOptions = {}): BackgroundsDescriptor {\n return { type: Types.Backgrounds, options }\n}\n\ntype BorderSideStyle = 'dashed' | 'dotted' | 'solid'\n\ntype BorderSide = { width: number | null | undefined; style: BorderSideStyle; color?: Color | null }\n\ntype Border = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `border${Capitalize<K>}`]:\n | BorderSide\n | null\n | undefined\n}\n\nexport type BorderValue = ResponsiveValue<Border>\n\ntype BorderOptions = Options<Record<string, never>>\n\ntype BorderDescriptor<_T = BorderValue> = { type: typeof Types.Border; options: BorderOptions }\n\nexport function Border(options: BorderOptions = {}): BorderDescriptor {\n return { type: Types.Border, options }\n}\n\ntype BorderRadius = {\n [K in 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' as `border${Capitalize<K>}Radius`]:\n | Length\n | null\n | undefined\n}\n\nexport type BorderRadiusValue = ResponsiveValue<BorderRadius>\n\ntype BorderRadiusOptions = Options<Record<string, never>>\n\ntype BorderRadiusDescriptor<_T = BorderRadiusValue> = {\n type: typeof Types.BorderRadius\n options: BorderRadiusOptions\n}\n\nexport function BorderRadius(options: BorderRadiusOptions = {}): BorderRadiusDescriptor {\n return { type: Types.BorderRadius, options }\n}\n\nexport type CheckboxValue = boolean\n\ntype CheckboxOptions = Options<{\n preset?: CheckboxValue\n label: string\n hidden?: boolean\n}>\n\ntype CheckboxDescriptor<_T = CheckboxValue> = {\n type: typeof Types.Checkbox\n options: CheckboxOptions\n}\n\nexport function Checkbox(options: CheckboxOptions): CheckboxDescriptor {\n return { type: Types.Checkbox, options }\n}\n\nexport type DateValue = string\n\ntype DateOptions = Options<{ preset?: DateValue }>\n\ntype DateDescriptor<_T = DateValue> = { type: typeof Types.Date; options: DateOptions }\n\nexport function Date(options: DateOptions = {}): DateDescriptor {\n return { type: Types.Date, options }\n}\n\nexport type ElementIDValue = string\n\ntype ElementIDOptions = Options<Record<string, never>>\n\ntype ElementIDDescriptor<_T = ElementIDValue> = {\n type: typeof Types.ElementID\n options: ElementIDOptions\n}\n\nexport function ElementID(options: ElementIDOptions = {}): ElementIDDescriptor {\n return { type: Types.ElementID, options }\n}\n\nexport type FontValue = ResponsiveValue<string>\n\ntype FontOptions = Options<{ preset?: FontValue; label?: string }>\n\ntype FontDescriptor<_T = FontValue> = { type: typeof Types.Font; options: FontOptions }\n\nexport function Font(options: FontOptions = {}): FontDescriptor {\n return { type: Types.Font, options }\n}\n\nexport type GapXValue = ResponsiveValue<Gap>\n\ntype GapXOptions = Options<{\n preset?: GapXValue\n label?: string\n defaultValue?: Gap\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}>\n\ntype GapXDescriptor<_T = GapXValue> = { type: typeof Types.GapX; options: GapXOptions }\n\nexport function GapX(options: GapXOptions = {}): GapXDescriptor {\n return { type: Types.GapX, options }\n}\n\nexport type GapYValue = ResponsiveValue<Gap>\n\ntype GapYOptions = Options<{\n preset?: GapYValue\n label?: string\n defaultValue?: Gap\n step?: number\n min?: number\n max?: number\n hidden?: boolean\n}>\n\ntype GapYDescriptor<_T = GapYValue> = { type: typeof Types.GapY; options: GapYOptions }\n\nexport function GapY(options: GapYOptions = {}): GapYDescriptor {\n return { type: Types.GapY, options }\n}\n\ntype GridColumn = { count: number; spans: number[][] }\n\nexport type GridValue = { elements: Element[]; columns: ResponsiveValue<GridColumn> }\n\ntype GridOptions = Options<Record<string, never>>\n\ntype GridDescriptor<_T = GridValue> = { type: typeof Types.Grid; options: GridOptions }\n\nexport function Grid(options: GridOptions = {}): GridDescriptor {\n return { type: Types.Grid, options }\n}\n\nexport type ImageValue = string\n\ntype ImageOptions = Options<{ label?: string; hidden?: boolean }>\n\ntype ImageDescriptor<_T = ImageValue> = { type: typeof Types.Image; options: ImageOptions }\n\nexport function Image(options: ImageOptions = {}): ImageDescriptor {\n return { type: Types.Image, options }\n}\n\nexport type ImagesValue = { key: string; props: { link?: Link; file?: string; altText?: string } }[]\n\ntype ImagesOptions = Options<{ preset?: ImagesValue }>\n\ntype ImagesDescriptor<_T = ImagesValue> = { type: typeof Types.Images; options: ImagesOptions }\n\nexport function Images(options: ImagesOptions = {}): ImagesDescriptor {\n return { type: Types.Images, options }\n}\n\nexport type LinkValue = Link\n\ntype LinkOptions = Options<{\n preset?: LinkValue\n label?: string\n defaultValue?: Link\n options?: { value: Link['type']; label: string }[]\n hidden?: boolean\n}>\n\ntype LinkDescriptor<_T = LinkValue> = { type: typeof Types.Link; options: LinkOptions }\n\nexport function Link(options: LinkOptions = {}): LinkDescriptor {\n return { type: Types.Link, options }\n}\n\ntype ListValueItem<T extends Data> = { id: string; value?: T }\n\nexport type ListValue<T extends Data = Data> = ListValueItem<T>[]\n\nexport type ListOptions<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: ((value: T | undefined) => string) | ((value: T | undefined) => Promise<string>)\n preset?: ListValue<T>\n defaultValue?: ListValue<T>\n}\n\nexport type ListDescriptor<T extends ListValue = ListValue> = {\n type: typeof Types.List\n options: ListOptions<T extends ListValue<infer U> ? U : never>\n}\n\nexport function List<T extends Data>(options: ListOptions<T>): ListDescriptor<ListValue<T>> {\n return { type: Types.List, options }\n}\n\ntype MarginSide = { value: number; unit: 'px' } | 'auto'\n\ntype Margin = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `margin${Capitalize<K>}`]:\n | MarginSide\n | null\n | undefined\n}\n\nexport type MarginValue = ResponsiveValue<Margin>\n\ntype MarginOptions = Options<{ preset?: MarginValue }>\n\ntype MarginDescriptor<_T = MarginValue> = { type: typeof Types.Margin; options: MarginOptions }\n\nexport function Margin(options: MarginOptions = {}): MarginDescriptor {\n return { type: Types.Margin, options }\n}\n\ntype ButtonVariant = 'flat' | 'outline' | 'shadow' | 'clear' | 'blocky' | 'bubbly' | 'skewed'\n\ntype ButtonShape = 'pill' | 'rounded' | 'square'\n\ntype ButtonSize = 'small' | 'medium' | 'large'\n\ntype NavigationButton = {\n id: string\n type: 'button'\n payload: {\n label: string\n link?: Link\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdownCaretType = 'caret' | 'plus' | 'arrow-down' | 'chevron-down'\n\ntype NavigationDropdownLink = {\n id: string\n payload: {\n label: string\n link?: Link\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdown = {\n id: string\n type: 'dropdown'\n payload: {\n label: string\n caret?: NavigationDropdownCaretType\n links?: NavigationDropdownLink[]\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\nexport type NavigationLinksValue = (NavigationButton | NavigationDropdown)[]\n\ntype NavigationLinksOptions = Options<Record<string, never>>\n\ntype NavigationLinksDescriptor<_T = NavigationLinksValue> = {\n type: typeof Types.NavigationLinks\n options: NavigationLinksOptions\n}\n\nexport function NavigationLinks(options: NavigationLinksOptions = {}): NavigationLinksDescriptor {\n return { type: Types.NavigationLinks, options }\n}\n\nexport type NumberValue = number\n\ntype NumberOptions = Options<{\n preset?: NumberValue\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype NumberDescriptor<_T = NumberValue> = { type: typeof Types.Number; options: NumberOptions }\n\nexport function Number(options: NumberOptions = {}): NumberDescriptor {\n return { type: Types.Number, options }\n}\n\ntype PaddingSide = { value: number; unit: 'px' }\n\ntype Padding = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `padding${Capitalize<K>}`]:\n | PaddingSide\n | null\n | undefined\n}\n\nexport type PaddingValue = ResponsiveValue<Padding>\n\ntype PaddingOptions = Options<{ preset?: PaddingValue }>\n\ntype PaddingDescriptor<_T = PaddingValue> = { type: typeof Types.Padding; options: PaddingOptions }\n\nexport function Padding(options: PaddingOptions = {}): PaddingDescriptor {\n return { type: Types.Padding, options }\n}\n\nexport type ResponsiveColorValue = ResponsiveValue<Color>\n\ntype ResponsiveColorOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype ResponsiveColorDescriptor<_T = ResponsiveColorValue> = {\n type: typeof Types.ResponsiveColor\n options: ResponsiveColorOptions\n}\n\nexport function ResponsiveColor(options: ResponsiveColorOptions = {}): ResponsiveColorDescriptor {\n return { type: Types.ResponsiveColor, options }\n}\n\ntype IconRadioGroupOption<T extends string> = { value: T; label: string; icon: IconName }\n\nexport type ResponsiveIconRadioGroupValue<T extends string> = ResponsiveValue<T>\n\ntype ResponsiveIconRadioGroupOptions<T extends string, U extends T = T> = Options<{\n label?: string\n options: IconRadioGroupOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveIconRadioGroupDescriptor<T extends ResponsiveIconRadioGroupValue<string>> = {\n type: typeof Types.ResponsiveIconRadioGroup\n options: ResponsiveIconRadioGroupOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveIconRadioGroup<_T extends string, T extends _T, U extends T>(\n options: ResponsiveIconRadioGroupOptions<T, U>,\n): ResponsiveIconRadioGroupDescriptor<ResponsiveIconRadioGroupValue<T>> {\n return { type: Types.ResponsiveIconRadioGroup, options }\n}\n\nexport type ResponsiveLengthValue = ResponsiveValue<Length>\n\ntype LengthOption =\n | { value: 'px'; label: 'Pixels'; icon: 'Px16' }\n | { value: '%'; label: 'Percentage'; icon: 'Percent16' }\n\ntype ResponsiveLengthOptions = Options<{\n label?: string\n options?: LengthOption[]\n defaultValue?: Length\n hidden?: boolean\n}>\n\ntype ResponsiveLengthDescriptor<_T = ResponsiveLengthValue> = {\n type: typeof Types.ResponsiveLength\n options: ResponsiveLengthOptions\n}\n\nexport function ResponsiveLength(\n options: ResponsiveLengthOptions = {},\n): ResponsiveLengthDescriptor {\n return { type: Types.ResponsiveLength, options }\n}\n\nexport type ResponsiveNumberValue = ResponsiveValue<number>\n\ntype ResponsiveNumberOptions = Options<{\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype ResponsiveNumberDescriptor<_T = ResponsiveNumberValue> = {\n type: typeof Types.ResponsiveNumber\n options: ResponsiveNumberOptions\n}\n\nexport function ResponsiveNumber(\n options: ResponsiveNumberOptions = {},\n): ResponsiveNumberDescriptor {\n return { type: Types.ResponsiveNumber, options }\n}\n\nexport type ResponsiveOpacityValue = ResponsiveValue<number>\n\ntype ResponsiveOpacityOptions = Options<Record<string, never>>\n\ntype ResponsiveOpacityDescriptor<_T = ResponsiveOpacityValue> = {\n type: typeof Types.ResponsiveOpacity\n options: ResponsiveOpacityOptions\n}\n\nexport function ResponsiveOpacity(\n options: ResponsiveOpacityOptions = {},\n): ResponsiveOpacityDescriptor {\n return { type: Types.ResponsiveOpacity, options }\n}\n\nexport type ResponsiveSelectValue<T extends string> = ResponsiveValue<T>\n\ntype SelectLabelOrientation = 'vertical' | 'horizontal'\n\ntype SelectOption<T extends string> = { value: T; label: string }\n\ntype ResponsiveSelectOptions<T extends string, U extends T = T> = Options<{\n label?: string\n labelOrientation?: SelectLabelOrientation\n options: SelectOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveSelectDescriptor<T extends ResponsiveSelectValue<string>> = {\n type: typeof Types.ResponsiveSelect\n options: ResponsiveSelectOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveSelect<_T extends string, T extends _T, U extends T>(\n options: ResponsiveSelectOptions<T, U>,\n): ResponsiveSelectDescriptor<ResponsiveSelectValue<T>> {\n return { type: Types.ResponsiveSelect, options }\n}\n\nexport type RichTextValue = IndexSignatureHack<Slate.ValueJSON>\n\ntype RichTextOptions = Options<{ preset?: RichTextValue }>\n\nexport type RichTextDescriptor<_T extends Data = RichTextValue> = {\n type: typeof Types.RichText\n options: RichTextOptions\n}\n\nexport function RichText(options: RichTextOptions = {}): RichTextDescriptor {\n return { type: Types.RichText, options }\n}\n\ntype Shadow = {\n color?: Color | null\n blurRadius?: number\n spreadRadius?: number\n offsetX?: number\n offsetY?: number\n inset?: boolean\n}\n\ntype Shadows = { id: string; payload: Shadow }[]\n\nexport type ShadowsValue = ResponsiveValue<Shadows>\n\ntype ShadowsOptions = Options<Record<string, never>>\n\ntype ShadowsDescriptor<_T = ShadowsValue> = { type: typeof Types.Shadows; options: ShadowsOptions }\n\nexport function Shadows(options: ShadowsOptions = {}): ShadowsDescriptor {\n return { type: Types.Shadows, options }\n}\n\nexport type ShapeValue<T extends Data = Data> = Record<string, T>\n\ntype ShapeOptions<T extends Record<string, PanelDescriptor>> = {\n type: T\n preset?: { [K in keyof T]?: DescriptorValueType<T[K]> }\n}\n\nexport type ShapeDescriptor<\n _T extends Record<string, Data>,\n U extends Record<string, PanelDescriptor>,\n> = {\n type: typeof Types.Shape\n options: ShapeOptions<U>\n}\n\nexport function Shape<T extends Record<string, PanelDescriptor>>(\n options: ShapeOptions<T>,\n): ShapeDescriptor<{ [K in keyof T]?: DescriptorValueType<T[K]> }, T> {\n return { type: Types.Shape, options }\n}\n\ntype SocialLinkType =\n | 'angellist'\n | 'codepen'\n | 'dribbble'\n | 'facebook'\n | 'github'\n | 'instagram'\n | 'linkedin'\n | 'medium'\n | 'pinterest'\n | 'reddit'\n | 'rss'\n | 'snapchat'\n | 'soundcloud'\n | 'spotify'\n | 'telegram'\n | 'tumblr'\n | 'twitch'\n | 'twitter'\n | 'vimeo'\n | 'whatsapp'\n | 'yelp'\n | 'youtube'\n\ntype SocialLink = { type: SocialLinkType; url: string }\n\ntype SocialLinksLink = { id: string; payload: SocialLink }\n\nexport type SocialLinksValue = { links: SocialLinksLink[]; openInNewTab: boolean }\n\ntype SocialLinksOptions = Options<{ preset?: SocialLinksValue }>\n\ntype SocialLinksDescriptor<_T = SocialLinksValue> = {\n type: typeof Types.SocialLinks\n options: SocialLinksOptions\n}\n\nexport function SocialLinks(options: SocialLinksOptions = {}): SocialLinksDescriptor {\n return { type: Types.SocialLinks, options }\n}\n\nexport type TableValue = string\n\ntype TableOptions = Options<{ preset?: TableValue }>\n\ntype TableDescriptor<_T = TableValue> = { type: typeof Types.Table; options: TableOptions }\n\nexport function Table(options: TableOptions = {}): TableDescriptor {\n return { type: Types.Table, options }\n}\n\ntype TableFormField = {\n id: string\n tableColumnId: string\n label?: string\n placeholder?: string\n defaultValue?: string | boolean | string[]\n required?: boolean\n hidden?: boolean\n type?: 'select' | 'radio'\n hideLabel?: boolean\n autofill?: boolean\n}\n\ntype Grid = { count: number; spans: number[][] }\n\nexport type TableFormFieldsValue = { fields: TableFormField[]; grid: ResponsiveValue<Grid> }\n\ntype TableFormFieldsOptions = Options<{ preset?: TableFormFieldsValue }>\n\nexport type TableFormFieldsDescriptor<_T = TableFormFieldsValue> = {\n type: typeof Types.TableFormFields\n options: TableFormFieldsOptions\n}\n\nexport function TableFormFields(options: TableFormFieldsOptions = {}): TableFormFieldsDescriptor {\n return { type: Types.TableFormFields, options }\n}\n\nexport type TypeaheadValue<T extends Data = Data> = {\n id: string\n label: string\n value: T\n}\n\nexport type TypeaheadOptions<T extends Data> = {\n getItems: (query: string) => Promise<TypeaheadValue<T>[]>\n label?: string\n preset?: TypeaheadValue<T>\n defaultValue?: TypeaheadValue<T>\n}\n\nexport type TypeaheadDescriptor<T extends TypeaheadValue = TypeaheadValue> = {\n type: typeof Types.Typeahead\n options: TypeaheadOptions<T extends TypeaheadValue<infer U> ? U : never>\n}\n\nexport function Typeahead<T extends Data>(\n options: TypeaheadOptions<T>,\n): TypeaheadDescriptor<TypeaheadValue<T>> {\n return { type: Types.Typeahead, options }\n}\n\nexport type TextAreaValue = string\n\ntype TextAreaOptions = Options<{ preset?: TextAreaValue; label?: string; rows?: number }>\n\ntype TextAreaDescriptor<_T = TextAreaValue> = {\n type: typeof Types.TextArea\n options: TextAreaOptions\n}\n\nexport function TextArea(options: TextAreaOptions = {}): TextAreaDescriptor {\n return { type: Types.TextArea, options }\n}\n\nexport type TextInputValue = string\n\ntype TextInputOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype TextInputDescriptor<_T = TextInputValue> = {\n type: typeof Types.TextInput\n options: TextInputOptions\n}\n\nexport function TextInput(options: TextInputOptions = {}): TextInputDescriptor {\n return { type: Types.TextInput, options }\n}\n\nexport type TextStyleValue = ResponsiveValue<TextStyle>\n\ntype TextStyleOptions = Options<{ preset?: TextStyleValue; label?: string; hidden?: boolean }>\n\ntype TextStyleDescriptor<_T = TextStyleValue> = {\n type: typeof Types.TextStyle\n options: TextStyleOptions\n}\n\nexport function TextStyle(options: TextStyleOptions = {}): TextStyleDescriptor {\n return { type: Types.TextStyle, options }\n}\n\ntype Video = {\n url?: string\n muted?: boolean\n playing?: boolean\n loop?: boolean\n controls?: boolean\n}\n\nexport type VideoValue = Video\n\ntype VideoOptions = Options<{ preset?: VideoValue }>\n\ntype VideoDescriptor<_T = VideoValue> = { type: typeof Types.Video; options: VideoOptions }\n\nexport function Video(options: VideoOptions = {}): VideoDescriptor {\n return { type: Types.Video, options }\n}\n\nexport type WidthValue = ResponsiveValue<Length>\n\ntype WidthOptions = Options<{ preset?: WidthValue; defaultValue?: Length }>\n\ntype WidthDescriptor<_T = WidthValue> = { type: typeof Types.Width; options: WidthOptions }\n\nexport function Width(options: WidthOptions = {}): WidthDescriptor {\n return { type: Types.Width, options }\n}\n\nexport type Descriptor<T extends Data = Data> =\n | BackgroundsDescriptor<T>\n | BorderDescriptor<T>\n | BorderRadiusDescriptor<T>\n | CheckboxDescriptor<T>\n | DateDescriptor<T>\n | ElementIDDescriptor<T>\n | FontDescriptor<T>\n | GapXDescriptor<T>\n | GapYDescriptor<T>\n | GridDescriptor<T>\n | ImageDescriptor<T>\n | ImagesDescriptor<T>\n | LinkDescriptor<T>\n | ListDescriptor<T extends ListValue ? T : ListValue>\n | MarginDescriptor<T>\n | NavigationLinksDescriptor<T>\n | NumberDescriptor<T>\n | PaddingDescriptor<T>\n | ResponsiveColorDescriptor<T>\n | ResponsiveIconRadioGroupDescriptor<\n T extends ResponsiveIconRadioGroupValue<string> ? T : ResponsiveIconRadioGroupValue<string>\n >\n | ResponsiveLengthDescriptor<T>\n | ResponsiveNumberDescriptor<T>\n | ResponsiveOpacityDescriptor<T>\n | ResponsiveSelectDescriptor<\n T extends ResponsiveSelectValue<string> ? T : ResponsiveSelectValue<string>\n >\n | RichTextDescriptor<T>\n | ShadowsDescriptor<T>\n | ShapeDescriptor<T extends ShapeValue ? T : ShapeValue, any>\n | SocialLinksDescriptor<T>\n | TableDescriptor<T>\n | TableFormFieldsDescriptor<T>\n | TypeaheadDescriptor<T extends TypeaheadValue ? T : TypeaheadValue>\n | TextAreaDescriptor<T>\n | TextInputDescriptor<T>\n | TextStyleDescriptor<T>\n | VideoDescriptor<T>\n | WidthDescriptor<T>\n\nexport type PanelDescriptorType =\n | typeof Types.Backgrounds\n | typeof Types.ResponsiveIconRadioGroup\n | typeof Types.Margin\n | typeof Types.Padding\n | typeof Types.Border\n | typeof Types.Shadows\n | typeof Types.GapY\n | typeof Types.GapX\n | typeof Types.BorderRadius\n | typeof Types.Checkbox\n | typeof Types.TextInput\n | typeof Types.Link\n | typeof Types.List\n | typeof Types.Shape\n | typeof Types.ResponsiveSelect\n | typeof Types.ResponsiveColor\n | typeof Types.TextStyle\n | typeof Types.Images\n | typeof Types.ResponsiveNumber\n | typeof Types.Number\n | typeof Types.Date\n | typeof Types.Font\n | typeof Types.TextArea\n | typeof Types.Table\n | typeof Types.Typeahead\n | typeof Types.RichText\n | typeof Types.Image\n | typeof Types.ResponsiveOpacity\n | typeof Types.SocialLinks\n | typeof Types.Video\n | typeof Types.NavigationLinks\n\nexport type PanelDescriptor<T extends Data = Data> = Extract<\n Descriptor<T>,\n { type: PanelDescriptorType }\n>\n\nexport type DescriptorValueType<T extends Descriptor> = T extends Descriptor<infer U> ? U : never\n\nexport type PanelDescriptorValueType<T extends PanelDescriptor> = T extends PanelDescriptor<infer U>\n ? U\n : never\n"],"names":[],"mappings":";AAwFO,MAAM,QAAQ;AAAA,EACnB,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,UAAU;AAAA,EACV,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,0BAA0B;AAAA,EAC1B,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,OAAO;AAAA,EACP,aAAa;AAAA,EACb,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AAAA,EACP,OAAO;AACT;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