@builder.io/sdk-qwik 0.20.0 → 0.21.1

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 (58) hide show
  1. package/lib/browser/blocks/form/form/form.qwik.cjs +7 -3
  2. package/lib/browser/blocks/form/form/form.qwik.mjs +7 -3
  3. package/lib/browser/blocks/symbol/symbol.qwik.cjs +13 -6
  4. package/lib/browser/blocks/symbol/symbol.qwik.mjs +13 -6
  5. package/lib/browser/blocks/tabs/tabs.qwik.cjs +5 -3
  6. package/lib/browser/blocks/tabs/tabs.qwik.mjs +5 -3
  7. package/lib/browser/components/block/components/component-ref/component-ref.qwik.cjs +2 -9
  8. package/lib/browser/components/block/components/component-ref/component-ref.qwik.mjs +3 -10
  9. package/lib/browser/components/content/components/enable-editor.qwik.cjs +18 -5
  10. package/lib/browser/components/content/components/enable-editor.qwik.mjs +18 -5
  11. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  12. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  13. package/lib/browser/functions/register.qwik.cjs +13 -0
  14. package/lib/browser/functions/register.qwik.mjs +14 -1
  15. package/lib/browser/index.qwik.cjs +1 -0
  16. package/lib/browser/index.qwik.mjs +2 -1
  17. package/lib/edge/blocks/form/form/form.qwik.cjs +7 -3
  18. package/lib/edge/blocks/form/form/form.qwik.mjs +7 -3
  19. package/lib/edge/blocks/symbol/symbol.qwik.cjs +13 -6
  20. package/lib/edge/blocks/symbol/symbol.qwik.mjs +13 -6
  21. package/lib/edge/blocks/tabs/tabs.qwik.cjs +5 -3
  22. package/lib/edge/blocks/tabs/tabs.qwik.mjs +5 -3
  23. package/lib/edge/components/block/components/component-ref/component-ref.qwik.cjs +2 -9
  24. package/lib/edge/components/block/components/component-ref/component-ref.qwik.mjs +3 -10
  25. package/lib/edge/components/content/components/enable-editor.qwik.cjs +18 -5
  26. package/lib/edge/components/content/components/enable-editor.qwik.mjs +18 -5
  27. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  28. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  29. package/lib/edge/functions/register.qwik.cjs +13 -0
  30. package/lib/edge/functions/register.qwik.mjs +14 -1
  31. package/lib/edge/index.qwik.cjs +1 -0
  32. package/lib/edge/index.qwik.mjs +2 -1
  33. package/lib/node/blocks/form/form/form.qwik.cjs +7 -3
  34. package/lib/node/blocks/form/form/form.qwik.mjs +7 -3
  35. package/lib/node/blocks/symbol/symbol.qwik.cjs +13 -6
  36. package/lib/node/blocks/symbol/symbol.qwik.mjs +13 -6
  37. package/lib/node/blocks/tabs/tabs.qwik.cjs +5 -3
  38. package/lib/node/blocks/tabs/tabs.qwik.mjs +5 -3
  39. package/lib/node/components/block/components/component-ref/component-ref.qwik.cjs +2 -9
  40. package/lib/node/components/block/components/component-ref/component-ref.qwik.mjs +3 -10
  41. package/lib/node/components/content/components/enable-editor.qwik.cjs +18 -5
  42. package/lib/node/components/content/components/enable-editor.qwik.mjs +18 -5
  43. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  44. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  45. package/lib/node/functions/register.qwik.cjs +13 -0
  46. package/lib/node/functions/register.qwik.mjs +14 -1
  47. package/lib/node/index.qwik.cjs +1 -0
  48. package/lib/node/index.qwik.mjs +2 -1
  49. package/package.json +1 -1
  50. package/types/src/blocks/form/form/form.d.ts +1 -0
  51. package/types/src/blocks/symbol/symbol.d.ts +1 -1
  52. package/types/src/blocks/symbol/symbol.types.d.ts +1 -2
  53. package/types/src/blocks/tabs/tabs.d.ts +1 -0
  54. package/types/src/components/awaiter.d.ts +1 -11
  55. package/types/src/components/awaiter.types.d.ts +7 -0
  56. package/types/src/constants/sdk-version.d.ts +1 -1
  57. package/types/src/functions/register.d.ts +18 -0
  58. package/types/src/server-index.d.ts +1 -1
@@ -5,6 +5,9 @@ const blocks = require("../../components/blocks/blocks.qwik.cjs");
5
5
  const activeTabContent = function activeTabContent2(props, state, active) {
6
6
  return props.tabs && props.tabs[active].content;
7
7
  };
