@vector-business-services/cristal-ds-web 0.13.0 → 0.13.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.
- package/dist/index.cjs +87 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +21 -27
- package/dist/index.css.map +1 -1
- package/dist/index.js +87 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -86,6 +86,23 @@ var Accordion = forwardRef(function Accordion2({ multiple = false, activeIndex,
|
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
88
|
});
|
|
89
|
+
|
|
90
|
+
// src/components/popup.ts
|
|
91
|
+
function seguirLado(painel, alvo) {
|
|
92
|
+
if (!(painel instanceof HTMLElement) || !alvo) return;
|
|
93
|
+
const marcar = () => {
|
|
94
|
+
const acima = painel.getBoundingClientRect().top < alvo.getBoundingClientRect().top;
|
|
95
|
+
if (acima) painel.setAttribute("data-cr-lado", "acima");
|
|
96
|
+
else painel.removeAttribute("data-cr-lado");
|
|
97
|
+
};
|
|
98
|
+
marcar();
|
|
99
|
+
new MutationObserver(marcar).observe(painel, { attributes: true, attributeFilter: ["style"] });
|
|
100
|
+
}
|
|
101
|
+
var painelDoCampo = (campo, seletorDoPainel) => {
|
|
102
|
+
const lista = campo?.getAttribute("aria-controls");
|
|
103
|
+
return lista ? document.getElementById(lista)?.closest(seletorDoPainel) : null;
|
|
104
|
+
};
|
|
105
|
+
var aoPosicionar = (onEnter) => ({ onEnter });
|
|
89
106
|
var AutoComplete = forwardRef(function AutoComplete2({
|
|
90
107
|
variant = "outline",
|
|
91
108
|
size = "large",
|
|
@@ -138,6 +155,11 @@ var AutoComplete = forwardRef(function AutoComplete2({
|
|
|
138
155
|
// O Prime mostra um spinner próprio enquanto busca; o Figma não define esse estado.
|
|
139
156
|
loadingIcon: { className: "cr-autocomplete__loader" },
|
|
140
157
|
panel: { className: "cr-autocomplete__panel" },
|
|
158
|
+
// Lado da lista (acima ou abaixo do campo), medido logo depois de o Prime posicionar.
|
|
159
|
+
transition: aoPosicionar(() => {
|
|
160
|
+
const campo = document.getElementById(id);
|
|
161
|
+
seguirLado(painelDoCampo(campo, ".cr-autocomplete__panel"), campo);
|
|
162
|
+
}),
|
|
141
163
|
list: { className: "cr-autocomplete__list" },
|
|
142
164
|
item: { className: "cr-autocomplete__item" }
|
|
143
165
|
},
|
|
@@ -237,8 +259,17 @@ function Tooltip({
|
|
|
237
259
|
useEffect(() => {
|
|
238
260
|
if (!describe) return;
|
|
239
261
|
const elements = resolveTargets(target);
|
|
240
|
-
|
|
241
|
-
|
|
262
|
+
const ids = (element) => (element.getAttribute("aria-describedby") ?? "").split(/\s+/).filter(Boolean);
|
|
263
|
+
const gravar = (element, lista) => lista.length ? element.setAttribute("aria-describedby", lista.join(" ")) : element.removeAttribute("aria-describedby");
|
|
264
|
+
elements.forEach((element) => {
|
|
265
|
+
if (!ids(element).includes(tooltipId)) gravar(element, [...ids(element), tooltipId]);
|
|
266
|
+
});
|
|
267
|
+
return () => elements.forEach(
|
|
268
|
+
(element) => gravar(
|
|
269
|
+
element,
|
|
270
|
+
ids(element).filter((idAtual) => idAtual !== tooltipId)
|
|
271
|
+
)
|
|
272
|
+
);
|
|
242
273
|
}, [target, tooltipId, describe]);
|
|
243
274
|
const classes = ["cr-tooltip", `cr-tooltip--${type}`, className].filter(Boolean).join(" ");
|
|
244
275
|
const pt = {
|
|
@@ -260,6 +291,7 @@ function Tooltip({
|
|
|
260
291
|
showDelay,
|
|
261
292
|
hideDelay,
|
|
262
293
|
disabled,
|
|
294
|
+
closeOnEscape: true,
|
|
263
295
|
onBeforeShow: (e) => e.originalEvent?.type !== "focus" || usandoTeclado,
|
|
264
296
|
pt,
|
|
265
297
|
children: content
|
|
@@ -575,7 +607,10 @@ var Checkbox = forwardRef(function Checkbox2({
|
|
|
575
607
|
value,
|
|
576
608
|
icon: /* @__PURE__ */ jsx(Check, { size: 16 }),
|
|
577
609
|
pt: {
|
|
578
|
-
|
|
610
|
+
// Marcado pela prop do Cristal, não pelo atributo interno do Prime (data-p-highlight).
|
|
611
|
+
root: {
|
|
612
|
+
className: `cr-checkbox__control${checked ? " cr-checkbox__control--checked" : ""}`
|
|
613
|
+
},
|
|
579
614
|
input: { className: "cr-checkbox__input" },
|
|
580
615
|
box: { className: "cr-checkbox__box" },
|
|
581
616
|
icon: { className: "cr-checkbox__icon", "aria-hidden": true }
|
|
@@ -934,10 +969,17 @@ var Menu = forwardRef(function Menu2({
|
|
|
934
969
|
className
|
|
935
970
|
}, ref) {
|
|
936
971
|
const primeRef = useRef(null);
|
|
972
|
+
const alvo = useRef(null);
|
|
937
973
|
const context = useContext(PrimeReactContext);
|
|
938
974
|
useImperativeHandle(ref, () => ({
|
|
939
|
-
toggle: (event) =>
|
|
940
|
-
|
|
975
|
+
toggle: (event) => {
|
|
976
|
+
alvo.current = event.currentTarget;
|
|
977
|
+
primeRef.current?.toggle(event);
|
|
978
|
+
},
|
|
979
|
+
show: (event) => {
|
|
980
|
+
alvo.current = event.currentTarget;
|
|
981
|
+
primeRef.current?.show(event);
|
|
982
|
+
},
|
|
941
983
|
hide: (event) => primeRef.current?.hide(event),
|
|
942
984
|
getElement: () => primeRef.current?.getElement() ?? null
|
|
943
985
|
}));
|
|
@@ -975,6 +1017,12 @@ var Menu = forwardRef(function Menu2({
|
|
|
975
1017
|
};
|
|
976
1018
|
},
|
|
977
1019
|
content: { className: "cr-menu__content" },
|
|
1020
|
+
// Lado do popup (acima ou abaixo de quem o abriu), medido logo depois de o Prime posicionar.
|
|
1021
|
+
// Numa microtarefa: no onEnter o Prime ainda está religando a ref (getElement vem vazio); ela
|
|
1022
|
+
// roda logo depois, antes de a tela ser pintada.
|
|
1023
|
+
transition: aoPosicionar(
|
|
1024
|
+
() => queueMicrotask(() => seguirLado(primeRef.current?.getElement(), alvo.current))
|
|
1025
|
+
),
|
|
978
1026
|
action: { className: "cr-menu__action" },
|
|
979
1027
|
label: { className: "cr-menu__label" }
|
|
980
1028
|
};
|
|
@@ -1232,9 +1280,12 @@ var MenuPrincipal = forwardRef(
|
|
|
1232
1280
|
const primeRef = useRef(null);
|
|
1233
1281
|
const context = useContext(PrimeReactContext);
|
|
1234
1282
|
const [baseDoAlvo, setBaseDoAlvo] = useState();
|
|
1283
|
+
const alvo = useRef(null);
|
|
1235
1284
|
const medirAlvo = (event) => {
|
|
1236
|
-
const
|
|
1237
|
-
if (
|
|
1285
|
+
const elemento = event.currentTarget;
|
|
1286
|
+
if (!(elemento instanceof Element)) return;
|
|
1287
|
+
alvo.current = elemento;
|
|
1288
|
+
setBaseDoAlvo(elemento.getBoundingClientRect().bottom);
|
|
1238
1289
|
};
|
|
1239
1290
|
useImperativeHandle(ref, () => ({
|
|
1240
1291
|
toggle: (event) => {
|
|
@@ -1293,7 +1344,12 @@ var MenuPrincipal = forwardRef(
|
|
|
1293
1344
|
menu: { className: "cr-menu-principal__list", "aria-label": ariaLabel },
|
|
1294
1345
|
submenuHeader: { className: "cr-menu-principal__group" },
|
|
1295
1346
|
separator: { className: "cr-menu-principal__separator" },
|
|
1296
|
-
menuitem: { className: "cr-menu-principal__item" }
|
|
1347
|
+
menuitem: { className: "cr-menu-principal__item" },
|
|
1348
|
+
// Lado do popup, medido logo depois de o Prime posicionar.
|
|
1349
|
+
// Numa microtarefa: no onEnter o Prime ainda está religando a ref (como no Menu).
|
|
1350
|
+
transition: aoPosicionar(
|
|
1351
|
+
() => queueMicrotask(() => seguirLado(primeRef.current?.getElement(), alvo.current))
|
|
1352
|
+
)
|
|
1297
1353
|
};
|
|
1298
1354
|
const menu = /* @__PURE__ */ jsx(
|
|
1299
1355
|
Menu$1,
|
|
@@ -1780,9 +1836,23 @@ var Select = forwardRef(function Select2({
|
|
|
1780
1836
|
input: { className: "cr-select__value" },
|
|
1781
1837
|
trigger: { className: "cr-field__icon cr-select__trigger", "aria-hidden": true },
|
|
1782
1838
|
panel: { className: "cr-select__panel" },
|
|
1839
|
+
// Lado da lista (acima ou abaixo do campo), medido logo depois de o Prime posicionar.
|
|
1840
|
+
transition: aoPosicionar(
|
|
1841
|
+
() => seguirLado(
|
|
1842
|
+
document.getElementById(listId)?.closest(".cr-select__panel"),
|
|
1843
|
+
document.getElementById(inputId)?.closest(".cr-select__control")
|
|
1844
|
+
)
|
|
1845
|
+
),
|
|
1783
1846
|
wrapper: { className: "cr-select__wrapper" },
|
|
1784
1847
|
list: { className: "cr-select__list", id: listId },
|
|
1785
|
-
|
|
1848
|
+
// Selecionado e em foco (teclado) pelo contexto do pt, a API pública do Prime (não data-p-*).
|
|
1849
|
+
item: ({ context }) => ({
|
|
1850
|
+
className: [
|
|
1851
|
+
"cr-select__item",
|
|
1852
|
+
context.selected && "cr-select__item--selected",
|
|
1853
|
+
context.focused && "cr-select__item--focused"
|
|
1854
|
+
].filter(Boolean).join(" ")
|
|
1855
|
+
}),
|
|
1786
1856
|
emptyMessage: { className: "cr-select__item cr-select__empty" }
|
|
1787
1857
|
};
|
|
1788
1858
|
return /* @__PURE__ */ jsxs("div", { className: classes, children: [
|
|
@@ -1970,7 +2040,8 @@ var Radio = forwardRef(function Radio2({
|
|
|
1970
2040
|
disabled,
|
|
1971
2041
|
required,
|
|
1972
2042
|
pt: {
|
|
1973
|
-
|
|
2043
|
+
// Marcado pela prop do Cristal, não pelo atributo interno do Prime (data-p-checked).
|
|
2044
|
+
root: { className: `cr-radio__control${checked ? " cr-radio__control--checked" : ""}` },
|
|
1974
2045
|
input: { className: "cr-radio__input" },
|
|
1975
2046
|
box: { className: "cr-radio__box" },
|
|
1976
2047
|
icon: { className: "cr-radio__icon" }
|
|
@@ -2110,7 +2181,12 @@ var Switch = forwardRef(function Switch2({
|
|
|
2110
2181
|
disabled,
|
|
2111
2182
|
name,
|
|
2112
2183
|
pt: {
|
|
2113
|
-
|
|
2184
|
+
// Ligado pela prop do Cristal, não pelo atributo interno do Prime (data-p-highlight).
|
|
2185
|
+
root: {
|
|
2186
|
+
className: `cr-switch__control${checked ? " cr-switch__control--checked" : ""}`,
|
|
2187
|
+
role: void 0,
|
|
2188
|
+
"aria-checked": void 0
|
|
2189
|
+
},
|
|
2114
2190
|
input: { className: "cr-switch__input" },
|
|
2115
2191
|
slider: { className: "cr-switch__track" }
|
|
2116
2192
|
}
|