@vector-business-services/cristal-ds-web 0.8.0 → 0.9.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
@@ -428,6 +428,45 @@ interface MultiSelectProps {
428
428
  }
429
429
  declare const MultiSelect: react.ForwardRefExoticComponent<MultiSelectProps & react.RefAttributes<HTMLInputElement>>;
430
430
 
431
+ /**
432
+ * Type no Figma: o estilo das abas. Primary tem o ícone em círculo e o fundo azul na aba ativa;
433
+ * Secondary é só o texto, com o sublinhado na ativa.
434
+ */
435
+ type PageHeaderVariant = 'primary' | 'secondary';
436
+ /** Uma aba (.Page Header Tab Item ou .Page Header Tab Secondary Item no Figma). */
437
+ interface PageHeaderTab {
438
+ label: string;
439
+ /** Ícone de 16px. No primary fica no círculo de 32px; no secondary é opcional. */
440
+ icon?: ReactNode;
441
+ disabled?: boolean;
442
+ }
443
+ interface PageHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
444
+ /** Título da página (Page Title no Figma). */
445
+ title: string;
446
+ /** Padrão: primary. */
447
+ variant?: PageHeaderVariant;
448
+ /** Mostra o botão de voltar antes do título (Show Back Button no Figma). */
449
+ onBack?: () => void;
450
+ backLabel?: string;
451
+ /** Texto da Tag depois do título (Show Tag no Figma). */
452
+ tag?: ReactNode;
453
+ /** Segment Control das ferramentas (Show Segment Control no Figma): um `<SegmentControl>`. */
454
+ segmentControl?: ReactNode;
455
+ /** Botões das ferramentas (Show Buttons no Figma), 8px entre eles. */
456
+ actions?: ReactNode;
457
+ /** Mostra o botão de expandir, o último das ferramentas. */
458
+ onExpand?: () => void;
459
+ expandLabel?: string;
460
+ /** Abas abaixo do título (Show Tabs no Figma). */
461
+ tabs?: PageHeaderTab[];
462
+ /** Aba ativa (controlado). Sem ela, o PageHeader controla sozinho. */
463
+ activeTab?: number;
464
+ onTabChange?: (index: number) => void;
465
+ /** Nome das abas para o leitor de tela. Padrão: o título. */
466
+ tabsLabel?: string;
467
+ }
468
+ declare const PageHeader: react.ForwardRefExoticComponent<PageHeaderProps & react.RefAttributes<HTMLDivElement>>;
469
+
431
470
  type PanelProps = Omit<HTMLAttributes<HTMLDivElement>, 'onToggle'>;
432
471
  declare const Panel: react.ForwardRefExoticComponent<PanelProps & react.RefAttributes<HTMLDivElement>>;
433
472
 
@@ -613,5 +652,5 @@ interface TooltipProps {
613
652
  }
614
653
  declare function Tooltip({ target, content, type, position, event, showDelay, hideDelay, disabled, id, className, }: TooltipProps): react.JSX.Element;
615
654
 
616
- 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 };
617
- 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, DrawerSize, 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 };
655
+ export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, MenuPrincipal, Menubar, Modal, MultiSelect, PageHeader, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
656
+ 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, DrawerSize, IconButtonProps, IconButtonSize, IconButtonVariant, InputProps, InputSize, InputVariant, MenuDensity, MenuHandle, MenuItem, MenuPrincipalEntry, MenuPrincipalGroup, MenuPrincipalHandle, MenuPrincipalItem, MenuPrincipalProps, MenuProps, MenubarProps, MenubarTool, MenubarUser, ModalProps, ModalSize, MultiSelectDensity, MultiSelectProps, MultiSelectSize, MultiSelectVariant, PageHeaderProps, PageHeaderTab, PageHeaderVariant, 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
@@ -428,6 +428,45 @@ interface MultiSelectProps {
428
428
  }
429
429
  declare const MultiSelect: react.ForwardRefExoticComponent<MultiSelectProps & react.RefAttributes<HTMLInputElement>>;
430
430
 
