@m4l/components 9.80.0 → 9.80.1-beta-docs-autocomplete-async-with-add-mf-sync.1
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/components/extended/mui/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/components/extended/mui/Autocomplete/Autocomplete.js +55 -54
- package/components/extended/mui/Autocomplete/hooks/useAutocomplete/useAutocomplete.d.ts.map +1 -1
- package/components/extended/mui/Autocomplete/hooks/useAutocomplete/useAutocomplete.js +81 -72
- package/components/extended/mui/Autocomplete/types.d.ts +1 -1
- package/components/extended/mui/Autocomplete/types.d.ts.map +1 -1
- package/components/extended/mui/AutocompleteAsync/AutocompleteAddButton.d.ts +4 -0
- package/components/extended/mui/AutocompleteAsync/AutocompleteAddButton.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/AutocompleteAddButton.js +23 -0
- package/components/extended/mui/AutocompleteAsync/AutocompleteAsync.d.ts +5 -9
- package/components/extended/mui/AutocompleteAsync/AutocompleteAsync.d.ts.map +1 -1
- package/components/extended/mui/AutocompleteAsync/AutocompleteAsync.js +87 -56
- package/components/extended/mui/AutocompleteAsync/constants.d.ts +4 -1
- package/components/extended/mui/AutocompleteAsync/constants.d.ts.map +1 -1
- package/components/extended/mui/AutocompleteAsync/constants.js +24 -12
- package/components/extended/mui/AutocompleteAsync/hooks/useAutocompleteAdd.d.ts +9 -0
- package/components/extended/mui/AutocompleteAsync/hooks/useAutocompleteAdd.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/hooks/useAutocompleteAdd.js +97 -0
- package/components/extended/mui/AutocompleteAsync/hooks/useFetchOptions.d.ts.map +1 -1
- package/components/extended/mui/AutocompleteAsync/hooks/useFetchOptions.js +47 -46
- package/components/extended/mui/AutocompleteAsync/index.d.ts +1 -1
- package/components/extended/mui/AutocompleteAsync/index.d.ts.map +1 -1
- package/components/extended/mui/AutocompleteAsync/reducer/AutocompleteAsyncReducer.d.ts.map +1 -1
- package/components/extended/mui/AutocompleteAsync/reducer/AutocompleteAsyncReducer.js +50 -28
- package/components/extended/mui/AutocompleteAsync/slots/addStyled.d.ts +6 -0
- package/components/extended/mui/AutocompleteAsync/slots/addStyled.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/slots/addStyled.js +19 -0
- package/components/extended/mui/AutocompleteAsync/tests/add/constants.d.ts +5 -0
- package/components/extended/mui/AutocompleteAsync/tests/add/constants.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/tests/add/helpers.d.ts +8 -0
- package/components/extended/mui/AutocompleteAsync/tests/add/helpers.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/tests/add/types.d.ts +20 -0
- package/components/extended/mui/AutocompleteAsync/tests/add/types.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/ControlledAsyncField.d.ts +4 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/ControlledAsyncField.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/constants.d.ts +8 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/constants.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/createDeferred.d.ts +4 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/createDeferred.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/mockAutocompleteAnchor.d.ts +3 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/mockAutocompleteAnchor.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/types.d.ts +21 -0
- package/components/extended/mui/AutocompleteAsync/tests/support/types.d.ts.map +1 -0
- package/components/extended/mui/AutocompleteAsync/types.d.ts +47 -0
- package/components/extended/mui/AutocompleteAsync/types.d.ts.map +1 -1
- package/components/extended/mui/AutocompleteAsync/types.js +4 -2
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.d.ts +1 -1
- package/components/hook-form/RHFAutocompleteAsync/index.d.ts +1 -0
- package/components/hook-form/RHFAutocompleteAsync/index.d.ts.map +1 -1
- package/components/hook-form/RHFAutocompleteAsync/tests/addConstants.d.ts +3 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/addConstants.d.ts.map +1 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/addHelpers.d.ts +4 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/addHelpers.d.ts.map +1 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/addTypes.d.ts +12 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/addTypes.d.ts.map +1 -0
- package/components/hook-form/index.d.ts +1 -0
- package/components/hook-form/index.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1,53 +1,67 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useRef as
|
|
1
|
+
import { jsx as A, jsxs as T } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import D from "lodash-es/debounce";
|
|
3
|
+
import { forwardRef as H, useRef as y, useReducer as Q, useCallback as f, useEffect as R, useMemo as K } from "react";
|
|
4
4
|
import { actionsType as i } from "./types.js";
|
|
5
|
-
import { autocompleteAsyncReducer as
|
|
6
|
-
import { useFetchOptions as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
5
|
+
import { autocompleteAsyncReducer as V, getInitialStateAutocompleteAsync as z } from "./reducer/AutocompleteAsyncReducer.js";
|
|
6
|
+
import { useFetchOptions as G } from "./hooks/useFetchOptions.js";
|
|
7
|
+
import { useAutocompleteAdd as J } from "./hooks/useAutocompleteAdd.js";
|
|
8
|
+
import { AutocompleteAddRoot as W, AutocompleteAddRow as X, AutocompleteAddInput as Z, AutocompleteAddStatusText as $ } from "./slots/addStyled.js";
|
|
9
|
+
import { ASYNC_ONLY_KEYS as ee } from "./constants.js";
|
|
10
|
+
import { AutocompleteAsyncRootStyled as te } from "./slots/AutocompleteAsyncSlots.js";
|
|
11
|
+
function oe(p, b) {
|
|
10
12
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
add: E,
|
|
14
|
+
endPoint: x,
|
|
15
|
+
timeout: I = 5e3,
|
|
16
|
+
parms: C,
|
|
17
|
+
resultField: j = "data",
|
|
18
|
+
isRemote: B = !0,
|
|
19
|
+
isExternalUrl: N = !1,
|
|
20
|
+
onChangeFilterParms: o,
|
|
21
|
+
responseToCamelCase: Y,
|
|
22
|
+
multiple: h,
|
|
23
|
+
shouldFetch: e,
|
|
24
|
+
resetKey: m,
|
|
25
|
+
retainSelectedOptions: F = !!E,
|
|
26
|
+
value: c,
|
|
27
|
+
isOptionEqualToValue: g
|
|
28
|
+
} = p, l = J(p), d = l.refreshKey, u = y(""), _ = Object.fromEntries(
|
|
29
|
+
Object.entries(p).filter(([t]) => !ee.includes(t))
|
|
30
|
+
), [s, n] = Q(
|
|
31
|
+
V(o),
|
|
32
|
+
z({ parms: C, onChangeFilterParms: o })
|
|
26
33
|
);
|
|
27
|
-
if (
|
|
34
|
+
if (h && o)
|
|
28
35
|
throw new Error(
|
|
29
36
|
"multiple cannot be enabled when onChangeFilterParms is defined; define the filter in parms if needed."
|
|
30
37
|
);
|
|
31
|
-
|
|
32
|
-
state:
|
|
38
|
+
G({
|
|
39
|
+
state: s,
|
|
33
40
|
dispatch: n,
|
|
34
|
-
endPoint:
|
|
35
|
-
timeout:
|
|
36
|
-
isExternalUrl:
|
|
37
|
-
parms:
|
|
38
|
-
responseToCamelCase:
|
|
39
|
-
isRemote:
|
|
40
|
-
resultField:
|
|
41
|
+
endPoint: x,
|
|
42
|
+
timeout: I,
|
|
43
|
+
isExternalUrl: N,
|
|
44
|
+
parms: C,
|
|
45
|
+
responseToCamelCase: Y,
|
|
46
|
+
isRemote: B,
|
|
47
|
+
resultField: j
|
|
41
48
|
});
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const v = f(() => n({ type: i.REFRESH }), []), S = y(d);
|
|
50
|
+
R(() => {
|
|
51
|
+
S.current !== d && (S.current = d, n({
|
|
52
|
+
type: i.INVALIDATE,
|
|
53
|
+
noFetch: !!(e && !e(u.current))
|
|
54
|
+
}));
|
|
55
|
+
}, [d, e]);
|
|
56
|
+
const w = f(() => {
|
|
57
|
+
const t = !e || e(u.current);
|
|
58
|
+
n({ type: i.OPEN, noFetch: !t });
|
|
59
|
+
}, [e]), q = f(() => n({ type: i.CLOSE }), []), r = K(
|
|
60
|
+
() => D(
|
|
61
|
+
(t) => {
|
|
48
62
|
n({
|
|
49
63
|
type: i.SET_QUERY_PARAMS,
|
|
50
|
-
payload:
|
|
64
|
+
payload: t
|
|
51
65
|
});
|
|
52
66
|
},
|
|
53
67
|
300,
|
|
@@ -55,31 +69,48 @@ function q(l) {
|
|
|
55
69
|
),
|
|
56
70
|
[n]
|
|
57
71
|
);
|
|
58
|
-
|
|
72
|
+
R(
|
|
59
73
|
() => () => {
|
|
60
74
|
r.cancel();
|
|
61
75
|
},
|
|
62
76
|
[r]
|
|
63
77
|
);
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
const O = y(m);
|
|
79
|
+
R(() => {
|
|
80
|
+
O.current !== m && (O.current = m, r.cancel(), n({
|
|
81
|
+
type: i.RESET,
|
|
82
|
+
noFetch: !!(e && !e(u.current)),
|
|
83
|
+
queryParams: o?.(u.current)
|
|
84
|
+
}));
|
|
85
|
+
}, [m, e, o, r]);
|
|
86
|
+
const M = f(
|
|
87
|
+
(t, a) => {
|
|
88
|
+
u.current = t, o && a === "input" && (!e || e(t) ? r(o(t)) : r.cancel());
|
|
67
89
|
},
|
|
68
|
-
[
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
I,
|
|
90
|
+
[o, r, e]
|
|
91
|
+
), U = K(() => !F || s.options.length === 0 ? s.options : (h ? Array.isArray(c) ? c : [] : c == null ? [] : [c]).reduce((a, L) => a.some((k) => g(k, L)) ? a : [...a, L], s.options), [s.options, h, c, g, F]), P = /* @__PURE__ */ A(
|
|
92
|
+
te,
|
|
72
93
|
{
|
|
73
|
-
...
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
..._,
|
|
95
|
+
inputRef: b ?? p.inputRef,
|
|
96
|
+
onChange: l.onChange,
|
|
97
|
+
loading: s.loading,
|
|
98
|
+
options: U,
|
|
99
|
+
onChangeFilterParmsLocal: o ? M : void 0,
|
|
100
|
+
refresh: v,
|
|
101
|
+
onOpen: w,
|
|
102
|
+
onClose: q
|
|
80
103
|
}
|
|
81
104
|
);
|
|
105
|
+
return E ? /* @__PURE__ */ T(W, { children: [
|
|
106
|
+
/* @__PURE__ */ T(X, { children: [
|
|
107
|
+
/* @__PURE__ */ A(Z, { children: P }),
|
|
108
|
+
l.addButton
|
|
109
|
+
] }),
|
|
110
|
+
l.status && /* @__PURE__ */ A($, { role: "status", "aria-live": "polite", children: l.status })
|
|
111
|
+
] }) : P;
|
|
82
112
|
}
|
|
113
|
+
const de = H(oe);
|
|
83
114
|
export {
|
|
84
|
-
|
|
115
|
+
de as AutocompleteAsync
|
|
85
116
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AutocompleteAddStatus } from './types';
|
|
1
2
|
import { AutocompleteAsyncSlots } from './slots/AutocompleteAsyncEnum';
|
|
2
3
|
/**
|
|
3
4
|
* Key to identify the AutocompleteAsync component in the design system.
|
|
@@ -9,5 +10,7 @@ export declare const AUTOCOMPLETE_ASYNC_COMBINED_CLASSES: {
|
|
|
9
10
|
root: AutocompleteAsyncSlots.root;
|
|
10
11
|
};
|
|
11
12
|
export declare const AUTOCOMPLETE_ASYNC_CLASSES: Record<"root", string>;
|
|
12
|
-
export declare const ASYNC_ONLY_KEYS: readonly ["endPoint", "timeout", "parms", "resultField", "isRemote", "isExternalUrl", "responseToCamelCase", "onChangeFilterParms", "shouldFetch"];
|
|
13
|
+
export declare const ASYNC_ONLY_KEYS: readonly ["add", "endPoint", "timeout", "parms", "resultField", "isRemote", "isExternalUrl", "responseToCamelCase", "onChangeFilterParms", "shouldFetch", "refreshKey", "resetKey", "retainSelectedOptions"];
|
|
14
|
+
export declare const AUTOCOMPLETE_ADD_MESSAGES: Record<AutocompleteAddStatus, string>;
|
|
15
|
+
export declare const AUTOCOMPLETE_ADD_RECENT_OPERATIONS = 32;
|
|
13
16
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAyC,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE9G;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,yBAAyB,CAAC;AAEvE,eAAO,MAAM,mCAAmC;;CAG/C,CAAC;AAEF,eAAO,MAAM,0BAA0B,wBAGtC,CAAC;AAEF,eAAO,MAAM,eAAe,8MAclB,CAAC;AAGX,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAM3E,CAAC;AAEF,eAAO,MAAM,kCAAkC,KAAK,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { getComponentClasses as e } from "../../../../utils/getComponentSlotRoot.js";
|
|
2
|
-
import { AutocompleteAsyncComplementaryClasses as
|
|
3
|
-
const
|
|
4
|
-
...
|
|
5
|
-
...
|
|
2
|
+
import { AutocompleteAsyncComplementaryClasses as t, AutocompleteAsyncSlots as o } from "./slots/AutocompleteAsyncEnum.js";
|
|
3
|
+
const n = "M4LAutocompleteAsync", r = {
|
|
4
|
+
...o,
|
|
5
|
+
...t
|
|
6
6
|
};
|
|
7
7
|
e(
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
n,
|
|
9
|
+
r
|
|
10
10
|
);
|
|
11
|
-
const
|
|
11
|
+
const c = [
|
|
12
|
+
"add",
|
|
12
13
|
"endPoint",
|
|
13
14
|
"timeout",
|
|
14
15
|
"parms",
|
|
@@ -17,10 +18,21 @@ const l = [
|
|
|
17
18
|
"isExternalUrl",
|
|
18
19
|
"responseToCamelCase",
|
|
19
20
|
"onChangeFilterParms",
|
|
20
|
-
"shouldFetch"
|
|
21
|
-
|
|
21
|
+
"shouldFetch",
|
|
22
|
+
"refreshKey",
|
|
23
|
+
"resetKey",
|
|
24
|
+
"retainSelectedOptions"
|
|
25
|
+
], l = {
|
|
26
|
+
pending: "Waiting for the new record.",
|
|
27
|
+
created: "Record created.",
|
|
28
|
+
cancelled: "Creation cancelled.",
|
|
29
|
+
unavailable: "Record created. Refresh the options to select it when available.",
|
|
30
|
+
error: "Could not complete this action. Try again."
|
|
31
|
+
}, i = 32;
|
|
22
32
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
c as ASYNC_ONLY_KEYS,
|
|
34
|
+
l as AUTOCOMPLETE_ADD_MESSAGES,
|
|
35
|
+
i as AUTOCOMPLETE_ADD_RECENT_OPERATIONS,
|
|
36
|
+
r as AUTOCOMPLETE_ASYNC_COMBINED_CLASSES,
|
|
37
|
+
n as AUTOCOMPLETE_ASYNC_KEY_COMPONENT
|
|
26
38
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AutocompleteAsyncProps } from '../types';
|
|
2
|
+
/** Manage optional creation, correlated invalidation and focus within the existing async selector. */
|
|
3
|
+
export declare function useAutocompleteAdd<T>(props: AutocompleteAsyncProps<T>): {
|
|
4
|
+
refreshKey: string | undefined;
|
|
5
|
+
onChange: (event: import('../..').AutocompleteValueChangeEvent<T> | undefined, value: T | T[] | null, reason: import('@mui/material').AutocompleteChangeReason) => void;
|
|
6
|
+
addButton: import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
status: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useAutocompleteAdd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutocompleteAdd.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/hooks/useAutocompleteAdd.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAyB,sBAAsB,EAA0B,MAAM,UAAU,CAAC;AAEtG,sGAAsG;AACtG,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC;;;;;EAkIrE"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as p } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { deepEqual as w } from "fast-equals";
|
|
3
|
+
import { useRef as d, useState as O, useCallback as _, useEffect as h } from "react";
|
|
4
|
+
import { AutocompleteAddButton as q } from "../AutocompleteAddButton.js";
|
|
5
|
+
import { AUTOCOMPLETE_ADD_RECENT_OPERATIONS as M, AUTOCOMPLETE_ADD_MESSAGES as R } from "../constants.js";
|
|
6
|
+
function B(r) {
|
|
7
|
+
const { add: o, resetKey: s, refreshKey: a } = r, f = d(r);
|
|
8
|
+
f.current = r;
|
|
9
|
+
const u = d({ value: r.value, version: 0 });
|
|
10
|
+
w(u.current.value, r.value) || (u.current = { value: r.value, version: u.current.version + 1 });
|
|
11
|
+
const l = d(null), v = d(null), b = d(!1), [y, m] = O(!1), [g, c] = O(), [C, k] = O({ resetKey: s, key: a }), i = d(new Set(a ? [a] : [])), A = _((e) => {
|
|
12
|
+
i.current.has(e) || (i.current.add(e), i.current.size > M && i.current.delete(i.current.values().next().value), k({ resetKey: f.current.resetKey, key: e }));
|
|
13
|
+
}, []);
|
|
14
|
+
h(() => {
|
|
15
|
+
m(!1), c(void 0);
|
|
16
|
+
const e = f.current.refreshKey;
|
|
17
|
+
return i.current = new Set(e ? [e] : []), k((t) => t.resetKey === s && t.key === e ? t : { resetKey: s, key: e }), () => {
|
|
18
|
+
l.current?.controller.abort(), l.current = null;
|
|
19
|
+
};
|
|
20
|
+
}, [s]), h(() => {
|
|
21
|
+
a && A(a);
|
|
22
|
+
}, [a, A]), h(() => {
|
|
23
|
+
!y && b.current && (b.current = !1, v.current?.isConnected && v.current.focus());
|
|
24
|
+
}, [y]);
|
|
25
|
+
const S = async () => {
|
|
26
|
+
if (!o || r.disabled || r.readOnly || o.disabled || l.current)
|
|
27
|
+
return;
|
|
28
|
+
const e = {
|
|
29
|
+
controller: new AbortController(),
|
|
30
|
+
selectionVersion: u.current.version,
|
|
31
|
+
resetKey: s
|
|
32
|
+
};
|
|
33
|
+
l.current = e, m(!0), c("pending");
|
|
34
|
+
try {
|
|
35
|
+
const t = await o.action({ requestId: crypto.randomUUID(), signal: e.controller.signal });
|
|
36
|
+
if (l.current !== e || e.controller.signal.aborted)
|
|
37
|
+
return;
|
|
38
|
+
const n = f.current;
|
|
39
|
+
if (n.resetKey !== e.resetKey)
|
|
40
|
+
return;
|
|
41
|
+
if (t.status === "cancelled") {
|
|
42
|
+
c("cancelled");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (A(t.operationId), c(t.option === null ? "unavailable" : "created"), t.option === null || n.add?.selectCreated === !1 || n.disabled || n.readOnly || u.current.version !== e.selectionVersion)
|
|
46
|
+
return;
|
|
47
|
+
const E = t.option, K = Array.isArray(n.value) ? n.value : [], P = n.multiple ? K.some((T) => n.isOptionEqualToValue(T, E)) ? K : [...K, E] : E;
|
|
48
|
+
try {
|
|
49
|
+
n.onChange({ target: { value: P } }, P, "selectOption");
|
|
50
|
+
} catch {
|
|
51
|
+
c("unavailable");
|
|
52
|
+
}
|
|
53
|
+
} catch (t) {
|
|
54
|
+
if (l.current !== e || e.controller.signal.aborted)
|
|
55
|
+
return;
|
|
56
|
+
c("error");
|
|
57
|
+
try {
|
|
58
|
+
o.onError?.(t);
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
} finally {
|
|
62
|
+
l.current === e && (l.current = null, b.current = !0, m(!1));
|
|
63
|
+
}
|
|
64
|
+
}, D = (e, t, n) => {
|
|
65
|
+
u.current.version += 1, r.onChange(e, t, n);
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
// Without creation, preserve every legacy refresh-key change, including a cleared key.
|
|
69
|
+
refreshKey: o && C.resetKey === s ? C.key : a,
|
|
70
|
+
onChange: D,
|
|
71
|
+
addButton: o && !r.readOnly ? /* @__PURE__ */ p(
|
|
72
|
+
q,
|
|
73
|
+
{
|
|
74
|
+
buttonRef: v,
|
|
75
|
+
type: "button",
|
|
76
|
+
tooltip: o.label,
|
|
77
|
+
"aria-label": o.label,
|
|
78
|
+
"aria-busy": y,
|
|
79
|
+
disabled: r.disabled || o.disabled || y,
|
|
80
|
+
size: r.size,
|
|
81
|
+
onMouseDown: (e) => {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
},
|
|
84
|
+
onKeyDown: (e) => {
|
|
85
|
+
(e.key === "Enter" || e.key === " ") && e.stopPropagation();
|
|
86
|
+
},
|
|
87
|
+
onClick: (e) => {
|
|
88
|
+
e.stopPropagation(), S();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
) : null,
|
|
92
|
+
status: g ? o?.messages?.[g] ?? R[g] : void 0
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
B as useAutocompleteAdd
|
|
97
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchOptions.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/hooks/useFetchOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG7D;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"useFetchOptions.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/hooks/useFetchOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG7D;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAyFhE"}
|
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { actionsType as
|
|
3
|
-
import { useNetwork as
|
|
4
|
-
function
|
|
1
|
+
import { useRef as o, useEffect as C } from "react";
|
|
2
|
+
import { actionsType as a } from "../types.js";
|
|
3
|
+
import { useNetwork as P, getPropertyByString as S } from "@m4l/core";
|
|
4
|
+
function w(O) {
|
|
5
5
|
const {
|
|
6
|
-
state:
|
|
7
|
-
dispatch:
|
|
8
|
-
endPoint:
|
|
9
|
-
timeout:
|
|
10
|
-
isExternalUrl:
|
|
11
|
-
parms:
|
|
12
|
-
responseToCamelCase:
|
|
13
|
-
isRemote:
|
|
14
|
-
resultField:
|
|
15
|
-
} =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
state: r,
|
|
7
|
+
dispatch: e,
|
|
8
|
+
endPoint: s,
|
|
9
|
+
timeout: c,
|
|
10
|
+
isExternalUrl: i,
|
|
11
|
+
parms: u,
|
|
12
|
+
responseToCamelCase: p,
|
|
13
|
+
isRemote: f,
|
|
14
|
+
resultField: l = "data"
|
|
15
|
+
} = O, { networkOperation: m } = P(), y = o(m);
|
|
16
|
+
y.current = m;
|
|
17
|
+
const t = o(null), h = o(r.fireFetchCount);
|
|
18
|
+
C(() => {
|
|
19
|
+
e({ type: a.SET_PARAMS, payload: u });
|
|
20
|
+
}, [u, e]), C(() => {
|
|
21
|
+
let n = !1;
|
|
22
|
+
if (h.current !== r.fireFetchCount)
|
|
23
|
+
return h.current = r.fireFetchCount, r.fireFetchCount > 0 && (t.current && t.current.abort(), t.current = new AbortController(), y.current({
|
|
22
24
|
method: "GET",
|
|
23
|
-
endPoint:
|
|
24
|
-
timeout:
|
|
25
|
-
isExternalUrl:
|
|
26
|
-
parms: { ...
|
|
27
|
-
responseToCamelCase:
|
|
28
|
-
isRemote:
|
|
29
|
-
signal:
|
|
30
|
-
}).then((
|
|
31
|
-
if (
|
|
25
|
+
endPoint: s,
|
|
26
|
+
timeout: c,
|
|
27
|
+
isExternalUrl: i,
|
|
28
|
+
parms: { ...r.parms, ...r.queryParams },
|
|
29
|
+
responseToCamelCase: p,
|
|
30
|
+
isRemote: f,
|
|
31
|
+
signal: t.current.signal
|
|
32
|
+
}).then((d) => {
|
|
33
|
+
if (n)
|
|
32
34
|
return;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
type:
|
|
36
|
-
payload: { options:
|
|
35
|
+
const F = S(d, l), A = Array.isArray(F) ? F : [];
|
|
36
|
+
e({
|
|
37
|
+
type: a.FINISH_LOAD_OPTIONS,
|
|
38
|
+
payload: { options: A }
|
|
37
39
|
});
|
|
38
40
|
}).catch(() => {
|
|
39
|
-
|
|
40
|
-
type:
|
|
41
|
+
n || e({
|
|
42
|
+
type: a.FINISH_LOAD_OPTIONS,
|
|
41
43
|
payload: {}
|
|
42
44
|
});
|
|
43
45
|
})), () => {
|
|
44
|
-
|
|
46
|
+
n = !0, t.current && t.current.abort();
|
|
45
47
|
};
|
|
46
48
|
}, [
|
|
47
|
-
|
|
48
|
-
a,
|
|
49
|
+
e,
|
|
49
50
|
s,
|
|
50
|
-
|
|
51
|
-
l,
|
|
52
|
-
o,
|
|
53
|
-
c,
|
|
51
|
+
i,
|
|
54
52
|
f,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
r.parms,
|
|
54
|
+
p,
|
|
55
|
+
l,
|
|
56
|
+
r.fireFetchCount,
|
|
57
|
+
r.queryParams,
|
|
58
|
+
c
|
|
58
59
|
]);
|
|
59
60
|
}
|
|
60
61
|
export {
|
|
61
|
-
|
|
62
|
+
w as useFetchOptions
|
|
62
63
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AutocompleteAsync } from './AutocompleteAsync';
|
|
2
|
-
export type { AutocompleteAsyncProps } from './types';
|
|
2
|
+
export type { AutocompleteAsyncProps, AutocompleteAddContext, AutocompleteAddResult, AutocompleteAddAction } from './types';
|
|
3
3
|
export { useFetchOptions } from './hooks/useFetchOptions';
|
|
4
4
|
export { autocompleteAsyncReducer, getInitialStateAutocompleteAsync } from './reducer/AutocompleteAsyncReducer';
|
|
5
5
|
export { actionsType } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC5H,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAChH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteAsyncReducer.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/reducer/AutocompleteAsyncReducer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,KAAK,oBAAoB,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,EAChD,KAAK,EAAE,oBAAoB,GAC1B,sBAAsB,CAAC,CAAC,CAAC,CAU3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,mBAAmB,CAAC,EAAE,mBAAmB,IAGvC,OAAO,sBAAsB,CAAC,CAAC,CAAC,EAChC,QAAQ,uBAAuB,CAAC,CAAC,CAAC,KACjC,sBAAsB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"AutocompleteAsyncReducer.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/reducer/AutocompleteAsyncReducer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,KAAK,oBAAoB,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,EAChD,KAAK,EAAE,oBAAoB,GAC1B,sBAAsB,CAAC,CAAC,CAAC,CAU3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,mBAAmB,CAAC,EAAE,mBAAmB,IAGvC,OAAO,sBAAsB,CAAC,CAAC,CAAC,EAChC,QAAQ,uBAAuB,CAAC,CAAC,CAAC,KACjC,sBAAsB,CAAC,CAAC,CAAC,CAsF7B"}
|
|
@@ -1,64 +1,86 @@
|
|
|
1
1
|
import { deepEqual as i } from "fast-equals";
|
|
2
|
-
import { actionsType as
|
|
3
|
-
function
|
|
2
|
+
import { actionsType as o } from "../types.js";
|
|
3
|
+
function s(u) {
|
|
4
4
|
return {
|
|
5
5
|
fireFetchCount: 0,
|
|
6
6
|
options: [],
|
|
7
|
-
parms:
|
|
7
|
+
parms: u.parms,
|
|
8
8
|
loading: !1,
|
|
9
|
-
queryParams:
|
|
9
|
+
queryParams: u.onChangeFilterParms ? u.onChangeFilterParms("") : {},
|
|
10
10
|
isOpen: !1,
|
|
11
11
|
firstOpen: !0
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return (r,
|
|
16
|
-
switch (
|
|
17
|
-
case
|
|
14
|
+
function l(u) {
|
|
15
|
+
return (r, n) => {
|
|
16
|
+
switch (n.type) {
|
|
17
|
+
case o.REFRESH:
|
|
18
18
|
return {
|
|
19
19
|
...r,
|
|
20
|
+
loading: !0,
|
|
20
21
|
fireFetchCount: r.fireFetchCount + 1
|
|
21
22
|
};
|
|
22
|
-
case
|
|
23
|
-
|
|
23
|
+
case o.INVALIDATE: {
|
|
24
|
+
const e = r.isOpen && !n.noFetch;
|
|
25
|
+
return {
|
|
26
|
+
...r,
|
|
27
|
+
firstOpen: !e,
|
|
28
|
+
loading: e || r.loading,
|
|
29
|
+
fireFetchCount: r.fireFetchCount + (e ? 1 : 0)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
case o.RESET: {
|
|
33
|
+
const e = r.isOpen && !n.noFetch;
|
|
34
|
+
return {
|
|
35
|
+
...r,
|
|
36
|
+
options: [],
|
|
37
|
+
queryParams: n.queryParams ?? r.queryParams,
|
|
38
|
+
firstOpen: !e,
|
|
39
|
+
loading: e,
|
|
40
|
+
fireFetchCount: e ? r.fireFetchCount + 1 : 0
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
case o.SET_PARAMS:
|
|
44
|
+
if (i(r.parms, n.payload))
|
|
24
45
|
return r;
|
|
25
46
|
{
|
|
26
|
-
const
|
|
47
|
+
const e = u ? u("") : r.queryParams;
|
|
27
48
|
return {
|
|
28
49
|
...r,
|
|
29
|
-
parms:
|
|
50
|
+
parms: n.payload,
|
|
30
51
|
fireFetchCount: 0,
|
|
31
52
|
firstOpen: !0,
|
|
32
53
|
options: [],
|
|
33
|
-
queryParams:
|
|
54
|
+
queryParams: e
|
|
34
55
|
};
|
|
35
56
|
}
|
|
36
|
-
case
|
|
37
|
-
return i(r.queryParams,
|
|
57
|
+
case o.SET_QUERY_PARAMS:
|
|
58
|
+
return i(r.queryParams, n.payload) ? r : {
|
|
38
59
|
...r,
|
|
39
|
-
queryParams:
|
|
60
|
+
queryParams: n.payload,
|
|
61
|
+
loading: !0,
|
|
40
62
|
fireFetchCount: r.fireFetchCount + 1
|
|
41
63
|
};
|
|
42
|
-
case
|
|
43
|
-
const
|
|
64
|
+
case o.FINISH_LOAD_OPTIONS: {
|
|
65
|
+
const e = n.payload?.options ?? r.options, f = n.payload?.options ? r.firstOpen : !0;
|
|
44
66
|
return {
|
|
45
67
|
...r,
|
|
46
|
-
options:
|
|
68
|
+
options: e,
|
|
47
69
|
loading: !1,
|
|
48
|
-
firstOpen:
|
|
70
|
+
firstOpen: f
|
|
49
71
|
};
|
|
50
72
|
}
|
|
51
|
-
case
|
|
52
|
-
const
|
|
73
|
+
case o.OPEN: {
|
|
74
|
+
const e = r.firstOpen && !n.noFetch;
|
|
53
75
|
return {
|
|
54
76
|
...r,
|
|
55
77
|
isOpen: !0,
|
|
56
|
-
fireFetchCount:
|
|
57
|
-
firstOpen:
|
|
58
|
-
loading:
|
|
78
|
+
fireFetchCount: e ? r.fireFetchCount + 1 : r.fireFetchCount,
|
|
79
|
+
firstOpen: e ? !1 : r.firstOpen,
|
|
80
|
+
loading: e ? !0 : r.loading
|
|
59
81
|
};
|
|
60
82
|
}
|
|
61
|
-
case
|
|
83
|
+
case o.CLOSE:
|
|
62
84
|
return {
|
|
63
85
|
...r,
|
|
64
86
|
isOpen: !1
|
|
@@ -69,6 +91,6 @@ function a(o) {
|
|
|
69
91
|
};
|
|
70
92
|
}
|
|
71
93
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
94
|
+
l as autocompleteAsyncReducer,
|
|
95
|
+
s as getInitialStateAutocompleteAsync
|
|
74
96
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const AutocompleteAddRoot: import('@emotion/styled').StyledComponent<Omit<import('../..').StackProps, "ref"> & import('react').RefAttributes<HTMLDivElement> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
|
|
2
|
+
export declare const AutocompleteAddRow: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
3
|
+
export declare const AutocompleteAddInput: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
4
|
+
export declare const AutocompleteAddIconContainer: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
5
|
+
export declare const AutocompleteAddStatusText: import('@emotion/styled').StyledComponent<Omit<import('@m4l/base').TypographyProps, "ref"> & import('react').RefAttributes<HTMLSpanElement> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
|
|
6
|
+
//# sourceMappingURL=addStyled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addStyled.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/extended/mui/AutocompleteAsync/slots/addStyled.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,wNAAgD,CAAC;AAEjF,eAAO,MAAM,kBAAkB,6NAM5B,CAAC;AACJ,eAAO,MAAM,oBAAoB,6NAAiD,CAAC;AAEnF,eAAO,MAAM,4BAA4B,+NAA4D,CAAC;AACtG,eAAO,MAAM,yBAAyB,kOAEnC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { styled as t } from "@mui/material/styles";
|
|
2
|
+
import { Stack as e } from "../../Stack/Stack.js";
|
|
3
|
+
import { Typography as i } from "../../Typography/Typography.js";
|
|
4
|
+
const s = t(e)({ width: "100%", minWidth: 0 }), m = t("div")(({ theme: o }) => ({
|
|
5
|
+
display: "flex",
|
|
6
|
+
alignItems: "center",
|
|
7
|
+
gap: o.vars.size.baseSpacings.sp1,
|
|
8
|
+
width: "100%",
|
|
9
|
+
minWidth: 0
|
|
10
|
+
})), c = t("div")({ flex: "1 1 0%", minWidth: 0 }), a = t("span")({ display: "inline-flex", flexShrink: 0 }), l = t(i)(({ theme: o }) => ({
|
|
11
|
+
marginTop: o.spacing(0.5)
|
|
12
|
+
}));
|
|
13
|
+
export {
|
|
14
|
+
a as AutocompleteAddIconContainer,
|
|
15
|
+
c as AutocompleteAddInput,
|
|
16
|
+
s as AutocompleteAddRoot,
|
|
17
|
+
m as AutocompleteAddRow,
|
|
18
|
+
l as AutocompleteAddStatusText
|
|
19
|
+
};
|