@builder.io/sdk-react-native 0.4.1 → 0.4.3

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.
Files changed (147) hide show
  1. package/dist/blocks/BaseText.d.ts +6 -0
  2. package/dist/blocks/button/button.d.ts +9 -0
  3. package/dist/blocks/button/component-info.d.ts +2 -0
  4. package/dist/blocks/columns/columns.d.ts +16 -0
  5. package/dist/blocks/columns/component-info.d.ts +2 -0
  6. package/dist/blocks/custom-code/component-info.d.ts +2 -0
  7. package/dist/blocks/custom-code/custom-code.d.ts +5 -0
  8. package/dist/blocks/embed/component-info.d.ts +2 -0
  9. package/dist/blocks/embed/embed.d.ts +5 -0
  10. package/dist/blocks/embed/helpers.d.ts +1 -0
  11. package/dist/blocks/form/component-info.d.ts +2 -0
  12. package/dist/blocks/form/form.d.ts +28 -0
  13. package/dist/blocks/fragment/component-info.d.ts +2 -0
  14. package/dist/blocks/fragment/fragment.d.ts +8 -0
  15. package/dist/blocks/image/component-info.d.ts +2 -0
  16. package/dist/blocks/image/image.d.ts +17 -0
  17. package/dist/blocks/image/image.helpers.d.ts +1 -0
  18. package/dist/blocks/img/component-info.d.ts +2 -0
  19. package/dist/blocks/img/component-info.js +1 -1
  20. package/dist/blocks/img/img.d.ts +11 -0
  21. package/dist/blocks/input/component-info.d.ts +2 -0
  22. package/dist/blocks/input/input.d.ts +12 -0
  23. package/dist/blocks/raw-text/component-info.d.ts +2 -0
  24. package/dist/blocks/raw-text/raw-text.d.ts +5 -0
  25. package/dist/blocks/section/component-info.d.ts +2 -0
  26. package/dist/blocks/section/section.d.ts +9 -0
  27. package/dist/blocks/select/component-info.d.ts +2 -0
  28. package/dist/blocks/select/select.d.ts +13 -0
  29. package/dist/blocks/submit-button/component-info.d.ts +2 -0
  30. package/dist/blocks/submit-button/submit-button.d.ts +7 -0
  31. package/dist/blocks/symbol/component-info.d.ts +2 -0
  32. package/dist/blocks/symbol/symbol.d.ts +21 -0
  33. package/dist/blocks/text/component-info.d.ts +2 -0
  34. package/dist/blocks/text/text.d.ts +7 -0
  35. package/dist/blocks/textarea/component-info.d.ts +2 -0
  36. package/dist/blocks/textarea/textarea.d.ts +10 -0
  37. package/dist/blocks/util.d.ts +4 -0
  38. package/dist/blocks/video/component-info.d.ts +2 -0
  39. package/dist/blocks/video/video.d.ts +31 -0
  40. package/dist/components/render-block/block-styles.d.ts +9 -0
  41. package/dist/components/render-block/render-block.d.ts +9 -0
  42. package/dist/components/render-block/render-block.helpers.d.ts +12 -0
  43. package/dist/components/render-block/render-block.js +18 -26
  44. package/dist/components/render-block/render-component.d.ts +17 -0
  45. package/dist/components/render-block/render-repeated-block.d.ts +9 -0
  46. package/dist/components/render-block/render-repeated-block.js +3 -12
  47. package/dist/components/render-block/types.d.ts +6 -0
  48. package/dist/components/render-blocks.d.ts +10 -0
  49. package/dist/components/render-blocks.js +1 -1
  50. package/dist/components/render-content/builder-editing.d.ts +3 -0
  51. package/dist/components/render-content/components/render-styles.d.ts +9 -0
  52. package/dist/components/render-content/components/render-styles.helpers.d.ts +15 -0
  53. package/dist/components/render-content/index.d.ts +1 -0
  54. package/dist/components/render-content/render-content.d.ts +4 -0
  55. package/dist/components/render-content/render-content.helpers.d.ts +7 -0
  56. package/dist/components/render-content/render-content.js +77 -71
  57. package/dist/components/render-content/render-content.types.d.ts +38 -0
  58. package/dist/components/render-content/wrap-component-ref.d.ts +6 -0
  59. package/dist/components/render-content-variants/helpers.d.ts +17 -0
  60. package/dist/components/render-content-variants/helpers.js +3 -1
  61. package/dist/components/render-content-variants/render-content-variants.d.ts +5 -0
  62. package/dist/components/render-inlined-styles.d.ts +7 -0
  63. package/dist/constants/builder-registered-components.d.ts +6 -0
  64. package/dist/constants/device-sizes.d.ts +13 -0
  65. package/dist/constants/sdk-version.d.ts +1 -0
  66. package/dist/constants/sdk-version.js +1 -1
  67. package/dist/constants/target.d.ts +3 -0
  68. package/dist/context/builder.context.d.ts +3 -0
  69. package/dist/context/types.d.ts +35 -0
  70. package/dist/functions/camel-to-kebab-case.d.ts +1 -0
  71. package/dist/functions/evaluate.d.ts +7 -0
  72. package/dist/functions/evaluate.test.d.ts +1 -0
  73. package/dist/functions/event-handler-name.d.ts +1 -0
  74. package/dist/functions/extract-text-styles.d.ts +4 -0
  75. package/dist/functions/fast-clone.d.ts +4 -0
  76. package/dist/functions/get-block-actions-handler.d.ts +8 -0
  77. package/dist/functions/get-block-actions.d.ts +9 -0
  78. package/dist/functions/get-block-component-options.d.ts +2 -0
  79. package/dist/functions/get-block-properties.d.ts +2 -0
  80. package/dist/functions/get-builder-search-params/fn.test.d.ts +1 -0
  81. package/dist/functions/get-builder-search-params/index.d.ts +12 -0
  82. package/dist/functions/get-content/generate-content-url.d.ts +2 -0
  83. package/dist/functions/get-content/generate-content-url.test.d.ts +1 -0
  84. package/dist/functions/get-content/index.d.ts +16 -0
  85. package/dist/functions/get-content/types.d.ts +51 -0
  86. package/dist/functions/get-fetch.d.ts +1 -0
  87. package/dist/functions/get-processed-block.d.ts +10 -0
  88. package/dist/functions/get-processed-block.test.d.ts +1 -0
  89. package/dist/functions/get-react-native-block-styles.d.ts +7 -0
  90. package/dist/functions/if-target.d.ts +7 -0
  91. package/dist/functions/is-browser.d.ts +1 -0
  92. package/dist/functions/is-editing.d.ts +1 -0
  93. package/dist/functions/is-iframe.d.ts +1 -0
  94. package/dist/functions/is-previewing.d.ts +1 -0
  95. package/dist/functions/on-change.d.ts +7 -0
  96. package/dist/functions/on-change.test.d.ts +1 -0
  97. package/dist/functions/register-component.d.ts +14 -0
  98. package/dist/functions/register.d.ts +16 -0
  99. package/dist/functions/sanitize-react-native-block-styles.d.ts +3 -0
  100. package/dist/functions/set-editor-settings.d.ts +4 -0
  101. package/dist/functions/set.d.ts +7 -0
  102. package/dist/functions/set.test.d.ts +1 -0
  103. package/dist/functions/track/helpers.d.ts +5 -0
  104. package/dist/functions/track/index.d.ts +51 -0
  105. package/dist/functions/track/interaction.d.ts +13 -0
  106. package/dist/functions/transform-block-properties.d.ts +3 -0
  107. package/dist/functions/transform-block.d.ts +2 -0
  108. package/dist/helpers/ab-tests.d.ts +9 -0
  109. package/dist/helpers/canTrack.d.ts +1 -0
  110. package/dist/helpers/cookie.d.ts +9 -0
  111. package/dist/helpers/css.d.ts +7 -0
  112. package/dist/helpers/flatten.d.ts +6 -0
  113. package/dist/helpers/localStorage.d.ts +9 -0
  114. package/dist/helpers/logger.d.ts +6 -0
  115. package/dist/helpers/nullable.d.ts +2 -0
  116. package/dist/helpers/sessionId.d.ts +6 -0
  117. package/dist/helpers/time.d.ts +1 -0
  118. package/dist/helpers/url.d.ts +6 -0
  119. package/dist/helpers/url.test.d.ts +1 -0
  120. package/dist/helpers/uuid.d.ts +8 -0
  121. package/dist/helpers/visitorId.d.ts +6 -0
  122. package/dist/index-helpers/blocks-exports.d.ts +8 -0
  123. package/dist/index-helpers/top-of-file.d.ts +1 -0
  124. package/dist/index.d.ts +15 -0
  125. package/dist/scripts/init-editing.d.ts +6 -0
  126. package/dist/types/api-version.d.ts +2 -0
  127. package/dist/types/builder-block.d.ts +66 -0
  128. package/dist/types/builder-content.d.ts +44 -0
  129. package/dist/types/can-track.d.ts +3 -0
  130. package/dist/types/components.d.ts +105 -0
  131. package/dist/types/deep-partial.d.ts +3 -0
  132. package/dist/types/element.d.ts +59 -0
  133. package/dist/types/input.d.ts +121 -0
  134. package/dist/types/targets.d.ts +3 -0
  135. package/dist/types/typescript.d.ts +5 -0
  136. package/package.json +1 -1
  137. package/src/blocks/img/component-info.js +1 -1
  138. package/src/components/render-block/render-block.jsx +21 -29
  139. package/src/components/render-block/render-repeated-block.jsx +5 -15
  140. package/src/components/render-blocks.jsx +1 -0
  141. package/src/components/render-content/render-content.jsx +77 -85
  142. package/src/components/render-content-variants/helpers.js +3 -1
  143. package/src/constants/sdk-version.js +1 -1
  144. package/dist/components/render-block/render-component-with-context.js +0 -45
  145. package/dist/functions/get-block-tag.js +0 -8
  146. package/dist/functions/get-content/ab-testing.js +0 -89
  147. package/dist/functions/track.js +0 -120
