@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.
Files changed (26) hide show
  1. package/components/DevicesPicker/DevicesPicker.d.ts.map +1 -1
  2. package/components/DevicesPicker/DevicesPicker.js +214 -213
  3. package/components/DevicesPicker/DevicesPicker.styles.d.ts.map +1 -1
  4. package/components/DevicesPicker/DevicesPicker.styles.js +34 -19
  5. package/components/DevicesPicker/constants.d.ts +14 -3
  6. package/components/DevicesPicker/constants.d.ts.map +1 -1
  7. package/components/DevicesPicker/constants.js +15 -13
  8. package/components/DevicesPicker/subcomponents/DeviceCard/DeviceCard.d.ts.map +1 -1
  9. package/components/DevicesPicker/subcomponents/DeviceCard/DeviceCard.js +17 -17
  10. package/components/DevicesPicker/subcomponents/DevicesPanel/DevicesPanel.d.ts.map +1 -1
  11. package/components/DevicesPicker/subcomponents/DevicesPanel/DevicesPanel.js +44 -36
  12. package/components/datagrids/views/CardsView/CardsView.d.ts.map +1 -1
  13. package/components/extended/mui/Autocomplete/Autocomplete.d.ts.map +1 -1
  14. package/components/extended/mui/Autocomplete/Autocomplete.js +52 -50
  15. package/components/extended/mui/Autocomplete/hooks/useAutocomplete/useAutocomplete.d.ts.map +1 -1
  16. package/components/extended/mui/Autocomplete/hooks/useAutocomplete/useAutocomplete.js +58 -60
  17. package/hooks/useChipsOverflow/helpers/calculateLeftoverWidth.d.ts +14 -0
  18. package/hooks/useChipsOverflow/helpers/calculateLeftoverWidth.d.ts.map +1 -0
  19. package/hooks/useChipsOverflow/helpers/calculateLeftoverWidth.js +7 -0
  20. package/hooks/useChipsOverflow/helpers/index.d.ts +1 -0
  21. package/hooks/useChipsOverflow/helpers/index.d.ts.map +1 -1
  22. package/hooks/useChipsOverflow/useChipsOverflow.d.ts +1 -0
  23. package/hooks/useChipsOverflow/useChipsOverflow.d.ts.map +1 -1
  24. package/hooks/useChipsOverflow/useChipsOverflow.js +44 -42
  25. package/index.js +783 -781
  26. package/package.json +6 -6
