@vector-business-services/cristal-ds-web 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +69 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +130 -43
- package/dist/index.css.map +1 -1
- package/dist/index.js +69 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ var Accordion = forwardRef(function Accordion2({ multiple = false, activeIndex,
|
|
|
40
40
|
const primeRef = useRef(null);
|
|
41
41
|
useImperativeHandle(ref, () => primeRef.current?.getElement());
|
|
42
42
|
const [interno, setInterno] = useState(multiple ? [0] : 0);
|
|
43
|
-
const
|
|
43
|
+
const abertos2 = activeIndex === void 0 ? interno : activeIndex;
|
|
44
44
|
const tabs = Children.toArray(children).filter(
|
|
45
45
|
(child) => isValidElement(child)
|
|
46
46
|
);
|
|
@@ -52,7 +52,7 @@ var Accordion = forwardRef(function Accordion2({ multiple = false, activeIndex,
|
|
|
52
52
|
ref: primeRef,
|
|
53
53
|
id,
|
|
54
54
|
multiple,
|
|
55
|
-
activeIndex:
|
|
55
|
+
activeIndex: abertos2,
|
|
56
56
|
onTabChange: (event) => {
|
|
57
57
|
const index = event.index;
|
|
58
58
|
setInterno(index);
|
|
@@ -76,8 +76,16 @@ var Accordion = forwardRef(function Accordion2({ multiple = false, activeIndex,
|
|
|
76
76
|
headerAction: { className: "cr-accordion__action" },
|
|
77
77
|
toggleableContent: { className: "cr-accordion__region" },
|
|
78
78
|
content: { className: "cr-accordion__content" },
|
|
79
|
-
//
|
|
80
|
-
|
|
79
|
+
// Abre e fecha pela altura, como o tema do Prime (p-toggleable-content, Accordion.css):
|
|
80
|
+
// no unstyled o Prime só dá o tempo, sem classes.
|
|
81
|
+
transition: {
|
|
82
|
+
classNames: {
|
|
83
|
+
enter: "cr-accordion__region--entrar",
|
|
84
|
+
enterActive: "cr-accordion__region--entrando",
|
|
85
|
+
exit: "cr-accordion__region--sair",
|
|
86
|
+
exitActive: "cr-accordion__region--saindo"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
81
89
|
},
|
|
82
90
|
children: tab.props.children
|
|
83
91
|
},
|
|
@@ -105,7 +113,17 @@ var painelDoCampo = (campo, seletorDoPainel) => {
|
|
|
105
113
|
const lista = campo?.getAttribute("aria-controls");
|
|
106
114
|
return lista ? document.getElementById(lista)?.closest(seletorDoPainel) : null;
|
|
107
115
|
};
|
|
108
|
-
var
|
|
116
|
+
var CLASSES_DO_POPUP = {
|
|
117
|
+
enter: "cr-popup--entrar",
|
|
118
|
+
enterActive: "cr-popup--entrando",
|
|
119
|
+
enterDone: "cr-popup--entrou",
|
|
120
|
+
exitActive: "cr-popup--saindo"
|
|
121
|
+
};
|
|
122
|
+
var transicaoDoPopup = (onEnter) => (
|
|
123
|
+
// Sem onEnter, a chave nem aparece: o Prime soma as funções do pt às dele, mas um undefined
|
|
124
|
+
// substituiria o onEnter dele (que posiciona a lista).
|
|
125
|
+
{ classNames: CLASSES_DO_POPUP, ...onEnter && { onEnter } }
|
|
126
|
+
);
|
|
109
127
|
var AutoComplete = forwardRef(function AutoComplete2({
|
|
110
128
|
variant = "outline",
|
|
111
129
|
size = "large",
|
|
@@ -158,8 +176,9 @@ var AutoComplete = forwardRef(function AutoComplete2({
|
|
|
158
176
|
// O Prime mostra um spinner próprio enquanto busca; o Figma não define esse estado.
|
|
159
177
|
loadingIcon: { className: "cr-autocomplete__loader" },
|
|
160
178
|
panel: { className: "cr-lista cr-autocomplete__panel" },
|
|
161
|
-
//
|
|
162
|
-
|
|
179
|
+
// Animação de entrada e saída (a do Prime) e o lado da lista, medido logo depois de o Prime
|
|
180
|
+
// posicionar.
|
|
181
|
+
transition: transicaoDoPopup(() => {
|
|
163
182
|
const campo = document.getElementById(id);
|
|
164
183
|
seguirLado(painelDoCampo(campo, ".cr-autocomplete__panel"), campo);
|
|
165
184
|
}),
|
|
@@ -239,8 +258,16 @@ var Card = forwardRef(function Card2({ padding = "xsmall", outline = false, clas
|
|
|
239
258
|
);
|
|
240
259
|
});
|
|
241
260
|
var usandoTeclado = false;
|
|
261
|
+
var abertos = /* @__PURE__ */ new Set();
|
|
242
262
|
if (typeof document !== "undefined") {
|
|
243
|
-
document.addEventListener(
|
|
263
|
+
document.addEventListener(
|
|
264
|
+
"keydown",
|
|
265
|
+
(event) => {
|
|
266
|
+
usandoTeclado = true;
|
|
267
|
+
if (event.key === "Escape") abertos.forEach((fechar) => fechar());
|
|
268
|
+
},
|
|
269
|
+
true
|
|
270
|
+
);
|
|
244
271
|
document.addEventListener("pointerdown", () => usandoTeclado = false, true);
|
|
245
272
|
}
|
|
246
273
|
var resolveTargets = (target) => {
|
|
@@ -263,6 +290,9 @@ function Tooltip({
|
|
|
263
290
|
}) {
|
|
264
291
|
const autoId = useId();
|
|
265
292
|
const tooltipId = id ?? autoId;
|
|
293
|
+
const primeRef = useRef(null);
|
|
294
|
+
const [fechar] = useState(() => () => void primeRef.current?.hide());
|
|
295
|
+
useEffect(() => () => void abertos.delete(fechar), [fechar]);
|
|
266
296
|
useEffect(() => {
|
|
267
297
|
if (!describe) return;
|
|
268
298
|
const elements = resolveTargets(target);
|
|
@@ -297,9 +327,17 @@ function Tooltip({
|
|
|
297
327
|
event,
|
|
298
328
|
showDelay,
|
|
299
329
|
hideDelay,
|
|
330
|
+
ref: primeRef,
|
|
300
331
|
disabled,
|
|
301
|
-
|
|
302
|
-
|
|
332
|
+
onBeforeShow: (e) => {
|
|
333
|
+
const abre = e.originalEvent?.type !== "focus" || usandoTeclado;
|
|
334
|
+
if (abre) abertos.add(fechar);
|
|
335
|
+
return abre;
|
|
336
|
+
},
|
|
337
|
+
onBeforeHide: () => {
|
|
338
|
+
abertos.delete(fechar);
|
|
339
|
+
return true;
|
|
340
|
+
},
|
|
303
341
|
pt,
|
|
304
342
|
children: content
|
|
305
343
|
}
|
|
@@ -1068,10 +1106,11 @@ var Menu = forwardRef(function Menu2({
|
|
|
1068
1106
|
};
|
|
1069
1107
|
},
|
|
1070
1108
|
content: { className: "cr-menu__content" },
|
|
1071
|
-
//
|
|
1109
|
+
// Animação de entrada e saída (a do Prime) e o lado do popup, medido logo depois de o Prime
|
|
1110
|
+
// posicionar.
|
|
1072
1111
|
// Numa microtarefa: no onEnter o Prime ainda está religando a ref (getElement vem vazio); ela
|
|
1073
1112
|
// roda logo depois, antes de a tela ser pintada.
|
|
1074
|
-
transition:
|
|
1113
|
+
transition: transicaoDoPopup(
|
|
1075
1114
|
() => queueMicrotask(() => seguirLado(primeRef.current?.getElement(), alvo.current))
|
|
1076
1115
|
),
|
|
1077
1116
|
action: { className: "cr-lista__item cr-menu__action" },
|
|
@@ -1414,7 +1453,7 @@ var MenuPrincipal = forwardRef(
|
|
|
1414
1453
|
menuitem: { className: "cr-menu-principal__item" },
|
|
1415
1454
|
// Lado do popup, medido logo depois de o Prime posicionar.
|
|
1416
1455
|
// Numa microtarefa: no onEnter o Prime ainda está religando a ref (como no Menu).
|
|
1417
|
-
transition:
|
|
1456
|
+
transition: transicaoDoPopup(
|
|
1418
1457
|
() => queueMicrotask(() => seguirLado(primeRef.current?.getElement(), alvo.current))
|
|
1419
1458
|
)
|
|
1420
1459
|
};
|
|
@@ -1528,6 +1567,16 @@ var Modal = forwardRef(function Modal2({
|
|
|
1528
1567
|
className: classes,
|
|
1529
1568
|
"aria-labelledby": titleId,
|
|
1530
1569
|
"aria-describedby": void 0
|
|
1570
|
+
},
|
|
1571
|
+
// Entrada e saída do tema do Prime (p-dialog, Modal.css). No unstyled o Prime não põe
|
|
1572
|
+
// classes na transição; o tipo exige o addEndListener do react-transition-group.
|
|
1573
|
+
transition: {
|
|
1574
|
+
classNames: {
|
|
1575
|
+
enter: "cr-modal--entrar",
|
|
1576
|
+
enterActive: "cr-modal--entrando",
|
|
1577
|
+
enterDone: "cr-modal--entrou",
|
|
1578
|
+
exitActive: "cr-modal--saindo"
|
|
1579
|
+
}
|
|
1531
1580
|
}
|
|
1532
1581
|
},
|
|
1533
1582
|
content: ({ hide, closeRef }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1713,7 +1762,9 @@ var MultiSelect = forwardRef(function MultiSelect2({
|
|
|
1713
1762
|
...checkbox,
|
|
1714
1763
|
root: { ...checkbox.root, role: void 0, "aria-checked": void 0, inert: true }
|
|
1715
1764
|
},
|
|
1716
|
-
emptyMessage: { className: "cr-multiselect__empty" }
|
|
1765
|
+
emptyMessage: { className: "cr-multiselect__empty" },
|
|
1766
|
+
// Animação de entrada e saída da lista, a do Prime (comum.css).
|
|
1767
|
+
transition: transicaoDoPopup()
|
|
1717
1768
|
};
|
|
1718
1769
|
return /* @__PURE__ */ jsxs("div", { className: classes, children: [
|
|
1719
1770
|
label && /* @__PURE__ */ jsxs("label", { className: "cr-field__label", htmlFor: inputId, children: [
|
|
@@ -1915,8 +1966,9 @@ var Select = forwardRef(function Select2({
|
|
|
1915
1966
|
input: { className: "cr-select__value" },
|
|
1916
1967
|
trigger: { className: "cr-field__icon cr-select__trigger", "aria-hidden": true },
|
|
1917
1968
|
panel: { className: "cr-lista cr-select__panel" },
|
|
1918
|
-
//
|
|
1919
|
-
|
|
1969
|
+
// Animação de entrada e saída (a do Prime) e o lado da lista, medido logo depois de o Prime
|
|
1970
|
+
// posicionar.
|
|
1971
|
+
transition: transicaoDoPopup(
|
|
1920
1972
|
() => seguirLado(
|
|
1921
1973
|
document.getElementById(listId)?.closest(".cr-select__panel"),
|
|
1922
1974
|
document.getElementById(inputId)?.closest(".cr-select__control")
|
|
@@ -2435,6 +2487,7 @@ var Toast = forwardRef(function Toast2({ position = "top-right", closeLabel = "F
|
|
|
2435
2487
|
classNames: {
|
|
2436
2488
|
enter: "cr-toast__message--enter",
|
|
2437
2489
|
enterActive: "cr-toast__message--enter-active",
|
|
2490
|
+
exit: "cr-toast__message--exit",
|
|
2438
2491
|
exitActive: "cr-toast__message--exit-active"
|
|
2439
2492
|
}
|
|
2440
2493
|
}
|