@ttoss/components 2.14.31 → 2.15.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.mts CHANGED
@@ -791,11 +791,30 @@ declare const NavList: {
791
791
  displayName: string;
792
792
  };
793
793
  //#endregion
794
+ //#region src/components/NotificationCard/NotificationButton.d.ts
795
+ type NotificationType$1 = 'success' | 'error' | 'warning' | 'info' | 'neutral';
796
+ /** Props for NotificationButton */
797
+ type NotificationButtonProps = Omit<ButtonProps, 'type'> & {
798
+ /** Notification type — controls background and border colors to match the card. */type: NotificationType$1;
799
+ };
800
+ /**
801
+ * A button styled to match the NotificationCard of a given type.
802
+ * Use this for action buttons rendered inside or alongside notification cards.
803
+ */
804
+ declare const NotificationButton: ({
805
+ type,
806
+ ...props
807
+ }: NotificationButtonProps) => import("react/jsx-runtime").JSX.Element;
808
+ //#endregion
794
809
  //#region src/components/NotificationCard/NotificationCard.d.ts
795
810
  type NotificationType = 'success' | 'error' | 'warning' | 'info' | 'neutral';
796
811
  type NotificationAction = {
797
- action?: 'open_url';
798
- url?: string;
812
+ action: 'open_url';
813
+ url: string;
814
+ label?: string;
815
+ } | {
816
+ action: 'callback';
817
+ onClick: () => void;
799
818
  label?: string;
800
819
  };