8
+ const getTabStyle = function getTabStyle2(props, state, index) {
9
+ return index === state.activeTab ? props.activeTabStyle : {};
10
+ };
8
11
  const onClick = function onClick2(props, state, index) {
9
12
  if (index === state.activeTab && props.collapsible)
10
13
  state.activeTab = -1;
@@ -38,9 +41,7 @@ const Tabs = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((
38
41
  props,
39
42
  state
40
43
  ]),
41
- style: {
42
- ...state.activeTab === index ? props.activeTabStyle : {}
43
- }
44
+ style: getTabStyle(props, state, index)
44
45
  }, null, /* @__PURE__ */ qwik._jsxC(blocks.Blocks, {
45
46
  get parent() {
46
47
  return props.builderBlock.id;
@@ -115,4 +116,5 @@ const Tabs = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((
115
116
  exports.Tabs = Tabs;
116
117
  exports.activeTabContent = activeTabContent;
117
118
  exports.default = Tabs;
119
+ exports.getTabStyle = getTabStyle;
118
120
  exports.onClick = onClick;
@@ -3,6 +3,9 @@ import { Blocks } from "../../components/blocks/blocks.qwik.mjs";
3
3
  const activeTabContent = function activeTabContent2(props, state, active) {
4
4
  return props.tabs && props.tabs[active].content;
5
5
  };
6
+ const getTabStyle = function getTabStyle2(props, state, index) {
7
+ return index === state.activeTab ? props.activeTabStyle : {};
8
+ };
6
9
  const onClick = function onClick2(props, state, index) {
7
10
  if (index === state.activeTab && props.collapsible)
8
11
  state.activeTab = -1;
@@ -36,9 +39,7 @@ const Tabs = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
36
39
  props,
37
40
  state
38
41
  ]),
39
- style: {
40
- ...state.activeTab === index ? props.activeTabStyle : {}
41
- }
42
+ style: getTabStyle(props, state, index)
42
43
  }, null, /* @__PURE__ */ _jsxC(Blocks, {
43
44
  get parent() {
44
45
  return props.builderBlock.id;
@@ -114,5 +115,6 @@ export {
114
115
  Tabs,
115
116
  activeTabContent,
116
117
  Tabs as default,
118
+ getTabStyle,
117
119
  onClick
118
120
  };
@@ -10,13 +10,6 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
10
10
  Wrapper: props.isInteractive ? interactiveElement.InteractiveElement : props.componentRef,
11
11
  shouldUpdate: false
12
12
  });
13
- qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(({ track }) => {
14
- const [props2] = qwik.useLexicalScope();
15
- track(() => props2.componentOptions);
16
- track(() => props2.blockChildren);
17
- }, "ComponentRef_component_useTask_IpU82pM3MjU", [
18
- props
19
- ]));
20
13
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
21
14
  children: props.componentRef ? /* @__PURE__ */ qwik._jsxC(state.Wrapper, {
22
15
  ...componentRef_helpers.getWrapperProps({
@@ -29,7 +22,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
29
22
  isInteractive: props.isInteractive,
30
23
  contextValue: props.context
31
24
  }),
32
- children: (props.blockChildren || []).map((child) => {
25
+ children: props.componentRef ? (props.blockChildren || []).map((child) => {
33
26
  return /* @__PURE__ */ qwik._jsxC(block.Block, {
34
27
  block: child,
35
28
  get context() {
@@ -53,7 +46,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
53
46
  ], "p0.registeredComponents")
54
47
  }
55
48
  }, 3, child.id);
56
- })
49
+ }) : null
57
50
  }, 0, "z6_0") : null
58
51
  }, 1, "z6_1");
59
52
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -1,4 +1,4 @@
1
- import { componentQrl, inlinedQrl, useStore, useTaskQrl, useLexicalScope, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
1
+ import { componentQrl, inlinedQrl, useStore, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
2
2
  import { Fragment } from "@builder.io/qwik/jsx-runtime";
3
3
  import { Block } from "../../block.qwik.mjs";
4
4
  import { InteractiveElement } from "../interactive-element.qwik.mjs";
@@ -8,13 +8,6 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
8
8
  Wrapper: props.isInteractive ? InteractiveElement : props.componentRef,
9
9
  shouldUpdate: false
10
10
  });
