@niscorp/loom 0.2.0 → 0.2.2

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 (37) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/DESIGN.md +38 -8
  3. package/README.md +28 -5
  4. package/dist/{chunk-LWY5TG7M.js → chunk-IZ5B6IMX.js} +7 -3
  5. package/dist/chunk-IZ5B6IMX.js.map +1 -0
  6. package/dist/{chunk-X7PCPONB.js → chunk-TCCN6LKV.js} +6 -4
  7. package/dist/chunk-TCCN6LKV.js.map +1 -0
  8. package/dist/index.cjs +4 -2
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +2 -2
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +1 -1
  13. package/dist/{loom-editor-D5SBQ4_F.d.ts → loom-editor-Clohg49u.d.ts} +1 -1
  14. package/dist/{loom-editor-CQ_GI4IA.d.cts → loom-editor-MACwUjLC.d.cts} +1 -1
  15. package/dist/plugins/nova/index.d.cts +1 -1
  16. package/dist/plugins/nova/index.d.ts +1 -1
  17. package/dist/plugins/nova/react/index.d.cts +2 -2
  18. package/dist/plugins/nova/react/index.d.ts +2 -2
  19. package/dist/plugins/prism/index.d.cts +1 -1
  20. package/dist/plugins/prism/index.d.ts +1 -1
  21. package/dist/plugins/prism/react/index.d.cts +2 -2
  22. package/dist/plugins/prism/react/index.d.ts +2 -2
  23. package/dist/plugins/vex/index.d.cts +1 -1
  24. package/dist/plugins/vex/index.d.ts +1 -1
  25. package/dist/plugins/vex/react/index.d.cts +2 -2
  26. package/dist/plugins/vex/react/index.d.ts +2 -2
  27. package/dist/plugins/vex/react/index.js +1 -1
  28. package/dist/react/index.cjs +9 -3
  29. package/dist/react/index.cjs.map +1 -1
  30. package/dist/react/index.d.cts +3 -3
  31. package/dist/react/index.d.ts +3 -3
  32. package/dist/react/index.js +3 -3
  33. package/dist/{types-BonjN3CB.d.cts → types-l8sDxrMR.d.cts} +5 -1
  34. package/dist/{types-BonjN3CB.d.ts → types-l8sDxrMR.d.ts} +5 -1
  35. package/package.json +9 -8
  36. package/dist/chunk-LWY5TG7M.js.map +0 -1
  37. package/dist/chunk-X7PCPONB.js.map +0 -1
@@ -556,7 +556,8 @@ var createLoomEditor = (config) => {
556
556
  const ir = parse(document);
557
557
  const wrap = needsWrap(document);
558
558
  if (wrap) wrappedDocs.add(name);
559
- const value = artifact.documents?.[name] ?? buildDocument(ir, {});
559
+ const seed = artifact.documents?.[name];
560
+ const value = seed ?? buildDocument(ir, {});
560
561
  const built = toNova(ir, {
561
562
  id: canvasId,
562
563
  ...wrap ? { rootKey: ROOT_KEY } : {},
@@ -564,7 +565,8 @@ var createLoomEditor = (config) => {
564
565
  widgets: plugin.widgets ?? []
565
566
  });
566
567
  for (const [id, node] of Object.entries(built.layouts)) store.set(id, node);
567
- action = built.action;
568
+ const seedsRoot = wrap && seed !== void 0 && seed !== null && !isRecord(seed) && document.safeParse(seed).success;
569
+ action = seedsRoot ? { ...built.action, data: { [ROOT_KEY]: seed } } : built.action;
568
570
  }
569
571
  shell.registerAction(action);
570
572
  shell.addCanvas({ id: canvasId, initial: action.id });
@@ -754,7 +756,11 @@ var LoomCheckbox = ({ value, novaModel }) => {
754
756
  };
755
757
  var LoomSelect = ({ value, options, novaModel }) => {
756
758
  const set = useModelWrite(novaModel);
757
- return /* @__PURE__ */ jsxRuntime.jsx("select", { value: String(value ?? ""), onChange: (event) => set(event.target.value), style: inputStyle, children: (options ?? []).map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: String(option.value), children: option.label }, String(option.value))) });
759
+ const choose = (text) => {
760
+ const chosen = (options ?? []).find((option) => String(option.value) === text);
761
+ set(chosen === void 0 ? text : chosen.value);
762
+ };
763
+ return /* @__PURE__ */ jsxRuntime.jsx("select", { value: String(value ?? ""), onChange: (event) => choose(event.target.value), style: inputStyle, children: (options ?? []).map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: String(option.value), children: option.label }, String(option.value))) });
758
764
  };
759
765
  var LoomRaw = ({ value, novaModel }) => {
760
766
  const set = useModelWrite(novaModel);