@m4l/gclick 0.28.0 → 0.29.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 (139) hide show
  1. package/@types/types.d.ts +19 -0
  2. package/_virtual/react-dom-server-legacy.browser.development.js +4 -0
  3. package/_virtual/react-dom-server-legacy.browser.production.js +4 -0
  4. package/_virtual/react-dom-server.browser.development.js +4 -0
  5. package/_virtual/react-dom-server.browser.production.js +4 -0
  6. package/_virtual/server.browser.js +5 -0
  7. package/_virtual/server.browser2.js +4 -0
  8. package/components/CheckableDevicesPicker/CheckableDevicesPicker.d.ts +13 -0
  9. package/components/CheckableDevicesPicker/CheckableDevicesPicker.d.ts.map +1 -0
  10. package/components/CheckableDevicesPicker/CheckableDevicesPicker.js +237 -0
  11. package/components/CheckableDevicesPicker/CheckableDevicesPicker.styles.d.ts +3 -0
  12. package/components/CheckableDevicesPicker/CheckableDevicesPicker.styles.d.ts.map +1 -0
  13. package/components/CheckableDevicesPicker/CheckableDevicesPicker.styles.js +157 -0
  14. package/components/CheckableDevicesPicker/constants.d.ts +22 -0
  15. package/components/CheckableDevicesPicker/constants.d.ts.map +1 -0
  16. package/components/CheckableDevicesPicker/constants.js +13 -0
  17. package/components/CheckableDevicesPicker/dictionary.d.ts +15 -0
  18. package/components/CheckableDevicesPicker/dictionary.d.ts.map +1 -0
  19. package/components/CheckableDevicesPicker/dictionary.js +15 -0
  20. package/components/CheckableDevicesPicker/helpers/resolveDeviceGroup.d.ts +11 -0
  21. package/components/CheckableDevicesPicker/helpers/resolveDeviceGroup.d.ts.map +1 -0
  22. package/components/CheckableDevicesPicker/helpers/resolveDeviceGroup.js +23 -0
  23. package/components/CheckableDevicesPicker/helpers/toDeviceArray.d.ts +7 -0
  24. package/components/CheckableDevicesPicker/helpers/toDeviceArray.d.ts.map +1 -0
  25. package/components/CheckableDevicesPicker/helpers/toDeviceArray.js +6 -0
  26. package/components/CheckableDevicesPicker/hooks/types.d.ts +178 -0
  27. package/components/CheckableDevicesPicker/hooks/types.d.ts.map +1 -0
  28. package/components/CheckableDevicesPicker/hooks/useDeviceGroups.d.ts +13 -0
  29. package/components/CheckableDevicesPicker/hooks/useDeviceGroups.d.ts.map +1 -0
  30. package/components/CheckableDevicesPicker/hooks/useDeviceGroups.js +51 -0
  31. package/components/CheckableDevicesPicker/hooks/useDevicesAsyncOptions.d.ts +13 -0
  32. package/components/CheckableDevicesPicker/hooks/useDevicesAsyncOptions.d.ts.map +1 -0
  33. package/components/CheckableDevicesPicker/hooks/useDevicesAsyncOptions.js +69 -0
  34. package/components/CheckableDevicesPicker/hooks/useDevicesSelection.d.ts +12 -0
  35. package/components/CheckableDevicesPicker/hooks/useDevicesSelection.d.ts.map +1 -0
  36. package/components/CheckableDevicesPicker/hooks/useDevicesSelection.js +26 -0
  37. package/components/CheckableDevicesPicker/hooks/usePanelColumns.d.ts +12 -0
  38. package/components/CheckableDevicesPicker/hooks/usePanelColumns.d.ts.map +1 -0
  39. package/components/CheckableDevicesPicker/hooks/usePanelColumns.js +30 -0
  40. package/components/CheckableDevicesPicker/index.d.ts +7 -0
  41. package/components/CheckableDevicesPicker/index.d.ts.map +1 -0
  42. package/components/CheckableDevicesPicker/slots/CheckableDevicesPickerEnum.d.ts +23 -0
  43. package/components/CheckableDevicesPicker/slots/CheckableDevicesPickerEnum.d.ts.map +1 -0
  44. package/components/CheckableDevicesPicker/slots/CheckableDevicesPickerEnum.js +4 -0
  45. package/components/CheckableDevicesPicker/slots/CheckableDevicesPickerSlots.d.ts +31 -0
  46. package/components/CheckableDevicesPicker/slots/CheckableDevicesPickerSlots.d.ts.map +1 -0
  47. package/components/CheckableDevicesPicker/slots/CheckableDevicesPickerSlots.js +49 -0
  48. package/components/CheckableDevicesPicker/slots/index.d.ts +3 -0
  49. package/components/CheckableDevicesPicker/slots/index.d.ts.map +1 -0
  50. package/components/CheckableDevicesPicker/types.d.ts +210 -0
  51. package/components/CheckableDevicesPicker/types.d.ts.map +1 -0
  52. package/components/DevicesPicker/DevicesPicker.d.ts +15 -0
  53. package/components/DevicesPicker/DevicesPicker.d.ts.map +1 -0
  54. package/components/DevicesPicker/DevicesPicker.js +311 -0
  55. package/components/DevicesPicker/DevicesPicker.styles.d.ts +3 -0
  56. package/components/DevicesPicker/DevicesPicker.styles.d.ts.map +1 -0
  57. package/components/DevicesPicker/DevicesPicker.styles.js +373 -0
  58. package/components/DevicesPicker/constants.d.ts +51 -0
  59. package/components/DevicesPicker/constants.d.ts.map +1 -0
  60. package/components/DevicesPicker/constants.js +30 -0
  61. package/components/DevicesPicker/dictionary.d.ts +17 -0
  62. package/components/DevicesPicker/dictionary.d.ts.map +1 -0
  63. package/components/DevicesPicker/dictionary.js +17 -0
  64. package/components/DevicesPicker/index.d.ts +8 -0
  65. package/components/DevicesPicker/index.d.ts.map +1 -0
  66. package/components/DevicesPicker/slots/DevicesPickerEnum.d.ts +61 -0
  67. package/components/DevicesPicker/slots/DevicesPickerEnum.d.ts.map +1 -0
  68. package/components/DevicesPicker/slots/DevicesPickerEnum.js +4 -0
  69. package/components/DevicesPicker/slots/DevicesPickerSlots.d.ts +88 -0
  70. package/components/DevicesPicker/slots/DevicesPickerSlots.d.ts.map +1 -0
  71. package/components/DevicesPicker/slots/DevicesPickerSlots.js +125 -0
  72. package/components/DevicesPicker/slots/index.d.ts +3 -0
  73. package/components/DevicesPicker/slots/index.d.ts.map +1 -0
  74. package/components/DevicesPicker/subcomponents/DeviceCard/DeviceCard.d.ts +8 -0
  75. package/components/DevicesPicker/subcomponents/DeviceCard/DeviceCard.d.ts.map +1 -0
  76. package/components/DevicesPicker/subcomponents/DeviceCard/DeviceCard.js +77 -0
  77. package/components/DevicesPicker/subcomponents/DeviceCard/index.d.ts +3 -0
  78. package/components/DevicesPicker/subcomponents/DeviceCard/index.d.ts.map +1 -0
  79. package/components/DevicesPicker/subcomponents/DeviceCard/types.d.ts +42 -0
  80. package/components/DevicesPicker/subcomponents/DeviceCard/types.d.ts.map +1 -0
  81. package/components/DevicesPicker/subcomponents/DevicesPickerSkeleton/DevicesPickerSkeleton.d.ts +10 -0
  82. package/components/DevicesPicker/subcomponents/DevicesPickerSkeleton/DevicesPickerSkeleton.d.ts.map +1 -0
  83. package/components/DevicesPicker/subcomponents/DevicesPickerSkeleton/DevicesPickerSkeleton.js +35 -0
  84. package/components/DevicesPicker/subcomponents/DevicesPickerSkeleton/index.d.ts +3 -0
  85. package/components/DevicesPicker/subcomponents/DevicesPickerSkeleton/index.d.ts.map +1 -0
  86. package/components/DevicesPicker/subcomponents/DevicesPickerSkeleton/types.d.ts +11 -0
  87. package/components/DevicesPicker/subcomponents/DevicesPickerSkeleton/types.d.ts.map +1 -0
  88. package/components/DevicesPicker/subcomponents/SelectedDevicesList/SelectedDevicesList.d.ts +11 -0
  89. package/components/DevicesPicker/subcomponents/SelectedDevicesList/SelectedDevicesList.d.ts.map +1 -0
  90. package/components/DevicesPicker/subcomponents/SelectedDevicesList/SelectedDevicesList.js +61 -0
  91. package/components/DevicesPicker/subcomponents/SelectedDevicesList/index.d.ts +3 -0
  92. package/components/DevicesPicker/subcomponents/SelectedDevicesList/index.d.ts.map +1 -0
  93. package/components/DevicesPicker/subcomponents/SelectedDevicesList/types.d.ts +32 -0
  94. package/components/DevicesPicker/subcomponents/SelectedDevicesList/types.d.ts.map +1 -0
  95. package/components/DevicesPicker/types.d.ts +91 -0
  96. package/components/DevicesPicker/types.d.ts.map +1 -0
  97. package/components/RHFs/RHFCheckableDevicesPicker/RHFCheckableDevicesPicker.d.ts +23 -0
  98. package/components/RHFs/RHFCheckableDevicesPicker/RHFCheckableDevicesPicker.d.ts.map +1 -0
  99. package/components/RHFs/RHFCheckableDevicesPicker/RHFCheckableDevicesPicker.js +6 -0
  100. package/components/RHFs/RHFCheckableDevicesPicker/index.d.ts +3 -0
  101. package/components/RHFs/RHFCheckableDevicesPicker/index.d.ts.map +1 -0
  102. package/components/RHFs/RHFCheckableDevicesPicker/types.d.ts +10 -0
  103. package/components/RHFs/RHFCheckableDevicesPicker/types.d.ts.map +1 -0
  104. package/components/RHFs/RHFDevicesPicker/RHFDevicesPicker.d.ts +21 -0
  105. package/components/RHFs/RHFDevicesPicker/RHFDevicesPicker.d.ts.map +1 -0
  106. package/components/RHFs/RHFDevicesPicker/RHFDevicesPicker.js +6 -0
  107. package/components/RHFs/RHFDevicesPicker/index.d.ts +3 -0
  108. package/components/RHFs/RHFDevicesPicker/index.d.ts.map +1 -0
  109. package/components/RHFs/RHFDevicesPicker/types.d.ts +9 -0
  110. package/components/RHFs/RHFDevicesPicker/types.d.ts.map +1 -0
  111. package/components/RHFs/renderAsRegistry.d.ts +33 -0
  112. package/components/RHFs/renderAsRegistry.d.ts.map +1 -0
  113. package/components/RHFs/renderAsRegistry.js +7 -0
  114. package/components/index.d.ts +6 -0
  115. package/components/index.d.ts.map +1 -1
  116. package/helpers/index.d.ts +3 -0
  117. package/helpers/index.d.ts.map +1 -0
  118. package/helpers/resolveDeviceIcon/constants.d.ts +31 -0
  119. package/helpers/resolveDeviceIcon/constants.d.ts.map +1 -0
  120. package/helpers/resolveDeviceIcon/constants.js +8 -0
  121. package/helpers/resolveDeviceIcon/deviceIconComponents.d.ts +19 -0
  122. package/helpers/resolveDeviceIcon/deviceIconComponents.d.ts.map +1 -0
  123. package/helpers/resolveDeviceIcon/deviceIconComponents.js +19 -0
  124. package/helpers/resolveDeviceIcon/index.d.ts +3 -0
  125. package/helpers/resolveDeviceIcon/index.d.ts.map +1 -0
  126. package/helpers/resolveDeviceIcon/resolveDeviceIcon.d.ts +28 -0
  127. package/helpers/resolveDeviceIcon/resolveDeviceIcon.d.ts.map +1 -0
  128. package/helpers/resolveDeviceIcon/resolveDeviceIcon.js +42 -0
  129. package/helpers/resolveDeviceLabels/index.d.ts +3 -0
  130. package/helpers/resolveDeviceLabels/index.d.ts.map +1 -0
  131. package/helpers/resolveDeviceLabels/resolveDeviceLabels.d.ts +22 -0
  132. package/helpers/resolveDeviceLabels/resolveDeviceLabels.d.ts.map +1 -0
  133. package/helpers/resolveDeviceLabels/resolveDeviceLabels.js +10 -0
  134. package/helpers/resolveDeviceLabels/types.d.ts +19 -0
  135. package/helpers/resolveDeviceLabels/types.d.ts.map +1 -0
  136. package/index.d.ts +1 -0
  137. package/index.d.ts.map +1 -1
  138. package/index.js +275 -221
  139. package/package.json +2 -2
