@realtek/core-theme 0.0.284 → 0.0.285

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-lib/index.js CHANGED
@@ -6339,16 +6339,23 @@ function Km({ form: e, rules: t, watchPaths: n, targetPath: r, resetOnNoMatch: i
6339
6339
  function qm({ form: e, config: t, watchPath: n }) {
6340
6340
  let r = V.useWatch(n, e), i = ci(void 0);
6341
6341
  return I(() => {
6342
- if (ah(r) || r === i.current) return;
6343
- i.current = r;
6344
- let n = new URLSearchParams({ [t.queryParam]: String(r) });
6345
- a(o, `${t.endpoint}?${n.toString()}`).then((n) => {
6342
+ ah(r) || r === i.current || (i.current = r, a(o, t.endpointTemplate ? `${t.endpointTemplate.replace("{value}", encodeURIComponent(String(r)))}` : `${t.endpoint}?${new URLSearchParams({ [t.queryParam]: String(r) }).toString()}`).then((n) => {
6346
6343
  let r = n?.data ?? n;
6344
+ if (t.substituteTokens) {
6345
+ (t.substituteInFields || []).forEach((n) => {
6346
+ let i = Bm(n), a = e.getFieldValue(i) || "";
6347
+ Object.entries(t.substituteTokens).forEach(([e, t]) => {
6348
+ let n = e.replace(/^\{\{|\}\}$/g, "").trim(), i = RegExp(`\\{\\{\\s*${n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*\\}\\}`, "gi");
6349
+ a = a.replace(i, r?.[t] ?? "");
6350
+ }), e.setFieldValue(i, a);
6351
+ });
6352
+ return;
6353
+ }
6347
6354
  Object.entries(t.mapResponseToFields).forEach(([n, i]) => {
6348
6355
  let a = Bm(n);
6349
6356
  t.onlyIfEmpty && !ah(e.getFieldValue(a)) || e.setFieldValue(a, r?.[i]);
6350
6357
  });
6351
- }).catch(() => {});
6358
+ }).catch(() => {}));
6352
6359
  }, [r]), null;
6353
6360
  }
6354
6361
  function Jm(e, t) {