11
- useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
12
- const [props2] = useLexicalScope();
13
- track(() => props2.componentOptions);
14
- track(() => props2.blockChildren);
15
- }, "ComponentRef_component_useTask_IpU82pM3MjU", [
16
- props
17
- ]));
18
11
  return /* @__PURE__ */ _jsxC(Fragment, {
19
12
  children: props.componentRef ? /* @__PURE__ */ _jsxC(state.Wrapper, {
20
13
  ...getWrapperProps({
@@ -27,7 +20,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
27
20
  isInteractive: props.isInteractive,
28
21
  contextValue: props.context
29
22
  }),
30
- children: (props.blockChildren || []).map((child) => {
23
+ children: props.componentRef ? (props.blockChildren || []).map((child) => {
31
24
  return /* @__PURE__ */ _jsxC(Block, {
32
25
  block: child,
33
26
  get context() {
@@ -51,7 +44,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
51
44
  ], "p0.registeredComponents")
52
45
  }
53
46
  }, 3, child.id);
54
- })
47
+ }) : null
55
48
  }, 0, "z6_0") : null
56
49
  }, 1, "z6_1");
57
50
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -126,11 +126,14 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
126
126
  method: "GET"
127
127
  };
128
128
  logFetch.logFetch(JSON.stringify(fetchRequestObj));
129
- fetch(fetchRequestObj.url, {
129
+ const fetchOptions = {
130
130
  method: fetchRequestObj.method,
131
131
  headers: fetchRequestObj.headers,
132
132
  body: fetchRequestObj.body
133
- }).then((response) => response.json()).then((json) => {
133
+ };
134
+ if (fetchRequestObj.method === "GET")
135
+ delete fetchOptions.body;
136
+ fetch(fetchRequestObj.url, fetchOptions).then((response) => response.json()).then((json) => {
134
137
  mergeNewRootState(props, state, showContentProps, elementRef, {
135
138
  [key]: json
136
139
  });
@@ -171,7 +174,9 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
171
174
  clicked: false,
172
175
  hasExecuted: false,
173
176
  httpReqsData: {},
174
- httpReqsPending: {}
177
+ httpReqsPending: {},
178
+ prevData: null,
179
+ prevLocale: ""
175
180
  }, {
176
181
  deep: true
177
182
  });
@@ -305,8 +310,12 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
305
310
  qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(({ track }) => {
306
311
  const [elementRef2, props2, showContentProps2, state2] = qwik.useLexicalScope();
307
312
  track(() => props2.data);
308
- if (props2.data)
313
+ if (props2.data) {
314
+ if (state2.prevData === props2.data)
315
+ return;
309
316
  mergeNewRootState(props2, state2, showContentProps2, elementRef2, props2.data);
317
+ state2.prevData = props2.data;
318
+ }
310
319
  }, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
311
320
  elementRef,
312
321
  props,
@@ -316,10 +325,14 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
316
325
  qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(({ track }) => {
317
326
  const [elementRef2, props2, showContentProps2, state2] = qwik.useLexicalScope();
318
327
  track(() => props2.locale);
319
- if (props2.locale)
328
+ if (props2.locale) {
329
+ if (state2.prevLocale === props2.locale)
330
+ return;
320
331
  mergeNewRootState(props2, state2, showContentProps2, elementRef2, {
321
332
  locale: props2.locale
322
333
  });
334
+ state2.prevLocale = props2.locale;
335
+ }
323
336
  }, "EnableEditor_component_useTask_4_moHYZG8uNVU", [
324
337
  elementRef,
325
338
  props,
@@ -124,11 +124,14 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
124
124
  method: "GET"
125
125
  };
126
126
  logFetch(JSON.stringify(fetchRequestObj));
127
- fetch(fetchRequestObj.url, {
127
+ const fetchOptions = {
128
128
  method: fetchRequestObj.method,
129
129
  headers: fetchRequestObj.headers,
130
130
  body: fetchRequestObj.body
131
- }).then((response) => response.json()).then((json) => {
131
+ };
132
+ if (fetchRequestObj.method === "GET")
133
+ delete fetchOptions.body;
134
+ fetch(fetchRequestObj.url, fetchOptions).then((response) => response.json()).then((json) => {
132
135
  mergeNewRootState(props, state, showContentProps, elementRef, {
133
136
  [key]: json
134
137
  });
@@ -169,7 +172,9 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
169
172
  clicked: false,
170
173
  hasExecuted: false,
171
174
  httpReqsData: {},
172
- httpReqsPending: {}
175
+ httpReqsPending: {},
176
+ prevData: null,
177
+ prevLocale: ""
173
178
  }, {
174
179
  deep: true
175
180
  });
@@ -303,8 +308,12 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
303
308
  useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
304
309
  const [elementRef2, props2, showContentProps2, state2] = useLexicalScope();
305
310
  track(() => props2.data);
306
- if (props2.data)
311
+ if (props2.data) {
312
+ if (state2.prevData === props2.data)
313
+ return;
307
314
  mergeNewRootState(props2, state2, showContentProps2, elementRef2, props2.data);
315
+ state2.prevData = props2.data;
316
+ }
308
317
  }, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
309
318
  elementRef,
310
319
  props,
@@ -314,10 +323,14 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
314
323
  useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
315
324
  const [elementRef2, props2, showContentProps2, state2] = useLexicalScope();
316
325
  track(() => props2.locale);
317
- if (props2.locale)
326
+ if (props2.locale) {
327
+ if (state2.prevLocale === props2.locale)
328
+ return;
318
329
  mergeNewRootState(props2, state2, showContentProps2, elementRef2, {
319
330
  locale: props2.locale
320
331
  });
332
+ state2.prevLocale = props2.locale;
333
+ }
321
334
  }, "EnableEditor_component_useTask_4_moHYZG8uNVU", [
322
335
  elementRef,
323
336
  props,
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.20.0";
3
+ const SDK_VERSION = "0.21.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.20.0";
1
+ const SDK_VERSION = "0.21.1";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -27,4 +27,17 @@ function register(type, info) {
27
27
  }
28
28
  }
29
29
  }
30
+ function registerAction(action) {
31
+ var _a;
32
+ if (isBrowser.isBrowser()) {
33
+ const actionClone = JSON.parse(JSON.stringify(action));
34
+ if (action.action)
35
+ actionClone.action = action.action.toString();
36
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
37
+ type: "builder.registerAction",
38
+ data: actionClone
39
+ }, "*");
40
+ }
41
+ }
30
42
  exports.register = register;
43
+ exports.registerAction = registerAction;
@@ -25,6 +25,19 @@ function register(type, info) {
25
25
  }
26
26
  }
