analytica-frontend-lib 1.1.93 → 1.1.95
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/BreadcrumbMenu/breadcrumbStore/index.d.mts +77 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.d.ts +77 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.js +146 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.js.map +1 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.mjs +120 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.mjs.map +1 -0
- package/dist/BreadcrumbMenu/index.d.mts +31 -0
- package/dist/BreadcrumbMenu/index.d.ts +31 -0
- package/dist/BreadcrumbMenu/index.js +308 -0
- package/dist/BreadcrumbMenu/index.js.map +1 -0
- package/dist/BreadcrumbMenu/index.mjs +289 -0
- package/dist/BreadcrumbMenu/index.mjs.map +1 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.d.mts +48 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.d.ts +48 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.js +189 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.js.map +1 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.mjs +164 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.mjs.map +1 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.d.mts +28 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.d.ts +28 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.js +43 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.js.map +1 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.mjs +18 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.mjs.map +1 -0
- package/dist/StatisticsCard/index.d.mts +77 -0
- package/dist/StatisticsCard/index.d.ts +77 -0
- package/dist/StatisticsCard/index.js +608 -0
- package/dist/StatisticsCard/index.js.map +1 -0
- package/dist/StatisticsCard/index.mjs +589 -0
- package/dist/StatisticsCard/index.mjs.map +1 -0
- package/dist/index.css +41 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +699 -354
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +679 -339
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +41 -0
- package/dist/styles.css.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
// src/utils/utils.ts
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
function cn(...inputs) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/components/Text/Text.tsx
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var Text = ({
|
|
11
|
+
children,
|
|
12
|
+
size = "md",
|
|
13
|
+
weight = "normal",
|
|
14
|
+
color = "text-text-950",
|
|
15
|
+
as,
|
|
16
|
+
className = "",
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
let sizeClasses = "";
|
|
20
|
+
let weightClasses = "";
|
|
21
|
+
const sizeClassMap = {
|
|
22
|
+
"2xs": "text-2xs",
|
|
23
|
+
xs: "text-xs",
|
|
24
|
+
sm: "text-sm",
|
|
25
|
+
md: "text-md",
|
|
26
|
+
lg: "text-lg",
|
|
27
|
+
xl: "text-xl",
|
|
28
|
+
"2xl": "text-2xl",
|
|
29
|
+
"3xl": "text-3xl",
|
|
30
|
+
"4xl": "text-4xl",
|
|
31
|
+
"5xl": "text-5xl",
|
|
32
|
+
"6xl": "text-6xl"
|
|
33
|
+
};
|
|
34
|
+
sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
|
|
35
|
+
const weightClassMap = {
|
|
36
|
+
hairline: "font-hairline",
|
|
37
|
+
light: "font-light",
|
|
38
|
+
normal: "font-normal",
|
|
39
|
+
medium: "font-medium",
|
|
40
|
+
semibold: "font-semibold",
|
|
41
|
+
bold: "font-bold",
|
|
42
|
+
extrabold: "font-extrabold",
|
|
43
|
+
black: "font-black"
|
|
44
|
+
};
|
|
45
|
+
weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
|
|
46
|
+
const baseClasses = "font-primary";
|
|
47
|
+
const Component = as ?? "p";
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
Component,
|
|
50
|
+
{
|
|
51
|
+
className: cn(baseClasses, sizeClasses, weightClasses, color, className),
|
|
52
|
+
...props,
|
|
53
|
+
children
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
var Text_default = Text;
|
|
58
|
+
|
|
59
|
+
// src/components/Button/Button.tsx
|
|
60
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
61
|
+
var VARIANT_ACTION_CLASSES = {
|
|
62
|
+
solid: {
|
|
63
|
+
primary: "bg-primary-950 text-text border border-primary-950 hover:bg-primary-800 hover:border-primary-800 focus-visible:outline-none focus-visible:bg-primary-950 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-primary-700 active:border-primary-700 disabled:bg-primary-500 disabled:border-primary-500 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
64
|
+
positive: "bg-success-500 text-text border border-success-500 hover:bg-success-600 hover:border-success-600 focus-visible:outline-none focus-visible:bg-success-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-success-700 active:border-success-700 disabled:bg-success-500 disabled:border-success-500 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
65
|
+
negative: "bg-error-500 text-text border border-error-500 hover:bg-error-600 hover:border-error-600 focus-visible:outline-none focus-visible:bg-error-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-error-700 active:border-error-700 disabled:bg-error-500 disabled:border-error-500 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
66
|
+
},
|
|
67
|
+
outline: {
|
|
68
|
+
primary: "bg-transparent text-primary-950 border border-primary-950 hover:bg-background-50 hover:text-primary-400 hover:border-primary-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 active:border-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
69
|
+
positive: "bg-transparent text-success-500 border border-success-300 hover:bg-background-50 hover:text-success-400 hover:border-success-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 active:border-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
70
|
+
negative: "bg-transparent text-error-500 border border-error-300 hover:bg-background-50 hover:text-error-400 hover:border-error-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 active:border-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
71
|
+
},
|
|
72
|
+
link: {
|
|
73
|
+
primary: "bg-transparent text-primary-950 hover:text-primary-400 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
74
|
+
positive: "bg-transparent text-success-500 hover:text-success-400 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
75
|
+
negative: "bg-transparent text-error-500 hover:text-error-400 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var SIZE_CLASSES = {
|
|
79
|
+
"extra-small": "text-xs px-3.5 py-2",
|
|
80
|
+
small: "text-sm px-4 py-2.5",
|
|
81
|
+
medium: "text-md px-5 py-2.5",
|
|
82
|
+
large: "text-lg px-6 py-3",
|
|
83
|
+
"extra-large": "text-lg px-7 py-3.5"
|
|
84
|
+
};
|
|
85
|
+
var Button = ({
|
|
86
|
+
children,
|
|
87
|
+
iconLeft,
|
|
88
|
+
iconRight,
|
|
89
|
+
size = "medium",
|
|
90
|
+
variant = "solid",
|
|
91
|
+
action = "primary",
|
|
92
|
+
className = "",
|
|
93
|
+
disabled,
|
|
94
|
+
type = "button",
|
|
95
|
+
...props
|
|
96
|
+
}) => {
|
|
97
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
98
|
+
const variantClasses = VARIANT_ACTION_CLASSES[variant][action];
|
|
99
|
+
const baseClasses = "inline-flex items-center justify-center rounded-full cursor-pointer font-medium";
|
|
100
|
+
return /* @__PURE__ */ jsxs(
|
|
101
|
+
"button",
|
|
102
|
+
{
|
|
103
|
+
className: cn(baseClasses, variantClasses, sizeClasses, className),
|
|
104
|
+
disabled,
|
|
105
|
+
type,
|
|
106
|
+
...props,
|
|
107
|
+
children: [
|
|
108
|
+
iconLeft && /* @__PURE__ */ jsx2("span", { className: "mr-2 flex items-center", children: iconLeft }),
|
|
109
|
+
children,
|
|
110
|
+
iconRight && /* @__PURE__ */ jsx2("span", { className: "ml-2 flex items-center", children: iconRight })
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
var Button_default = Button;
|
|
116
|
+
|
|
117
|
+
// src/components/Select/Select.tsx
|
|
118
|
+
import { create, useStore } from "zustand";
|
|
119
|
+
import {
|
|
120
|
+
useEffect,
|
|
121
|
+
useRef,
|
|
122
|
+
forwardRef,
|
|
123
|
+
isValidElement,
|
|
124
|
+
Children,
|
|
125
|
+
cloneElement,
|
|
126
|
+
useId
|
|
127
|
+
} from "react";
|
|
128
|
+
import { CaretDown, Check, WarningCircle } from "phosphor-react";
|
|
129
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
130
|
+
var VARIANT_CLASSES = {
|
|
131
|
+
outlined: "border-2 rounded-lg focus:border-primary-950",
|
|
132
|
+
underlined: "border-b-2 focus:border-primary-950",
|
|
133
|
+
rounded: "border-2 rounded-full focus:border-primary-950"
|
|
134
|
+
};
|
|
135
|
+
var SIZE_CLASSES2 = {
|
|
136
|
+
small: "text-sm",
|
|
137
|
+
medium: "text-md",
|
|
138
|
+
large: "text-lg",
|
|
139
|
+
"extra-large": "text-lg"
|
|
140
|
+
};
|
|
141
|
+
var HEIGHT_CLASSES = {
|
|
142
|
+
small: "h-8",
|
|
143
|
+
medium: "h-9",
|
|
144
|
+
large: "h-10",
|
|
145
|
+
"extra-large": "h-12"
|
|
146
|
+
};
|
|
147
|
+
var PADDING_CLASSES = {
|
|
148
|
+
small: "px-2 py-1",
|
|
149
|
+
medium: "px-3 py-2",
|
|
150
|
+
large: "px-4 py-3",
|
|
151
|
+
"extra-large": "px-5 py-4"
|
|
152
|
+
};
|
|
153
|
+
var SIDE_CLASSES = {
|
|
154
|
+
top: "bottom-full -translate-y-1",
|
|
155
|
+
right: "top-full translate-y-1",
|
|
156
|
+
bottom: "top-full translate-y-1",
|
|
157
|
+
left: "top-full translate-y-1"
|
|
158
|
+
};
|
|
159
|
+
var ALIGN_CLASSES = {
|
|
160
|
+
start: "left-0",
|
|
161
|
+
center: "left-1/2 -translate-x-1/2",
|
|
162
|
+
end: "right-0"
|
|
163
|
+
};
|
|
164
|
+
function createSelectStore(onValueChange) {
|
|
165
|
+
return create((set) => ({
|
|
166
|
+
open: false,
|
|
167
|
+
setOpen: (open) => set({ open }),
|
|
168
|
+
value: "",
|
|
169
|
+
setValue: (value) => set({ value }),
|
|
170
|
+
selectedLabel: "",
|
|
171
|
+
setSelectedLabel: (label) => set({ selectedLabel: label }),
|
|
172
|
+
onValueChange
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
var useSelectStore = (externalStore) => {
|
|
176
|
+
if (!externalStore) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
"Component must be used within a Select (store is missing)"
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return externalStore;
|
|
182
|
+
};
|
|
183
|
+
function getLabelAsNode(children) {
|
|
184
|
+
if (typeof children === "string" || typeof children === "number") {
|
|
185
|
+
return children;
|
|
186
|
+
}
|
|
187
|
+
const flattened = Children.toArray(children);
|
|
188
|
+
if (flattened.length === 1) return flattened[0];
|
|
189
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: flattened });
|
|
190
|
+
}
|
|
191
|
+
var injectStore = (children, store, size, selectId) => {
|
|
192
|
+
return Children.map(children, (child) => {
|
|
193
|
+
if (isValidElement(child)) {
|
|
194
|
+
const typedChild = child;
|
|
195
|
+
const newProps = {
|
|
196
|
+
store
|
|
197
|
+
};
|
|
198
|
+
if (typedChild.type === SelectTrigger) {
|
|
199
|
+
newProps.size = size;
|
|
200
|
+
newProps.selectId = selectId;
|
|
201
|
+
}
|
|
202
|
+
if (typedChild.props.children) {
|
|
203
|
+
newProps.children = injectStore(
|
|
204
|
+
typedChild.props.children,
|
|
205
|
+
store,
|
|
206
|
+
size,
|
|
207
|
+
selectId
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
return cloneElement(typedChild, newProps);
|
|
211
|
+
}
|
|
212
|
+
return child;
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
var Select = ({
|
|
216
|
+
children,
|
|
217
|
+
defaultValue = "",
|
|
218
|
+
className,
|
|
219
|
+
value: propValue,
|
|
220
|
+
onValueChange,
|
|
221
|
+
size = "small",
|
|
222
|
+
label,
|
|
223
|
+
helperText,
|
|
224
|
+
errorMessage,
|
|
225
|
+
id
|
|
226
|
+
}) => {
|
|
227
|
+
const storeRef = useRef(null);
|
|
228
|
+
storeRef.current ??= createSelectStore(onValueChange);
|
|
229
|
+
const store = storeRef.current;
|
|
230
|
+
const selectRef = useRef(null);
|
|
231
|
+
const { open, setOpen, setValue, selectedLabel } = useStore(store, (s) => s);
|
|
232
|
+
const generatedId = useId();
|
|
233
|
+
const selectId = id ?? `select-${generatedId}`;
|
|
234
|
+
const findLabelForValue = (children2, targetValue) => {
|
|
235
|
+
let found = null;
|
|
236
|
+
const search = (nodes) => {
|
|
237
|
+
Children.forEach(nodes, (child) => {
|
|
238
|
+
if (!isValidElement(child)) return;
|
|
239
|
+
const typedChild = child;
|
|
240
|
+
if (typedChild.type === SelectItem && typedChild.props.value === targetValue) {
|
|
241
|
+
if (typeof typedChild.props.children === "string")
|
|
242
|
+
found = typedChild.props.children;
|
|
243
|
+
}
|
|
244
|
+
if (typedChild.props.children && !found)
|
|
245
|
+
search(typedChild.props.children);
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
search(children2);
|
|
249
|
+
return found;
|
|
250
|
+
};
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
if (!selectedLabel && defaultValue) {
|
|
253
|
+
const label2 = findLabelForValue(children, defaultValue);
|
|
254
|
+
if (label2) store.setState({ selectedLabel: label2 });
|
|
255
|
+
}
|
|
256
|
+
}, [children, defaultValue, selectedLabel]);
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
const handleClickOutside = (event) => {
|
|
259
|
+
if (selectRef.current && !selectRef.current.contains(event.target)) {
|
|
260
|
+
setOpen(false);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const handleArrowKeys = (event) => {
|
|
264
|
+
const selectContent = selectRef.current?.querySelector('[role="menu"]');
|
|
265
|
+
if (selectContent) {
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
const items = Array.from(
|
|
268
|
+
selectContent.querySelectorAll(
|
|
269
|
+
'[role="menuitem"]:not([aria-disabled="true"])'
|
|
270
|
+
)
|
|
271
|
+
).filter((el) => el instanceof HTMLElement);
|
|
272
|
+
const focused = document.activeElement;
|
|
273
|
+
const currentIndex = items.findIndex((item) => item === focused);
|
|
274
|
+
let nextIndex = 0;
|
|
275
|
+
if (event.key === "ArrowDown") {
|
|
276
|
+
nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % items.length;
|
|
277
|
+
} else {
|
|
278
|
+
nextIndex = currentIndex === -1 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
|
|
279
|
+
}
|
|
280
|
+
items[nextIndex]?.focus();
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
if (open) {
|
|
284
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
285
|
+
document.addEventListener("keydown", handleArrowKeys);
|
|
286
|
+
}
|
|
287
|
+
return () => {
|
|
288
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
289
|
+
document.removeEventListener("keydown", handleArrowKeys);
|
|
290
|
+
};
|
|
291
|
+
}, [open]);
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if (propValue) {
|
|
294
|
+
setValue(propValue);
|
|
295
|
+
const label2 = findLabelForValue(children, propValue);
|
|
296
|
+
if (label2) store.setState({ selectedLabel: label2 });
|
|
297
|
+
}
|
|
298
|
+
}, [propValue]);
|
|
299
|
+
const sizeClasses = SIZE_CLASSES2[size];
|
|
300
|
+
return /* @__PURE__ */ jsxs2("div", { className: cn("w-full", className), children: [
|
|
301
|
+
label && /* @__PURE__ */ jsx3(
|
|
302
|
+
"label",
|
|
303
|
+
{
|
|
304
|
+
htmlFor: selectId,
|
|
305
|
+
className: cn("block font-bold text-text-900 mb-1.5", sizeClasses),
|
|
306
|
+
children: label
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
/* @__PURE__ */ jsx3("div", { className: cn("relative w-full"), ref: selectRef, children: injectStore(children, store, size, selectId) }),
|
|
310
|
+
(helperText || errorMessage) && /* @__PURE__ */ jsxs2("div", { className: "mt-1.5 gap-1.5", children: [
|
|
311
|
+
helperText && /* @__PURE__ */ jsx3("p", { className: "text-sm text-text-500", children: helperText }),
|
|
312
|
+
errorMessage && /* @__PURE__ */ jsxs2("p", { className: "flex gap-1 items-center text-sm text-indicator-error", children: [
|
|
313
|
+
/* @__PURE__ */ jsx3(WarningCircle, { size: 16 }),
|
|
314
|
+
" ",
|
|
315
|
+
errorMessage
|
|
316
|
+
] })
|
|
317
|
+
] })
|
|
318
|
+
] });
|
|
319
|
+
};
|
|
320
|
+
var SelectValue = ({
|
|
321
|
+
placeholder,
|
|
322
|
+
store: externalStore
|
|
323
|
+
}) => {
|
|
324
|
+
const store = useSelectStore(externalStore);
|
|
325
|
+
const selectedLabel = useStore(store, (s) => s.selectedLabel);
|
|
326
|
+
const value = useStore(store, (s) => s.value);
|
|
327
|
+
return /* @__PURE__ */ jsx3("span", { className: "text-inherit flex gap-2 items-center", children: selectedLabel || placeholder || value });
|
|
328
|
+
};
|
|
329
|
+
var SelectTrigger = forwardRef(
|
|
330
|
+
({
|
|
331
|
+
className,
|
|
332
|
+
invalid = false,
|
|
333
|
+
variant = "outlined",
|
|
334
|
+
store: externalStore,
|
|
335
|
+
disabled,
|
|
336
|
+
size = "medium",
|
|
337
|
+
selectId,
|
|
338
|
+
...props
|
|
339
|
+
}, ref) => {
|
|
340
|
+
const store = useSelectStore(externalStore);
|
|
341
|
+
const open = useStore(store, (s) => s.open);
|
|
342
|
+
const toggleOpen = () => store.setState({ open: !open });
|
|
343
|
+
const variantClasses = VARIANT_CLASSES[variant];
|
|
344
|
+
const heightClasses = HEIGHT_CLASSES[size];
|
|
345
|
+
const paddingClasses = PADDING_CLASSES[size];
|
|
346
|
+
return /* @__PURE__ */ jsxs2(
|
|
347
|
+
"button",
|
|
348
|
+
{
|
|
349
|
+
ref,
|
|
350
|
+
id: selectId,
|
|
351
|
+
className: cn(
|
|
352
|
+
"flex w-full items-center justify-between border-border-300",
|
|
353
|
+
heightClasses,
|
|
354
|
+
paddingClasses,
|
|
355
|
+
invalid && `${variant == "underlined" ? "border-b-2" : "border-2"} border-indicator-error text-text-600`,
|
|
356
|
+
disabled ? "cursor-not-allowed text-text-400 pointer-events-none opacity-50" : "cursor-pointer hover:bg-background-50 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground",
|
|
357
|
+
!invalid && !disabled ? "text-text-700" : "",
|
|
358
|
+
variantClasses,
|
|
359
|
+
className
|
|
360
|
+
),
|
|
361
|
+
onClick: toggleOpen,
|
|
362
|
+
"aria-expanded": open,
|
|
363
|
+
"aria-haspopup": "listbox",
|
|
364
|
+
"aria-controls": open ? "select-content" : void 0,
|
|
365
|
+
...props,
|
|
366
|
+
children: [
|
|
367
|
+
props.children,
|
|
368
|
+
/* @__PURE__ */ jsx3(
|
|
369
|
+
CaretDown,
|
|
370
|
+
{
|
|
371
|
+
className: cn(
|
|
372
|
+
"h-[1em] w-[1em] opacity-50 transition-transform",
|
|
373
|
+
open ? "rotate-180" : ""
|
|
374
|
+
)
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
]
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
);
|
|
382
|
+
SelectTrigger.displayName = "SelectTrigger";
|
|
383
|
+
var SelectContent = forwardRef(
|
|
384
|
+
({
|
|
385
|
+
children,
|
|
386
|
+
className,
|
|
387
|
+
align = "start",
|
|
388
|
+
side = "bottom",
|
|
389
|
+
store: externalStore,
|
|
390
|
+
...props
|
|
391
|
+
}, ref) => {
|
|
392
|
+
const store = useSelectStore(externalStore);
|
|
393
|
+
const open = useStore(store, (s) => s.open);
|
|
394
|
+
if (!open) return null;
|
|
395
|
+
const getPositionClasses = () => `w-full min-w-full absolute ${SIDE_CLASSES[side]} ${ALIGN_CLASSES[align]}`;
|
|
396
|
+
return /* @__PURE__ */ jsx3(
|
|
397
|
+
"div",
|
|
398
|
+
{
|
|
399
|
+
role: "menu",
|
|
400
|
+
ref,
|
|
401
|
+
className: cn(
|
|
402
|
+
"bg-secondary z-50 min-w-[210px] max-h-[300px] overflow-y-auto overflow-x-hidden rounded-md border p-1 shadow-md border-border-100",
|
|
403
|
+
getPositionClasses(),
|
|
404
|
+
className
|
|
405
|
+
),
|
|
406
|
+
...props,
|
|
407
|
+
children
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
SelectContent.displayName = "SelectContent";
|
|
413
|
+
var SelectItem = forwardRef(
|
|
414
|
+
({
|
|
415
|
+
className,
|
|
416
|
+
children,
|
|
417
|
+
value,
|
|
418
|
+
disabled = false,
|
|
419
|
+
store: externalStore,
|
|
420
|
+
...props
|
|
421
|
+
}, ref) => {
|
|
422
|
+
const store = useSelectStore(externalStore);
|
|
423
|
+
const {
|
|
424
|
+
value: selectedValue,
|
|
425
|
+
setValue,
|
|
426
|
+
setOpen,
|
|
427
|
+
setSelectedLabel,
|
|
428
|
+
onValueChange
|
|
429
|
+
} = useStore(store, (s) => s);
|
|
430
|
+
const handleClick = (e) => {
|
|
431
|
+
const labelNode = getLabelAsNode(children);
|
|
432
|
+
if (!disabled) {
|
|
433
|
+
setValue(value);
|
|
434
|
+
setSelectedLabel(labelNode);
|
|
435
|
+
setOpen(false);
|
|
436
|
+
onValueChange?.(value);
|
|
437
|
+
}
|
|
438
|
+
props.onClick?.(e);
|
|
439
|
+
};
|
|
440
|
+
return /* @__PURE__ */ jsxs2(
|
|
441
|
+
"div",
|
|
442
|
+
{
|
|
443
|
+
role: "menuitem",
|
|
444
|
+
"aria-disabled": disabled,
|
|
445
|
+
ref,
|
|
446
|
+
className: `
|
|
447
|
+
bg-secondary focus-visible:bg-background-50
|
|
448
|
+
relative flex select-none items-center gap-2 rounded-sm p-3 outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0
|
|
449
|
+
${className}
|
|
450
|
+
${disabled ? "cursor-not-allowed text-text-400 pointer-events-none opacity-50" : "cursor-pointer hover:bg-background-50 text-text-700 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground"}
|
|
451
|
+
${selectedValue === value && "bg-background-50"}
|
|
452
|
+
`,
|
|
453
|
+
onClick: handleClick,
|
|
454
|
+
onKeyDown: (e) => {
|
|
455
|
+
if (e.key === "Enter" || e.key === " ") handleClick(e);
|
|
456
|
+
},
|
|
457
|
+
tabIndex: disabled ? -1 : 0,
|
|
458
|
+
...props,
|
|
459
|
+
children: [
|
|
460
|
+
/* @__PURE__ */ jsx3("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: selectedValue === value && /* @__PURE__ */ jsx3(Check, { className: "" }) }),
|
|
461
|
+
children
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
);
|
|
467
|
+
SelectItem.displayName = "SelectItem";
|
|
468
|
+
var Select_default = Select;
|
|
469
|
+
|
|
470
|
+
// src/components/StatisticsCard/StatisticsCard.tsx
|
|
471
|
+
import { Plus } from "phosphor-react";
|
|
472
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
473
|
+
var VARIANT_STYLES = {
|
|
474
|
+
high: "bg-success-background",
|
|
475
|
+
medium: "bg-warning-background",
|
|
476
|
+
low: "bg-error-background",
|
|
477
|
+
total: "bg-info-background"
|
|
478
|
+
};
|
|
479
|
+
var VALUE_TEXT_COLORS = {
|
|
480
|
+
high: "text-success-700",
|
|
481
|
+
medium: "text-warning-600",
|
|
482
|
+
low: "text-error-700",
|
|
483
|
+
total: "text-info-700"
|
|
484
|
+
};
|
|
485
|
+
var StatCard = ({ item }) => {
|
|
486
|
+
return /* @__PURE__ */ jsxs3(
|
|
487
|
+
"div",
|
|
488
|
+
{
|
|
489
|
+
className: `rounded-xl py-[17px] px-6 min-h-[105px] flex flex-col justify-center items-start gap-1 ${VARIANT_STYLES[item.variant]}`,
|
|
490
|
+
children: [
|
|
491
|
+
/* @__PURE__ */ jsx4(
|
|
492
|
+
Text_default,
|
|
493
|
+
{
|
|
494
|
+
size: "4xl",
|
|
495
|
+
weight: "bold",
|
|
496
|
+
className: `${VALUE_TEXT_COLORS[item.variant]} leading-[42px] tracking-[0.2px] self-stretch`,
|
|
497
|
+
children: item.value
|
|
498
|
+
}
|
|
499
|
+
),
|
|
500
|
+
/* @__PURE__ */ jsx4(
|
|
501
|
+
Text_default,
|
|
502
|
+
{
|
|
503
|
+
size: "xs",
|
|
504
|
+
weight: "bold",
|
|
505
|
+
className: "uppercase text-[8px] leading-[9px] text-text-800 self-stretch",
|
|
506
|
+
children: item.label
|
|
507
|
+
}
|
|
508
|
+
)
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
);
|
|
512
|
+
};
|
|
513
|
+
var StatisticsCard = ({
|
|
514
|
+
title,
|
|
515
|
+
data,
|
|
516
|
+
emptyStateMessage,
|
|
517
|
+
emptyStateButtonText,
|
|
518
|
+
onEmptyStateButtonClick,
|
|
519
|
+
dropdownOptions,
|
|
520
|
+
selectedDropdownValue,
|
|
521
|
+
onDropdownChange,
|
|
522
|
+
selectPlaceholder = "Selecione um per\xEDodo",
|
|
523
|
+
dropdownAriaLabel = "Filtro de per\xEDodo",
|
|
524
|
+
className = ""
|
|
525
|
+
}) => {
|
|
526
|
+
const hasData = data && data.length > 0;
|
|
527
|
+
return /* @__PURE__ */ jsxs3(
|
|
528
|
+
"div",
|
|
529
|
+
{
|
|
530
|
+
className: `bg-background rounded-xl p-4 h-auto lg:h-[185px] flex flex-col gap-2 ${className}`,
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-row justify-between items-center gap-4", children: [
|
|
533
|
+
/* @__PURE__ */ jsx4(Text_default, { as: "h3", size: "sm", weight: "medium", color: "text-text-600", children: title }),
|
|
534
|
+
dropdownOptions && dropdownOptions.length > 0 && /* @__PURE__ */ jsx4("div", { className: "w-[99px]", children: /* @__PURE__ */ jsxs3(
|
|
535
|
+
Select_default,
|
|
536
|
+
{
|
|
537
|
+
value: selectedDropdownValue,
|
|
538
|
+
onValueChange: onDropdownChange,
|
|
539
|
+
size: "medium",
|
|
540
|
+
children: [
|
|
541
|
+
/* @__PURE__ */ jsx4(
|
|
542
|
+
SelectTrigger,
|
|
543
|
+
{
|
|
544
|
+
className: "border border-border-300 rounded whitespace-nowrap",
|
|
545
|
+
"aria-label": dropdownAriaLabel,
|
|
546
|
+
children: /* @__PURE__ */ jsx4(SelectValue, { placeholder: selectPlaceholder })
|
|
547
|
+
}
|
|
548
|
+
),
|
|
549
|
+
/* @__PURE__ */ jsx4(SelectContent, { children: dropdownOptions.map((option) => /* @__PURE__ */ jsx4(SelectItem, { value: option.value, children: option.label }, option.value)) })
|
|
550
|
+
]
|
|
551
|
+
}
|
|
552
|
+
) })
|
|
553
|
+
] }),
|
|
554
|
+
hasData ? /* @__PURE__ */ jsx4("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-[13px]", children: data.map((item, index) => /* @__PURE__ */ jsx4(
|
|
555
|
+
StatCard,
|
|
556
|
+
{
|
|
557
|
+
item
|
|
558
|
+
},
|
|
559
|
+
`${item.variant}-${item.label}-${index}`
|
|
560
|
+
)) }) : /* @__PURE__ */ jsxs3("div", { className: "border border-dashed border-border-300 rounded-lg p-6 min-h-[105px] flex flex-col items-center justify-center gap-2", children: [
|
|
561
|
+
/* @__PURE__ */ jsx4(
|
|
562
|
+
Text_default,
|
|
563
|
+
{
|
|
564
|
+
size: "sm",
|
|
565
|
+
color: "text-text-600",
|
|
566
|
+
className: "text-center max-w-md",
|
|
567
|
+
children: emptyStateMessage
|
|
568
|
+
}
|
|
569
|
+
),
|
|
570
|
+
onEmptyStateButtonClick && /* @__PURE__ */ jsx4(
|
|
571
|
+
Button_default,
|
|
572
|
+
{
|
|
573
|
+
variant: "outline",
|
|
574
|
+
action: "primary",
|
|
575
|
+
size: "small",
|
|
576
|
+
onClick: onEmptyStateButtonClick,
|
|
577
|
+
iconLeft: /* @__PURE__ */ jsx4(Plus, { size: 16, weight: "bold" }),
|
|
578
|
+
children: emptyStateButtonText
|
|
579
|
+
}
|
|
580
|
+
)
|
|
581
|
+
] })
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
};
|
|
586
|
+
export {
|
|
587
|
+
StatisticsCard
|
|
588
|
+
};
|
|
589
|
+
//# sourceMappingURL=index.mjs.map
|