@calimero-network/mero-react 11.4.0 → 11.5.0

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/index.cjs CHANGED
@@ -1947,7 +1947,7 @@ var EVERY_UNITS = { s: "second", m: "minute", h: "hour" };
1947
1947
  var INVITED_ONLY = "Only people invited to it can open it";
1948
1948
  var NOT_READABLE = "Calimero can't read it.";
1949
1949
  var TEST_SERVER_ENFORCES = ", as this test server enforces it";
1950
- var CONTROL = { creator: "Only you control it", member: "Only the workspace's owners control it" };
1950
+ var control = (viewer, noun) => "Only you control it" ;
1951
1951
  var MAX_DOC_CHARS = 4e3;
1952
1952
  var WORD_TAIL = 8;
1953
1953
  var ABBREVIATIONS = /* @__PURE__ */ new Set(["e.g", "i.e", "etc", "vs", "cf"]);
@@ -2151,9 +2151,10 @@ function codeLine(card, evidence, signed = true) {
2151
2151
  const fromRelease = `bundle ${chunkRRETZWNI_cjs.shortHash(card.bundle)}, from ${signed ? "the signed release" : "the release as this test server lists it"}`;
2152
2152
  return { text: fromRelease };
2153
2153
  }
2154
- function dataStatements(kind, viewer) {
2155
- if (kind === "verified") return [`${CONTROL[viewer]}.`, `${INVITED_ONLY}.`, NOT_READABLE];
2156
- if (kind === "unsealed") return [`${CONTROL[viewer]}${TEST_SERVER_ENFORCES}`, `${INVITED_ONLY}${TEST_SERVER_ENFORCES}`];
2154
+ function dataStatements(kind, viewer, noun = "workspace") {
2155
+ const CONTROL = control();
2156
+ if (kind === "verified") return [`${CONTROL}.`, `${INVITED_ONLY}.`, NOT_READABLE];
2157
+ if (kind === "unsealed") return [`${CONTROL}${TEST_SERVER_ENFORCES}`, `${INVITED_ONLY}${TEST_SERVER_ENFORCES}`];
2157
2158
  return [];
2158
2159
  }
2159
2160
  var OPEN_GROUP_MAX = 3;
@@ -2275,7 +2276,7 @@ function Diverged({ divergence }) {
2275
2276
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "This node runs different code than the release, so no statement about your data is made here." })
2276
2277
  ] }) });
2277
2278
  }
2278
- function ReviewBody({ review, release, cluster, local }) {
2279
+ function ReviewBody({ review, release, cluster, local, noun }) {
2279
2280
  const { client, state, loaded, retry } = review;
2280
2281
  const view = chunkRRETZWNI_cjs.describeShield(state, { code: null });
2281
2282
  const card = loaded.status === "ready" ? loaded.card : null;
@@ -2284,7 +2285,7 @@ function ReviewBody({ review, release, cluster, local }) {
2284
2285
  const code = card ? codeLine(card, null, sealed) : null;
2285
2286
  const summary = card ? summarize(card, sealed) : [];
2286
2287
  const risks = card ? exceptions(card, sealed) : [];
2287
- const statements = dataStatements(view.kind, "creator");
2288
+ const statements = dataStatements(view.kind, "creator", noun);
2288
2289
  const nodes = client && !local ? `${client.nodes.length} ${client.nodes.length === 1 ? "node" : "nodes"}` : "";
2289
2290
  const unreleased = loaded.status === "none";
2290
2291
  const unknown = unreleased ? "This build has no signed release, so what it can do and what leaves the sealed hardware is not known." : !card ? "What leaves the sealed hardware is not known until the app's details load." : !card.abi ? "This app publishes no action list, so what it makes visible to anyone is not known." : null;
@@ -2292,7 +2293,7 @@ function ReviewBody({ review, release, cluster, local }) {
2292
2293
  loaded.status === "error" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__alert", role: "alert", children: [
2293
2294
  /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
2294
2295
  loaded.message,
2295
- client ? " You can still create the workspace." : ""
2296
+ client ? ` You can still create the ${noun}.` : ""
2296
2297
  ] }),
2297
2298
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn", onClick: retry, children: "Try again" })
2298
2299
  ] }),
@@ -2388,19 +2389,19 @@ function ReviewBody({ review, release, cluster, local }) {
2388
2389
  ] }) })
2389
2390
  ] });
2390
2391
  }
