@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,178 @@
1
+ import { ReactNode } from 'react';
2
+ import { CheckableListGroup, CheckableListItem } from '@m4l/components';
3
+ import { CheckableDevicesPickerProps, DevicePickerGroupRef, DevicePickerOption } from '../types';
4
+ /**
5
+ * Subset of the picker props that configures the async source.
6
+ */
7
+ export type UseDevicesAsyncOptionsProps<T> = Pick<CheckableDevicesPickerProps<T>, 'endPoint' | 'timeout' | 'parms' | 'resultField' | 'isRemote' | 'isExternalUrl' | 'responseToCamelCase' | 'shouldFetch' | 'onChangeFilterParms'>;
8
+ /**
9
+ * Value returned by the async options hook.
10
+ */
11
+ export interface UseDevicesAsyncOptionsReturn<T> {
12
+ /**
13
+ * Options loaded from the endpoint.
14
+ */
15
+ options: T[];
16
+ /**
17
+ * A request is in flight.
18
+ */
19
+ loading: boolean;
20
+ /**
21
+ * Notifies the engine that the panel opened, triggering the first fetch.
22
+ */
23
+ onOpen: () => void;
24
+ /**
25
+ * Notifies the engine that the panel closed.
26
+ */
27
+ onClose: () => void;
28
+ /**
29
+ * Forces a refetch with the current params.
30
+ */
31
+ refresh: () => void;
32
+ /**
33
+ * Feeds the panel search box into the remote query when the consumer
34
+ * provided `onChangeFilterParms`.
35
+ */
36
+ onSearchChange: (query: string) => void;
37
+ }
38
+ /**
39
+ * Options accepted by the device grouping hook.
40
+ */
41
+ export interface UseDeviceGroupsProps<T = DevicePickerOption> {
42
+ /**
43
+ * Devices to organize.
44
+ */
45
+ options: T[];
46
+ /**
47
+ * Groups the devices by department when enabled.
48
+ */
49
+ grouped: boolean;
50
+ /**
51
+ * Resolves the group of a device; null falls into the default group.
52
+ */
53
+ getDeviceGroup: (option: T) => DevicePickerGroupRef | null;
54
+ /**
55
+ * Label used for devices with no department.
56
+ */
57
+ defaultGroupLabel: string;
58
+ /**
59
+ * Resolves the first line of a row.
60
+ */
61
+ getOptionLabel: (option: T) => string;
62
+ /**
63
+ * Resolves the second line of a row.
64
+ */
65
+ getDeviceSubtitle: (option: T) => string | undefined;
66
+ /**
67
+ * Resolves the icon of a row.
68
+ */
69
+ getDeviceIcon?: (option: T) => ReactNode;
70
+ }
71
+ /**
72
+ * Value returned by the device grouping hook.
73
+ */
74
+ export interface UseDeviceGroupsReturn {
75
+ /**
76
+ * Collapsible groups fed to the CheckableList; undefined when flat.
77
+ */
78
+ groups?: CheckableListGroup[];
79
+ /**
80
+ * Flat items fed to the CheckableList; undefined when grouped.
81
+ */
82
+ items?: CheckableListItem[];
83
+ }
84
+ /**
85
+ * Options accepted by the panel columns hook.
86
+ */
87
+ export interface UsePanelColumnsProps<T = DevicePickerOption> {
88
+ /**
89
+ * Devices used to detect whether each column has data at all.
90
+ */
91
+ options: T[];
92
+ /**
93
+ * Forces the "Ver departamentos" switch instead of deriving it.
94
+ */
95
+ showDepartments?: boolean;
96
+ /**
97
+ * Forces the "Ver ID" switch instead of deriving it.
98
+ */
99
+ showIds?: boolean;
100
+ /**
101
+ * Resolves the group of a device, used for the department detection.
102
+ */
103
+ getDeviceGroup: (option: T) => DevicePickerGroupRef | null;
104
+ }
105
+ /**
106
+ * Value returned by the panel columns hook.
107
+ */
108
+ export interface UsePanelColumnsReturn {
109
+ /**
110
+ * The list is grouped by department.
111
+ */
112
+ showDepartments: boolean;
113
+ /**
114
+ * Rows render the id line.
115
+ */
116
+ showIds: boolean;
117
+ /**
118
+ * At least one device has a department, so the switch is offered.
119
+ */
120
+ canShowDepartments: boolean;
121
+ /**
122
+ * At least one device has an id, so the switch is offered.
123
+ */
124
+ canShowIds: boolean;
125
+ /**
126
+ * Toggles the "Ver departamentos" switch.
127
+ */
128
+ toggleDepartments: () => void;
129
+ /**
130
+ * Toggles the "Ver ID" switch.
131
+ */
132
+ toggleIds: () => void;
133
+ }
134
+ /**
135
+ * Options accepted by the selection hook.
136
+ */
137
+ export interface UseDevicesSelectionProps<T = DevicePickerOption> {
138
+ /**
139
+ * Current picker value, as objects.
140
+ */
141
+ value: T | T[] | null | undefined;
142
+ /**
143
+ * Options currently loaded from the endpoint. Only the id-based selection
144
+ * needs them; a consumer that just reads the value (the DevicesPicker
145
+ * trigger) can omit them.
146
+ */
147
+ options?: T[];
148
+ /**
149
+ * Multiple selection.
150
+ */
151
+ multiple: boolean;
152
+ /**
153
+ * Reports the new value to the consumer.
154
+ */
155
+ onChange: CheckableDevicesPickerProps<T>['onChange'];
156
+ }
157
+ /**
158
+ * Value returned by the selection hook.
159
+ */
160
+ export interface UseDevicesSelectionReturn<T = DevicePickerOption> {
161
+ /**
162
+ * Selected ids, the shape the CheckableList works with.
163
+ */
164
+ selectedIds: (string | number)[];
165
+ /**
166
+ * Currently selected devices, as objects.
167
+ */
168
+ selectedDevices: T[];
169
+ /**
170
+ * Translates a CheckableList id selection back into device objects.
171
+ */
172
+ handleSelectionChange: (selectedIds: (string | number)[]) => void;
173
+ /**
174
+ * Removes one device from the selection.
175
+ */
176
+ handleRemove: (device: T) => void;
177
+ }
178
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CheckableDevicesPicker/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEjG;;GAEG;AACH,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI,IAAI,CAC/C,2BAA2B,CAAC,CAAC,CAAC,EAC5B,UAAU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,IAAI,CAAC;CACnC"}
@@ -0,0 +1,13 @@
1
+ import { DevicePickerOption } from '../types';
2
+ import { UseDeviceGroupsProps, UseDeviceGroupsReturn } from './types';
3
+ /**
4
+ * Builds the CheckableList payload for the panel.
5
+ *
6
+ * The CheckableList consumes groups already built (it only flattens them to
7
+ * filter and virtualize), so the grouping lives here, mirroring what the
8
+ * geofences assignment does: one group per department carrying its color, so
9
+ * the count badge can be tinted with it. Devices with no department fall into a
10
+ * default group rendered last, so a selection is never hidden by the grouping.
11
+ */
12
+ export declare function useDeviceGroups<T extends DevicePickerOption = DevicePickerOption>(props: UseDeviceGroupsProps<T>): UseDeviceGroupsReturn;
13
+ //# sourceMappingURL=useDeviceGroups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeviceGroups.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CheckableDevicesPicker/hooks/useDeviceGroups.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EAC/E,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC7B,qBAAqB,CA6EvB"}
@@ -0,0 +1,51 @@
1
+ import { useCallback as v, useMemo as p } from "react";
2
+ import { CHECKABLE_DEVICES_PICKER_DEFAULT_GROUP_ID as c } from "../constants.js";
3
+ function E(f) {
4
+ const {
5
+ options: i,
6
+ grouped: u,
7
+ getDeviceGroup: d,
8
+ defaultGroupLabel: n,
9
+ getOptionLabel: m,
10
+ getDeviceSubtitle: a,
11
+ getDeviceIcon: b
12
+ } = f, o = v(
13
+ (r) => ({
14
+ id: r.id,
15
+ label: m(r),
16
+ // Search matches label and description, so the name stays findable once
17
+ // the alias takes the first line.
18
+ description: a(r),
19
+ value: r,
20
+ icon: b?.(r),
21
+ metadata: {
22
+ subtitle: a(r),
23
+ deviceId: r.id
24
+ }
25
+ }),
26
+ [m, a, b]
27
+ ), g = p(() => {
28
+ if (!u)
29
+ return i.map(o);
30
+ }, [u, i, o]);
31
+ return { groups: p(() => {
32
+ if (!u)
33
+ return;
34
+ const r = i.reduce((e, t) => {
35
+ const l = d(t), s = String(l?.id ?? c);
36
+ return e[s] || (e[s] = {
37
+ id: s,
38
+ label: l?.label ?? n,
39
+ color: l?.color,
40
+ items: []
41
+ }), e[s].items.push(o(t)), e;
42
+ }, {});
43
+ return Object.values(r).map((e) => ({
44
+ ...e,
45
+ items: [...e.items].sort((t, l) => t.label.localeCompare(l.label))
46
+ })).sort((e, t) => e.id === c ? 1 : t.id === c ? -1 : e.label.localeCompare(t.label));
47
+ }, [u, i, d, n, o]), items: g };
48
+ }
49
+ export {
50
+ E as useDeviceGroups
51
+ };
@@ -0,0 +1,13 @@
1
+ import { UseDevicesAsyncOptionsProps, UseDevicesAsyncOptionsReturn } from './types';
2
+ /**
3
+ * Drives the device options using the very same async engine as
4
+ * AutocompleteAsync: the shared reducer decides when to fetch and
5
+ * `useFetchOptions` performs the request with its abort handling.
6
+ * Options are fetched lazily, the first time the panel is opened.
7
+ *
8
+ * `onChangeFilterParms` behaves exactly like in AutocompleteAsync: the panel
9
+ * search box builds the query params, debounced by 300ms, and the request is
10
+ * re-issued so the backend returns the filtered list.
11
+ */
12
+ export declare function useDevicesAsyncOptions<T>(props: UseDevicesAsyncOptionsProps<T>): UseDevicesAsyncOptionsReturn<T>;
13
+ //# sourceMappingURL=useDevicesAsyncOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDevicesAsyncOptions.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CheckableDevicesPicker/hooks/useDevicesAsyncOptions.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,KAAK,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACpC,4BAA4B,CAAC,CAAC,CAAC,CAoFjC"}
@@ -0,0 +1,69 @@
1
+ import S from "lodash-es/debounce";
2
+ import { useRef as g, useReducer as A, useCallback as c, useMemo as O, useEffect as P } from "react";
3
+ import { autocompleteAsyncReducer as b, getInitialStateAutocompleteAsync as T, useFetchOptions as x, actionsType as r } from "@m4l/components";
4
+ function k(l) {
5
+ const {
6
+ endPoint: p,
7
+ timeout: m = 5e3,
8
+ parms: i,
9
+ resultField: d = "data",
10
+ isRemote: f = !0,
11
+ isExternalUrl: h = !1,
12
+ responseToCamelCase: R,
13
+ shouldFetch: t,
14
+ onChangeFilterParms: n
15
+ } = l, u = g(""), [a, o] = A(
16
+ b(n),
17
+ T({ parms: i, onChangeFilterParms: n })
18
+ );
19
+ x({
20
+ state: a,
21
+ dispatch: o,
22
+ endPoint: p,
23
+ timeout: m,
24
+ isExternalUrl: h,
25
+ parms: i,
26
+ responseToCamelCase: R,
27
+ isRemote: f,
28
+ resultField: d
29
+ });
30
+ const E = c(() => {
31
+ const e = !t || t(u.current);
32
+ o({ type: r.OPEN, noFetch: !e });
33
+ }, [t]), F = c(() => o({ type: r.CLOSE }), []), y = c(() => o({ type: r.REFRESH }), []), s = O(
34
+ () => S(
35
+ (e) => {
36
+ o({
37
+ type: r.SET_QUERY_PARAMS,
38
+ payload: e
39
+ });
40
+ },
41
+ 300,
42
+ { trailing: !0 }
43
+ ),
44
+ [o]
45
+ );
46
+ P(
47
+ () => () => {
48
+ s.cancel();
49
+ },
50
+ [s]
51
+ );
52
+ const C = c(
53
+ (e) => {
54
+ u.current = e, n && (!t || t(e)) && s(n(e));
55
+ },
56
+ [n, s, t]
57
+ );
58
+ return {
59
+ options: a.options,
60
+ loading: a.loading,
61
+ onOpen: E,
62
+ onClose: F,
63
+ refresh: y,
64
+ onSearchChange: C
65
+ };
66
+ }
67
+ export {
68
+ k as useDevicesAsyncOptions
69
+ };
@@ -0,0 +1,12 @@
1
+ import { DevicePickerOption } from '../types';
2
+ import { UseDevicesSelectionProps, UseDevicesSelectionReturn } from './types';
3
+ /**
4
+ * Bridges the picker value with the CheckableList selection.
5
+ *
6
+ * The picker reports device objects, mirroring the AutocompleteAsync contract
7
+ * and what the DynamicFilter stores, while the CheckableList works with ids.
8
+ * Already-selected devices are kept even when they are not in the latest
9
+ * options, so a selection made before a param change never disappears.
10
+ */
11
+ export declare function useDevicesSelection<T extends DevicePickerOption = DevicePickerOption>(props: UseDevicesSelectionProps<T>): UseDevicesSelectionReturn<T>;
12
+ //# sourceMappingURL=useDevicesSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDevicesSelection.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CheckableDevicesPicker/hooks/useDevicesSelection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EACnF,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACjC,yBAAyB,CAAC,CAAC,CAAC,CAwC9B"}
@@ -0,0 +1,26 @@
1
+ import { useMemo as u, useCallback as d } from "react";
2
+ import { toDeviceArray as h } from "../helpers/toDeviceArray.js";
3
+ function D(m) {
4
+ const { value: i, options: r = [], multiple: c, onChange: l } = m, t = u(() => h(i), [i]), p = u(
5
+ () => t.map((n) => n.id),
6
+ [t]
7
+ ), v = d(
8
+ (n) => {
9
+ const o = /* @__PURE__ */ new Map();
10
+ t.forEach((e) => o.set(e.id, e)), r.forEach((e) => o.set(e.id, e));
11
+ const s = n.map((e) => o.get(e)).filter((e) => !!e), a = c ? s : s[0] ?? null;
12
+ l({ target: { value: a } }, a, "selectOption");
13
+ },
14
+ [t, r, c, l]
15
+ ), f = d(
16
+ (n) => {
17
+ const o = t.filter((a) => a.id !== n.id), s = c ? o : null;
18
+ l({ target: { value: s } }, s, "removeOption");
19
+ },
20
+ [t, c, l]
21
+ );
22
+ return { selectedIds: p, selectedDevices: t, handleSelectionChange: v, handleRemove: f };
23
+ }
24
+ export {
25
+ D as useDevicesSelection
26
+ };
@@ -0,0 +1,12 @@
1
+ import { DevicePickerOption } from '../types';
2
+ import { UsePanelColumnsProps, UsePanelColumnsReturn } from './types';
3
+ /**
4
+ * Drives the two column switches of the panel.
5
+ *
6
+ * A switch is only offered when the data behind it exists: grouping by
7
+ * department is pointless if no device has one, and the id line would render an
8
+ * empty column. When the consumer passes the prop explicitly it wins over the
9
+ * detection.
10
+ */
11
+ export declare function usePanelColumns<T extends DevicePickerOption = DevicePickerOption>(props: UsePanelColumnsProps<T>): UsePanelColumnsReturn;
12
+ //# sourceMappingURL=usePanelColumns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePanelColumns.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CheckableDevicesPicker/hooks/usePanelColumns.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EAC/E,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC7B,qBAAqB,CA8CvB"}
@@ -0,0 +1,30 @@
1
+ import { useMemo as m, useState as r, useEffect as i, useCallback as u } from "react";
2
+ function g(p) {
3
+ const { options: s, showDepartments: t, showIds: o, getDeviceGroup: d } = p, n = m(
4
+ () => s.some((e) => d(e) !== null),
5
+ [s, d]
6
+ ), a = m(
7
+ () => s.some((e) => e.id !== void 0 && e.id !== null),
8
+ [s]
9
+ ), [f, l] = r(t ?? !1), [h, c] = r(o ?? !1);
10
+ i(() => {
11
+ t === void 0 && l(n);
12
+ }, [n, t]), i(() => {
13
+ o === void 0 && c(a);
14
+ }, [a, o]);
15
+ const w = u(
16
+ () => l((e) => !e),
17
+ []
18
+ ), D = u(() => c((e) => !e), []);
19
+ return {
20
+ showDepartments: (t ?? f) && n,
21
+ showIds: (o ?? h) && a,
22
+ canShowDepartments: n,
23
+ canShowIds: a,
24
+ toggleDepartments: w,
25
+ toggleIds: D
26
+ };
27
+ }
28
+ export {
29
+ g as usePanelColumns
30
+ };
@@ -0,0 +1,7 @@
1
+ export * from './CheckableDevicesPicker';
2
+ export * from './types';
3
+ export * from './constants';
4
+ export { CHECKABLE_DEVICES_PICKER_DICTIONARY_ID, getCheckableDevicesPickerComponentsDictionary, } from './dictionary';
5
+ export * from './helpers/resolveDeviceGroup';
6
+ export * from './helpers/toDeviceArray';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/CheckableDevicesPicker/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,sCAAsC,EACtC,6CAA6C,GAC9C,MAAM,cAAc,CAAC;AACtB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare enum CheckableDevicesPickerSlots {
2
+ /** Surface of the picker: header, search and list stacked in a column. */
3
+ root = "root",
4
+ /** Row holding the "Ver departamentos" and "Ver ID" switches. */
5
+ header = "header",
6
+ /** Each column switch inside the header. */
7
+ columnSwitch = "columnSwitch",
8
+ /** The CheckableList that paints the devices. */
9
+ list = "list",
10
+ /** Device name inside a row. */
11
+ rowName = "rowName",
12
+ /** Device plate inside a row, below the alias. */
13
+ rowSubtitle = "rowSubtitle",
14
+ /** Device id inside a row, toggled by the "Ver ID" switch. */
15
+ rowId = "rowId",
16
+ /** Row that lays out the group header label and its count badge. */
17
+ groupRow = "groupRow",
18
+ /** Group header label. */
19
+ groupLabel = "groupLabel",
20
+ /** Group count badge, tinted with the department color. */
21
+ groupBadge = "groupBadge"
22
+ }
23
+ //# sourceMappingURL=CheckableDevicesPickerEnum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckableDevicesPickerEnum.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CheckableDevicesPicker/slots/CheckableDevicesPickerEnum.ts"],"names":[],"mappings":"AAAA,oBAAY,2BAA2B;IACrC,0EAA0E;IAC1E,IAAI,SAAS;IACb,iEAAiE;IACjE,MAAM,WAAW;IACjB,4CAA4C;IAC5C,YAAY,iBAAiB;IAC7B,iDAAiD;IACjD,IAAI,SAAS;IACb,gCAAgC;IAChC,OAAO,YAAY;IACnB,kDAAkD;IAClD,WAAW,gBAAgB;IAC3B,8DAA8D;IAC9D,KAAK,UAAU;IACf,oEAAoE;IACpE,QAAQ,aAAa;IACrB,0BAA0B;IAC1B,UAAU,eAAe;IACzB,2DAA2D;IAC3D,UAAU,eAAe;CAC1B"}
@@ -0,0 +1,4 @@
1
+ var r = /* @__PURE__ */ ((o) => (o.root = "root", o.header = "header", o.columnSwitch = "columnSwitch", o.list = "list", o.rowName = "rowName", o.rowSubtitle = "rowSubtitle", o.rowId = "rowId", o.groupRow = "groupRow", o.groupLabel = "groupLabel", o.groupBadge = "groupBadge", o))(r || {});
2
+ export {
3
+ r as CheckableDevicesPickerSlots
4
+ };