@makeswift/runtime 0.0.8 → 0.0.11

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 (36) hide show
  1. package/dist/builder.cjs.js +2 -0
  2. package/dist/builder.cjs.js.map +1 -1
  3. package/dist/builder.es.js +1 -1
  4. package/dist/components.cjs.js +1 -0
  5. package/dist/components.cjs.js.map +1 -1
  6. package/dist/components.es.js +1 -0
  7. package/dist/components.es.js.map +1 -1
  8. package/dist/control-serialization.cjs.js +11 -3
  9. package/dist/control-serialization.cjs.js.map +1 -1
  10. package/dist/control-serialization.es.js +10 -4
  11. package/dist/control-serialization.es.js.map +1 -1
  12. package/dist/index.cjs.js +34 -23
  13. package/dist/index.cjs.js.map +1 -1
  14. package/dist/index.es.js +34 -23
  15. package/dist/index.es.js.map +1 -1
  16. package/dist/next.cjs.js +1 -0
  17. package/dist/next.cjs.js.map +1 -1
  18. package/dist/next.es.js +1 -0
  19. package/dist/next.es.js.map +1 -1
  20. package/dist/react-builder-preview.es.js +1 -1
  21. package/dist/react.cjs.js +1 -0
  22. package/dist/react.cjs.js.map +1 -1
  23. package/dist/react.es.js +1 -0
  24. package/dist/react.es.js.map +1 -1
  25. package/dist/text-input.cjs.js.map +1 -1
  26. package/dist/text-input.es.js.map +1 -1
  27. package/dist/types/builder/serialization/control-serialization.d.ts +2 -0
  28. package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
  29. package/dist/types/builder/serialization/controls/list.d.ts.map +1 -1
  30. package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
  31. package/dist/types/components/builtin/Text/Text.d.ts.map +1 -1
  32. package/dist/types/controls/shape.d.ts +0 -1
  33. package/dist/types/controls/shape.d.ts.map +1 -1
  34. package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
  35. package/dist/types/runtimes/react/index.d.ts.map +1 -1
  36. package/package.json +3 -1
package/dist/index.es.js CHANGED
@@ -62,6 +62,7 @@ import { normalize } from "polished";
62
62
  import ReactPlayer from "react-player";
63
63
  import Hotkeys from "slate-hotkeys";
64
64
  import ipsum from "corporate-ipsum";
65
+ import { isHotkey } from "is-hotkey";
65
66
  import { Editor } from "slate-react";
66
67
  import Lists from "@convertkit/slate-lists";
67
68
  import { S as ShapeControlType, I as ImageControlType, C as ColorControlType, a as SelectControlType, T as TextAreaControlType, b as TextInputControlType, N as NumberControlType, c as CheckboxControlType } from "./text-input.es.js";
