@ttoss/components 2.14.25 → 2.14.26

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.
Files changed (47) hide show
  1. package/dist/index.d.mts +910 -0
  2. package/dist/index.mjs +3074 -0
  3. package/package.json +14 -100
  4. package/dist/Accordion/index.d.mts +0 -157
  5. package/dist/Accordion/index.mjs +0 -175
  6. package/dist/DatePicker/index.d.mts +0 -26
  7. package/dist/DatePicker/index.mjs +0 -339
  8. package/dist/Drawer/index.d.mts +0 -17
  9. package/dist/Drawer/index.mjs +0 -66
  10. package/dist/EnhancedTitle/index.d.mts +0 -107
  11. package/dist/EnhancedTitle/index.mjs +0 -234
  12. package/dist/FileUploader/index.d.mts +0 -77
  13. package/dist/FileUploader/index.mjs +0 -386
  14. package/dist/InstallPwa/index.d.mts +0 -13
  15. package/dist/InstallPwa/index.mjs +0 -64
  16. package/dist/JsonEditor/index.d.mts +0 -3
  17. package/dist/JsonEditor/index.mjs +0 -3
  18. package/dist/JsonView/index.d.mts +0 -3
  19. package/dist/JsonView/index.mjs +0 -3
  20. package/dist/List/index.d.mts +0 -16
  21. package/dist/List/index.mjs +0 -34
  22. package/dist/LockedOverlay/index.d.mts +0 -162
  23. package/dist/LockedOverlay/index.mjs +0 -386
  24. package/dist/Markdown/index.d.mts +0 -16
  25. package/dist/Markdown/index.mjs +0 -26
  26. package/dist/Menu/index.d.mts +0 -16
  27. package/dist/Menu/index.mjs +0 -136
  28. package/dist/MetricCard/index.d.mts +0 -153
  29. package/dist/MetricCard/index.mjs +0 -408
  30. package/dist/Modal/index.d.mts +0 -11
  31. package/dist/Modal/index.mjs +0 -64
  32. package/dist/NavList/index.d.mts +0 -64
  33. package/dist/NavList/index.mjs +0 -252
  34. package/dist/NotificationCard/index.d.mts +0 -22
  35. package/dist/NotificationCard/index.mjs +0 -173
  36. package/dist/NotificationsMenu/index.d.mts +0 -47
  37. package/dist/NotificationsMenu/index.mjs +0 -380
  38. package/dist/Search/index.d.mts +0 -18
  39. package/dist/Search/index.mjs +0 -31
  40. package/dist/SpotlightCard/index.d.mts +0 -36
  41. package/dist/SpotlightCard/index.mjs +0 -219
  42. package/dist/Table/index.d.mts +0 -17
  43. package/dist/Table/index.mjs +0 -64
  44. package/dist/Tabs/index.d.mts +0 -17
  45. package/dist/Tabs/index.mjs +0 -87
  46. package/dist/Toast/index.d.mts +0 -8
  47. package/dist/Toast/index.mjs +0 -43
