@ttoss/components 2.11.6 → 2.12.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.
@@ -0,0 +1,97 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { BadgeProps } from '@ttoss/ui';
3
+
4
+ /**
5
+ * Visual variant for the icon wrapper.
6
+ */
7
+ type EnhancedTitleVariant = 'spotlight-accent' | 'spotlight-primary' | 'primary' | 'secondary' | 'accent' | 'positive' | 'negative' | 'informative' | 'muted';
8
+ /**
9
+ * Badge configuration for top and bottom badge sections.
10
+ */
11
+ interface EnhancedTitleBadge {
12
+ /**
13
+ * Icon to display in the badge.
14
+ */
15
+ icon?: string;
16
+ /**
17
+ * Badge label text.
18
+ */
19
+ label: string;
20
+ /**
21
+ * Badge visual variant.
22
+ */
23
+ variant?: BadgeProps['variant'];
24
+ }
25
+ /**
26
+ * Props for the EnhancedTitle component.
27
+ */
28
+ interface EnhancedTitleProps {
29
+ /**
30
+ * Visual variant for the icon wrapper.
31
+ * @default 'primary'
32
+ */
33
+ variant?: EnhancedTitleVariant;
34
+ /**
35
+ * Icon to display next to the title.
36
+ */
37
+ icon?: string;
38
+ /**
39
+ * Main title text (heading).
40
+ */
41
+ title: string;
42
+ /**
43
+ * Optional subtitle/description text.
44
+ */
45
+ description?: string;
46
+ /**
47
+ * Optional text displayed next to the title (e.g., price, metadata).
48
+ */
49
+ frontTitle?: string;
50
+ /**
51
+ * Badges to display above the title.
52
+ */
53
+ topBadges?: EnhancedTitleBadge[];
54
+ /**
55
+ * Badges to display below the title.
56
+ */
57
+ bottomBadges?: EnhancedTitleBadge[];
58
+ }
59
+
60
+ /**
61
+ * EnhancedTitle component renders a structured title section with icon, badges, and metadata.
62
+ *
63
+ * This component is useful for displaying rich title sections with status indicators,
64
+ * feature tags, and supplementary information in a consistent layout.
65
+ *
66
+ * @example
67
+ * ```tsx
68
+ * <EnhancedTitle
69
+ * icon="fluent:shield-24-filled"
70
+ * title="Starter Plan"
71
+ * frontTitle="R$ 49,90/mês"
72
+ * description="Perfect for small teams"
73
+ * variant="primary"
74
+ * topBadges={[
75
+ * { label: 'Active', variant: 'positive', icon: 'fluent:checkmark-circle-24-filled' }
76
+ * ]}
77
+ * bottomBadges={[
78
+ * { label: 'OneClick Tracking', icon: 'fluent:checkmark-24-filled' }
79
+ * ]}
80
+ * />
81
+ * ```
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * <EnhancedTitle
86
+ * title="Pro Plan"
87
+ * frontTitle="$99/month"
88
+ * variant="accent"
89
+ * topBadges={[
90
+ * { label: 'Most Popular', variant: 'informative' }
91
+ * ]}
92
+ * />
93
+ * ```
94
+ */
95
+ declare const EnhancedTitle: ({ variant, icon, title, description, frontTitle, topBadges, bottomBadges, }: EnhancedTitleProps) => react_jsx_runtime.JSX.Element;
96
+
97
+ export { EnhancedTitle, type EnhancedTitleBadge, type EnhancedTitleProps, type EnhancedTitleVariant };
@@ -0,0 +1,151 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonProps, ThemeUIStyleObject, Theme } from '@ttoss/ui';
3
+ import * as React from 'react';
4
+
5
+ type LockedOverlayAction = {
6
+ /**
7
+ * Label text for the button
8
+ */
9
+ label: string;
10
+ /**
11
+ * Icon identifier from @ttoss/react-icons
12
+ */
13
+ icon?: string;
14
+ /**
15
+ * Button variant
16
+ */
17
+ variant: 'primary' | 'accent' | 'secondary';
18
+ /**
19
+ * Click handler for the button
20
+ */
21
+ onClick: () => void;
22
+ };
23
+ type LockedOverlayProps = {
24
+ /**
25
+ * Controls the overlay visibility
26
+ */
27
+ isOpen: boolean;
28
+ /**
29
+ * Optional close handler. If not provided, overlay cannot be closed by user interaction
30
+ */
31
+ onRequestClose?: () => void;
32
+ /**
33
+ * Header configuration for the SpotlightCard
34
+ */
35
+ header: {
36
+ /**
37
+ * Icon identifier from @ttoss/react-icons
38
+ */
39
+ icon: string;
40
+ /**
41
+ * Title text for the header
42
+ */
43
+ title: string;
44
+ /**
45
+ * Description text for the header
46
+ */
47
+ description: string;
48
+ /**
49
+ * Visual variant for the SpotlightCard
50
+ * @default 'primary'
51
+ */
52
+ variant?: 'primary' | 'accent';
53
+ };
54
+ /**
55
+ * Optional first button to display in the SpotlightCard header
56
+ */
57
+ firstButton?: ButtonProps | React.ReactNode;
58
+ /**
59
+ * Optional second button to display in the SpotlightCard header
60
+ */
61
+ secondButton?: ButtonProps | React.ReactNode;
62
+ /**
63
+ * Content to be rendered in the overlay body
64
+ */
65
+ children: React.ReactNode;
66
+ /**
67
+ * Optional list of actions to render as buttons in the footer
68
+ */
69
+ actions?: LockedOverlayAction[];
70
+ /**
71
+ * Optional style overrides for the overlay and content container
72
+ */
73
+ sx?: ThemeUIStyleObject<Theme<object>>;
74
+ /**
75
+ * Optional z-index value to control overlay stacking order.
76
+ * The overlay will appear above the parent container content.
77
+ * @default 1
78
+ *
79
+ * zIndex hierarchy reference:
80
+ * - modal: 1400
81
+ * - overlay: 1300 (sidebar layouts use this value)
82
+ * - dropdown: 1000
83
+ * - sticky: 1100
84
+ * - banner: 1200
85
+ */
86
+ zIndex?: string | number;
87
+ };
88
+ /**
89
+ * LockedOverlay is a component for blocking and displaying locked features or restricted content
90
+ * within a specific container.
91
+ *
92
+ * This component renders as an absolutely positioned overlay that blocks the parent container's content.
93
+ * The parent container must have `position: relative` for proper positioning.
94
+ *
95
+ * Unlike a modal, this component blocks only its parent container, not the entire viewport,
96
+ * making it ideal for blocking specific sections like Layout.Main, Layout.Main.Body, etc.
97
+ *
98
+ * @example
99
+ * ```tsx
100
+ * // Parent container must have position: relative
101
+ * <Layout.Main sx={{ position: 'relative' }}>
102
+ * <LockedOverlay
103
+ * isOpen={isOpen}
104
+ * onRequestClose={() => setIsOpen(false)}
105
+ * header={{
106
+ * icon: "fluent:lock-closed-24-filled",
107
+ * title: "Premium Feature",
108
+ * description: "Available in Pro plan only",
109
+ * variant: "primary"
110
+ * }}
111
+ * actions={[
112
+ * {
113
+ * label: "Upgrade Now",
114
+ * icon: "fluent-emoji-high-contrast:sparkles",
115
+ * variant: "primary",
116
+ * onClick: handleUpgrade
117
+ * },
118
+ * {
119
+ * label: "Learn More",
120
+ * icon: "fluent:arrow-right-16-regular",
121
+ * variant: "accent",
122
+ * onClick: handleLearnMore
123
+ * }
124
+ * ]}
125
+ * >
126
+ * <Text>This feature is only available for Pro users.</Text>
127
+ * </LockedOverlay>
128
+ * </Layout.Main>
129
+ * ```
130
+ *
131
+ * @example
132
+ * ```tsx
133
+ * // Blocking a specific section with custom zIndex
134
+ * <Box sx={{ position: 'relative' }}>
135
+ * <LockedOverlay
136
+ * isOpen={isOpen}
137
+ * zIndex={10}
138
+ * header={{
139
+ * icon: "fluent:lock-closed-24-filled",
140
+ * title: "Feature Locked",
141
+ * description: "Unlock this feature"
142
+ * }}
143
+ * >
144
+ * <Text>Content here</Text>
145
+ * </LockedOverlay>
146
+ * </Box>
147
+ * ```
148
+ */
149
+ declare const LockedOverlay: ({ isOpen, onRequestClose, header, firstButton, secondButton, children, actions, sx, zIndex, }: LockedOverlayProps) => react_jsx_runtime.JSX.Element | null;
150
+
151
+ export { LockedOverlay };
@@ -0,0 +1,148 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { IconType } from '@ttoss/react-icons';
3
+
4
+ /**
5
+ * Base metric properties shared by all metric types.
6
+ */
7
+ interface BaseMetric {
8
+ /**
9
+ * Label displayed above the metric value.
10
+ */
11
+ label: string;
12
+ /**
13
+ * Optional tooltip text or action handler for additional context.
14
+ * When a string is provided, it displays a simple tooltip.
15
+ * When a function is provided, it's called when the tooltip icon is clicked.
16
+ */
17
+ tooltip?: string | (() => void);
18
+ /**
19
+ * Icon to display alongside the metric.
20
+ */
21
+ icon?: IconType;
22
+ /**
23
+ * Optional click handler to make the metric card interactive.
24
+ */
25
+ onClick?: () => void;
26
+ /**
27
+ * Optional help article action handler.
28
+ */
29
+ helpArticleAction?: () => void;
30
+ }
31
+ /**
32
+ * Date-based metric for displaying dates like expiration or renewal.
33
+ */
34
+ interface DateMetric extends BaseMetric {
35
+ type: 'date';
36
+ /**
37
+ * The date value to display.
38
+ */
39
+ date: string;
40
+ /**
41
+ * Optional message showing remaining days.
42
+ */
43
+ remainingDaysMessage?: string;
44
+ /**
45
+ * Whether to show a warning indicator.
46
+ */
47
+ isWarning?: boolean;
48
+ }
49
+ /**
50
+ * Percentage-based metric with progress bar.
51
+ */
52
+ interface PercentageMetric extends BaseMetric {
53
+ type: 'percentage';
54
+ /**
55
+ * Current value.
56
+ */
57
+ current: number;
58
+ /**
59
+ * Maximum value. Use null for unlimited.
60
+ */
61
+ max: number | null;
62
+ /**
63
+ * Custom formatter for displaying values.
64
+ */
65
+ formatValue?: (value: number) => string;
66
+ /**
67
+ * Percentage threshold at which to show an alert.
68
+ */
69
+ showAlertThreshold?: number;
70
+ }
71
+ /**
72
+ * Number-based metric for displaying counts.
73
+ */
74
+ interface NumberMetric extends BaseMetric {
75
+ type: 'number';
76
+ /**
77
+ * Current value.
78
+ */
79
+ current: number;
80
+ /**
81
+ * Maximum value. Use null for unlimited.
82
+ */
83
+ max: number | null;
84
+ /**
85
+ * Custom formatter for displaying values.
86
+ */
87
+ formatValue?: (value: number) => string;
88
+ /**
89
+ * Optional footer text below the metric.
90
+ */
91
+ footerText?: string;
92
+ }
93
+ /**
94
+ * Union type for all supported metric types.
95
+ */
96
+ type Metric = DateMetric | PercentageMetric | NumberMetric;
97
+ /**
98
+ * Props for the MetricCard component.
99
+ */
100
+ interface MetricCardProps {
101
+ /**
102
+ * The metric configuration to display.
103
+ */
104
+ metric: Metric;
105
+ /**
106
+ * Whether the card is in loading state.
107
+ */
108
+ isLoading?: boolean;
109
+ }
110
+
111
+ /**
112
+ * MetricCard component displays a metric in a consistent card layout.
113
+ *
114
+ * It supports three metric types:
115
+ * - **date**: displays a date and optional remaining-days message
116
+ * - **percentage**: displays current/max values and a progress bar
117
+ * - **number**: displays current/max values and an optional footer text
118
+ *
119
+ * @example
120
+ * ```tsx
121
+ * <MetricCard
122
+ * metric={{
123
+ * type: 'date',
124
+ * label: 'Renewal date',
125
+ * date: '31/12/2025',
126
+ * icon: 'fluent:calendar-24-regular',
127
+ * remainingDaysMessage: '10 days remaining',
128
+ * }}
129
+ * />
130
+ * ```
131
+ *
132
+ * @example
133
+ * ```tsx
134
+ * <MetricCard
135
+ * metric={{
136
+ * type: 'percentage',
137
+ * label: 'Plan usage',
138
+ * current: 350,
139
+ * max: 1000,
140
+ * icon: 'fluent:gauge-24-regular',
141
+ * showAlertThreshold: 80,
142
+ * }}
143
+ * />
144
+ * ```
145
+ */
146
+ declare const MetricCard: ({ metric, isLoading }: MetricCardProps) => react_jsx_runtime.JSX.Element | null;
147
+
148
+ export { type BaseMetric, type DateMetric, type Metric, MetricCard, type MetricCardProps, type NumberMetric, type PercentageMetric };
@@ -1,6 +1,21 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { NotificationCardProps } from '../NotificationCard/index.js';
3
- import 'react';
2
+ import * as React from 'react';
3
+
4
+ type NotificationType = 'success' | 'error' | 'warning' | 'info' | 'neutral';
5
+ type NotificationAction = {
6
+ action?: 'open_url';
7
+ url?: string;
8
+ label?: string;
9
+ };
10
+ type NotificationCardProps = {
11
+ type: NotificationType;
12
+ title?: string | React.ReactNode;
13
+ message: string | React.ReactNode;
14
+ actions?: NotificationAction[];
15
+ caption?: string | React.ReactNode;
16
+ tags?: string[] | React.ReactNode;
17
+ onClose?: () => void;
18
+ };
4
19
 