27
27
  }
28
+ function registerAction(action) {
29
+ var _a;
30
+ if (isBrowser()) {
31
+ const actionClone = JSON.parse(JSON.stringify(action));
32
+ if (action.action)
33
+ actionClone.action = action.action.toString();
34
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
35
+ type: "builder.registerAction",
36
+ data: actionClone
37
+ }, "*");
38
+ }
39
+ }
28
40
  export {
29
- register
41
+ register,
42
+ registerAction
30
43
  };
@@ -38,6 +38,7 @@ exports.isEditing = isEditing.isEditing;
38
38
  exports.isPreviewing = isPreviewing.isPreviewing;
39
39
  exports.createRegisterComponentMessage = registerComponent.createRegisterComponentMessage;
40
40
  exports.register = register.register;
41
+ exports.registerAction = register.registerAction;
41
42
  exports.setEditorSettings = setEditorSettings.setEditorSettings;
42
43
  exports.getBuilderSearchParams = index.getBuilderSearchParams;
43
44
  exports.track = index$1.track;
@@ -13,7 +13,7 @@ import { setClientUserAttributes } from "./helpers/user-attributes.qwik.mjs";
13
13
  import { isEditing } from "./functions/is-editing.qwik.mjs";
14
14
  import { isPreviewing } from "./functions/is-previewing.qwik.mjs";
15
15
  import { createRegisterComponentMessage } from "./functions/register-component.qwik.mjs";
16
- import { register } from "./functions/register.qwik.mjs";
16
+ import { register, registerAction } from "./functions/register.qwik.mjs";
17
17
  import { setEditorSettings } from "./functions/set-editor-settings.qwik.mjs";
18
18
  import { getBuilderSearchParams } from "./functions/get-builder-search-params/index.qwik.mjs";
19
19
  import { track } from "./functions/track/index.qwik.mjs";
