@vector-business-services/cristal-ds-web 0.12.0 → 0.13.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 CHANGED
@@ -211,6 +211,11 @@ var Card = react.forwardRef(function Card2({ padding = "xsmall", outline = false
211
211
  }
212
212
  );
213
213
  });
214
+ var usandoTeclado = false;
215
+ if (typeof document !== "undefined") {
216
+ document.addEventListener("keydown", () => usandoTeclado = true, true);
217
+ document.addEventListener("pointerdown", () => usandoTeclado = false, true);
218
+ }
214
219
  var resolveTargets = (target) => {
215
220
  if (typeof target === "string") return Array.from(document.querySelectorAll(target));
216
221
  if (target instanceof HTMLElement) return [target];
@@ -225,16 +230,18 @@ function Tooltip({
225
230
  showDelay,
226
231
  hideDelay,
227
232
  disabled,
233
+ describe = true,
228
234
  id,
229
235
  className
230
236
  }) {
231
237
  const autoId = react.useId();
232
238
  const tooltipId = id ?? autoId;
233
239
  react.useEffect(() => {
240
+ if (!describe) return;
234
241
  const elements = resolveTargets(target);
235
242
  elements.forEach((element) => element.setAttribute("aria-describedby", tooltipId));
236
243
  return () => elements.forEach((element) => element.removeAttribute("aria-describedby"));
237
- }, [target, tooltipId]);
244
+ }, [target, tooltipId, describe]);
238
245
  const classes = ["cr-tooltip", `cr-tooltip--${type}`, className].filter(Boolean).join(" ");
239
246
  const pt = {
240
247
  root: (options) => {
@@ -255,6 +262,7 @@ function Tooltip({
255
262
  showDelay,
256
263
  hideDelay,
257
264
  disabled,
265
+ onBeforeShow: (e) => e.originalEvent?.type !== "focus" || usandoTeclado,
258
266
  pt,
259
267
  children: content
260
268
  }
@@ -658,24 +666,54 @@ var Divider = react.forwardRef(function Divider2({ orientation = "horizontal", v
658
666
  }
659
667
  );
660
668
  });
661
- var IconButton = react.forwardRef(function IconButton2({ variant = "primary", size = "large", icon, type = "button", className, ...props }, ref) {
669
+ var IconButton = react.forwardRef(function IconButton2({
670
+ variant = "primary",
671
+ size = "large",
672
+ icon,
673
+ type = "button",
674
+ tooltip,
675
+ tooltipPosition,
676
+ className,
677
+ ...props
678
+ }, ref) {
679
+ const botao = react.useRef(null);
680
+ const ligar = react.useCallback(
681
+ (elemento) => {
682
+ botao.current = elemento;
683
+ if (typeof ref === "function") ref(elemento);
684
+ else if (ref) ref.current = elemento;
685
+ },
686
+ [ref]
687
+ );
688
+ const texto = tooltip ?? props["aria-label"];
662
689
  const classes = [
663
690
  "cr-icon-button",
664
691
  `cr-icon-button--${variant}`,
665
692
  `cr-icon-button--${size}`,
666
693
  className
667
694
  ].filter(Boolean).join(" ");
668
- return /* @__PURE__ */ jsxRuntime.jsx(
669
- button.Button,
670
- {
671
- unstyled: true,
672
- ref,
673
- type,
674
- className: classes,
675
- ...props,
676
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-icon-button__icon", "aria-hidden": "true", children: icon })
677
- }
678
- );
695
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
696
+ /* @__PURE__ */ jsxRuntime.jsx(
697
+ button.Button,
698
+ {
699
+ unstyled: true,
700
+ ref: ligar,
701
+ type,
702
+ className: classes,
703
+ ...props,
704
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-icon-button__icon", "aria-hidden": "true", children: icon })
705
+ }
706
+ ),
707
+ texto !== false && /* @__PURE__ */ jsxRuntime.jsx(
708
+ Tooltip,
709
+ {
710
+ target: botao,
711
+ content: texto,
712
+ position: tooltipPosition,
713
+ describe: texto !== props["aria-label"]
714
+ }
715
+ )
716
+ ] });
679
717
  });
680
718
  var FOCAVEIS = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
681
719
  function Drawer({
@@ -1592,7 +1630,9 @@ var PageHeader = react.forwardRef(function PageHeader2({
1592
1630
  segmentControl,
1593
1631
  actions,
1594
1632
  onExpand,
1633
+ expanded,
1595
1634
  expandLabel = "Expandir",
1635
+ collapseLabel = "Recolher",
1596
1636
  tabs,
1597
1637
  activeTab,
1598
1638
  onTabChange,
@@ -1602,6 +1642,8 @@ var PageHeader = react.forwardRef(function PageHeader2({
1602
1642
  }, ref) {
1603
1643
  const [interna, setInterna] = react.useState(0);
1604
1644
  const ativa = activeTab ?? interna;
1645
+ const [expandidoInterno, setExpandidoInterno] = react.useState(false);
1646
+ const expandido = expanded ?? expandidoInterno;
1605
1647
  const tools = segmentControl || actions;
1606
1648
  const tabTemplate = (tab) => (
1607
1649
  // O TabMenu também passa o index da aba nas opções, além do que o tipo do MenuItem declara.
@@ -1649,9 +1691,12 @@ var PageHeader = react.forwardRef(function PageHeader2({
1649
1691
  className: "cr-page-header__expand",
1650
1692
  variant: "tertiary",
1651
1693
  size: "medium",
1652
- icon: /* @__PURE__ */ jsxRuntime.jsx(react$1.ArrowsOutSimple, {}),
1653
- "aria-label": expandLabel,
1654
- onClick: onExpand
1694
+ icon: expandido ? /* @__PURE__ */ jsxRuntime.jsx(react$1.ArrowsInSimple, {}) : /* @__PURE__ */ jsxRuntime.jsx(react$1.ArrowsOutSimple, {}),
1695
+ "aria-label": expandido ? collapseLabel : expandLabel,
1696
+ onClick: () => {
1697
+ setExpandidoInterno(!expandido);
1698
+ onExpand(!expandido);
1699
+ }
1655
1700
  }
1656
1701
  )
1657
1702
  ]