@envisiongroup/porygon 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
1
|
+
import { jsx as a, jsxs as F, Fragment as Ee } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as v, useState as w, useMemo as p, useEffect as A, useCallback as u } from "react";
|
|
3
|
-
import { makeStyles as
|
|
3
|
+
import { makeStyles as De, tokens as n, useTagPickerFilter as ze, TagPickerOption as R, Spinner as Ve, mergeClasses as _e, Text as Fe, TagPicker as Qe, TagPickerControl as We, TagPickerGroup as je, Tag as Ge, TagPickerInput as qe, Button as Xe, TagPickerList as He, Avatar as Je } from "@fluentui/react-components";
|
|
4
4
|
import { getTagPickerFormattedValue as pe } from "./EFWTagPicker.utils.js";
|
|
5
5
|
import { normalizeArrayValue as Ke } from "../../commons/valueNormalization.js";
|
|
6
6
|
import { CollectionsEmpty20Regular as Ye, Eraser20Regular as $e } from "@fluentui/react-icons";
|
|
7
7
|
import { useFieldsLocaleText as Ue } from "../../i18n/PorygonI18nProvider.js";
|
|
8
|
-
const Q = [], ue = (
|
|
8
|
+
const Q = [], Ze = 12, ue = (P) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden": !0, name: P.text, color: "colorful" }), et = De({
|
|
9
9
|
efwTagPickerControlError: {
|
|
10
10
|
backgroundColor: n.colorPaletteRedBackground1,
|
|
11
11
|
"::after": {
|
|
@@ -62,31 +62,31 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
62
62
|
fontSize: "12px",
|
|
63
63
|
lineHeight: "16px"
|
|
64
64
|
}
|
|
65
|
-
}),
|
|
65
|
+
}), ct = (P) => {
|
|
66
66
|
const {
|
|
67
67
|
labels: f,
|
|
68
68
|
className: ge = "",
|
|
69
69
|
minQueryLength: m = 0,
|
|
70
70
|
options: r = Q,
|
|
71
71
|
hidden: fe = !1,
|
|
72
|
-
disabled:
|
|
72
|
+
disabled: W = !1,
|
|
73
73
|
editable: me = !0,
|
|
74
|
-
selectedOptions:
|
|
75
|
-
defaultSelectedOptions:
|
|
74
|
+
selectedOptions: j = Q,
|
|
75
|
+
defaultSelectedOptions: B = Q,
|
|
76
76
|
noPopover: be = !1,
|
|
77
77
|
tagSize: he = "medium",
|
|
78
78
|
tagShape: Se = "rounded",
|
|
79
|
-
tagAppearance:
|
|
80
|
-
onChange:
|
|
81
|
-
beforeRenderOptions:
|
|
82
|
-
renderOptionMedia:
|
|
79
|
+
tagAppearance: Oe = "brand",
|
|
80
|
+
onChange: x,
|
|
81
|
+
beforeRenderOptions: y,
|
|
82
|
+
renderOptionMedia: I,
|
|
83
83
|
showOptionMediaInSelectedTags: G = !1,
|
|
84
|
-
readOnlyRenderer:
|
|
85
|
-
multiple:
|
|
84
|
+
readOnlyRenderer: ye,
|
|
85
|
+
multiple: q = !0,
|
|
86
86
|
validationState: X = "none",
|
|
87
87
|
validationMessage: Ce,
|
|
88
|
-
setParentComponentState:
|
|
89
|
-
} =
|
|
88
|
+
setParentComponentState: E
|
|
89
|
+
} = P, Te = v(X), ke = v(Ce), [s, H] = w(""), c = P.selectedOptions !== void 0, J = (c ? j : B) ?? [], [Me, D] = w(J), i = c ? j ?? [] : Me, N = p(
|
|
90
90
|
() => new Map(i.map((e) => [e.key, e])),
|
|
91
91
|
[i]
|
|
92
92
|
), b = p(
|
|
@@ -101,15 +101,15 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
101
101
|
), l = p(
|
|
102
102
|
() => new Map(L.map((e) => [e.key, e])),
|
|
103
103
|
[L]
|
|
104
|
-
),
|
|
104
|
+
), Pe = Y.loading, [z, T] = w(!1), $ = p(() => s.toLowerCase(), [s]), k = v(), g = v(null);
|
|
105
105
|
g.current === null && (g.current = Object.fromEntries(
|
|
106
106
|
J.map((e) => [e.key, e])
|
|
107
107
|
));
|
|
108
108
|
const V = v(
|
|
109
|
-
|
|
109
|
+
I ?? ue
|
|
110
110
|
), U = p(
|
|
111
|
-
() =>
|
|
112
|
-
[
|
|
111
|
+
() => B ?? [],
|
|
112
|
+
[B]
|
|
113
113
|
), h = Ue().tagPicker.labels, Z = h.placeholder, ee = h.noMatchesMessage, te = h.loadingMessage, oe = h.emptyState, ae = h.selectedItemsAriaLabel, ne = h.inputAriaLabel, re = f?.placeholder, le = f?.noMatchesMessage, ie = f?.loadingMessage, se = f?.emptyState, ce = f?.selectedItemsAriaLabel, de = f?.inputAriaLabel, S = p(() => ({
|
|
114
114
|
placeholder: re ?? Z,
|
|
115
115
|
noMatchesMessage: le ?? ee,
|
|
@@ -136,9 +136,9 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
136
136
|
g.current[e.key] = e;
|
|
137
137
|
});
|
|
138
138
|
}, [i]), A(() => {
|
|
139
|
-
V.current =
|
|
140
|
-
}, [
|
|
141
|
-
const
|
|
139
|
+
V.current = I ?? ue;
|
|
140
|
+
}, [I]);
|
|
141
|
+
const O = et(), xe = u(
|
|
142
142
|
(e) => (N.get(e) || l.get(e) || g.current[e])?.text || e,
|
|
143
143
|
[N, l]
|
|
144
144
|
), Ne = u(
|
|
@@ -158,13 +158,13 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
158
158
|
l
|
|
159
159
|
]
|
|
160
160
|
);
|
|
161
|
-
A(() =>
|
|
161
|
+
A(() => z ? (k.current?.abort(), k.current = new AbortController(), (async () => {
|
|
162
162
|
if (typeof r != "function") {
|
|
163
|
-
const t =
|
|
163
|
+
const t = y ? y(r) : r;
|
|
164
164
|
C((o) => ({ ...o, available: t }));
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
E?.(
|
|
168
168
|
Te.current,
|
|
169
169
|
ke.current
|
|
170
170
|
);
|
|
@@ -172,22 +172,22 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
172
172
|
C({ available: [], loading: !0 });
|
|
173
173
|
const t = await r(s, {
|
|
174
174
|
signal: k.current.signal
|
|
175
|
-
}), o =
|
|
175
|
+
}), o = y ? y(t) : t;
|
|
176
176
|
C({ available: o, loading: !1 });
|
|
177
177
|
} catch (t) {
|
|
178
|
-
k.current?.signal.aborted || (console.error("Error loading options:", t), C({ available: [], loading: !1 }),
|
|
178
|
+
k.current?.signal.aborted || (console.error("Error loading options:", t), C({ available: [], loading: !1 }), E?.("error", JSON.stringify(t)));
|
|
179
179
|
}
|
|
180
180
|
})(), () => k.current?.abort()) : void 0, [
|
|
181
|
-
|
|
181
|
+
z,
|
|
182
182
|
r,
|
|
183
183
|
s,
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
y,
|
|
185
|
+
E,
|
|
186
186
|
m
|
|
187
187
|
]);
|
|
188
188
|
const Le = u(() => {
|
|
189
|
-
c ||
|
|
190
|
-
}, [c,
|
|
189
|
+
c || D([]), x?.([], "");
|
|
190
|
+
}, [c, x]), we = u(
|
|
191
191
|
(e, t) => {
|
|
192
192
|
if (t.open && typeof r == "function" && s.length < m) {
|
|
193
193
|
T(!1);
|
|
@@ -202,28 +202,28 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
202
202
|
H(t), typeof r == "function" && t.length < m && T(!1);
|
|
203
203
|
},
|
|
204
204
|
[r, m]
|
|
205
|
-
),
|
|
205
|
+
), Re = u(
|
|
206
206
|
(e, t) => {
|
|
207
207
|
if (t.value === "no-matches") return;
|
|
208
208
|
let o;
|
|
209
|
-
|
|
209
|
+
q ? o = t.selectedOptions : (o = t.selectedOptions.slice(-1), T(!1)), H(""), typeof r == "function" && m > 0 && T(!1);
|
|
210
210
|
const M = o.map((d) => {
|
|
211
|
-
const
|
|
212
|
-
return
|
|
211
|
+
const _ = l.get(d) || g.current[d];
|
|
212
|
+
return _ && (g.current[d] = _), _ || { key: d, text: d };
|
|
213
213
|
});
|
|
214
|
-
c ||
|
|
214
|
+
c || D(M), x?.(
|
|
215
215
|
M,
|
|
216
216
|
pe(Ke(M))
|
|
217
217
|
);
|
|
218
218
|
},
|
|
219
|
-
[l,
|
|
220
|
-
),
|
|
219
|
+
[l, x, q, c]
|
|
220
|
+
), Be = ze({
|
|
221
221
|
// La consulta actual ingresada por el usuario para filtrar opciones.
|
|
222
222
|
query: s,
|
|
223
223
|
// Lista de claves (como strings) de las opciones disponibles, obtenidas de 'availableOptions'.
|
|
224
224
|
options: ve,
|
|
225
225
|
// Elemento a mostrar cuando no hay opciones disponibles.
|
|
226
|
-
noOptionsElement:
|
|
226
|
+
noOptionsElement: Pe ? (
|
|
227
227
|
// Si está cargando ('isLoading' es true), muestra un spinner pequeño.
|
|
228
228
|
/* @__PURE__ */ a(
|
|
229
229
|
Ve,
|
|
@@ -241,7 +241,7 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
241
241
|
) : (
|
|
242
242
|
// Si no está cargando y no hay opciones, muestra un mensaje de "sin coincidencias".
|
|
243
243
|
/* @__PURE__ */ a(
|
|
244
|
-
|
|
244
|
+
R,
|
|
245
245
|
{
|
|
246
246
|
value: "no-matches",
|
|
247
247
|
media: /* @__PURE__ */ a(Ye, {}),
|
|
@@ -260,19 +260,19 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
260
260
|
if (t) {
|
|
261
261
|
const o = V.current(t), M = o != null && o !== !1, d = typeof o == "boolean" ? void 0 : o;
|
|
262
262
|
return !M && t.secondaryContent ? /* @__PURE__ */ a(
|
|
263
|
-
|
|
263
|
+
R,
|
|
264
264
|
{
|
|
265
265
|
media: d,
|
|
266
266
|
text: t.text,
|
|
267
267
|
value: t.key,
|
|
268
|
-
children: /* @__PURE__ */
|
|
268
|
+
children: /* @__PURE__ */ F("div", { className: O.efwTagPickerOptionContentNoMedia, children: [
|
|
269
269
|
/* @__PURE__ */ a("span", { children: t.text }),
|
|
270
|
-
/* @__PURE__ */ a("span", { className:
|
|
270
|
+
/* @__PURE__ */ a("span", { className: O.efwTagPickerOptionSecondaryNoMedia, children: t.secondaryContent })
|
|
271
271
|
] })
|
|
272
272
|
},
|
|
273
273
|
t.key
|
|
274
274
|
) : /* @__PURE__ */ a(
|
|
275
|
-
|
|
275
|
+
R,
|
|
276
276
|
{
|
|
277
277
|
secondaryContent: t.secondaryContent || "",
|
|
278
278
|
media: d,
|
|
@@ -285,13 +285,13 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
285
285
|
}
|
|
286
286
|
return (
|
|
287
287
|
// Si no se encuentra la opción, renderiza una versión básica con solo la clave.
|
|
288
|
-
/* @__PURE__ */ a(
|
|
288
|
+
/* @__PURE__ */ a(R, { value: e, children: e }, e)
|
|
289
289
|
);
|
|
290
290
|
},
|
|
291
291
|
[
|
|
292
292
|
l,
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
O.efwTagPickerOptionContentNoMedia,
|
|
294
|
+
O.efwTagPickerOptionSecondaryNoMedia
|
|
295
295
|
]
|
|
296
296
|
),
|
|
297
297
|
// Dependencia: se recrea solo si cambia el set de opciones disponibles.
|
|
@@ -307,37 +307,41 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
307
307
|
},
|
|
308
308
|
[l, K, $]
|
|
309
309
|
)
|
|
310
|
-
}),
|
|
310
|
+
}), Ie = _e(
|
|
311
311
|
ge,
|
|
312
|
-
|
|
313
|
-
X === "error" &&
|
|
312
|
+
O.efwTagPickerControl,
|
|
313
|
+
X === "error" && O.efwTagPickerControlError
|
|
314
314
|
);
|
|
315
315
|
if (A(() => {
|
|
316
|
-
c ||
|
|
316
|
+
c || D(U);
|
|
317
317
|
}, [c, U]), fe) return null;
|
|
318
318
|
if (!me) {
|
|
319
|
-
const e = pe(i) || S.emptyState, t =
|
|
319
|
+
const e = pe(i) || S.emptyState, t = ye?.(
|
|
320
320
|
i,
|
|
321
321
|
e
|
|
322
322
|
);
|
|
323
|
-
return t != null ? /* @__PURE__ */ a(
|
|
323
|
+
return t != null ? /* @__PURE__ */ a(Ee, { children: t }) : /* @__PURE__ */ a(Fe, { style: i.length ? void 0 : { opacity: 0.7 }, children: e });
|
|
324
324
|
}
|
|
325
|
-
return /* @__PURE__ */
|
|
325
|
+
return /* @__PURE__ */ F(
|
|
326
326
|
Qe,
|
|
327
327
|
{
|
|
328
|
-
open:
|
|
328
|
+
open: z,
|
|
329
329
|
size: he,
|
|
330
|
-
disabled:
|
|
331
|
-
onOptionSelect:
|
|
330
|
+
disabled: W,
|
|
331
|
+
onOptionSelect: Re,
|
|
332
332
|
onOpenChange: we,
|
|
333
333
|
selectedOptions: b,
|
|
334
334
|
noPopover: be,
|
|
335
|
+
positioning: {
|
|
336
|
+
autoSize: "height",
|
|
337
|
+
overflowBoundaryPadding: Ze
|
|
338
|
+
},
|
|
335
339
|
children: [
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
|
|
340
|
+
/* @__PURE__ */ F(
|
|
341
|
+
We,
|
|
338
342
|
{
|
|
339
|
-
className:
|
|
340
|
-
secondaryAction: !
|
|
343
|
+
className: Ie,
|
|
344
|
+
secondaryAction: !W && b.length ? /* @__PURE__ */ a(
|
|
341
345
|
Xe,
|
|
342
346
|
{
|
|
343
347
|
appearance: "transparent",
|
|
@@ -349,20 +353,20 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
349
353
|
}
|
|
350
354
|
) : void 0,
|
|
351
355
|
children: [
|
|
352
|
-
/* @__PURE__ */ a(
|
|
356
|
+
/* @__PURE__ */ a(je, { "aria-label": S.selectedItemsAriaLabel, children: b.map((e) => /* @__PURE__ */ a(
|
|
353
357
|
Ge,
|
|
354
358
|
{
|
|
355
359
|
style: { paddingTop: "0px", paddingBottom: "0px" },
|
|
356
360
|
shape: Se,
|
|
357
|
-
appearance:
|
|
361
|
+
appearance: Oe,
|
|
358
362
|
media: Ne(e),
|
|
359
363
|
value: e,
|
|
360
|
-
children:
|
|
364
|
+
children: xe(e)
|
|
361
365
|
},
|
|
362
366
|
e
|
|
363
367
|
)) }),
|
|
364
368
|
/* @__PURE__ */ a(
|
|
365
|
-
|
|
369
|
+
qe,
|
|
366
370
|
{
|
|
367
371
|
placeholder: b.length ? "" : S.placeholder,
|
|
368
372
|
autoComplete: "off",
|
|
@@ -374,11 +378,11 @@ const Q = [], ue = (x) => /* @__PURE__ */ a(Je, { shape: "square", "aria-hidden"
|
|
|
374
378
|
]
|
|
375
379
|
}
|
|
376
380
|
),
|
|
377
|
-
/* @__PURE__ */ a(He, { children:
|
|
381
|
+
/* @__PURE__ */ a(He, { children: Be })
|
|
378
382
|
]
|
|
379
383
|
}
|
|
380
384
|
);
|
|
381
385
|
};
|
|
382
386
|
export {
|
|
383
|
-
|
|
387
|
+
ct as EFWTagPicker
|
|
384
388
|
};
|