@ttoss/components 2.14.20 → 2.14.22

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 (74) hide show
  1. package/dist/Accordion/index.d.mts +157 -0
  2. package/dist/Accordion/index.mjs +175 -0
  3. package/dist/DatePicker/index.d.mts +26 -0
  4. package/dist/DatePicker/index.mjs +339 -0
  5. package/dist/Drawer/index.d.mts +17 -0
  6. package/dist/{esm/Drawer/index.js → Drawer/index.mjs} +21 -14
  7. package/dist/EnhancedTitle/{index.d.ts → index.d.mts} +57 -47
  8. package/dist/EnhancedTitle/index.mjs +234 -0
  9. package/dist/FileUploader/index.d.mts +77 -0
  10. package/dist/FileUploader/index.mjs +386 -0
  11. package/dist/InstallPwa/index.d.mts +13 -0
  12. package/dist/InstallPwa/index.mjs +64 -0
  13. package/dist/JsonEditor/index.d.mts +3 -0
  14. package/dist/{esm/JsonEditor/index.js → JsonEditor/index.mjs} +0 -3
  15. package/dist/JsonView/index.d.mts +3 -0
  16. package/dist/{esm/JsonView/index.js → JsonView/index.mjs} +0 -3
  17. package/dist/List/{index.d.ts → index.d.mts} +9 -6
  18. package/dist/List/index.mjs +34 -0
  19. package/dist/LockedOverlay/index.d.mts +162 -0
  20. package/dist/LockedOverlay/index.mjs +386 -0
  21. package/dist/Markdown/index.d.mts +16 -0
  22. package/dist/Markdown/index.mjs +26 -0
  23. package/dist/Menu/index.d.mts +16 -0
  24. package/dist/{esm/Menu/index.js → Menu/index.mjs} +56 -51
  25. package/dist/MetricCard/index.d.mts +153 -0
  26. package/dist/MetricCard/index.mjs +408 -0
  27. package/dist/Modal/index.d.mts +11 -0
  28. package/dist/{esm/Modal/index.js → Modal/index.mjs} +11 -12
  29. package/dist/NavList/index.d.mts +64 -0
  30. package/dist/{esm/NavList/index.js → NavList/index.mjs} +79 -73
  31. package/dist/NotificationCard/index.d.mts +22 -0
  32. package/dist/NotificationCard/index.mjs +173 -0
  33. package/dist/NotificationsMenu/index.d.mts +47 -0
  34. package/dist/NotificationsMenu/index.mjs +380 -0
  35. package/dist/Search/index.d.mts +18 -0
  36. package/dist/{esm/Search/index.js → Search/index.mjs} +11 -9
  37. package/dist/SpotlightCard/index.d.mts +36 -0
  38. package/dist/SpotlightCard/index.mjs +219 -0
  39. package/dist/Table/index.d.mts +17 -0
  40. package/dist/Table/index.mjs +64 -0
  41. package/dist/Tabs/index.d.mts +17 -0
  42. package/dist/{esm/Tabs/index.js → Tabs/index.mjs} +24 -12
  43. package/dist/Toast/index.d.mts +8 -0
  44. package/dist/Toast/index.mjs +43 -0
  45. package/package.json +15 -15
  46. package/dist/Accordion/index.d.ts +0 -148
  47. package/dist/DatePicker/index.d.ts +0 -20
  48. package/dist/Drawer/index.d.ts +0 -12
  49. package/dist/LockedOverlay/index.d.ts +0 -151
  50. package/dist/Markdown/index.d.ts +0 -11
  51. package/dist/Menu/index.d.ts +0 -11
  52. package/dist/MetricCard/index.d.ts +0 -148
  53. package/dist/Modal/index.d.ts +0 -10
  54. package/dist/NavList/index.d.ts +0 -55
  55. package/dist/NotificationCard/index.d.ts +0 -21
  56. package/dist/NotificationsMenu/index.d.ts +0 -36
  57. package/dist/Search/index.d.ts +0 -11
  58. package/dist/SpotlightCard/index.d.ts +0 -27
  59. package/dist/Table/index.d.ts +0 -16
  60. package/dist/esm/Accordion/index.js +0 -119
  61. package/dist/esm/DatePicker/index.js +0 -331
  62. package/dist/esm/EnhancedTitle/index.js +0 -190
  63. package/dist/esm/FileUploader/index.js +0 -401
  64. package/dist/esm/InstallPwa/index.js +0 -61
  65. package/dist/esm/List/index.js +0 -30
  66. package/dist/esm/LockedOverlay/index.js +0 -316
  67. package/dist/esm/Markdown/index.js +0 -23
  68. package/dist/esm/MetricCard/index.js +0 -327
  69. package/dist/esm/NotificationCard/index.js +0 -156
  70. package/dist/esm/NotificationsMenu/index.js +0 -359
  71. package/dist/esm/SpotlightCard/index.js +0 -212
  72. package/dist/esm/Table/index.js +0 -63
  73. package/dist/esm/Toast/index.js +0 -38
  74. package/dist/esm/chunk-V4MHYKRI.js +0 -7
