@m4l/components 9.54.2-beta-m4lcom-764-device-picker.1 → 9.55.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.
- package/components/DevicesPicker/DevicesPicker.d.ts.map +1 -1
- package/components/DevicesPicker/DevicesPicker.js +214 -213
- package/components/DevicesPicker/DevicesPicker.styles.d.ts.map +1 -1
- package/components/DevicesPicker/DevicesPicker.styles.js +34 -19
- package/components/DevicesPicker/constants.d.ts +14 -3
- package/components/DevicesPicker/constants.d.ts.map +1 -1
- package/components/DevicesPicker/constants.js +15 -13
- package/components/DevicesPicker/subcomponents/DeviceCard/DeviceCard.d.ts.map +1 -1
- package/components/DevicesPicker/subcomponents/DeviceCard/DeviceCard.js +17 -17
- package/components/DevicesPicker/subcomponents/DevicesPanel/DevicesPanel.d.ts.map +1 -1
- package/components/DevicesPicker/subcomponents/DevicesPanel/DevicesPanel.js +44 -36
- package/components/datagrids/views/CardsView/CardsView.d.ts.map +1 -1
- package/components/extended/mui/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/components/extended/mui/Autocomplete/Autocomplete.js +52 -50
- package/components/extended/mui/Autocomplete/hooks/useAutocomplete/useAutocomplete.d.ts.map +1 -1
- package/components/extended/mui/Autocomplete/hooks/useAutocomplete/useAutocomplete.js +58 -60
- package/hooks/useChipsOverflow/helpers/calculateLeftoverWidth.d.ts +14 -0
- package/hooks/useChipsOverflow/helpers/calculateLeftoverWidth.d.ts.map +1 -0
- package/hooks/useChipsOverflow/helpers/calculateLeftoverWidth.js +7 -0
- package/hooks/useChipsOverflow/helpers/index.d.ts +1 -0
- package/hooks/useChipsOverflow/helpers/index.d.ts.map +1 -1
- package/hooks/useChipsOverflow/useChipsOverflow.d.ts +1 -0
- package/hooks/useChipsOverflow/useChipsOverflow.d.ts.map +1 -1
- package/hooks/useChipsOverflow/useChipsOverflow.js +44 -42
- package/index.js +783 -781
- package/package.json +6 -6
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useModuleSkeleton as
|
|
3
|
-
import { useValuesAndHandlers as
|
|
4
|
-
import { useComponentSize as
|
|
5
|
-
import { useMemo as
|
|
6
|
-
import { useMultipleChips as
|
|
7
|
-
import { useEndAdornments as
|
|
8
|
-
import { renderOption as
|
|
9
|
-
import { RenderInputStyled as
|
|
10
|
-
function
|
|
1
|
+
import { jsx as F } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useModuleSkeleton as G } from "@m4l/core";
|
|
3
|
+
import { useValuesAndHandlers as J } from "../useValuesAndHandlers.js";
|
|
4
|
+
import { useComponentSize as Q } from "../../../../../../hooks/useComponentSize/index.js";
|
|
5
|
+
import { useMemo as U, useCallback as R } from "react";
|
|
6
|
+
import { useMultipleChips as X } from "../useMultipleChips.js";
|
|
7
|
+
import { useEndAdornments as Y } from "../useEndAdornments.js";
|
|
8
|
+
import { renderOption as Z } from "../../subcomponents/renderOptions/index.js";
|
|
9
|
+
import { RenderInputStyled as $ } from "../../slots/AutocompleteSlots.js";
|
|
10
|
+
function de(m) {
|
|
11
11
|
const {
|
|
12
12
|
size: c,
|
|
13
13
|
variant: a,
|
|
@@ -15,67 +15,66 @@ function me(m) {
|
|
|
15
15
|
multiple: o,
|
|
16
16
|
error: i,
|
|
17
17
|
readOnly: s,
|
|
18
|
-
startAdornment:
|
|
19
|
-
endAdornment:
|
|
18
|
+
startAdornment: j,
|
|
19
|
+
endAdornment: N,
|
|
20
20
|
getOptionStartAdornment: h,
|
|
21
21
|
getOptionEndAdornment: u,
|
|
22
22
|
getOptionDescription: f,
|
|
23
|
-
loading:
|
|
24
|
-
refresh:
|
|
25
|
-
placeholder: z
|
|
26
|
-
htmlFor: I
|
|
23
|
+
loading: V,
|
|
24
|
+
refresh: D,
|
|
25
|
+
placeholder: z
|
|
27
26
|
} = m, {
|
|
28
|
-
open:
|
|
27
|
+
open: I,
|
|
29
28
|
selectedValue: e,
|
|
30
|
-
inputValue:
|
|
29
|
+
inputValue: E,
|
|
31
30
|
isOptionEqualToValueLocal: p,
|
|
32
|
-
handleDelete:
|
|
33
|
-
handleRefresh:
|
|
34
|
-
handleChange:
|
|
35
|
-
handleInputChange:
|
|
36
|
-
onCloseLocal:
|
|
37
|
-
onOpenLocal:
|
|
31
|
+
handleDelete: g,
|
|
32
|
+
handleRefresh: y,
|
|
33
|
+
handleChange: M,
|
|
34
|
+
handleInputChange: v,
|
|
35
|
+
onCloseLocal: w,
|
|
36
|
+
onOpenLocal: b,
|
|
38
37
|
getOptionLabelLocal: d,
|
|
39
|
-
checkKeyDown:
|
|
40
|
-
scrollPositionOptionsRef:
|
|
41
|
-
} =
|
|
38
|
+
checkKeyDown: x,
|
|
39
|
+
scrollPositionOptionsRef: B
|
|
40
|
+
} = J(m), { currentSize: r } = Q(c), _ = G(), L = !!m.startAdornment, k = !!(o && Array.isArray(e) && e.length > 0), l = U(() => ({
|
|
42
41
|
size: r,
|
|
43
42
|
variant: a,
|
|
44
43
|
disabled: t,
|
|
45
44
|
multiple: !!o,
|
|
46
45
|
error: i,
|
|
47
46
|
readOnly: s,
|
|
48
|
-
startAdornment:
|
|
49
|
-
hasChips:
|
|
50
|
-
}), [r, a, t, o, i, s,
|
|
47
|
+
startAdornment: L,
|
|
48
|
+
hasChips: k
|
|
49
|
+
}), [r, a, t, o, i, s, L, k]), A = X({
|
|
51
50
|
selectedValue: e,
|
|
52
51
|
multiple: o,
|
|
53
52
|
adjustedSize: r,
|
|
54
53
|
getOptionLabelLocal: d,
|
|
55
54
|
ownerState: l,
|
|
56
|
-
handleDelete:
|
|
55
|
+
handleDelete: g,
|
|
57
56
|
disabled: t,
|
|
58
|
-
startAdornment:
|
|
57
|
+
startAdornment: j,
|
|
59
58
|
getOptionStartAdornment: h,
|
|
60
59
|
getOptionEndAdornment: u,
|
|
61
60
|
getOptionDescription: f
|
|
62
|
-
}), C =
|
|
63
|
-
loading:
|
|
61
|
+
}), C = Y({
|
|
62
|
+
loading: V,
|
|
64
63
|
adjustedSize: r,
|
|
65
64
|
ownerState: l,
|
|
66
|
-
refresh:
|
|
67
|
-
handleRefresh:
|
|
65
|
+
refresh: D,
|
|
66
|
+
handleRefresh: y,
|
|
68
67
|
disabled: t,
|
|
69
|
-
onOpenLocal:
|
|
70
|
-
open:
|
|
68
|
+
onOpenLocal: b,
|
|
69
|
+
open: I,
|
|
71
70
|
readOnly: s,
|
|
72
71
|
multiple: o,
|
|
73
72
|
selectedValue: e,
|
|
74
73
|
getOptionEndAdornment: u,
|
|
75
|
-
endAdornment:
|
|
76
|
-
}),
|
|
74
|
+
endAdornment: N
|
|
75
|
+
}), q = R((S, n) => {
|
|
77
76
|
const O = o ? Array.isArray(e) && e.some((P) => p(n, P)) : p(n, e);
|
|
78
|
-
return
|
|
77
|
+
return Z(S, {
|
|
79
78
|
...typeof n == "object" && n !== null ? n : {},
|
|
80
79
|
label: d(n),
|
|
81
80
|
selected: O,
|
|
@@ -92,10 +91,10 @@ function me(m) {
|
|
|
92
91
|
h,
|
|
93
92
|
u,
|
|
94
93
|
f
|
|
95
|
-
]), H =
|
|
96
|
-
const { InputLabelProps: n, inputProps: O, InputProps: P, ...K } = S, { className:
|
|
97
|
-
return /* @__PURE__ */
|
|
98
|
-
|
|
94
|
+
]), H = R((S) => {
|
|
95
|
+
const { InputLabelProps: n, inputProps: O, InputProps: P, ...K } = S, { className: ee, ...T } = P, { className: te, ...W } = O;
|
|
96
|
+
return /* @__PURE__ */ F(
|
|
97
|
+
$,
|
|
99
98
|
{
|
|
100
99
|
variant: a,
|
|
101
100
|
ownerState: l,
|
|
@@ -103,7 +102,7 @@ function me(m) {
|
|
|
103
102
|
...n,
|
|
104
103
|
shrink: !0
|
|
105
104
|
},
|
|
106
|
-
inputProps: { ...W
|
|
105
|
+
inputProps: { ...W },
|
|
107
106
|
error: i,
|
|
108
107
|
...K,
|
|
109
108
|
autoComplete: "off",
|
|
@@ -123,7 +122,6 @@ function me(m) {
|
|
|
123
122
|
}, [
|
|
124
123
|
a,
|
|
125
124
|
l,
|
|
126
|
-
I,
|
|
127
125
|
i,
|
|
128
126
|
A,
|
|
129
127
|
C,
|
|
@@ -135,24 +133,24 @@ function me(m) {
|
|
|
135
133
|
return {
|
|
136
134
|
// propiedades de useAutocomplete
|
|
137
135
|
ownerState: l,
|
|
138
|
-
isSkeleton:
|
|
136
|
+
isSkeleton: _,
|
|
139
137
|
currentSize: r,
|
|
140
|
-
memoizedRenderOption:
|
|
138
|
+
memoizedRenderOption: q,
|
|
141
139
|
memoizedRenderInput: H,
|
|
142
140
|
// propiedades de useValuesAndHandlers
|
|
143
|
-
open:
|
|
141
|
+
open: I,
|
|
144
142
|
selectedValue: e,
|
|
145
|
-
inputValue:
|
|
143
|
+
inputValue: E,
|
|
146
144
|
isOptionEqualToValueLocal: p,
|
|
147
|
-
handleDelete:
|
|
148
|
-
handleRefresh:
|
|
149
|
-
handleChange:
|
|
150
|
-
handleInputChange:
|
|
151
|
-
onCloseLocal:
|
|
152
|
-
onOpenLocal:
|
|
145
|
+
handleDelete: g,
|
|
146
|
+
handleRefresh: y,
|
|
147
|
+
handleChange: M,
|
|
148
|
+
handleInputChange: v,
|
|
149
|
+
onCloseLocal: w,
|
|
150
|
+
onOpenLocal: b,
|
|
153
151
|
getOptionLabelLocal: d,
|
|
154
|
-
checkKeyDown:
|
|
155
|
-
scrollPositionOptionsRef:
|
|
152
|
+
checkKeyDown: x,
|
|
153
|
+
scrollPositionOptionsRef: B,
|
|
156
154
|
// propiedades de useMultipleChips
|
|
157
155
|
multipleChips: A,
|
|
158
156
|
// propiedades de useEndAdornments
|
|
@@ -160,5 +158,5 @@ function me(m) {
|
|
|
160
158
|
};
|
|
161
159
|
}
|
|
162
160
|
export {
|
|
163
|
-
|
|
161
|
+
de as useAutocomplete
|
|
164
162
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the width left over after the visible chips, so a consumer can
|
|
3
|
+
* decide whether the first chip that does not fit is worth painting shrunk or
|
|
4
|
+
* should go straight into the "More" chip.
|
|
5
|
+
* Pure function — all measurements are passed in by the caller.
|
|
6
|
+
* @param availableWidth - Width available for the chips, already excluding the
|
|
7
|
+
* "More" chip and any padding.
|
|
8
|
+
* @param gap - Gap between chips in pixels.
|
|
9
|
+
* @param chipWidths - Natural width of each chip in display order.
|
|
10
|
+
* @param visibleCount - How many chips are painted whole.
|
|
11
|
+
* @returns The remaining width, its leading gap already discounted.
|
|
12
|
+
*/
|
|
13
|
+
export declare function calculateLeftoverWidth(availableWidth: number, gap: number, chipWidths: number[], visibleCount: number): number;
|
|
14
|
+
//# sourceMappingURL=calculateLeftoverWidth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateLeftoverWidth.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/hooks/useChipsOverflow/helpers/calculateLeftoverWidth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAAE,EACpB,YAAY,EAAE,MAAM,GACnB,MAAM,CAKR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/hooks/useChipsOverflow/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/hooks/useChipsOverflow/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -22,6 +22,7 @@ export declare function useChipsOverflow<T extends OverflowItem>(filters: T[], o
|
|
|
22
22
|
visibleFilters: T[];
|
|
23
23
|
overflowFilters: T[];
|
|
24
24
|
measuringFilters: T[];
|
|
25
|
+
leftoverWidth: number;
|
|
25
26
|
parentRef: import('react').RefObject<HTMLDivElement | null>;
|
|
26
27
|
containerRef: import('react').RefObject<HTMLDivElement | null>;
|
|
27
28
|
setChipRef: (id: OverflowItem["id"], el: HTMLElement | null) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChipsOverflow.d.ts","sourceRoot":"","sources":["../../../../../../packages/components/src/hooks/useChipsOverflow/useChipsOverflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useChipsOverflow.d.ts","sourceRoot":"","sources":["../../../../../../packages/components/src/hooks/useChipsOverflow/useChipsOverflow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAIrE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,YAAY,EACrD,OAAO,EAAE,CAAC,EAAE,EACZ,OAAO,GAAE,uBAA4B;;;;;;;qBAmKD,YAAY,CAAC,IAAI,CAAC,MAAM,WAAW,GAAG,IAAI;yBAcvE,WAAW,GAAG,IAAI;wBAalB,WAAW,GAAG,IAAI;wBAYlB,WAAW,GAAG,IAAI;EA6F1B"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useRef as c, useState as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useRef as c, useState as b, useEffect as m, useCallback as h, useMemo as z } from "react";
|
|
2
|
+
import { calculateLeftoverWidth as ne } from "./helpers/calculateLeftoverWidth.js";
|
|
3
|
+
import { calculateVisibleChipsCount as B } from "./helpers/calculateVisibleChipsCount.js";
|
|
4
|
+
const re = [];
|
|
5
|
+
function ae(t, G = {}) {
|
|
6
|
+
const { deferMeasurement: f = !1 } = G, v = c(null), C = c(null), M = c(null), S = c(null), y = c(null), R = c(/* @__PURE__ */ new Map()), a = c(/* @__PURE__ */ new Map()), [o, p] = b(null), [N, A] = b(0), [E, T] = b(/* @__PURE__ */ new Set()), d = c(null);
|
|
6
7
|
m(() => {
|
|
7
8
|
const e = new Set(t.map((r) => r.id));
|
|
8
9
|
for (const r of a.current.keys())
|
|
@@ -10,53 +11,53 @@ function se(t, x = {}) {
|
|
|
10
11
|
t.some((r) => !a.current.has(r.id)) && !f && p(null);
|
|
11
12
|
}, [t, f]);
|
|
12
13
|
const s = h(() => {
|
|
13
|
-
const e = v.current, n =
|
|
14
|
+
const e = v.current, n = C.current;
|
|
14
15
|
if (!e || !n || t.length === 0) {
|
|
15
16
|
p(null);
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
let r = !1;
|
|
19
20
|
if (t.forEach((l) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
}), r &&
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const W = R.current.get(l.id);
|
|
22
|
+
W && W.offsetWidth > 0 && (r = r || !a.current.has(l.id), a.current.set(l.id, W.offsetWidth));
|
|
23
|
+
}), r && T(new Set(a.current.keys())), !t.every((l) => a.current.has(l.id))) {
|
|
24
|
+
d.current === null && (d.current = requestAnimationFrame(() => {
|
|
25
|
+
d.current = null, I.current?.();
|
|
25
26
|
}));
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
const i = getComputedStyle(e), F = getComputedStyle(n),
|
|
29
|
-
if (
|
|
29
|
+
const i = getComputedStyle(e), F = getComputedStyle(n), K = parseFloat(i.paddingLeft) || 0, Q = parseFloat(i.paddingRight) || 0, X = parseFloat(F.paddingLeft) || 0, Z = parseFloat(F.paddingRight) || 0, u = parseFloat(F.gap) || 0, O = e.getBoundingClientRect().width || e.clientWidth;
|
|
30
|
+
if (O === 0)
|
|
30
31
|
return;
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
p(t.length);
|
|
32
|
+
const P = S.current?.offsetWidth ?? 0, $ = P > 0 ? P + u : 0, k = y.current?.offsetWidth ?? 0, ee = k > 0 ? k + u : 0, U = O - K - Q - X - Z - $ - ee, w = t.map((l) => a.current.get(l.id) ?? 0);
|
|
33
|
+
if (B(U, u, w) >= t.length) {
|
|
34
|
+
p(t.length), A(0);
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
const
|
|
37
|
-
p(
|
|
38
|
-
}, [t]),
|
|
39
|
-
|
|
37
|
+
const q = M.current?.offsetWidth ?? 0, te = q > 0 ? q + u : 0, V = U - te, x = B(V, u, w);
|
|
38
|
+
p(x), A(ne(V, u, w, x));
|
|
39
|
+
}, [t]), I = c(null);
|
|
40
|
+
I.current = s, m(
|
|
40
41
|
() => () => {
|
|
41
|
-
|
|
42
|
+
d.current !== null && cancelAnimationFrame(d.current);
|
|
42
43
|
},
|
|
43
44
|
[]
|
|
44
45
|
);
|
|
45
|
-
const
|
|
46
|
+
const Y = h((e, n) => {
|
|
46
47
|
n ? R.current.set(e, n) : R.current.delete(e);
|
|
47
|
-
}, []),
|
|
48
|
+
}, []), _ = h(
|
|
48
49
|
(e) => {
|
|
49
|
-
|
|
50
|
+
M.current = e, s();
|
|
50
51
|
},
|
|
51
52
|
[s]
|
|
52
|
-
),
|
|
53
|
+
), j = h(
|
|
53
54
|
(e) => {
|
|
54
|
-
|
|
55
|
+
S.current = e, s();
|
|
55
56
|
},
|
|
56
57
|
[s]
|
|
57
|
-
),
|
|
58
|
+
), D = h(
|
|
58
59
|
(e) => {
|
|
59
|
-
|
|
60
|
+
y.current = e, s();
|
|
60
61
|
},
|
|
61
62
|
[s]
|
|
62
63
|
);
|
|
@@ -76,33 +77,34 @@ function se(t, x = {}) {
|
|
|
76
77
|
});
|
|
77
78
|
return () => cancelAnimationFrame(e);
|
|
78
79
|
}, [t, s]);
|
|
79
|
-
const g =
|
|
80
|
-
() => f && o !== null ? t.filter((e) => !
|
|
81
|
-
[t, f, o,
|
|
82
|
-
), { visibleFilters:
|
|
80
|
+
const g = z(
|
|
81
|
+
() => f && o !== null ? t.filter((e) => !E.has(e.id)) : re,
|
|
82
|
+
[t, f, o, E]
|
|
83
|
+
), { visibleFilters: H, overflowFilters: J } = z(() => {
|
|
83
84
|
if (g.length === 0)
|
|
84
85
|
return o === null || o >= t.length ? { visibleFilters: t, overflowFilters: [] } : {
|
|
85
86
|
visibleFilters: t.slice(0, o),
|
|
86
87
|
overflowFilters: t.slice(o)
|
|
87
88
|
};
|
|
88
|
-
const e = new Set(g.map((i) => i.id)), n = t.filter((i) => !e.has(i.id)), r = o === null || o >= n.length ? n : n.slice(0, o),
|
|
89
|
+
const e = new Set(g.map((i) => i.id)), n = t.filter((i) => !e.has(i.id)), r = o === null || o >= n.length ? n : n.slice(0, o), L = new Set(r.map((i) => i.id));
|
|
89
90
|
return {
|
|
90
91
|
visibleFilters: r,
|
|
91
|
-
overflowFilters: t.filter((i) => !
|
|
92
|
+
overflowFilters: t.filter((i) => !L.has(i.id))
|
|
92
93
|
};
|
|
93
94
|
}, [t, o, g]);
|
|
94
95
|
return {
|
|
95
|
-
visibleFilters:
|
|
96
|
-
overflowFilters:
|
|
96
|
+
visibleFilters: H,
|
|
97
|
+
overflowFilters: J,
|
|
97
98
|
measuringFilters: g,
|
|
99
|
+
leftoverWidth: N,
|
|
98
100
|
parentRef: v,
|
|
99
|
-
containerRef:
|
|
100
|
-
setChipRef:
|
|
101
|
-
setMoreChipRef:
|
|
102
|
-
setActionsRef:
|
|
103
|
-
setLeadingRef:
|
|
101
|
+
containerRef: C,
|
|
102
|
+
setChipRef: Y,
|
|
103
|
+
setMoreChipRef: _,
|
|
104
|
+
setActionsRef: j,
|
|
105
|
+
setLeadingRef: D
|
|
104
106
|
};
|
|
105
107
|
}
|
|
106
108
|
export {
|
|
107
|
-
|
|
109
|
+
ae as useChipsOverflow
|
|
108
110
|
};
|