@@ -2135,7 +2136,8 @@ const Button$1 = forwardRef(function Button2(_m, ref) {
2135
2136
  color,
2136
2137
  textStyle,
2137
2138
  width,
2138
- margin
2139
+ margin,
2140
+ className
2139
2141
  } = _n, restOfProps = __objRest(_n, [
2140
2142
  "id",
2141
2143
  "children",
@@ -2147,12 +2149,13 @@ const Button$1 = forwardRef(function Button2(_m, ref) {
2147
2149
  "color",
2148
2150
  "textStyle",
2149
2151
  "width",
2150
- "margin"
2152
+ "margin",
2153
+ "className"
2151
2154
  ]);
2152
2155
  return /* @__PURE__ */ jsx(StyledButton$1, __spreadProps(__spreadValues({}, restOfProps), {
2153
2156
  ref,
2154
2157
  id,
2155
- className: cx(css$1(responsiveWidth(width, "auto"))),
2158
+ className: cx(css$1(responsiveWidth(width, "auto")), className),
2156
2159
  color,
2157
2160
  link,
2158
2161
  margin,
@@ -7578,7 +7581,7 @@ const Text = forwardRef(function Text2({
7578
7581
  (_a = lastController.current) == null ? void 0 : _a.focus();
7579
7582
  }, []);
7580
7583
  const handleKeyDown = useCallback((event, _editor, next) => {
7581
- var _a, _b;
7584
+ var _a, _b, _c;
7582
7585
  if (Hotkeys.isUndo(event)) {
7583
7586
  (_a = lastController.current) == null ? void 0 : _a.undo();
7584
7587
  return true;
@@ -7587,6 +7590,10 @@ const Text = forwardRef(function Text2({
7587
7590
  (_b = lastController.current) == null ? void 0 : _b.redo();
7588
7591
  return true;
7589
7592
  }
7593
+ if (isHotkey("escape")(event)) {
7594
+ (_c = lastController.current) == null ? void 0 : _c.blur();
7595
+ return true;
7596
+ }
7590
7597
  return next();
7591
7598
  }, []);
7592
7599
  const isInBuilder = useIsInBuilder();
@@ -7599,7 +7606,8 @@ const Text = forwardRef(function Text2({
7599
7606
  value,
7600
7607
  onChange: handleChange,
7601
7608
  onFocus: handleFocus,
7602
- onKeyDown: handleKeyDown
7609
+ onKeyDown: handleKeyDown,
7610
+ onBlur: (e) => e.preventDefault()
7603
7611
  });
7604
7612
  });
7605
7613
  function registerComponent$1(runtime) {
@@ -8169,7 +8177,8 @@ function useStyleControlCssObject(style, controlDefinition) {
8169
8177
  return `${borderRadius.value}${borderRadius.unit}`;
8170
8178
  }
8171
8179
  }
8172
- const useInsertionEffect = (_ea = React["useInsertionEffect"]) != null ? _ea : React.useLayoutEffect;
8180
+ const useInsertionEffectSpecifier = "useInsertionEffect";
8181
+ const useInsertionEffect = (_ea = React[useInsertionEffectSpecifier]) != null ? _ea : React.useLayoutEffect;
8173
8182
  function useFormattedStyle(styleControlData, controlDefinition) {
8174
8183
  const style = useStyleControlCssObject(styleControlData, controlDefinition);
8175
8184
  const serialized = serializeStyles([style], cache.registered);
@@ -8235,7 +8244,7 @@ function ShapeControlValue({
8235
8244
  data,
8236
8245
  children
8237
8246
  }) {
8238
- return Object.entries(definition.config.type).reduce((renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ jsx(ControlValue, {
8247
+ return Object.entries(definition.config.type).reduceRight((renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ jsx(ControlValue, {
8239
8248
  definition: controlDefinition,
8240
8249
  data: data == null ? void 0 : data[key],
8241
8250
  children: (value) => renderFn(__spreadProps(__spreadValues({}, shapeControlValue), {
@@ -8381,11 +8390,9 @@ function PropsValue({
8381
8390
  function suppressWarningAndFindDomNode(instance) {
8382
8391
  const error = console.error;
8383
8392
  console.error = (...args) => {
8384
- const [msg, ...substitutions] = args;
8385
- const text = substitutions.reduce((text2, substitution) => text2.replace("%s", substitution), msg);
8386
- if (!text.includes("findDOMNode is deprecated in StrictMode.")) {
8387
- error.apply(console, args);
8388
- }
8393
+ if (typeof args[0] === "string" && args[0].includes("%s is deprecated in StrictMode."))
8394
+ return;
8395
+ return error.apply(console, args);
8389
8396
  };
8390
8397
  const foundDomNode = findDOMNode(instance);
8391
8398
  console.error = error;
@@ -8543,11 +8550,10 @@ function useSuppressRefWarning(ownerName) {
8543
8550
  const patchedRef = useRef(false);
8544
8551
  if (patchedRef.current === false) {
8545
8552
  console.error = (...args) => {
8546
- const [msg, ...substitutions] = args;
8547
- const text = substitutions.reduce((text2, substitution) => text2.replace("%s", substitution), msg);
8548
- if (!text.includes("Function components cannot be given refs.") || !text.includes(`Check the render method of \`${ownerName}\`.`)) {
8549
- originalErrorRef.current(...args);
8553
+ if (typeof args[0] === "string" && args[0].includes("Function components cannot be given refs.") && args[0].includes(`Check the render method of \`${ownerName}\`.`)) {
8554
+ return;
8550
8555
  }
8556
+ return originalErrorRef.current(...args);
8551
8557
  };
8552
8558
  patchedRef.current = true;
8553
8559
  }
@@ -8577,6 +8583,7 @@ const ElementData = memo(forwardRef(function ElementData2({
8577
8583
  })
8578
8584
  });
8579
8585
  }));
8586
+ const DisableRegisterElement = createContext(false);
8580
8587
  const ElementReference = memo(forwardRef(function ElementReference2({
8581
8588
  elementReference
8582
8589
  }, ref) {
@@ -8613,9 +8620,12 @@ const ElementReference = memo(forwardRef(function ElementReference2({
8613
8620
  return elementReferenceDocument != null ? /* @__PURE__ */ jsx(Document, {
8614
8621
  document: elementReferenceDocument,
8615
8622
  ref
8616
- }) : /* @__PURE__ */ jsx(ElementData, {
8617
- elementData: globalElementData,
8618
- ref
8623
+ }) : /* @__PURE__ */ jsx(DisableRegisterElement.Provider, {
8624
+ value: true,
8625
+ children: /* @__PURE__ */ jsx(ElementData, {
8626
+ elementData: globalElementData,
8627
+ ref
8628
+ })
8619
8629
  });
8620
8630
  }));
8621
8631
  const Element$1 = memo(forwardRef(function Element2({
@@ -8625,17 +8635,18 @@ const Element$1 = memo(forwardRef(function Element2({
8625
8635
  const dispatch = useDispatch();
8626
8636
  const documentKey = useDocumentKey();
8627
8637
  const [handle, setHandle] = useState(null);
8638
+ const isRegisterElementDisabled = useContext(DisableRegisterElement);
8628
8639
  useImperativeHandle(ref, () => handle, [handle]);
8629
8640
  useEffect(() => {
8630
- if (documentKey == null)
8641
+ if (documentKey == null || isRegisterElementDisabled)
8631
8642
  return;
8632
8643
  return dispatch(registerComponentHandleEffect(documentKey, elementKey, handle));
8633
- }, [dispatch, documentKey, elementKey, handle]);
8644
+ }, [dispatch, documentKey, elementKey, handle, isRegisterElementDisabled]);
8634
8645
  useEffect(() => {
8635
- if (documentKey == null)
8646
+ if (documentKey == null || isRegisterElementDisabled)
8636
8647
  return;
8637
8648
  return dispatch(mountComponentEffect(documentKey, elementKey));
8638
- }, [dispatch, documentKey, elementKey]);
8649
+ }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
8639
8650
  return isElementReference(element) ? /* @__PURE__ */ jsx(ElementReference, {
8640
8651
  ref: setHandle,
8641
8652
  elementReference: element