@@ -1,11 +1,11 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- import { __name } from "../chunk-V4MHYKRI.js";
3
-
4
- // src/components/Menu/Menu.tsx
2
+ import * as React from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
5
4
  import { Icon } from "@ttoss/react-icons";
6
5
  import { Box, Flex } from "@ttoss/ui";
7
- import * as React from "react";
8
- var Menu = /* @__PURE__ */__name(({
6
+
7
+ //#region src/components/Menu/Menu.tsx
8
+ const Menu = ({
9
9
  children,
10
10
  sx,
11
11
  menuIcon = "menu-open"
@@ -14,19 +14,17 @@ var Menu = /* @__PURE__ */__name(({
14
14
  const [stylePos, setStylePos] = React.useState({});
15
15
  const triggerRef = React.useRef(null);
16
16
  const panelRef = React.useRef(null);
17
- const toggle = /* @__PURE__ */__name(() => {
17
+ const toggle = () => {
18
18
  return setIsOpen(v => {
19
19
  return !v;
20
20
  });
21
- }, "toggle");
21
+ };
22
22
  React.useEffect(() => {
23
23
  if (!isOpen) return;
24
- const onDocClick = /* @__PURE__ */__name(e => {
24
+ const onDocClick = e => {
25
25
  const t = e.target;
26
- if (panelRef.current && !panelRef.current.contains(t) && triggerRef.current && !triggerRef.current.contains(t)) {
27
- setIsOpen(false);
28
- }
29
- }, "onDocClick");
26
+ if (panelRef.current && !panelRef.current.contains(t) && triggerRef.current && !triggerRef.current.contains(t)) setIsOpen(false);
27
+ };
30
28
  document.addEventListener("mousedown", onDocClick);
31
29
  return () => {
32
30
  return document.removeEventListener("mousedown", onDocClick);
@@ -35,18 +33,18 @@ var Menu = /* @__PURE__ */__name(({
35
33
  React.useLayoutEffect(() => {
36
34
  if (!isOpen) return;
37
35
  let rafId = 0;
38
- const getWidth = /* @__PURE__ */__name(() => {
36
+ const getWidth = () => {
39
37
  const w = sx?.width ?? sx?.maxWidth ?? sx?.minWidth;
40
38
  return Array.isArray(w) ? w[w.length - 1] : w;
41
- }, "getWidth");
42
- const compute = /* @__PURE__ */__name(() => {
39
+ };
40
+ const compute = () => {
43
41
  const trigger = triggerRef.current;
44
- const panel2 = panelRef.current;
45
- if (!trigger || !panel2) return;
42
+ const panel = panelRef.current;
43
+ if (!trigger || !panel) return;
46
44
  const width = getWidth();
47
- if (width) panel2.style.width = typeof width === "number" ? `${width}px` : String(width);
45
+ if (width) panel.style.width = typeof width === "number" ? `${width}px` : String(width);
48
46
  const tr = trigger.getBoundingClientRect();
49
- const pr = panel2.getBoundingClientRect();
47
+ const pr = panel.getBoundingClientRect();
50
48
  const vw = window.innerWidth,
51
49
  vh = window.innerHeight,
52
50
  m = 8;
@@ -65,11 +63,11 @@ var Menu = /* @__PURE__ */__name(({
65
63
  width: typeof width === "number" ? `${width}px` : String(width)
66
64
  })
67
65
  });
68
- }, "compute");
66
+ };
69
67
  rafId = requestAnimationFrame(compute);
70
- const onResizeScroll = /* @__PURE__ */__name(() => {
68
+ const onResizeScroll = () => {
71
69
  return rafId = requestAnimationFrame(compute);
72
- }, "onResizeScroll");
70
+ };
73
71
  window.addEventListener("resize", onResizeScroll);
74
72
  window.addEventListener("scroll", onResizeScroll, true);
75
73
  return () => {
@@ -78,7 +76,7 @@ var Menu = /* @__PURE__ */__name(({
78
76
  window.removeEventListener("scroll", onResizeScroll, true);
79
77
  };
80
78
  }, [isOpen, sx]);
81
- const panel = isOpen ? /* @__PURE__ */React.createElement(Flex, {
79
+ const panel = isOpen ? /* @__PURE__ */jsx(Flex, {
82
80
  ref: panelRef,
83
81
  sx: {
84
82
  width: ["280px", "320px"],
@@ -97,35 +95,42 @@ var Menu = /* @__PURE__ */__name(({
97
95
  style: {
98
96
  pointerEvents: "auto",
99
97
  ...stylePos
100
- }
101
- }, /* @__PURE__ */React.createElement(Box, {
102
- as: "nav"
103
- }, children)) : null;
104
- return /* @__PURE__ */React.createElement(Flex, {
98
+ },
99
+ children: /* @__PURE__ */jsx(Box, {
100
+ as: "nav",
101
+ children
102
+ })
103
+ }) : null;
104
+ return /* @__PURE__ */jsx(Flex, {
105
105
  sx: {
106
106
  position: "relative",
107
107
  display: "inline-block"
108
- }
109
- }, /* @__PURE__ */React.createElement(Box, {
110
- sx: {
111
- position: "relative"
112
- }
113
- }, /* @__PURE__ */React.createElement("button", {
114
- ref: triggerRef,
115
- onClick: toggle,
116
- "aria-haspopup": "true",
117
- "aria-expanded": isOpen,
118
- style: {
119
- background: "transparent",
120
- border: 0,
121
- padding: 4,
122
- cursor: "pointer",
123
- display: "inline-flex",
124
- alignItems: "center",
125
- justifyContent: "center"
126
- }
127
- }, /* @__PURE__ */React.createElement(Icon, {
128
- icon: menuIcon
129
- })), isOpen && panel));
130
- }, "Menu");
108
+ },
109
+ children: /* @__PURE__ */jsxs(Box, {
110
+ sx: {
111
+ position: "relative"
112
+ },
113
+ children: [/* @__PURE__ */jsx("button", {
114
+ ref: triggerRef,
115
+ onClick: toggle,
116
+ "aria-haspopup": "true",
117
+ "aria-expanded": isOpen,
118
+ style: {
119
+ background: "transparent",
120
+ border: 0,
121
+ padding: 4,
122
+ cursor: "pointer",
123
+ display: "inline-flex",
124
+ alignItems: "center",
125
+ justifyContent: "center"
126
+ },
127
+ children: /* @__PURE__ */jsx(Icon, {
128
+ icon: menuIcon
129
+ })
130
+ }), isOpen && panel]
131
+ })
132
+ });
133
+ };
134
+
135
+ //#endregion
131
136
  export { Menu };
@@ -0,0 +1,153 @@
1
+
2
+ import { IconType } from "@ttoss/react-icons";
3
+
4
+ //#region src/components/MetricCard/MetricCard.types.d.ts
5
+ /**
6
+ * Base metric properties shared by all metric types.
7
+ */
8
+ interface BaseMetric {
9
+ /**
10
+ * Label displayed above the metric value.
11
+ */
12
+ label: string;
13
+ /**
14
+ * Optional tooltip text or action handler for additional context.
15
+ * When a string is provided, it displays a simple tooltip.
16
+ * When a function is provided, it's called when the tooltip icon is clicked.
17
+ */
18
+ tooltip?: string | (() => void);
19
+ /**
20
+ * Icon to display alongside the metric.
21
+ */
22
+ icon?: IconType;
23
+ /**
24
+ * Optional click handler to make the metric card interactive.
25
+ */
26
+ onClick?: () => void;
27
+ /**
28
+ * Optional help article action handler.
29
+ */
30
+ helpArticleAction?: () => void;
31
+ }
32
+ /**
33
+ * Date-based metric for displaying dates like expiration or renewal.
34
+ */
35
+ interface DateMetric extends BaseMetric {
36
+ type: 'date';
37
+ /**
38
+ * The date value to display.
39
+ */
40
+ date: string;
41
+ /**
42
+ * Optional message showing remaining days.
43
+ */
44
+ remainingDaysMessage?: string;
45
+ /**
46
+ * Whether to show a warning indicator.
47
+ */
48
+ isWarning?: boolean;
49
+ }
50
+ /**
51
+ * Percentage-based metric with progress bar.
52
+ */
53
+ interface PercentageMetric extends BaseMetric {
54
+ type: 'percentage';
55
+ /**
56
+ * Current value.
57
+ */
58
+ current: number;
59
+ /**
60
+ * Maximum value. Use null for unlimited.
61
+ */
62
+ max: number | null;
63
+ /**
64
+ * Custom formatter for displaying values.
65
+ */
66
+ formatValue?: (value: number) => string;
67
+ /**
68
+ * Percentage threshold at which to show an alert.
69
+ */
70
+ showAlertThreshold?: number;
71
+ }
72
+ /**
73
+ * Number-based metric for displaying counts.
74
+ */
75
+ interface NumberMetric extends BaseMetric {
76
+ type: 'number';
77
+ /**
78
+ * Current value.
79
+ */
80
+ current: number;
81
+ /**
82
+ * Maximum value. Use null for unlimited.
83
+ */
84
+ max: number | null;
85
+ /**
86
+ * Custom formatter for displaying values.
87
+ */
88
+ formatValue?: (value: number) => string;
89
+ /**
90
+ * Optional footer text below the metric.
91
+ */
92
+ footerText?: string;
93
+ }
94
+ /**
95
+ * Union type for all supported metric types.
96
+ */
97
+ type Metric = DateMetric | PercentageMetric | NumberMetric;
98
+ /**
99
+ * Props for the MetricCard component.
100
+ */
101
+ interface MetricCardProps {
102
+ /**
103
+ * The metric configuration to display.
104
+ */
105
+ metric: Metric;
106
+ /**
107
+ * Whether the card is in loading state.
108
+ */
109
+ isLoading?: boolean;
110
+ }
111
+ //#endregion
112
+ //#region src/components/MetricCard/MetricCard.d.ts
113
+ /**
114
+ * MetricCard component displays a metric in a consistent card layout.
115
+ *
116
+ * It supports three metric types:
117
+ * - **date**: displays a date and optional remaining-days message
118
+ * - **percentage**: displays current/max values and a progress bar
119
+ * - **number**: displays current/max values and an optional footer text
120
+ *
121
+ * @example
122
+ * ```tsx
123
+ * <MetricCard
124
+ * metric={{
125
+ * type: 'date',
126
+ * label: 'Renewal date',
127
+ * date: '31/12/2025',
128
+ * icon: 'fluent:calendar-24-regular',
129
+ * remainingDaysMessage: '10 days remaining',
130
+ * }}
131
+ * />
132
+ * ```
133
+ *
134
+ * @example
135
+ * ```tsx
136
+ * <MetricCard
137
+ * metric={{
138
+ * type: 'percentage',
139
+ * label: 'Plan usage',
140
+ * current: 350,
141
+ * max: 1000,
142
+ * icon: 'fluent:gauge-24-regular',
143
+ * showAlertThreshold: 80,
144
+ * }}
145
+ * />
146
+ * ```
147
+ */
148
+ declare const MetricCard: ({
149
+ metric,
150
+ isLoading
151
+ }: MetricCardProps) => import("react/jsx-runtime").JSX.Element | null;
152
+ //#endregion
153
+ export { BaseMetric, DateMetric, Metric, MetricCard, MetricCardProps, NumberMetric, PercentageMetric };