@commercelayer/app-elements 0.0.56 → 0.0.58

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.
@@ -0,0 +1,92 @@
1
+ import { L as de, H as le } from "./main-aba0dc4d.js";
2
+ import * as ce from "react";
3
+ import { useRef as B, useState as a, useEffect as V, useCallback as x, forwardRef as ve } from "react";
4
+ import { _ as Oe, a as s, h as Se, b as h, u as me, S as _e, c as he, s as ge } from "./overrides-13b2488b.js";
5
+ import { d as ye } from "./unsupportedIterableToArray-f3568793.js";
6
+ import "react-dom";
7
+ import "@commercelayer/sdk";
8
+ var Ce = ["defaultOptions", "cacheOptions", "loadOptions", "options", "isLoading", "onInputChange", "filterOption"];
9
+ function Ie(t) {
10
+ var o = t.defaultOptions, n = o === void 0 ? !1 : o, i = t.cacheOptions, r = i === void 0 ? !1 : i, p = t.loadOptions;
11
+ t.options;
12
+ var f = t.isLoading, g = f === void 0 ? !1 : f, O = t.onInputChange, S = t.filterOption, F = S === void 0 ? null : S, E = Oe(t, Ce), $ = E.inputValue, d = B(void 0), m = B(!1), G = a(Array.isArray(n) ? n : void 0), j = s(G, 2), J = j[0], D = j[1], K = a(typeof $ < "u" ? $ : ""), R = s(K, 2), q = R[0], y = R[1], Q = a(n === !0), w = s(Q, 2), U = w[0], l = w[1], X = a(void 0), H = s(X, 2), C = H[0], I = H[1], Y = a([]), M = s(Y, 2), Z = M[0], L = M[1], k = a(!1), N = s(k, 2), ee = N[0], _ = N[1], te = a({}), T = s(te, 2), c = T[0], W = T[1], ne = a(void 0), b = s(ne, 2), ae = b[0], se = b[1], re = a(void 0), z = s(re, 2), oe = z[0], ie = z[1];
13
+ r !== oe && (W({}), ie(r)), n !== ae && (D(Array.isArray(n) ? n : void 0), se(n)), V(function() {
14
+ return m.current = !0, function() {
15
+ m.current = !1;
16
+ };
17
+ }, []);
18
+ var A = x(function(v, u) {
19
+ if (!p)
20
+ return u();
21
+ var e = p(v, u);
22
+ e && typeof e.then == "function" && e.then(u, function() {
23
+ return u();
24
+ });
25
+ }, [p]);
26
+ V(function() {
27
+ n === !0 && A(q, function(v) {
28
+ m.current && (D(v || []), l(!!d.current));
29
+ });
30
+ }, []);
31
+ var ue = x(function(v, u) {
32
+ var e = Se(v, u, O);
33
+ if (!e) {
34
+ d.current = void 0, y(""), I(""), L([]), l(!1), _(!1);
35
+ return;
36
+ }
37
+ if (r && c[e])
38
+ y(e), I(e), L(c[e]), l(!1), _(!1);
39
+ else {
40
+ var fe = d.current = {};
41
+ y(e), l(!0), _(!C), A(e, function(P) {
42
+ m && fe === d.current && (d.current = void 0, l(!1), I(e), L(P || []), _(!1), W(P ? h(h({}, c), {}, ye({}, e, P)) : c));
43
+ });
44
+ }
45
+ }, [r, A, C, c, O]), pe = ee ? [] : q && C ? Z : J || [];
46
+ return h(h({}, E), {}, {
47
+ options: pe,
48
+ isLoading: U || g,
49
+ onInputChange: ue,
50
+ filterOption: F
51
+ });
52
+ }
53
+ var Le = /* @__PURE__ */ ve(function(t, o) {
54
+ var n = Ie(t), i = me(n);
55
+ return /* @__PURE__ */ ce.createElement(_e, he({
56
+ ref: o
57
+ }, i));
58
+ }), Ae = Le;
59
+ function Pe({
60
+ onSelect: t,
61
+ noOptionsMessage: o,
62
+ initialValues: n,
63
+ loadAsyncValues: i,
64
+ debounceMs: r = 500,
65
+ ...p
66
+ }) {
67
+ const f = x(
68
+ de((g, O) => {
69
+ i(g).then((S) => {
70
+ O(S);
71
+ });
72
+ }, r),
73
+ [r]
74
+ );
75
+ return V(() => () => {
76
+ f.cancel();
77
+ }, [r]), /* @__PURE__ */ le.jsx(
78
+ Ae,
79
+ {
80
+ ...p,
81
+ defaultOptions: n,
82
+ onChange: t,
83
+ noOptionsMessage: () => o,
84
+ loadOptions: f,
85
+ components: ge
86
+ }
87
+ );
88
+ }
89
+ Pe.displayName = "AsyncSelectComponent";
90
+ export {
91
+ Pe as AsyncSelectComponent
92
+ };
@@ -1,7 +1,7 @@
1
- import { P as Ma, r as E, a as Rn, t as H, b as Mt, c as Ee, d as _, g as Cr, _ as Qt, s as je, e as cr, f as xa, h as ur, i as Ln, j as Sa, k as Oa, l as Ea, m as qr, n as _a, o as Kr, p as Pa, q as Ta, u as Na, v as An, w as ae, x as nt, y as pr, z as Hn, A as Ya, B as lr, C as Zr, D as Ia, E as Ra, F as La, G as At, H as Ke, I as Aa, J as Ha, K as Fa } from "./main-cbf3ba03.js";
1
+ import { P as Ma, r as E, a as Rn, t as H, b as Mt, c as Ee, d as _, g as Cr, _ as Qt, s as je, e as cr, f as xa, h as ur, i as Ln, j as Sa, k as Oa, l as Ea, m as qr, n as _a, o as Kr, p as Pa, q as Ta, u as Na, v as An, w as ae, x as nt, y as pr, z as Hn, A as Ya, B as lr, C as Zr, D as Ia, E as Ra, F as La, G as At, H as Ke, I as Aa, J as Ha, K as Fa } from "./main-aba0dc4d.js";
2
2
  import * as B from "react";
3
3
  import h, { forwardRef as Fn, createElement as ja, Component as Ua, createRef as Ba } from "react";
4
- import { _ as Wa, a as I, b as R, c as N, d as D, e as b, f as Y } from "./unsupportedIterableToArray-d8cc7c68.js";
4
+ import { _ as Wa, a as I, b as R, c as N, d as D, e as b, f as Y } from "./unsupportedIterableToArray-f3568793.js";
5
5
  import * as Va from "react-dom";
6
6
  import Qa, { findDOMNode as $a } from "react-dom";
7
7
  import "@commercelayer/sdk";
@@ -1,10 +1,10 @@
1
- import { H as a } from "./main-cbf3ba03.js";
2
- import { u as n, S as s, c as m, s as p } from "./overrides-e9c07b2d.js";
1
+ import { H as a } from "./main-aba0dc4d.js";
2
+ import { u as n, S as s, c as m, s as p } from "./overrides-13b2488b.js";
3
3
  import * as i from "react";
4
4
  import { forwardRef as c } from "react";
5
5
  import "react-dom";
6
6
  import "@commercelayer/sdk";
7
- import "./unsupportedIterableToArray-d8cc7c68.js";
7
+ import "./unsupportedIterableToArray-f3568793.js";
8
8
  var S = /* @__PURE__ */ c(function(e, t) {
9
9
  var o = n(e);
10
10
  return /* @__PURE__ */ i.createElement(s, m({