@zelelo/iskra-ui 0.0.0-stage → 0.1.1

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/index.cjs ADDED
@@ -0,0 +1,1267 @@
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/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Accordion: () => Accordion,
24
+ AccordionContent: () => AccordionContent,
25
+ AccordionItem: () => AccordionItem,
26
+ AccordionTrigger: () => AccordionTrigger,
27
+ Alert: () => Alert,
28
+ Badge: () => Badge,
29
+ Button: () => Button,
30
+ Checkbox: () => Checkbox,
31
+ Input: () => Input,
32
+ Modal: () => Modal,
33
+ Radio: () => Radio,
34
+ RadioGroup: () => RadioGroup,
35
+ Skeleton: () => Skeleton,
36
+ Spinner: () => Spinner,
37
+ Switch: () => Switch,
38
+ Tabs: () => Tabs,
39
+ Toast: () => Toast,
40
+ ToastProvider: () => ToastProvider,
41
+ Tooltip: () => Tooltip,
42
+ useToast: () => useToast
43
+ });
44
+ module.exports = __toCommonJS(index_exports);
45
+
46
+ // src/utils/utils.ts
47
+ var cx = (...classes) => classes.filter(Boolean).join(" ");
48
+ var toCss = (value) => typeof value === "number" ? `${value}px` : value;
49
+
50
+ // src/components/Accordion/context.ts
51
+ var import_react = require("react");
52
+ var AccordionContext = (0, import_react.createContext)(null);
53
+ var AccordionItemContext = (0, import_react.createContext)(null);
54
+
55
+ // src/components/Accordion/hooks/useAccordionState.ts
56
+ var import_react2 = require("react");
57
+ var useAccordionState = ({
58
+ type,
59
+ defaultValue = [],
60
+ value: controlledValue,
61
+ onValueChange
62
+ }) => {
63
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react2.useState)(defaultValue);
64
+ const isControlled = controlledValue !== void 0;
65
+ const openValues = isControlled ? controlledValue : uncontrolledValue;
66
+ const toggleItem = (itemValue) => {
67
+ const isCurrentlyOpen = openValues.includes(itemValue);
68
+ let nextValue;
69
+ if (type === "single") {
70
+ nextValue = isCurrentlyOpen ? [] : [itemValue];
71
+ } else {
72
+ nextValue = isCurrentlyOpen ? openValues.filter((v) => v !== itemValue) : [...openValues, itemValue];
73
+ }
74
+ if (!isControlled) {
75
+ setUncontrolledValue(nextValue);
76
+ }
77
+ onValueChange?.(nextValue);
78
+ };
79
+ return { openValues, toggleItem };
80
+ };
81
+
82
+ // src/components/Accordion/AccordionProvider/AccordionProvider.tsx
83
+ var import_jsx_runtime = require("react/jsx-runtime");
84
+ var AccordionProvider = ({
85
+ type = "single",
86
+ defaultValue,
87
+ value,
88
+ onValueChange,
89
+ disabled,
90
+ children
91
+ }) => {
92
+ const { openValues, toggleItem } = useAccordionState({
93
+ type,
94
+ defaultValue,
95
+ value,
96
+ onValueChange
97
+ });
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionContext.Provider, { value: { openValues, toggleItem, disabled }, children });
99
+ };
100
+
101
+ // src/components/Accordion/Accordion.module.css
102
+ var Accordion_default = {
103
+ accordion: "Accordion_accordion",
104
+ item: "Accordion_item",
105
+ disabled: "Accordion_disabled",
106
+ header: "Accordion_header",
107
+ trigger: "Accordion_trigger",
108
+ icon: "Accordion_icon",
109
+ iconOpen: "Accordion_iconOpen",
110
+ contentWrapper: "Accordion_contentWrapper",
111
+ contentWrapperOpen: "Accordion_contentWrapperOpen",
112
+ contentInner: "Accordion_contentInner"
113
+ };
114
+
115
+ // src/components/Accordion/Accordion.tsx
116
+ var import_jsx_runtime2 = require("react/jsx-runtime");
117
+ var Accordion = ({
118
+ type = "single",
119
+ defaultValue,
120
+ value,
121
+ onValueChange,
122
+ disabled,
123
+ className,
124
+ children,
125
+ ...props
126
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
127
+ AccordionProvider,
128
+ {
129
+ type,
130
+ defaultValue,
131
+ value,
132
+ onValueChange,
133
+ disabled,
134
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: cx(Accordion_default.accordion, className), ...props, children })
135
+ }
136
+ );
137
+ Accordion.displayName = "Accordion";
138
+
139
+ // src/components/Accordion/hooks/useAccordionItem.ts
140
+ var import_react3 = require("react");
141
+ var useAccordionItem = () => {
142
+ const context = (0, import_react3.useContext)(AccordionItemContext);
143
+ if (!context) {
144
+ throw new Error("useAccordionItem \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D \u0432\u043D\u0435 AccordionItem");
145
+ }
146
+ return context;
147
+ };
148
+
149
+ // src/components/Accordion/components/AccordionContent.tsx
150
+ var import_jsx_runtime3 = require("react/jsx-runtime");
151
+ var AccordionContent = ({
152
+ className,
153
+ children,
154
+ ...props
155
+ }) => {
156
+ const { isOpen, baseId } = useAccordionItem();
157
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
158
+ "div",
159
+ {
160
+ id: `content-${baseId}`,
161
+ role: "region",
162
+ "aria-labelledby": `trigger-${baseId}`,
163
+ className: cx(Accordion_default.contentWrapper, isOpen && Accordion_default.contentWrapperOpen, className),
164
+ ...props,
165
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: Accordion_default.contentInner, children })
166
+ }
167
+ );
168
+ };
169
+ AccordionContent.displayName = "AccordionContent";
170
+
171
+ // src/components/Accordion/AccordionProvider/AccordionItemProvider.tsx
172
+ var import_react5 = require("react");
173
+
174
+ // src/components/Accordion/hooks/useAccordion.ts
175
+ var import_react4 = require("react");
176
+ var useAccordion = () => {
177
+ const context = (0, import_react4.useContext)(AccordionContext);
178
+ if (!context) {
179
+ throw new Error("useAccordion \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D \u0432\u043D\u0435 Accordion");
180
+ }
181
+ return context;
182
+ };
183
+
184
+ // src/components/Accordion/AccordionProvider/AccordionItemProvider.tsx
185
+ var import_jsx_runtime4 = require("react/jsx-runtime");
186
+ var AccordionItemProvider = ({
187
+ value,
188
+ disabled: itemDisabled,
189
+ children
190
+ }) => {
191
+ const { openValues, disabled: rootDisabled } = useAccordion();
192
+ const isOpen = openValues.includes(value);
193
+ const disabled = rootDisabled || itemDisabled;
194
+ const baseId = (0, import_react5.useId)();
195
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AccordionItemContext.Provider, { value: { value, isOpen, baseId, disabled }, children });
196
+ };
197
+
198
+ // src/components/Accordion/components/AccordionItem.tsx
199
+ var import_jsx_runtime5 = require("react/jsx-runtime");
200
+ var AccordionItem = ({
201
+ value,
202
+ disabled,
203
+ className,
204
+ children,
205
+ ...props
206
+ }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AccordionItemProvider, { value, disabled, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: cx(Accordion_default.item, disabled && Accordion_default.disabled, className), ...props, children }) });
207
+
208
+ // src/components/Accordion/components/AccordionTrigger.tsx
209
+ var import_jsx_runtime6 = require("react/jsx-runtime");
210
+ var AccordionTrigger = ({
211
+ className,
212
+ children,
213
+ disabled: triggerDisabled,
214
+ ...props
215
+ }) => {
216
+ const { toggleItem } = useAccordion();
217
+ const { value, isOpen, baseId, disabled } = useAccordionItem();
218
+ const isDisabled = disabled || triggerDisabled;
219
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: Accordion_default.header, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
220
+ "button",
221
+ {
222
+ type: "button",
223
+ id: `trigger-${baseId}`,
224
+ "aria-expanded": isOpen,
225
+ "aria-controls": `content-${baseId}`,
226
+ disabled: isDisabled,
227
+ className: cx(Accordion_default.trigger, className),
228
+ onClick: () => toggleItem(value),
229
+ ...props,
230
+ children: [
231
+ children,
232
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
233
+ "svg",
234
+ {
235
+ className: cx(Accordion_default.icon, isOpen && Accordion_default.iconOpen),
236
+ width: "16",
237
+ height: "16",
238
+ viewBox: "0 0 16 16",
239
+ fill: "none",
240
+ xmlns: "http://www.w3.org/2000/svg",
241
+ "aria-hidden": "true",
242
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
243
+ "path",
244
+ {
245
+ d: "M4 6L8 10L12 6",
246
+ stroke: "currentColor",
247
+ strokeWidth: "2",
248
+ strokeLinecap: "round",
249
+ strokeLinejoin: "round"
250
+ }
251
+ )
252
+ }
253
+ )
254
+ ]
255
+ }
256
+ ) });
257
+ };
258
+ AccordionTrigger.displayName = "AccordionTrigger";
259
+
260
+ // src/components/Alert/Alert.tsx
261
+ var import_react6 = require("react");
262
+
263
+ // src/components/Alert/Alert.module.css
264
+ var Alert_default = {
265
+ alert: "Alert_alert",
266
+ content: "Alert_content",
267
+ title: "Alert_title",
268
+ description: "Alert_description",
269
+ closeButton: "Alert_closeButton",
270
+ info: "Alert_info",
271
+ success: "Alert_success",
272
+ warning: "Alert_warning",
273
+ error: "Alert_error"
274
+ };
275
+
276
+ // src/components/Alert/Alert.tsx
277
+ var import_jsx_runtime7 = require("react/jsx-runtime");
278
+ var Alert = ({
279
+ variant = "info",
280
+ title,
281
+ closable = false,
282
+ onClose,
283
+ children,
284
+ className,
285
+ ...props
286
+ }) => {
287
+ const [visible, setVisible] = (0, import_react6.useState)(true);
288
+ if (!visible) {
289
+ return null;
290
+ }
291
+ const handleClose = () => {
292
+ setVisible(false);
293
+ onClose?.();
294
+ };
295
+ const classes = cx(Alert_default.alert, Alert_default[variant], className);
296
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: classes, role: "alert", ...props, children: [
297
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: Alert_default.content, children: [
298
+ title && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: Alert_default.title, children: title }),
299
+ children && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: Alert_default.description, children })
300
+ ] }),
301
+ closable && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
302
+ "button",
303
+ {
304
+ type: "button",
305
+ className: Alert_default.closeButton,
306
+ onClick: handleClose,
307
+ "aria-label": "Close alert",
308
+ children: "\xD7"
309
+ }
310
+ )
311
+ ] });
312
+ };
313
+ Alert.displayName = "Alert";
314
+
315
+ // src/components/Badge/Badge.module.css
316
+ var Badge_default = {
317
+ badge: "Badge_badge",
318
+ count: "Badge_count",
319
+ dot: "Badge_dot",
320
+ blue: "Badge_blue",
321
+ red: "Badge_red",
322
+ green: "Badge_green"
323
+ };
324
+
325
+ // src/components/Badge/Badge.tsx
326
+ var import_jsx_runtime8 = require("react/jsx-runtime");
327
+ var formatCount = (count, max) => {
328
+ if (count > max) {
329
+ return `${max}+`;
330
+ }
331
+ return String(count);
332
+ };
333
+ var Badge = ({
334
+ color = "blue",
335
+ max = 999,
336
+ count,
337
+ className,
338
+ ...props
339
+ }) => {
340
+ const isDot = count === void 0;
341
+ const classes = cx(Badge_default.badge, isDot ? Badge_default.dot : Badge_default.count, Badge_default[color], className);
342
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: classes, ...props, children: isDot ? null : formatCount(count, max) });
343
+ };
344
+ Badge.displayName = "Badge";
345
+
346
+ // src/components/Button/Button.tsx
347
+ var import_react7 = require("react");
348
+
349
+ // src/components/Button/Button.module.css
350
+ var Button_default = {
351
+ button: "Button_button",
352
+ primary: "Button_primary",
353
+ secondary: "Button_secondary",
354
+ sm: "Button_sm",
355
+ md: "Button_md",
356
+ lg: "Button_lg"
357
+ };
358
+
359
+ // src/components/Button/Button.tsx
360
+ var import_jsx_runtime9 = require("react/jsx-runtime");
361
+ var Button = (0, import_react7.forwardRef)(
362
+ ({ variant = "primary", size = "md", type = "button", className, ...props }, ref) => {
363
+ const classes = cx(Button_default.button, Button_default[variant], Button_default[size], className);
364
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { ref, type, className: classes, ...props });
365
+ }
366
+ );
367
+ Button.displayName = "Button";
368
+
369
+ // src/components/Checkbox/Checkbox.tsx
370
+ var import_react8 = require("react");
371
+
372
+ // src/components/Checkbox/Checkbox.module.css
373
+ var Checkbox_default = {
374
+ sm: "Checkbox_sm",
375
+ md: "Checkbox_md",
376
+ lg: "Checkbox_lg",
377
+ root: "Checkbox_root",
378
+ label: "Checkbox_label",
379
+ input: "Checkbox_input",
380
+ disabled: "Checkbox_disabled",
381
+ required: "Checkbox_required",
382
+ error: "Checkbox_error"
383
+ };
384
+
385
+ // src/components/Checkbox/Checkbox.tsx
386
+ var import_jsx_runtime10 = require("react/jsx-runtime");
387
+ var Checkbox = (0, import_react8.forwardRef)(
388
+ ({
389
+ size = "md",
390
+ label,
391
+ indeterminate,
392
+ error,
393
+ className,
394
+ disabled,
395
+ required,
396
+ id,
397
+ "aria-describedby": ariaDescribedBy,
398
+ ...props
399
+ }, ref) => {
400
+ const innerRef = (0, import_react8.useRef)(null);
401
+ const autoId = (0, import_react8.useId)();
402
+ const checkboxId = id ?? autoId;
403
+ const hasError = Boolean(error);
404
+ const messageId = hasError ? `${checkboxId}-message` : void 0;
405
+ const describeBy = [ariaDescribedBy, messageId].filter(Boolean).join(" ") || void 0;
406
+ (0, import_react8.useImperativeHandle)(ref, () => innerRef.current, []);
407
+ (0, import_react8.useEffect)(() => {
408
+ if (innerRef.current) {
409
+ innerRef.current.indeterminate = Boolean(indeterminate);
410
+ }
411
+ }, [indeterminate]);
412
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: cx(Checkbox_default.root, Checkbox_default[size], disabled && Checkbox_default.disabled, className), children: [
413
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { className: Checkbox_default.label, children: [
414
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
415
+ "input",
416
+ {
417
+ id: checkboxId,
418
+ ref: innerRef,
419
+ type: "checkbox",
420
+ className: Checkbox_default.input,
421
+ disabled,
422
+ required,
423
+ "aria-invalid": hasError || void 0,
424
+ "aria-describedby": describeBy,
425
+ ...props
426
+ }
427
+ ),
428
+ label,
429
+ required && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: Checkbox_default.required, "aria-hidden": "true", children: " *" })
430
+ ] }),
431
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { id: messageId, className: Checkbox_default.error, children: error })
432
+ ] });
433
+ }
434
+ );
435
+ Checkbox.displayName = "Checkbox";
436
+
437
+ // src/components/Input/Input.tsx
438
+ var import_react9 = require("react");
439
+
440
+ // src/components/Input/Input.module.css
441
+ var Input_default = {
442
+ sm: "Input_sm",
443
+ md: "Input_md",
444
+ lg: "Input_lg",
445
+ root: "Input_root",
446
+ label: "Input_label",
447
+ required: "Input_required",
448
+ field: "Input_field",
449
+ disabled: "Input_disabled",
450
+ invalid: "Input_invalid",
451
+ input: "Input_input",
452
+ icon: "Input_icon",
453
+ message: "Input_message",
454
+ error: "Input_error"
455
+ };
456
+
457
+ // src/components/Input/Input.tsx
458
+ var import_jsx_runtime11 = require("react/jsx-runtime");
459
+ var Input = (0, import_react9.forwardRef)(
460
+ ({
461
+ size = "md",
462
+ label,
463
+ hint,
464
+ error,
465
+ startIcon,
466
+ endIcon,
467
+ className,
468
+ id,
469
+ required,
470
+ disabled,
471
+ "aria-describedby": ariaDescribedBy,
472
+ ...props
473
+ }, ref) => {
474
+ const autoId = (0, import_react9.useId)();
475
+ const inputId = id ?? autoId;
476
+ const hasError = Boolean(error);
477
+ const message = hasError ? error : hint;
478
+ const messageId = message ? `${inputId}-message` : void 0;
479
+ const describeBy = [ariaDescribedBy, messageId].filter(Boolean).join(" ") || void 0;
480
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cx(Input_default.root, Input_default[size], className), children: [
481
+ label && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { htmlFor: inputId, className: Input_default.label, children: [
482
+ label,
483
+ " ",
484
+ required && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: Input_default.required, "aria-hidden": "true", children: " *" })
485
+ ] }),
486
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cx(Input_default.field, hasError && Input_default.invalid, disabled && Input_default.disabled), children: [
487
+ startIcon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: Input_default.icon, children: startIcon }),
488
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
489
+ "input",
490
+ {
491
+ ref,
492
+ id: inputId,
493
+ required,
494
+ disabled,
495
+ "aria-invalid": hasError || void 0,
496
+ "aria-describedby": describeBy,
497
+ className: Input_default.input,
498
+ ...props
499
+ }
500
+ ),
501
+ endIcon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: Input_default.icon, children: endIcon })
502
+ ] }),
503
+ message && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { id: messageId, className: cx(Input_default.message, hasError && Input_default.error), children: message })
504
+ ] });
505
+ }
506
+ );
507
+ Input.displayName = "Input";
508
+
509
+ // src/components/Modal/Modal.tsx
510
+ var import_react10 = require("react");
511
+
512
+ // src/components/Modal/Modal.module.css
513
+ var Modal_default = {
514
+ modal: "Modal_modal",
515
+ "modal-in": "Modal_modal-in",
516
+ "fade-in": "Modal_fade-in",
517
+ sm: "Modal_sm",
518
+ md: "Modal_md",
519
+ lg: "Modal_lg",
520
+ content: "Modal_content",
521
+ header: "Modal_header",
522
+ title: "Modal_title",
523
+ close: "Modal_close",
524
+ body: "Modal_body",
525
+ footer: "Modal_footer"
526
+ };
527
+
528
+ // src/components/Modal/Modal.tsx
529
+ var import_jsx_runtime12 = require("react/jsx-runtime");
530
+ var Modal = ({
531
+ open,
532
+ onClose,
533
+ title,
534
+ footer,
535
+ size = "md",
536
+ width,
537
+ children
538
+ }) => {
539
+ const ref = (0, import_react10.useRef)(null);
540
+ const titleId = (0, import_react10.useId)();
541
+ (0, import_react10.useEffect)(() => {
542
+ if (open) {
543
+ ref.current?.showModal();
544
+ } else {
545
+ ref.current?.close();
546
+ }
547
+ }, [open]);
548
+ const close = () => ref.current?.close();
549
+ return (
550
+ // Escape у <dialog> уже закрывает модалку с клавиатуры
551
+ // oxlint-disable-next-line jsx-a11y/click-events-have-key-events jsx-a11y/no-noninteractive-element-interactions
552
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
553
+ "dialog",
554
+ {
555
+ ref,
556
+ className: cx(Modal_default.modal, Modal_default[size]),
557
+ style: { maxWidth: toCss(width) },
558
+ "aria-labelledby": title ? titleId : void 0,
559
+ onClose,
560
+ onClick: (e) => e.target === e.currentTarget && close(),
561
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: Modal_default.content, children: [
562
+ title && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("header", { className: Modal_default.header, children: [
563
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { id: titleId, className: Modal_default.title, children: title }),
564
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: Modal_default.close, "aria-label": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C", onClick: close, children: "\xD7" })
565
+ ] }),
566
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: Modal_default.body, children }),
567
+ footer && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("footer", { className: Modal_default.footer, children: footer })
568
+ ] })
569
+ }
570
+ )
571
+ );
572
+ };
573
+ Modal.displayName = "Modal";
574
+
575
+ // src/components/Radio/Radio.tsx
576
+ var import_react12 = require("react");
577
+
578
+ // src/components/RadioGroup/RadioGroupProvider/context.ts
579
+ var import_react11 = require("react");
580
+ var RadioGroupContext = (0, import_react11.createContext)(null);
581
+
582
+ // src/components/Radio/Radio.module.css
583
+ var Radio_default = {
584
+ sm: "Radio_sm",
585
+ md: "Radio_md",
586
+ lg: "Radio_lg",
587
+ root: "Radio_root",
588
+ label: "Radio_label",
589
+ input: "Radio_input",
590
+ hasError: "Radio_hasError",
591
+ disabled: "Radio_disabled",
592
+ required: "Radio_required",
593
+ error: "Radio_error"
594
+ };
595
+
596
+ // src/components/Radio/Radio.tsx
597
+ var import_jsx_runtime13 = require("react/jsx-runtime");
598
+ var Radio = (0, import_react12.forwardRef)(
599
+ ({
600
+ size = "md",
601
+ label,
602
+ error,
603
+ className,
604
+ disabled,
605
+ required,
606
+ id,
607
+ name,
608
+ value,
609
+ checked,
610
+ onChange,
611
+ "aria-describedby": ariaDescribedBy,
612
+ ...props
613
+ }, ref) => {
614
+ const group = (0, import_react12.useContext)(RadioGroupContext);
615
+ const autoId = (0, import_react12.useId)();
616
+ const radioId = id ?? autoId;
617
+ const hasError = Boolean(error);
618
+ const messageId = hasError ? `${radioId}-message` : void 0;
619
+ const describeBy = [ariaDescribedBy, messageId].filter(Boolean).join(" ") || void 0;
620
+ const inputName = group ? group.name : name;
621
+ const isChecked = group ? group.value === String(value) : checked;
622
+ const isDisabled = group?.disabled || disabled;
623
+ const isRequired = group ? group.required : required;
624
+ const handleChange = (event) => {
625
+ onChange?.(event);
626
+ group?.onChange(event.target.value);
627
+ };
628
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
629
+ "div",
630
+ {
631
+ className: cx(
632
+ Radio_default.root,
633
+ Radio_default[size],
634
+ disabled && Radio_default.disabled,
635
+ hasError && Radio_default.hasError,
636
+ className
637
+ ),
638
+ children: [
639
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: Radio_default.label, children: [
640
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
641
+ "input",
642
+ {
643
+ ref,
644
+ id: radioId,
645
+ name: inputName,
646
+ type: "radio",
647
+ value,
648
+ checked: isChecked,
649
+ onChange: handleChange,
650
+ className: Radio_default.input,
651
+ disabled: isDisabled,
652
+ required: isRequired,
653
+ "aria-describedby": describeBy,
654
+ ...props
655
+ }
656
+ ),
657
+ label,
658
+ required && !group && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: Radio_default.required, "aria-hidden": "true", children: " *" })
659
+ ] }),
660
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { id: messageId, className: Radio_default.error, children: error })
661
+ ]
662
+ }
663
+ );
664
+ }
665
+ );
666
+ Radio.displayName = "Radio";
667
+
668
+ // src/components/RadioGroup/RadioGroup.tsx
669
+ var import_react14 = require("react");
670
+
671
+ // src/components/RadioGroup/RadioGroupProvider/RadioGroupProvider.tsx
672
+ var import_react13 = require("react");
673
+ var import_jsx_runtime14 = require("react/jsx-runtime");
674
+ var RadioGroupProvider = ({
675
+ name,
676
+ value: controlledValue,
677
+ defaultValue,
678
+ onChange,
679
+ disabled,
680
+ required,
681
+ children
682
+ }) => {
683
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react13.useState)(defaultValue);
684
+ const isControlled = controlledValue !== void 0;
685
+ const currentValue = isControlled ? controlledValue : uncontrolledValue;
686
+ const autoId = (0, import_react13.useId)();
687
+ const finalName = name ?? `radiogroup-${autoId}`;
688
+ const handleChange = (newValue) => {
689
+ if (!isControlled) {
690
+ setUncontrolledValue(newValue);
691
+ }
692
+ onChange?.(newValue);
693
+ };
694
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
695
+ RadioGroupContext.Provider,
696
+ {
697
+ value: {
698
+ name: finalName,
699
+ value: currentValue,
700
+ onChange: handleChange,
701
+ disabled,
702
+ required
703
+ },
704
+ children
705
+ }
706
+ );
707
+ };
708
+
709
+ // src/components/RadioGroup/RadioGroup.module.css
710
+ var RadioGroup_default = {
711
+ root: "RadioGroup_root",
712
+ disabled: "RadioGroup_disabled",
713
+ groupLabel: "RadioGroup_groupLabel",
714
+ required: "RadioGroup_required",
715
+ options: "RadioGroup_options",
716
+ error: "RadioGroup_error"
717
+ };
718
+
719
+ // src/components/RadioGroup/RadioGroup.tsx
720
+ var import_jsx_runtime15 = require("react/jsx-runtime");
721
+ var RadioGroup = ({
722
+ value,
723
+ defaultValue,
724
+ onChange,
725
+ name,
726
+ label,
727
+ error,
728
+ required,
729
+ disabled,
730
+ className,
731
+ children,
732
+ ...props
733
+ }) => {
734
+ const labelId = (0, import_react14.useId)();
735
+ const messageId = (0, import_react14.useId)();
736
+ const hasError = Boolean(error);
737
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
738
+ RadioGroupProvider,
739
+ {
740
+ name,
741
+ value,
742
+ defaultValue,
743
+ onChange,
744
+ disabled,
745
+ required,
746
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
747
+ "div",
748
+ {
749
+ className: cx(RadioGroup_default.root, disabled && RadioGroup_default.disabled, className),
750
+ role: "radiogroup",
751
+ "aria-labelledby": label ? labelId : void 0,
752
+ "aria-invalid": hasError || void 0,
753
+ "aria-describedby": hasError ? messageId : void 0,
754
+ "aria-required": required || void 0,
755
+ ...props,
756
+ children: [
757
+ label && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { id: labelId, className: RadioGroup_default.groupLabel, children: [
758
+ label,
759
+ required && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: RadioGroup_default.required, "aria-hidden": "true", children: " *" })
760
+ ] }),
761
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: RadioGroup_default.options, children }),
762
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { id: messageId, className: RadioGroup_default.error, children: error })
763
+ ]
764
+ }
765
+ )
766
+ }
767
+ );
768
+ };
769
+ RadioGroup.displayName = "RadioGroup";
770
+
771
+ // src/components/Skeleton/Skeleton.module.css
772
+ var Skeleton_default = {
773
+ skeleton: "Skeleton_skeleton",
774
+ text: "Skeleton_text",
775
+ rect: "Skeleton_rect",
776
+ circle: "Skeleton_circle",
777
+ lines: "Skeleton_lines",
778
+ withChildren: "Skeleton_withChildren",
779
+ hidden: "Skeleton_hidden",
780
+ pulse: "Skeleton_pulse",
781
+ wave: "Skeleton_wave"
782
+ };
783
+
784
+ // src/components/Skeleton/Skeleton.tsx
785
+ var import_jsx_runtime16 = require("react/jsx-runtime");
786
+ var Skeleton = ({
787
+ variant = "text",
788
+ width,
789
+ height,
790
+ radius,
791
+ lines = 1,
792
+ animation = "pulse",
793
+ loading = true,
794
+ className,
795
+ style,
796
+ children,
797
+ ...props
798
+ }) => {
799
+ if (!loading) {
800
+ return children;
801
+ }
802
+ const baseClasses = cx(Skeleton_default.skeleton, Skeleton_default[variant], Skeleton_default[animation]);
803
+ const sizeStyle = {
804
+ width: toCss(width),
805
+ height: toCss(variant === "circle" ? height ?? width : height),
806
+ borderRadius: toCss(radius)
807
+ };
808
+ if (variant === "text" && lines > 1) {
809
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
810
+ "span",
811
+ {
812
+ className: cx(Skeleton_default.lines, className),
813
+ style: { width: sizeStyle.width, ...style },
814
+ "aria-hidden": "true",
815
+ ...props,
816
+ children: Array.from({ length: lines }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
817
+ "span",
818
+ {
819
+ className: baseClasses,
820
+ style: { ...sizeStyle, width: i === lines - 1 ? "70%" : "100%" }
821
+ },
822
+ i
823
+ ))
824
+ }
825
+ );
826
+ }
827
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
828
+ "span",
829
+ {
830
+ className: cx(baseClasses, children != null && Skeleton_default.withChildren, className),
831
+ style: { ...sizeStyle, ...style },
832
+ "aria-hidden": "true",
833
+ ...props,
834
+ children: children != null && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: Skeleton_default.hidden, children })
835
+ }
836
+ );
837
+ };
838
+ Skeleton.displayName = "Skeleton";
839
+
840
+ // src/components/Spinner/constants.ts
841
+ var SPINNER_VARIANTS = {
842
+ circle: { items: 0 },
843
+ dots: { items: 3 },
844
+ spiral: { items: 5 },
845
+ propagate: { items: 6 }
846
+ };
847
+
848
+ // src/components/Spinner/Spinner.module.css
849
+ var Spinner_default = {
850
+ spinner: "Spinner_spinner",
851
+ sm: "Spinner_sm",
852
+ md: "Spinner_md",
853
+ lg: "Spinner_lg",
854
+ item: "Spinner_item",
855
+ circle: "Spinner_circle",
856
+ spin: "Spinner_spin",
857
+ dots: "Spinner_dots",
858
+ beat: "Spinner_beat",
859
+ spiral: "Spinner_spiral",
860
+ propagate: "Spinner_propagate"
861
+ };
862
+
863
+ // src/components/Spinner/Spinner.tsx
864
+ var import_jsx_runtime17 = require("react/jsx-runtime");
865
+ var Spinner = ({
866
+ variant = "circle",
867
+ size = "md",
868
+ label = "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430",
869
+ color,
870
+ className,
871
+ style,
872
+ ...props
873
+ }) => {
874
+ const { items } = SPINNER_VARIANTS[variant];
875
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
876
+ "span",
877
+ {
878
+ role: "status",
879
+ "aria-label": label,
880
+ className: cx(Spinner_default.spinner, Spinner_default[variant], Spinner_default[size], className),
881
+ style: { ...style, ...color && { color } },
882
+ ...props,
883
+ children: Array.from({ length: items }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: Spinner_default.item, style: { "--i": i } }, i))
884
+ }
885
+ );
886
+ };
887
+ Spinner.displayName = "Spinner";
888
+
889
+ // src/components/Switch/Switch.tsx
890
+ var import_react15 = require("react");
891
+
892
+ // src/components/Switch/Switch.module.css
893
+ var Switch_default = {
894
+ sm: "Switch_sm",
895
+ md: "Switch_md",
896
+ lg: "Switch_lg",
897
+ root: "Switch_root",
898
+ input: "Switch_input",
899
+ track: "Switch_track",
900
+ thumb: "Switch_thumb",
901
+ disabled: "Switch_disabled"
902
+ };
903
+
904
+ // src/components/Switch/Switch.tsx
905
+ var import_jsx_runtime18 = require("react/jsx-runtime");
906
+ var Switch = (0, import_react15.forwardRef)(
907
+ ({ size = "md", label, className, disabled, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: cx(Switch_default.root, Switch_default[size], disabled && Switch_default.disabled, className), children: [
908
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
909
+ "input",
910
+ {
911
+ ref,
912
+ "aria-checked": true,
913
+ type: "checkbox",
914
+ role: "switch",
915
+ disabled,
916
+ className: Switch_default.input,
917
+ ...props
918
+ }
919
+ ),
920
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: Switch_default.track, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: Switch_default.thumb }) }),
921
+ label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: Switch_default.label, children: label })
922
+ ] })
923
+ );
924
+
925
+ // src/components/Tabs/Tabs.tsx
926
+ var import_react16 = require("react");
927
+
928
+ // src/components/Tabs/Tabs.module.css
929
+ var Tabs_default = {
930
+ tabs: "Tabs_tabs",
931
+ list: "Tabs_list",
932
+ tab: "Tabs_tab",
933
+ panel: "Tabs_panel"
934
+ };
935
+
936
+ // src/components/Tabs/Tabs.tsx
937
+ var import_jsx_runtime19 = require("react/jsx-runtime");
938
+ var Tabs = ({ items, defaultValue, onChange, className }) => {
939
+ const [active, setActive] = (0, import_react16.useState)(() => {
940
+ const isSelectable = items.some((item) => item.value === defaultValue && !item.disabled);
941
+ return isSelectable ? defaultValue : items.find((item) => !item.disabled)?.value;
942
+ });
943
+ const id = (0, import_react16.useId)();
944
+ const tabRefs = (0, import_react16.useRef)([]);
945
+ const activeIndex = items.findIndex((item) => item.value === active);
946
+ const select = (value) => {
947
+ if (value === active) return;
948
+ setActive(value);
949
+ onChange?.(value);
950
+ };
951
+ const handleKeyDown = (event, index) => {
952
+ const enabled = items.flatMap((item, i) => item.disabled ? [] : [i]);
953
+ const position = enabled.indexOf(index);
954
+ let next;
955
+ switch (event.key) {
956
+ case "ArrowRight":
957
+ next = enabled[(position + 1) % enabled.length];
958
+ break;
959
+ case "ArrowLeft":
960
+ next = enabled[(position - 1 + enabled.length) % enabled.length];
961
+ break;
962
+ case "Home":
963
+ next = enabled[0];
964
+ break;
965
+ case "End":
966
+ next = enabled[enabled.length - 1];
967
+ break;
968
+ default:
969
+ return;
970
+ }
971
+ event.preventDefault();
972
+ tabRefs.current[next]?.focus();
973
+ select(items[next].value);
974
+ };
975
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: cx(Tabs_default.tabs, className), children: [
976
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "tablist", className: Tabs_default.list, children: items.map((item, index) => {
977
+ const selected = index === activeIndex;
978
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
979
+ "button",
980
+ {
981
+ ref: (el) => {
982
+ tabRefs.current[index] = el;
983
+ },
984
+ type: "button",
985
+ role: "tab",
986
+ id: `${id}-tab-${index}`,
987
+ "aria-selected": selected,
988
+ "aria-controls": `${id}-panel`,
989
+ tabIndex: selected ? 0 : -1,
990
+ disabled: item.disabled,
991
+ className: Tabs_default.tab,
992
+ onClick: () => select(item.value),
993
+ onKeyDown: (event) => handleKeyDown(event, index),
994
+ children: item.label
995
+ },
996
+ item.value
997
+ );
998
+ }) }),
999
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1000
+ "div",
1001
+ {
1002
+ role: "tabpanel",
1003
+ id: `${id}-panel`,
1004
+ "aria-labelledby": activeIndex >= 0 ? `${id}-tab-${activeIndex}` : void 0,
1005
+ tabIndex: 0,
1006
+ className: Tabs_default.panel,
1007
+ children: items[activeIndex]?.content
1008
+ }
1009
+ )
1010
+ ] });
1011
+ };
1012
+ Tabs.displayName = "Tabs";
1013
+
1014
+ // src/components/Toast/Toast.tsx
1015
+ var import_react17 = require("react");
1016
+
1017
+ // src/components/Toast/Toast.module.css
1018
+ var Toast_default = {
1019
+ toast: "Toast_toast",
1020
+ "toast-in": "Toast_toast-in",
1021
+ content: "Toast_content",
1022
+ title: "Toast_title",
1023
+ description: "Toast_description",
1024
+ closeButton: "Toast_closeButton",
1025
+ info: "Toast_info",
1026
+ success: "Toast_success",
1027
+ warning: "Toast_warning",
1028
+ error: "Toast_error"
1029
+ };
1030
+
1031
+ // src/components/Toast/Toast.tsx
1032
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1033
+ var Toast = ({
1034
+ variant = "info",
1035
+ title,
1036
+ closable = true,
1037
+ duration = 5e3,
1038
+ onClose,
1039
+ children,
1040
+ className,
1041
+ onMouseEnter,
1042
+ onMouseLeave,
1043
+ ...props
1044
+ }) => {
1045
+ const [visible, setVisible] = (0, import_react17.useState)(true);
1046
+ const timerRef = (0, import_react17.useRef)();
1047
+ const remainingRef = (0, import_react17.useRef)(duration);
1048
+ const startedAtRef = (0, import_react17.useRef)(0);
1049
+ const onCloseRef = (0, import_react17.useRef)(onClose);
1050
+ (0, import_react17.useEffect)(() => {
1051
+ onCloseRef.current = onClose;
1052
+ }, [onClose]);
1053
+ const handleClose = (0, import_react17.useCallback)(() => {
1054
+ setVisible(false);
1055
+ onCloseRef.current?.();
1056
+ }, []);
1057
+ const clearTimer = (0, import_react17.useCallback)(() => {
1058
+ if (timerRef.current) {
1059
+ clearTimeout(timerRef.current);
1060
+ timerRef.current = void 0;
1061
+ }
1062
+ }, []);
1063
+ const startTimer = (0, import_react17.useCallback)(
1064
+ (ms) => {
1065
+ if (ms <= 0) return;
1066
+ startedAtRef.current = Date.now();
1067
+ timerRef.current = setTimeout(handleClose, ms);
1068
+ },
1069
+ [handleClose]
1070
+ );
1071
+ (0, import_react17.useEffect)(() => {
1072
+ startTimer(remainingRef.current);
1073
+ return clearTimer;
1074
+ }, [startTimer, clearTimer]);
1075
+ const handleMouseEnter = (e) => {
1076
+ clearTimer();
1077
+ remainingRef.current -= Date.now() - startedAtRef.current;
1078
+ onMouseEnter?.(e);
1079
+ };
1080
+ const handleMouseLeave = (e) => {
1081
+ startTimer(remainingRef.current);
1082
+ onMouseLeave?.(e);
1083
+ };
1084
+ if (!visible) {
1085
+ return null;
1086
+ }
1087
+ const classes = cx(Toast_default.toast, Toast_default[variant], className);
1088
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1089
+ "div",
1090
+ {
1091
+ className: classes,
1092
+ onMouseEnter: handleMouseEnter,
1093
+ onMouseLeave: handleMouseLeave,
1094
+ ...props,
1095
+ children: [
1096
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: Toast_default.content, role: "status", "aria-live": "polite", children: [
1097
+ title && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: Toast_default.title, children: title }),
1098
+ children && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: Toast_default.description, children })
1099
+ ] }),
1100
+ closable && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1101
+ "button",
1102
+ {
1103
+ type: "button",
1104
+ className: Toast_default.closeButton,
1105
+ onClick: handleClose,
1106
+ "aria-label": "Close toast",
1107
+ children: "\xD7"
1108
+ }
1109
+ )
1110
+ ]
1111
+ }
1112
+ );
1113
+ };
1114
+ Toast.displayName = "Toast";
1115
+
1116
+ // src/components/Toast/ToastProvider/ToastProvider.tsx
1117
+ var import_react18 = require("react");
1118
+ var import_react_dom = require("react-dom");
1119
+
1120
+ // src/components/Toast/ToastProvider/ToastContainer.module.css
1121
+ var ToastContainer_default = {
1122
+ container: "ToastContainer_container",
1123
+ "top-right": "ToastContainer_top-right",
1124
+ "top-left": "ToastContainer_top-left",
1125
+ "top-center": "ToastContainer_top-center",
1126
+ "bottom-right": "ToastContainer_bottom-right",
1127
+ "bottom-left": "ToastContainer_bottom-left",
1128
+ "bottom-center": "ToastContainer_bottom-center"
1129
+ };
1130
+
1131
+ // src/components/Toast/ToastProvider/ToastProvider.tsx
1132
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1133
+ var idCounter = 0;
1134
+ var nextId = () => `toast-${Date.now()}-${idCounter++}`;
1135
+ var ToastContext = (0, import_react18.createContext)(null);
1136
+ var ToastProvider = ({
1137
+ children,
1138
+ position = "top-right"
1139
+ }) => {
1140
+ const [toasts, setToasts] = (0, import_react18.useState)([]);
1141
+ const close = (0, import_react18.useCallback)((id) => {
1142
+ setToasts((prev) => prev.filter((toast) => toast.id !== id));
1143
+ }, []);
1144
+ const show = (0, import_react18.useCallback)((options) => {
1145
+ const id = nextId();
1146
+ setToasts((prev) => [...prev, { id, ...options }]);
1147
+ return id;
1148
+ }, []);
1149
+ const value = (0, import_react18.useMemo)(() => {
1150
+ return { show, close };
1151
+ }, [show, close]);
1152
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ToastContext.Provider, { value, children: [
1153
+ children,
1154
+ typeof document !== "undefined" && (0, import_react_dom.createPortal)(
1155
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: cx(ToastContainer_default.container, ToastContainer_default[position]), children: toasts.map(({ id, description, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Toast, { ...rest, onClose: () => close(id), children: description }, id)) }),
1156
+ document.body
1157
+ )
1158
+ ] });
1159
+ };
1160
+
1161
+ // src/components/Toast/ToastProvider/hook/useToast.ts
1162
+ var import_react19 = require("react");
1163
+ var useToast = () => {
1164
+ const ctx = (0, import_react19.useContext)(ToastContext);
1165
+ if (!ctx) {
1166
+ throw new Error("useToast \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D \u0432\u043D\u0435 ToastProvider");
1167
+ }
1168
+ const make = (variant) => (options = {}) => ctx.show({ variant, ...options });
1169
+ return {
1170
+ show: ctx.show,
1171
+ close: ctx.close,
1172
+ info: make("info"),
1173
+ success: make("success"),
1174
+ warning: make("warning"),
1175
+ error: make("error")
1176
+ };
1177
+ };
1178
+
1179
+ // src/components/Tooltip/Tooltip.tsx
1180
+ var import_react20 = require("react");
1181
+ var import_react21 = require("@floating-ui/react");
1182
+
1183
+ // src/components/Tooltip/Tooltip.module.css
1184
+ var Tooltip_default = {
1185
+ tooltip: "Tooltip_tooltip",
1186
+ fadeIn: "Tooltip_fadeIn",
1187
+ arrow: "Tooltip_arrow"
1188
+ };
1189
+
1190
+ // src/components/Tooltip/Tooltip.tsx
1191
+ var import_jsx_runtime22 = require("react/jsx-runtime");
1192
+ var Tooltip = ({
1193
+ content,
1194
+ children,
1195
+ placement = "top",
1196
+ delay = 200,
1197
+ className,
1198
+ ...props
1199
+ }) => {
1200
+ const [open, setOpen] = (0, import_react20.useState)(false);
1201
+ const {
1202
+ refs,
1203
+ floatingStyles,
1204
+ context,
1205
+ placement: finalPlacement
1206
+ } = (0, import_react21.useFloating)({
1207
+ open,
1208
+ onOpenChange: setOpen,
1209
+ placement,
1210
+ whileElementsMounted: import_react21.autoUpdate,
1211
+ middleware: [(0, import_react21.offset)(8), (0, import_react21.flip)(), (0, import_react21.shift)({ padding: 8 })]
1212
+ });
1213
+ const hover = (0, import_react21.useHover)(context, { delay: { open: delay, close: 0 } });
1214
+ const focus = (0, import_react21.useFocus)(context);
1215
+ const role = (0, import_react21.useRole)(context, { role: "tooltip" });
1216
+ const { getReferenceProps, getFloatingProps } = (0, import_react21.useInteractions)([hover, focus, role]);
1217
+ const childRef = (0, import_react20.isValidElement)(children) ? children.props?.ref ?? children.ref : null;
1218
+ const mergedRef = (0, import_react21.useMergeRefs)([refs.setReference, childRef]);
1219
+ const child = (0, import_react20.isValidElement)(children) ? (0, import_react20.cloneElement)(
1220
+ children,
1221
+ getReferenceProps({
1222
+ ...children.props,
1223
+ ref: mergedRef
1224
+ })
1225
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { ref: refs.setReference, ...getReferenceProps(), children });
1226
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
1227
+ child,
1228
+ open && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
1229
+ "div",
1230
+ {
1231
+ ref: refs.setFloating,
1232
+ style: floatingStyles,
1233
+ "data-placement": finalPlacement,
1234
+ className: cx(Tooltip_default.tooltip, className),
1235
+ ...getFloatingProps(props),
1236
+ children: [
1237
+ content,
1238
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: Tooltip_default.arrow })
1239
+ ]
1240
+ }
1241
+ )
1242
+ ] });
1243
+ };
1244
+ // Annotate the CommonJS export names for ESM import in node:
1245
+ 0 && (module.exports = {
1246
+ Accordion,
1247
+ AccordionContent,
1248
+ AccordionItem,
1249
+ AccordionTrigger,
1250
+ Alert,
1251
+ Badge,
1252
+ Button,
1253
+ Checkbox,
1254
+ Input,
1255
+ Modal,
1256
+ Radio,
1257
+ RadioGroup,
1258
+ Skeleton,
1259
+ Spinner,
1260
+ Switch,
1261
+ Tabs,
1262
+ Toast,
1263
+ ToastProvider,
1264
+ Tooltip,
1265
+ useToast
1266
+ });
1267
+ //# sourceMappingURL=index.cjs.map