431
+ /**
432
+ * Type no Figma: o estilo das abas. Primary tem o ícone em círculo e o fundo azul na aba ativa;
433
+ * Secondary é só o texto, com o sublinhado na ativa.
434
+ */
435
+ type PageHeaderVariant = 'primary' | 'secondary';
436
+ /** Uma aba (.Page Header Tab Item ou .Page Header Tab Secondary Item no Figma). */
437
+ interface PageHeaderTab {
438
+ label: string;
439
+ /** Ícone de 16px. No primary fica no círculo de 32px; no secondary é opcional. */
440
+ icon?: ReactNode;
441
+ disabled?: boolean;
442
+ }
443
+ interface PageHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
444
+ /** Título da página (Page Title no Figma). */
445
+ title: string;
446
+ /** Padrão: primary. */
447
+ variant?: PageHeaderVariant;
448
+ /** Mostra o botão de voltar antes do título (Show Back Button no Figma). */
449
+ onBack?: () => void;
450
+ backLabel?: string;
451
+ /** Texto da Tag depois do título (Show Tag no Figma). */
452
+ tag?: ReactNode;
453
+ /** Segment Control das ferramentas (Show Segment Control no Figma): um `<SegmentControl>`. */
454
+ segmentControl?: ReactNode;
455
+ /** Botões das ferramentas (Show Buttons no Figma), 8px entre eles. */
456
+ actions?: ReactNode;
457
+ /** Mostra o botão de expandir, o último das ferramentas. */
458
+ onExpand?: () => void;
459
+ expandLabel?: string;
460
+ /** Abas abaixo do título (Show Tabs no Figma). */
461
+ tabs?: PageHeaderTab[];
462
+ /** Aba ativa (controlado). Sem ela, o PageHeader controla sozinho. */
463
+ activeTab?: number;
464
+ onTabChange?: (index: number) => void;
465
+ /** Nome das abas para o leitor de tela. Padrão: o título. */
466
+ tabsLabel?: string;
467
+ }
468
+ declare const PageHeader: react.ForwardRefExoticComponent<PageHeaderProps & react.RefAttributes<HTMLDivElement>>;
469
+
431
470
  type PanelProps = Omit<HTMLAttributes<HTMLDivElement>, 'onToggle'>;
432
471
  declare const Panel: react.ForwardRefExoticComponent<PanelProps & react.RefAttributes<HTMLDivElement>>;
433
472
 
@@ -613,5 +652,5 @@ interface TooltipProps {
613
652
  }
614
653
  declare function Tooltip({ target, content, type, position, event, showDelay, hideDelay, disabled, id, className, }: TooltipProps): react.JSX.Element;
615
654
 
616
- 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 };
617
- 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, DrawerSize, 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 };
655
+ export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, MenuPrincipal, Menubar, Modal, MultiSelect, PageHeader, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
656
+ 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, DrawerSize, IconButtonProps, IconButtonSize, IconButtonVariant, InputProps, InputSize, InputVariant, MenuDensity, MenuHandle, MenuItem, MenuPrincipalEntry, MenuPrincipalGroup, MenuPrincipalHandle, MenuPrincipalItem, MenuPrincipalProps, MenuProps, MenubarProps, MenubarTool, MenubarUser, ModalProps, ModalSize, MultiSelectDensity, MultiSelectProps, MultiSelectSize, MultiSelectVariant, PageHeaderProps, PageHeaderTab, PageHeaderVariant, 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, DribbbleLogo, ArrowLeft, Question } from '@phosphor-icons/react';
3
+ import { WarningCircle, Info, Check, CircleNotch, CaretDown, MagnifyingGlass, ArrowLeft, ArrowsOutSimple, CaretUp, X, List, DribbbleLogo, 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';
@@ -18,6 +18,7 @@ import { Tooltip as Tooltip$1 } from 'primereact/tooltip';
18
18
  import { Tag as Tag$1 } from 'primereact/tag';
19
19
  import { Dialog } from 'primereact/dialog';
20
20
  import { MultiSelect as MultiSelect$1 } from 'primereact/multiselect';
21
+ import { TabMenu } from 'primereact/tabmenu';
21
22
  import { Panel as Panel$1 } from 'primereact/panel';
22
23
  import { RadioButton } from 'primereact/radiobutton';
23
24
  import { ScrollPanel as ScrollPanel$1 } from 'primereact/scrollpanel';
@@ -1217,6 +1218,105 @@ var MultiSelect = forwardRef(function MultiSelect2({
1217
1218
  ] })
1218
1219
  ] });
1219
1220
  });
