@commercelayer/app-elements 0.0.58 → 0.0.60

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,94 @@
1
+ import { L as de, H as le } from "./main-b9194133.js";
2
+ import * as ce from "react";
3
+ import { useRef as F, useState as a, useEffect as x, useCallback as E, forwardRef as ve } from "react";
4
+ import { _ as Oe, a as s, h as Se, b as g, u as me, S as _e, c as he, s as ge } from "./overrides-be7a208f.js";
5
+ import { d as ye } from "./unsupportedIterableToArray-c65c3f0a.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, u = i === void 0 ? !1 : i, r = t.loadOptions;
11
+ t.options;
12
+ var v = t.isLoading, O = v === void 0 ? !1 : v, S = t.onInputChange, m = t.filterOption, y = m === void 0 ? null : m, $ = Oe(t, Ce), j = $.inputValue, f = F(void 0), _ = F(!1), G = a(Array.isArray(n) ? n : void 0), D = s(G, 2), J = D[0], R = D[1], K = a(typeof j < "u" ? j : ""), q = s(K, 2), w = q[0], C = q[1], Q = a(n === !0), H = s(Q, 2), U = H[0], d = H[1], X = a(void 0), M = s(X, 2), I = M[0], L = M[1], Y = a([]), N = s(Y, 2), Z = N[0], A = N[1], k = a(!1), T = s(k, 2), ee = T[0], h = T[1], te = a({}), W = s(te, 2), l = W[0], b = W[1], ne = a(void 0), z = s(ne, 2), ae = z[0], se = z[1], re = a(void 0), B = s(re, 2), oe = B[0], ie = B[1];
13
+ u !== oe && (b({}), ie(u)), n !== ae && (R(Array.isArray(n) ? n : void 0), se(n)), x(function() {
14
+ return _.current = !0, function() {
15
+ _.current = !1;
16
+ };
17
+ }, []);
18
+ var P = E(function(c, p) {
19
+ if (!r)
20
+ return p();
21
+ var e = r(c, p);
22
+ e && typeof e.then == "function" && e.then(p, function() {
23
+ return p();
24
+ });
25
+ }, [r]);
26
+ x(function() {
27
+ n === !0 && P(w, function(c) {
28
+ _.current && (R(c || []), d(!!f.current));
29
+ });
30
+ }, []);
31
+ var ue = E(function(c, p) {
32
+ var e = Se(c, p, S);
33
+ if (!e) {
34
+ f.current = void 0, C(""), L(""), A([]), d(!1), h(!1);
35
+ return;
36
+ }
37
+ if (u && l[e])
38
+ C(e), L(e), A(l[e]), d(!1), h(!1);
39
+ else {
40
+ var fe = f.current = {};
41
+ C(e), d(!0), h(!I), P(e, function(V) {
42
+ _ && fe === f.current && (f.current = void 0, d(!1), L(e), A(V || []), h(!1), b(V ? g(g({}, l), {}, ye({}, e, V)) : l));
43
+ });
44
+ }
45
+ }, [u, P, I, l, S]), pe = ee ? [] : w && I ? Z : J || [];
46
+ return g(g({}, $), {}, {
47
+ options: pe,
48
+ isLoading: U || O,
49
+ onInputChange: ue,
50
+ filterOption: y
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
+ isOptionDisabled: i,
64
+ loadAsyncValues: u,
65
+ debounceMs: r = 500,
66
+ ...v
67
+ }) {
68
+ const O = E(
69
+ de((S, m) => {
70
+ u(S).then((y) => {
71
+ m(y);
72
+ });
73
+ }, r),
74
+ [r]
75
+ );
76
+ return x(() => () => {
77
+ O.cancel();
78
+ }, [r]), /* @__PURE__ */ le.jsx(
79
+ Ae,
80
+ {
81
+ ...v,
82
+ defaultOptions: n,
83
+ onChange: t,
84
+ noOptionsMessage: () => o,
85
+ loadOptions: O,
86
+ components: ge,
87
+ isOptionDisabled: i
88
+ }
89
+ );
90
+ }
91
+ Pe.displayName = "AsyncSelectComponent";
92
+ export {
93
+ Pe as AsyncSelectComponent
94
+ };
@@ -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-aba0dc4d.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-b9194133.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-f3568793.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-c65c3f0a.js";
5
5
  import * as Va from "react-dom";
