@vector-business-services/cristal-ds-web 0.7.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
@@ -149,6 +149,11 @@ type DrawerSide = 'right' | 'left';
149
149
  * corpo rola).
150
150
  */
151
151
  type DrawerBehavior = 'full' | 'fixed';
152
+ /**
153
+ * Largura da gaveta. O Figma só tem a de 340px (small); medium (480px), large (720px) e full (a
154
+ * tela toda) são do Cristal, nas faixas usuais de drawer.
155
+ */
156
+ type DrawerSize = 'small' | 'medium' | 'large' | 'full';
152
157
  interface DrawerProps {
153
158
  visible: boolean;
154
159
  /** Pedido para fechar (X, Esc ou clique no overlay). */
@@ -161,6 +166,8 @@ interface DrawerProps {
161
166
  side?: DrawerSide;
162
167
  /** Padrão: full. */
163
168
  behavior?: DrawerBehavior;
169
+ /** Padrão: small (340px, a do Figma). */
170
+ size?: DrawerSize;
164
171
  /**
165
172
  * Com overlay (padrão): a gaveta é modal, a página atrás fica bloqueada e o clique no overlay
166
173
  * fecha. Sem overlay (`false`): a página continua rolando e clicável, e só o X e o Esc fecham.
@@ -176,7 +183,7 @@ interface DrawerProps {
176
183
  id?: string;
177
184
  className?: string;
178
185
  }
179
- declare function Drawer({ visible, onHide, title, subtitle, side, behavior, modal, onBack, backLabel, closeLabel, footer, children, id, className, }: DrawerProps): react.JSX.Element;
186
+ declare function Drawer({ visible, onHide, title, subtitle, side, behavior, size, modal, onBack, backLabel, closeLabel, footer, children, id, className, }: DrawerProps): react.JSX.Element;
180
187
 
181
188
  /**
182
189
  * Hierarchy no Figma: Primary (Filled), Secondary (Tonal), Tertiary (Outlined) e Other (Icon),
@@ -421,6 +428,45 @@ interface MultiSelectProps {
421
428
  }
422
429
  declare const MultiSelect: react.ForwardRefExoticComponent<MultiSelectProps & react.RefAttributes<HTMLInputElement>>;
423
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
+
424
470
  type PanelProps = Omit<HTMLAttributes<HTMLDivElement>, 'onToggle'>;
425
471
  declare const Panel: react.ForwardRefExoticComponent<PanelProps & react.RefAttributes<HTMLDivElement>>;
426
472
 
@@ -606,5 +652,5 @@ interface TooltipProps {
606
652
  }
607
653
  declare function Tooltip({ target, content, type, position, event, showDelay, hideDelay, disabled, id, className, }: TooltipProps): react.JSX.Element;
608
654
 
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 };
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
@@ -149,6 +149,11 @@ type DrawerSide = 'right' | 'left';
149
149
  * corpo rola).
150
150
  */
151
151
  type DrawerBehavior = 'full' | 'fixed';
152
+ /**
153
+ * Largura da gaveta. O Figma só tem a de 340px (small); medium (480px), large (720px) e full (a
154
+ * tela toda) são do Cristal, nas faixas usuais de drawer.
155
+ */
156
+ type DrawerSize = 'small' | 'medium' | 'large' | 'full';
152
157
  interface DrawerProps {
153
158
  visible: boolean;
154
159
  /** Pedido para fechar (X, Esc ou clique no overlay). */
@@ -161,6 +166,8 @@ interface DrawerProps {
161
166
  side?: DrawerSide;
162
167
  /** Padrão: full. */
163
168
  behavior?: DrawerBehavior;
169
+ /** Padrão: small (340px, a do Figma). */
170
+ size?: DrawerSize;
164
171
  /**
165
172
  * Com overlay (padrão): a gaveta é modal, a página atrás fica bloqueada e o clique no overlay
166
173
  * fecha. Sem overlay (`false`): a página continua rolando e clicável, e só o X e o Esc fecham.
@@ -176,7 +183,7 @@ interface DrawerProps {
176
183
  id?: string;
177
184
  className?: string;
178
185
  }
179
- declare function Drawer({ visible, onHide, title, subtitle, side, behavior, modal, onBack, backLabel, closeLabel, footer, children, id, className, }: DrawerProps): react.JSX.Element;
186
+ declare function Drawer({ visible, onHide, title, subtitle, side, behavior, size, modal, onBack, backLabel, closeLabel, footer, children, id, className, }: DrawerProps): react.JSX.Element;
180
187
 
181
188
  /**
182
189
  * Hierarchy no Figma: Primary (Filled), Secondary (Tonal), Tertiary (Outlined) e Other (Icon),
@@ -421,6 +428,45 @@ interface MultiSelectProps {
421
428
  }
422
429
  declare const MultiSelect: react.ForwardRefExoticComponent<MultiSelectProps & react.RefAttributes<HTMLInputElement>>;
423
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
+
424
470
  type PanelProps = Omit<HTMLAttributes<HTMLDivElement>, 'onToggle'>;
425
471
  declare const Panel: react.ForwardRefExoticComponent<PanelProps & react.RefAttributes<HTMLDivElement>>;
426
472
 
@@ -606,5 +652,5 @@ interface TooltipProps {
606
652
  }
607
653
  declare function Tooltip({ target, content, type, position, event, showDelay, hideDelay, disabled, id, className, }: TooltipProps): react.JSX.Element;
608
654
 
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 };
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';
@@ -319,6 +320,7 @@ function Drawer({
319
320
  subtitle,
320
321
  side = "right",
321
322
  behavior = "full",
323
+ size = "small",
322
324
  modal = true,
323
325
  onBack,
324
326
  backLabel = "Voltar",
@@ -366,7 +368,13 @@ function Drawer({
366
368
  primeiro.focus();
367
369
  }
368
370
  };
369
- const classes = ["cr-drawer", `cr-drawer--${side}`, `cr-drawer--${behavior}`, className].filter(Boolean).join(" ");
371
+ const classes = [
372
+ "cr-drawer",
373
+ `cr-drawer--${side}`,
374
+ `cr-drawer--${behavior}`,
375
+ `cr-drawer--size-${size}`,
376
+ className
377
+ ].filter(Boolean).join(" ");
370
378
  return /* @__PURE__ */ jsx(
371
379
  Sidebar,
372
380
  {
@@ -1210,6 +1218,105 @@ var MultiSelect = forwardRef(function MultiSelect2({
1210
1218
  ] })
1211
1219
  ] });
1212
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
+ });
1213
1320
  var Panel = forwardRef(function Panel2({ className, style, children, ...props }, ref) {
1214
1321
  const primeRef = useRef(null);
1215
1322
  useImperativeHandle(ref, () => primeRef.current?.getElement());
@@ -1607,6 +1714,6 @@ var Tabs = forwardRef(function Tabs2({ activeIndex, onTabChange, children, id, c
1607
1714
  );
1608
1715
  });
1609
1716
 
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 };
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 };
1611
1718
  //# sourceMappingURL=index.js.map
1612
1719
  //# sourceMappingURL=index.js.map