@@ -41,6 +41,7 @@ export {
41
41
  isEditing,
42
42
  isPreviewing,
43
43
  register,
44
+ registerAction,
44
45
  setClientUserAttributes,
45
46
  setEditorSettings,
46
47
  subscribeToEditor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.20.0",
3
+ "version": "0.21.1",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,6 +32,7 @@ export type FormProps = BuilderDataProps & BuilderComponentsProp & BuilderLinkCo
32
32
  export type FormState = "unsubmitted" | "sending" | "success" | "error";
33
33
  export declare const mergeNewRootState: (props: any, state: any, formRef: any, newData: Dictionary<any>) => void;
34
34
  export declare const submissionState: (props: any, state: any, formRef: any) => any;
35
+ export declare const errorResponse: (props: any, state: any, formRef: any, response: any) => string;
35
36
  export declare const onSubmit: (props: any, state: any, formRef: any, event: any) => void;
36
37
  export declare const FormComponent: import("@builder.io/qwik").Component<FormProps>;
37
38
  export default FormComponent;
@@ -1,4 +1,4 @@
1
1
  import { SymbolProps } from "./symbol.types";
2
- export declare const setContent: (props: any, state: any, blocksWrapper: any, contentWrapper: any, className: any) => void;
2
+ export declare const setContent: (props: any, state: any, blocksWrapper: any, contentWrapper: any, customComponents: any, className: any) => void;
3
3
  export declare const Symbol: import("@builder.io/qwik").Component<SymbolProps>;
4
4
  export default Symbol;
@@ -1,6 +1,6 @@
1
1
  import type { BuilderContent } from '../../types/builder-content';
2
2
  import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
3
- interface SymbolInfo {
3
+ export interface SymbolInfo {
4
4
  model?: string;
5
5
  entry?: string;
6
6
  data?: any;
@@ -16,4 +16,3 @@ export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, Bu
16
16
  inheritState?: boolean;
17
17
  renderToLiquid?: boolean;
18
18
  }
19
- export {};
@@ -1,5 +1,6 @@
1
1
  import { TabsProps } from "./tabs.types";
2
2
  export declare const activeTabContent: (props: any, state: any, active: number) => any;
3
+ export declare const getTabStyle: (props: any, state: any, index: number) => any;
3
4
  export declare const onClick: (props: any, state: any, index: number) => void;
4
5
  export declare const Tabs: import("@builder.io/qwik").Component<TabsProps>;
5
6
  export default Tabs;
@@ -1,13 +1,3 @@
1
- /**
2
- * Placeholder component to be overridden by specific SDKs.
3
- * Allows to dynamically import components.
4
- */
5
- type AwaiterProps = {
6
- load: () => Promise<any>;
7
- props?: any;
8
- attributes?: any;
9
- fallback?: any;
10
- children?: any;
11
- };
1
+ import { AwaiterProps } from "./awaiter.types";
12
2
  export declare const Awaiter: import("@builder.io/qwik").Component<AwaiterProps>;
13
3
  export default Awaiter;
@@ -0,0 +1,7 @@
1
+ export type AwaiterProps = {
2
+ load: () => Promise<any>;
3
+ props?: any;
4
+ attributes?: any;
5
+ fallback?: any;
6
+ children?: any;
7
+ };
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.20.0";
1
+ export declare const SDK_VERSION = "0.21.1";
@@ -1,5 +1,22 @@
1
1
  import type { BuilderBlock } from '../types/builder-block';
2
2
  import type { DeepPartial } from '../types/deep-partial';
3
+ import type { Input } from '../types/input';
4
+ export interface Action {
5
+ name: string;
6
+ inputs?: readonly Input[];
7
+ returnType?: Input;
8
+ action: (options: Record<string, any>) => string;
9
+ /**
10
+ * Is an action for expression (e.g. calculating a binding like a formula
11
+ * to fill a value based on locale) or a function (e.g. something to trigger
12
+ * on an event like add to cart) or either (e.g. a custom code block)
13
+ */
14
+ kind: 'expression' | 'function' | 'any';
15
+ /**
16
+ * Globally unique ID for an action, e.g. "@builder.io:setState"
17
+ */
18
+ id: string;
19
+ }
3
20
  export interface InsertMenuItem {
4
21
  name: string;
5
22
  icon?: string;
@@ -14,3 +31,4 @@ export interface InsertMenuConfig {
14
31
  }
15
32
  export declare function register(type: 'insertMenu', info: InsertMenuConfig): void;
16
33
  export declare function register(type: string, info: any): void;
34
+ export declare function registerAction(action: Action): void;
@@ -25,7 +25,7 @@ export type { ComponentInfo } from './types/components';
25
25
  export { isEditing } from './functions/is-editing';
26
26
  export { isPreviewing } from './functions/is-previewing';
27
27
  export { createRegisterComponentMessage } from './functions/register-component';
28
- export { register } from './functions/register';
28
+ export { register, registerAction } from './functions/register';
29
29
  export type { InsertMenuConfig, InsertMenuItem } from './functions/register';
30
30
  export { setEditorSettings } from './functions/set-editor-settings';
31
31
  export type { Settings } from './functions/set-editor-settings';