2391
- function WorkspaceReview({ client, cluster, local, release, creating = false, disabled = false, onBack, onCreate }) {
2392
+ function WorkspaceReview({ client, cluster, local, noun = "workspace", release, creating = false, disabled = false, onBack, onCreate }) {
2392
2393
  const heading = react.useRef(null);
2393
2394
  react.useEffect(() => heading.current?.focus(), []);
2394
2395
  const review = useReview(client, release);
2395
2396
  const refused = review.state.status === "refused";
2396
2397
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review", children: [
2397
2398
  /* @__PURE__ */ jsxRuntime.jsx("h2", { ref: heading, tabIndex: -1, className: "mero-cw-review__title", children: "Review before creating" }),
2398
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__lede", children: "Check what this app can do and where it will run before you create the workspace." }),
2399
- /* @__PURE__ */ jsxRuntime.jsx(ReviewBody, { review, release, cluster, local }),
2399
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__lede", children: `Check what this app can do and where it will run before you create the ${noun}.` }),
2400
+ /* @__PURE__ */ jsxRuntime.jsx(ReviewBody, { review, release, cluster, local, noun }),
2400
2401
  refused && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "Create is unavailable: this node did not pass its check." }),
2401
2402
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__buttons", children: [
2402
2403
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn", disabled: creating, onClick: onBack, children: "Back" }),
2403
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn mero-cw-review__btn--primary", disabled: creating || disabled || refused, onClick: onCreate, children: creating ? "Creating\u2026" : "Create workspace" })
2404
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn mero-cw-review__btn--primary", disabled: creating || disabled || refused, onClick: onCreate, children: creating ? "Creating\u2026" : `Create ${noun}` })
2404
2405
  ] })
2405
2406
  ] });
2406
2407
  }
@@ -2613,15 +2614,21 @@ function useCreateWorkspaceResume({ onCreated }) {
2613
2614
  }, [client]);
2614
2615
  return { message };
2615
2616
  }
2616
- var DEFAULT_LABELS = {
2617
- title: "Create workspace",
2618
- subtitle: "Name your workspace, and choose how others in it will see you.",
2619
- nameLabel: "Workspace name",
2620
- namePlaceholder: "",
2621
- selfLabel: "Your name",
2622
- selfPlaceholder: "",
2623
- next: "Continue"
2624
- };
2617
+ var NOUN = "workspace";
2618
+ function wording(labels) {
2619
+ const noun = labels?.noun ?? NOUN;
2620
+ return {
2621
+ noun,
2622
+ title: `Create ${noun}`,
2623
+ subtitle: `Name your ${noun}, and choose how others in it will see you.`,
2624
+ nameLabel: `${noun.charAt(0).toUpperCase()}${noun.slice(1)} name`,
2625
+ namePlaceholder: "",
2626
+ selfLabel: "Your name",
2627
+ selfPlaceholder: "",
2628
+ next: "Continue",
2629
+ ...labels
2630
+ };
2631
+ }
2625
2632
  var subscribeNothing = () => () => void 0;
2626
2633
  var useMounted = () => react.useSyncExternalStore(subscribeNothing, () => true, () => false);
2627
2634
  function ResumeNotice({ onCreated }) {
@@ -2644,8 +2651,8 @@ function CreateWorkspaceDialog({ client, passkey, ...props }) {
2644
2651
  const inner = /* @__PURE__ */ jsxRuntime.jsx(Dialog, { ...props });
2645
2652
  return client ? /* @__PURE__ */ jsxRuntime.jsx(MeroProvider, { client, sessionStore, passkey, children: inner }) : inner;
2646
2653
  }
2647
- function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSelfName = "", cluster }) {
2648
- const text = { ...DEFAULT_LABELS, ...labels };
2654
+ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSelfName = "", cluster, fields, fieldsValid = true }) {
2655
+ const text = wording(labels);
2649
2656
  const { client, cluster: ambientCluster, nodeUrl } = useMero();
2650
2657
  const flow = useCreateWorkspace({ returnTo: returnTo ?? `${typeof window === "undefined" ? "" : window.location.origin}/`, onCreated });
2651
2658
  const [step, setStep] = react.useState("names");
@@ -2684,7 +2691,7 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
2684
2691
  {
2685
2692
  onSubmit: (e) => {
2686
2693
  e.preventDefault();
2687
- if (trimmed.name && trimmed.self) setStep("review");
2694
+ if (trimmed.name && trimmed.self && fieldsValid) setStep("review");
2688
2695
  },
2689
2696
  children: [
2690
2697
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: text.title }),
@@ -2697,7 +2704,8 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
2697
2704
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ids[1], children: text.selfLabel }),
2698
2705
  /* @__PURE__ */ jsxRuntime.jsx("input", { id: ids[1], value: selfName, placeholder: text.selfPlaceholder, onChange: (e) => setSelfName(e.target.value) })
2699
2706
  ] }),
2700
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full", disabled: !trimmed.name || !trimmed.self, children: text.next })
2707
+ fields,
2708
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full", disabled: !trimmed.name || !trimmed.self || !fieldsValid, children: text.next })
2701
2709
  ]
2702
2710
  }
2703
2711
  ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -2708,6 +2716,7 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
2708
2716
  client,
2709
2717
  cluster: where,
2710
2718
  local: !!node && clusterName(node) === "merod local",
2719
+ noun: text.noun,
2711
2720
  release,
2712
2721
  creating: flow.phase === "creating",
2713
2722
  disabled: !flow.ready,