801
820
  type NotificationCardProps = {
@@ -907,4 +926,4 @@ declare const Tabs: {
907
926
  declare const ToastContainer: (props: ToastContainerProps) => import("react/jsx-runtime").JSX.Element;
908
927
  declare const toast: typeof toast$1;
909
928
  //#endregion
910
- export { Accordion, AccordionItem, AccordionProps, AccordionRenderItemProps, BaseMetric, DateMetric, DatePicker, DateRange, Drawer, DrawerProps, EnhancedTitle, EnhancedTitleBadge, EnhancedTitleProps, EnhancedTitleVariant, FileUploadState, FileUploader, FileUploaderProps, InstallPwa, InstallPwaUi, InstallPwaUiProps, JsonEditor, JsonView, type LinkComponentProps, List, ListItem, ListItemProps, ListProps, LockedOverlay, Markdown, MarkdownProps, Menu, MenuProps, Metric, MetricCard, MetricCardProps, Modal, ModalProps, NavList, type NavListGroup, type NavListItem, type NavListProps, Notification, NotificationAction, NotificationCard, NotificationCardProps, NotificationsMenu, NumberMetric, OnFilesChange, OnRemove, OnUpload, OnUploadComplete, OnUploadError, OnUploadProgress, OnUploadStart, PercentageMetric, Search, SearchProps, SpotlightCard, SpotlightCardProps, type TabListProps, type TabPanelProps, type TabProps, Table, Tabs, type TabsProps, ToastContainer, type ToastContainerProps, type ToastOptions, UploadResult, UploadedFile, createCell, createColumnHelper, flexRender, getCoreRowModel, toast, useReactTable };
929
+ export { Accordion, AccordionItem, AccordionProps, AccordionRenderItemProps, BaseMetric, DateMetric, DatePicker, DateRange, Drawer, DrawerProps, EnhancedTitle, EnhancedTitleBadge, EnhancedTitleProps, EnhancedTitleVariant, FileUploadState, FileUploader, FileUploaderProps, InstallPwa, InstallPwaUi, InstallPwaUiProps, JsonEditor, JsonView, type LinkComponentProps, List, ListItem, ListItemProps, ListProps, LockedOverlay, Markdown, MarkdownProps, Menu, MenuProps, Metric, MetricCard, MetricCardProps, Modal, ModalProps, NavList, type NavListGroup, type NavListItem, type NavListProps, Notification, NotificationAction, NotificationButton, NotificationButtonProps, NotificationCard, NotificationCardProps, NotificationsMenu, NumberMetric, OnFilesChange, OnRemove, OnUpload, OnUploadComplete, OnUploadError, OnUploadProgress, OnUploadStart, PercentageMetric, Search, SearchProps, SpotlightCard, SpotlightCardProps, type TabListProps, type TabPanelProps, type TabProps, Table, Tabs, type TabsProps, ToastContainer, type ToastContainerProps, type ToastOptions, UploadResult, UploadedFile, createCell, createColumnHelper, flexRender, getCoreRowModel, toast, useReactTable };
package/dist/index.mjs CHANGED
@@ -2510,168 +2510,265 @@ var NavList = ({
2510
2510
  };
2511
2511
  NavList.displayName = "NavList";
2512
2512
 
2513
+ //#endregion
2514
+ //#region src/components/NotificationCard/NotificationButton.tsx
2515
+ var sxMap$1 = {
2516
+ success: {
2517
+ backgroundColor: "feedback.background.positive.active",
2518
+ borderColor: "feedback.border.positive.active"
2519
+ },
2520
+ error: {
2521
+ backgroundColor: "feedback.background.negative.active",
2522
+ borderColor: "feedback.border.negative.active"
2523
+ },
2524
+ warning: {
2525
+ backgroundColor: "feedback.background.caution.active",
2526
+ borderColor: "feedback.border.caution.active"
2527
+ },
2528
+ info: {
2529
+ backgroundColor: "feedback.background.primary.active",
2530
+ borderColor: "feedback.border.primary.active"
2531
+ },
2532
+ neutral: {
2533
+ backgroundColor: "feedback.background.primary.active",
2534
+ borderColor: "feedback.border.primary.active"
2535
+ }
2536
+ };
2537
+ /**
2538
+ * A button styled to match the NotificationCard of a given type.
2539
+ * Use this for action buttons rendered inside or alongside notification cards.
2540
+ */
2541
+ var NotificationButton = ({
2542
+ type,
2543
+ ...props
2544
+ }) => {
2545
+ return /* @__PURE__ */jsx(Button, {
2546
+ type: "button",
2547
+ ...props,
2548
+ sx: {
2549
+ ...sxMap$1[type],
2550
+ color: "display.text.primary.default",
2551
+ borderRadius: "lg",
2552
+ borderWidth: "sm",
2553
+ borderStyle: "solid"
2554
+ }
2555
+ });
2556
+ };
2557
+
2513
2558
  //#endregion
2514
2559
  //#region src/components/NotificationCard/NotificationCard.tsx
2515
- var NotificationCard = props => {
2516
- const sxMap = {
2517
- success: {
2518
- card: {
2519
- backgroundColor: "feedback.background.positive.default",
2520
- borderColor: "feedback.border.positive.default"
2521
- }
2522
- },
2523
- error: {
2524
- card: {
2525
- backgroundColor: "feedback.background.negative.default",
2526
- borderColor: "feedback.border.negative.default"
2527
- }
2528
- },
2529
- warning: {
2530
- card: {
2531
- backgroundColor: "feedback.background.caution.default",
2532
- borderColor: "feedback.border.caution.default"
2533
- }
2534
- },
2535
- info: {
2536
- card: {
2537
- backgroundColor: "feedback.background.primary.default",
2538
- borderColor: "feedback.border.primary.default"
2539
- }
2540
- },
2541
- neutral: {
2542
- card: {
2543
- backgroundColor: "feedback.background.primary.default",
2544
- borderColor: "feedback.border.primary.default"
2545
- }
2560
+ var sxMap = {
2561
+ success: {
2562
+ card: {
2563
+ backgroundColor: "feedback.background.positive.default",
2564
+ borderColor: "feedback.border.positive.default"
2546
2565
  }
2547
- };
2548
- const icon = {
2549
- success: "success-circle",
2550
- error: "error",
2551
- warning: "warning-alt",
2552
- info: "info",
2553
- neutral: "info"
2554
- };
2555
- const hasCaption = Boolean(props.caption);
2556
- const hasActions = Boolean(props.actions && props.actions.length > 0);
2557
- const hasTitle = Boolean(props.title);
2558
- const shouldCenterVerticallyWithoutTitle = !hasCaption && !hasActions && !hasTitle;
2559
- const shouldCenterVerticallyWithTitle = !hasCaption && !hasActions && hasTitle;
2560
- const shouldAddMinHeight = !hasCaption && !hasActions;
2561
- return /* @__PURE__ */jsxs(Card, {
2566
+ },
2567
+ error: {
2568
+ card: {
2569
+ backgroundColor: "feedback.background.negative.default",
2570
+ borderColor: "feedback.border.negative.default"
2571
+ }
2572
+ },
2573
+ warning: {
2574
+ card: {
2575
+ backgroundColor: "feedback.background.caution.default",
2576
+ borderColor: "feedback.border.caution.default"
2577
+ }
2578
+ },
2579
+ info: {
2580
+ card: {
2581
+ backgroundColor: "feedback.background.primary.default",
2582
+ borderColor: "feedback.border.primary.default"
2583
+ }
2584
+ },
2585
+ neutral: {
2586
+ card: {
2587
+ backgroundColor: "feedback.background.primary.default",
2588
+ borderColor: "feedback.border.primary.default"
2589
+ }
2590
+ }
2591
+ };
2592
+ var iconMap = {
2593
+ success: "success-circle",
2594
+ error: "error",
2595
+ warning: "warning-alt",
2596
+ info: "info",
2597
+ neutral: "info"
2598
+ };
2599
+ var NotificationCardTags = ({
2600
+ tags
2601
+ }) => {
2602
+ if (!tags) return null;
2603
+ if (Array.isArray(tags)) {
2604
+ if (tags.length === 0) return null;
2605
+ return /* @__PURE__ */jsx(Fragment, {
2606
+ children: tags.map((tag, index) => {
2607
+ return /* @__PURE__ */jsx(Tag, {
2608
+ children: tag
2609
+ }, index);
2610
+ })
2611
+ });
2612
+ }
2613
+ return /* @__PURE__ */jsx(Tag, {
2614
+ children: tags
2615
+ });
2616
+ };
2617
+ var NotificationCardTitle = ({
2618
+ type,
2619
+ title,
2620
+ tags,
2621
+ onClose
2622
+ }) => {
2623
+ return /* @__PURE__ */jsxs(Card.Title, {
2562
2624
  sx: {
2563
- ...sxMap[props.type].card,
2564
- width: "full"
2625
+ display: "flex",
2626
+ justifyContent: "space-between",
2627
+ alignItems: "center",
2628
+ fontSize: ["md", "xl"],
2629
+ paddingY: ["1", "2", "4"],
2630
+ paddingX: ["2", "4", "8"]
2565
2631
  },
2566
- children: [props.title && /* @__PURE__ */jsxs(Card.Title, {
2632
+ children: [/* @__PURE__ */jsxs(Text, {
2567
2633
  sx: {
2568
- display: "flex",
2569
- justifyContent: "space-between",
2570
- alignItems: "center",
2571
- fontSize: ["md", "xl"],
2572
- paddingY: ["1", "2", "4"],
2573
- paddingX: ["2", "4", "8"]
2634
+ display: "inline-flex",
2635
+ alignItems: "flex-start",
2636
+ gap: "2",
2637
+ flexDirection: "row",
2638
+ flexWrap: "wrap"
2574
2639
  },
2575
- children: [/* @__PURE__ */jsxs(Text, {
2576
- sx: {
2577
- display: "inline-flex",
2578
- alignItems: "flex-start",
2579
- gap: "2",
2580
- flexDirection: "row",
2581
- flexWrap: "wrap"
2582
- },
2583
- children: [/* @__PURE__ */jsxs(Box, {
2584
- sx: {
2585
- display: "flex",
2586
- alignItems: "center",
2587
- gap: "2"
2588
- },
2589
- children: [/* @__PURE__ */jsx(Icon, {
2590
- icon: icon[props.type]
2591
- }), props.title]
2592
- }), props.tags && (Array.isArray(props.tags) ? props.tags.length > 0 : true) && (Array.isArray(props.tags) ? props.tags.map((tag, index) => {
2593
- return /* @__PURE__ */jsx(Tag, {
2594
- children: tag
2595
- }, index);
2596
- }) : /* @__PURE__ */jsx(Tag, {
2597
- children: props.tags
2598
- }))]
2599
- }), props.onClose && /* @__PURE__ */jsx(Box, {
2640
+ children: [/* @__PURE__ */jsxs(Box, {
2600
2641
  sx: {
2601
- marginLeft: "auto"
2642
+ display: "flex",
2643
+ alignItems: "center",
2644
+ gap: "2"
2602
2645
  },
2603
- children: /* @__PURE__ */jsx(CloseButton, {
2604
- onClick: props.onClose
2605
- })
2646
+ children: [/* @__PURE__ */jsx(Icon, {
2647
+ icon: iconMap[type]
2648
+ }), title]
2649
+ }), /* @__PURE__ */jsx(NotificationCardTags, {
2650
+ tags
2606
2651
  })]
2607
- }), /* @__PURE__ */jsxs(Card.Body, {
2652
+ }), onClose && /* @__PURE__ */jsx(Box, {
2653
+ sx: {
2654
+ marginLeft: "auto"
2655
+ },
2656
+ children: /* @__PURE__ */jsx(CloseButton, {
2657
+ onClick: onClose
2658
+ })
2659
+ })]
2660
+ });
2661
+ };
2662
+ var NotificationCardActions = ({
2663
+ type,
2664
+ actions
2665
+ }) => {
2666
+ if (actions.length === 0) return null;
2667
+ return /* @__PURE__ */jsx(Box, {
2668
+ sx: {
2669
+ display: "flex",
2670
+ flexDirection: "row",
2671
+ flexWrap: "wrap",
2672
+ gap: 2,
2673
+ mt: 2
2674
+ },
2675
+ children: actions.map((action, index) => {
2676
+ return /* @__PURE__ */jsx(NotificationButton, {
2677
+ type,
2678
+ onClick: action.action === "open_url" ? () => {
2679
+ return window.open(action.url, "_blank");
2680
+ } : action.onClick,
2681
+ children: action.label || "Acessar"
2682
+ }, index);
2683
+ })
2684
+ });
2685
+ };
2686
+ var NotificationCardBody = ({
2687
+ type,
2688
+ message,
2689
+ actions,
2690
+ caption,
2691
+ onClose,
2692
+ hasTitle
2693
+ }) => {
2694
+ const hasCaption = Boolean(caption);
2695
+ const hasActions = Boolean(actions?.length);
2696
+ const shouldCenter = !hasCaption && !hasActions;
2697
+ const bodyAlign = shouldCenter ? "center" : "flex-start";
2698
+ const bodyMinHeight = shouldCenter && !hasTitle ? "40px" : "auto";
2699
+ return /* @__PURE__ */jsxs(Card.Body, {
2700
+ sx: {
2701
+ ...sxMap[type].card,
2702
+ display: "flex",
2703
+ flexDirection: "column",
2704
+ gap: "2",
2705
+ paddingY: ["1", "2", "4"],
2706
+ paddingX: ["2", "4", "8"]
2707
+ },
2708
+ children: [/* @__PURE__ */jsx(Box, {
2608
2709
  sx: {
2609
- ...sxMap[props.type].card,
2610
2710
  display: "flex",
2611
- flexDirection: "column",
2612
- gap: "2",
2613
- paddingY: ["1", "2", "4"],
2614
- paddingX: ["2", "4", "8"]
2711
+ justifyContent: "space-between",
2712
+ minHeight: bodyMinHeight,
2713
+ alignItems: bodyAlign,
2714
+ width: "100%",
2715
+ gap: "4"
2615
2716
  },
2616
- children: [/* @__PURE__ */jsx(Box, {
2617
- sx: {
2618
- display: "flex",
2619
- justifyContent: "space-between",
2620
- minHeight: shouldAddMinHeight ? "40px" : "auto",
2621
- alignItems: shouldCenterVerticallyWithoutTitle ? "center" : shouldCenterVerticallyWithTitle ? "center" : "flex-start",
2622
- width: "100%",
2623
- gap: "4"
2624
- },
2625
- children: /* @__PURE__ */jsx(Box, {
2626
- sx: {
2627
- flex: 1
2628
- },
2629
- children: /* @__PURE__ */jsx(Text, {
2630
- sx: {
2631
- fontSize: ["sm", "md"]
2632
- },
2633
- children: props.message
2634
- })
2635
- })
2636
- }), props.actions && props.actions.length > 0 && /* @__PURE__ */jsx(Box, {
2637
- sx: {
2638
- display: "flex",
2639
- flexDirection: "column",
2640
- gap: 2,
2641
- mt: 2
2642
- },
2643
- children: props.actions.map((action, index) => {
2644
- return action.action === "open_url" ? /* @__PURE__ */jsx(Link, {
2645
- href: action.url,
2646
- target: "_blank",
2647
- rel: "noopener noreferrer",
2648
- sx: {
2649
- color: "action.text.accent.default",
2650
- cursor: "pointer"
2651
- },
2652
- children: action.label || "Acessar"
2653
- }, index) : null;
2654
- })
2655
- }), props.caption && /* @__PURE__ */jsx(Box, {
2717
+ children: /* @__PURE__ */jsx(Box, {
2656
2718
  sx: {
2657
- whiteSpace: "nowrap",
2658
- mt: 6
2719
+ flex: 1
2659
2720
  },
2660
2721
  children: /* @__PURE__ */jsx(Text, {
2661
2722
  sx: {
2662
- fontSize: "xs",
2663
- color: "text.secondary"
2723
+ fontSize: ["sm", "md"]
2664
2724
  },
2665
- children: props.caption
2725
+ children: message
2666
2726
  })
2667
- }), !props.title && props.onClose && /* @__PURE__ */jsx(Box, {
2727
+ })
2728
+ }), actions && /* @__PURE__ */jsx(NotificationCardActions, {
2729
+ type,
2730
+ actions
2731
+ }), caption && /* @__PURE__ */jsx(Box, {
2732
+ sx: {
2733
+ whiteSpace: "nowrap",
2734
+ mt: 6
2735
+ },
2736
+ children: /* @__PURE__ */jsx(Text, {
2668
2737
  sx: {
2669
- alignSelf: "flex-end"
2738
+ fontSize: "xs",
2739
+ color: "text.secondary"
2670
2740
  },
2671
- children: /* @__PURE__ */jsx(CloseButton, {
2672
- onClick: props.onClose
2673
- })
2674
- })]
2741
+ children: caption
2742
+ })
2743
+ }), !hasTitle && onClose && /* @__PURE__ */jsx(Box, {
2744
+ sx: {
2745
+ alignSelf: "flex-end"
2746
+ },
2747
+ children: /* @__PURE__ */jsx(CloseButton, {
2748
+ onClick: onClose
2749
+ })
2750
+ })]
2751
+ });
2752
+ };
2753
+ var NotificationCard = props => {
2754
+ const hasTitle = Boolean(props.title);
2755
+ return /* @__PURE__ */jsxs(Card, {
2756
+ sx: {
2757
+ ...sxMap[props.type].card,
2758
+ width: "full"
2759
+ },
2760
+ children: [props.title && /* @__PURE__ */jsx(NotificationCardTitle, {
2761
+ type: props.type,
2762
+ title: props.title,
2763
+ tags: props.tags,
2764
+ onClose: props.onClose
2765
+ }), /* @__PURE__ */jsx(NotificationCardBody, {
2766
+ type: props.type,
2767
+ message: props.message,
2768
+ actions: props.actions,
2769
+ caption: props.caption,
2770
+ onClose: props.onClose,
2771
+ hasTitle
2675
2772
  })]
2676
2773
  });
2677
2774
  };
@@ -3081,4 +3178,4 @@ var ToastContainer = props => {
3081
3178
  var toast = toast$1;
3082
3179
 
3083
3180
  //#endregion
3084
- export { Accordion, DatePicker, Drawer, EnhancedTitle, FileUploader, InstallPwa, InstallPwaUi, JsonEditor, JsonView, List, ListItem, LockedOverlay, Markdown, Menu, MetricCard, Modal, NavList, NotificationCard, NotificationsMenu, Search, SpotlightCard, Table, Tabs, ToastContainer, createCell, createColumnHelper, flexRender, getCoreRowModel, toast, useReactTable };
3181
+ export { Accordion, DatePicker, Drawer, EnhancedTitle, FileUploader, InstallPwa, InstallPwaUi, JsonEditor, JsonView, List, ListItem, LockedOverlay, Markdown, Menu, MetricCard, Modal, NavList, NotificationButton, NotificationCard, NotificationsMenu, Search, SpotlightCard, Table, Tabs, ToastContainer, createCell, createColumnHelper, flexRender, getCoreRowModel, toast, useReactTable };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/components",
3
- "version": "2.14.31",
3
+ "version": "2.15.0",
4
4
  "description": "React components for ttoss ecosystem.",
5
5
  "keywords": [
6
6
  "React",
@@ -55,18 +55,18 @@
55
55
  "tsx": "^4.21.0",
56
56
  "@ttoss/config": "^1.37.17",
57
57
  "@ttoss/i18n-cli": "^0.8.17",
58
- "@ttoss/react-i18n": "^2.2.21",
59
58
  "@ttoss/react-hooks": "^2.3.20",
59
+ "@ttoss/react-i18n": "^2.3.0",
60
60
  "@ttoss/react-icons": "^0.7.21",
61
- "@ttoss/ui": "^6.9.27",
61
+ "@ttoss/ui": "^6.9.28",
62
62
  "@ttoss/test-utils": "^4.2.18"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": ">=16.8.0",
66
66
  "@ttoss/react-hooks": "^2.3.20",
67
+ "@ttoss/react-i18n": "^2.3.0",
67
68
  "@ttoss/react-icons": "^0.7.21",
68
- "@ttoss/react-i18n": "^2.2.21",
69
- "@ttoss/ui": "^6.9.27"
69
+ "@ttoss/ui": "^6.9.28"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public",