@vector-business-services/cristal-ds-web 0.6.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.d.cts CHANGED
@@ -294,6 +294,54 @@ interface MenubarProps {
294
294
  }
295
295
  declare const Menubar: react.ForwardRefExoticComponent<MenubarProps & react.RefAttributes<HTMLDivElement>>;
296
296
 
297
+ /** Um produto do menu (.Menu Principal / Item no Figma). */
298
+ interface MenuPrincipalItem {
299
+ /** Nome do produto (Item Label no Figma). */
300
+ label: string;
301
+ /** Texto de apoio abaixo do nome, até 2 linhas. */
302
+ description?: string;
303
+ /** Ícone no círculo à esquerda. Use um ícone de `@vector-business-services/cristal-ds-web/icons`. */
304
+ icon: ReactNode;
305
+ /** Texto da tag no canto (Show Tag no Figma, onde é "Experimente"). */
306
+ tag?: string;
307
+ /** Ação do item; o menu popup fecha depois dela. */
308
+ command?: (event: MenuItemCommandEvent) => void;
309
+ /** Link do item; sem ele o clique não navega. */
310
+ url?: string;
311
+ target?: string;
312
+ id?: string;
313
+ className?: string;
314
+ }
315
+ /** Um grupo de produtos com título (Product Group no Figma). */
316
+ interface MenuPrincipalGroup {
317
+ /** Título do grupo, acima dos itens. */
318
+ label: string;
319
+ items: MenuPrincipalItem[];
320
+ id?: string;
321
+ }
322
+ type MenuPrincipalEntry = MenuPrincipalItem | MenuPrincipalGroup;
323
+ interface MenuPrincipalProps {
324
+ /** Itens soltos e grupos, na ordem; o divisor tracejado entra antes e depois de cada grupo. */
325
+ model: MenuPrincipalEntry[];
326
+ /** Abre sobre a tela, posicionado no elemento que chamou `toggle`/`show` pela ref. */
327
+ popup?: boolean;
328
+ /** Nome acessível do menu. */
329
+ 'aria-label'?: string;
330
+ onShow?: (event: SyntheticEvent) => void;
331
+ onHide?: (event: SyntheticEvent) => void;
332
+ id?: string;
333
+ className?: string;
334
+ }
335
+ /** Controle do menu popup, pela ref. */
336
+ interface MenuPrincipalHandle {
337
+ toggle: (event: SyntheticEvent) => void;
338
+ show: (event: SyntheticEvent) => void;
339
+ hide: (event: SyntheticEvent) => void;
340
+ /** O <div> raiz do menu (só existe com o popup aberto). */
341
+ getElement: () => HTMLDivElement | null;
342
+ }
343
+ declare const MenuPrincipal: react.ForwardRefExoticComponent<MenuPrincipalProps & react.RefAttributes<MenuPrincipalHandle>>;
344
+
297
345
  /**
298
346
  * Size no Figma: Small (520px), Medium (768px) e Large (1200 x 720px; abaixo de 768px de tela
299
347
  * vira tela cheia, como o Responsive=360 do Figma).
@@ -558,5 +606,5 @@ interface TooltipProps {
558
606
  }
559
607
  declare function Tooltip({ target, content, type, position, event, showDelay, hideDelay, disabled, id, className, }: TooltipProps): react.JSX.Element;
560
608
 
561
- export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, Menubar, Modal, MultiSelect, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
562
- export type { AutoCompleteProps, AutoCompleteSize, AutoCompleteVariant, BadgeProps, BadgeSize, BadgeVariant, ButtonProps, ButtonSize, ButtonVariant, CardPadding, CardProps, CheckboxLabelSize, CheckboxPosition, CheckboxProps, ChipProps, ChipSize, ChipVariant, DividerOrientation, DividerProps, DividerVariant, DrawerBehavior, DrawerProps, DrawerSide, IconButtonProps, IconButtonSize, IconButtonVariant, InputProps, InputSize, InputVariant, MenuDensity, MenuHandle, MenuItem, MenuProps, MenubarProps, MenubarTool, MenubarUser, ModalProps, ModalSize, MultiSelectDensity, MultiSelectProps, MultiSelectSize, MultiSelectVariant, PanelProps, RadioLabelSize, RadioProps, ScrollPanelProps, SegmentControlOption, SegmentControlProps, SegmentControlVariant, SelectProps, SelectSize, SelectVariant, SwitchLabelPosition, SwitchProps, SwitchSize, TabPanelProps, TabsProps, TagProps, TagSize, TagVariant, TooltipPosition, TooltipProps, TooltipType };
609
+ export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, MenuPrincipal, Menubar, Modal, MultiSelect, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
610
+ export type { AutoCompleteProps, AutoCompleteSize, AutoCompleteVariant, BadgeProps, BadgeSize, BadgeVariant, ButtonProps, ButtonSize, ButtonVariant, CardPadding, CardProps, CheckboxLabelSize, CheckboxPosition, CheckboxProps, ChipProps, ChipSize, ChipVariant, DividerOrientation, DividerProps, DividerVariant, DrawerBehavior, DrawerProps, DrawerSide, IconButtonProps, IconButtonSize, IconButtonVariant, InputProps, InputSize, InputVariant, MenuDensity, MenuHandle, MenuItem, MenuPrincipalEntry, MenuPrincipalGroup, MenuPrincipalHandle, MenuPrincipalItem, MenuPrincipalProps, MenuProps, MenubarProps, MenubarTool, MenubarUser, ModalProps, ModalSize, MultiSelectDensity, MultiSelectProps, MultiSelectSize, MultiSelectVariant, PanelProps, RadioLabelSize, RadioProps, ScrollPanelProps, SegmentControlOption, SegmentControlProps, SegmentControlVariant, SelectProps, SelectSize, SelectVariant, SwitchLabelPosition, SwitchProps, SwitchSize, TabPanelProps, TabsProps, TagProps, TagSize, TagVariant, TooltipPosition, TooltipProps, TooltipType };
package/dist/index.d.ts CHANGED
@@ -294,6 +294,54 @@ interface MenubarProps {
294
294
  }
295
295
  declare const Menubar: react.ForwardRefExoticComponent<MenubarProps & react.RefAttributes<HTMLDivElement>>;
296
296
 
297
+ /** Um produto do menu (.Menu Principal / Item no Figma). */
298
+ interface MenuPrincipalItem {
299
+ /** Nome do produto (Item Label no Figma). */
300
+ label: string;
301
+ /** Texto de apoio abaixo do nome, até 2 linhas. */
302
+ description?: string;
303
+ /** Ícone no círculo à esquerda. Use um ícone de `@vector-business-services/cristal-ds-web/icons`. */
304
+ icon: ReactNode;
305
+ /** Texto da tag no canto (Show Tag no Figma, onde é "Experimente"). */
306
+ tag?: string;
307
+ /** Ação do item; o menu popup fecha depois dela. */
308
+ command?: (event: MenuItemCommandEvent) => void;
309
+ /** Link do item; sem ele o clique não navega. */
310
+ url?: string;
311
+ target?: string;
312
+ id?: string;
313
+ className?: string;
314
+ }
315
+ /** Um grupo de produtos com título (Product Group no Figma). */
316
+ interface MenuPrincipalGroup {
317
+ /** Título do grupo, acima dos itens. */
318
+ label: string;
319
+ items: MenuPrincipalItem[];
320
+ id?: string;
321
+ }
322
+ type MenuPrincipalEntry = MenuPrincipalItem | MenuPrincipalGroup;
323
+ interface MenuPrincipalProps {
324
+ /** Itens soltos e grupos, na ordem; o divisor tracejado entra antes e depois de cada grupo. */
325
+ model: MenuPrincipalEntry[];
326
+ /** Abre sobre a tela, posicionado no elemento que chamou `toggle`/`show` pela ref. */
327
+ popup?: boolean;
328
+ /** Nome acessível do menu. */
329
+ 'aria-label'?: string;
330
+ onShow?: (event: SyntheticEvent) => void;
331
+ onHide?: (event: SyntheticEvent) => void;
332
+ id?: string;
333
+ className?: string;
334
+ }
335
+ /** Controle do menu popup, pela ref. */
336
+ interface MenuPrincipalHandle {
337
+ toggle: (event: SyntheticEvent) => void;
338
+ show: (event: SyntheticEvent) => void;
339
+ hide: (event: SyntheticEvent) => void;
340
+ /** O <div> raiz do menu (só existe com o popup aberto). */
341
+ getElement: () => HTMLDivElement | null;
342
+ }
343
+ declare const MenuPrincipal: react.ForwardRefExoticComponent<MenuPrincipalProps & react.RefAttributes<MenuPrincipalHandle>>;
344
+
297
345
  /**
298
346
  * Size no Figma: Small (520px), Medium (768px) e Large (1200 x 720px; abaixo de 768px de tela
299
347
  * vira tela cheia, como o Responsive=360 do Figma).
@@ -558,5 +606,5 @@ interface TooltipProps {
558
606
  }
559
607
  declare function Tooltip({ target, content, type, position, event, showDelay, hideDelay, disabled, id, className, }: TooltipProps): react.JSX.Element;
560
608
 
561
- export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, Menubar, Modal, MultiSelect, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
562
- export type { AutoCompleteProps, AutoCompleteSize, AutoCompleteVariant, BadgeProps, BadgeSize, BadgeVariant, ButtonProps, ButtonSize, ButtonVariant, CardPadding, CardProps, CheckboxLabelSize, CheckboxPosition, CheckboxProps, ChipProps, ChipSize, ChipVariant, DividerOrientation, DividerProps, DividerVariant, DrawerBehavior, DrawerProps, DrawerSide, IconButtonProps, IconButtonSize, IconButtonVariant, InputProps, InputSize, InputVariant, MenuDensity, MenuHandle, MenuItem, MenuProps, MenubarProps, MenubarTool, MenubarUser, ModalProps, ModalSize, MultiSelectDensity, MultiSelectProps, MultiSelectSize, MultiSelectVariant, PanelProps, RadioLabelSize, RadioProps, ScrollPanelProps, SegmentControlOption, SegmentControlProps, SegmentControlVariant, SelectProps, SelectSize, SelectVariant, SwitchLabelPosition, SwitchProps, SwitchSize, TabPanelProps, TabsProps, TagProps, TagSize, TagVariant, TooltipPosition, TooltipProps, TooltipType };
609
+ export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, MenuPrincipal, Menubar, Modal, MultiSelect, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
610
+ export type { AutoCompleteProps, AutoCompleteSize, AutoCompleteVariant, BadgeProps, BadgeSize, BadgeVariant, ButtonProps, ButtonSize, ButtonVariant, CardPadding, CardProps, CheckboxLabelSize, CheckboxPosition, CheckboxProps, ChipProps, ChipSize, ChipVariant, DividerOrientation, DividerProps, DividerVariant, DrawerBehavior, DrawerProps, DrawerSide, IconButtonProps, IconButtonSize, IconButtonVariant, InputProps, InputSize, InputVariant, MenuDensity, MenuHandle, MenuItem, MenuPrincipalEntry, MenuPrincipalGroup, MenuPrincipalHandle, MenuPrincipalItem, MenuPrincipalProps, MenuProps, MenubarProps, MenubarTool, MenubarUser, ModalProps, ModalSize, MultiSelectDensity, MultiSelectProps, MultiSelectSize, MultiSelectVariant, PanelProps, RadioLabelSize, RadioProps, ScrollPanelProps, SegmentControlOption, SegmentControlProps, SegmentControlVariant, SelectProps, SelectSize, SelectVariant, SwitchLabelPosition, SwitchProps, SwitchSize, TabPanelProps, TabsProps, TagProps, TagSize, TagVariant, TooltipPosition, TooltipProps, TooltipType };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, useId, useRef, useImperativeHandle, useCallback, useEffect, useContext, useState, Children, isValidElement, cloneElement } from 'react';
2
2
  import { AutoComplete as AutoComplete$1 } from 'primereact/autocomplete';
3
- import { WarningCircle, Info, Check, CircleNotch, CaretDown, MagnifyingGlass, CaretUp, X, List, ArrowLeft, Question } from '@phosphor-icons/react';
3
+ import { WarningCircle, Info, Check, CircleNotch, CaretDown, MagnifyingGlass, CaretUp, X, List, DribbbleLogo, ArrowLeft, Question } from '@phosphor-icons/react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import { Badge as Badge$1 } from 'primereact/badge';
6
6
  import { Button as Button$1 } from 'primereact/button';
@@ -15,6 +15,7 @@ import { Menu as Menu$1 } from 'primereact/menu';
15
15
  import { Menubar as Menubar$1 } from 'primereact/menubar';
16
16
  import { Avatar } from 'primereact/avatar';
17
17
  import { Tooltip as Tooltip$1 } from 'primereact/tooltip';
18
+ import { Tag as Tag$1 } from 'primereact/tag';
18
19
  import { Dialog } from 'primereact/dialog';
19
20
  import { MultiSelect as MultiSelect$1 } from 'primereact/multiselect';
20
21
  import { Panel as Panel$1 } from 'primereact/panel';
@@ -24,7 +25,6 @@ import { SelectButton } from 'primereact/selectbutton';
24
25
  import { Dropdown } from 'primereact/dropdown';
25
26
  import { InputSwitch } from 'primereact/inputswitch';
26
27
  import { TabView, TabPanel as TabPanel$1 } from 'primereact/tabview';
27
- import { Tag as Tag$1 } from 'primereact/tag';
28
28
 
29
29
  // src/components/AutoComplete/AutoComplete.tsx
30
30
  var AutoComplete = forwardRef(function AutoComplete2({
@@ -842,6 +842,105 @@ var Menubar = forwardRef(function Menubar2({
842
842
  }
843
843
  ) });
844
844
  });
845
+ var Tag = forwardRef(function Tag2({ variant = "default", size = "small", icon, className, children, ...props }, ref) {
846
+ const primeRef = useRef(null);
847
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
848
+ const classes = ["cr-tag", `cr-tag--${variant}`, `cr-tag--${size}`, className].filter(Boolean).join(" ");
849
+ return /* @__PURE__ */ jsx(
850
+ Tag$1,
851
+ {
852
+ unstyled: true,
853
+ ref: primeRef,
854
+ className: classes,
855
+ icon: icon ? () => /* @__PURE__ */ jsx("span", { className: "cr-tag__icon", "aria-hidden": "true", children: icon }) : void 0,
856
+ value: children,
857
+ ...props
858
+ }
859
+ );
860
+ });
861
+ var isGroup = (entry) => "items" in entry;
862
+ var MenuPrincipal = forwardRef(
863
+ function MenuPrincipal2({
864
+ model,
865
+ popup = false,
866
+ "aria-label": ariaLabel = "Menu principal",
867
+ onShow,
868
+ onHide,
869
+ id,
870
+ className
871
+ }, ref) {
872
+ const primeRef = useRef(null);
873
+ const context = useContext(PrimeReactContext);
874
+ useImperativeHandle(ref, () => ({
875
+ toggle: (event) => primeRef.current?.toggle(event),
876
+ show: (event) => primeRef.current?.show(event),
877
+ hide: (event) => primeRef.current?.hide(event),
878
+ getElement: () => primeRef.current?.getElement() ?? null
879
+ }));
880
+ const toPrime = (item) => ({
881
+ id: item.id,
882
+ // Sem label no Prime: ele viraria o aria-label do item, só com parte do texto visível. O
883
+ // nome vem do conteúdo: o nome, a descrição e a tag. Os espaços entre eles não aparecem
884
+ // (estão em flex), mas separam as palavras no nome ("Início Tela inicial", não colado).
885
+ command: item.command,
886
+ url: item.url,
887
+ target: item.target,
888
+ className: item.className,
889
+ // O <a> leva o data-pc-section do Prime: o Enter do teclado clica nele (e segue o link).
890
+ template: () => /* @__PURE__ */ jsxs(
891
+ "a",
892
+ {
893
+ className: "cr-menu-principal__action",
894
+ "data-pc-section": "action",
895
+ href: item.url ?? "#",
896
+ target: item.target,
897
+ tabIndex: -1,
898
+ children: [
899
+ /* @__PURE__ */ jsx("span", { className: "cr-menu-principal__icon", "aria-hidden": "true", children: item.icon }),
900
+ /* @__PURE__ */ jsxs("span", { className: "cr-menu-principal__text", children: [
901
+ /* @__PURE__ */ jsx("span", { className: "cr-menu-principal__label", children: item.label }),
902
+ " ",
903
+ item.description && /* @__PURE__ */ jsx("span", { className: "cr-menu-principal__description", children: item.description })
904
+ ] }),
905
+ " ",
906
+ item.tag && /* @__PURE__ */ jsx(Tag, { className: "cr-menu-principal__tag", variant: "warning", icon: /* @__PURE__ */ jsx(DribbbleLogo, {}), children: item.tag })
907
+ ]
908
+ }
909
+ )
910
+ });
911
+ const items = [];
912
+ let anterior;
913
+ model.forEach((entry) => {
914
+ if (anterior && (isGroup(entry) || isGroup(anterior))) items.push({ separator: true });
915
+ items.push(
916
+ isGroup(entry) ? { id: entry.id, label: entry.label, items: entry.items.map(toPrime) } : toPrime(entry)
917
+ );
918
+ anterior = entry;
919
+ });
920
+ const classes = ["cr-menu-principal", popup && "cr-menu-principal--popup", className].filter(Boolean).join(" ");
921
+ const pt = {
922
+ menu: { className: "cr-menu-principal__list", "aria-label": ariaLabel },
923
+ submenuHeader: { className: "cr-menu-principal__group" },
924
+ separator: { className: "cr-menu-principal__separator" },
925
+ menuitem: { className: "cr-menu-principal__item" }
926
+ };
927
+ const menu = /* @__PURE__ */ jsx(
928
+ Menu$1,
929
+ {
930
+ unstyled: true,
931
+ ref: primeRef,
932
+ id,
933
+ className: classes,
934
+ model: items,
935
+ popup,
936
+ onShow,
937
+ onHide,
938
+ pt
939
+ }
940
+ );
941
+ return context ? menu : /* @__PURE__ */ jsx(PrimeReactProvider, { children: menu });
942
+ }
943
+ );
845
944
  function Modal({
846
945
  visible,
847
946
  onHide,
@@ -1507,23 +1606,7 @@ var Tabs = forwardRef(function Tabs2({ activeIndex, onTabChange, children, id, c
1507
1606
  }
1508
1607
  );
1509
1608
  });
1510
- var Tag = forwardRef(function Tag2({ variant = "default", size = "small", icon, className, children, ...props }, ref) {
1511
- const primeRef = useRef(null);
1512
- useImperativeHandle(ref, () => primeRef.current?.getElement());
1513
- const classes = ["cr-tag", `cr-tag--${variant}`, `cr-tag--${size}`, className].filter(Boolean).join(" ");
1514
- return /* @__PURE__ */ jsx(
1515
- Tag$1,
1516
- {
1517
- unstyled: true,
1518
- ref: primeRef,
1519
- className: classes,
1520
- icon: icon ? () => /* @__PURE__ */ jsx("span", { className: "cr-tag__icon", "aria-hidden": "true", children: icon }) : void 0,
1521
- value: children,
1522
- ...props
1523
- }
1524
- );
1525
- });
1526
1609
 
1527
- export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, Menubar, Modal, MultiSelect, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
1610
+ export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, MenuPrincipal, Menubar, Modal, MultiSelect, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
1528
1611
  //# sourceMappingURL=index.js.map
1529
1612
  //# sourceMappingURL=index.js.map