@commercelayer/app-elements 5.7.0 → 6.0.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.
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { u as Pe, j as le, I as Se } from "./main-BqlK85T7.js";
2
+ import { u as Pe, j as le, I as Se } from "./main-BANV9Udl.js";
3
3
  import R, { memo as oe, useState as V, useEffect as S, useRef as v, useCallback as ie, forwardRef as Ce } from "react";
4
4
  import { f as Ee } from "./fetchCoreResourcesSuggestions-DLZhtrDX.js";
5
5
  function Ie(e, t, r) {
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import { c as X, t as _, m as fr, a as hr, w as he, x as fe, y as dt, z as We, A as mr, E as Ur, F as Vr, G as rt, H as vr, J as qr, K as Dr, L as gr, M as jr, N as $r, O as Lt, P as Gr, Q as zr, R as Ft, S as Xr, T as Re, U as Zr, j as te, V as z, W as Pe, X as be, o as wt, Y as xt, Z as yr, _ as Et, $ as wr, a0 as Jr, a1 as xe, a2 as At, a3 as en, a4 as tn, a5 as rn, a6 as nn, a7 as nt, a8 as an, I as on, v as sn, a9 as ln, aa as cn, ab as un } from "./main-BqlK85T7.js";
2
+ import { c as X, t as _, m as fr, a as hr, w as he, x as fe, y as dt, z as We, A as mr, E as Ur, F as Vr, G as rt, H as vr, J as qr, K as Dr, L as gr, M as jr, N as $r, O as Lt, P as Gr, Q as zr, R as Ft, S as Xr, T as Re, U as Zr, j as te, V as z, W as Pe, X as be, o as wt, Y as xt, Z as yr, _ as Et, $ as wr, a0 as Jr, a1 as xe, a2 as At, a3 as en, a4 as tn, a5 as rn, a6 as nn, a7 as nt, a8 as an, I as on, v as sn, a9 as ln, aa as cn, ab as un } from "./main-BANV9Udl.js";
3
3
  import * as b from "react";
4
4
  import f, { useLayoutEffect as br, useEffect as Pt, cloneElement as _r, createRef as Me, Component as $, useRef as bt, useCallback as dn, createElement as pn, forwardRef as fn, useMemo as hn } from "react";
5
5
  import * as mn from "react-dom";
6
6
  import vn from "react-dom";
7
- import { p as Dn } from "./parseISO-B-bk2SyC.js";
7
+ import { p as Dn } from "./parseISO-8P5gMU86.js";
8
8
  function kr(o, r, t) {
9
9
  return X(o, +_(o) + r);
10
10
  }
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { t as S, b as H, d as Z, j as e, i as V, g as G, e as Q, f, h as y, k as $, D as z, l as R, n as p, B as J, o as w, p as U, u as P, q as ee, r as te, s as ne, v as _, I as ae, C as le } from "./main-BqlK85T7.js";
2
+ import { t as S, b as H, d as Z, j as e, i as V, g as G, e as Q, f, h as y, k as $, D as z, l as R, n as p, B as J, o as w, p as U, u as P, q as ee, r as te, s as ne, v as _, I as ae, C as le } from "./main-BANV9Udl.js";
3
3
  import I, { useReducer as se, useCallback as N, useMemo as re, createContext as ie, useContext as ue, useState as g, useEffect as v, useRef as ce } from "react";
4
4
  import "react-hook-form";
5
5
  import { a as oe } from "./fetchCoreResourcesSuggestions-DLZhtrDX.js";
6
- import { p as k } from "./parseISO-B-bk2SyC.js";
6
+ import { p as k } from "./parseISO-8P5gMU86.js";
7
7
  function A(t, n) {
8
8
  const a = t.match(
9
9
  /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
@@ -98,7 +98,7 @@ function me({
98
98
  );
99
99
  return /* @__PURE__ */ e.jsx(K.Provider, { value: i, children: t });
100
100
  }
101
- function x() {
101
+ function h() {
102
102
  const t = ue(K);
103
103
  if (t === void 0)
104
104
  throw new Error("useRuleEngine must be used within a RuleEngineProvider");
@@ -117,7 +117,7 @@ function fe({
117
117
  item: t,
118
118
  pathPrefix: n
119
119
  }) {
120
- const { setPath: a } = x();
120
+ const { setPath: a } = h();
121
121
  if (t == null)
122
122
  return null;
123
123
  switch (t.type) {
@@ -237,7 +237,7 @@ function ge({
237
237
  const {
238
238
  setPath: r,
239
239
  state: { selectedRuleIndex: u }
240
- } = x(), s = {
240
+ } = h(), s = {
241
241
  percentage: "Percentage discount",
242
242
  fixed_amount: "Fixed amount",
243
243
  fixed_price: "Fixed price",
@@ -245,7 +245,7 @@ function ge({
245
245
  every_x_discount_y: "Every X, Discount Y"
246
246
  }, l = `rules.${u}.actions.${n}`;
247
247
  return /* @__PURE__ */ e.jsx("div", { className: "mb-4 last:mb-0", children: /* @__PURE__ */ e.jsxs("div", { className: "bg-gray-50 rounded-md flex items-center", children: [
248
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 flex-grow p-2", children: [
248
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 grow p-2", children: [
249
249
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
250
250
  y,
251
251
  {
@@ -284,7 +284,7 @@ function ge({
284
284
  "button",
285
285
  {
286
286
  type: "button",
287
- className: "flex items-center justify-center self-stretch flex-grow",
287
+ className: "flex items-center justify-center self-stretch grow",
288
288
  children: /* @__PURE__ */ e.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" })
289
289
  }
290
290
  ),
@@ -301,13 +301,13 @@ function ge({
301
301
  )
302
302
  ] }) });
303
303
  }
304
- function xe({
304
+ function he({
305
305
  actions: t
306
306
  }) {
307
307
  const [n, a] = g(0), {
308
308
  setPath: r,
309
309
  state: { selectedRuleIndex: u }
310
- } = x();
310
+ } = h();
311
311
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
312
312
  /* @__PURE__ */ e.jsx("div", { children: t?.map((s, l, i) => /* @__PURE__ */ e.jsx(
313
313
  ge,
@@ -365,11 +365,11 @@ function Y(t) {
365
365
  }
366
366
  return "string";
367
367
  }
368
- function he({
368
+ function xe({
369
369
  item: t,
370
370
  pathPrefix: n
371
371
  }) {
372
- const { setPath: a } = x(), { infos: r } = X(t);
372
+ const { setPath: a } = h(), { infos: r } = X(t);
373
373
  let u = r?.field?.type;
374
374
  return u == null && (u = Y(t?.value)), /* @__PURE__ */ e.jsx(
375
375
  y,
@@ -669,11 +669,11 @@ function be({
669
669
  defaultValue: n,
670
670
  pathPrefix: a
671
671
  }) {
672
- const [r, u] = g(t), [s, l] = g(t), [i, o] = g(n), { setPath: c } = x();
672
+ const [r, u] = g(t), [s, l] = g(t), [i, o] = g(n), { setPath: c } = h();
673
673
  return v(() => {
674
674
  r !== s && (c(`${a}.${r}`, null), u(s)), c(`${a}.${s}`, i);
675
675
  }, [s, i, c]), /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
676
- /* @__PURE__ */ e.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ e.jsx(
676
+ /* @__PURE__ */ e.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ e.jsx(
677
677
  y,
678
678
  {
679
679
  defaultValue: [
@@ -690,7 +690,7 @@ function be({
690
690
  }
691
691
  }
692
692
  ) }),
693
- /* @__PURE__ */ e.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ e.jsx(
693
+ /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
694
694
  y,
695
695
  {
696
696
  isMulti: !0,
@@ -721,7 +721,7 @@ function ye({
721
721
  Array.isArray(t) && typeof t[1] == "number" ? t[1] : null
722
722
  );
723
723
  return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
724
- /* @__PURE__ */ e.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ e.jsx(
724
+ /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
725
725
  f,
726
726
  {
727
727
  type: "number",
@@ -734,7 +734,7 @@ function ye({
734
734
  }
735
735
  ) }),
736
736
  /* @__PURE__ */ e.jsx("span", { className: "text-gray-300", children: "to" }),
737
- /* @__PURE__ */ e.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ e.jsx(
737
+ /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
738
738
  f,
739
739
  {
740
740
  type: "number",
@@ -758,7 +758,7 @@ function ve({
758
758
  Array.isArray(t) && typeof t[1] == "string" ? t[1] : null
759
759
  );
760
760
  return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
761
- /* @__PURE__ */ e.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ e.jsx(
761
+ /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
762
762
  f,
763
763
  {
764
764
  type: "text",
@@ -771,7 +771,7 @@ function ve({
771
771
  }
772
772
  ) }),
773
773
  /* @__PURE__ */ e.jsx("span", { className: "text-gray-300", children: "to" }),
774
- /* @__PURE__ */ e.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ e.jsx(
774
+ /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
775
775
  f,
776
776
  {
777
777
  type: "text",
@@ -789,7 +789,7 @@ function je({
789
789
  item: t,
790
790
  pathPrefix: n
791
791
  }) {
792
- const { setPath: a } = x(), { infos: r } = X(t), { user: u } = P(), s = `${n}.value`;
792
+ const { setPath: a } = h(), { infos: r } = X(t), { user: u } = P(), s = `${n}.value`;
793
793
  if (t == null || W.includes(
794
794
  t.matcher
795
795
  ))
@@ -1013,7 +1013,7 @@ function Ne({
1013
1013
  pathPrefix: a,
1014
1014
  onDelete: r
1015
1015
  }) {
1016
- const { setPath: u } = x(), s = [];
1016
+ const { setPath: u } = h(), s = [];
1017
1017
  return n < 2 && (s[0] ??= [], s[0].push(
1018
1018
  /* @__PURE__ */ e.jsx(
1019
1019
  R,
@@ -1038,7 +1038,7 @@ function Ne({
1038
1038
  }
1039
1039
  )
1040
1040
  )), /* @__PURE__ */ e.jsxs("div", { className: "bg-gray-50 rounded-md flex items-center", children: [
1041
- /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-between gap-2 flex-grow p-2", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-2 flex-grow", children: [
1041
+ /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-between gap-2 grow p-2", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-2 grow", children: [
1042
1042
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1043
1043
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
1044
1044
  f,
@@ -1054,7 +1054,7 @@ function Ne({
1054
1054
  }
1055
1055
  }
1056
1056
  ) }),
1057
- /* @__PURE__ */ e.jsx("div", { className: "flex-14", children: /* @__PURE__ */ e.jsx(he, { item: t, pathPrefix: a }) })
1057
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(xe, { item: t, pathPrefix: a }) })
1058
1058
  ] }),
1059
1059
  /* @__PURE__ */ e.jsx(je, { item: t, pathPrefix: a })
1060
1060
  ] }) }),
@@ -1066,7 +1066,7 @@ function Ne({
1066
1066
  "button",
1067
1067
  {
1068
1068
  type: "button",
1069
- className: "flex items-center justify-center self-stretch flex-grow",
1069
+ className: "flex items-center justify-center self-stretch grow",
1070
1070
  children: /* @__PURE__ */ e.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" })
1071
1071
  }
1072
1072
  ),
@@ -1092,7 +1092,7 @@ function B({
1092
1092
  }) {
1093
1093
  const {
1094
1094
  state: { selectedRuleIndex: u }
1095
- } = x(), s = t?.conditions_logic?.toLowerCase() ?? "and", { setPath: l } = x(), [i, o] = g(0), c = a > 0;
1095
+ } = h(), s = t?.conditions_logic?.toLowerCase() ?? "and", { setPath: l } = h(), [i, o] = g(0), c = a > 0;
1096
1096
  return /* @__PURE__ */ e.jsxs(
1097
1097
  "div",
1098
1098
  {
@@ -1112,7 +1112,7 @@ function B({
1112
1112
  );
1113
1113
  },
1114
1114
  defaultValue: s,
1115
- className: "pl-4 pr-8 py-2 font-bold focus:ring-0 focus:outline-none appearance-none bg-gray-50 border border-gray-200 rounded-md text-sm leading-4",
1115
+ className: "pl-4 pr-8 py-2 font-bold focus:ring-0 focus:outline-hidden appearance-none bg-gray-50 border border-gray-200 rounded-md text-sm leading-4",
1116
1116
  children: [
1117
1117
  /* @__PURE__ */ e.jsxs("option", { value: "and", children: [
1118
1118
  c ? "Nested in " : "",
@@ -1152,7 +1152,7 @@ function B({
1152
1152
  nestingLevel: a,
1153
1153
  pathPrefix: `${r}.conditions.${m}`,
1154
1154
  onDelete: j.length > 1 || a > 0 ? () => {
1155
- o((h) => h + 1);
1155
+ o((x) => x + 1);
1156
1156
  } : void 0
1157
1157
  }
1158
1158
  )
@@ -1174,15 +1174,15 @@ function we({
1174
1174
  rounded: t = !1
1175
1175
  }) {
1176
1176
  return t ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1177
- /* @__PURE__ */ e.jsx("div", { className: "absolute -left-[1px] top-1/2 w-px h-1/2 bg-white" }),
1178
- /* @__PURE__ */ e.jsx("div", { className: "absolute -left-[1px] top-1/2 -translate-y-1/2 w-3.5 h-3.5 border-l border-b rounded-es-sm bg-white border-gray-200" })
1177
+ /* @__PURE__ */ e.jsx("div", { className: "absolute -left-px top-1/2 w-px h-1/2 bg-white" }),
1178
+ /* @__PURE__ */ e.jsx("div", { className: "absolute -left-px top-1/2 -translate-y-1/2 w-3.5 h-3.5 border-l border-b rounded-es-sm bg-white border-gray-200" })
1179
1179
  ] }) : /* @__PURE__ */ e.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-3.5 h-px bg-gray-200" });
1180
1180
  }
1181
1181
  function _e() {
1182
1182
  const {
1183
1183
  setPath: t,
1184
1184
  state: { value: n, selectedRuleIndex: a }
1185
- } = x(), [r, u] = g(
1185
+ } = h(), [r, u] = g(
1186
1186
  n.rules[a]?.name ?? ""
1187
1187
  );
1188
1188
  return v(() => {
@@ -1241,7 +1241,7 @@ function $e(t) {
1241
1241
  setSelectedRuleIndex: r,
1242
1242
  setValue: u,
1243
1243
  setPath: s
1244
- } = x(), [l, i] = g(
1244
+ } = h(), [l, i] = g(
1245
1245
  t.defaultCodeEditorVisible ?? !1
1246
1246
  ), o = n.rules[a], c = ce(null), [d, m] = g(0);
1247
1247
  v(
@@ -1252,8 +1252,8 @@ function $e(t) {
1252
1252
  );
1253
1253
  const j = N(
1254
1254
  (b) => {
1255
- const h = T(b);
1256
- c.current?.hasTextFocus() && Te(b) && !V(h, n) && (u(h), m((C) => C + 1));
1255
+ const x = T(b);
1256
+ c.current?.hasTextFocus() && Te(b) && !V(x, n) && (u(x), m((C) => C + 1));
1257
1257
  },
1258
1258
  [n]
1259
1259
  );
@@ -1271,17 +1271,17 @@ function $e(t) {
1271
1271
  children: [
1272
1272
  /* @__PURE__ */ e.jsxs("header", { className: "w-full bg-white border-b border-gray-200 py-3 px-8 flex text-[13px] gap-4 text-gray-400 font-semibold items-center", children: [
1273
1273
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4 flex-wrap", children: [
1274
- n.rules.map((b, h) => {
1275
- const C = `#${(h + 1).toString().padStart(2, "0")}`;
1274
+ n.rules.map((b, x) => {
1275
+ const C = `#${(x + 1).toString().padStart(2, "0")}`;
1276
1276
  return /* @__PURE__ */ e.jsx(
1277
1277
  "button",
1278
1278
  {
1279
1279
  type: "button",
1280
1280
  className: _("font-bold", {
1281
- "text-black": a === h
1281
+ "text-black": a === x
1282
1282
  }),
1283
1283
  onClick: () => {
1284
- r(h);
1284
+ r(x);
1285
1285
  },
1286
1286
  children: C
1287
1287
  },
@@ -1306,11 +1306,11 @@ function $e(t) {
1306
1306
  }
1307
1307
  )
1308
1308
  ] }),
1309
- /* @__PURE__ */ e.jsx("div", { className: "flex-grow flex justify-end", children: /* @__PURE__ */ e.jsx(
1309
+ /* @__PURE__ */ e.jsx("div", { className: "grow flex justify-end", children: /* @__PURE__ */ e.jsx(
1310
1310
  "button",
1311
1311
  {
1312
1312
  type: "button",
1313
- className: "text-blue-600 hover:text-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500",
1313
+ className: "text-blue-600 hover:text-blue-700 focus:outline-hidden focus:ring-2 focus:ring-blue-500",
1314
1314
  onClick: () => {
1315
1315
  i(!l);
1316
1316
  },
@@ -1323,7 +1323,7 @@ function $e(t) {
1323
1323
  /* @__PURE__ */ e.jsx(_e, {}),
1324
1324
  /* @__PURE__ */ e.jsx(p, { name: "pencilSimple", size: 16, className: "shrink-0" })
1325
1325
  ] }),
1326
- /* @__PURE__ */ e.jsx(L, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ e.jsx(xe, { actions: o?.actions }) }),
1326
+ /* @__PURE__ */ e.jsx(L, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ e.jsx(he, { actions: o?.actions }) }),
1327
1327
  /* @__PURE__ */ e.jsx(Ce, { children: "when" }),
1328
1328
  /* @__PURE__ */ e.jsxs(L, { title: "Conditions", icon: "treeView", children: [
1329
1329
  /* @__PURE__ */ e.jsx(
@@ -1386,9 +1386,9 @@ function L({
1386
1386
  title: n,
1387
1387
  icon: a
1388
1388
  }) {
1389
- return /* @__PURE__ */ e.jsxs("div", { className: "rounded-md bg-white shadow-sm", children: [
1389
+ return /* @__PURE__ */ e.jsxs("div", { className: "rounded-md bg-white shadow-xs", children: [
1390
1390
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-4 py-4 border-b border-gray-100", children: [
1391
- /* @__PURE__ */ e.jsx("div", { className: "w-8 h-8 -ml-4 bg-white rounded-full border border-gray-200 flex items-center justify-center shadow-sm shadow-primary-200", children: /* @__PURE__ */ e.jsx(p, { name: a }) }),
1391
+ /* @__PURE__ */ e.jsx("div", { className: "w-8 h-8 -ml-4 bg-white rounded-full border border-gray-200 flex items-center justify-center shadow-xs shadow-primary-200", children: /* @__PURE__ */ e.jsx(p, { name: a }) }),
1392
1392
  /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: n })
1393
1393
  ] }),
1394
1394
  /* @__PURE__ */ e.jsx("div", { className: "p-6", children: t })
@@ -1397,7 +1397,7 @@ function L({
1397
1397
  function Ve({
1398
1398
  children: t
1399
1399
  }) {
1400
- return /* @__PURE__ */ e.jsx("div", { className: "h-full w-full bg-gray-50 p-8 [background-image:radial-gradient(#d6d6d6_1px,transparent_1px)] [background-size:16px_16px] overflow-auto", children: /* @__PURE__ */ e.jsx("div", { className: "max-w-[900px] mx-auto", children: t }) });
1400
+ return /* @__PURE__ */ e.jsx("div", { className: "h-full w-full bg-gray-50 p-8 bg-[radial-gradient(#d6d6d6_1px,transparent_1px)] bg-size-[16px_16px] overflow-auto", children: /* @__PURE__ */ e.jsx("div", { className: "max-w-[900px] mx-auto", children: t }) });
1401
1401
  }
1402
1402
  export {
1403
1403
  Ae as RuleEngine