@@ -1,408 +0,0 @@
1
- /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- import { defineMessages, useI18n } from "@ttoss/react-i18n";
3
- import { Icon } from "@ttoss/react-icons";
4
- import { Box, Card, Flex, Text, TooltipIcon } from "@ttoss/ui";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
-
7
- //#region src/components/MetricCard/MetricCard.tsx
8
- var messages = defineMessages({
9
- ofMax: {
10
- id: "oYpm71",
11
- defaultMessage: [{
12
- "type": 0,
13
- "value": "of "
14
- }, {
15
- "type": 1,
16
- "value": "max"
17
- }]
18
- },
19
- percentageUsed: {
20
- id: "zr0OS6",
21
- defaultMessage: [{
22
- "type": 1,
23
- "value": "percentage"
24
- }, {
25
- "type": 0,
26
- "value": "% used"
27
- }]
28
- },
29
- unlimited: {
30
- id: "rskBv4",
31
- defaultMessage: [{
32
- "type": 0,
33
- "value": "Unlimited"
34
- }]
35
- },
36
- infinity: {
37
- id: "0EjvY6",
38
- defaultMessage: [{
39
- "type": 0,
40
- "value": "∞"
41
- }]
42
- },
43
- nearLimit: {
44
- id: "1DbX9V",
45
- defaultMessage: [{
46
- "type": 0,
47
- "value": "Near limit"
48
- }]
49
- },
50
- reachedLimit: {
51
- id: "4NwCn9",
52
- defaultMessage: [{
53
- "type": 0,
54
- "value": "Reached limit"
55
- }]
56
- }
57
- });
58
- /**
59
- * Icon wrapper for metric cards.
60
- */
61
- var MetricIconWrapper = ({
62
- icon
63
- }) => {
64
- return /* @__PURE__ */jsx(Flex, {
65
- sx: {
66
- alignItems: "center",
67
- justifyContent: "center",
68
- borderRadius: "full",
69
- border: "md",
70
- borderColor: "display.border.muted.default",
71
- backgroundColor: "display.background.muted.default",
72
- color: "display.text.secondary.default",
73
- width: "48px",
74
- height: "48px",
75
- flexShrink: 0
76
- },
77
- children: icon && /* @__PURE__ */jsx(Icon, {
78
- icon
79
- })
80
- });
81
- };
82
- /**
83
- * Card header with label, tooltip, and optional clickable icon.
84
- */
85
- var MetricCardHeader = ({
86
- label,
87
- tooltip,
88
- isClickable
89
- }) => {
90
- const isTooltipAction = typeof tooltip === "function";
91
- const tooltipText = typeof tooltip === "string" ? tooltip : void 0;
92
- return /* @__PURE__ */jsxs(Flex, {
93
- sx: {
94
- alignItems: "center",
95
- gap: "2"
96
- },
97
- children: [/* @__PURE__ */jsx(Text, {
98
- sx: {
99
- fontSize: "sm",
100
- fontWeight: "medium",
101
- color: "display.text.secondary.default"
102
- },
103
- children: label
104
- }), tooltipText && /* @__PURE__ */jsx(TooltipIcon, {
105
- icon: "fluent:info-24-regular",
106
- tooltip: {
107
- children: tooltipText
108
- },
109
- variant: "info"
110
- }), isTooltipAction && /* @__PURE__ */jsx(Text, {
111
- onClick: e => {
112
- e.stopPropagation();
113
- tooltip();
114
- },
115
- sx: {
116
- fontSize: "sm",
117
- color: "display.text.secondary.default",
118
- cursor: "pointer",
119
- ":hover": {
120
- color: "action.text.primary.default"
121
- }
122
- },
123
- children: /* @__PURE__ */jsx(Icon, {
124
- icon: "fluent:info-24-regular",
125
- inline: true
126
- })
127
- }), isClickable && /* @__PURE__ */jsx(Text, {
128
- sx: {
129
- fontSize: "sm",
130
- color: "display.text.secondary.default"
131
- },
132
- children: /* @__PURE__ */jsx(Icon, {
133
- icon: "fluent:open-24-regular",
134
- inline: true
135
- })
136
- })]
137
- });
138
- };
139
- /**
140
- * Renders the content for a date metric.
141
- */
142
- var DateMetricContent = ({
143
- metric
144
- }) => {
145
- return /* @__PURE__ */jsxs(Fragment, {
146
- children: [/* @__PURE__ */jsx(Text, {
147
- sx: {
148
- fontSize: "2xl",
149
- fontWeight: "bold",
150
- color: "display.text.primary.default"
151
- },
152
- children: metric.date
153
- }), metric.remainingDaysMessage && /* @__PURE__ */jsxs(Flex, {
154
- sx: {
155
- alignItems: "center",
156
- gap: "2"
157
- },
158
- children: [/* @__PURE__ */jsx(Text, {
159
- sx: {
160
- fontSize: "sm",
161
- color: metric.isWarning ? "feedback.text.caution.default" : "display.text.secondary.default"
162
- },
163
- children: /* @__PURE__ */jsx(Icon, {
164
- icon: metric.isWarning ? "fluent:warning-24-regular" : "fluent:clock-24-regular",
165
- inline: true
166
- })
167
- }), /* @__PURE__ */jsx(Text, {
168
- sx: {
169
- fontSize: "sm",
170
- color: metric.isWarning ? "feedback.text.caution.default" : "display.text.secondary.default"
171
- },
172
- children: metric.remainingDaysMessage
173
- })]
174
- })]
175
- });
176
- };
177
- /**
178
- * Renders the content for a percentage metric.
179
- */
180
- var PercentageMetricContent = ({
181
- metric
182
- }) => {
183
- const {
184
- intl
185
- } = useI18n();
186
- const percentage = metric.max === null || metric.max <= 0 ? null : Math.min(Math.round(metric.current / metric.max * 100), 100);
187
- const formatValue = metric.formatValue || (val => {
188
- return val.toString();
189
- });
190
- const showAlert = percentage !== null && metric.showAlertThreshold !== void 0 && percentage >= metric.showAlertThreshold;
191
- const isOverLimit = percentage !== null && percentage >= 100;
192
- const maxText = metric.max !== null ? formatValue(metric.max) : intl.formatMessage(messages.infinity);
193
- return /* @__PURE__ */jsxs(Fragment, {
194
- children: [/* @__PURE__ */jsxs(Flex, {
195
- sx: {
196
- alignItems: "baseline",
197
- justifyContent: "space-between",
198
- gap: "2"
199
- },
200
- children: [/* @__PURE__ */jsx(Text, {
201
- sx: {
202
- fontSize: "2xl",
203
- fontWeight: "bold",
204
- color: "display.text.primary.default"
205
- },
206
- children: formatValue(metric.current)
207
- }), /* @__PURE__ */jsx(Text, {
208
- sx: {
209
- fontSize: "sm",
210
- color: "display.text.secondary.default"
211
- },
212
- children: intl.formatMessage(messages.ofMax, {
213
- max: maxText
214
- })
215
- })]
216
- }), /* @__PURE__ */jsx(Box, {
217
- sx: {
218
- width: "full",
219
- height: "8px",
220
- backgroundColor: "display.background.secondary.default",
221
- borderRadius: "full",
222
- overflow: "hidden"
223
- },
224
- children: /* @__PURE__ */jsx(Box, {
225
- sx: {
226
- height: "full",
227
- width: percentage !== null ? `${percentage}%` : "100%",
228
- backgroundColor: "action.background.primary.default",
229
- borderRadius: "full",
230
- transition: "width 0.5s ease-out"
231
- }
232
- })
233
- }), /* @__PURE__ */jsxs(Flex, {
234
- sx: {
235
- alignItems: "center",
236
- justifyContent: "space-between",
237
- fontSize: "xs"
238
- },
239
- children: [/* @__PURE__ */jsx(Text, {
240
- sx: {
241
- color: "display.text.secondary.default"
242
- },
243
- children: percentage !== null ? intl.formatMessage(messages.percentageUsed, {
244
- percentage
245
- }) : intl.formatMessage(messages.unlimited)
246
- }), showAlert && !isOverLimit && /* @__PURE__ */jsxs(Flex, {
247
- sx: {
248
- alignItems: "center",
249
- gap: "1",
250
- color: "feedback.text.caution.default"
251
- },
252
- children: [/* @__PURE__ */jsx(Icon, {
253
- icon: "fluent:warning-24-regular"
254
- }), /* @__PURE__ */jsx(Text, {
255
- sx: {
256
- fontWeight: "medium"
257
- },
258
- children: intl.formatMessage(messages.nearLimit)
259
- })]
260
- }), showAlert && isOverLimit && /* @__PURE__ */jsxs(Flex, {
261
- sx: {
262
- alignItems: "center",
263
- gap: "1",
264
- color: "feedback.text.negative.default"
265
- },
266
- children: [/* @__PURE__ */jsx(Icon, {
267
- icon: "fluent:warning-24-regular"
268
- }), /* @__PURE__ */jsx(Text, {
269
- sx: {
270
- fontWeight: "medium",
271
- color: "feedback.text.negative.default"
272
- },
273
- children: intl.formatMessage(messages.reachedLimit)
274
- })]
275
- })]
276
- })]
277
- });
278
- };
279
- /**
280
- * Renders the content for a number metric.
281
- */
282
- var NumberMetricContent = ({
283
- metric
284
- }) => {
285
- const {
286
- intl
287
- } = useI18n();
288
- const formatValue = metric.formatValue || (val => {
289
- return val.toString();
290
- });
291
- const maxText = metric.max !== null ? formatValue(metric.max) : intl.formatMessage(messages.infinity);
292
- return /* @__PURE__ */jsxs(Fragment, {
293
- children: [/* @__PURE__ */jsxs(Flex, {
294
- sx: {
295
- alignItems: "baseline",
296
- gap: "3"
297
- },
298
- children: [/* @__PURE__ */jsx(Text, {
299
- sx: {
300
- fontSize: "2xl",
301
- fontWeight: "bold",
302
- color: "display.text.primary.default"
303
- },
304
- children: formatValue(metric.current)
305
- }), /* @__PURE__ */jsx(Text, {
306
- sx: {
307
- fontSize: "sm",
308
- color: "display.text.secondary.default"
309
- },
310
- children: intl.formatMessage(messages.ofMax, {
311
- max: maxText
312
- })
313
- })]
314
- }), metric.footerText && /* @__PURE__ */jsx(Text, {
315
- sx: {
316
- fontSize: "xs",
317
- color: "display.text.secondary.default",
318
- lineHeight: "relaxed",
319
- maxWidth: "300px"
320
- },
321
- children: metric.footerText
322
- })]
323
- });
324
- };
325
- /**
326
- * MetricCard component displays a metric in a consistent card layout.
327
- *
328
- * It supports three metric types:
329
- * - **date**: displays a date and optional remaining-days message
330
- * - **percentage**: displays current/max values and a progress bar
331
- * - **number**: displays current/max values and an optional footer text
332
- *
333
- * @example
334
- * ```tsx
335
- * <MetricCard
336
- * metric={{
337
- * type: 'date',
338
- * label: 'Renewal date',
339
- * date: '31/12/2025',
340
- * icon: 'fluent:calendar-24-regular',
341
- * remainingDaysMessage: '10 days remaining',
342
- * }}
343
- * />
344
- * ```
345
- *
346
- * @example
347
- * ```tsx
348
- * <MetricCard
349
- * metric={{
350
- * type: 'percentage',
351
- * label: 'Plan usage',
352
- * current: 350,
353
- * max: 1000,
354
- * icon: 'fluent:gauge-24-regular',
355
- * showAlertThreshold: 80,
356
- * }}
357
- * />
358
- * ```
359
- */
360
- var MetricCard = ({
361
- metric,
362
- isLoading = false
363
- }) => {
364
- if (isLoading) return null;
365
- const isClickable = Boolean(metric.onClick || metric.helpArticleAction);
366
- return /* @__PURE__ */jsx(Card, {
367
- onClick: metric.onClick || metric.helpArticleAction,
368
- sx: {
369
- backgroundColor: "display.background.muted.default",
370
- padding: "6",
371
- cursor: isClickable ? "pointer" : "default",
372
- transition: "all 0.2s ease",
373
- minWidth: ["full", "full", "400px"],
374
- ":hover": {
375
- transform: "scale(1.01)"
376
- }
377
- },
378
- children: /* @__PURE__ */jsxs(Flex, {
379
- sx: {
380
- gap: "4",
381
- width: "full"
382
- },
383
- children: [/* @__PURE__ */jsx(MetricIconWrapper, {
384
- icon: metric.icon
385
- }), /* @__PURE__ */jsxs(Flex, {
386
- sx: {
387
- flex: 1,
388
- flexDirection: "column",
389
- gap: "2"
390
- },
391
- children: [/* @__PURE__ */jsx(MetricCardHeader, {
392
- label: metric.label,
393
- tooltip: metric.tooltip,
394
- isClickable
395
- }), metric.type === "date" && /* @__PURE__ */jsx(DateMetricContent, {
396
- metric
397
- }), metric.type === "percentage" && /* @__PURE__ */jsx(PercentageMetricContent, {
398
- metric
399
- }), metric.type === "number" && /* @__PURE__ */jsx(NumberMetricContent, {
400
- metric
401
- })]
402
- })]
403
- })
404
- });
405
- };
406
-
407
- //#endregion
408
- export { MetricCard };
@@ -1,11 +0,0 @@
1
-
2
- import ReactModal from "react-modal";
3
-
4
- //#region src/components/Modal/Modal.d.ts
5
- type ModalProps = ReactModal.Props;
6
- declare const Modal: {
7
- (props: ModalProps): import("react/jsx-runtime").JSX.Element;
8
- setAppElement: typeof ReactModal.setAppElement;
9
- };
10
- //#endregion
11
- export { Modal, ModalProps };
@@ -1,64 +0,0 @@
1
- /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- import { useResponsiveValue, useTheme } from "@ttoss/ui";
3
- import { jsx } from "react/jsx-runtime";
4
- import { css } from "@theme-ui/css";
5
- import ReactModal from "react-modal";
6
-
7
- //#region src/components/Modal/Modal.tsx
8
- ReactModal.defaultStyles = {
9
- overlay: {},
10
- content: {}
11
- };
12
- var Modal = props => {
13
- const {
14
- theme
15
- } = useTheme();
16
- const space = theme.space;
17
- const padding = useResponsiveValue([space?.["4"], space?.["5"], space?.["5"]]) || 0;
18
- const style = {
19
- overlay: css({
20
- position: "fixed",
21
- top: 0,
22
- left: 0,
23
- right: 0,
24
- bottom: 0,
25
- backgroundColor: "rgba(0, 0, 0, 0.5)",
26
- display: "flex",
27
- justifyContent: "center",
28
- alignItems: "center",
29
- zIndex: "modal",
30
- ...props.style?.overlay
31
- })(theme),
32
- content: css({
33
- /**
34
- * Theme
35
- */
36
- backgroundColor: "surface",
37
- padding,
38
- border: "default",
39
- borderColor: "surface",
40
- borderRadius: "default",
41
- /**
42
- * General
43
- */
44
- WebkitOverflowScrolling: "touch",
45
- overflow: "auto",
46
- position: "relative",
47
- top: "0px",
48
- left: "0px",
49
- right: "0px",
50
- bottom: "0px",
51
- maxHeight: "90%",
52
- maxWidth: "90%",
53
- ...props.style?.content
54
- })(theme)
55
- };
56
- return /* @__PURE__ */jsx(ReactModal, {
57
- ...props,
58
- style
59
- });
60
- };
61
- Modal.setAppElement = ReactModal.setAppElement;
62
-
63
- //#endregion
64
- export { Modal };
@@ -1,64 +0,0 @@
1
-
2
- import * as React from "react";
3
-
4
- //#region src/components/NavList/NavList.d.ts
5
- type NavListItem = {
6
- id?: string;
7
- label: string;
8
- href: string;
9
- icon?: string;
10
- disabled?: boolean;
11
- active?: boolean;
12
- onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
13
- group?: string;
14
- divider?: boolean;
15
- };
16
- type NavListGroup = {
17
- id?: string;
18
- label?: string;
19
- items: NavListItem[];
20
- divider?: boolean;
21
- };
22
- type LinkComponentProps = {
23
- href: string;
24
- onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
25
- children: React.ReactNode;
26
- [key: string]: unknown;
27
- };
28
- type NavListProps = {
29
- items?: NavListItem[];
30
- groups?: NavListGroup[];
31
- variant?: 'sidebar' | 'menu' | 'dropdown';
32
- onItemClick?: (item: NavListItem) => void;
33
- sx?: Record<string, unknown>;
34
- iconSize?: number;
35
- /**
36
- * Custom Link component to use for rendering links.
37
- * Useful for integrating with Next.js Link, React Router Link, etc.
38
- *
39
- * @example
40
- * // Next.js
41
- * import NextLink from 'next/link';
42
- * <NavList LinkComponent={NextLink} ... />
43
- *
44
- * @example
45
- * // React Router
46
- * import { Link as RouterLink } from 'react-router-dom';
47
- * <NavList LinkComponent={RouterLink} ... />
48
- */
49
- LinkComponent?: React.ComponentType<LinkComponentProps>;
50
- };
51
- declare const NavList: {
52
- ({
53
- items,
54
- groups,
55
- variant,
56
- onItemClick,
57
- sx,
58
- iconSize,
59
- LinkComponent
60
- }: NavListProps): import("react/jsx-runtime").JSX.Element;
61
- displayName: string;
62
- };
63
- //#endregion
64
- export { type LinkComponentProps, NavList, type NavListGroup, type NavListItem, type NavListProps };