5
20
  type Notification = NotificationCardProps & {
6
21
  id: string;
@@ -0,0 +1,190 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ import * as React from 'react';
3
+ import { __name } from "../chunk-V4MHYKRI.js";
4
+
5
+ // src/components/EnhancedTitle/EnhancedTitle.tsx
6
+ import { Icon } from "@ttoss/react-icons";
7
+ import { Badge, Flex, Heading, Stack, Text } from "@ttoss/ui";
8
+
9
+ // src/components/EnhancedTitle/EnhancedTitle.styles.ts
10
+ import { keyframes } from "@ttoss/ui";
11
+ var gradientFlow = keyframes({
12
+ "0%": {
13
+ backgroundPosition: "0% 50%"
14
+ },
15
+ "50%": {
16
+ backgroundPosition: "100% 50%"
17
+ },
18
+ "100%": {
19
+ backgroundPosition: "0% 50%"
20
+ }
21
+ });
22
+ var getAccentGradientBackground = /* @__PURE__ */__name(t => {
23
+ const theme = t;
24
+ const start = theme.colors?.action?.background?.accent?.default || theme.colors?.input?.background?.accent?.default;
25
+ if (!start) return void 0;
26
+ const middle = theme.colors?.action?.background?.accent?.active || theme.colors?.input?.background?.accent?.active || start;
27
+ return `linear-gradient(270deg, ${start}, ${middle}, ${start})`;
28
+ }, "getAccentGradientBackground");
29
+ var getPrimaryGradientBackground = /* @__PURE__ */__name(t => {
30
+ const theme = t;
31
+ const start = theme.colors?.action?.background?.primary?.default;
32
+ if (!start) return void 0;
33
+ const middle = theme.colors?.action?.background?.secondary?.default || start;
34
+ return `linear-gradient(270deg, ${start}, ${middle}, ${start})`;
35
+ }, "getPrimaryGradientBackground");
36
+ var getEnhancedTitleIconSx = /* @__PURE__ */__name(variant => {
37
+ const variantStyles = {
38
+ "spotlight-accent": {
39
+ backgroundColor: "input.background.accent.default",
40
+ color: "action.text.accent.default",
41
+ borderColor: "display.border.muted.default",
42
+ background: getAccentGradientBackground,
43
+ backgroundSize: "400% 400%",
44
+ animation: `${gradientFlow} 6s ease infinite`
45
+ },
46
+ "spotlight-primary": {
47
+ backgroundColor: "action.background.primary.default",
48
+ color: "display.text.accent.default",
49
+ borderColor: "display.border.muted.default",
50
+ background: getPrimaryGradientBackground,
51
+ backgroundSize: "400% 400%",
52
+ animation: `${gradientFlow} 6s ease infinite`
53
+ },
54
+ primary: {
55
+ backgroundColor: "action.background.primary.default",
56
+ color: "action.text.primary.default",
57
+ borderColor: "display.border.muted.default"
58
+ },
59
+ secondary: {
60
+ backgroundColor: "action.background.secondary.default",
61
+ color: "action.text.primary.default",
62
+ borderColor: "display.border.muted.default"
63
+ },
64
+ accent: {
65
+ backgroundColor: "action.background.accent.default",
66
+ color: "action.text.accent.default",
67
+ borderColor: "display.border.muted.default"
68
+ },
69
+ positive: {
70
+ backgroundColor: "display.bg.positive.boldest",
71
+ color: "display.fg.positive.bolder",
72
+ borderColor: "display.border.muted.default"
73
+ },
74
+ negative: {
75
+ backgroundColor: "display.bg.negative.boldest",
76
+ color: "display.fg.negative.bolder",
77
+ borderColor: "display.border.muted.default"
78
+ },
79
+ informative: {
80
+ backgroundColor: "display.bg.informative.boldest",
81
+ color: "display.fg.informative.bolder",
82
+ borderColor: "display.border.muted.default"
83
+ },
84
+ muted: {
85
+ backgroundColor: "display.bg.muted.boldest",
86
+ color: "display.fg.muted.bolder",
87
+ borderColor: "display.border.muted.default"
88
+ }
89
+ };
90
+ return {
91
+ flexShrink: 0,
92
+ alignItems: "center",
93
+ justifyContent: "center",
94
+ borderRadius: "2xl",
95
+ border: "md",
96
+ width: "56px",
97
+ height: "56px",
98
+ ...variantStyles[variant]
99
+ };
100
+ }, "getEnhancedTitleIconSx");
101
+
102
+ // src/components/EnhancedTitle/EnhancedTitle.tsx
103
+ var EnhancedTitle = /* @__PURE__ */__name(({
104
+ variant = "spotlight-primary",
105
+ icon,
106
+ title,
107
+ description,
108
+ frontTitle,
109
+ topBadges = [],
110
+ bottomBadges = []
111
+ }) => {
112
+ return /* @__PURE__ */React.createElement(Stack, {
113
+ sx: {
114
+ paddingY: "6",
115
+ paddingX: "6",
116
+ width: "full"
117
+ }
118
+ }, /* @__PURE__ */React.createElement(Flex, {
119
+ sx: {
120
+ gap: "6",
121
+ alignItems: "flex-start",
122
+ flexDirection: ["column", "row"]
123
+ }
124
+ }, icon && /* @__PURE__ */React.createElement(Flex, {
125
+ sx: getEnhancedTitleIconSx(variant)
126
+ }, /* @__PURE__ */React.createElement(Icon, {
127
+ icon,
128
+ width: 24,
129
+ height: 24
130
+ })), /* @__PURE__ */React.createElement(Flex, {
131
+ sx: {
132
+ flexDirection: "column",
133
+ gap: ["4", "5"],
134
+ flex: 1
135
+ }
136
+ }, topBadges.length > 0 && /* @__PURE__ */React.createElement(Flex, {
137
+ sx: {
138
+ flexWrap: "wrap",
139
+ gap: "2",
140
+ alignItems: "center"
141
+ }
142
+ }, topBadges.map((badge, index) => {
143
+ return /* @__PURE__ */React.createElement(Badge, {
144
+ key: index,
145
+ icon: badge.icon,
146
+ variant: badge.variant ?? "muted",
147
+ sx: {
148
+ borderRadius: "full"
149
+ }
150
+ }, badge.label);
151
+ })), /* @__PURE__ */React.createElement(Flex, {
152
+ sx: {
153
+ flexDirection: ["column", "row"],
154
+ alignItems: ["flex-start", "baseline"],
155
+ gap: ["1", "3"]
156
+ }
157
+ }, /* @__PURE__ */React.createElement(Heading, {
158
+ as: "h2",
159
+ sx: {
160
+ fontSize: "4xl",
161
+ fontWeight: "semibold",
162
+ color: "display.text.primary.default"
163
+ }
164
+ }, title), frontTitle && /* @__PURE__ */React.createElement(Text, {
165
+ sx: {
166
+ fontSize: "xl",
167
+ color: "display.text.secondary.default"
168
+ }
169
+ }, frontTitle)), description && /* @__PURE__ */React.createElement(Text, {
170
+ sx: {
171
+ fontSize: "md",
172
+ color: "display.text.secondary.default"
173
+ }
174
+ }, description), bottomBadges.length > 0 && /* @__PURE__ */React.createElement(Flex, {
175
+ sx: {
176
+ flexWrap: "wrap",
177
+ gap: "2"
178
+ }
179
+ }, bottomBadges.map((badge, index) => {
180
+ return /* @__PURE__ */React.createElement(Badge, {
181
+ key: index,
182
+ icon: badge.icon ?? "fluent:checkmark-24-filled",
183
+ variant: badge.variant ?? "muted",
184
+ sx: {
185
+ borderRadius: "full"
186
+ }
187
+ }, badge.label);
188
+ })))));
189
+ }, "EnhancedTitle");
190
+ export { EnhancedTitle };