@vector-business-services/cristal-ds-web 0.5.0 → 0.7.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
@@ -17,6 +17,7 @@ var menu = require('primereact/menu');
17
17
  var menubar = require('primereact/menubar');
18
18
  var avatar = require('primereact/avatar');
19
19
  var tooltip = require('primereact/tooltip');
20
+ var tag = require('primereact/tag');
20
21
  var dialog = require('primereact/dialog');
21
22
  var multiselect = require('primereact/multiselect');
22
23
  var panel = require('primereact/panel');
@@ -26,7 +27,6 @@ var selectbutton = require('primereact/selectbutton');
26
27
  var dropdown = require('primereact/dropdown');
27
28
  var inputswitch = require('primereact/inputswitch');
28
29
  var tabview = require('primereact/tabview');
29
- var tag = require('primereact/tag');
30
30
 
31
31
  // src/components/AutoComplete/AutoComplete.tsx
32
32
  var AutoComplete = react.forwardRef(function AutoComplete2({
@@ -321,6 +321,7 @@ function Drawer({
321
321
  subtitle,
322
322
  side = "right",
323
323
  behavior = "full",
324
+ modal = true,
324
325
  onBack,
325
326
  backLabel = "Voltar",
326
327
  closeLabel = "Fechar",
@@ -354,7 +355,7 @@ function Drawer({
354
355
  return () => observer.disconnect();
355
356
  }, [rolagem, children]);
356
357
  const prenderFoco = (event) => {
357
- if (event.key !== "Tab" || !panelRef.current) return;
358
+ if (!modal || event.key !== "Tab" || !panelRef.current) return;
358
359
  const focaveis = [...panelRef.current.querySelectorAll(FOCAVEIS)];
359
360
  const primeiro = focaveis[0];
360
361
  const ultimo = focaveis[focaveis.length - 1];
@@ -376,16 +377,29 @@ function Drawer({
376
377
  visible,
377
378
  onHide,
378
379
  position: side,
379
- blockScroll: true,
380
+ modal,
381
+ blockScroll: modal,
382
+ dismissable: modal,
380
383
  pt: {
381
- mask: { className: `cr-drawer__mask cr-drawer__mask--${side}` },
384
+ mask: {
385
+ className: `cr-drawer__mask cr-drawer__mask--${side}${modal ? "" : " cr-drawer__mask--sem-overlay"}`
386
+ },
382
387
  root: {
383
388
  className: classes,
384
389
  role: "dialog",
385
- "aria-modal": true,
390
+ "aria-modal": modal || void 0,
386
391
  "aria-labelledby": titleId,
387
392
  "aria-describedby": subtitle ? subtitleId : void 0,
388
393
  onKeyDown: prenderFoco
394
+ },
395
+ // No unstyled o Prime não põe classes na transição: o Cristal dá as dele (Drawer.css).
396
+ // O tipo do Prime exige o addEndListener do react-transition-group, que aqui não se usa.
397
+ transition: {
398
+ classNames: {
399
+ enter: "cr-drawer--enter",
400
+ enterActive: "cr-drawer--enter-active",
401
+ exitActive: "cr-drawer--exit-active"
402
+ }
389
403
  }
390
404
  },
391
405
  content: ({ closeIconRef, hide }) => /* @__PURE__ */ jsxRuntime.jsxs(
@@ -830,6 +844,105 @@ var Menubar = react.forwardRef(function Menubar2({
830
844
  }
831
845
  ) });
832
846
  });
847
+ var Tag = react.forwardRef(function Tag2({ variant = "default", size = "small", icon, className, children, ...props }, ref) {
848
+ const primeRef = react.useRef(null);
849
+ react.useImperativeHandle(ref, () => primeRef.current?.getElement());
850
+ const classes = ["cr-tag", `cr-tag--${variant}`, `cr-tag--${size}`, className].filter(Boolean).join(" ");
851
+ return /* @__PURE__ */ jsxRuntime.jsx(
852
+ tag.Tag,
853
+ {
854
+ unstyled: true,
855
+ ref: primeRef,
856
+ className: classes,
857
+ icon: icon ? () => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-tag__icon", "aria-hidden": "true", children: icon }) : void 0,
858
+ value: children,
859
+ ...props
860
+ }
861
+ );
862
+ });
863
+ var isGroup = (entry) => "items" in entry;
864
+ var MenuPrincipal = react.forwardRef(
865
+ function MenuPrincipal2({
866
+ model,
867
+ popup = false,
868
+ "aria-label": ariaLabel = "Menu principal",
869
+ onShow,
870
+ onHide,
871
+ id,
872
+ className
873
+ }, ref) {
874
+ const primeRef = react.useRef(null);
875
+ const context = react.useContext(api.PrimeReactContext);
876
+ react.useImperativeHandle(ref, () => ({
877
+ toggle: (event) => primeRef.current?.toggle(event),
878
+ show: (event) => primeRef.current?.show(event),
879
+ hide: (event) => primeRef.current?.hide(event),
880
+ getElement: () => primeRef.current?.getElement() ?? null
881
+ }));
882
+ const toPrime = (item) => ({
883
+ id: item.id,
884
+ // Sem label no Prime: ele viraria o aria-label do item, só com parte do texto visível. O
885
+ // nome vem do conteúdo: o nome, a descrição e a tag. Os espaços entre eles não aparecem
886
+ // (estão em flex), mas separam as palavras no nome ("Início Tela inicial", não colado).
887
+ command: item.command,
888
+ url: item.url,
889
+ target: item.target,
890
+ className: item.className,
891
+ // O <a> leva o data-pc-section do Prime: o Enter do teclado clica nele (e segue o link).
892
+ template: () => /* @__PURE__ */ jsxRuntime.jsxs(
893
+ "a",
894
+ {
895
+ className: "cr-menu-principal__action",
896
+ "data-pc-section": "action",
897
+ href: item.url ?? "#",
898
+ target: item.target,
899
+ tabIndex: -1,
900
+ children: [
901
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-menu-principal__icon", "aria-hidden": "true", children: item.icon }),
902
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "cr-menu-principal__text", children: [
903
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-menu-principal__label", children: item.label }),
904
+ " ",
905
+ item.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-menu-principal__description", children: item.description })
906
+ ] }),
907
+ " ",
908
+ item.tag && /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: "cr-menu-principal__tag", variant: "warning", icon: /* @__PURE__ */ jsxRuntime.jsx(react$1.DribbbleLogo, {}), children: item.tag })
909
+ ]
910
+ }
911
+ )
912
+ });
913
+ const items = [];
914
+ let anterior;
915
+ model.forEach((entry) => {
916
+ if (anterior && (isGroup(entry) || isGroup(anterior))) items.push({ separator: true });
917
+ items.push(
918
+ isGroup(entry) ? { id: entry.id, label: entry.label, items: entry.items.map(toPrime) } : toPrime(entry)
919
+ );
920
+ anterior = entry;
921
+ });
922
+ const classes = ["cr-menu-principal", popup && "cr-menu-principal--popup", className].filter(Boolean).join(" ");
923
+ const pt = {
924
+ menu: { className: "cr-menu-principal__list", "aria-label": ariaLabel },
925
+ submenuHeader: { className: "cr-menu-principal__group" },
926
+ separator: { className: "cr-menu-principal__separator" },
927
+ menuitem: { className: "cr-menu-principal__item" }
928
+ };
929
+ const menu$1 = /* @__PURE__ */ jsxRuntime.jsx(
930
+ menu.Menu,
931
+ {
932
+ unstyled: true,
933
+ ref: primeRef,
934
+ id,
935
+ className: classes,
936
+ model: items,
937
+ popup,
938
+ onShow,
939
+ onHide,
940
+ pt
941
+ }
942
+ );
943
+ return context ? menu$1 : /* @__PURE__ */ jsxRuntime.jsx(api.PrimeReactProvider, { children: menu$1 });
944
+ }
945
+ );
833
946
  function Modal({
834
947
  visible,
835
948
  onHide,
@@ -1495,22 +1608,6 @@ var Tabs = react.forwardRef(function Tabs2({ activeIndex, onTabChange, children,
1495
1608
  }
1496
1609
  );
1497
1610
  });
1498
- var Tag = react.forwardRef(function Tag2({ variant = "default", size = "small", icon, className, children, ...props }, ref) {
1499
- const primeRef = react.useRef(null);
1500
- react.useImperativeHandle(ref, () => primeRef.current?.getElement());
1501
- const classes = ["cr-tag", `cr-tag--${variant}`, `cr-tag--${size}`, className].filter(Boolean).join(" ");
1502
- return /* @__PURE__ */ jsxRuntime.jsx(
1503
- tag.Tag,
1504
- {
1505
- unstyled: true,
1506
- ref: primeRef,
1507
- className: classes,
1508
- icon: icon ? () => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-tag__icon", "aria-hidden": "true", children: icon }) : void 0,
1509
- value: children,
1510
- ...props
1511
- }
1512
- );
1513
- });
1514
1611
 
1515
1612
  exports.AutoComplete = AutoComplete;
1516
1613
  exports.Badge = Badge;
@@ -1523,6 +1620,7 @@ exports.Drawer = Drawer;
1523
1620
  exports.IconButton = IconButton;
1524
1621
  exports.Input = Input;
1525
1622
  exports.Menu = Menu;
1623
+ exports.MenuPrincipal = MenuPrincipal;
1526
1624
  exports.Menubar = Menubar;
1527
1625
  exports.Modal = Modal;
1528
1626
  exports.MultiSelect = MultiSelect;