1221
+ var PageHeader = forwardRef(function PageHeader2({
1222
+ title,
1223
+ variant = "primary",
1224
+ onBack,
1225
+ backLabel = "Voltar",
1226
+ tag,
1227
+ segmentControl,
1228
+ actions,
1229
+ onExpand,
1230
+ expandLabel = "Expandir",
1231
+ tabs,
1232
+ activeTab,
1233
+ onTabChange,
1234
+ tabsLabel,
1235
+ className,
1236
+ ...props
1237
+ }, ref) {
1238
+ const [interna, setInterna] = useState(0);
1239
+ const ativa = activeTab ?? interna;
1240
+ const tools = segmentControl || actions;
1241
+ const tabTemplate = (tab) => (
1242
+ // O TabMenu também passa o index da aba nas opções, além do que o tipo do MenuItem declara.
1243
+ function TabContent(item, options) {
1244
+ const { element, index } = options;
1245
+ const active = index === ativa;
1246
+ return cloneElement(
1247
+ element,
1248
+ { "aria-current": active ? "page" : void 0 },
1249
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1250
+ (variant === "primary" || tab.icon) && /* @__PURE__ */ jsx("span", { className: "cr-page-header__tab-icon", "aria-hidden": "true", children: tab.icon }),
1251
+ /* @__PURE__ */ jsx("span", { className: "cr-page-header__tab-label", children: item.label })
1252
+ ] })
1253
+ );
1254
+ }
1255
+ );
1256
+ const classes = ["cr-page-header", `cr-page-header--${variant}`, className].filter(Boolean).join(" ");
1257
+ return /* @__PURE__ */ jsxs("div", { ref, className: classes, ...props, children: [
1258
+ /* @__PURE__ */ jsxs(
1259
+ "div",
1260
+ {
1261
+ className: `cr-page-header__title-group${tools ? " cr-page-header__title-group--tools" : ""}`,
1262
+ children: [
1263
+ /* @__PURE__ */ jsxs("div", { className: "cr-page-header__title-text", children: [
1264
+ onBack && /* @__PURE__ */ jsx(
1265
+ IconButton,
1266
+ {
1267
+ variant: "tertiary",
1268
+ size: "small",
1269
+ icon: /* @__PURE__ */ jsx(ArrowLeft, {}),
1270
+ "aria-label": backLabel,
1271
+ onClick: onBack
1272
+ }
1273
+ ),
1274
+ /* @__PURE__ */ jsx("h1", { className: "cr-page-header__title", children: title }),
1275
+ tag && /* @__PURE__ */ jsx(Tag, { className: "cr-page-header__tag", children: tag })
1276
+ ] }),
1277
+ tools && /* @__PURE__ */ jsxs("div", { className: "cr-page-header__tools", children: [
1278
+ segmentControl && /* @__PURE__ */ jsx("div", { className: "cr-page-header__segment", children: segmentControl }),
1279
+ actions && /* @__PURE__ */ jsx("div", { className: "cr-page-header__actions", children: actions })
1280
+ ] }),
1281
+ onExpand && /* @__PURE__ */ jsx(
1282
+ IconButton,
1283
+ {
1284
+ className: "cr-page-header__expand",
1285
+ variant: "tertiary",
1286
+ size: "medium",
1287
+ icon: /* @__PURE__ */ jsx(ArrowsOutSimple, {}),
1288
+ "aria-label": expandLabel,
1289
+ onClick: onExpand
1290
+ }
1291
+ )
1292
+ ]
1293
+ }
1294
+ ),
1295
+ tabs && tabs.length > 0 && /* @__PURE__ */ jsx(
1296
+ TabMenu,
1297
+ {
1298
+ unstyled: true,
1299
+ model: tabs.map((tab) => ({
1300
+ label: tab.label,
1301
+ disabled: tab.disabled,
1302
+ template: tabTemplate(tab)
1303
+ })),
1304
+ activeIndex: ativa,
1305
+ onTabChange: (event) => {
1306
+ setInterna(event.index);
1307
+ onTabChange?.(event.index);
1308
+ },
1309
+ pt: {
1310
+ root: { className: "cr-page-header__tabs" },
1311
+ menu: { className: "cr-page-header__tab-list", "aria-label": tabsLabel ?? title },
1312
+ menuitem: { className: "cr-page-header__tab-item" },
1313
+ action: { className: "cr-page-header__tab" },
1314
+ inkbar: { className: "cr-page-header__inkbar" }
1315
+ }
1316
+ }
1317
+ )
1318
+ ] });
1319
+ });
1220
1320
  var Panel = forwardRef(function Panel2({ className, style, children, ...props }, ref) {
1221
1321
  const primeRef = useRef(null);
1222
1322
  useImperativeHandle(ref, () => primeRef.current?.getElement());
@@ -1614,6 +1714,6 @@ var Tabs = forwardRef(function Tabs2({ activeIndex, onTabChange, children, id, c
1614
1714
  );
1615
1715
  });
1616
1716
 
1617
- 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 };
1717
+ export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, MenuPrincipal, Menubar, Modal, MultiSelect, PageHeader, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
1618
1718
  //# sourceMappingURL=index.js.map
1619
1719
  //# sourceMappingURL=index.js.map