analytica-frontend-lib 1.0.21 → 1.0.23
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/Alert/Alert.d.mts +13 -0
- package/dist/Alert/Alert.d.ts +13 -0
- package/dist/Alert/Alert.js +158 -0
- package/dist/Alert/Alert.mjs +85 -0
- package/dist/Badge/Badge.d.mts +47 -0
- package/dist/Badge/Badge.d.ts +47 -0
- package/dist/Badge/Badge.js +117 -0
- package/dist/Badge/Badge.mjs +92 -0
- package/dist/Button/Button.d.mts +46 -0
- package/dist/Button/Button.d.ts +46 -0
- package/dist/Button/Button.js +84 -0
- package/dist/Button/Button.mjs +59 -0
- package/dist/CheckBox/CheckBox.d.mts +74 -0
- package/dist/CheckBox/CheckBox.d.ts +74 -0
- package/dist/CheckBox/CheckBox.js +264 -0
- package/dist/CheckBox/CheckBox.mjs +195 -0
- package/dist/DropdownMenu/DropdownMenu.d.mts +29 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts +29 -0
- package/dist/DropdownMenu/DropdownMenu.js +262 -0
- package/dist/DropdownMenu/DropdownMenu.mjs +242 -0
- package/dist/IconButton/IconButton.d.mts +77 -0
- package/dist/IconButton/IconButton.d.ts +77 -0
- package/dist/IconButton/IconButton.js +79 -0
- package/dist/IconButton/IconButton.mjs +54 -0
- package/dist/IconRoundedButton/IconRoundedButton.d.mts +35 -0
- package/dist/IconRoundedButton/IconRoundedButton.d.ts +35 -0
- package/dist/IconRoundedButton/IconRoundedButton.js +68 -0
- package/dist/IconRoundedButton/IconRoundedButton.mjs +43 -0
- package/dist/NavButton/NavButton.d.mts +58 -0
- package/dist/NavButton/NavButton.d.ts +58 -0
- package/dist/NavButton/NavButton.js +76 -0
- package/dist/NavButton/NavButton.mjs +51 -0
- package/dist/SelectionButton/SelectionButton.d.mts +58 -0
- package/dist/SelectionButton/SelectionButton.d.ts +58 -0
- package/dist/SelectionButton/SelectionButton.js +81 -0
- package/dist/SelectionButton/SelectionButton.mjs +56 -0
- package/dist/Table/Table.d.mts +17 -0
- package/dist/Table/Table.d.ts +17 -0
- package/dist/Table/Table.js +139 -0
- package/dist/Table/Table.mjs +107 -0
- package/dist/Text/Text.d.mts +59 -0
- package/dist/Text/Text.d.ts +59 -0
- package/dist/Text/Text.js +77 -0
- package/dist/Text/Text.mjs +6 -0
- package/dist/TextArea/TextArea.d.mts +69 -0
- package/dist/TextArea/TextArea.d.ts +69 -0
- package/dist/TextArea/TextArea.js +211 -0
- package/dist/TextArea/TextArea.mjs +142 -0
- package/dist/Toast/Toast.d.mts +17 -0
- package/dist/Toast/Toast.d.ts +17 -0
- package/dist/Toast/Toast.js +100 -0
- package/dist/Toast/Toast.mjs +7 -0
- package/dist/Toast/utils/ToastStore.d.mts +19 -0
- package/dist/Toast/utils/ToastStore.d.ts +19 -0
- package/dist/Toast/utils/ToastStore.js +44 -0
- package/dist/Toast/utils/ToastStore.mjs +6 -0
- package/dist/Toast/utils/Toaster.d.mts +11 -0
- package/dist/Toast/utils/Toaster.d.ts +11 -0
- package/dist/Toast/utils/Toaster.js +145 -0
- package/dist/Toast/utils/Toaster.mjs +35 -0
- package/dist/chunk-MI5FIRHM.mjs +75 -0
- package/dist/chunk-TT3VCQGR.mjs +53 -0
- package/dist/chunk-WIOCQOM7.mjs +20 -0
- package/dist/index.css +103 -0
- package/dist/index.d.mts +68 -2
- package/dist/index.d.ts +68 -2
- package/dist/index.js +217 -84
- package/dist/index.mjs +215 -79
- package/package.json +71 -3
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/TextArea/TextArea.tsx
|
|
22
|
+
var TextArea_exports = {};
|
|
23
|
+
__export(TextArea_exports, {
|
|
24
|
+
TextArea: () => TextArea
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(TextArea_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
|
|
29
|
+
// src/components/Text/Text.tsx
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var Text = ({
|
|
32
|
+
children,
|
|
33
|
+
size = "md",
|
|
34
|
+
weight = "normal",
|
|
35
|
+
color = "text-text-950",
|
|
36
|
+
as,
|
|
37
|
+
className = "",
|
|
38
|
+
...props
|
|
39
|
+
}) => {
|
|
40
|
+
let sizeClasses = "";
|
|
41
|
+
let weightClasses = "";
|
|
42
|
+
const sizeClassMap = {
|
|
43
|
+
"2xs": "text-2xs",
|
|
44
|
+
xs: "text-xs",
|
|
45
|
+
sm: "text-sm",
|
|
46
|
+
md: "text-md",
|
|
47
|
+
lg: "text-lg",
|
|
48
|
+
xl: "text-xl",
|
|
49
|
+
"2xl": "text-2xl",
|
|
50
|
+
"3xl": "text-3xl",
|
|
51
|
+
"4xl": "text-4xl",
|
|
52
|
+
"5xl": "text-5xl",
|
|
53
|
+
"6xl": "text-6xl"
|
|
54
|
+
};
|
|
55
|
+
sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
|
|
56
|
+
const weightClassMap = {
|
|
57
|
+
hairline: "font-hairline",
|
|
58
|
+
light: "font-light",
|
|
59
|
+
normal: "font-normal",
|
|
60
|
+
medium: "font-medium",
|
|
61
|
+
semibold: "font-semibold",
|
|
62
|
+
bold: "font-bold",
|
|
63
|
+
extrabold: "font-extrabold",
|
|
64
|
+
black: "font-black"
|
|
65
|
+
};
|
|
66
|
+
weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
|
|
67
|
+
const baseClasses = "font-primary";
|
|
68
|
+
const Component = as ?? "p";
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
70
|
+
Component,
|
|
71
|
+
{
|
|
72
|
+
className: `${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`,
|
|
73
|
+
...props,
|
|
74
|
+
children
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/components/TextArea/TextArea.tsx
|
|
80
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
81
|
+
var SIZE_CLASSES = {
|
|
82
|
+
small: {
|
|
83
|
+
container: "w-72",
|
|
84
|
+
// 288px width
|
|
85
|
+
textarea: "h-24 text-sm",
|
|
86
|
+
// 96px height, 14px font
|
|
87
|
+
textSize: "sm"
|
|
88
|
+
},
|
|
89
|
+
medium: {
|
|
90
|
+
container: "w-72",
|
|
91
|
+
// 288px width
|
|
92
|
+
textarea: "h-24 text-base",
|
|
93
|
+
// 96px height, 16px font
|
|
94
|
+
textSize: "md"
|
|
95
|
+
},
|
|
96
|
+
large: {
|
|
97
|
+
container: "w-72",
|
|
98
|
+
// 288px width
|
|
99
|
+
textarea: "h-24 text-lg",
|
|
100
|
+
// 96px height, 18px font
|
|
101
|
+
textSize: "lg"
|
|
102
|
+
},
|
|
103
|
+
extraLarge: {
|
|
104
|
+
container: "w-72",
|
|
105
|
+
// 288px width
|
|
106
|
+
textarea: "h-24 text-xl",
|
|
107
|
+
// 96px height, 20px font
|
|
108
|
+
textSize: "xl"
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var BASE_TEXTAREA_CLASSES = "w-full box-border p-3 bg-background border border-solid rounded-[4px] resize-none focus:outline-none font-roboto font-normal leading-[150%] placeholder:text-text-600 transition-all duration-200";
|
|
112
|
+
var STATE_CLASSES = {
|
|
113
|
+
default: {
|
|
114
|
+
base: "border-border-300 bg-background text-text-600",
|
|
115
|
+
hover: "hover:border-border-400",
|
|
116
|
+
focus: "focus:border-border-500"
|
|
117
|
+
},
|
|
118
|
+
hovered: {
|
|
119
|
+
base: "border-border-400 bg-background text-text-600",
|
|
120
|
+
hover: "",
|
|
121
|
+
focus: "focus:border-border-500"
|
|
122
|
+
},
|
|
123
|
+
focused: {
|
|
124
|
+
base: "border-2 border-primary-950 bg-background text-text-900",
|
|
125
|
+
hover: "",
|
|
126
|
+
focus: ""
|
|
127
|
+
},
|
|
128
|
+
invalid: {
|
|
129
|
+
base: "border-2 border-red-700 bg-white text-gray-800",
|
|
130
|
+
hover: "hover:border-red-700",
|
|
131
|
+
focus: "focus:border-red-700"
|
|
132
|
+
},
|
|
133
|
+
disabled: {
|
|
134
|
+
base: "border-border-300 bg-background text-text-600 cursor-not-allowed opacity-40",
|
|
135
|
+
hover: "",
|
|
136
|
+
focus: ""
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var TextArea = (0, import_react.forwardRef)(
|
|
140
|
+
({
|
|
141
|
+
label,
|
|
142
|
+
size = "medium",
|
|
143
|
+
state = "default",
|
|
144
|
+
errorMessage,
|
|
145
|
+
helperMessage,
|
|
146
|
+
className = "",
|
|
147
|
+
labelClassName = "",
|
|
148
|
+
disabled,
|
|
149
|
+
id,
|
|
150
|
+
onChange,
|
|
151
|
+
placeholder,
|
|
152
|
+
...props
|
|
153
|
+
}, ref) => {
|
|
154
|
+
const generatedId = (0, import_react.useId)();
|
|
155
|
+
const inputId = id ?? `textarea-${generatedId}`;
|
|
156
|
+
const [isFocused, setIsFocused] = (0, import_react.useState)(false);
|
|
157
|
+
const handleChange = (event) => {
|
|
158
|
+
onChange?.(event);
|
|
159
|
+
};
|
|
160
|
+
const handleFocus = (event) => {
|
|
161
|
+
setIsFocused(true);
|
|
162
|
+
props.onFocus?.(event);
|
|
163
|
+
};
|
|
164
|
+
const handleBlur = (event) => {
|
|
165
|
+
setIsFocused(false);
|
|
166
|
+
props.onBlur?.(event);
|
|
167
|
+
};
|
|
168
|
+
let currentState = disabled ? "disabled" : state;
|
|
169
|
+
if (isFocused && currentState !== "invalid" && currentState !== "disabled") {
|
|
170
|
+
currentState = "focused";
|
|
171
|
+
}
|
|
172
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
173
|
+
const stateClasses = STATE_CLASSES[currentState];
|
|
174
|
+
const textareaClasses = `${BASE_TEXTAREA_CLASSES} ${sizeClasses.textarea} ${stateClasses.base} ${stateClasses.hover} ${stateClasses.focus} ${className}`;
|
|
175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex flex-col ${sizeClasses.container}`, children: [
|
|
176
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
177
|
+
Text,
|
|
178
|
+
{
|
|
179
|
+
as: "label",
|
|
180
|
+
htmlFor: inputId,
|
|
181
|
+
size: sizeClasses.textSize,
|
|
182
|
+
weight: "medium",
|
|
183
|
+
color: "text-text-950",
|
|
184
|
+
className: `mb-1.5 ${labelClassName}`,
|
|
185
|
+
children: label
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
189
|
+
"textarea",
|
|
190
|
+
{
|
|
191
|
+
ref,
|
|
192
|
+
id: inputId,
|
|
193
|
+
disabled,
|
|
194
|
+
onChange: handleChange,
|
|
195
|
+
onFocus: handleFocus,
|
|
196
|
+
onBlur: handleBlur,
|
|
197
|
+
className: textareaClasses,
|
|
198
|
+
placeholder,
|
|
199
|
+
...props
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-error-600", children: errorMessage }),
|
|
203
|
+
helperMessage && !errorMessage && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperMessage })
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
TextArea.displayName = "TextArea";
|
|
208
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
209
|
+
0 && (module.exports = {
|
|
210
|
+
TextArea
|
|
211
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Text
|
|
4
|
+
} from "../chunk-TT3VCQGR.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/TextArea/TextArea.tsx
|
|
7
|
+
import {
|
|
8
|
+
forwardRef,
|
|
9
|
+
useState,
|
|
10
|
+
useId
|
|
11
|
+
} from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
var SIZE_CLASSES = {
|
|
14
|
+
small: {
|
|
15
|
+
container: "w-72",
|
|
16
|
+
// 288px width
|
|
17
|
+
textarea: "h-24 text-sm",
|
|
18
|
+
// 96px height, 14px font
|
|
19
|
+
textSize: "sm"
|
|
20
|
+
},
|
|
21
|
+
medium: {
|
|
22
|
+
container: "w-72",
|
|
23
|
+
// 288px width
|
|
24
|
+
textarea: "h-24 text-base",
|
|
25
|
+
// 96px height, 16px font
|
|
26
|
+
textSize: "md"
|
|
27
|
+
},
|
|
28
|
+
large: {
|
|
29
|
+
container: "w-72",
|
|
30
|
+
// 288px width
|
|
31
|
+
textarea: "h-24 text-lg",
|
|
32
|
+
// 96px height, 18px font
|
|
33
|
+
textSize: "lg"
|
|
34
|
+
},
|
|
35
|
+
extraLarge: {
|
|
36
|
+
container: "w-72",
|
|
37
|
+
// 288px width
|
|
38
|
+
textarea: "h-24 text-xl",
|
|
39
|
+
// 96px height, 20px font
|
|
40
|
+
textSize: "xl"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var BASE_TEXTAREA_CLASSES = "w-full box-border p-3 bg-background border border-solid rounded-[4px] resize-none focus:outline-none font-roboto font-normal leading-[150%] placeholder:text-text-600 transition-all duration-200";
|
|
44
|
+
var STATE_CLASSES = {
|
|
45
|
+
default: {
|
|
46
|
+
base: "border-border-300 bg-background text-text-600",
|
|
47
|
+
hover: "hover:border-border-400",
|
|
48
|
+
focus: "focus:border-border-500"
|
|
49
|
+
},
|
|
50
|
+
hovered: {
|
|
51
|
+
base: "border-border-400 bg-background text-text-600",
|
|
52
|
+
hover: "",
|
|
53
|
+
focus: "focus:border-border-500"
|
|
54
|
+
},
|
|
55
|
+
focused: {
|
|
56
|
+
base: "border-2 border-primary-950 bg-background text-text-900",
|
|
57
|
+
hover: "",
|
|
58
|
+
focus: ""
|
|
59
|
+
},
|
|
60
|
+
invalid: {
|
|
61
|
+
base: "border-2 border-red-700 bg-white text-gray-800",
|
|
62
|
+
hover: "hover:border-red-700",
|
|
63
|
+
focus: "focus:border-red-700"
|
|
64
|
+
},
|
|
65
|
+
disabled: {
|
|
66
|
+
base: "border-border-300 bg-background text-text-600 cursor-not-allowed opacity-40",
|
|
67
|
+
hover: "",
|
|
68
|
+
focus: ""
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var TextArea = forwardRef(
|
|
72
|
+
({
|
|
73
|
+
label,
|
|
74
|
+
size = "medium",
|
|
75
|
+
state = "default",
|
|
76
|
+
errorMessage,
|
|
77
|
+
helperMessage,
|
|
78
|
+
className = "",
|
|
79
|
+
labelClassName = "",
|
|
80
|
+
disabled,
|
|
81
|
+
id,
|
|
82
|
+
onChange,
|
|
83
|
+
placeholder,
|
|
84
|
+
...props
|
|
85
|
+
}, ref) => {
|
|
86
|
+
const generatedId = useId();
|
|
87
|
+
const inputId = id ?? `textarea-${generatedId}`;
|
|
88
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
89
|
+
const handleChange = (event) => {
|
|
90
|
+
onChange?.(event);
|
|
91
|
+
};
|
|
92
|
+
const handleFocus = (event) => {
|
|
93
|
+
setIsFocused(true);
|
|
94
|
+
props.onFocus?.(event);
|
|
95
|
+
};
|
|
96
|
+
const handleBlur = (event) => {
|
|
97
|
+
setIsFocused(false);
|
|
98
|
+
props.onBlur?.(event);
|
|
99
|
+
};
|
|
100
|
+
let currentState = disabled ? "disabled" : state;
|
|
101
|
+
if (isFocused && currentState !== "invalid" && currentState !== "disabled") {
|
|
102
|
+
currentState = "focused";
|
|
103
|
+
}
|
|
104
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
105
|
+
const stateClasses = STATE_CLASSES[currentState];
|
|
106
|
+
const textareaClasses = `${BASE_TEXTAREA_CLASSES} ${sizeClasses.textarea} ${stateClasses.base} ${stateClasses.hover} ${stateClasses.focus} ${className}`;
|
|
107
|
+
return /* @__PURE__ */ jsxs("div", { className: `flex flex-col ${sizeClasses.container}`, children: [
|
|
108
|
+
label && /* @__PURE__ */ jsx(
|
|
109
|
+
Text,
|
|
110
|
+
{
|
|
111
|
+
as: "label",
|
|
112
|
+
htmlFor: inputId,
|
|
113
|
+
size: sizeClasses.textSize,
|
|
114
|
+
weight: "medium",
|
|
115
|
+
color: "text-text-950",
|
|
116
|
+
className: `mb-1.5 ${labelClassName}`,
|
|
117
|
+
children: label
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ jsx(
|
|
121
|
+
"textarea",
|
|
122
|
+
{
|
|
123
|
+
ref,
|
|
124
|
+
id: inputId,
|
|
125
|
+
disabled,
|
|
126
|
+
onChange: handleChange,
|
|
127
|
+
onFocus: handleFocus,
|
|
128
|
+
onBlur: handleBlur,
|
|
129
|
+
className: textareaClasses,
|
|
130
|
+
placeholder,
|
|
131
|
+
...props
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
errorMessage && /* @__PURE__ */ jsx(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-error-600", children: errorMessage }),
|
|
135
|
+
helperMessage && !errorMessage && /* @__PURE__ */ jsx(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperMessage })
|
|
136
|
+
] });
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
TextArea.displayName = "TextArea";
|
|
140
|
+
export {
|
|
141
|
+
TextArea
|
|
142
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'default';
|
|
5
|
+
type ToastProps = {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
/** Visual variant of the badge */
|
|
10
|
+
variant?: 'solid' | 'outlined';
|
|
11
|
+
/** Action type of the badge */
|
|
12
|
+
action?: 'warning' | 'success' | 'info';
|
|
13
|
+
position?: ToastPosition;
|
|
14
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
15
|
+
declare const Toast: ({ variant, action, className, onClose, title, description, position, ...props }: ToastProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { Toast };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'default';
|
|
5
|
+
type ToastProps = {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
/** Visual variant of the badge */
|
|
10
|
+
variant?: 'solid' | 'outlined';
|
|
11
|
+
/** Action type of the badge */
|
|
12
|
+
action?: 'warning' | 'success' | 'info';
|
|
13
|
+
position?: ToastPosition;
|
|
14
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
15
|
+
declare const Toast: ({ variant, action, className, onClose, title, description, position, ...props }: ToastProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { Toast };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/Toast/Toast.tsx
|
|
22
|
+
var Toast_exports = {};
|
|
23
|
+
__export(Toast_exports, {
|
|
24
|
+
Toast: () => Toast
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(Toast_exports);
|
|
27
|
+
var import_phosphor_react = require("phosphor-react");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
var VARIANT_ACTION_CLASSES = {
|
|
30
|
+
solid: {
|
|
31
|
+
warning: "bg-warning text-warning-800 border-none focus-visible:outline-none",
|
|
32
|
+
success: "bg-success text-success-800 border-none focus-visible:outline-none",
|
|
33
|
+
info: "bg-info text-info-800 border-none focus-visible:outline-none"
|
|
34
|
+
},
|
|
35
|
+
outlined: {
|
|
36
|
+
warning: "bg-warning text-warning-800 border border-warning-200 focus-visible:outline-none",
|
|
37
|
+
success: "bg-success text-success-800 border border-success-200 focus-visible:outline-none",
|
|
38
|
+
info: "bg-info text-info-800 border border-info-200 focus-visible:outline-none"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var iconMap = {
|
|
42
|
+
success: import_phosphor_react.CheckCircle,
|
|
43
|
+
info: import_phosphor_react.Info,
|
|
44
|
+
warning: import_phosphor_react.WarningCircle
|
|
45
|
+
};
|
|
46
|
+
var Toast = ({
|
|
47
|
+
variant = "outlined",
|
|
48
|
+
action = "success",
|
|
49
|
+
className = "",
|
|
50
|
+
onClose,
|
|
51
|
+
title,
|
|
52
|
+
description,
|
|
53
|
+
position = "default",
|
|
54
|
+
...props
|
|
55
|
+
}) => {
|
|
56
|
+
const variantClasses = VARIANT_ACTION_CLASSES[variant][action];
|
|
57
|
+
const positionClasses = {
|
|
58
|
+
"top-left": "fixed top-4 left-4",
|
|
59
|
+
"top-center": "fixed top-4 left-1/2 transform -translate-x-1/2",
|
|
60
|
+
"top-right": "fixed top-4 right-4",
|
|
61
|
+
"bottom-left": "fixed bottom-4 left-4",
|
|
62
|
+
"bottom-center": "fixed bottom-4 left-1/2 transform -translate-x-1/2",
|
|
63
|
+
"bottom-right": "fixed bottom-4 right-4",
|
|
64
|
+
default: ""
|
|
65
|
+
};
|
|
66
|
+
const IconAction = iconMap[action] || iconMap["success"];
|
|
67
|
+
const baseClasses = "max-w-[390px] w-full flex flex-row items-start justify-between shadow-lg rounded-lg border p-4 gap-6 group";
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
role: "alert",
|
|
72
|
+
"aria-live": "assertive",
|
|
73
|
+
"aria-atomic": "true",
|
|
74
|
+
className: `${baseClasses} ${positionClasses[position]} ${variantClasses} ${className}`,
|
|
75
|
+
...props,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-row items-start gap-3", children: [
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mt-1", "data-testid": `toast-icon-${action}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconAction, {}) }),
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-start justify-start", children: [
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "font-semibold text-md", children: title }),
|
|
81
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-md text-text-900", children: description })
|
|
82
|
+
] })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
+
"button",
|
|
86
|
+
{
|
|
87
|
+
onClick: onClose,
|
|
88
|
+
"aria-label": "Dismiss notification",
|
|
89
|
+
className: "text-background-500 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
|
|
90
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_phosphor_react.X, {})
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
Toast
|
|
100
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
|
|
3
|
+
type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'default';
|
|
4
|
+
type ToastData = {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
variant?: 'solid' | 'outlined';
|
|
9
|
+
action?: 'warning' | 'success' | 'info';
|
|
10
|
+
position?: ToastPosition;
|
|
11
|
+
};
|
|
12
|
+
type ToastStore = {
|
|
13
|
+
toasts: ToastData[];
|
|
14
|
+
addToast: (toast: Omit<ToastData, 'id'>) => void;
|
|
15
|
+
removeToast: (id: string) => void;
|
|
16
|
+
};
|
|
17
|
+
declare const useToastStore: zustand.UseBoundStore<zustand.StoreApi<ToastStore>>;
|
|
18
|
+
|
|
19
|
+
export { type ToastData, useToastStore };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
|
|
3
|
+
type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'default';
|
|
4
|
+
type ToastData = {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
variant?: 'solid' | 'outlined';
|
|
9
|
+
action?: 'warning' | 'success' | 'info';
|
|
10
|
+
position?: ToastPosition;
|
|
11
|
+
};
|
|
12
|
+
type ToastStore = {
|
|
13
|
+
toasts: ToastData[];
|
|
14
|
+
addToast: (toast: Omit<ToastData, 'id'>) => void;
|
|
15
|
+
removeToast: (id: string) => void;
|
|
16
|
+
};
|
|
17
|
+
declare const useToastStore: zustand.UseBoundStore<zustand.StoreApi<ToastStore>>;
|
|
18
|
+
|
|
19
|
+
export { type ToastData, useToastStore };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/Toast/utils/ToastStore.ts
|
|
21
|
+
var ToastStore_exports = {};
|
|
22
|
+
__export(ToastStore_exports, {
|
|
23
|
+
useToastStore: () => useToastStore
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ToastStore_exports);
|
|
26
|
+
var import_zustand = require("zustand");
|
|
27
|
+
var useToastStore = (0, import_zustand.create)((set) => ({
|
|
28
|
+
toasts: [],
|
|
29
|
+
addToast: (toast) => {
|
|
30
|
+
const id = crypto.randomUUID();
|
|
31
|
+
set((state) => ({
|
|
32
|
+
toasts: [...state.toasts, { id, ...toast }]
|
|
33
|
+
}));
|
|
34
|
+
},
|
|
35
|
+
removeToast: (id) => {
|
|
36
|
+
set((state) => ({
|
|
37
|
+
toasts: state.toasts.filter((t) => t.id !== id)
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
useToastStore
|
|
44
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ToastData } from './ToastStore.mjs';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import 'zustand';
|
|
4
|
+
|
|
5
|
+
declare const Toaster: () => react_jsx_runtime.JSX.Element;
|
|
6
|
+
declare const useToast: () => {
|
|
7
|
+
addToast: (toast: Omit<ToastData, "id">) => void;
|
|
8
|
+
removeToast: (id: string) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { Toaster, useToast };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ToastData } from './ToastStore.js';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import 'zustand';
|
|
4
|
+
|
|
5
|
+
declare const Toaster: () => react_jsx_runtime.JSX.Element;
|
|
6
|
+
declare const useToast: () => {
|
|
7
|
+
addToast: (toast: Omit<ToastData, "id">) => void;
|
|
8
|
+
removeToast: (id: string) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { Toaster, useToast };
|