@@ -0,0 +1,7 @@
1
+ type Target = import('../types/targets').Target;
2
+ export declare function ifTarget<A, B>({ targets, doThing, elseThing, }: {
3
+ targets: Target[];
4
+ doThing: () => A;
5
+ elseThing?: () => B;
6
+ }): A | B | undefined;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare function isBrowser(): boolean;
@@ -0,0 +1 @@
1
+ export declare function isEditing(): boolean;
@@ -0,0 +1 @@
1
+ export declare function isIframe(): boolean;
@@ -0,0 +1 @@
1
+ export declare function isPreviewing(): boolean;
@@ -0,0 +1,7 @@
1
+ export declare const onChangeProxySymbol: unique symbol;
2
+ /**
3
+ * Deeply observe an object and run a callback when it changes
4
+ *
5
+ * See ./on-change.test.ts for more info
6
+ */
7
+ export declare function onChange<T extends object = any>(obj: T, cb: () => void): T;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { RegisteredComponent } from '../context/types.js';
2
+ import type { ComponentInfo } from '../types/components.js';
3
+ /**
4
+ * @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
5
+ */
6
+ export declare const components: RegisteredComponent[];
7
+ /**
8
+ * @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
9
+ */
10
+ export declare function registerComponent(component: any, info: ComponentInfo): void;
11
+ export declare const createRegisterComponentMessage: ({ component: _, ...info }: RegisteredComponent) => {
12
+ type: string;
13
+ data: ComponentInfo;
14
+ };
@@ -0,0 +1,16 @@
1
+ import type { BuilderBlock } from '../types/builder-block.js';
2
+ import type { DeepPartial } from '../types/deep-partial.js';
3
+ export interface InsertMenuItem {
4
+ name: string;
5
+ icon?: string;
6
+ item: DeepPartial<BuilderBlock>;
7
+ }
8
+ export interface InsertMenuConfig {
9
+ name: string;
10
+ priority?: number;
11
+ persist?: boolean;
12
+ advanced?: boolean;
13
+ items: InsertMenuItem[];
14
+ }
15
+ export declare function register(type: 'insertMenu', info: InsertMenuConfig): void;
16
+ export declare function register(type: string, info: any): void;
@@ -0,0 +1,3 @@
1
+ type Styles = Record<string, string | number>;
2
+ export declare const sanitizeReactNativeBlockStyles: (styles: Styles) => Styles;
3
+ export {};
@@ -0,0 +1,4 @@
1
+ export type Settings = {
2
+ customInsertMenu?: boolean;
3
+ };
4
+ export declare function setEditorSettings(newSettings: Settings): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Minimal implementation of lodash's _.set
3
+ * https://lodash.com/docs/4.17.15#set
4
+ *
5
+ * See ./set.test.ts for usage examples
6
+ */
7
+ export declare const set: (obj: any, _path: string | string[], value: any) => any;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const getUserAttributes: () => {
2
+ urlPath: string | undefined;
3
+ host: string | undefined;
4
+ device: string;
5
+ };
@@ -0,0 +1,51 @@
1
+ import type { CanTrack } from '../../types/can-track.js';
2
+ import type { Dictionary } from '../../types/typescript.js';
3
+ interface Event {
4
+ /**
5
+ * The type of your event.
6
+ *
7
+ * Examples: `click`, `conversion`, `pageview`, `impression`
8
+ */
9
+ type: string;
10
+ data: {
11
+ /**
12
+ * (Optional) The content's ID. Useful if this event pertains to a specific piece of content.
13
+ */
14
+ contentId?: string;
15
+ /**
16
+ * This is the ID of the space that the content belongs to.
17
+ */
18
+ ownerId: string;
19
+ /**
20
+ * (Optional) metadata that you want to provide with your event.
21
+ */
22
+ metadata?: Dictionary<any>;
23
+ /**
24
+ * Session ID of the user. This is provided by the SDK by checking session storage.
25
+ */
26
+ sessionId: string | undefined;
27
+ /**
28
+ * Visitor ID of the user. This is provided by the SDK by checking cookies.
29
+ */
30
+ visitorId: string | undefined;
31
+ /**
32
+ * (Optional) If running an A/B test, the ID of the variation that the user is in.
33
+ */
34
+ variationId?: string;
35
+ [index: string]: any;
36
+ };
37
+ }
38
+ type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | 'variationId' | 'metadata'> & {
39
+ /**
40
+ * Your organization's API key.
41
+ */
42
+ apiKey: Event['data']['ownerId'];
43
+ /**
44
+ * (Optional) Any additional (non-metadata) properties to add to the event.
45
+ */
46
+ [index: string]: any;
47
+ };
48
+ export type EventProps = EventProperties & CanTrack;
49
+ export declare function _track(eventProps: EventProps): Promise<void | Response>;
50
+ export declare const track: (args: EventProperties) => Promise<void | Response>;
51
+ export {};
@@ -0,0 +1,13 @@
1
+ type Offset = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ export declare const getInteractionPropertiesForEvent: (event: MouseEvent) => {
6
+ targetBuilderElement: string | undefined;
7
+ metadata: {
8
+ targetOffset: Offset | undefined;
9
+ builderTargetOffset: Offset | undefined;
10
+ builderElementIndex: number | undefined;
11
+ };
12
+ };
13
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare function transformBlockProperties<T extends {
2
+ id?: string;
3
+ }>(block: T): T;
@@ -0,0 +1,2 @@
1
+ import type { BuilderBlock } from '../types/builder-block.js';
2
+ export declare function transformBlock(block: BuilderBlock): BuilderBlock;
@@ -0,0 +1,9 @@
1
+ import type { CanTrack } from '../types/can-track.js';
2
+ import type { BuilderContent } from '../types/builder-content.js';
3
+ import type { Nullable } from '../types/typescript.js';
4
+ export declare const handleABTestingSync: ({ item, canTrack, }: {
5
+ item: Nullable<BuilderContent>;
6
+ } & CanTrack) => Nullable<BuilderContent>;
7
+ export declare const handleABTesting: ({ item, canTrack, }: {
8
+ item: BuilderContent;
9
+ } & CanTrack) => Promise<BuilderContent>;
@@ -0,0 +1 @@
1
+ export declare const getDefaultCanTrack: (canTrack?: boolean) => boolean;
@@ -0,0 +1,9 @@
1
+ import type { CanTrack } from '../types/can-track.js';
2
+ export declare const getCookie: ({ name, canTrack, }: {
3
+ name: string;
4
+ } & CanTrack) => Promise<any>;
5
+ export declare const setCookie: ({ name, value, expires, canTrack, }: {
6
+ name: string;
7
+ value: string;
8
+ expires?: Date | undefined;
9
+ } & CanTrack) => Promise<undefined>;
@@ -0,0 +1,7 @@
1
+ export declare const convertStyleMapToCSSArray: (style: Partial<CSSStyleDeclaration>) => string[];
2
+ export declare const convertStyleMapToCSS: (style: Partial<CSSStyleDeclaration>) => string;
3
+ export declare const createCssClass: ({ mediaQuery, className, styles, }: {
4
+ mediaQuery?: string | undefined;
5
+ className: string;
6
+ styles: Partial<CSSStyleDeclaration>;
7
+ }) => string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Convert deep object to a flat object with dots
3
+ *
4
+ * { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
5
+ */
6
+ export declare function flatten<T extends Record<string, any>>(object: T, path?: string | null, separator?: string): T;
@@ -0,0 +1,9 @@
1
+ import type { CanTrack } from '../types/can-track.js';
2
+ import type { Nullable } from './nullable.js';
3
+ export declare const getLocalStorageItem: ({ key, canTrack, }: {
4
+ key: string;
5
+ } & CanTrack) => Nullable<string>;
6
+ export declare const setLocalStorageItem: ({ key, canTrack, value, }: {
7
+ key: string;
8
+ value: string;
9
+ } & CanTrack) => void;
@@ -0,0 +1,6 @@
1
+ export declare const logger: {
2
+ log: (...message: any[]) => void;
3
+ error: (...message: any[]) => void;
4
+ warn: (...message: any[]) => void;
5
+ debug: (...message: any[]) => void;
6
+ };
@@ -0,0 +1,2 @@
1
+ export type Nullable<T> = T | null | undefined;
2
+ export declare const checkIsDefined: <T>(maybeT: Nullable<T>) => maybeT is T;
@@ -0,0 +1,6 @@
1
+ import type { CanTrack } from '../types/can-track.js';
2
+ export declare const getSessionId: ({ canTrack, }: CanTrack) => Promise<string | undefined>;
3
+ export declare const createSessionId: () => string;
4
+ export declare const setSessionId: ({ id, canTrack, }: {
5
+ id: string;
6
+ } & CanTrack) => Promise<undefined>;
@@ -0,0 +1 @@
1
+ export declare const getCurrentDatePlusMinutes: (minutes?: number) => Date;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Only gets one level up from hostname
3
+ * wwww.example.com -> example.com
4
+ * www.example.co.uk -> example.co.uk
5
+ */
6
+ export declare const getTopLevelDomain: (host: string) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @credit https://stackoverflow.com/a/2117523
3
+ */
4
+ export declare function uuidv4(): string;
5
+ /**
6
+ * Slightly cleaner and smaller UUIDs
7
+ */
8
+ export declare function uuid(): string;
@@ -0,0 +1,6 @@
1
+ import type { CanTrack } from '../types/can-track.js';
2
+ export declare const getVisitorId: ({ canTrack }: CanTrack) => string | undefined;
3
+ export declare const createVisitorId: () => string;
4
+ export declare const setVisitorId: ({ id, canTrack, }: {
5
+ id: string;
6
+ } & CanTrack) => void;
@@ -0,0 +1,8 @@
1
+ export { default as Columns } from '../blocks/columns/columns';
2
+ export { default as Image } from '../blocks/image/image';
3
+ export { default as Text } from '../blocks/text/text';
4
+ export { default as Symbol } from '../blocks/symbol/symbol';
5
+ export { default as Button } from '../blocks/button/button';
6
+ export { default as Section } from '../blocks/section/section';
7
+ export { default as Fragment } from '../blocks/fragment/fragment';
8
+ export { default as RenderContent } from '../components/render-content/render-content';
@@ -0,0 +1 @@
1
+ import 'react-native-url-polyfill/auto';
@@ -0,0 +1,15 @@
1
+ export * from './index-helpers/top-of-file.js';
2
+ export * from './index-helpers/blocks-exports.js';
3
+ export { isEditing } from './functions/is-editing.js';
4
+ export { isPreviewing } from './functions/is-previewing.js';
5
+ export { createRegisterComponentMessage } from './functions/register-component.js';
6
+ export { register } from './functions/register.js';
7
+ export type { InsertMenuConfig, InsertMenuItem } from './functions/register.js';
8
+ export { setEditorSettings } from './functions/set-editor-settings.js';
9
+ export type { Settings } from './functions/set-editor-settings.js';
10
+ export { getAllContent, getContent, processContentResult, } from './functions/get-content/index.js';
11
+ export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
12
+ export { track } from './functions/track/index.js';
13
+ export type { RegisteredComponent } from './context/types';
14
+ export type { ComponentInfo } from './types/components';
15
+ export type { RenderContentProps } from './components/render-content/render-content.types.js';
@@ -0,0 +1,6 @@
1
+ export declare const registerInsertMenu: () => void;
2
+ export declare const setupBrowserForEditing: (options?: {
3
+ enrich?: boolean;
4
+ includeRefs?: boolean;
5
+ locale?: string;
6
+ }) => void;
@@ -0,0 +1,2 @@
1
+ export type ApiVersion = 'v2' | 'v3';
2
+ export declare const DEFAULT_API_VERSION: ApiVersion;
@@ -0,0 +1,66 @@
1
+ type JSONValue = string | number | boolean | JSONObject | JSONArray;
2
+ interface JSONObject {
3
+ [x: string]: JSONValue;
4
+ }
5
+ interface JSONArray extends Array<JSONValue> {
6
+ }
7
+ /** @todo typedoc this */
8
+ export interface BuilderBlock {
9
+ '@type': '@builder.io/sdk:Element';
10
+ '@version'?: number;
11
+ id?: string;
12
+ tagName?: string;
13
+ layerName?: string;
14
+ groupLocked?: boolean;
15
+ layerLocked?: boolean;
16
+ /** @todo make alias for properties.class */
17
+ class?: string;
18
+ children?: BuilderBlock[];
19
+ responsiveStyles?: {
20
+ large?: Partial<CSSStyleDeclaration>;
21
+ medium?: Partial<CSSStyleDeclaration>;
22
+ small?: Partial<CSSStyleDeclaration>;
23
+ /** @deprecated */
24
+ xsmall?: Partial<CSSStyleDeclaration>;
25
+ };
26
+ component?: {
27
+ name: string;
28
+ options?: any;
29
+ tag?: string;
30
+ };
31
+ bindings?: {
32
+ [key: string]: string;
33
+ };
34
+ meta?: {
35
+ [key: string]: JSONValue;
36
+ };
37
+ actions?: {
38
+ [key: string]: string;
39
+ };
40
+ properties?: {
41
+ [key: string]: string;
42
+ };
43
+ code?: {
44
+ bindings?: {
45
+ [key: string]: string;
46
+ };
47
+ actions?: {
48
+ [key: string]: string;
49
+ };
50
+ };
51
+ repeat?: {
52
+ collection: string;
53
+ itemName?: string;
54
+ } | null;
55
+ animations?: any[];
56
+ style?: Partial<CSSStyleDeclaration>;
57
+ /**
58
+ * generated by the "Hide If" binding
59
+ */
60
+ hide?: boolean;
61
+ /**
62
+ * generated by the "Show If" binding
63
+ */
64
+ show?: boolean;
65
+ }
66
+ export {};
@@ -0,0 +1,44 @@
1
+ import type { BuilderBlock } from './builder-block.js';
2
+ import type { Input } from './input.js';
3
+ import type { Nullable } from './typescript.js';
4
+ export interface Breakpoints {
5
+ small: number;
6
+ medium: number;
7
+ }
8
+ export interface BuilderContentVariation {
9
+ data?: {
10
+ title?: string;
11
+ blocks?: BuilderBlock[];
12
+ inputs?: Input[];
13
+ state?: {
14
+ [key: string]: any;
15
+ };
16
+ jsCode?: string;
17
+ tsCode?: string;
18
+ httpRequests?: {
19
+ [key: string]: string;
20
+ };
21
+ [key: string]: any;
22
+ };
23
+ name?: string;
24
+ testRatio?: number;
25
+ id?: string;
26
+ meta?: {
27
+ breakpoints?: Nullable<Breakpoints>;
28
+ [key: string]: any;
29
+ };
30
+ }
31
+ export interface BuilderContent extends BuilderContentVariation {
32
+ '@version'?: number;
33
+ published?: 'published' | 'draft' | 'archived';
34
+ modelId?: string;
35
+ priority?: number;
36
+ lastUpdated?: number;
37
+ startDate?: number;
38
+ endDate?: number;
39
+ variations?: {
40
+ [id: string]: BuilderContentVariation;
41
+ };
42
+ testVariationId?: string;
43
+ testVariationName?: string;
44
+ }
@@ -0,0 +1,3 @@
1
+ export type CanTrack = {
2
+ canTrack: boolean;
3
+ };
@@ -0,0 +1,105 @@
1
+ import type { BuilderElement } from './element';
2
+ import type { Input } from './input';
3
+ export interface ComponentInfo {
4
+ /**
5
+ * Name your component something unique, e.g. 'MyButton'. You can override built-in components
6
+ * by registering a component with the same name, e.g. 'Text', to replace the built-in text component
7
+ */
8
+ name: string;
9
+ description?: string;
10
+ /**
11
+ * Link to a documentation page for this component
12
+ */
13
+ docsLink?: string;
14
+ image?: string;
15
+ /**
16
+ * Input schema for your component for users to fill in the options
17
+ */
18
+ inputs?: Input[];
19
+ class?: any;
20
+ type?: 'angular' | 'webcomponent' | 'react' | 'vue';
21
+ defaultStyles?: {
22
+ [key: string]: string;
23
+ };
24
+ /**
25
+ * Turn on if your component can accept children. Be sure to use in combination with
26
+ * withChildren(YourComponent) like here
27
+ * github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
28
+ */
29
+ canHaveChildren?: boolean;
30
+ fragment?: boolean;
31
+ /**
32
+ * Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
33
+ * like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
34
+ */
35
+ noWrap?: boolean;
36
+ /**
37
+ * Default children
38
+ */
39
+ defaultChildren?: BuilderElement[];
40
+ defaults?: Partial<BuilderElement>;
41
+ hooks?: {
42
+ [key: string]: string | Function;
43
+ };
44
+ /**
45
+ * Hide your component in editor, useful for gradually deprecating components
46
+ */
47
+ hideFromInsertMenu?: boolean;
48
+ tag?: string;
49
+ static?: boolean;
50
+ /**
51
+ * Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
52
+ */
53
+ models?: string[];
54
+ /**
55
+ * Specify restrictions direct children must match
56
+ */
57
+ childRequirements?: {
58
+ /** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
59
+ message: string;
60
+ /** Simple way to say children must be a specific component name */
61
+ component?: string;
62
+ /**
63
+ * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
64
+ * of what the children objects should match, e.g.
65
+ *
66
+ * @example
67
+ * query: {
68
+ * // Child of this element must be a 'Button' or 'Text' component
69
+ * 'component.name': { $in: ['Button', 'Text'] }
70
+ * }
71
+ */
72
+ query?: any;
73
+ };
74
+ /**
75
+ * Specify restrictions any parent must match
76
+ */
77
+ requiresParent?: {
78
+ /** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
79
+ message: string;
80
+ /** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
81
+ component?: string;
82
+ /**
83
+ * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
84
+ * of what at least one parent in the parents hierarchy should match, e.g.
85
+ *
86
+ * @example
87
+ * query: {
88
+ * // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
89
+ * 'component.name': { $in: ['Product Box', 'Collection'] }
90
+ * }
91
+ */
92
+ query?: any;
93
+ };
94
+ /** not yet implemented */
95
+ friendlyName?: string;
96
+ /**
97
+ * Use to restrict access to your component based on a the current user permissions
98
+ * By default components will show to all users
99
+ * for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
100
+ */
101
+ requiredPermissions?: Array<Permission>;
102
+ hidden?: boolean;
103
+ }
104
+ type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
105
+ export {};
@@ -0,0 +1,3 @@
1
+ export type DeepPartial<T> = {
2
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
3
+ };
@@ -0,0 +1,59 @@
1
+ type JSONValue = string | number | boolean | JSONObject | JSONArray;
2
+ interface JSONObject {
3
+ [x: string]: JSONValue;
4
+ }
5
+ interface JSONArray extends Array<JSONValue> {
6
+ }
7
+ /** @todo typedoc this */
8
+ export interface BuilderElement {
9
+ '@type': '@builder.io/sdk:Element';
10
+ '@version'?: number;
11
+ id?: string;
12
+ tagName?: string;
13
+ layerName?: string;
14
+ groupLocked?: boolean;
15
+ layerLocked?: boolean;
16
+ /** @todo make alias for properties.class */
17
+ class?: string;
18
+ children?: BuilderElement[];
19
+ responsiveStyles?: {
20
+ large?: Partial<CSSStyleDeclaration>;
21
+ medium?: Partial<CSSStyleDeclaration>;
22
+ small?: Partial<CSSStyleDeclaration>;
23
+ /** @deprecated */
24
+ xsmall?: Partial<CSSStyleDeclaration>;
25
+ };
26
+ component?: {
27
+ name: string;
28
+ options?: any;
29
+ tag?: string;
30
+ };
31
+ bindings?: {
32
+ [key: string]: string;
33
+ };
34
+ meta?: {
35
+ [key: string]: JSONValue;
36
+ };
37
+ actions?: {
38
+ [key: string]: string;
39
+ };
40
+ properties?: {
41
+ [key: string]: string;
42
+ };
43
+ code?: {
44
+ bindings?: {
45
+ [key: string]: string;
46
+ };
47
+ actions?: {
48
+ [key: string]: string;
49
+ };
50
+ };
51
+ repeat?: {
52
+ collection: string;
53
+ itemName?: string;
54
+ } | null;
55
+ animations?: Animation[];
56
+ }
57
+ interface Animation {
58
+ }
59
+ export {};