@@ -0,0 +1,311 @@
1
+ import { jsx as o, jsxs as d, Fragment as Ce } from "@emotion/react/jsx-runtime";
2
+ import { useRef as ue, useState as w, useCallback as c, useMemo as be } from "react";
3
+ import K from "clsx";
4
+ import { useModuleDictionary as De } from "@m4l/core";
5
+ import { Icon as Se } from "@m4l/base";
6
+ import { ConectivityDispositiveOutlined as Ie, ArrowChevronMdUpOutlined as Pe, ArrowChevronMdDownOutlined as ye } from "@m4l/icons";
7
+ import { useChipsOverflow as we, Popover as U } from "@m4l/components";
8
+ import { useDevicesSelection as Re } from "../CheckableDevicesPicker/hooks/useDevicesSelection.js";
9
+ import { DEVICES_PICKER_PARTIAL_CARD_MIN_WIDTH as Te, DEVICES_PICKER_CLASSES as r } from "./constants.js";
10
+ import { DICCTIONARY as R } from "./dictionary.js";
11
+ import { resolveDeviceIcon as Ne } from "../../helpers/resolveDeviceIcon/resolveDeviceIcon.js";
12
+ import { RootStyled as V, TriggerStyled as Oe, PlaceholderContainerStyled as Ae, PlaceholderIconStyled as Le, PlaceholderStyled as ke, CardsContainerStyled as Ee, DeviceCardWrapperStyled as G, PartialCardWrapperStyled as _e, MeasuringLayerStyled as xe, OverflowToggleStyled as Fe, ChevronButtonStyled as Me, PanelActionsStyled as We, PanelActionDoneStyled as ze } from "./slots/DevicesPickerSlots.js";
13
+ import { DevicesPickerSkeleton as $e } from "./subcomponents/DevicesPickerSkeleton/DevicesPickerSkeleton.js";
14
+ import { resolveDeviceSubtitle as v, resolveDeviceTitle as C } from "../../helpers/resolveDeviceLabels/resolveDeviceLabels.js";
15
+ import { CheckableDevicesPicker as Be } from "../CheckableDevicesPicker/CheckableDevicesPicker.js";
16
+ import { SelectedDevicesList as je } from "./subcomponents/SelectedDevicesList/SelectedDevicesList.js";
17
+ import { DeviceCard as T } from "./subcomponents/DeviceCard/DeviceCard.js";
18
+ function lo(H) {
19
+ const {
20
+ endPoint: Y,
21
+ timeout: q,
22
+ parms: J,
23
+ resultField: Q,
24
+ isRemote: X,
25
+ isExternalUrl: Z,
26
+ responseToCamelCase: ee,
27
+ shouldFetch: oe,
28
+ value: N,
29
+ onChange: O,
30
+ multiple: i = !0,
31
+ disabled: A = !1,
32
+ loading: L = !1,
33
+ error: re = !1,
34
+ size: n = "medium",
35
+ showOverflowToggle: te = !0,
36
+ showDepartments: ae,
37
+ showIds: ie,
38
+ searchable: ne = !0,
39
+ placeholder: le,
40
+ className: k,
41
+ dataTestid: E,
42
+ getDeviceGroup: se,
43
+ onChangeFilterParms: _
44
+ } = H;
45
+ if (i && _)
46
+ throw new Error(
47
+ "multiple cannot be enabled when onChangeFilterParms is defined; define the filter in parms if needed."
48
+ );
49
+ const { getLabel: u } = De(), b = ue(null), [l, x] = w(!1), [F, D] = w(!1), [de, ce] = w(!1), m = c(
50
+ (e) => Ne(e.deviceIcon?.iconId),
51
+ []
52
+ ), { selectedDevices: p, handleRemove: S } = Re({
53
+ value: N,
54
+ multiple: i,
55
+ onChange: O
56
+ }), {
57
+ visibleFilters: I,
58
+ overflowFilters: P,
59
+ measuringFilters: h,
60
+ leftoverWidth: M,
61
+ parentRef: me,
62
+ containerRef: pe,
63
+ setChipRef: W,
64
+ setMoreChipRef: he,
65
+ setActionsRef: fe
66
+ } = we(p, { deferMeasurement: !0 }), { visibleCards: ge, partialCard: a, hiddenCards: z } = be(() => {
67
+ const e = new Set(h.map((s) => s.id)), t = P.find((s) => !e.has(s.id)), j = M >= Te || I.length === 0 ? t : void 0;
68
+ return {
69
+ visibleCards: I,
70
+ partialCard: j,
71
+ hiddenCards: P.filter((s) => s.id !== j?.id)
72
+ };
73
+ }, [I, P, h, M]), $ = c((e) => {
74
+ e?.stopPropagation(), D(!1), x((t) => !t);
75
+ }, []), f = c(() => x(!1), []), y = c((e) => {
76
+ e?.stopPropagation(), l && f(), D((t) => !t);
77
+ }, [l, f]), ve = c(() => D(!1), []), B = L || de, g = {
78
+ size: n,
79
+ panelOpen: l,
80
+ listOpen: F,
81
+ error: re,
82
+ disabled: A,
83
+ loading: B,
84
+ hasSelection: p.length > 0
85
+ };
86
+ return L ? /* @__PURE__ */ o(
87
+ V,
88
+ {
89
+ ownerState: g,
90
+ className: K(k, r.root),
91
+ "data-testid": E,
92
+ children: /* @__PURE__ */ o($e, { size: n })
93
+ }
94
+ ) : /* @__PURE__ */ d(Ce, { children: [
95
+ /* @__PURE__ */ o(
96
+ V,
97
+ {
98
+ ref: me,
99
+ ownerState: g,
100
+ className: K(k, r.root),
101
+ "data-testid": E,
102
+ children: /* @__PURE__ */ d(
103
+ Oe,
104
+ {
105
+ ref: b,
106
+ ownerState: g,
107
+ className: r.trigger,
108
+ onClick: $,
109
+ children: [
110
+ p.length === 0 ? /* @__PURE__ */ d(
111
+ Ae,
112
+ {
113
+ className: r.placeholderContainer,
114
+ children: [
115
+ /* @__PURE__ */ o(Le, { className: r.placeholderIcon, children: /* @__PURE__ */ o(Se, { src: /* @__PURE__ */ o(Ie, {}), color: "text.secondary" }) }),
116
+ /* @__PURE__ */ o(
117
+ ke,
118
+ {
119
+ className: r.placeholder,
120
+ variant: "bodyStandard",
121
+ color: "text.disabled",
122
+ children: le ?? u(R.label_placeholder)
123
+ }
124
+ )
125
+ ]
126
+ }
127
+ ) : /* @__PURE__ */ d(
128
+ Ee,
129
+ {
130
+ ref: pe,
131
+ className: r.cardsContainer,
132
+ children: [
133
+ ge.map((e) => /* @__PURE__ */ o(
134
+ G,
135
+ {
136
+ ref: (t) => W(e.id, t),
137
+ className: r.deviceCardWrapper,
138
+ children: /* @__PURE__ */ o(
139
+ T,
140
+ {
141
+ deviceId: e.id,
142
+ name: C(e),
143
+ subtitle: v(e),
144
+ icon: m(e),
145
+ disableRemove: !i,
146
+ onRemove: () => S(e),
147
+ onClick: y,
148
+ dataTestid: `${r.deviceCard}-${e.id}`
149
+ }
150
+ )
151
+ },
152
+ e.id
153
+ )),
154
+ a && // No lleva ref de medición a propósito: su ancho natural ya se
155
+ // cacheó en la pasada inicial y aquí sale encogido, así que
156
+ // registrarlo corrompería el cálculo del overflow.
157
+ /* @__PURE__ */ o(
158
+ _e,
159
+ {
160
+ className: r.partialCardWrapper,
161
+ children: /* @__PURE__ */ o(
162
+ T,
163
+ {
164
+ deviceId: a.id,
165
+ name: C(a),
166
+ subtitle: v(a),
167
+ icon: m(a),
168
+ disableRemove: !i,
169
+ onRemove: () => S(a),
170
+ onClick: y,
171
+ dataTestid: `${r.deviceCard}-${a.id}`
172
+ }
173
+ )
174
+ },
175
+ a.id
176
+ )
177
+ ]
178
+ }
179
+ ),
180
+ h.length > 0 && /* @__PURE__ */ o(
181
+ xe,
182
+ {
183
+ className: r.measuringLayer,
184
+ "aria-hidden": !0,
185
+ children: h.map((e) => /* @__PURE__ */ o(
186
+ G,
187
+ {
188
+ ref: (t) => W(e.id, t),
189
+ className: r.deviceCardWrapper,
190
+ children: /* @__PURE__ */ o(
191
+ T,
192
+ {
193
+ deviceId: e.id,
194
+ name: C(e),
195
+ subtitle: v(e),
196
+ icon: m(e),
197
+ disableRemove: !i
198
+ }
199
+ )
200
+ },
201
+ e.id
202
+ ))
203
+ }
204
+ ),
205
+ te && z.length > 0 && /* @__PURE__ */ o(
206
+ Fe,
207
+ {
208
+ ref: he,
209
+ ownerState: g,
210
+ className: r.overflowToggle,
211
+ dataTestId: r.overflowToggle,
212
+ variant: "contained",
213
+ color: "default",
214
+ size: n,
215
+ label: `+${z.length}`,
216
+ onToggle: y
217
+ }
218
+ ),
219
+ /* @__PURE__ */ o(
220
+ Me,
221
+ {
222
+ ref: fe,
223
+ className: r.chevronButton,
224
+ dataTestId: r.chevronButton,
225
+ icon: l ? /* @__PURE__ */ o(Pe, {}) : /* @__PURE__ */ o(ye, {}),
226
+ variant: "text",
227
+ size: n,
228
+ disabled: A || B,
229
+ "aria-label": u(R.label_open_panel),
230
+ onClick: $
231
+ }
232
+ )
233
+ ]
234
+ }
235
+ )
236
+ }
237
+ ),
238
+ /* @__PURE__ */ d(
239
+ U,
240
+ {
241
+ open: l,
242
+ anchorEl: b.current,
243
+ onClose: f,
244
+ arrowType: "no-arrow",
245
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
246
+ transformOrigin: { vertical: "top", horizontal: "right" },
247
+ children: [
248
+ /* @__PURE__ */ o(
249
+ Be,
250
+ {
251
+ open: l,
252
+ endPoint: Y,
253
+ timeout: q,
254
+ parms: J,
255
+ resultField: Q,
256
+ isRemote: X,
257
+ isExternalUrl: Z,
258
+ responseToCamelCase: ee,
259
+ shouldFetch: oe,
260
+ onChangeFilterParms: _,
261
+ value: N,
262
+ onChange: O,
263
+ multiple: i,
264
+ size: n,
265
+ searchable: ne,
266
+ showDepartments: ae,
267
+ showIds: ie,
268
+ onLoadingChange: ce,
269
+ getDeviceGroup: se
270
+ }
271
+ ),
272
+ /* @__PURE__ */ o(We, { className: r.panelActions, children: /* @__PURE__ */ o(
273
+ ze,
274
+ {
275
+ className: r.panelActionDone,
276
+ "data-testid": r.panelActionDone,
277
+ type: "button",
278
+ size: n,
279
+ label: u(R.label_done),
280
+ onClick: f
281
+ }
282
+ ) })
283
+ ]
284
+ }
285
+ ),
286
+ /* @__PURE__ */ o(
287
+ U,
288
+ {
289
+ open: F,
290
+ anchorEl: b.current,
291
+ onClose: ve,
292
+ arrowType: "no-arrow",
293
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
294
+ transformOrigin: { vertical: -3, horizontal: "right" },
295
+ children: /* @__PURE__ */ o(
296
+ je,
297
+ {
298
+ devices: p,
299
+ getOptionLabel: C,
300
+ getDeviceSubtitle: v,
301
+ getDeviceIcon: m,
302
+ onRemove: S
303
+ }
304
+ )
305
+ }
306
+ )
307
+ ] });
308
+ }
309
+ export {
310
+ lo as DevicesPicker
311
+ };
@@ -0,0 +1,3 @@
1
+ import { DevicesPickerStyles } from './types';
2
+ export declare const devicesPickerStyles: DevicesPickerStyles;
3
+ //# sourceMappingURL=DevicesPicker.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevicesPicker.styles.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/DevicesPicker/DevicesPicker.styles.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,mBAAmB,EAAE,mBAiXjC,CAAC"}
@@ -0,0 +1,373 @@
1
+ import { getSizeStyles as r, getTypographyStyles as d, BUTTON_CLASSES as t } from "@m4l/components";
2
+ import { DEVICES_PICKER_WIDTH as n, DEVICES_PICKER_CARD_MAX_WIDTH as l, DEVICES_PICKER_CARD_MIN_HEIGHT as o, DEVICES_PICKER_SKELETON as p, DEVICES_PICKER_SELECTED_LIST_WIDTH as c, DEVICES_PICKER_SELECTED_LIST_HEIGHT as g, DEVICES_PICKER_CLASSES as s } from "./constants.js";
3
+ const f = {
4
+ /**
5
+ * root: Full-width wrapper. The overflow measurement reads its width, so it
6
+ * must not depend on how many cards are currently painted.
7
+ */
8
+ root: () => ({
9
+ // El ancho definido es lo que ve un padre shrink-to-fit, así no crece con
10
+ // cada card. El mínimo sigue al padre cuando es mayor y se planta en el
11
+ // ancho base cuando es menor, para no deformarse al encoger la ventana.
12
+ width: n,
13
+ minWidth: `max(100%, ${n}px)`
14
+ }),
15
+ /**
16
+ * trigger: The visible row. It takes the full width of the field, as the
17
+ * master asks for the picker inside a form field, and what does not fit goes
18
+ * to the +N toggle, never to a silent clipping.
19
+ * The master paints no stroke and no fill at rest: only the two expanded
20
+ * surfaces paint it, in primary, and error replaces that tone. The stroke is
21
+ * kept transparent so turning it on never shifts the layout by a pixel.
22
+ */
23
+ trigger: ({ theme: e, ownerState: i }) => ({
24
+ display: "inline-flex",
25
+ alignItems: "center",
26
+ width: "100%",
27
+ maxWidth: "100%",
28
+ gap: e.vars.size.baseSpacings["sp1-5"],
29
+ padding: e.vars.size.baseSpacings["sp0-5"],
30
+ borderRadius: e.vars.size.borderRadius.r2,
31
+ border: "1px solid transparent",
32
+ ...(i?.panelOpen || i?.listOpen) && {
33
+ borderColor: e.vars.palette.primary.enabled
34
+ },
35
+ ...i?.error && {
36
+ borderColor: e.vars.palette.error.enabled
37
+ },
38
+ ...i?.disabled && {
39
+ opacity: 0.6,
40
+ pointerEvents: "none"
41
+ }
42
+ }),
43
+ /**
44
+ * deviceCardWrapper: Carries the measuring ref of each card. inline-flex and
45
+ * flexShrink 0 keep its width equal to the card's natural width.
46
+ */
47
+ deviceCardWrapper: () => ({
48
+ display: "inline-flex",
49
+ flexShrink: 0,
50
+ // Un alias largo se comía el renglón entero y dejaba a las demás cards
51
+ // reducidas a su icono, así que aquí se topa y el texto trunca.
52
+ maxWidth: l,
53
+ [`& .${s.deviceCard}`]: {
54
+ maxWidth: "100%",
55
+ minWidth: 0
56
+ }
57
+ }),
58
+ /**
59
+ * measuringLayer: Holds the cards whose width is still unknown. It is taken
60
+ * out of the layout so they can be measured without the row opening up for a
61
+ * frame, which is what made the +N jump on every addition.
62
+ */
63
+ measuringLayer: () => ({
64
+ position: "fixed",
65
+ top: 0,
66
+ left: 0,
67
+ visibility: "hidden",
68
+ pointerEvents: "none",
69
+ display: "flex"
70
+ }),
71
+ /**
72
+ * partialCardWrapper: The card that does not fit whole. It is the only one
73
+ * allowed to shrink, so it takes the leftover space and truncates instead of
74
+ * leaving a gap next to the +N toggle.
75
+ */
76
+ partialCardWrapper: () => ({
77
+ display: "inline-flex",
78
+ flexShrink: 1,
79
+ minWidth: 0,
80
+ [`& .${s.deviceCard}`]: {
81
+ flexShrink: 1,
82
+ minWidth: 0
83
+ }
84
+ }),
85
+ /**
86
+ * cardsContainer: Holds the cards that fit in the available space.
87
+ * overflow is hidden on purpose: the hidden ones are reported by the +N
88
+ * toggle, which is the only supported way to reach them.
89
+ */
90
+ cardsContainer: ({ theme: e }) => ({
91
+ display: "flex",
92
+ alignItems: "center",
93
+ // Abraza las cards: el hueco que sobre queda entre ellas y el +N, que se
94
+ // ancla a la derecha junto al chevron.
95
+ flex: "0 1 auto",
96
+ minWidth: 0,
97
+ overflow: "hidden",
98
+ gap: e.vars.size.baseSpacings["sp1-5"]
99
+ }),
100
+ /**
101
+ * placeholderContainer: Leading icon plus placeholder text.
102
+ */
103
+ placeholderContainer: ({ theme: e }) => ({
104
+ display: "flex",
105
+ alignItems: "center",
106
+ flex: "1 1 auto",
107
+ minWidth: 0,
108
+ gap: e.vars.size.baseSpacings.sp2
109
+ }),
110
+ /**
111
+ * placeholderIcon: Tinted box around the device icon, as in the master.
112
+ */
113
+ placeholderIcon: ({ theme: e }) => ({
114
+ display: "flex",
115
+ alignItems: "center",
116
+ justifyContent: "center",
117
+ flexShrink: 0,
118
+ padding: e.vars.size.baseSpacings.sp1,
119
+ borderRadius: e.vars.size.borderRadius.r2,
120
+ backgroundColor: e.vars.palette.chips.default.contained.backgroundColor,
121
+ ...r(e, "medium", "container", (i) => ({
122
+ width: i,
123
+ height: i
124
+ }))
125
+ }),
126
+ /**
127
+ * placeholder: Text shown when there is no selection.
128
+ */
129
+ placeholder: ({ theme: e }) => ({
130
+ padding: `0 ${e.vars.size.baseSpacings.sp1}`,
131
+ whiteSpace: "nowrap"
132
+ }),
133
+ /**
134
+ * overflowToggle: ToggleButton with the number of hidden cards.
135
+ * Stretches to the full height of the cards row, as in the master, and turns
136
+ * primary while the selected-devices list is open.
137
+ */
138
+ overflowToggle: ({ theme: e, ownerState: i }) => ({
139
+ flexShrink: 0,
140
+ // Vive con el chevron, en el extremo derecho del trigger, no pegado a la
141
+ // última card. El chevron cede su propio margen automático: con dos, flex
142
+ // reparte el sobrante entre ambos y el +N se queda a medio camino.
143
+ marginLeft: "auto",
144
+ [`& + .${s.chevronButton}`]: {
145
+ marginLeft: 0
146
+ },
147
+ alignSelf: "stretch",
148
+ height: "auto",
149
+ "&&": {
150
+ backgroundColor: i?.listOpen ? e.vars.palette.chips.primary.contained.backgroundColor : e.vars.palette.default.enabled
151
+ },
152
+ // El Button pinta su label con su propia tipografía; hay que ganarle.
153
+ [`&&&& .${t.textButton}`]: {
154
+ ...d(
155
+ !!e.generalSettings?.isMobile,
156
+ i?.size || "medium",
157
+ "bodyDens"
158
+ ),
159
+ ...i?.listOpen && {
160
+ color: e.vars.palette.chips.primary.contained.color
161
+ }
162
+ }
163
+ }),
164
+ /**
165
+ * chevronButton: Opens and closes the selection panel.
166
+ * The IconButton sets its own square size inside a `&&&` block, so it is
167
+ * centered in the row instead of stretched: stretching against that fixed
168
+ * height pins it to the top of the cross axis.
169
+ */
170
+ chevronButton: ({ theme: e }) => ({
171
+ flexShrink: 0,
172
+ alignSelf: "center",
173
+ marginLeft: "auto",
174
+ borderRadius: e.vars.size.borderRadius["r1-5"]
175
+ }),
176
+ /**
177
+ * deviceCard: One selected device. Sits on top of the system Card, so only
178
+ * the layout of the internal slot is defined here: the master places it at
179
+ * 6px horizontal and 4px vertical, with the icon 6px from the text block.
180
+ * The width is reset because the system Card is full width by default and
181
+ * the trigger card has to hug its content.
182
+ */
183
+ deviceCard: ({ theme: e }) => ({
184
+ display: "flex",
185
+ alignItems: "center",
186
+ flexShrink: 0,
187
+ width: "auto",
188
+ minHeight: o,
189
+ gap: e.vars.size.baseSpacings["sp1-5"],
190
+ padding: `${e.vars.size.baseSpacings.sp1} ${e.vars.size.baseSpacings["sp1-5"]}`
191
+ }),
192
+ /**
193
+ * deviceCardIcon: Device icon wrapper inside the card.
194
+ */
195
+ deviceCardIcon: ({ theme: e }) => ({
196
+ display: "flex",
197
+ alignItems: "center",
198
+ justifyContent: "center",
199
+ flexShrink: 0,
200
+ borderRadius: e.vars.size.borderRadius.r1,
201
+ ...r(e, "medium", "container", (i) => ({
202
+ width: i,
203
+ height: i
204
+ }))
205
+ }),
206
+ /**
207
+ * deviceCardContent: Column with name, subtitle and id.
208
+ */
209
+ deviceCardContent: () => ({
210
+ display: "flex",
211
+ flexDirection: "column",
212
+ minWidth: 0,
213
+ flex: "1 1 auto"
214
+ }),
215
+ /**
216
+ * deviceCardName: First line of the card.
217
+ * No line-height override on purpose: `bodyStandard` is 11px on a 1.5 ratio,
218
+ * which already lands on the 16px line box the master declares.
219
+ */
220
+ deviceCardName: () => ({
221
+ whiteSpace: "nowrap"
222
+ }),
223
+ /**
224
+ * deviceCardSubtitle: Second line of the card: the plate the backend
225
+ * published as `name`, once the alias took the first line.
226
+ */
227
+ deviceCardSubtitle: () => ({
228
+ whiteSpace: "nowrap"
229
+ }),
230
+ /**
231
+ * deviceCardId: Third line of the card.
232
+ */
233
+ deviceCardId: () => ({
234
+ whiteSpace: "nowrap"
235
+ }),
236
+ /**
237
+ * deviceCardRemove: Removes this device from the selection.
238
+ */
239
+ deviceCardRemove: ({ theme: e, ownerState: i }) => ({
240
+ flexShrink: 0,
241
+ ...r(e, i?.size || "medium", "base", (a) => ({
242
+ width: a,
243
+ height: a
244
+ }))
245
+ }),
246
+ /**
247
+ * panelActions: Foot row of the selection panel. Without it the panel only
248
+ * closes by clicking outside, which users inside a filter popover never find.
249
+ */
250
+ panelActions: ({ theme: e }) => ({
251
+ display: "flex",
252
+ justifyContent: "flex-end",
253
+ padding: e.vars.size.baseSpacings.sp2
254
+ }),
255
+ /**
256
+ * panelActionDone: Close action of the selection panel.
257
+ */
258
+ panelActionDone: () => ({}),
259
+ /**
260
+ * selectedList: Surface of the selected-devices list, opened from the +N
261
+ * toggle. It is the only way to reach the cards that do not fit.
262
+ */
263
+ selectedList: ({ theme: e }) => ({
264
+ width: c,
265
+ display: "flex",
266
+ flexDirection: "column",
267
+ borderRadius: e.vars.size.borderRadius.r3,
268
+ overflow: "hidden"
269
+ }),
270
+ /**
271
+ * selectedListHeader: Title row of the selected-devices list. The master
272
+ * groups the icon and the label on the left and pushes the count chip to
273
+ * the opposite edge.
274
+ */
275
+ selectedListHeader: ({ theme: e }) => ({
276
+ display: "flex",
277
+ alignItems: "center",
278
+ justifyContent: "space-between",
279
+ gap: e.vars.size.baseSpacings.sp2,
280
+ padding: e.vars.size.baseSpacings.sp2
281
+ }),
282
+ /**
283
+ * selectedListTitle: Icon and label group at the start of the header.
284
+ */
285
+ selectedListTitle: ({ theme: e }) => ({
286
+ display: "flex",
287
+ alignItems: "center",
288
+ minWidth: 0,
289
+ gap: e.vars.size.baseSpacings.sp2
290
+ }),
291
+ /**
292
+ * selectedListCount: Count chip at the end of the header.
293
+ */
294
+ selectedListCount: () => ({
295
+ flexShrink: 0
296
+ }),
297
+ /**
298
+ * selectedListItems: Scrollable body of the selected-devices list.
299
+ */
300
+ selectedListItems: ({ theme: e }) => ({
301
+ display: "flex",
302
+ flexDirection: "column",
303
+ gap: e.vars.size.baseSpacings["sp1-5"],
304
+ maxHeight: g,
305
+ overflowY: "auto",
306
+ padding: e.vars.size.baseSpacings.sp2,
307
+ // Aquí sí hay sitio para el texto entero: el recorte es cosa del trigger,
308
+ // donde la card compite por el ancho de la fila.
309
+ [`&& .${s.deviceCardName},
310
+ && .${s.deviceCardSubtitle},
311
+ && .${s.deviceCardId}`]: {
312
+ whiteSpace: "normal",
313
+ overflowWrap: "anywhere",
314
+ textOverflow: "clip"
315
+ }
316
+ }),
317
+ /**
318
+ * skeletonCard: Ghost row shown while the devices are loading. Keeps the
319
+ * trigger geometry so nothing jumps when the data arrives.
320
+ */
321
+ skeletonCard: ({ theme: e }) => ({
322
+ display: "flex",
323
+ alignItems: "center",
324
+ width: "100%",
325
+ gap: e.vars.size.baseSpacings.sp2,
326
+ padding: e.vars.size.baseSpacings["sp0-5"]
327
+ }),
328
+ /**
329
+ * skeletonIcon: Ghost icon; same container size as the real device icon.
330
+ */
331
+ skeletonIcon: ({ theme: e, ownerState: i }) => ({
332
+ flexShrink: 0,
333
+ // El Skeleton fuerza 100% en `&.MuiSkeleton-root`; hay que ganarle.
334
+ "&&.MuiSkeleton-root": {
335
+ borderRadius: e.vars.size.borderRadius.r2,
336
+ backgroundColor: e.vars.palette.skeleton.default,
337
+ ...r(e, i?.size || "medium", "container", (a) => ({
338
+ width: a,
339
+ height: a
340
+ }))
341
+ }
342
+ }),
343
+ /**
344
+ * skeletonLine: Ghost text bar. `r4` is the largest radius token and CSS
345
+ * clamps it to half the height, which is the pill the master draws.
346
+ */
347
+ skeletonLine: ({ theme: e }) => ({
348
+ flexShrink: 0,
349
+ "&&.MuiSkeleton-root": {
350
+ width: p.textLineWidth,
351
+ height: e.vars.size.baseSpacings["sp2-5"],
352
+ borderRadius: e.vars.size.borderRadius.r4,
353
+ backgroundColor: e.vars.palette.skeleton.default
354
+ }
355
+ }),
356
+ /**
357
+ * skeletonChevron: Ghost chevron; same base size as the real icons.
358
+ */
359
+ skeletonChevron: ({ theme: e, ownerState: i }) => ({
360
+ flexShrink: 0,
361
+ "&&.MuiSkeleton-root": {
362
+ borderRadius: e.vars.size.borderRadius.r4,
363
+ backgroundColor: e.vars.palette.skeleton.default,
364
+ ...r(e, i?.size || "medium", "base", (a) => ({
365
+ width: a,
366
+ height: a
367
+ }))
368
+ }
369
+ })
370
+ };
371
+ export {
372
+ f as devicesPickerStyles
373
+ };