6
6
  import Qa, { findDOMNode as $a } from "react-dom";
7
7
  import "@commercelayer/sdk";
@@ -0,0 +1,36 @@
1
+ import { H as n } from "./main-b9194133.js";
2
+ import { u as s, S as m, c as p, s as i } from "./overrides-be7a208f.js";
3
+ import * as c from "react";
4
+ import { forwardRef as S } from "react";
5
+ import "react-dom";
6
+ import "@commercelayer/sdk";
7
+ import "./unsupportedIterableToArray-c65c3f0a.js";
8
+ var f = /* @__PURE__ */ S(function(e, t) {
9
+ var o = s(e);
10
+ return /* @__PURE__ */ c.createElement(m, p({
11
+ ref: t
12
+ }, o));
13
+ }), l = f;
14
+ function u({
15
+ onSelect: e,
16
+ noOptionsMessage: t,
17
+ isOptionDisabled: o,
18
+ initialValues: r,
19
+ ...a
20
+ }) {
21
+ return /* @__PURE__ */ n.jsx(
22
+ l,
23
+ {
24
+ ...a,
25
+ isOptionDisabled: o,
26
+ options: r,
27
+ onChange: e,
28
+ noOptionsMessage: () => t,
29
+ components: i
30
+ }
31
+ );
32
+ }
33
+ u.displayName = "SelectComponent";
34
+ export {
35
+ u as SelectComponent
36
+ };
@@ -1,9 +1,7 @@
1
1
  import { type IconProps } from '../ui/atoms/Icon';
2
2
  import type { Order } from '@commercelayer/sdk';
3
3
  type UITriggerAttributes = '_approve' | '_cancel' | '_capture' | '_refund' | '_return' | '_archive' | '_unarchive';
4
- type UIStatus = 'placed' | 'approved' | 'in_progress' | 'paid' | 'fulfilled' | 'error' | 'cancelled' | 'refunded' | 'part_refunded' | 'not_handled';
5
4
  interface OrderDisplayStatus {
6
- status: UIStatus;
7
5
  label: string;
8
6
  icon: IconProps['name'];
9
7
  color: IconProps['background'];
@@ -22,15 +22,26 @@ export declare function goBack({ setLocation, defaultRelativePath }: {
22
22
  */
23
23
  defaultRelativePath: string;
24
24
  }): void;
25
- /**
26
- * Navigate to an internal or external URL or pathname and store the current url in sessionStorage
27
- * to be able to navigate back to it with the `goBack` function.
28
- */
29
- export declare function navigateToDetail({ setLocation, destination }: {
25
+ interface NavigateToInternalDetailsParams {
30
26
  /**
31
27
  * React router's history.push method, this is used when linking internal app pages.
32
28
  */
33
- setLocation?: (url: string) => void;
29
+ setLocation: (url: string) => void;
30
+ /**
31
+ * destination instructions to navigate to a detail page
32
+ */
33
+ destination: {
34
+ /**
35
+ * app name to navigate to, it could be the current app (internal linking) or another app (cross linking)
36
+ */
37
+ app: ResourceTypeLock;
38
+ /**
39
+ * resource id to open
40
+ */
41
+ resourceId: string;
42
+ };
43
+ }
44
+ interface NavigateToExternalDetailsParams {
34
45
  /**
35
46
  * destination instructions to navigate to a detail page
36
47
  */
@@ -43,8 +54,18 @@ export declare function navigateToDetail({ setLocation, destination }: {
43
54
  * resource id to open
44
55
  */
45
56
  resourceId: string;
57
+ /**
58
+ * required when linking to another app, it indicates if the destination app should be opened in test or live mode
59
+ */
60
+ mode: 'test' | 'live';
46
61
  };
47
- }): {
62
+ }
63
+ /**
64
+ * Navigate to an internal or external URL or pathname and store the current url in sessionStorage
65
+ * to be able to navigate back to it with the `goBack` function.
66
+ */
67
+ export declare function navigateToDetail(params: NavigateToInternalDetailsParams | NavigateToExternalDetailsParams): {
48
68
  href: string;
49
69
  onClick: (e: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>) => void;
50
70
  };
71
+ export {};