@makeswift/runtime 0.0.0-602aed3 → 0.0.0-67a73fb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.cjs.js +8 -0
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +1 -1
- package/dist/control-serialization.cjs.js +42 -5
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +42 -5
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js.map +1 -1
- package/dist/react-page.cjs.js +1 -1
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +1 -1
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs2.js +8 -0
- package/dist/react.cjs2.js.map +1 -1
- package/dist/react.es2.js +1 -1
- package/dist/types/builder/serialization/control-serialization.d.ts +35 -7
- package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/prop-controllers/descriptors.d.ts +5 -4
- package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/prop-controllers/index.d.ts +1 -1
- package/dist/types/prop-controllers/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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 Typeahead: 'Typeahead',\n TextArea: 'TextArea',\n TextInput: 'TextInput',\n TextStyle: 'TextStyle',\n Video: 'Video',\n Width: 'Width',\n} as const\n\ntype Options<T> = T | ((props: Record<string, unknown>, decideMode: Device) => T)\n\ntype ColorBackground = { type: 'color'; id: string; payload: Color | null }\n\ntype GradientStop = { id: string; location: number; color: Color | null }\n\ntype Gradient = { angle?: number; isRadial?: boolean; stops: GradientStop[] }\n\ntype GradientBackground = { type: 'gradient'; id: string; payload: Gradient }\n\ntype BackgroundImagePosition = { x: number; y: number }\n\ntype BackgroundImageSize = 'cover' | 'contain' | 'auto'\n\ntype BackgroundImageRepeat = 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat'\n\ntype BackgroundImage = {\n imageId: string\n position: BackgroundImagePosition\n size?: BackgroundImageSize\n repeat?: BackgroundImageRepeat\n opacity?: number\n parallax?: number\n}\n\ntype ImageBackground = { type: 'image'; id: string; payload: BackgroundImage }\n\ntype BackgroundVideoAspectRatio = 'wide' | 'standard'\n\ntype BackgroundVideo = {\n url?: string\n maskColor?: Color | null\n opacity?: number\n zoom?: number\n aspectRatio?: BackgroundVideoAspectRatio\n parallax?: number\n}\n\ntype VideoBackground = { type: 'video'; id: string; payload: BackgroundVideo }\n\ntype Background = ColorBackground | GradientBackground | ImageBackground | VideoBackground\n\nexport type BackgroundsValue = ResponsiveValue<Background[]>\n\ntype BackgroundsOptions = Options<Record<string, never>>\n\ntype BackgroundsDescriptor<_T = BackgroundsValue> = {\n type: typeof Types.Backgrounds\n options: BackgroundsOptions\n}\n\nexport function Backgrounds(options: BackgroundsOptions = {}): BackgroundsDescriptor {\n return { type: Types.Backgrounds, options }\n}\n\ntype BorderSideStyle = 'dashed' | 'dotted' | 'solid'\n\ntype BorderSide = { width: number | null | undefined; style: BorderSideStyle; color?: Color | null }\n\ntype Border = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `border${Capitalize<K>}`]:\n | BorderSide\n | null\n | undefined\n}\n\nexport type BorderValue = ResponsiveValue<Border>\n\ntype BorderOptions = Options<Record<string, never>>\n\ntype BorderDescriptor<_T = BorderValue> = { type: typeof Types.Border; options: BorderOptions }\n\nexport function Border(options: BorderOptions = {}): BorderDescriptor {\n return { type: Types.Border, options }\n}\n\ntype BorderRadius = {\n [K in 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' as `border${Capitalize<K>}Radius`]:\n | Length\n | null\n | undefined\n}\n\nexport type BorderRadiusValue = ResponsiveValue<BorderRadius>\n\ntype BorderRadiusOptions = Options<Record<string, never>>\n\ntype BorderRadiusDescriptor<_T = BorderRadiusValue> = {\n type: typeof Types.BorderRadius\n options: BorderRadiusOptions\n}\n\nexport function BorderRadius(options: BorderRadiusOptions = {}): BorderRadiusDescriptor {\n return { type: Types.BorderRadius, options }\n}\n\nexport type CheckboxValue = boolean\n\ntype CheckboxOptions = Options<{\n preset?: CheckboxValue\n label: string\n hidden?: boolean\n}>\n\ntype CheckboxDescriptor<_T = CheckboxValue> = {\n type: typeof Types.Checkbox\n options: CheckboxOptions\n}\n\nexport function Checkbox(options: CheckboxOptions): CheckboxDescriptor {\n return { type: Types.Checkbox, options }\n}\n\nexport type DateValue = string\n\ntype DateOptions = Options<{ preset?: DateValue }>\n\ntype DateDescriptor<_T = DateValue> = { type: typeof Types.Date; options: DateOptions }\n\nexport function Date(options: DateOptions = {}): DateDescriptor {\n return { type: Types.Date, options }\n}\n\nexport type ElementIDValue = string\n\ntype ElementIDOptions = Options<Record<string, never>>\n\ntype ElementIDDescriptor<_T = ElementIDValue> = {\n type: typeof Types.ElementID\n options: ElementIDOptions\n}\n\nexport function ElementID(options: ElementIDOptions = {}): ElementIDDescriptor {\n return { type: Types.ElementID, options }\n}\n\nexport type FontValue = ResponsiveValue<string>\n\ntype FontOptions = Options<{ preset?: FontValue; label?: string }>\n\ntype FontDescriptor<_T = FontValue> = { type: typeof Types.Font; options: FontOptions }\n\nexport function Font(options: FontOptions = {}): FontDescriptor {\n return { type: Types.Font, options }\n}\n\nexport type GapXValue = ResponsiveValue<Gap>\n\ntype GapXOptions = Options<{\n preset?: GapXValue\n label?: string\n defaultValue?: Gap\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}>\n\ntype GapXDescriptor<_T = GapXValue> = { type: typeof Types.GapX; options: GapXOptions }\n\nexport function GapX(options: GapXOptions = {}): GapXDescriptor {\n return { type: Types.GapX, options }\n}\n\nexport type GapYValue = ResponsiveValue<Gap>\n\ntype GapYOptions = Options<{\n preset?: GapYValue\n label?: string\n defaultValue?: Gap\n step?: number\n min?: number\n max?: number\n hidden?: boolean\n}>\n\ntype GapYDescriptor<_T = GapYValue> = { type: typeof Types.GapY; options: GapYOptions }\n\nexport function GapY(options: GapYOptions = {}): GapYDescriptor {\n return { type: Types.GapY, options }\n}\n\ntype GridColumn = { count: number; spans: number[][] }\n\nexport type GridValue = { elements: Element[]; columns: ResponsiveValue<GridColumn> }\n\ntype GridOptions = Options<Record<string, never>>\n\ntype GridDescriptor<_T = GridValue> = { type: typeof Types.Grid; options: GridOptions }\n\nexport function Grid(options: GridOptions = {}): GridDescriptor {\n return { type: Types.Grid, options }\n}\n\nexport type ImageValue = string\n\ntype ImageOptions = Options<{ label?: string; hidden?: boolean }>\n\ntype ImageDescriptor<_T = ImageValue> = { type: typeof Types.Image; options: ImageOptions }\n\nexport function Image(options: ImageOptions = {}): ImageDescriptor {\n return { type: Types.Image, options }\n}\n\nexport type ImagesValue = { key: string; props: { link?: Link; file?: string; altText?: string } }[]\n\ntype ImagesOptions = Options<{ preset?: ImagesValue }>\n\ntype ImagesDescriptor<_T = ImagesValue> = { type: typeof Types.Images; options: ImagesOptions }\n\nexport function Images(options: ImagesOptions = {}): ImagesDescriptor {\n return { type: Types.Images, options }\n}\n\nexport type LinkValue = Link\n\ntype LinkOptions = Options<{\n preset?: LinkValue\n label?: string\n defaultValue?: Link\n options?: { value: Link['type']; label: string }[]\n hidden?: boolean\n}>\n\ntype LinkDescriptor<_T = LinkValue> = { type: typeof Types.Link; options: LinkOptions }\n\nexport function Link(options: LinkOptions = {}): LinkDescriptor {\n return { type: Types.Link, options }\n}\n\ntype ListValueItem<T extends Data> = { id: string; value?: T }\n\nexport type ListValue<T extends Data = Data> = ListValueItem<T>[]\n\nexport type ListOptions<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: ((value: T | undefined) => string) | ((value: T | undefined) => Promise<string>)\n preset?: ListValue<T>\n defaultValue?: ListValue<T>\n}\n\nexport type ListDescriptor<T extends ListValue = ListValue> = {\n type: typeof Types.List\n options: ListOptions<T extends ListValue<infer U> ? U : never>\n}\n\nexport function List<T extends Data>(options: ListOptions<T>): ListDescriptor<ListValue<T>> {\n return { type: Types.List, options }\n}\n\ntype MarginSide = { value: number; unit: 'px' } | 'auto'\n\ntype Margin = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `margin${Capitalize<K>}`]:\n | MarginSide\n | null\n | undefined\n}\n\nexport type MarginValue = ResponsiveValue<Margin>\n\ntype MarginOptions = Options<{ preset?: MarginValue }>\n\ntype MarginDescriptor<_T = MarginValue> = { type: typeof Types.Margin; options: MarginOptions }\n\nexport function Margin(options: MarginOptions = {}): MarginDescriptor {\n return { type: Types.Margin, options }\n}\n\ntype ButtonVariant = 'flat' | 'outline' | 'shadow' | 'clear' | 'blocky' | 'bubbly' | 'skewed'\n\ntype ButtonShape = 'pill' | 'rounded' | 'square'\n\ntype ButtonSize = 'small' | 'medium' | 'large'\n\ntype NavigationButton = {\n id: string\n type: 'button'\n payload: {\n label: string\n link?: Link\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdownCaretType = 'caret' | 'plus' | 'arrow-down' | 'chevron-down'\n\ntype NavigationDropdownLink = {\n id: string\n payload: {\n label: string\n link?: Link\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdown = {\n id: string\n type: 'dropdown'\n payload: {\n label: string\n caret?: NavigationDropdownCaretType\n links?: NavigationDropdownLink[]\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\nexport type NavigationLinksValue = (NavigationButton | NavigationDropdown)[]\n\ntype NavigationLinksOptions = Options<Record<string, never>>\n\ntype NavigationLinksDescriptor<_T = NavigationLinksValue> = {\n type: typeof Types.NavigationLinks\n options: NavigationLinksOptions\n}\n\nexport function NavigationLinks(options: NavigationLinksOptions = {}): NavigationLinksDescriptor {\n return { type: Types.NavigationLinks, options }\n}\n\nexport type NumberValue = number\n\ntype NumberOptions = Options<{\n preset?: NumberValue\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype NumberDescriptor<_T = NumberValue> = { type: typeof Types.Number; options: NumberOptions }\n\nexport function Number(options: NumberOptions = {}): NumberDescriptor {\n return { type: Types.Number, options }\n}\n\ntype PaddingSide = { value: number; unit: 'px' }\n\ntype Padding = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `padding${Capitalize<K>}`]:\n | PaddingSide\n | null\n | undefined\n}\n\nexport type PaddingValue = ResponsiveValue<Padding>\n\ntype PaddingOptions = Options<{ preset?: PaddingValue }>\n\ntype PaddingDescriptor<_T = PaddingValue> = { type: typeof Types.Padding; options: PaddingOptions }\n\nexport function Padding(options: PaddingOptions = {}): PaddingDescriptor {\n return { type: Types.Padding, options }\n}\n\nexport type ResponsiveColorValue = ResponsiveValue<Color>\n\ntype ResponsiveColorOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype ResponsiveColorDescriptor<_T = ResponsiveColorValue> = {\n type: typeof Types.ResponsiveColor\n options: ResponsiveColorOptions\n}\n\nexport function ResponsiveColor(options: ResponsiveColorOptions = {}): ResponsiveColorDescriptor {\n return { type: Types.ResponsiveColor, options }\n}\n\ntype IconRadioGroupOption<T extends string> = { value: T; label: string; icon: IconName }\n\nexport type ResponsiveIconRadioGroupValue<T extends string> = ResponsiveValue<T>\n\ntype ResponsiveIconRadioGroupOptions<T extends string, U extends T = T> = Options<{\n label?: string\n options: IconRadioGroupOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveIconRadioGroupDescriptor<T extends ResponsiveIconRadioGroupValue<string>> = {\n type: typeof Types.ResponsiveIconRadioGroup\n options: ResponsiveIconRadioGroupOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveIconRadioGroup<_T extends string, T extends _T, U extends T>(\n options: ResponsiveIconRadioGroupOptions<T, U>,\n): ResponsiveIconRadioGroupDescriptor<ResponsiveIconRadioGroupValue<T>> {\n return { type: Types.ResponsiveIconRadioGroup, options }\n}\n\nexport type ResponsiveLengthValue = ResponsiveValue<Length>\n\ntype LengthOption =\n | { value: 'px'; label: 'Pixels'; icon: 'Px16' }\n | { value: '%'; label: 'Percentage'; icon: 'Percent16' }\n\ntype ResponsiveLengthOptions = Options<{\n label?: string\n options?: LengthOption[]\n defaultValue?: Length\n hidden?: boolean\n}>\n\ntype ResponsiveLengthDescriptor<_T = ResponsiveLengthValue> = {\n type: typeof Types.ResponsiveLength\n options: ResponsiveLengthOptions\n}\n\nexport function ResponsiveLength(\n options: ResponsiveLengthOptions = {},\n): ResponsiveLengthDescriptor {\n return { type: Types.ResponsiveLength, options }\n}\n\nexport type ResponsiveNumberValue = ResponsiveValue<number>\n\ntype ResponsiveNumberOptions = Options<{\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype ResponsiveNumberDescriptor<_T = ResponsiveNumberValue> = {\n type: typeof Types.ResponsiveNumber\n options: ResponsiveNumberOptions\n}\n\nexport function ResponsiveNumber(\n options: ResponsiveNumberOptions = {},\n): ResponsiveNumberDescriptor {\n return { type: Types.ResponsiveNumber, options }\n}\n\nexport type ResponsiveOpacityValue = ResponsiveValue<number>\n\ntype ResponsiveOpacityOptions = Options<Record<string, never>>\n\ntype ResponsiveOpacityDescriptor<_T = ResponsiveOpacityValue> = {\n type: typeof Types.ResponsiveOpacity\n options: ResponsiveOpacityOptions\n}\n\nexport function ResponsiveOpacity(\n options: ResponsiveOpacityOptions = {},\n): ResponsiveOpacityDescriptor {\n return { type: Types.ResponsiveOpacity, options }\n}\n\nexport type ResponsiveSelectValue<T extends string> = ResponsiveValue<T>\n\ntype SelectLabelOrientation = 'vertical' | 'horizontal'\n\ntype SelectOption<T extends string> = { value: T; label: string }\n\ntype ResponsiveSelectOptions<T extends string, U extends T = T> = Options<{\n label?: string\n labelOrientation?: SelectLabelOrientation\n options: SelectOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveSelectDescriptor<T extends ResponsiveSelectValue<string>> = {\n type: typeof Types.ResponsiveSelect\n options: ResponsiveSelectOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveSelect<_T extends string, T extends _T, U extends T>(\n options: ResponsiveSelectOptions<T, U>,\n): ResponsiveSelectDescriptor<ResponsiveSelectValue<T>> {\n return { type: Types.ResponsiveSelect, options }\n}\n\nexport type RichTextValue = IndexSignatureHack<Slate.ValueJSON>\n\ntype RichTextOptions = Options<{ preset?: RichTextValue }>\n\nexport type RichTextDescriptor<_T extends Data = RichTextValue> = {\n type: typeof Types.RichText\n options: RichTextOptions\n}\n\nexport function RichText(options: RichTextOptions = {}): RichTextDescriptor {\n return { type: Types.RichText, options }\n}\n\ntype Shadow = {\n color?: Color | null\n blurRadius?: number\n spreadRadius?: number\n offsetX?: number\n offsetY?: number\n inset?: boolean\n}\n\ntype Shadows = { id: string; payload: Shadow }[]\n\nexport type ShadowsValue = ResponsiveValue<Shadows>\n\ntype ShadowsOptions = Options<Record<string, never>>\n\ntype ShadowsDescriptor<_T = ShadowsValue> = { type: typeof Types.Shadows; options: ShadowsOptions }\n\nexport function Shadows(options: ShadowsOptions = {}): ShadowsDescriptor {\n return { type: Types.Shadows, options }\n}\n\nexport type ShapeValue<T extends Data = Data> = Record<string, T>\n\ntype ShapeOptions<T extends Record<string, Descriptor>> = {\n type: T\n preset?: { [K in keyof T]?: DescriptorValueType<T[K]> }\n}\n\ntype ShapeDescriptor<_T extends Record<string, Data>, U extends Record<string, Descriptor>> = {\n type: typeof Types.Shape\n options: ShapeOptions<U>\n}\n\nexport function Shape<T extends Record<string, Descriptor>>(\n options: ShapeOptions<T>,\n): ShapeDescriptor<{ [K in keyof T]?: DescriptorValueType<T[K]> }, T> {\n return { type: Types.Shape, options }\n}\n\ntype SocialLinkType =\n | 'angellist'\n | 'codepen'\n | 'dribbble'\n | 'facebook'\n | 'github'\n | 'instagram'\n | 'linkedin'\n | 'medium'\n | 'pinterest'\n | 'reddit'\n | 'rss'\n | 'snapchat'\n | 'soundcloud'\n | 'spotify'\n | 'telegram'\n | 'tumblr'\n | 'twitch'\n | 'twitter'\n | 'vimeo'\n | 'whatsapp'\n | 'yelp'\n | 'youtube'\n\ntype SocialLink = { type: SocialLinkType; url: string }\n\ntype SocialLinksLink = { id: string; payload: SocialLink }\n\nexport type SocialLinksValue = { links: SocialLinksLink[]; openInNewTab: boolean }\n\ntype SocialLinksOptions = Options<{ preset?: SocialLinksValue }>\n\ntype SocialLinksDescriptor<_T = SocialLinksValue> = {\n type: typeof Types.SocialLinks\n options: SocialLinksOptions\n}\n\nexport function SocialLinks(options: SocialLinksOptions = {}): SocialLinksDescriptor {\n return { type: Types.SocialLinks, options }\n}\n\nexport type TableValue = string\n\ntype TableOptions = Options<{ preset?: TableValue }>\n\ntype TableDescriptor<_T = TableValue> = { type: typeof Types.Table; options: TableOptions }\n\nexport function Table(options: TableOptions = {}): TableDescriptor {\n return { type: Types.Table, options }\n}\n\ntype TableFormField = {\n id: string\n tableColumnId: string\n label?: string\n placeholder?: string\n defaultValue?: string | boolean | string[]\n required?: boolean\n hidden?: boolean\n type?: 'select' | 'radio'\n hideLabel?: boolean\n autofill?: boolean\n}\n\ntype Grid = { count: number; spans: number[][] }\n\nexport type TableFormFieldsValue = { fields: TableFormField[]; grid: ResponsiveValue<Grid> }\n\ntype TableFormFieldsOptions = Options<{ preset?: TableFormFieldsValue }>\n\nexport type TableFormFieldsDescriptor<_T = TableFormFieldsValue> = {\n type: typeof Types.TableFormFields\n options: TableFormFieldsOptions\n}\n\nexport function TableFormFields(options: TableFormFieldsOptions = {}): TableFormFieldsDescriptor {\n return { type: Types.TableFormFields, options }\n}\n\nexport type TypeaheadValue<T extends Data = Data> = {\n id: string\n label: string\n value: T\n}\n\nexport type TypeaheadOptions<T extends Data> = {\n getItems: (query: string) => Promise<TypeaheadValue<T>[]>\n label?: string\n preset?: TypeaheadValue<T>\n defaultValue?: TypeaheadValue<T>\n}\n\nexport type TypeaheadDescriptor<T extends TypeaheadValue = TypeaheadValue> = {\n type: typeof Types.Typeahead\n options: TypeaheadOptions<T extends TypeaheadValue<infer U> ? U : never>\n}\n\nexport function Typeahead<T extends Data>(\n options: TypeaheadOptions<T>,\n): TypeaheadDescriptor<TypeaheadValue<T>> {\n return { type: Types.Typeahead, options }\n}\n\nexport type TextAreaValue = string\n\ntype TextAreaOptions = Options<{ preset?: TextAreaValue; label?: string; rows?: number }>\n\ntype TextAreaDescriptor<_T = TextAreaValue> = {\n type: typeof Types.TextArea\n options: TextAreaOptions\n}\n\nexport function TextArea(options: TextAreaOptions = {}): TextAreaDescriptor {\n return { type: Types.TextArea, options }\n}\n\nexport type TextInputValue = string\n\ntype TextInputOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype TextInputDescriptor<_T = TextInputValue> = {\n type: typeof Types.TextInput\n options: TextInputOptions\n}\n\nexport function TextInput(options: TextInputOptions = {}): TextInputDescriptor {\n return { type: Types.TextInput, options }\n}\n\nexport type TextStyleValue = ResponsiveValue<TextStyle>\n\ntype TextStyleOptions = Options<{ preset?: TextStyleValue; label?: string; hidden?: boolean }>\n\ntype TextStyleDescriptor<_T = TextStyleValue> = {\n type: typeof Types.TextStyle\n options: TextStyleOptions\n}\n\nexport function TextStyle(options: TextStyleOptions = {}): TextStyleDescriptor {\n return { type: Types.TextStyle, options }\n}\n\ntype Video = {\n url?: string\n muted?: boolean\n playing?: boolean\n loop?: boolean\n controls?: boolean\n}\n\nexport type VideoValue = Video\n\ntype VideoOptions = Options<{ preset?: VideoValue }>\n\ntype VideoDescriptor<_T = VideoValue> = { type: typeof Types.Video; options: VideoOptions }\n\nexport function Video(options: VideoOptions = {}): VideoDescriptor {\n return { type: Types.Video, options }\n}\n\nexport type WidthValue = ResponsiveValue<Length>\n\ntype WidthOptions = Options<{ preset?: WidthValue; defaultValue?: Length }>\n\ntype WidthDescriptor<_T = WidthValue> = { type: typeof Types.Width; options: WidthOptions }\n\nexport function Width(options: WidthOptions = {}): WidthDescriptor {\n return { type: Types.Width, options }\n}\n\nexport type Descriptor<T extends Data = Data> =\n | BackgroundsDescriptor<T>\n | BorderDescriptor<T>\n | BorderRadiusDescriptor<T>\n | CheckboxDescriptor<T>\n | DateDescriptor<T>\n | ElementIDDescriptor<T>\n | FontDescriptor<T>\n | GapXDescriptor<T>\n | GapYDescriptor<T>\n | GridDescriptor<T>\n | ImageDescriptor<T>\n | ImagesDescriptor<T>\n | LinkDescriptor<T>\n | ListDescriptor<T extends ListValue ? T : ListValue>\n | MarginDescriptor<T>\n | NavigationLinksDescriptor<T>\n | NumberDescriptor<T>\n | PaddingDescriptor<T>\n | ResponsiveColorDescriptor<T>\n | ResponsiveIconRadioGroupDescriptor<\n T extends ResponsiveIconRadioGroupValue<string> ? T : ResponsiveIconRadioGroupValue<string>\n >\n | ResponsiveLengthDescriptor<T>\n | ResponsiveNumberDescriptor<T>\n | ResponsiveOpacityDescriptor<T>\n | ResponsiveSelectDescriptor<\n T extends ResponsiveSelectValue<string> ? T : ResponsiveSelectValue<string>\n >\n | RichTextDescriptor<T>\n | ShadowsDescriptor<T>\n | ShapeDescriptor<T extends ShapeValue ? T : ShapeValue, any>\n | SocialLinksDescriptor<T>\n | TableDescriptor<T>\n | TableFormFieldsDescriptor<T>\n | TypeaheadDescriptor<T extends TypeaheadValue ? T : TypeaheadValue>\n | TextAreaDescriptor<T>\n | TextInputDescriptor<T>\n | TextStyleDescriptor<T>\n | VideoDescriptor<T>\n | WidthDescriptor<T>\n\ntype PanelDescriptorType =\n | typeof Types.Backgrounds\n | typeof Types.ResponsiveIconRadioGroup\n | typeof Types.Margin\n | typeof Types.Padding\n | typeof Types.Border\n | typeof Types.Shadows\n | typeof Types.GapY\n | typeof Types.GapX\n | typeof Types.BorderRadius\n | typeof Types.Checkbox\n | typeof Types.TextInput\n | typeof Types.Link\n | typeof Types.List\n | typeof Types.Shape\n | typeof Types.ResponsiveSelect\n | typeof Types.ResponsiveColor\n | typeof Types.TextStyle\n | typeof Types.Images\n | typeof Types.ResponsiveNumber\n | typeof Types.Number\n | typeof Types.Date\n | typeof Types.Font\n | typeof Types.TextArea\n | typeof Types.Table\n | typeof Types.Typeahead\n | typeof Types.RichText\n | typeof Types.Image\n | typeof Types.ResponsiveOpacity\n | typeof Types.SocialLinks\n | typeof Types.Video\n | typeof Types.NavigationLinks\n\nexport type PanelDescriptor<T extends Data = Data> = Extract<\n Descriptor<T>,\n { type: PanelDescriptorType }\n>\n\nexport type DescriptorValueType<T extends Descriptor> = T extends Descriptor<infer U> ? U : never\n"],"names":[],"mappings":"AAwFO,MAAM,QAAQ;AAAA,EACnB,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,UAAU;AAAA,EACV,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,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,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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\ntype Gap = { value: number; unit: 'px' }\n\nexport type Length = { value: number; unit: 'px' | '%' }\n\ntype OpenPageLink = {\n type: 'OPEN_PAGE'\n payload: { pageId: string | null | undefined; openInNewTab: boolean }\n}\n\ntype OpenURLLink = { type: 'OPEN_URL'; payload: { url: string; openInNewTab: boolean } }\n\ntype SendEmailLink = {\n type: 'SEND_EMAIL'\n payload: { to: string; subject?: string; body?: string }\n}\n\ntype CallPhoneLink = { type: 'CALL_PHONE'; payload: { phoneNumber: string } }\n\ntype ScrollToElementLink = {\n type: 'SCROLL_TO_ELEMENT'\n payload: {\n elementIdConfig: { elementKey: string; propName: string } | null | undefined\n block: 'start' | 'center' | 'end'\n }\n}\n\ntype Link = OpenPageLink | OpenURLLink | SendEmailLink | CallPhoneLink | ScrollToElementLink\n\ntype TextStyle = {\n fontFamily?: string | null | undefined\n letterSpacing: number | null | undefined\n fontSize: { value: number; unit: 'px' } | null | undefined\n fontWeight: number | null | undefined\n textTransform: 'uppercase'[]\n fontStyle: 'italic'[]\n}\n\nexport const Types = {\n Backgrounds: 'Backgrounds',\n Border: 'Border',\n BorderRadius: 'BorderRadius',\n Checkbox: 'Checkbox',\n Date: 'Date',\n ElementID: 'ElementID',\n Font: 'Font',\n GapX: 'GapX',\n GapY: 'GapY',\n Grid: 'Grid',\n Image: 'Image',\n Images: 'Images',\n Link: 'Link',\n List: 'List',\n Margin: 'Margin',\n NavigationLinks: 'NavigationLinks',\n Number: 'Number',\n Padding: 'Padding',\n ResponsiveColor: 'ResponsiveColor',\n ResponsiveIconRadioGroup: 'ResponsiveIconRadioGroup',\n ResponsiveLength: 'ResponsiveLength',\n ResponsiveNumber: 'ResponsiveNumber',\n ResponsiveOpacity: 'ResponsiveOpacity',\n ResponsiveSelect: 'ResponsiveSelect',\n RichText: 'RichText',\n Shadows: 'Shadows',\n Shape: 'Shape',\n SocialLinks: 'SocialLinks',\n Table: 'Table',\n TableFormFields: 'TableFormFields',\n Typeahead: 'Typeahead',\n TextArea: 'TextArea',\n TextInput: 'TextInput',\n TextStyle: 'TextStyle',\n Video: 'Video',\n Width: 'Width',\n} as const\n\ntype Options<T> = T | ((props: Record<string, unknown>, decideMode: Device) => T)\n\ntype ColorBackground = { type: 'color'; id: string; payload: Color | null }\n\ntype GradientStop = { id: string; location: number; color: Color | null }\n\ntype Gradient = { angle?: number; isRadial?: boolean; stops: GradientStop[] }\n\ntype GradientBackground = { type: 'gradient'; id: string; payload: Gradient }\n\ntype BackgroundImagePosition = { x: number; y: number }\n\ntype BackgroundImageSize = 'cover' | 'contain' | 'auto'\n\ntype BackgroundImageRepeat = 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat'\n\ntype BackgroundImage = {\n imageId: string\n position: BackgroundImagePosition\n size?: BackgroundImageSize\n repeat?: BackgroundImageRepeat\n opacity?: number\n parallax?: number\n}\n\ntype ImageBackground = { type: 'image'; id: string; payload: BackgroundImage }\n\ntype BackgroundVideoAspectRatio = 'wide' | 'standard'\n\ntype BackgroundVideo = {\n url?: string\n maskColor?: Color | null\n opacity?: number\n zoom?: number\n aspectRatio?: BackgroundVideoAspectRatio\n parallax?: number\n}\n\ntype VideoBackground = { type: 'video'; id: string; payload: BackgroundVideo }\n\ntype Background = ColorBackground | GradientBackground | ImageBackground | VideoBackground\n\nexport type BackgroundsValue = ResponsiveValue<Background[]>\n\ntype BackgroundsOptions = Options<Record<string, never>>\n\ntype BackgroundsDescriptor<_T = BackgroundsValue> = {\n type: typeof Types.Backgrounds\n options: BackgroundsOptions\n}\n\nexport function Backgrounds(options: BackgroundsOptions = {}): BackgroundsDescriptor {\n return { type: Types.Backgrounds, options }\n}\n\ntype BorderSideStyle = 'dashed' | 'dotted' | 'solid'\n\ntype BorderSide = { width: number | null | undefined; style: BorderSideStyle; color?: Color | null }\n\ntype Border = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `border${Capitalize<K>}`]:\n | BorderSide\n | null\n | undefined\n}\n\nexport type BorderValue = ResponsiveValue<Border>\n\ntype BorderOptions = Options<Record<string, never>>\n\ntype BorderDescriptor<_T = BorderValue> = { type: typeof Types.Border; options: BorderOptions }\n\nexport function Border(options: BorderOptions = {}): BorderDescriptor {\n return { type: Types.Border, options }\n}\n\ntype BorderRadius = {\n [K in 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' as `border${Capitalize<K>}Radius`]:\n | Length\n | null\n | undefined\n}\n\nexport type BorderRadiusValue = ResponsiveValue<BorderRadius>\n\ntype BorderRadiusOptions = Options<Record<string, never>>\n\ntype BorderRadiusDescriptor<_T = BorderRadiusValue> = {\n type: typeof Types.BorderRadius\n options: BorderRadiusOptions\n}\n\nexport function BorderRadius(options: BorderRadiusOptions = {}): BorderRadiusDescriptor {\n return { type: Types.BorderRadius, options }\n}\n\nexport type CheckboxValue = boolean\n\ntype CheckboxOptions = Options<{\n preset?: CheckboxValue\n label: string\n hidden?: boolean\n}>\n\ntype CheckboxDescriptor<_T = CheckboxValue> = {\n type: typeof Types.Checkbox\n options: CheckboxOptions\n}\n\nexport function Checkbox(options: CheckboxOptions): CheckboxDescriptor {\n return { type: Types.Checkbox, options }\n}\n\nexport type DateValue = string\n\ntype DateOptions = Options<{ preset?: DateValue }>\n\ntype DateDescriptor<_T = DateValue> = { type: typeof Types.Date; options: DateOptions }\n\nexport function Date(options: DateOptions = {}): DateDescriptor {\n return { type: Types.Date, options }\n}\n\nexport type ElementIDValue = string\n\ntype ElementIDOptions = Options<Record<string, never>>\n\ntype ElementIDDescriptor<_T = ElementIDValue> = {\n type: typeof Types.ElementID\n options: ElementIDOptions\n}\n\nexport function ElementID(options: ElementIDOptions = {}): ElementIDDescriptor {\n return { type: Types.ElementID, options }\n}\n\nexport type FontValue = ResponsiveValue<string>\n\ntype FontOptions = Options<{ preset?: FontValue; label?: string }>\n\ntype FontDescriptor<_T = FontValue> = { type: typeof Types.Font; options: FontOptions }\n\nexport function Font(options: FontOptions = {}): FontDescriptor {\n return { type: Types.Font, options }\n}\n\nexport type GapXValue = ResponsiveValue<Gap>\n\ntype GapXOptions = Options<{\n preset?: GapXValue\n label?: string\n defaultValue?: Gap\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}>\n\ntype GapXDescriptor<_T = GapXValue> = { type: typeof Types.GapX; options: GapXOptions }\n\nexport function GapX(options: GapXOptions = {}): GapXDescriptor {\n return { type: Types.GapX, options }\n}\n\nexport type GapYValue = ResponsiveValue<Gap>\n\ntype GapYOptions = Options<{\n preset?: GapYValue\n label?: string\n defaultValue?: Gap\n step?: number\n min?: number\n max?: number\n hidden?: boolean\n}>\n\ntype GapYDescriptor<_T = GapYValue> = { type: typeof Types.GapY; options: GapYOptions }\n\nexport function GapY(options: GapYOptions = {}): GapYDescriptor {\n return { type: Types.GapY, options }\n}\n\ntype GridColumn = { count: number; spans: number[][] }\n\nexport type GridValue = { elements: Element[]; columns: ResponsiveValue<GridColumn> }\n\ntype GridOptions = Options<Record<string, never>>\n\ntype GridDescriptor<_T = GridValue> = { type: typeof Types.Grid; options: GridOptions }\n\nexport function Grid(options: GridOptions = {}): GridDescriptor {\n return { type: Types.Grid, options }\n}\n\nexport type ImageValue = string\n\ntype ImageOptions = Options<{ label?: string; hidden?: boolean }>\n\ntype ImageDescriptor<_T = ImageValue> = { type: typeof Types.Image; options: ImageOptions }\n\nexport function Image(options: ImageOptions = {}): ImageDescriptor {\n return { type: Types.Image, options }\n}\n\nexport type ImagesValue = { key: string; props: { link?: Link; file?: string; altText?: string } }[]\n\ntype ImagesOptions = Options<{ preset?: ImagesValue }>\n\ntype ImagesDescriptor<_T = ImagesValue> = { type: typeof Types.Images; options: ImagesOptions }\n\nexport function Images(options: ImagesOptions = {}): ImagesDescriptor {\n return { type: Types.Images, options }\n}\n\nexport type LinkValue = Link\n\ntype LinkOptions = Options<{\n preset?: LinkValue\n label?: string\n defaultValue?: Link\n options?: { value: Link['type']; label: string }[]\n hidden?: boolean\n}>\n\ntype LinkDescriptor<_T = LinkValue> = { type: typeof Types.Link; options: LinkOptions }\n\nexport function Link(options: LinkOptions = {}): LinkDescriptor {\n return { type: Types.Link, options }\n}\n\ntype ListValueItem<T extends Data> = { id: string; value?: T }\n\nexport type ListValue<T extends Data = Data> = ListValueItem<T>[]\n\nexport type ListOptions<T extends Data> = {\n type: PanelDescriptor<T>\n label?: string\n getItemLabel?: ((value: T | undefined) => string) | ((value: T | undefined) => Promise<string>)\n preset?: ListValue<T>\n defaultValue?: ListValue<T>\n}\n\nexport type ListDescriptor<T extends ListValue = ListValue> = {\n type: typeof Types.List\n options: ListOptions<T extends ListValue<infer U> ? U : never>\n}\n\nexport function List<T extends Data>(options: ListOptions<T>): ListDescriptor<ListValue<T>> {\n return { type: Types.List, options }\n}\n\ntype MarginSide = { value: number; unit: 'px' } | 'auto'\n\ntype Margin = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `margin${Capitalize<K>}`]:\n | MarginSide\n | null\n | undefined\n}\n\nexport type MarginValue = ResponsiveValue<Margin>\n\ntype MarginOptions = Options<{ preset?: MarginValue }>\n\ntype MarginDescriptor<_T = MarginValue> = { type: typeof Types.Margin; options: MarginOptions }\n\nexport function Margin(options: MarginOptions = {}): MarginDescriptor {\n return { type: Types.Margin, options }\n}\n\ntype ButtonVariant = 'flat' | 'outline' | 'shadow' | 'clear' | 'blocky' | 'bubbly' | 'skewed'\n\ntype ButtonShape = 'pill' | 'rounded' | 'square'\n\ntype ButtonSize = 'small' | 'medium' | 'large'\n\ntype NavigationButton = {\n id: string\n type: 'button'\n payload: {\n label: string\n link?: Link\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdownCaretType = 'caret' | 'plus' | 'arrow-down' | 'chevron-down'\n\ntype NavigationDropdownLink = {\n id: string\n payload: {\n label: string\n link?: Link\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\ntype NavigationDropdown = {\n id: string\n type: 'dropdown'\n payload: {\n label: string\n caret?: NavigationDropdownCaretType\n links?: NavigationDropdownLink[]\n variant?: ResponsiveValue<ButtonVariant>\n shape?: ResponsiveValue<ButtonShape>\n size?: ResponsiveValue<ButtonSize>\n textColor?: ResponsiveValue<Color>\n color?: ResponsiveValue<Color>\n textStyle?: ResponsiveValue<TextStyle>\n }\n}\n\nexport type NavigationLinksValue = (NavigationButton | NavigationDropdown)[]\n\ntype NavigationLinksOptions = Options<Record<string, never>>\n\ntype NavigationLinksDescriptor<_T = NavigationLinksValue> = {\n type: typeof Types.NavigationLinks\n options: NavigationLinksOptions\n}\n\nexport function NavigationLinks(options: NavigationLinksOptions = {}): NavigationLinksDescriptor {\n return { type: Types.NavigationLinks, options }\n}\n\nexport type NumberValue = number\n\ntype NumberOptions = Options<{\n preset?: NumberValue\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype NumberDescriptor<_T = NumberValue> = { type: typeof Types.Number; options: NumberOptions }\n\nexport function Number(options: NumberOptions = {}): NumberDescriptor {\n return { type: Types.Number, options }\n}\n\ntype PaddingSide = { value: number; unit: 'px' }\n\ntype Padding = {\n [K in 'top' | 'right' | 'bottom' | 'left' as `padding${Capitalize<K>}`]:\n | PaddingSide\n | null\n | undefined\n}\n\nexport type PaddingValue = ResponsiveValue<Padding>\n\ntype PaddingOptions = Options<{ preset?: PaddingValue }>\n\ntype PaddingDescriptor<_T = PaddingValue> = { type: typeof Types.Padding; options: PaddingOptions }\n\nexport function Padding(options: PaddingOptions = {}): PaddingDescriptor {\n return { type: Types.Padding, options }\n}\n\nexport type ResponsiveColorValue = ResponsiveValue<Color>\n\ntype ResponsiveColorOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype ResponsiveColorDescriptor<_T = ResponsiveColorValue> = {\n type: typeof Types.ResponsiveColor\n options: ResponsiveColorOptions\n}\n\nexport function ResponsiveColor(options: ResponsiveColorOptions = {}): ResponsiveColorDescriptor {\n return { type: Types.ResponsiveColor, options }\n}\n\ntype IconRadioGroupOption<T extends string> = { value: T; label: string; icon: IconName }\n\nexport type ResponsiveIconRadioGroupValue<T extends string> = ResponsiveValue<T>\n\ntype ResponsiveIconRadioGroupOptions<T extends string, U extends T = T> = Options<{\n label?: string\n options: IconRadioGroupOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveIconRadioGroupDescriptor<T extends ResponsiveIconRadioGroupValue<string>> = {\n type: typeof Types.ResponsiveIconRadioGroup\n options: ResponsiveIconRadioGroupOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveIconRadioGroup<_T extends string, T extends _T, U extends T>(\n options: ResponsiveIconRadioGroupOptions<T, U>,\n): ResponsiveIconRadioGroupDescriptor<ResponsiveIconRadioGroupValue<T>> {\n return { type: Types.ResponsiveIconRadioGroup, options }\n}\n\nexport type ResponsiveLengthValue = ResponsiveValue<Length>\n\ntype LengthOption =\n | { value: 'px'; label: 'Pixels'; icon: 'Px16' }\n | { value: '%'; label: 'Percentage'; icon: 'Percent16' }\n\ntype ResponsiveLengthOptions = Options<{\n label?: string\n options?: LengthOption[]\n defaultValue?: Length\n hidden?: boolean\n}>\n\ntype ResponsiveLengthDescriptor<_T = ResponsiveLengthValue> = {\n type: typeof Types.ResponsiveLength\n options: ResponsiveLengthOptions\n}\n\nexport function ResponsiveLength(\n options: ResponsiveLengthOptions = {},\n): ResponsiveLengthDescriptor {\n return { type: Types.ResponsiveLength, options }\n}\n\nexport type ResponsiveNumberValue = ResponsiveValue<number>\n\ntype ResponsiveNumberOptions = Options<{\n label?: string\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n hidden?: boolean\n}>\n\ntype ResponsiveNumberDescriptor<_T = ResponsiveNumberValue> = {\n type: typeof Types.ResponsiveNumber\n options: ResponsiveNumberOptions\n}\n\nexport function ResponsiveNumber(\n options: ResponsiveNumberOptions = {},\n): ResponsiveNumberDescriptor {\n return { type: Types.ResponsiveNumber, options }\n}\n\nexport type ResponsiveOpacityValue = ResponsiveValue<number>\n\ntype ResponsiveOpacityOptions = Options<Record<string, never>>\n\ntype ResponsiveOpacityDescriptor<_T = ResponsiveOpacityValue> = {\n type: typeof Types.ResponsiveOpacity\n options: ResponsiveOpacityOptions\n}\n\nexport function ResponsiveOpacity(\n options: ResponsiveOpacityOptions = {},\n): ResponsiveOpacityDescriptor {\n return { type: Types.ResponsiveOpacity, options }\n}\n\nexport type ResponsiveSelectValue<T extends string> = ResponsiveValue<T>\n\ntype SelectLabelOrientation = 'vertical' | 'horizontal'\n\ntype SelectOption<T extends string> = { value: T; label: string }\n\ntype ResponsiveSelectOptions<T extends string, U extends T = T> = Options<{\n label?: string\n labelOrientation?: SelectLabelOrientation\n options: SelectOption<T>[]\n defaultValue?: U\n hidden?: boolean\n}>\n\ntype ResponsiveSelectDescriptor<T extends ResponsiveSelectValue<string>> = {\n type: typeof Types.ResponsiveSelect\n options: ResponsiveSelectOptions<ResponsiveValueType<T>>\n}\n\n// HACK(miguel): We have to use a layer of indirection with `_T` and `T` because otherwise the\n// values provided would undergo type widening. For some reason, the extra layer of indirection\n// reuslts in TypeScript not widening types. Note, this only happens when the returned value of this\n// function is passed to another as an argument, which is common with the `registerComponent` API.\nexport function ResponsiveSelect<_T extends string, T extends _T, U extends T>(\n options: ResponsiveSelectOptions<T, U>,\n): ResponsiveSelectDescriptor<ResponsiveSelectValue<T>> {\n return { type: Types.ResponsiveSelect, options }\n}\n\nexport type RichTextValue = IndexSignatureHack<Slate.ValueJSON>\n\ntype RichTextOptions = Options<{ preset?: RichTextValue }>\n\nexport type RichTextDescriptor<_T extends Data = RichTextValue> = {\n type: typeof Types.RichText\n options: RichTextOptions\n}\n\nexport function RichText(options: RichTextOptions = {}): RichTextDescriptor {\n return { type: Types.RichText, options }\n}\n\ntype Shadow = {\n color?: Color | null\n blurRadius?: number\n spreadRadius?: number\n offsetX?: number\n offsetY?: number\n inset?: boolean\n}\n\ntype Shadows = { id: string; payload: Shadow }[]\n\nexport type ShadowsValue = ResponsiveValue<Shadows>\n\ntype ShadowsOptions = Options<Record<string, never>>\n\ntype ShadowsDescriptor<_T = ShadowsValue> = { type: typeof Types.Shadows; options: ShadowsOptions }\n\nexport function Shadows(options: ShadowsOptions = {}): ShadowsDescriptor {\n return { type: Types.Shadows, options }\n}\n\nexport type ShapeValue<T extends Data = Data> = Record<string, T>\n\ntype ShapeOptions<T extends Record<string, PanelDescriptor>> = {\n type: T\n preset?: { [K in keyof T]?: DescriptorValueType<T[K]> }\n}\n\nexport type ShapeDescriptor<\n _T extends Record<string, Data>,\n U extends Record<string, PanelDescriptor>,\n> = {\n type: typeof Types.Shape\n options: ShapeOptions<U>\n}\n\nexport function Shape<T extends Record<string, PanelDescriptor>>(\n options: ShapeOptions<T>,\n): ShapeDescriptor<{ [K in keyof T]?: DescriptorValueType<T[K]> }, T> {\n return { type: Types.Shape, options }\n}\n\ntype SocialLinkType =\n | 'angellist'\n | 'codepen'\n | 'dribbble'\n | 'facebook'\n | 'github'\n | 'instagram'\n | 'linkedin'\n | 'medium'\n | 'pinterest'\n | 'reddit'\n | 'rss'\n | 'snapchat'\n | 'soundcloud'\n | 'spotify'\n | 'telegram'\n | 'tumblr'\n | 'twitch'\n | 'twitter'\n | 'vimeo'\n | 'whatsapp'\n | 'yelp'\n | 'youtube'\n\ntype SocialLink = { type: SocialLinkType; url: string }\n\ntype SocialLinksLink = { id: string; payload: SocialLink }\n\nexport type SocialLinksValue = { links: SocialLinksLink[]; openInNewTab: boolean }\n\ntype SocialLinksOptions = Options<{ preset?: SocialLinksValue }>\n\ntype SocialLinksDescriptor<_T = SocialLinksValue> = {\n type: typeof Types.SocialLinks\n options: SocialLinksOptions\n}\n\nexport function SocialLinks(options: SocialLinksOptions = {}): SocialLinksDescriptor {\n return { type: Types.SocialLinks, options }\n}\n\nexport type TableValue = string\n\ntype TableOptions = Options<{ preset?: TableValue }>\n\ntype TableDescriptor<_T = TableValue> = { type: typeof Types.Table; options: TableOptions }\n\nexport function Table(options: TableOptions = {}): TableDescriptor {\n return { type: Types.Table, options }\n}\n\ntype TableFormField = {\n id: string\n tableColumnId: string\n label?: string\n placeholder?: string\n defaultValue?: string | boolean | string[]\n required?: boolean\n hidden?: boolean\n type?: 'select' | 'radio'\n hideLabel?: boolean\n autofill?: boolean\n}\n\ntype Grid = { count: number; spans: number[][] }\n\nexport type TableFormFieldsValue = { fields: TableFormField[]; grid: ResponsiveValue<Grid> }\n\ntype TableFormFieldsOptions = Options<{ preset?: TableFormFieldsValue }>\n\nexport type TableFormFieldsDescriptor<_T = TableFormFieldsValue> = {\n type: typeof Types.TableFormFields\n options: TableFormFieldsOptions\n}\n\nexport function TableFormFields(options: TableFormFieldsOptions = {}): TableFormFieldsDescriptor {\n return { type: Types.TableFormFields, options }\n}\n\nexport type TypeaheadValue<T extends Data = Data> = {\n id: string\n label: string\n value: T\n}\n\nexport type TypeaheadOptions<T extends Data> = {\n getItems: (query: string) => Promise<TypeaheadValue<T>[]>\n label?: string\n preset?: TypeaheadValue<T>\n defaultValue?: TypeaheadValue<T>\n}\n\nexport type TypeaheadDescriptor<T extends TypeaheadValue = TypeaheadValue> = {\n type: typeof Types.Typeahead\n options: TypeaheadOptions<T extends TypeaheadValue<infer U> ? U : never>\n}\n\nexport function Typeahead<T extends Data>(\n options: TypeaheadOptions<T>,\n): TypeaheadDescriptor<TypeaheadValue<T>> {\n return { type: Types.Typeahead, options }\n}\n\nexport type TextAreaValue = string\n\ntype TextAreaOptions = Options<{ preset?: TextAreaValue; label?: string; rows?: number }>\n\ntype TextAreaDescriptor<_T = TextAreaValue> = {\n type: typeof Types.TextArea\n options: TextAreaOptions\n}\n\nexport function TextArea(options: TextAreaOptions = {}): TextAreaDescriptor {\n return { type: Types.TextArea, options }\n}\n\nexport type TextInputValue = string\n\ntype TextInputOptions = Options<{ label?: string; placeholder?: string; hidden?: boolean }>\n\ntype TextInputDescriptor<_T = TextInputValue> = {\n type: typeof Types.TextInput\n options: TextInputOptions\n}\n\nexport function TextInput(options: TextInputOptions = {}): TextInputDescriptor {\n return { type: Types.TextInput, options }\n}\n\nexport type TextStyleValue = ResponsiveValue<TextStyle>\n\ntype TextStyleOptions = Options<{ preset?: TextStyleValue; label?: string; hidden?: boolean }>\n\ntype TextStyleDescriptor<_T = TextStyleValue> = {\n type: typeof Types.TextStyle\n options: TextStyleOptions\n}\n\nexport function TextStyle(options: TextStyleOptions = {}): TextStyleDescriptor {\n return { type: Types.TextStyle, options }\n}\n\ntype Video = {\n url?: string\n muted?: boolean\n playing?: boolean\n loop?: boolean\n controls?: boolean\n}\n\nexport type VideoValue = Video\n\ntype VideoOptions = Options<{ preset?: VideoValue }>\n\ntype VideoDescriptor<_T = VideoValue> = { type: typeof Types.Video; options: VideoOptions }\n\nexport function Video(options: VideoOptions = {}): VideoDescriptor {\n return { type: Types.Video, options }\n}\n\nexport type WidthValue = ResponsiveValue<Length>\n\ntype WidthOptions = Options<{ preset?: WidthValue; defaultValue?: Length }>\n\ntype WidthDescriptor<_T = WidthValue> = { type: typeof Types.Width; options: WidthOptions }\n\nexport function Width(options: WidthOptions = {}): WidthDescriptor {\n return { type: Types.Width, options }\n}\n\nexport type Descriptor<T extends Data = Data> =\n | BackgroundsDescriptor<T>\n | BorderDescriptor<T>\n | BorderRadiusDescriptor<T>\n | CheckboxDescriptor<T>\n | DateDescriptor<T>\n | ElementIDDescriptor<T>\n | FontDescriptor<T>\n | GapXDescriptor<T>\n | GapYDescriptor<T>\n | GridDescriptor<T>\n | ImageDescriptor<T>\n | ImagesDescriptor<T>\n | LinkDescriptor<T>\n | ListDescriptor<T extends ListValue ? T : ListValue>\n | MarginDescriptor<T>\n | NavigationLinksDescriptor<T>\n | NumberDescriptor<T>\n | PaddingDescriptor<T>\n | ResponsiveColorDescriptor<T>\n | ResponsiveIconRadioGroupDescriptor<\n T extends ResponsiveIconRadioGroupValue<string> ? T : ResponsiveIconRadioGroupValue<string>\n >\n | ResponsiveLengthDescriptor<T>\n | ResponsiveNumberDescriptor<T>\n | ResponsiveOpacityDescriptor<T>\n | ResponsiveSelectDescriptor<\n T extends ResponsiveSelectValue<string> ? T : ResponsiveSelectValue<string>\n >\n | RichTextDescriptor<T>\n | ShadowsDescriptor<T>\n | ShapeDescriptor<T extends ShapeValue ? T : ShapeValue, any>\n | SocialLinksDescriptor<T>\n | TableDescriptor<T>\n | TableFormFieldsDescriptor<T>\n | TypeaheadDescriptor<T extends TypeaheadValue ? T : TypeaheadValue>\n | TextAreaDescriptor<T>\n | TextInputDescriptor<T>\n | TextStyleDescriptor<T>\n | VideoDescriptor<T>\n | WidthDescriptor<T>\n\nexport type PanelDescriptorType =\n | typeof Types.Backgrounds\n | typeof Types.ResponsiveIconRadioGroup\n | typeof Types.Margin\n | typeof Types.Padding\n | typeof Types.Border\n | typeof Types.Shadows\n | typeof Types.GapY\n | typeof Types.GapX\n | typeof Types.BorderRadius\n | typeof Types.Checkbox\n | typeof Types.TextInput\n | typeof Types.Link\n | typeof Types.List\n | typeof Types.Shape\n | typeof Types.ResponsiveSelect\n | typeof Types.ResponsiveColor\n | typeof Types.TextStyle\n | typeof Types.Images\n | typeof Types.ResponsiveNumber\n | typeof Types.Number\n | typeof Types.Date\n | typeof Types.Font\n | typeof Types.TextArea\n | typeof Types.Table\n | typeof Types.Typeahead\n | typeof Types.RichText\n | typeof Types.Image\n | typeof Types.ResponsiveOpacity\n | typeof Types.SocialLinks\n | typeof Types.Video\n | typeof Types.NavigationLinks\n\nexport type PanelDescriptor<T extends Data = Data> = Extract<\n Descriptor<T>,\n { type: PanelDescriptorType }\n>\n\nexport type DescriptorValueType<T extends Descriptor> = T extends Descriptor<infer U> ? U : never\n\nexport type PanelDescriptorValueType<T extends PanelDescriptor> = T extends PanelDescriptor<infer U>\n ? U\n : never\n"],"names":[],"mappings":"AAwFO,MAAM,QAAQ;AAAA,EACnB,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,UAAU;AAAA,EACV,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,0BAA0B;AAAA,EAC1B,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,OAAO;AAAA,EACP,aAAa;AAAA,EACb,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AAAA,EACP,OAAO;AACT;AAqD4B,qBAAA,UAA8B,IAA2B;AACnF,SAAO,EAAE,MAAM,MAAM,aAAa,QAAQ;AAC5C;AAmBuB,gBAAA,UAAyB,IAAsB;AACpE,SAAO,EAAE,MAAM,MAAM,QAAQ,QAAQ;AACvC;AAkB6B,sBAAA,UAA+B,IAA4B;AACtF,SAAO,EAAE,MAAM,MAAM,cAAc,QAAQ;AAC7C;AAeO,kBAAkB,SAA8C;AACrE,SAAO,EAAE,MAAM,MAAM,UAAU,QAAQ;AACzC;AAQqB,cAAA,UAAuB,IAAoB;AAC9D,SAAO,EAAE,MAAM,MAAM,MAAM,QAAQ;AACrC;AAW0B,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
|
package/dist/react-page.cjs.js
CHANGED
|
@@ -191,7 +191,7 @@ function normalizeElement(element, descriptors2) {
|
|
|
191
191
|
elements.set(current.key, current);
|
|
192
192
|
if (isElementReference(current))
|
|
193
193
|
continue;
|
|
194
|
-
const elementDescriptors = descriptors2.get(
|
|
194
|
+
const elementDescriptors = descriptors2.get(current.type);
|
|
195
195
|
if (elementDescriptors == null)
|
|
196
196
|
continue;
|
|
197
197
|
const parent = current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-page.cjs.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/prop-controllers/introspection.ts","../src/state/react-page.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nfunction getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type {\n ClassAttributes,\n ComponentClass,\n PropsWithoutRef,\n RefAttributes,\n VoidFunctionComponent,\n} from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | ComponentClass<PropsWithoutRef<P> & ClassAttributes<T>>\n | VoidFunctionComponent<PropsWithoutRef<P> & RefAttributes<T>>\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Descriptor, ElementIDValue, GridValue, Types } from './descriptors'\nimport { Data, Element } from '../state/react-page'\n\nexport function getElementChildren<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): Element[] {\n if (prop == null) return []\n\n switch (descriptor.type) {\n case Types.Grid:\n return (prop as GridValue).elements\n\n default:\n return []\n }\n}\n\nexport function getElementId<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): string | null {\n if (prop == null) return null\n\n switch (descriptor.type) {\n case Types.ElementID:\n return prop as ElementIDValue\n\n default:\n return null\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n isInBuilder: (_state: boolean = false, _action: Action): boolean => false,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(element.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n} = {}): Store {\n return createStore(\n reducer,\n { ...preloadedState, documents: Documents.getInitialState({ rootElements }) },\n applyMiddleware(thunk),\n )\n}\n"],"names":["getInitialState","ActionTypes","reactComponents","Map","state","type","getReactComponents","get","action","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","Types","combineReducers","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","Documents.isElementReference","Introspection.getElementChildren","Introspection.getElementId","createStore","Documents.getInitialState","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,4BAA4B,SAA+C;AAChF,SAAO,CAAa,YAAA;AACtB;AAMO,iCAAiC,KAAgC;AACtE,SAAO,EAAE,IAAI;AACf;AAOO,wBAAwB,KAAa,aAAgC;AACnE,SAAA,EAAE,KAAK;AAChB;AAIgC,2BAAA;AAAA,EAC9B,mCAAmB,IAAI;AAAA,IACoB,IAAW;AAChD,QAAA,mCAAmB;AAEZ,eAAA,QAAQ,CAAC,aAAa,gBAAgB;AACjD,iBAAa,IAAI,aAAa,eAAe,aAAa,WAAW,CAAC;AAAA,EAAA,CACvE;AAEM,SAAA;AACT;AAEA,sBAAsB,OAAqC;AAClD,SAAA;AACT;AAEO,uBAAqB,OAAc,aAAsC;;AAC9E,SAAO,mBAAa,KAAK,EAAE,IAAI,WAAW,MAAnC,YAAwC;AACjD;AAEwB,mBAAA,QAAeA,kBAAgB,GAAG,QAAuB;AAC/E,UAAQ,OAAO;AAAA,SACRC,QAAY,YAAA;AACR,aAAA,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,OAAO,QAAQ,QAAQ;AAAA,SAE1EA,QAAAA,YAAY,qBAAqB;AAC9B,YAAA,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,WAAW;AAE3D,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA;AAGS,a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;AAAU,WAAA;AAErE,QAAM,eAAc,sCAAsC,OAAO,QAAQ,IAAI;AAE7E,MAAI,gBAAe;AAAa,WAAA;AAE1B,QAAA,YAAY,OAAO,QAAQ,YAAW,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,gBAAgB;AACpF,QAAI,OAAO;AAAa,aAAA;AAExB,WAAOE,eAA2B,YAAY,QAAQ,MAAM,SAAS;AAAA,KACpE,IAAqB;AAEjB,SAAA;AACT;AAEO,wBAAwB,OAAuB;AACpD,SAAO,MAAM;AACf;AAM+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,IAIE,IAAW;AACb,SAAOC,MACL,YAAA,SACA,iCAAK,iBAAL,EAAqB,WAAWC,kBAA0B,EAAE,aAAc,CAAA,EAC1E,IAAAC,sBAAgBC,eAAAA,UAAK,CACvB;AACF;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"react-page.cjs.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/prop-controllers/introspection.ts","../src/state/react-page.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nfunction getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type {\n ClassAttributes,\n ComponentClass,\n PropsWithoutRef,\n RefAttributes,\n VoidFunctionComponent,\n} from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | ComponentClass<PropsWithoutRef<P> & ClassAttributes<T>>\n | VoidFunctionComponent<PropsWithoutRef<P> & RefAttributes<T>>\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Descriptor, ElementIDValue, GridValue, Types } from './descriptors'\nimport { Data, Element } from '../state/react-page'\n\nexport function getElementChildren<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): Element[] {\n if (prop == null) return []\n\n switch (descriptor.type) {\n case Types.Grid:\n return (prop as GridValue).elements\n\n default:\n return []\n }\n}\n\nexport function getElementId<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): string | null {\n if (prop == null) return null\n\n switch (descriptor.type) {\n case Types.ElementID:\n return prop as ElementIDValue\n\n default:\n return null\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n isInBuilder: (_state: boolean = false, _action: Action): boolean => false,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(current.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n} = {}): Store {\n return createStore(\n reducer,\n { ...preloadedState, documents: Documents.getInitialState({ rootElements }) },\n applyMiddleware(thunk),\n )\n}\n"],"names":["getInitialState","ActionTypes","reactComponents","Map","state","type","getReactComponents","get","action","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","Types","combineReducers","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","Documents.isElementReference","Introspection.getElementChildren","Introspection.getElementId","createStore","Documents.getInitialState","applyMiddleware","thunk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,4BAA4B,SAA+C;AAChF,SAAO,CAAa,YAAA;AACtB;AAMO,iCAAiC,KAAgC;AACtE,SAAO,EAAE,IAAI;AACf;AAOO,wBAAwB,KAAa,aAAgC;AACnE,SAAA,EAAE,KAAK;AAChB;AAIgC,2BAAA;AAAA,EAC9B,mCAAmB,IAAI;AAAA,IACoB,IAAW;AAChD,QAAA,mCAAmB;AAEZ,eAAA,QAAQ,CAAC,aAAa,gBAAgB;AACjD,iBAAa,IAAI,aAAa,eAAe,aAAa,WAAW,CAAC;AAAA,EAAA,CACvE;AAEM,SAAA;AACT;AAEA,sBAAsB,OAAqC;AAClD,SAAA;AACT;AAEO,uBAAqB,OAAc,aAAsC;;AAC9E,SAAO,mBAAa,KAAK,EAAE,IAAI,WAAW,MAAnC,YAAwC;AACjD;AAEwB,mBAAA,QAAeA,kBAAgB,GAAG,QAAuB;AAC/E,UAAQ,OAAO;AAAA,SACRC,QAAY,YAAA;AACR,aAAA,IAA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,WAAW,OAAO,aAAa,UAAU;AAEzD,MAAI,WAAW,QAAQD,mBAA6B,OAAO;AAAU,WAAA;AAE9D,SAAA,sCAAsC,OAAO,QAAQ,IAAI;AAClE;AAE6B,sBAAA,OAAc,aAAqB,YAAmC;AACjG,QAAM,UAAU,WAAW,OAAO,aAAa,UAAU;AAEzD,MAAI,WAAW,QAAQA,mBAA6B,OAAO;AAAU,WAAA;AAErE,QAAM,eAAc,sCAAsC,OAAO,QAAQ,IAAI;AAE7E,MAAI,gBAAe;AAAa,WAAA;AAE1B,QAAA,YAAY,OAAO,QAAQ,YAAW,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,gBAAgB;AACpF,QAAI,OAAO;AAAa,aAAA;AAExB,WAAOE,eAA2B,YAAY,QAAQ,MAAM,SAAS;AAAA,KACpE,IAAqB;AAEjB,SAAA;AACT;AAEO,wBAAwB,OAAuB;AACpD,SAAO,MAAM;AACf;AAM+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,IAIE,IAAW;AACb,SAAOC,MACL,YAAA,SACA,iCAAK,iBAAL,EAAqB,WAAWC,kBAA0B,EAAE,aAAc,CAAA,EAC1E,IAAAC,sBAAgBC,eAAAA,UAAK,CACvB;AACF;;;;;;;;;;;;;;;;;;"}
|
package/dist/react-page.es.js
CHANGED
|
@@ -186,7 +186,7 @@ function normalizeElement(element, descriptors) {
|
|
|
186
186
|
elements.set(current.key, current);
|
|
187
187
|
if (isElementReference(current))
|
|
188
188
|
continue;
|
|
189
|
-
const elementDescriptors = descriptors.get(
|
|
189
|
+
const elementDescriptors = descriptors.get(current.type);
|
|
190
190
|
if (elementDescriptors == null)
|
|
191
191
|
continue;
|
|
192
192
|
const parent = current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-page.es.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/prop-controllers/introspection.ts","../src/state/react-page.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nfunction getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type {\n ClassAttributes,\n ComponentClass,\n PropsWithoutRef,\n RefAttributes,\n VoidFunctionComponent,\n} from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | ComponentClass<PropsWithoutRef<P> & ClassAttributes<T>>\n | VoidFunctionComponent<PropsWithoutRef<P> & RefAttributes<T>>\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Descriptor, ElementIDValue, GridValue, Types } from './descriptors'\nimport { Data, Element } from '../state/react-page'\n\nexport function getElementChildren<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): Element[] {\n if (prop == null) return []\n\n switch (descriptor.type) {\n case Types.Grid:\n return (prop as GridValue).elements\n\n default:\n return []\n }\n}\n\nexport function getElementId<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): string | null {\n if (prop == null) return null\n\n switch (descriptor.type) {\n case Types.ElementID:\n return prop as ElementIDValue\n\n default:\n return null\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n isInBuilder: (_state: boolean = false, _action: Action): boolean => false,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(element.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n} = {}): Store {\n return createStore(\n reducer,\n { ...preloadedState, documents: Documents.getInitialState({ rootElements }) },\n applyMiddleware(thunk),\n )\n}\n"],"names":["getInitialState","reactComponents","Map","state","type","getReactComponents","get","action","ActionTypes","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","Documents.isElementReference","Introspection.getElementChildren","Introspection.getElementId","Documents.getInitialState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUO,4BAA4B,SAA+C;AAChF,SAAO,CAAa,YAAA;AACtB;AAMO,iCAAiC,KAAgC;AACtE,SAAO,EAAE,IAAI;AACf;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AAG,CAAyB,CAAA;AAElB,cAAA,KAAK,GAAG,QAAQ;AAAA,EAC5B;AAEO,SAAA;AACT;AAEA,6BAA6B,OAAc,aAAqD;AACxF,QAAA,WAAW,YAAY,OAAO,WAAW;AACzC,QAAA,cAAc,6BAA6B,KAAK;AAEtD,MAAI,YAAY;AAAM,+BAAW,IAAI;AAE9B,SAAA,iBAAiB,SAAS,aAAa,WAAW;AAC3D;AAGE,oBAAA,OACA,aACA,YAC0B;;AAC1B,SAAO,0BAAoB,OAAO,WAAW,EAAE,IAAI,UAAU,MAAtD,YAA2D;AACpE;AAGE,6CAAA,OACA,aACA,YACiE;AACjE,QAAM,UAAU,WAAW,OAAO,aAAa,UAAU;AAEzD,MAAI,WAAW,QAAQD,mBAA6B,OAAO;AAAU,WAAA;AAE9D,SAAA,sCAAsC,OAAO,QAAQ,IAAI;AAClE;AAE6B,sBAAA,OAAc,aAAqB,YAAmC;AACjG,QAAM,UAAU,WAAW,OAAO,aAAa,UAAU;AAEzD,MAAI,WAAW,QAAQA,mBAA6B,OAAO;AAAU,WAAA;AAErE,QAAM,cAAc,sCAAsC,OAAO,QAAQ,IAAI;AAE7E,MAAI,eAAe;AAAa,WAAA;AAE1B,QAAA,YAAY,OAAO,QAAQ,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,gBAAgB;AACpF,QAAI,OAAO;AAAa,aAAA;AAExB,WAAOE,eAA2B,YAAY,QAAQ,MAAM,SAAS;AAAA,KACpE,IAAqB;AAEjB,SAAA;AACT;AAEO,wBAAwB,OAAuB;AACpD,SAAO,MAAM;AACf;AAM+B,wBAAA;AAAA,EAC7B;AAAA,EACA;AAAA,IAIE,IAAW;AACb,SAAO,YACL,SACA,iCAAK,iBAAL,EAAqB,WAAWC,kBAA0B,EAAE,aAAc,CAAA,EAC1E,IAAA,gBAAgB,KAAK,CACvB;AACF;;"}
|
|
1
|
+
{"version":3,"file":"react-page.es.js","sources":["../src/state/modules/read-only-documents.ts","../src/state/modules/react-components.tsx","../src/state/modules/components-meta.ts","../src/state/modules/prop-controllers.ts","../src/prop-controllers/introspection.ts","../src/state/react-page.ts"],"sourcesContent":["import { Action, ActionTypes } from '../actions'\n\nexport type Data = undefined | null | boolean | number | string | Data[] | { [key: string]: Data }\n\nexport type ElementData = { type: string; key: string; props: Record<string, Data> }\n\nexport type ElementReference = { type: 'reference'; key: string; value: string }\n\nexport type Element = ElementData | ElementReference\n\nexport function isElementReference(element: Element): element is ElementReference {\n return !('props' in element)\n}\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\nexport type Document = {\n key: string\n rootElement: Element\n}\n\nexport function createDocument(key: string, rootElement: Element): Document {\n return { key, rootElement }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({\n rootElements = new Map(),\n}: { rootElements?: Map<string, Element> } = {}): State {\n const initialState = new Map()\n\n rootElements.forEach((rootElement, documentKey) => {\n initialState.set(documentKey, createDocument(documentKey, rootElement))\n })\n\n return initialState\n}\n\nfunction getDocuments(state: State): Map<string, Document> {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n return new Map(state).set(action.payload.documentKey, action.payload.document)\n\n case ActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import type {\n ClassAttributes,\n ComponentClass,\n PropsWithoutRef,\n RefAttributes,\n VoidFunctionComponent,\n} from 'react'\n\nimport { Action, ActionTypes } from '../actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | ComponentClass<PropsWithoutRef<P> & ClassAttributes<T>>\n | VoidFunctionComponent<PropsWithoutRef<P> & RefAttributes<T>>\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action) {\n switch (action.type) {\n case ActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type ComponentIcon =\n | 'Carousel40'\n | 'Code40'\n | 'Countdown40'\n | 'Cube40'\n | 'Divider40'\n | 'Form40'\n | 'Navigation40'\n | 'SocialLinks40'\n | 'Video40'\n\nexport type ComponentMeta = { label: string; icon: ComponentIcon; hidden: boolean }\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Action, ActionTypes } from '../actions'\nimport { PropControllerDescriptor } from '../../prop-controllers'\n\nexport type { PropControllerDescriptor }\n\nexport type State = Map<string, Record<string, PropControllerDescriptor>>\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: Map<string, Record<string, PropControllerDescriptor>>\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllerDescriptor>> {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllerDescriptor> | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n","import { Descriptor, ElementIDValue, GridValue, Types } from './descriptors'\nimport { Data, Element } from '../state/react-page'\n\nexport function getElementChildren<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): Element[] {\n if (prop == null) return []\n\n switch (descriptor.type) {\n case Types.Grid:\n return (prop as GridValue).elements\n\n default:\n return []\n }\n}\n\nexport function getElementId<T extends Data>(\n descriptor: Descriptor<T>,\n prop: T | undefined,\n): string | null {\n if (prop == null) return null\n\n switch (descriptor.type) {\n case Types.ElementID:\n return prop as ElementIDValue\n\n default:\n return null\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkDispatch } from 'redux-thunk'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as Introspection from '../prop-controllers/introspection'\nimport { Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\nexport {\n createDocument,\n createDocumentReference,\n isElementReference,\n} from './modules/read-only-documents'\nexport type { ComponentType } from './modules/react-components'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n isInBuilder: (_state: boolean = false, _action: Action): boolean => false,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getPropControllerDescriptors(\n state: State,\n): Map<string, Record<string, PropControllers.PropControllerDescriptor>> {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction normalizeElement(\n element: Documents.Element,\n descriptors: Map<string, Record<string, PropControllers.PropControllerDescriptor>>,\n): Map<string, Documents.Element> {\n const elements = new Map<string, Documents.Element>()\n const remaining = [element]\n let current: Documents.Element | undefined\n\n while ((current = remaining.pop())) {\n elements.set(current.key, current)\n\n if (Documents.isElementReference(current)) continue\n\n const elementDescriptors = descriptors.get(current.type)\n\n if (elementDescriptors == null) continue\n\n const parent = current\n const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {\n return [...acc, ...Introspection.getElementChildren(descriptor, parent.props[propName])]\n }, [] as Documents.Element[])\n\n remaining.push(...children)\n }\n\n return elements\n}\n\nfunction getDocumentElements(state: State, documentKey: string): Map<string, Documents.Element> {\n const document = getDocument(state, documentKey)\n const descriptors = getPropControllerDescriptors(state)\n\n if (document == null) return new Map()\n\n return normalizeElement(document.rootElement, descriptors)\n}\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return getDocumentElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n const descriptors = getComponentPropControllerDescriptors(state, element.type)\n\n if (descriptors == null) return null\n\n const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n if (acc != null) return acc\n\n return Introspection.getElementId(descriptor, element.props[propName])\n }, null as string | null)\n\n return elementId\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n} = {}): Store {\n return createStore(\n reducer,\n { ...preloadedState, documents: Documents.getInitialState({ rootElements }) },\n applyMiddleware(thunk),\n )\n}\n"],"names":["getInitialState","reactComponents","Map","state","type","getReactComponents","get","action","ActionTypes","REGISTER_REACT_COMPONENT","set","payload","component","UNREGISTER_REACT_COMPONENT","nextState","deleted","delete","getPropControllerDescriptors","Documents.reducer","ReactComponents.reducer","ComponentsMeta.reducer","PropControllers.reducer","Documents.getDocument","ReactComponents.getReactComponent","PropControllers.getPropControllerDescriptors","PropControllers.getComponentPropControllerDescriptors","Documents.isElementReference","Introspection.getElementChildren","Introspection.getElementId","Documents.getInitialState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUO,4BAA4B,SAA+C;AA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;"}
|
package/dist/react.cjs2.js
CHANGED
|
@@ -7723,6 +7723,14 @@ exports.cssTextStyle = cssTextStyle;
|
|
|
7723
7723
|
exports.cssWidth = cssWidth;
|
|
7724
7724
|
exports.registerBuiltinComponents = registerBuiltinComponents;
|
|
7725
7725
|
exports.registerComponent = registerComponent$b;
|
|
7726
|
+
exports.useBackgrounds = useBackgrounds;
|
|
7727
|
+
exports.useBorder = useBorder;
|
|
7728
|
+
exports.useBoxShadow = useBoxShadow;
|
|
7729
|
+
exports.useColor = useColor;
|
|
7730
|
+
exports.useFile = useFile;
|
|
7726
7731
|
exports.useIsInBuilder = useIsInBuilder;
|
|
7732
|
+
exports.useMediaQuery = useMediaQuery;
|
|
7733
|
+
exports.usePage = usePage;
|
|
7727
7734
|
exports.usePageId = usePageId;
|
|
7735
|
+
exports.useTable = useTable;
|
|
7728
7736
|
//# sourceMappingURL=react.cjs2.js.map
|