@wix/himalaya-cli 0.1006.0 → 0.1008.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.
@@ -319,6 +319,8 @@ export declare function button(props: {
319
319
  action: ActionShape;
320
320
  style?: string;
321
321
  disabled?: boolean;
322
+ /** #3117 — `$service:`/`$item.` bool binding, OR'd with `disabled`/`loading`. */
323
+ disabledPath?: string;
322
324
  leadingIcon?: string;
323
325
  trailingIcon?: string;
324
326
  loading?: boolean;
@@ -650,11 +650,14 @@ export interface ButtonProps {
650
650
  title: string;
651
651
  action: Action;
652
652
  style?: string;
653
- /** Literal only, NOT bindable: a `"$service:…"` string here fails `validate`, and there is no
654
- * `disabledPath`. To disable from worker state, author two buttons — the live one and a
655
- * `disabled: true` copy — and swap them with complementary `modifiers.hiddenPath` flags
656
- * (e.g. `canSubmit` / `cannotSubmit`); also guard the action so a stray tap is a no-op. */
653
+ /** LITERAL disabled state. A `"$service:…"` string here fails `validate` (the wire type is
654
+ * bool) — bind `disabledPath` instead. */
657
655
  disabled?: boolean;
656
+ /** #3117 — `$service:`/`$item.` binding → a live bool that disables the button while true
657
+ * (e.g. a submit while a request is in flight). Binding-aware. OR'd with `disabled`,
658
+ * `loading` and an enclosing Form's validity: a bound `false` never re-enables a button one
659
+ * of those disabled, and an unresolved binding leaves the literal in charge. */
660
+ disabledPath?: string;
658
661
  /** RFC 0034 — capability enrichments. */
659
662
  leadingIcon?: IconRef;
660
663
  trailingIcon?: IconRef;
@@ -31,14 +31,34 @@ function addToCurrentCart(productId, quantity = 1, options) {
31
31
  }
32
32
  var OWNED_CART_NOT_FOUND = "OWNED_CART_NOT_FOUND";
33
33
  function applicationErrorCode(error) {
34
- const o = error;
35
- if (o && typeof o === "object") {
36
- const structured = o.details?.applicationError?.code ?? o.applicationError?.code ?? o.code;
34
+ if (error && typeof error === "object") {
35
+ const structured = structuredApplicationCode(error);
37
36
  if (typeof structured === "string" && structured) return structured;
38
37
  }
39
- const msg = error instanceof Error ? error.message : String(error ?? "");
40
- const m = /"code"\s*:\s*"([A-Z0-9_]+)"/.exec(msg) ?? /\[([A-Z0-9_]{4,})\]/.exec(msg);
41
- return m ? m[1] : "";
38
+ const message = error?.message;
39
+ const msg = typeof message === "string" ? message : String(error ?? "");
40
+ const body = /^HTTP \d{3}: ([\s\S]*)$/.exec(msg);
41
+ return bodyApplicationCode(body?.[1] ?? msg);
42
+ }
43
+ function structuredApplicationCode(value) {
44
+ const o = value;
45
+ return o && typeof o === "object" ? o.details?.applicationError?.code ?? o.applicationError?.code ?? o.code : void 0;
46
+ }
47
+ var CANONICAL_CUT_BODY = /^\s*\{\s*(?:"message"\s*:\s*"(?:[^"\\]|\\.)*"\s*,\s*)?"details"\s*:\s*\{\s*"applicationError"\s*:\s*\{\s*(?:"[A-Za-z]+"\s*:\s*"(?:[^"\\]|\\.)*"\s*,\s*)*"code"\s*:\s*"([A-Za-z0-9_]+)"/;
48
+ function bodyApplicationCode(body) {
49
+ if (!body) return "";
50
+ let parsed;
51
+ try {
52
+ parsed = JSON.parse(body);
53
+ } catch {
54
+ parsed = void 0;
55
+ }
56
+ if (parsed !== void 0) {
57
+ const structured = structuredApplicationCode(parsed);
58
+ return typeof structured === "string" ? structured : "";
59
+ }
60
+ const m = /^(?:HTTP \d{3} )?\[([A-Z0-9_]{4,})\]/.exec(body) ?? CANONICAL_CUT_BODY.exec(body);
61
+ return m?.[1] ?? "";
42
62
  }
43
63
  function isEmptyCurrentCartError(error) {
44
64
  return applicationErrorCode(error) === OWNED_CART_NOT_FOUND;