@makeswift/runtime 0.0.0-afbfa6b → 0.0.0-b87dd43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Page.cjs.js +215 -0
- package/dist/Page.cjs.js.map +1 -0
- package/dist/Page.es.js +209 -0
- package/dist/Page.es.js.map +1 -0
- package/dist/actions.cjs.js +21 -1
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +18 -2
- package/dist/actions.es.js.map +1 -1
- package/dist/box-models.cjs.js +2 -0
- package/dist/box-models.cjs.js.map +1 -1
- package/dist/box-models.es.js +2 -0
- package/dist/box-models.es.js.map +1 -1
- package/dist/builder.cjs.js +1 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +1 -1
- package/dist/components.cjs.js +17 -1
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +8 -2
- package/dist/components.es.js.map +1 -1
- package/dist/constants.cjs.js +96 -1
- package/dist/constants.cjs.js.map +1 -1
- package/dist/constants.es.js +96 -1
- package/dist/constants.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +137 -5
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +137 -6
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/descriptors.cjs.js +8 -0
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js +6 -1
- package/dist/descriptors.es.js.map +1 -1
- package/dist/instances.cjs.js +17 -0
- package/dist/instances.cjs.js.map +1 -1
- package/dist/instances.es.js +17 -1
- package/dist/instances.es.js.map +1 -1
- package/dist/main.cjs.js +9 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +5 -1
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +34 -13
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +35 -14
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +1 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +1 -1
- package/dist/react-builder-preview.cjs.js +23 -35
- package/dist/react-builder-preview.cjs.js.map +1 -1
- package/dist/react-builder-preview.es.js +22 -34
- package/dist/react-builder-preview.es.js.map +1 -1
- package/dist/react-page.cjs.js +262 -0
- package/dist/react-page.cjs.js.map +1 -0
- package/dist/react-page.es.js +241 -0
- package/dist/react-page.es.js.map +1 -0
- package/dist/react.cjs.js +7 -2
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.cjs2.js +2464 -565
- package/dist/react.cjs2.js.map +1 -1
- package/dist/react.es.js +7 -2
- package/dist/react.es.js.map +1 -1
- package/dist/react.es2.js +2453 -554
- package/dist/react.es2.js.map +1 -1
- package/dist/types/api/constants.d.ts.map +1 -1
- package/dist/types/api/generated/graphql.d.ts +59 -0
- package/dist/types/api/generated/graphql.d.ts.map +1 -1
- package/dist/types/api/react.d.ts +25 -4
- package/dist/types/api/react.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +2 -2
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/builder/serialization/control-serialization.d.ts +121 -7
- package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/builder/serialization/function-serialization.d.ts +1 -0
- package/dist/types/builder/serialization/function-serialization.d.ts.map +1 -1
- package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts +41 -0
- package/dist/types/components/builtin/Form/Form.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +15 -0
- package/dist/types/components/builtin/Form/components/Field/components/Checkbox/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/CheckboxTableField/index.d.ts +15 -0
- package/dist/types/components/builtin/Form/components/Field/components/CheckboxTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/EmailTableField/index.d.ts +11 -0
- package/dist/types/components/builtin/Form/components/Field/components/EmailTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/Input/index.d.ts +14 -0
- package/dist/types/components/builtin/Form/components/Field/components/Input/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts +16 -0
- package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/LongTextTableField/index.d.ts +10 -0
- package/dist/types/components/builtin/Form/components/Field/components/LongTextTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.d.ts +23 -0
- package/dist/types/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/NumberTableField/index.d.ts +11 -0
- package/dist/types/components/builtin/Form/components/Field/components/NumberTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/PhoneNumberTableField/index.d.ts +11 -0
- package/dist/types/components/builtin/Form/components/Field/components/PhoneNumberTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts +3 -0
- package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/RadioButton/index.d.ts +17 -0
- package/dist/types/components/builtin/Form/components/Field/components/RadioButton/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleLineTextTableField/index.d.ts +11 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleLineTextTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.d.ts +23 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.d.ts +19 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/index.d.ts +24 -0
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/TextArea/index.d.ts +13 -0
- package/dist/types/components/builtin/Form/components/Field/components/TextArea/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/components/URLTableField/index.d.ts +11 -0
- package/dist/types/components/builtin/Form/components/Field/components/URLTableField/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/index.d.ts +19 -0
- package/dist/types/components/builtin/Form/components/Field/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Field/services/cssField.d.ts +11 -0
- package/dist/types/components/builtin/Form/components/Field/services/cssField.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts +9 -0
- package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/components/Spinner/index.d.ts +3 -0
- package/dist/types/components/builtin/Form/components/Spinner/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/context/FormContext.d.ts +32 -0
- package/dist/types/components/builtin/Form/context/FormContext.d.ts.map +1 -0
- package/dist/types/components/builtin/Form/index.d.ts +2 -0
- package/dist/types/components/builtin/Form/index.d.ts.map +1 -0
- package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
- package/dist/types/components/builtin/Video/Video.d.ts +15 -0
- package/dist/types/components/builtin/Video/Video.d.ts.map +1 -0
- package/dist/types/components/builtin/Video/index.d.ts +2 -0
- package/dist/types/components/builtin/Video/index.d.ts.map +1 -0
- package/dist/types/components/builtin/index.d.ts +1 -0
- package/dist/types/components/builtin/index.d.ts.map +1 -1
- package/dist/types/components/hooks/index.d.ts +1 -0
- package/dist/types/components/hooks/index.d.ts.map +1 -1
- package/dist/types/components/hooks/useTable.d.ts +66 -0
- package/dist/types/components/hooks/useTable.d.ts.map +1 -0
- package/dist/types/components/hooks/useTableFormFieldRefs.d.ts +8 -0
- package/dist/types/components/hooks/useTableFormFieldRefs.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/components/page/BodySnippet.d.ts +7 -0
- package/dist/types/components/page/BodySnippet.d.ts.map +1 -0
- package/dist/types/components/page/Page.d.ts +45 -0
- package/dist/types/components/page/Page.d.ts.map +1 -0
- package/dist/types/components/page/index.d.ts +2 -0
- package/dist/types/components/page/index.d.ts.map +1 -0
- package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
- package/dist/types/components/shared/FallbackComponent/FallbackComponent.d.ts +7 -0
- package/dist/types/components/shared/FallbackComponent/FallbackComponent.d.ts.map +1 -0
- package/dist/types/components/shared/FallbackComponent/index.d.ts +2 -0
- package/dist/types/components/shared/FallbackComponent/index.d.ts.map +1 -0
- package/dist/types/components/utils/placeholders.d.ts +7 -0
- package/dist/types/components/utils/placeholders.d.ts.map +1 -1
- package/dist/types/components/utils/queries.d.ts +1 -0
- package/dist/types/components/utils/queries.d.ts.map +1 -1
- package/dist/types/components/utils/types.d.ts +1 -2
- package/dist/types/components/utils/types.d.ts.map +1 -1
- package/dist/types/controls.d.ts +4 -0
- package/dist/types/controls.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/next.d.ts +5 -4
- package/dist/types/next.d.ts.map +1 -1
- package/dist/types/prop-controllers/descriptors.d.ts +34 -16
- package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/prop-controllers/index.d.ts +3 -3
- package/dist/types/prop-controllers/index.d.ts.map +1 -1
- package/dist/types/prop-controllers/instances.d.ts +36 -4
- package/dist/types/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/react.d.ts +1 -1
- package/dist/types/react.d.ts.map +1 -1
- package/dist/types/runtimes/react.d.ts +7 -7
- package/dist/types/runtimes/react.d.ts.map +1 -1
- package/dist/types/state/actions.d.ts +36 -1
- package/dist/types/state/actions.d.ts.map +1 -1
- package/dist/types/state/modules/box-models.d.ts.map +1 -1
- package/dist/types/state/modules/read-only-documents.d.ts +8 -4
- package/dist/types/state/modules/read-only-documents.d.ts.map +1 -1
- package/dist/types/state/modules/read-write-documents.d.ts +1 -1
- package/dist/types/state/modules/read-write-documents.d.ts.map +1 -1
- package/dist/types/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/state/react-page.d.ts +3 -3
- package/dist/types/state/react-page.d.ts.map +1 -1
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptors.es.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 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\ntype 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 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 | 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.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,SAAS;AAAA,EACT,iBAAiB;AAAA,E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Q;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;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.es.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\nexport type 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>, deviceMode: 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\nexport type CheckboxOptions = Options<{\n preset?: CheckboxValue\n label: string\n hidden?: boolean\n}>\n\nexport type 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\nexport type 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\nexport type 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\nexport type 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\nexport type 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\nexport type 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\nexport type 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;AAqD4B,qBAAA,UAA8B,IAA2B;AACnF,SAAO,EAAE,MAAM,MAAM,aAAa,QAAQ;AAC5C;AAmBuB,gBAAA,UAAyB,IAAsB;AACpE,SAAO,EAAE,MAAM,MAAM,QA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7E,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/instances.cjs.js
CHANGED
|
@@ -76,14 +76,31 @@ class RichTextPropController extends PropController {
|
|
|
76
76
|
this.send({ type: RichTextPropControllerMessageType.REDO });
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
const TableFormFieldsMessageType = {
|
|
80
|
+
TABLE_FORM_LAYOUT_CHANGE: "TABLE_FORM_LAYOUT_CHANGE",
|
|
81
|
+
TABLE_FORM_FIELD_LAYOUT_CHANGE: "TABLE_FORM_FIELD_LAYOUT_CHANGE"
|
|
82
|
+
};
|
|
83
|
+
class TableFormFieldsPropController extends PropController {
|
|
84
|
+
recv() {
|
|
85
|
+
}
|
|
86
|
+
tableFormLayoutChange(payload) {
|
|
87
|
+
this.send({ type: TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE, payload });
|
|
88
|
+
}
|
|
89
|
+
tableFormFieldLayoutChange(payload) {
|
|
90
|
+
this.send({ type: TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE, payload });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
79
93
|
function createPropController(descriptor, send) {
|
|
80
94
|
switch (descriptor.type) {
|
|
81
95
|
case descriptors.Types.RichText:
|
|
82
96
|
return new RichTextPropController(send);
|
|
97
|
+
case descriptors.Types.TableFormFields:
|
|
98
|
+
return new TableFormFieldsPropController(send);
|
|
83
99
|
default:
|
|
84
100
|
return new DefaultPropController(send);
|
|
85
101
|
}
|
|
86
102
|
}
|
|
87
103
|
exports.RichTextPropControllerMessageType = RichTextPropControllerMessageType;
|
|
104
|
+
exports.TableFormFieldsMessageType = TableFormFieldsMessageType;
|
|
88
105
|
exports.createPropController = createPropController;
|
|
89
106
|
//# sourceMappingURL=instances.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances.cjs.js","sources":["../src/utils/constants.ts","../src/prop-controllers/instances.ts"],"sourcesContent":["export const BuilderEditMode = {\n BUILD: 'build',\n CONTENT: 'content',\n} as const\n\nexport type BuilderEditMode = typeof BuilderEditMode[keyof typeof BuilderEditMode]\n","import { Editor } from 'slate-react'\nimport { ValueJSON } from 'slate'\nimport { OnChangeParam } from 'slate-react'\nimport { Descriptor, RichTextDescriptor, Types } from './descriptors'\nimport { BuilderEditMode } from '../utils/constants'\n\nexport const RichTextPropControllerMessageType = {\n CHANGE_BUILDER_EDIT_MODE: 'CHANGE_BUILDER_EDIT_MODE',\n INITIALIZE_EDITOR: 'INITIALIZE_EDITOR',\n CHANGE_EDITOR_VALUE: 'CHANGE_EDITOR_VALUE',\n FOCUS: 'FOCUS',\n BLUR: 'BLUR',\n UNDO: 'UNDO',\n REDO: 'REDO',\n} as const\n\ntype ChangeBuilderEditModeRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE\n editMode: BuilderEditMode\n}\n\ntype InitializeEditorRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.INITIALIZE_EDITOR\n value: ValueJSON\n}\n\ntype ChangeEditorValueRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE\n value: ValueJSON\n}\n\ntype FocusRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.FOCUS }\n\ntype BlurRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.BLUR }\n\ntype UndoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.UNDO }\n\ntype RedoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.REDO }\n\nexport type RichTextPropControllerMessage =\n | ChangeBuilderEditModeRichTextPropControllerMessage\n | InitializeEditorRichTextPropControllerMessage\n | ChangeEditorValueRichTextPropControllerMessage\n | FocusRichTextPropControllerMessage\n | BlurRichTextPropControllerMessage\n | UndoRichTextPropControllerMessage\n | RedoRichTextPropControllerMessage\n\nexport type PropControllerMessage = RichTextPropControllerMessage\n\ntype Send<T = PropControllerMessage> = (message: T) => void\n\nexport abstract class PropController<T = PropControllerMessage> {\n protected send: Send<T>\n\n constructor(send: Send<T>) {\n this.send = send\n }\n\n abstract recv(message: T): void\n}\n\nclass DefaultPropController extends PropController {\n recv(_message: PropControllerMessage): void {\n // Do nothing.\n }\n}\n\nclass RichTextPropController extends PropController<RichTextPropControllerMessage> {\n private editor: Editor | null = null\n\n recv(message: RichTextPropControllerMessage): void {\n switch (message.type) {\n case RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.editMode) {\n case BuilderEditMode.BUILD:\n this.editor?.deselect().blur()\n break\n\n case BuilderEditMode.CONTENT:\n this.editor?.focus().moveToRangeOfDocument()\n break\n }\n\n break\n }\n }\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.send({\n type: RichTextPropControllerMessageType.INITIALIZE_EDITOR,\n value: editor.value.toJSON({ preserveSelection: false }),\n })\n }\n\n onChange(change: OnChangeParam) {\n this.send({\n type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,\n value: change.value.toJSON({ preserveSelection: true }),\n })\n }\n\n focus() {\n this.send({ type: RichTextPropControllerMessageType.FOCUS })\n }\n\n blur() {\n this.send({ type: RichTextPropControllerMessageType.BLUR })\n }\n\n undo() {\n this.send({ type: RichTextPropControllerMessageType.UNDO })\n }\n\n redo() {\n this.send({ type: RichTextPropControllerMessageType.REDO })\n }\n}\n\ntype DescriptorPropController<T extends Descriptor> = T extends { type: typeof Types.RichText }\n ? RichTextPropController\n : DefaultPropController\n\nexport type DescriptorsPropControllers<T extends Record<string, Descriptor>> = {\n [K in keyof T]: undefined extends T[K]\n ? DescriptorPropController<Exclude<T[K], undefined>>\n : DescriptorPropController<T[K]>\n}\n\nexport function createPropController(\n descriptor: RichTextDescriptor,\n send: Send<RichTextPropControllerMessage>,\n): RichTextPropController\nexport function createPropController(descriptor: Descriptor, send: Send):
|
|
1
|
+
{"version":3,"file":"instances.cjs.js","sources":["../src/utils/constants.ts","../src/prop-controllers/instances.ts"],"sourcesContent":["export const BuilderEditMode = {\n BUILD: 'build',\n CONTENT: 'content',\n} as const\n\nexport type BuilderEditMode = typeof BuilderEditMode[keyof typeof BuilderEditMode]\n","import { Editor } from 'slate-react'\nimport { ValueJSON } from 'slate'\nimport { OnChangeParam } from 'slate-react'\nimport { Descriptor, RichTextDescriptor, TableFormFieldsDescriptor, Types } from './descriptors'\nimport { BuilderEditMode } from '../utils/constants'\nimport { BoxModel } from '../state/modules/box-models'\n\nexport const RichTextPropControllerMessageType = {\n CHANGE_BUILDER_EDIT_MODE: 'CHANGE_BUILDER_EDIT_MODE',\n INITIALIZE_EDITOR: 'INITIALIZE_EDITOR',\n CHANGE_EDITOR_VALUE: 'CHANGE_EDITOR_VALUE',\n FOCUS: 'FOCUS',\n BLUR: 'BLUR',\n UNDO: 'UNDO',\n REDO: 'REDO',\n} as const\n\ntype ChangeBuilderEditModeRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE\n editMode: BuilderEditMode\n}\n\ntype InitializeEditorRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.INITIALIZE_EDITOR\n value: ValueJSON\n}\n\ntype ChangeEditorValueRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE\n value: ValueJSON\n}\n\ntype FocusRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.FOCUS }\n\ntype BlurRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.BLUR }\n\ntype UndoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.UNDO }\n\ntype RedoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.REDO }\n\nexport type RichTextPropControllerMessage =\n | ChangeBuilderEditModeRichTextPropControllerMessage\n | InitializeEditorRichTextPropControllerMessage\n | ChangeEditorValueRichTextPropControllerMessage\n | FocusRichTextPropControllerMessage\n | BlurRichTextPropControllerMessage\n | UndoRichTextPropControllerMessage\n | RedoRichTextPropControllerMessage\n\nexport type PropControllerMessage = RichTextPropControllerMessage | TableFormFieldsMessage\n\ntype Send<T = PropControllerMessage> = (message: T) => void\n\nexport abstract class PropController<T = PropControllerMessage> {\n protected send: Send<T>\n\n constructor(send: Send<T>) {\n this.send = send\n }\n\n abstract recv(message: T): void\n}\n\nclass DefaultPropController extends PropController {\n recv(_message: PropControllerMessage): void {\n // Do nothing.\n }\n}\n\nclass RichTextPropController extends PropController<RichTextPropControllerMessage> {\n private editor: Editor | null = null\n\n recv(message: RichTextPropControllerMessage): void {\n switch (message.type) {\n case RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.editMode) {\n case BuilderEditMode.BUILD:\n this.editor?.deselect().blur()\n break\n\n case BuilderEditMode.CONTENT:\n this.editor?.focus().moveToRangeOfDocument()\n break\n }\n\n break\n }\n }\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.send({\n type: RichTextPropControllerMessageType.INITIALIZE_EDITOR,\n value: editor.value.toJSON({ preserveSelection: false }),\n })\n }\n\n onChange(change: OnChangeParam) {\n this.send({\n type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,\n value: change.value.toJSON({ preserveSelection: true }),\n })\n }\n\n focus() {\n this.send({ type: RichTextPropControllerMessageType.FOCUS })\n }\n\n blur() {\n this.send({ type: RichTextPropControllerMessageType.BLUR })\n }\n\n undo() {\n this.send({ type: RichTextPropControllerMessageType.UNDO })\n }\n\n redo() {\n this.send({ type: RichTextPropControllerMessageType.REDO })\n }\n}\n\nexport const TableFormFieldsMessageType = {\n TABLE_FORM_LAYOUT_CHANGE: 'TABLE_FORM_LAYOUT_CHANGE',\n TABLE_FORM_FIELD_LAYOUT_CHANGE: 'TABLE_FORM_FIELD_LAYOUT_CHANGE',\n} as const\n\ntype TableLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE\n payload: { layout: BoxModel }\n}\n\ntype TableFieldLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE\n payload: { layout: BoxModel; index: number }\n}\n\nexport type TableFormFieldsMessage =\n | TableLayoutTableFormFieldsMessage\n | TableFieldLayoutTableFormFieldsMessage\n\nexport class TableFormFieldsPropController extends PropController<TableFormFieldsMessage> {\n recv(): void {}\n\n tableFormLayoutChange(payload: { layout: BoxModel }) {\n this.send({ type: TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE, payload })\n }\n\n tableFormFieldLayoutChange(payload: { layout: BoxModel; index: number }) {\n this.send({ type: TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE, payload })\n }\n}\n\ntype DescriptorPropController<T extends Descriptor> = T extends { type: typeof Types.RichText }\n ? RichTextPropController\n : T extends { type: typeof Types.TableFormFields }\n ? TableFormFieldsPropController\n : DefaultPropController\n\nexport type DescriptorsPropControllers<T extends Record<string, Descriptor>> = {\n [K in keyof T]: undefined extends T[K]\n ? DescriptorPropController<Exclude<T[K], undefined>>\n : DescriptorPropController<T[K]>\n}\n\ntype AnyPropController =\n | DefaultPropController\n | RichTextPropController\n | TableFormFieldsPropController\n\nexport function createPropController(\n descriptor: RichTextDescriptor,\n send: Send<RichTextPropControllerMessage>,\n): RichTextPropController\nexport function createPropController(\n descriptor: TableFormFieldsDescriptor,\n send: Send<TableFormFieldsMessage>,\n): TableFormFieldsPropController\nexport function createPropController(descriptor: Descriptor, send: Send): DefaultPropController\nexport function createPropController<T extends PropControllerMessage>(\n descriptor: Descriptor,\n send: Send<T>,\n): AnyPropController {\n switch (descriptor.type) {\n case Types.RichText:\n return new RichTextPropController(send as Send<RichTextPropControllerMessage>)\n\n case Types.TableFormFields:\n return new TableFormFieldsPropController(send as Send<TableFormFieldsMessage>)\n\n default:\n return new DefaultPropController(send as Send)\n }\n}\n"],"names":["Types"],"mappings":";;;;;;;;AAAO,MAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,SAAS;AACX;ACIO,MAAM,oCAAoC;AAAA,EAC/C,0BAA0B;AAAA,EAC1B,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAsCO,MAAe,eAA0C;AAAA,EAG9D,YAAY,MAAe;AAFjB;AAGR,SAAK,OAAO;AAAA,EACd;AAGF;AAEA,MAAM,8BAA8B,eAAe;AAAA,EACjD,KAAK,UAAuC;AAAA,EAE5C;AACF;AAEA,MAAM,+BAA+B,eAA8C;AAAA,EAAnF;AAAA;AACU,kCAAwB;AAAA;AAAA,EAEhC,KAAK,SAA8C;;AACjD,YAAQ,QAAQ;AAAA,WACT,kCAAkC,0BAA0B;AAC/D,gBAAQ,QAAQ;AAAA,eACT,gBAAgB;AACd,uBAAA,WAAA,mBAAQ,WAAW;AACxB;AAAA,eAEG,gBAAgB;AACd,uBAAA,WAAA,mBAAQ,QAAQ;AACrB;AAAA;AAGJ;AAAA,MACF;AAAA;AAAA,EAEJ;AAAA,EAEA,eAAe,QAAgB;AAC7B,SAAK,SAAS;AAEd,SAAK,KAAK;AAAA,MACR,MAAM,kCAAkC;AAAA,MACxC,OAAO,OAAO,MAAM,OAAO,EAAE,mBAAmB,OAAO;AAAA,IAAA,CACxD;AAAA,EACH;AAAA,EAEA,SAAS,QAAuB;AAC9B,SAAK,KAAK;AAAA,MACR,MAAM,kCAAkC;AAAA,MACxC,OAAO,OAAO,MAAM,OAAO,EAAE,mBAAmB,MAAM;AAAA,IAAA,CACvD;AAAA,EACH;AAAA,EAEA,QAAQ;AACN,SAAK,KAAK,EAAE,MAAM,kCAAkC,MAAO,CAAA;AAAA,EAC7D;AAAA,EAEA,OAAO;AACL,SAAK,KAAK,EAAE,MAAM,kCAAkC,KAAM,CAAA;AAAA,EAC5D;AAAA,EAEA,OAAO;AACL,SAAK,KAAK,EAAE,MAAM,kCAAkC,KAAM,CAAA;AAAA,EAC5D;AAAA,EAEA,OAAO;AACL,SAAK,KAAK,EAAE,MAAM,kCAAkC,KAAM,CAAA;AAAA,EAC5D;AACF;AAEO,MAAM,6BAA6B;AAAA,EACxC,0BAA0B;AAAA,EAC1B,gCAAgC;AAClC;AAgBO,MAAM,sCAAsC,eAAuC;AAAA,EACxF,OAAa;AAAA,EAAC;AAAA,EAEd,sBAAsB,SAA+B;AACnD,SAAK,KAAK,EAAE,MAAM,2BAA2B,0BAA0B,SAAS;AAAA,EAClF;AAAA,EAEA,2BAA2B,SAA8C;AACvE,SAAK,KAAK,EAAE,MAAM,2BAA2B,gCAAgC,SAAS;AAAA,EACxF;AACF;AA4BO,8BACL,YACA,MACmB;AACnB,UAAQ,WAAW;AAAA,SACZA,YAAM,MAAA;AACF,aAAA,IAAI,uBAAuB,IAA2C;AAAA,SAE1EA,YAAM,MAAA;AACF,aAAA,IAAI,8BAA8B,IAAoC;AAAA;AAGtE,aAAA,IAAI,sBAAsB,IAAY;AAAA;AAEnD;;;;"}
|
package/dist/instances.es.js
CHANGED
|
@@ -75,13 +75,29 @@ class RichTextPropController extends PropController {
|
|
|
75
75
|
this.send({ type: RichTextPropControllerMessageType.REDO });
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
const TableFormFieldsMessageType = {
|
|
79
|
+
TABLE_FORM_LAYOUT_CHANGE: "TABLE_FORM_LAYOUT_CHANGE",
|
|
80
|
+
TABLE_FORM_FIELD_LAYOUT_CHANGE: "TABLE_FORM_FIELD_LAYOUT_CHANGE"
|
|
81
|
+
};
|
|
82
|
+
class TableFormFieldsPropController extends PropController {
|
|
83
|
+
recv() {
|
|
84
|
+
}
|
|
85
|
+
tableFormLayoutChange(payload) {
|
|
86
|
+
this.send({ type: TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE, payload });
|
|
87
|
+
}
|
|
88
|
+
tableFormFieldLayoutChange(payload) {
|
|
89
|
+
this.send({ type: TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE, payload });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
78
92
|
function createPropController(descriptor, send) {
|
|
79
93
|
switch (descriptor.type) {
|
|
80
94
|
case Types.RichText:
|
|
81
95
|
return new RichTextPropController(send);
|
|
96
|
+
case Types.TableFormFields:
|
|
97
|
+
return new TableFormFieldsPropController(send);
|
|
82
98
|
default:
|
|
83
99
|
return new DefaultPropController(send);
|
|
84
100
|
}
|
|
85
101
|
}
|
|
86
|
-
export { RichTextPropControllerMessageType as R, createPropController as c };
|
|
102
|
+
export { RichTextPropControllerMessageType as R, TableFormFieldsMessageType as T, createPropController as c };
|
|
87
103
|
//# sourceMappingURL=instances.es.js.map
|
package/dist/instances.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances.es.js","sources":["../src/utils/constants.ts","../src/prop-controllers/instances.ts"],"sourcesContent":["export const BuilderEditMode = {\n BUILD: 'build',\n CONTENT: 'content',\n} as const\n\nexport type BuilderEditMode = typeof BuilderEditMode[keyof typeof BuilderEditMode]\n","import { Editor } from 'slate-react'\nimport { ValueJSON } from 'slate'\nimport { OnChangeParam } from 'slate-react'\nimport { Descriptor, RichTextDescriptor, Types } from './descriptors'\nimport { BuilderEditMode } from '../utils/constants'\n\nexport const RichTextPropControllerMessageType = {\n CHANGE_BUILDER_EDIT_MODE: 'CHANGE_BUILDER_EDIT_MODE',\n INITIALIZE_EDITOR: 'INITIALIZE_EDITOR',\n CHANGE_EDITOR_VALUE: 'CHANGE_EDITOR_VALUE',\n FOCUS: 'FOCUS',\n BLUR: 'BLUR',\n UNDO: 'UNDO',\n REDO: 'REDO',\n} as const\n\ntype ChangeBuilderEditModeRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE\n editMode: BuilderEditMode\n}\n\ntype InitializeEditorRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.INITIALIZE_EDITOR\n value: ValueJSON\n}\n\ntype ChangeEditorValueRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE\n value: ValueJSON\n}\n\ntype FocusRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.FOCUS }\n\ntype BlurRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.BLUR }\n\ntype UndoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.UNDO }\n\ntype RedoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.REDO }\n\nexport type RichTextPropControllerMessage =\n | ChangeBuilderEditModeRichTextPropControllerMessage\n | InitializeEditorRichTextPropControllerMessage\n | ChangeEditorValueRichTextPropControllerMessage\n | FocusRichTextPropControllerMessage\n | BlurRichTextPropControllerMessage\n | UndoRichTextPropControllerMessage\n | RedoRichTextPropControllerMessage\n\nexport type PropControllerMessage = RichTextPropControllerMessage\n\ntype Send<T = PropControllerMessage> = (message: T) => void\n\nexport abstract class PropController<T = PropControllerMessage> {\n protected send: Send<T>\n\n constructor(send: Send<T>) {\n this.send = send\n }\n\n abstract recv(message: T): void\n}\n\nclass DefaultPropController extends PropController {\n recv(_message: PropControllerMessage): void {\n // Do nothing.\n }\n}\n\nclass RichTextPropController extends PropController<RichTextPropControllerMessage> {\n private editor: Editor | null = null\n\n recv(message: RichTextPropControllerMessage): void {\n switch (message.type) {\n case RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.editMode) {\n case BuilderEditMode.BUILD:\n this.editor?.deselect().blur()\n break\n\n case BuilderEditMode.CONTENT:\n this.editor?.focus().moveToRangeOfDocument()\n break\n }\n\n break\n }\n }\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.send({\n type: RichTextPropControllerMessageType.INITIALIZE_EDITOR,\n value: editor.value.toJSON({ preserveSelection: false }),\n })\n }\n\n onChange(change: OnChangeParam) {\n this.send({\n type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,\n value: change.value.toJSON({ preserveSelection: true }),\n })\n }\n\n focus() {\n this.send({ type: RichTextPropControllerMessageType.FOCUS })\n }\n\n blur() {\n this.send({ type: RichTextPropControllerMessageType.BLUR })\n }\n\n undo() {\n this.send({ type: RichTextPropControllerMessageType.UNDO })\n }\n\n redo() {\n this.send({ type: RichTextPropControllerMessageType.REDO })\n }\n}\n\ntype DescriptorPropController<T extends Descriptor> = T extends { type: typeof Types.RichText }\n ? RichTextPropController\n : DefaultPropController\n\nexport type DescriptorsPropControllers<T extends Record<string, Descriptor>> = {\n [K in keyof T]: undefined extends T[K]\n ? DescriptorPropController<Exclude<T[K], undefined>>\n : DescriptorPropController<T[K]>\n}\n\nexport function createPropController(\n descriptor: RichTextDescriptor,\n send: Send<RichTextPropControllerMessage>,\n): RichTextPropController\nexport function createPropController(descriptor: Descriptor, send: Send):
|
|
1
|
+
{"version":3,"file":"instances.es.js","sources":["../src/utils/constants.ts","../src/prop-controllers/instances.ts"],"sourcesContent":["export const BuilderEditMode = {\n BUILD: 'build',\n CONTENT: 'content',\n} as const\n\nexport type BuilderEditMode = typeof BuilderEditMode[keyof typeof BuilderEditMode]\n","import { Editor } from 'slate-react'\nimport { ValueJSON } from 'slate'\nimport { OnChangeParam } from 'slate-react'\nimport { Descriptor, RichTextDescriptor, TableFormFieldsDescriptor, Types } from './descriptors'\nimport { BuilderEditMode } from '../utils/constants'\nimport { BoxModel } from '../state/modules/box-models'\n\nexport const RichTextPropControllerMessageType = {\n CHANGE_BUILDER_EDIT_MODE: 'CHANGE_BUILDER_EDIT_MODE',\n INITIALIZE_EDITOR: 'INITIALIZE_EDITOR',\n CHANGE_EDITOR_VALUE: 'CHANGE_EDITOR_VALUE',\n FOCUS: 'FOCUS',\n BLUR: 'BLUR',\n UNDO: 'UNDO',\n REDO: 'REDO',\n} as const\n\ntype ChangeBuilderEditModeRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE\n editMode: BuilderEditMode\n}\n\ntype InitializeEditorRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.INITIALIZE_EDITOR\n value: ValueJSON\n}\n\ntype ChangeEditorValueRichTextPropControllerMessage = {\n type: typeof RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE\n value: ValueJSON\n}\n\ntype FocusRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.FOCUS }\n\ntype BlurRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.BLUR }\n\ntype UndoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.UNDO }\n\ntype RedoRichTextPropControllerMessage = { type: typeof RichTextPropControllerMessageType.REDO }\n\nexport type RichTextPropControllerMessage =\n | ChangeBuilderEditModeRichTextPropControllerMessage\n | InitializeEditorRichTextPropControllerMessage\n | ChangeEditorValueRichTextPropControllerMessage\n | FocusRichTextPropControllerMessage\n | BlurRichTextPropControllerMessage\n | UndoRichTextPropControllerMessage\n | RedoRichTextPropControllerMessage\n\nexport type PropControllerMessage = RichTextPropControllerMessage | TableFormFieldsMessage\n\ntype Send<T = PropControllerMessage> = (message: T) => void\n\nexport abstract class PropController<T = PropControllerMessage> {\n protected send: Send<T>\n\n constructor(send: Send<T>) {\n this.send = send\n }\n\n abstract recv(message: T): void\n}\n\nclass DefaultPropController extends PropController {\n recv(_message: PropControllerMessage): void {\n // Do nothing.\n }\n}\n\nclass RichTextPropController extends PropController<RichTextPropControllerMessage> {\n private editor: Editor | null = null\n\n recv(message: RichTextPropControllerMessage): void {\n switch (message.type) {\n case RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.editMode) {\n case BuilderEditMode.BUILD:\n this.editor?.deselect().blur()\n break\n\n case BuilderEditMode.CONTENT:\n this.editor?.focus().moveToRangeOfDocument()\n break\n }\n\n break\n }\n }\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.send({\n type: RichTextPropControllerMessageType.INITIALIZE_EDITOR,\n value: editor.value.toJSON({ preserveSelection: false }),\n })\n }\n\n onChange(change: OnChangeParam) {\n this.send({\n type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,\n value: change.value.toJSON({ preserveSelection: true }),\n })\n }\n\n focus() {\n this.send({ type: RichTextPropControllerMessageType.FOCUS })\n }\n\n blur() {\n this.send({ type: RichTextPropControllerMessageType.BLUR })\n }\n\n undo() {\n this.send({ type: RichTextPropControllerMessageType.UNDO })\n }\n\n redo() {\n this.send({ type: RichTextPropControllerMessageType.REDO })\n }\n}\n\nexport const TableFormFieldsMessageType = {\n TABLE_FORM_LAYOUT_CHANGE: 'TABLE_FORM_LAYOUT_CHANGE',\n TABLE_FORM_FIELD_LAYOUT_CHANGE: 'TABLE_FORM_FIELD_LAYOUT_CHANGE',\n} as const\n\ntype TableLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE\n payload: { layout: BoxModel }\n}\n\ntype TableFieldLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE\n payload: { layout: BoxModel; index: number }\n}\n\nexport type TableFormFieldsMessage =\n | TableLayoutTableFormFieldsMessage\n | TableFieldLayoutTableFormFieldsMessage\n\nexport class TableFormFieldsPropController extends PropController<TableFormFieldsMessage> {\n recv(): void {}\n\n tableFormLayoutChange(payload: { layout: BoxModel }) {\n this.send({ type: TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE, payload })\n }\n\n tableFormFieldLayoutChange(payload: { layout: BoxModel; index: number }) {\n this.send({ type: TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE, payload })\n }\n}\n\ntype DescriptorPropController<T extends Descriptor> = T extends { type: typeof Types.RichText }\n ? RichTextPropController\n : T extends { type: typeof Types.TableFormFields }\n ? TableFormFieldsPropController\n : DefaultPropController\n\nexport type DescriptorsPropControllers<T extends Record<string, Descriptor>> = {\n [K in keyof T]: undefined extends T[K]\n ? DescriptorPropController<Exclude<T[K], undefined>>\n : DescriptorPropController<T[K]>\n}\n\ntype AnyPropController =\n | DefaultPropController\n | RichTextPropController\n | TableFormFieldsPropController\n\nexport function createPropController(\n descriptor: RichTextDescriptor,\n send: Send<RichTextPropControllerMessage>,\n): RichTextPropController\nexport function createPropController(\n descriptor: TableFormFieldsDescriptor,\n send: Send<TableFormFieldsMessage>,\n): TableFormFieldsPropController\nexport function createPropController(descriptor: Descriptor, send: Send): DefaultPropController\nexport function createPropController<T extends PropControllerMessage>(\n descriptor: Descriptor,\n send: Send<T>,\n): AnyPropController {\n switch (descriptor.type) {\n case Types.RichText:\n return new RichTextPropController(send as Send<RichTextPropControllerMessage>)\n\n case Types.TableFormFields:\n return new TableFormFieldsPropController(send as Send<TableFormFieldsMessage>)\n\n default:\n return new DefaultPropController(send as Send)\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAO,MAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,SAAS;AACX;ACIO,MAAM,oCAAoC;AAAA,EAC/C,0BAA0B;AAAA,EAC1B,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAsCO,MAAe,eAA0C;AAAA,EAG9D,YAAY,MAAe;AAFjB;AAGR,SAAK,OAAO;AAAA,EACd;AAGF;AAEA,MAAM,8BAA8B,eAAe;AAAA,EACjD,KAAK,UAAuC;AAAA,EAE5C;AACF;AAEA,MAAM,+BAA+B,eAA8C;AAAA,EAAnF;AAAA;AACU,kCAAwB;AAAA;AAAA,EAEhC,KAAK,SAA8C;;AACjD,YAAQ,QAAQ;AAAA,W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,MAAM;AACF,aAAA,IAAI,uBAAuB,IAA2C;AAAA,SAE1E,MAAM;AACF,aAAA,IAAI,8BAA8B,IAAoC;AAAA;AAGtE,aAAA,IAAI,sBAAsB,IAAY;AAAA;AAEnD;;"}
|
package/dist/main.cjs.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
var actions = require("./actions.cjs.js");
|
|
4
|
+
var reactPage = require("./react-page.cjs.js");
|
|
5
|
+
require("redux");
|
|
6
|
+
require("redux-thunk");
|
|
7
|
+
require("./descriptors.cjs.js");
|
|
4
8
|
exports.ActionTypes = actions.ActionTypes;
|
|
5
9
|
exports.changeApiResource = actions.changeApiResource;
|
|
6
10
|
exports.changeDocument = actions.changeDocument;
|
|
7
11
|
exports.changeDocumentElementScrollTop = actions.changeDocumentElementScrollTop;
|
|
8
12
|
exports.cleanUp = actions.cleanUp;
|
|
13
|
+
exports.evictApiResource = actions.evictApiResource;
|
|
9
14
|
exports.init = actions.init;
|
|
10
15
|
exports.messageHostPropController = actions.messageHostPropController;
|
|
16
|
+
exports.registerDocument = actions.registerDocument;
|
|
17
|
+
exports.scrollDocumentElement = actions.scrollDocumentElement;
|
|
18
|
+
exports.unregisterDocument = actions.unregisterDocument;
|
|
19
|
+
exports.createDocument = reactPage.createDocument;
|
|
11
20
|
//# sourceMappingURL=main.cjs.js.map
|
package/dist/main.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.es.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { A as ActionTypes, d as changeApiResource, c as changeDocument, a as changeDocumentElementScrollTop, b as cleanUp, i as init, m as messageHostPropController } from "./actions.es.js";
|
|
1
|
+
export { A as ActionTypes, d as changeApiResource, c as changeDocument, a as changeDocumentElementScrollTop, b as cleanUp, e as evictApiResource, i as init, m as messageHostPropController, r as registerDocument, s as scrollDocumentElement, u as unregisterDocument } from "./actions.es.js";
|
|
2
|
+
export { c as createDocument } from "./react-page.es.js";
|
|
3
|
+
import "redux";
|
|
4
|
+
import "redux-thunk";
|
|
5
|
+
import "./descriptors.es.js";
|
|
2
6
|
//# sourceMappingURL=main.es.js.map
|
package/dist/main.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/next.cjs.js
CHANGED
|
@@ -20,17 +20,23 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
21
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
22
22
|
var NextDocument = require("next/document");
|
|
23
|
+
var React = require("react");
|
|
23
24
|
var styled = require("styled-components");
|
|
24
25
|
var react = require("./react.cjs2.js");
|
|
26
|
+
var Page$1 = require("./Page.cjs.js");
|
|
25
27
|
var jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
require("react");
|
|
27
28
|
require("use-sync-external-store/shim/with-selector");
|
|
28
29
|
require("@apollo/client");
|
|
30
|
+
require("./react-page.cjs.js");
|
|
29
31
|
require("redux");
|
|
30
32
|
require("redux-thunk");
|
|
31
33
|
require("./actions.cjs.js");
|
|
32
34
|
require("./descriptors.cjs.js");
|
|
33
35
|
require("framer-motion");
|
|
36
|
+
require("@apollo/client/react/ssr");
|
|
37
|
+
require("uuid/v4");
|
|
38
|
+
require("html-react-parser");
|
|
39
|
+
require("next/head");
|
|
34
40
|
require("./box-models.cjs.js");
|
|
35
41
|
require("css-box-model");
|
|
36
42
|
require("next/image");
|
|
@@ -40,7 +46,7 @@ require("scroll-into-view-if-needed");
|
|
|
40
46
|
require("next/link");
|
|
41
47
|
require("react-use-gesture");
|
|
42
48
|
require("@popmotion/popcorn");
|
|
43
|
-
require("
|
|
49
|
+
require("formik");
|
|
44
50
|
require("polished");
|
|
45
51
|
require("slate");
|
|
46
52
|
require("slate-hotkeys");
|
|
@@ -93,11 +99,17 @@ async function getServerSideProps({
|
|
|
93
99
|
return {
|
|
94
100
|
notFound: true
|
|
95
101
|
};
|
|
102
|
+
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
103
|
+
const client = new react.MakeswiftClient({
|
|
104
|
+
uri: makeswiftApiEndpoint
|
|
105
|
+
});
|
|
106
|
+
const cacheData = await client.prefetch(page.data);
|
|
96
107
|
return {
|
|
97
108
|
props: {
|
|
98
|
-
|
|
109
|
+
page,
|
|
99
110
|
rootElement: page.data,
|
|
100
|
-
makeswiftApiEndpoint
|
|
111
|
+
makeswiftApiEndpoint,
|
|
112
|
+
cacheData
|
|
101
113
|
}
|
|
102
114
|
};
|
|
103
115
|
}
|
|
@@ -131,11 +143,17 @@ async function getStaticProps({
|
|
|
131
143
|
notFound: true,
|
|
132
144
|
revalidate: REVALIDATE_SECONDS
|
|
133
145
|
};
|
|
146
|
+
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
147
|
+
const client = new react.MakeswiftClient({
|
|
148
|
+
uri: makeswiftApiEndpoint
|
|
149
|
+
});
|
|
150
|
+
const cacheData = await client.prefetch(page.data);
|
|
134
151
|
return {
|
|
135
152
|
props: {
|
|
136
|
-
|
|
153
|
+
page,
|
|
137
154
|
rootElement: page.data,
|
|
138
|
-
makeswiftApiEndpoint
|
|
155
|
+
makeswiftApiEndpoint,
|
|
156
|
+
cacheData
|
|
139
157
|
},
|
|
140
158
|
revalidate: REVALIDATE_SECONDS
|
|
141
159
|
};
|
|
@@ -147,17 +165,20 @@ async function getStaticPaths() {
|
|
|
147
165
|
};
|
|
148
166
|
}
|
|
149
167
|
function Page({
|
|
150
|
-
|
|
168
|
+
page,
|
|
151
169
|
rootElement,
|
|
152
170
|
makeswiftApiEndpoint,
|
|
153
|
-
|
|
171
|
+
cacheData
|
|
154
172
|
}) {
|
|
173
|
+
const [client] = React.useState(() => new react.MakeswiftClient({
|
|
174
|
+
uri: makeswiftApiEndpoint,
|
|
175
|
+
cacheData
|
|
176
|
+
}));
|
|
155
177
|
return /* @__PURE__ */ jsxRuntime.jsx(react.RuntimeProvider, {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
documentKey: pageId
|
|
178
|
+
client,
|
|
179
|
+
defaultRootElements: /* @__PURE__ */ new Map([[page.id, rootElement]]),
|
|
180
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Page$1.Page, {
|
|
181
|
+
page
|
|
161
182
|
})
|
|
162
183
|
});
|
|
163
184
|
}
|
package/dist/next.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.cjs.js","sources":["../src/next.tsx"],"sourcesContent":["import {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps } from 'next/document'\nimport { ServerStyleSheet } from 'styled-components'\n\nimport {
|
|
1
|
+
{"version":3,"file":"next.cjs.js","sources":["../src/next.tsx"],"sourcesContent":["import { NormalizedCacheObject } from '@apollo/client'\nimport {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps } from 'next/document'\nimport { useState } from 'react'\nimport { ServerStyleSheet } from 'styled-components'\n\nimport { MakeswiftClient } from './api/react'\nimport { Element } from './state/react-page'\nimport { RuntimeProvider } from './runtimes/react'\nimport { Page as PageMeta, PageData } from './components'\n\nexport class Document extends NextDocument {\n static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {\n const sheet = new ServerStyleSheet()\n const originalRenderPage = ctx.renderPage\n\n try {\n ctx.renderPage = () =>\n originalRenderPage({\n enhanceApp: App => props => sheet.collectStyles(<App {...props} />),\n })\n\n const initialProps = await NextDocument.getInitialProps(ctx)\n\n return {\n ...initialProps,\n styles: (\n <>\n {initialProps.styles}\n {sheet.getStyleElement()}\n </>\n ),\n }\n } finally {\n sheet.seal()\n }\n }\n}\n\nconst REVALIDATE_SECONDS = 1\n\nexport type PageProps = {\n page: PageData\n rootElement: Element\n makeswiftApiEndpoint: string\n cacheData: NormalizedCacheObject\n}\n\ntype APIResult = PageData & {\n data: any\n}\n\nexport async function getServerSideProps({\n query: { pageId },\n}: GetServerSidePropsContext): Promise<GetServerSidePropsResult<PageProps>> {\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/preview-page-data?id=${pageId}`\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n },\n }\n}\n\nexport async function getStaticProps({\n params,\n}: GetStaticPropsContext<{ path: string[] }>): Promise<GetStaticPropsResult<PageProps>> {\n if (params == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n const { path = [] } = params\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/live-page-data?path=${path.join('/')}`\n\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true, revalidate: REVALIDATE_SECONDS }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n },\n revalidate: REVALIDATE_SECONDS,\n }\n}\n\nexport async function getStaticPaths(): Promise<GetStaticPathsResult> {\n return { paths: [], fallback: 'blocking' }\n}\n\nexport function Page({ page, rootElement, makeswiftApiEndpoint, cacheData }: PageProps) {\n const [client] = useState(() => new MakeswiftClient({ uri: makeswiftApiEndpoint, cacheData }))\n\n return (\n <RuntimeProvider client={client} defaultRootElements={new Map([[page.id, rootElement]])}>\n <PageMeta page={page} />\n </RuntimeProvider>\n )\n}\n"],"names":["Document","NextDocument","getInitialProps","ctx","sheet","ServerStyleSheet","originalRenderPage","renderPage","enhanceApp","App","props","collectStyles","initialProps","styles","_Fragment","getStyleElement","seal","REVALIDATE_SECONDS","query","pageId","url","process","MAKESWIFT_API_HOST","res","fetch","headers","MAKESWIFT_SITE_API_KEY","status","console","error","json","notFound","page","makeswiftApiEndpoint","client","MakeswiftClient","uri","cacheData","prefetch","data","rootElement","params","revalidate","path","join","paths","fallback","useState","RuntimeProvider","Map","id","PageMeta"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,MAAMA,iBAAiBC,sBAAAA,WAAa;AAAA,eAC5BC,gBAAgBC,KAAqD;AAC1EC,UAAAA,QAAQ,IAAIC,OAAAA;AAClB,UAAMC,qBAAqBH,IAAII;AAE3B,QAAA;AACEA,UAAAA,aAAa,MACfD,mBAAmB;AAAA,QAC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AAjD,CAAA,CAAP;AAEzB,wCACGW,MAAAA,iBAAD;AAAA,IAAiB;AAAA,IAAgB,yCAAyBC,IAAI,CAAC,CAACjB,KAAKkB,IAAIV,WAAV,CAAD,CAAR;AAAA,IAAtD,yCACGW,aAAD;AAAA,MAAU;AAAA,IAAA,CAAV;AAAA,EAAA,CAFJ;AAKD;;;;;;"}
|
package/dist/next.es.js
CHANGED
|
@@ -18,17 +18,23 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import NextDocument from "next/document";
|
|
21
|
+
import { useState } from "react";
|
|
21
22
|
import { ServerStyleSheet } from "styled-components";
|
|
22
|
-
import {
|
|
23
|
+
import { Q as MakeswiftClient, R as RuntimeProvider } from "./react.es2.js";
|
|
24
|
+
import { P as Page$1 } from "./Page.es.js";
|
|
23
25
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
24
|
-
import "react";
|
|
25
26
|
import "use-sync-external-store/shim/with-selector";
|
|
26
27
|
import "@apollo/client";
|
|
28
|
+
import "./react-page.es.js";
|
|
27
29
|
import "redux";
|
|
28
30
|
import "redux-thunk";
|
|
29
31
|
import "./actions.es.js";
|
|
30
32
|
import "./descriptors.es.js";
|
|
31
33
|
import "framer-motion";
|
|
34
|
+
import "@apollo/client/react/ssr";
|
|
35
|
+
import "uuid/v4";
|
|
36
|
+
import "html-react-parser";
|
|
37
|
+
import "next/head";
|
|
32
38
|
import "./box-models.es.js";
|
|
33
39
|
import "css-box-model";
|
|
34
40
|
import "next/image";
|
|
@@ -38,7 +44,7 @@ import "scroll-into-view-if-needed";
|
|
|
38
44
|
import "next/link";
|
|
39
45
|
import "react-use-gesture";
|
|
40
46
|
import "@popmotion/popcorn";
|
|
41
|
-
import "
|
|
47
|
+
import "formik";
|
|
42
48
|
import "polished";
|
|
43
49
|
import "slate";
|
|
44
50
|
import "slate-hotkeys";
|
|
@@ -87,11 +93,17 @@ async function getServerSideProps({
|
|
|
87
93
|
return {
|
|
88
94
|
notFound: true
|
|
89
95
|
};
|
|
96
|
+
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
97
|
+
const client = new MakeswiftClient({
|
|
98
|
+
uri: makeswiftApiEndpoint
|
|
99
|
+
});
|
|
100
|
+
const cacheData = await client.prefetch(page.data);
|
|
90
101
|
return {
|
|
91
102
|
props: {
|
|
92
|
-
|
|
103
|
+
page,
|
|
93
104
|
rootElement: page.data,
|
|
94
|
-
makeswiftApiEndpoint
|
|
105
|
+
makeswiftApiEndpoint,
|
|
106
|
+
cacheData
|
|
95
107
|
}
|
|
96
108
|
};
|
|
97
109
|
}
|
|
@@ -125,11 +137,17 @@ async function getStaticProps({
|
|
|
125
137
|
notFound: true,
|
|
126
138
|
revalidate: REVALIDATE_SECONDS
|
|
127
139
|
};
|
|
140
|
+
const makeswiftApiEndpoint = `${process["env"].MAKESWIFT_API_HOST}/graphql`;
|
|
141
|
+
const client = new MakeswiftClient({
|
|
142
|
+
uri: makeswiftApiEndpoint
|
|
143
|
+
});
|
|
144
|
+
const cacheData = await client.prefetch(page.data);
|
|
128
145
|
return {
|
|
129
146
|
props: {
|
|
130
|
-
|
|
147
|
+
page,
|
|
131
148
|
rootElement: page.data,
|
|
132
|
-
makeswiftApiEndpoint
|
|
149
|
+
makeswiftApiEndpoint,
|
|
150
|
+
cacheData
|
|
133
151
|
},
|
|
134
152
|
revalidate: REVALIDATE_SECONDS
|
|
135
153
|
};
|
|
@@ -141,17 +159,20 @@ async function getStaticPaths() {
|
|
|
141
159
|
};
|
|
142
160
|
}
|
|
143
161
|
function Page({
|
|
144
|
-
|
|
162
|
+
page,
|
|
145
163
|
rootElement,
|
|
146
164
|
makeswiftApiEndpoint,
|
|
147
|
-
|
|
165
|
+
cacheData
|
|
148
166
|
}) {
|
|
167
|
+
const [client] = useState(() => new MakeswiftClient({
|
|
168
|
+
uri: makeswiftApiEndpoint,
|
|
169
|
+
cacheData
|
|
170
|
+
}));
|
|
149
171
|
return /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
documentKey: pageId
|
|
172
|
+
client,
|
|
173
|
+
defaultRootElements: /* @__PURE__ */ new Map([[page.id, rootElement]]),
|
|
174
|
+
children: /* @__PURE__ */ jsx(Page$1, {
|
|
175
|
+
page
|
|
155
176
|
})
|
|
156
177
|
});
|
|
157
178
|
}
|
package/dist/next.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.es.js","sources":["../src/next.tsx"],"sourcesContent":["import {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps } from 'next/document'\nimport { ServerStyleSheet } from 'styled-components'\n\nimport {
|
|
1
|
+
{"version":3,"file":"next.es.js","sources":["../src/next.tsx"],"sourcesContent":["import { NormalizedCacheObject } from '@apollo/client'\nimport {\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n GetStaticPathsResult,\n GetStaticPropsContext,\n GetStaticPropsResult,\n} from 'next'\nimport NextDocument, { DocumentContext, DocumentInitialProps } from 'next/document'\nimport { useState } from 'react'\nimport { ServerStyleSheet } from 'styled-components'\n\nimport { MakeswiftClient } from './api/react'\nimport { Element } from './state/react-page'\nimport { RuntimeProvider } from './runtimes/react'\nimport { Page as PageMeta, PageData } from './components'\n\nexport class Document extends NextDocument {\n static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {\n const sheet = new ServerStyleSheet()\n const originalRenderPage = ctx.renderPage\n\n try {\n ctx.renderPage = () =>\n originalRenderPage({\n enhanceApp: App => props => sheet.collectStyles(<App {...props} />),\n })\n\n const initialProps = await NextDocument.getInitialProps(ctx)\n\n return {\n ...initialProps,\n styles: (\n <>\n {initialProps.styles}\n {sheet.getStyleElement()}\n </>\n ),\n }\n } finally {\n sheet.seal()\n }\n }\n}\n\nconst REVALIDATE_SECONDS = 1\n\nexport type PageProps = {\n page: PageData\n rootElement: Element\n makeswiftApiEndpoint: string\n cacheData: NormalizedCacheObject\n}\n\ntype APIResult = PageData & {\n data: any\n}\n\nexport async function getServerSideProps({\n query: { pageId },\n}: GetServerSidePropsContext): Promise<GetServerSidePropsResult<PageProps>> {\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/preview-page-data?id=${pageId}`\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n },\n }\n}\n\nexport async function getStaticProps({\n params,\n}: GetStaticPropsContext<{ path: string[] }>): Promise<GetStaticPropsResult<PageProps>> {\n if (params == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n const { path = [] } = params\n const url = `${process['env'].MAKESWIFT_API_HOST}/v0/live-page-data?path=${path.join('/')}`\n\n const res = await fetch(url, {\n headers: { 'x-api-key': process['env'].MAKESWIFT_SITE_API_KEY! },\n })\n\n if (res.status !== 200) {\n console.error(await res.json())\n\n return { notFound: true, revalidate: REVALIDATE_SECONDS }\n }\n\n const page: APIResult = await res.json()\n\n if (page == null) return { notFound: true, revalidate: REVALIDATE_SECONDS }\n\n const makeswiftApiEndpoint = `${process['env'].MAKESWIFT_API_HOST}/graphql`\n const client = new MakeswiftClient({ uri: makeswiftApiEndpoint })\n const cacheData = await client.prefetch(page.data)\n\n return {\n props: {\n page,\n rootElement: page.data,\n makeswiftApiEndpoint,\n cacheData,\n },\n revalidate: REVALIDATE_SECONDS,\n }\n}\n\nexport async function getStaticPaths(): Promise<GetStaticPathsResult> {\n return { paths: [], fallback: 'blocking' }\n}\n\nexport function Page({ page, rootElement, makeswiftApiEndpoint, cacheData }: PageProps) {\n const [client] = useState(() => new MakeswiftClient({ uri: makeswiftApiEndpoint, cacheData }))\n\n return (\n <RuntimeProvider client={client} defaultRootElements={new Map([[page.id, rootElement]])}>\n <PageMeta page={page} />\n </RuntimeProvider>\n )\n}\n"],"names":["Document","NextDocument","getInitialProps","ctx","sheet","ServerStyleSheet","originalRenderPage","renderPage","enhanceApp","App","props","collectStyles","initialProps","styles","_Fragment","getStyleElement","seal","REVALIDATE_SECONDS","query","pageId","url","process","MAKESWIFT_API_HOST","res","fetch","headers","MAKESWIFT_SITE_API_KEY","status","console","error","json","notFound","page","makeswiftApiEndpoint","client","MakeswiftClient","uri","cacheData","prefetch","data","rootElement","params","revalidate","path","join","paths","fallback","useState","Map","id","PageMeta"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,MAAMA,iBAAiBC,aAAa;AAAA,eAC5BC,gBAAgBC,KAAqD;AAC1EC,UAAAA,QAAQ,IAAIC;AAClB,UAAMC,qBAAqBH,IAAII;AAE3B,QAAA;AACEA,UAAAA,aAAa,MACfD,mBAAmB;AAAA,QACjBE,YAAYC,CAAOC,QAAAA,CAAAA,UAASN,MAAMO,kCAAe,KAAQD,mBAAAA,MAA7B,CAAA;AAAA,MAAA,CADZ;AAIdE,YAAAA,eAAe,MAAMX,aAAaC,gBAAgBC,GAA7B;AAEpB,aAAA,iCACFS,eADE;AAAA,QAELC,6BACEC,UAAA;AAAA,UAAA,UAAA,CACGF,aAAaC,QACbT,MAAMW,iBAFT;AAAA,QAAA,CAAA;AAAA,MAAA;AAAA,IAHJ,UASQ;AACRX,YAAMY,KAAN;AAAA,IACD;AAAA,EACF;AAzBwC;AA4B3C,MAAMC,qBA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