@@ -1,13 +1,13 @@
1
- import { jsx as G } from "@emotion/react/jsx-runtime";
2
- import { useModuleSkeleton as J } from "@m4l/core";
3
- import { useValuesAndHandlers as Q } from "../useValuesAndHandlers.js";
4
- import { useComponentSize as U } from "../../../../../../hooks/useComponentSize/index.js";
5
- import { useMemo as X, useCallback as j } from "react";
6
- import { useMultipleChips as Y } from "../useMultipleChips.js";
7
- import { useEndAdornments as Z } from "../useEndAdornments.js";
8
- import { renderOption as $ } from "../../subcomponents/renderOptions/index.js";
9
- import { RenderInputStyled as ee } from "../../slots/AutocompleteSlots.js";
10
- function me(m) {
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: N,
19
- endAdornment: V,
18
+ startAdornment: j,
19
+ endAdornment: N,
20
20
  getOptionStartAdornment: h,
21
21
  getOptionEndAdornment: u,
22
22
  getOptionDescription: f,
23
- loading: D,
24
- refresh: E,
25
- placeholder: z,
26
- htmlFor: I
23
+ loading: V,
24
+ refresh: D,
25
+ placeholder: z
27
26
  } = m, {
28
- open: g,
27
+ open: I,
29
28
  selectedValue: e,
30
- inputValue: M,
29
+ inputValue: E,
31
30
  isOptionEqualToValueLocal: p,
32
- handleDelete: y,
33
- handleRefresh: b,
34
- handleChange: v,
35
- handleInputChange: w,
36
- onCloseLocal: x,
37
- onOpenLocal: L,
31
+ handleDelete: g,
32
+ handleRefresh: y,
33
+ handleChange: M,
34
+ handleInputChange: v,
35
+ onCloseLocal: w,
36
+ onOpenLocal: b,
38
37
  getOptionLabelLocal: d,
39
- checkKeyDown: B,
40
- scrollPositionOptionsRef: _
41
- } = Q(m), { currentSize: r } = U(c), q = J(), k = !!m.startAdornment, R = !!(o && Array.isArray(e) && e.length > 0), l = X(() => ({
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: k,
49
- hasChips: R
50
- }), [r, a, t, o, i, s, k, R]), A = Y({
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: y,
55
+ handleDelete: g,
57
56
  disabled: t,
58
- startAdornment: N,
57
+ startAdornment: j,
59
58
  getOptionStartAdornment: h,
60
59
  getOptionEndAdornment: u,
61
60
  getOptionDescription: f
62
- }), C = Z({
63
- loading: D,
61
+ }), C = Y({
62
+ loading: V,
64
63
  adjustedSize: r,
65
64
  ownerState: l,
66
- refresh: E,
67
- handleRefresh: b,
65
+ refresh: D,
66
+ handleRefresh: y,
68
67
  disabled: t,
69
- onOpenLocal: L,
70
- open: g,
68
+ onOpenLocal: b,
69
+ open: I,
71
70
  readOnly: s,
72
71
  multiple: o,
73
72
  selectedValue: e,
74
73
  getOptionEndAdornment: u,
75
- endAdornment: V
76
- }), F = j((S, n) => {
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 $(S, {
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 = j((S) => {
96
- const { InputLabelProps: n, inputProps: O, InputProps: P, ...K } = S, { className: te, ...T } = P, { className: ne, ...W } = O;
97
- return /* @__PURE__ */ G(
98
- ee,
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, id: I },
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: q,
136
+ isSkeleton: _,
139
137
  currentSize: r,
140
- memoizedRenderOption: F,
138
+ memoizedRenderOption: q,
141
139
  memoizedRenderInput: H,
142
140
  // propiedades de useValuesAndHandlers
143
- open: g,
141
+ open: I,
144
142
  selectedValue: e,
145
- inputValue: M,
143
+ inputValue: E,
146
144
  isOptionEqualToValueLocal: p,
147
- handleDelete: y,
148
- handleRefresh: b,
149
- handleChange: v,
150
- handleInputChange: w,
151
- onCloseLocal: x,
152
- onOpenLocal: L,
145
+ handleDelete: g,
146
+ handleRefresh: y,
147
+ handleChange: M,
148
+ handleInputChange: v,
149
+ onCloseLocal: w,
150
+ onOpenLocal: b,
153
151
  getOptionLabelLocal: d,
154
- checkKeyDown: B,
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
- me as useAutocomplete
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"}
@@ -0,0 +1,7 @@
1
+ function d(i, c, l, n) {
2
+ const e = l.filter((t) => t > 0).slice(0, n), r = e.reduce((t, s) => t + s, 0);
3
+ return Math.max(i - r - c * e.length, 0);
4
+ }
5
+ export {
6
+ d as calculateLeftoverWidth
7
+ };
@@ -1,2 +1,3 @@
1
+ export { calculateLeftoverWidth } from './calculateLeftoverWidth';
1
2
  export { calculateVisibleChipsCount } from './calculateVisibleChipsCount';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -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":"AAEA,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;;;;;;qBA8JD,YAAY,CAAC,IAAI,CAAC,MAAM,WAAW,GAAG,IAAI;yBAcvE,WAAW,GAAG,IAAI;wBAalB,WAAW,GAAG,IAAI;wBAYlB,WAAW,GAAG,IAAI;EA4F1B"}
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 U, useEffect as m, useCallback as h, useMemo as q } from "react";
2
- import { calculateVisibleChipsCount as V } from "./helpers/calculateVisibleChipsCount.js";
3
- const ee = [];
4
- function se(t, x = {}) {
5
- const { deferMeasurement: f = !1 } = x, v = c(null), b = c(null), C = c(null), M = c(null), W = c(null), R = c(/* @__PURE__ */ new Map()), a = c(/* @__PURE__ */ new Map()), [o, p] = U(null), [S, z] = U(/* @__PURE__ */ new Set()), u = c(null);
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 = b.current;
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 w = R.current.get(l.id);
21
- w && w.offsetWidth > 0 && (r = r || !a.current.has(l.id), a.current.set(l.id, w.offsetWidth));
22
- }), r && z(new Set(a.current.keys())), !t.every((l) => a.current.has(l.id))) {
23
- u.current === null && (u.current = requestAnimationFrame(() => {
24
- u.current = null, y.current?.();
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), j = parseFloat(i.paddingLeft) || 0, D = parseFloat(i.paddingRight) || 0, H = parseFloat(F.paddingLeft) || 0, J = parseFloat(F.paddingRight) || 0, d = parseFloat(F.gap) || 0, E = e.getBoundingClientRect().width || e.clientWidth;
29
- if (E === 0)
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 I = M.current?.offsetWidth ?? 0, K = I > 0 ? I + d : 0, L = W.current?.offsetWidth ?? 0, Q = L > 0 ? L + d : 0, O = E - j - D - H - J - K - Q, P = t.map((l) => a.current.get(l.id) ?? 0);
32
- if (V(O, d, P) >= t.length) {
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 k = C.current?.offsetWidth ?? 0, X = k > 0 ? k + d : 0, Z = O - X, $ = V(Z, d, P);
37
- p($);
38
- }, [t]), y = c(null);
39
- y.current = s, m(
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
- u.current !== null && cancelAnimationFrame(u.current);
42
+ d.current !== null && cancelAnimationFrame(d.current);
42
43
  },
43
44
  []
44
45
  );
45
- const B = h((e, n) => {
46
+ const Y = h((e, n) => {
46
47
  n ? R.current.set(e, n) : R.current.delete(e);
47
- }, []), G = h(
48
+ }, []), _ = h(
48
49
  (e) => {
49
- C.current = e, s();
50
+ M.current = e, s();
50
51
  },
51
52
  [s]
52
- ), N = h(
53
+ ), j = h(
53
54
  (e) => {
54
- M.current = e, s();
55
+ S.current = e, s();
55
56
  },
56
57
  [s]
57
- ), T = h(
58
+ ), D = h(
58
59
  (e) => {
59
- W.current = e, s();
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 = q(
80
- () => f && o !== null ? t.filter((e) => !S.has(e.id)) : ee,
81
- [t, f, o, S]
82
- ), { visibleFilters: Y, overflowFilters: _ } = q(() => {
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), A = new Set(r.map((i) => i.id));
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) => !A.has(i.id))
92
+ overflowFilters: t.filter((i) => !L.has(i.id))
92
93
  };
93
94
  }, [t, o, g]);
94
95
  return {
95
- visibleFilters: Y,
96
- overflowFilters: _,
96
+ visibleFilters: H,
97
+ overflowFilters: J,
97
98
  measuringFilters: g,
99
+ leftoverWidth: N,
98
100
  parentRef: v,
99
- containerRef: b,
100
- setChipRef: B,
101
- setMoreChipRef: G,
102
- setActionsRef: N,
103
- setLeadingRef: T
101
+ containerRef: C,
102
+ setChipRef: Y,
103
+ setMoreChipRef: _,
104
+ setActionsRef: j,
105
+ setLeadingRef: D
104
106
  };
105
107
  }
106
108
  export {
107
- se as useChipsOverflow
109
+ ae as useChipsOverflow
108
110
  };