@kopexa/sight 17.12.1 → 17.13.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/chunk-5LLYOCGQ.mjs +153 -0
- package/dist/chunk-6IAHC3UK.mjs +1 -0
- package/dist/chunk-6XUZNN3X.mjs +1 -0
- package/dist/chunk-7KISSD3Q.mjs +1 -0
- package/dist/chunk-BJ7QPNKW.mjs +242 -0
- package/dist/chunk-CZNF6WPR.mjs +33 -0
- package/dist/chunk-DU3OVIBY.mjs +16 -0
- package/dist/chunk-DWZQIPCX.mjs +301 -0
- package/dist/chunk-EAJ3DTJ3.mjs +59 -0
- package/dist/chunk-FBTSAODG.mjs +25 -0
- package/dist/chunk-G57FFIKP.mjs +48 -0
- package/dist/chunk-GR3VEF4M.mjs +1 -0
- package/dist/chunk-HISY6ZIK.mjs +1 -0
- package/dist/chunk-HUHVPC6T.mjs +17 -0
- package/dist/chunk-HVOS7SXF.mjs +15 -0
- package/dist/chunk-PKG2E3MX.mjs +1 -0
- package/dist/chunk-POVIOFVF.mjs +18 -0
- package/dist/chunk-RK7G2GYB.mjs +45 -0
- package/dist/chunk-SHETEVHO.mjs +178 -0
- package/dist/chunk-UWC3Z7SY.mjs +1 -0
- package/dist/chunk-UWQG4HGJ.mjs +13 -0
- package/dist/chunk-XL2RCXMY.mjs +26 -0
- package/dist/chunk-XPDEN2RV.mjs +1 -0
- package/dist/components/blankstate/blankstate.d.mts +14 -0
- package/dist/components/blankstate/blankstate.d.ts +14 -0
- package/dist/components/blankstate/blankstate.js +69 -0
- package/dist/components/blankstate/blankstate.mjs +7 -0
- package/dist/components/blankstate/index.d.mts +4 -0
- package/dist/components/blankstate/index.d.ts +4 -0
- package/dist/components/blankstate/index.js +71 -0
- package/dist/components/blankstate/index.mjs +8 -0
- package/dist/components/code/code.d.mts +9 -0
- package/dist/components/code/code.d.ts +9 -0
- package/dist/components/code/code.js +49 -0
- package/dist/components/code/code.mjs +7 -0
- package/dist/components/code/index.d.mts +4 -0
- package/dist/components/code/index.d.ts +4 -0
- package/dist/components/code/index.js +51 -0
- package/dist/components/code/index.mjs +8 -0
- package/dist/components/dialog/dialog.d.mts +44 -0
- package/dist/components/dialog/dialog.d.ts +44 -0
- package/dist/components/dialog/dialog.js +213 -0
- package/dist/components/dialog/dialog.mjs +31 -0
- package/dist/components/dialog/index.d.mts +22 -0
- package/dist/components/dialog/index.d.ts +22 -0
- package/dist/components/dialog/index.js +232 -0
- package/dist/components/dialog/index.mjs +35 -0
- package/dist/components/dialog/namespace.d.mts +5 -0
- package/dist/components/dialog/namespace.d.ts +5 -0
- package/dist/components/dialog/namespace.js +213 -0
- package/dist/components/dialog/namespace.mjs +29 -0
- package/dist/components/dialog/transition.d.mts +5 -0
- package/dist/components/dialog/transition.d.ts +5 -0
- package/dist/components/dialog/transition.js +132 -0
- package/dist/components/dialog/transition.mjs +106 -0
- package/dist/components/file-upload/avatar-upload.d.mts +54 -0
- package/dist/components/file-upload/avatar-upload.d.ts +54 -0
- package/dist/components/file-upload/avatar-upload.js +841 -0
- package/dist/components/file-upload/avatar-upload.mjs +15 -0
- package/dist/components/file-upload/index.d.mts +5 -0
- package/dist/components/file-upload/index.d.ts +5 -0
- package/dist/components/file-upload/index.js +843 -0
- package/dist/components/file-upload/index.mjs +16 -0
- package/dist/components/file-upload/messages.d.mts +39 -0
- package/dist/components/file-upload/messages.d.ts +39 -0
- package/dist/components/file-upload/messages.js +68 -0
- package/dist/components/file-upload/messages.mjs +7 -0
- package/dist/components/file-upload/utils/data-url-to-file.d.mts +3 -0
- package/dist/components/file-upload/utils/data-url-to-file.d.ts +3 -0
- package/dist/components/file-upload/utils/data-url-to-file.js +38 -0
- package/dist/components/file-upload/utils/data-url-to-file.mjs +7 -0
- package/dist/components/file-upload/utils/format-accept-types.d.mts +8 -0
- package/dist/components/file-upload/utils/format-accept-types.d.ts +8 -0
- package/dist/components/file-upload/utils/format-accept-types.js +82 -0
- package/dist/components/file-upload/utils/format-accept-types.mjs +7 -0
- package/dist/components/file-upload/utils/is-image-like.d.mts +3 -0
- package/dist/components/file-upload/utils/is-image-like.d.ts +3 -0
- package/dist/components/file-upload/utils/is-image-like.js +36 -0
- package/dist/components/file-upload/utils/is-image-like.mjs +7 -0
- package/dist/components/index.d.mts +67 -0
- package/dist/components/index.d.ts +67 -0
- package/dist/components/index.js +1137 -0
- package/dist/components/index.mjs +92 -0
- package/dist/components/skeleton/index.d.mts +5 -0
- package/dist/components/skeleton/index.d.ts +5 -0
- package/dist/components/skeleton/index.js +53 -0
- package/dist/components/skeleton/index.mjs +12 -0
- package/dist/components/skeleton/skeleton-avatar.d.mts +9 -0
- package/dist/components/skeleton/skeleton-avatar.d.ts +9 -0
- package/dist/components/skeleton/skeleton-avatar.js +51 -0
- package/dist/components/skeleton/skeleton-avatar.mjs +8 -0
- package/dist/components/skeleton/skeleton.d.mts +7 -0
- package/dist/components/skeleton/skeleton.d.ts +7 -0
- package/dist/components/skeleton/skeleton.js +39 -0
- package/dist/components/skeleton/skeleton.mjs +7 -0
- package/dist/components/stat/index.d.mts +4 -0
- package/dist/components/stat/index.d.ts +4 -0
- package/dist/components/stat/index.js +186 -0
- package/dist/components/stat/index.mjs +24 -0
- package/dist/components/stat/stat.d.mts +36 -0
- package/dist/components/stat/stat.d.ts +36 -0
- package/dist/components/stat/stat.js +185 -0
- package/dist/components/stat/stat.mjs +24 -0
- package/dist/components/textarea/index.d.mts +4 -0
- package/dist/components/textarea/index.d.ts +4 -0
- package/dist/components/textarea/index.js +42 -0
- package/dist/components/textarea/index.mjs +8 -0
- package/dist/components/textarea/textarea.d.mts +8 -0
- package/dist/components/textarea/textarea.d.ts +8 -0
- package/dist/components/textarea/textarea.js +40 -0
- package/dist/components/textarea/textarea.mjs +7 -0
- package/dist/hooks/index.d.mts +2 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +341 -0
- package/dist/hooks/index.mjs +9 -0
- package/dist/hooks/use-file-upload/index.d.mts +47 -0
- package/dist/hooks/use-file-upload/index.d.ts +47 -0
- package/dist/hooks/use-file-upload/index.js +340 -0
- package/dist/hooks/use-file-upload/index.mjs +9 -0
- package/dist/hooks/use-file-upload/messages.d.mts +19 -0
- package/dist/hooks/use-file-upload/messages.d.ts +19 -0
- package/dist/hooks/use-file-upload/messages.js +48 -0
- package/dist/hooks/use-file-upload/messages.mjs +7 -0
- package/dist/index.d.mts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +1108 -32
- package/dist/index.mjs +82 -18
- package/dist/index.ts.backup.d.mts +14 -8
- package/dist/index.ts.backup.d.ts +14 -8
- package/dist/index.ts.backup.js +1108 -32
- package/dist/index.ts.backup.mjs +82 -18
- package/package.json +60 -64
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/components/stat/stat.tsx
|
|
23
|
+
var stat_exports = {};
|
|
24
|
+
__export(stat_exports, {
|
|
25
|
+
Stat: () => Stat,
|
|
26
|
+
StatDownIndicator: () => StatDownIndicator,
|
|
27
|
+
StatGroup: () => StatGroup,
|
|
28
|
+
StatHelpText: () => StatHelpText,
|
|
29
|
+
StatLabel: () => StatLabel,
|
|
30
|
+
StatRoot: () => StatRoot,
|
|
31
|
+
StatUpIndicator: () => StatUpIndicator,
|
|
32
|
+
StatValueText: () => StatValueText,
|
|
33
|
+
StatValueUnit: () => StatValueUnit
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(stat_exports);
|
|
36
|
+
var import_icons = require("@kopexa/icons");
|
|
37
|
+
var import_shared_utils = require("@kopexa/shared-utils");
|
|
38
|
+
var import_theme = require("@kopexa/theme");
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
function StatRoot({
|
|
41
|
+
className,
|
|
42
|
+
size,
|
|
43
|
+
trend,
|
|
44
|
+
children,
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
const styles = (0, import_theme.stat)({ size, trend });
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dl", { "data-slot": "stat", className: (0, import_shared_utils.cn)(styles.root(), className), ...props, children });
|
|
49
|
+
}
|
|
50
|
+
function StatLabel({ className, children, ...props }) {
|
|
51
|
+
const styles = (0, import_theme.stat)();
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
|
+
"dt",
|
|
54
|
+
{
|
|
55
|
+
"data-slot": "stat-label",
|
|
56
|
+
className: (0, import_shared_utils.cn)(styles.label(), className),
|
|
57
|
+
...props,
|
|
58
|
+
children
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
function StatValueText({
|
|
63
|
+
className,
|
|
64
|
+
size,
|
|
65
|
+
children,
|
|
66
|
+
...props
|
|
67
|
+
}) {
|
|
68
|
+
const styles = (0, import_theme.stat)({ size });
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
70
|
+
"dd",
|
|
71
|
+
{
|
|
72
|
+
"data-slot": "stat-value",
|
|
73
|
+
className: (0, import_shared_utils.cn)(styles.valueText(), className),
|
|
74
|
+
...props,
|
|
75
|
+
children
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
function StatValueUnit({
|
|
80
|
+
className,
|
|
81
|
+
children,
|
|
82
|
+
...props
|
|
83
|
+
}) {
|
|
84
|
+
const styles = (0, import_theme.stat)();
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
+
"span",
|
|
87
|
+
{
|
|
88
|
+
"data-slot": "stat-value-unit",
|
|
89
|
+
className: (0, import_shared_utils.cn)(styles.valueUnit(), className),
|
|
90
|
+
...props,
|
|
91
|
+
children
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
function StatHelpText({
|
|
96
|
+
className,
|
|
97
|
+
children,
|
|
98
|
+
...props
|
|
99
|
+
}) {
|
|
100
|
+
const styles = (0, import_theme.stat)();
|
|
101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
102
|
+
"span",
|
|
103
|
+
{
|
|
104
|
+
"data-slot": "stat-help-text",
|
|
105
|
+
className: (0, import_shared_utils.cn)(styles.helpText(), className),
|
|
106
|
+
...props,
|
|
107
|
+
children
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
function StatUpIndicator({
|
|
112
|
+
className,
|
|
113
|
+
icon,
|
|
114
|
+
children,
|
|
115
|
+
...props
|
|
116
|
+
}) {
|
|
117
|
+
const styles = (0, import_theme.stat)({ trend: "up" });
|
|
118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
119
|
+
"span",
|
|
120
|
+
{
|
|
121
|
+
"data-slot": "stat-indicator",
|
|
122
|
+
"data-type": "up",
|
|
123
|
+
className: (0, import_shared_utils.cn)(styles.indicator(), className),
|
|
124
|
+
...props,
|
|
125
|
+
children: [
|
|
126
|
+
icon != null ? icon : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ArrowUp, {}),
|
|
127
|
+
children
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
function StatDownIndicator({
|
|
133
|
+
className,
|
|
134
|
+
icon,
|
|
135
|
+
children,
|
|
136
|
+
...props
|
|
137
|
+
}) {
|
|
138
|
+
const styles = (0, import_theme.stat)({ trend: "down" });
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
140
|
+
"span",
|
|
141
|
+
{
|
|
142
|
+
"data-slot": "stat-indicator",
|
|
143
|
+
"data-type": "down",
|
|
144
|
+
className: (0, import_shared_utils.cn)(styles.indicator(), className),
|
|
145
|
+
...props,
|
|
146
|
+
children: [
|
|
147
|
+
icon != null ? icon : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ArrowDown, {}),
|
|
148
|
+
children
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
function StatGroup({ className, children, ...props }) {
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
"data-slot": "stat-group",
|
|
158
|
+
className: (0, import_shared_utils.cn)("flex flex-wrap justify-around gap-4", className),
|
|
159
|
+
...props,
|
|
160
|
+
children
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
var Stat = Object.assign(StatRoot, {
|
|
165
|
+
Root: StatRoot,
|
|
166
|
+
Label: StatLabel,
|
|
167
|
+
ValueText: StatValueText,
|
|
168
|
+
ValueUnit: StatValueUnit,
|
|
169
|
+
HelpText: StatHelpText,
|
|
170
|
+
UpIndicator: StatUpIndicator,
|
|
171
|
+
DownIndicator: StatDownIndicator,
|
|
172
|
+
Group: StatGroup
|
|
173
|
+
});
|
|
174
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
175
|
+
0 && (module.exports = {
|
|
176
|
+
Stat,
|
|
177
|
+
StatDownIndicator,
|
|
178
|
+
StatGroup,
|
|
179
|
+
StatHelpText,
|
|
180
|
+
StatLabel,
|
|
181
|
+
StatRoot,
|
|
182
|
+
StatUpIndicator,
|
|
183
|
+
StatValueText,
|
|
184
|
+
StatValueUnit
|
|
185
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
Stat,
|
|
5
|
+
StatDownIndicator,
|
|
6
|
+
StatGroup,
|
|
7
|
+
StatHelpText,
|
|
8
|
+
StatLabel,
|
|
9
|
+
StatRoot,
|
|
10
|
+
StatUpIndicator,
|
|
11
|
+
StatValueText,
|
|
12
|
+
StatValueUnit
|
|
13
|
+
} from "../../chunk-5LLYOCGQ.mjs";
|
|
14
|
+
export {
|
|
15
|
+
Stat,
|
|
16
|
+
StatDownIndicator,
|
|
17
|
+
StatGroup,
|
|
18
|
+
StatHelpText,
|
|
19
|
+
StatLabel,
|
|
20
|
+
StatRoot,
|
|
21
|
+
StatUpIndicator,
|
|
22
|
+
StatValueText,
|
|
23
|
+
StatValueUnit
|
|
24
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
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/index.ts
|
|
22
|
+
var textarea_exports = {};
|
|
23
|
+
__export(textarea_exports, {
|
|
24
|
+
Textarea: () => Textarea
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(textarea_exports);
|
|
27
|
+
|
|
28
|
+
// src/components/textarea/textarea.tsx
|
|
29
|
+
var import_theme = require("@kopexa/theme");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var Textarea = (props) => {
|
|
32
|
+
const { className, size, ...rest } = props;
|
|
33
|
+
const styles = (0, import_theme.textarea)({
|
|
34
|
+
className,
|
|
35
|
+
size
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { "data-slot": "textarea", className: styles, ...rest });
|
|
38
|
+
};
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
Textarea
|
|
42
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { TextareaVariantProps } from '@kopexa/theme';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
|
|
5
|
+
type TextareaProps = ComponentProps<"textarea"> & TextareaVariantProps;
|
|
6
|
+
declare const Textarea: (props: TextareaProps) => react_jsx_runtime.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { Textarea, type TextareaProps };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { TextareaVariantProps } from '@kopexa/theme';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
|
|
5
|
+
type TextareaProps = ComponentProps<"textarea"> & TextareaVariantProps;
|
|
6
|
+
declare const Textarea: (props: TextareaProps) => react_jsx_runtime.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { Textarea, type TextareaProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
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_theme = require("@kopexa/theme");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
var Textarea = (props) => {
|
|
30
|
+
const { className, size, ...rest } = props;
|
|
31
|
+
const styles = (0, import_theme.textarea)({
|
|
32
|
+
className,
|
|
33
|
+
size
|
|
34
|
+
});
|
|
35
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { "data-slot": "textarea", className: styles, ...rest });
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
Textarea
|
|
40
|
+
});
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
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/hooks/index.ts
|
|
22
|
+
var hooks_exports = {};
|
|
23
|
+
__export(hooks_exports, {
|
|
24
|
+
useFileUpload: () => useFileUpload
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
27
|
+
|
|
28
|
+
// src/hooks/use-file-upload/index.ts
|
|
29
|
+
var import_i18n2 = require("@kopexa/i18n");
|
|
30
|
+
var import_shared_utils = require("@kopexa/shared-utils");
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
|
|
33
|
+
// src/hooks/use-file-upload/messages.ts
|
|
34
|
+
var import_i18n = require("@kopexa/i18n");
|
|
35
|
+
var messages = (0, import_i18n.defineMessages)({
|
|
36
|
+
file_exceeds_max: {
|
|
37
|
+
id: "use_file_upload.file_exceeds_max",
|
|
38
|
+
defaultMessage: `File "{name}" exceeds the maximum size of {max}.`,
|
|
39
|
+
description: "Shown when a single file is larger than allowed"
|
|
40
|
+
},
|
|
41
|
+
file_not_accepted: {
|
|
42
|
+
id: "use_file_upload.file_not_accepted",
|
|
43
|
+
defaultMessage: `File "{name}" is not an accepted file type.`,
|
|
44
|
+
description: "Shown when file type/extension doesn't match accept"
|
|
45
|
+
},
|
|
46
|
+
too_many_files: {
|
|
47
|
+
id: "file_upload.too_many_files",
|
|
48
|
+
defaultMessage: "You can only upload a maximum of {max} files.",
|
|
49
|
+
description: "Shown when maxFiles would be exceeded"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// src/hooks/use-file-upload/index.ts
|
|
54
|
+
var useFileUpload = (options = {}) => {
|
|
55
|
+
const {
|
|
56
|
+
maxFiles = Number.POSITIVE_INFINITY,
|
|
57
|
+
maxSize = Number.POSITIVE_INFINITY,
|
|
58
|
+
accept = "*",
|
|
59
|
+
multiple = false,
|
|
60
|
+
initialFiles = [],
|
|
61
|
+
onFilesChange,
|
|
62
|
+
onFilesAdded,
|
|
63
|
+
onError
|
|
64
|
+
} = options;
|
|
65
|
+
const t = (0, import_i18n2.useSafeIntl)();
|
|
66
|
+
const [state, setState] = (0, import_react.useState)({
|
|
67
|
+
files: initialFiles.map((file) => ({
|
|
68
|
+
file,
|
|
69
|
+
id: file.id,
|
|
70
|
+
preview: file.url
|
|
71
|
+
})),
|
|
72
|
+
isDragging: false,
|
|
73
|
+
errors: []
|
|
74
|
+
});
|
|
75
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
76
|
+
const validateFile = (0, import_react.useCallback)(
|
|
77
|
+
(file) => {
|
|
78
|
+
if (file instanceof File) {
|
|
79
|
+
if (file.size > maxSize) {
|
|
80
|
+
return t.formatMessage(messages.file_exceeds_max, {
|
|
81
|
+
name: file.name,
|
|
82
|
+
max: (0, import_shared_utils.formatBytes)(maxSize)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
if (file.size > maxSize) {
|
|
87
|
+
return t.formatMessage(messages.file_exceeds_max, {
|
|
88
|
+
name: file.name,
|
|
89
|
+
max: (0, import_shared_utils.formatBytes)(maxSize)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (accept !== "*") {
|
|
94
|
+
const acceptedTypes = accept.split(",").map((type) => type.trim());
|
|
95
|
+
const fileType = file instanceof File ? file.type || "" : file.type;
|
|
96
|
+
const fileExtension = `.${file instanceof File ? file.name.split(".").pop() : file.name.split(".").pop()}`;
|
|
97
|
+
const isAccepted = acceptedTypes.some((type) => {
|
|
98
|
+
if (type.startsWith(".")) {
|
|
99
|
+
return fileExtension.toLowerCase() === type.toLowerCase();
|
|
100
|
+
}
|
|
101
|
+
if (type.endsWith("/*")) {
|
|
102
|
+
const baseType = type.split("/")[0];
|
|
103
|
+
return fileType.startsWith(`${baseType}/`);
|
|
104
|
+
}
|
|
105
|
+
return fileType === type;
|
|
106
|
+
});
|
|
107
|
+
if (!isAccepted) {
|
|
108
|
+
return t.formatMessage(messages.file_not_accepted, {
|
|
109
|
+
name: file instanceof File ? file.name : file.name
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
},
|
|
115
|
+
[accept, maxSize, t.formatMessage]
|
|
116
|
+
);
|
|
117
|
+
const createPreview = (0, import_react.useCallback)(
|
|
118
|
+
(file) => {
|
|
119
|
+
if (file instanceof File) {
|
|
120
|
+
return URL.createObjectURL(file);
|
|
121
|
+
}
|
|
122
|
+
return file.url;
|
|
123
|
+
},
|
|
124
|
+
[]
|
|
125
|
+
);
|
|
126
|
+
const generateUniqueId = (0, import_react.useCallback)((file) => {
|
|
127
|
+
if (file instanceof File) {
|
|
128
|
+
return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
129
|
+
}
|
|
130
|
+
return file.id;
|
|
131
|
+
}, []);
|
|
132
|
+
const clearFiles = (0, import_react.useCallback)(() => {
|
|
133
|
+
setState((prev) => {
|
|
134
|
+
for (const file of prev.files) {
|
|
135
|
+
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) {
|
|
136
|
+
URL.revokeObjectURL(file.preview);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (inputRef.current) {
|
|
140
|
+
inputRef.current.value = "";
|
|
141
|
+
}
|
|
142
|
+
const newState = {
|
|
143
|
+
...prev,
|
|
144
|
+
files: [],
|
|
145
|
+
errors: []
|
|
146
|
+
};
|
|
147
|
+
onFilesChange == null ? void 0 : onFilesChange(newState.files);
|
|
148
|
+
return newState;
|
|
149
|
+
});
|
|
150
|
+
}, [onFilesChange]);
|
|
151
|
+
const addFiles = (0, import_react.useCallback)(
|
|
152
|
+
(newFiles) => {
|
|
153
|
+
if (!newFiles || newFiles.length === 0) return;
|
|
154
|
+
const newFilesArray = Array.from(newFiles);
|
|
155
|
+
const errors = [];
|
|
156
|
+
setState((prev) => ({ ...prev, errors: [] }));
|
|
157
|
+
if (!multiple) {
|
|
158
|
+
clearFiles();
|
|
159
|
+
}
|
|
160
|
+
if (multiple && maxFiles !== Number.POSITIVE_INFINITY && state.files.length + newFilesArray.length > maxFiles) {
|
|
161
|
+
errors.push(
|
|
162
|
+
t.formatMessage(messages.too_many_files, {
|
|
163
|
+
max: maxFiles
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
onError == null ? void 0 : onError(errors);
|
|
167
|
+
setState((prev) => ({ ...prev, errors }));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const validFiles = [];
|
|
171
|
+
for (const file of newFilesArray) {
|
|
172
|
+
if (multiple) {
|
|
173
|
+
const isDuplicate = state.files.some(
|
|
174
|
+
(existingFile) => existingFile.file.name === file.name && existingFile.file.size === file.size
|
|
175
|
+
);
|
|
176
|
+
if (isDuplicate) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (file.size > maxSize) {
|
|
181
|
+
errors.push(
|
|
182
|
+
multiple ? `Some files exceed the maximum size of ${(0, import_shared_utils.formatBytes)(maxSize)}.` : `File exceeds the maximum size of ${(0, import_shared_utils.formatBytes)(maxSize)}.`
|
|
183
|
+
);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const error = validateFile(file);
|
|
187
|
+
if (error) {
|
|
188
|
+
errors.push(error);
|
|
189
|
+
} else {
|
|
190
|
+
validFiles.push({
|
|
191
|
+
file,
|
|
192
|
+
id: generateUniqueId(file),
|
|
193
|
+
preview: createPreview(file)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (validFiles.length > 0) {
|
|
198
|
+
onFilesAdded == null ? void 0 : onFilesAdded(validFiles);
|
|
199
|
+
setState((prev) => {
|
|
200
|
+
const newFiles2 = !multiple ? validFiles : [...prev.files, ...validFiles];
|
|
201
|
+
onFilesChange == null ? void 0 : onFilesChange(newFiles2);
|
|
202
|
+
return {
|
|
203
|
+
...prev,
|
|
204
|
+
files: newFiles2,
|
|
205
|
+
errors
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
} else if (errors.length > 0) {
|
|
209
|
+
onError == null ? void 0 : onError(errors);
|
|
210
|
+
setState((prev) => ({
|
|
211
|
+
...prev,
|
|
212
|
+
errors
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
if (inputRef.current) {
|
|
216
|
+
inputRef.current.value = "";
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
[
|
|
220
|
+
onError,
|
|
221
|
+
state.files,
|
|
222
|
+
maxFiles,
|
|
223
|
+
multiple,
|
|
224
|
+
maxSize,
|
|
225
|
+
validateFile,
|
|
226
|
+
createPreview,
|
|
227
|
+
generateUniqueId,
|
|
228
|
+
clearFiles,
|
|
229
|
+
onFilesChange,
|
|
230
|
+
onFilesAdded,
|
|
231
|
+
t.formatMessage
|
|
232
|
+
]
|
|
233
|
+
);
|
|
234
|
+
const removeFile = (0, import_react.useCallback)(
|
|
235
|
+
(id) => {
|
|
236
|
+
setState((prev) => {
|
|
237
|
+
const fileToRemove = prev.files.find((file) => file.id === id);
|
|
238
|
+
if ((fileToRemove == null ? void 0 : fileToRemove.preview) && fileToRemove.file instanceof File && fileToRemove.file.type.startsWith("image/")) {
|
|
239
|
+
URL.revokeObjectURL(fileToRemove.preview);
|
|
240
|
+
}
|
|
241
|
+
const newFiles = prev.files.filter((file) => file.id !== id);
|
|
242
|
+
onFilesChange == null ? void 0 : onFilesChange(newFiles);
|
|
243
|
+
return {
|
|
244
|
+
...prev,
|
|
245
|
+
files: newFiles,
|
|
246
|
+
errors: []
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
[onFilesChange]
|
|
251
|
+
);
|
|
252
|
+
const clearErrors = (0, import_react.useCallback)(() => {
|
|
253
|
+
setState((prev) => ({
|
|
254
|
+
...prev,
|
|
255
|
+
errors: []
|
|
256
|
+
}));
|
|
257
|
+
}, []);
|
|
258
|
+
const handleDragEnter = (0, import_react.useCallback)((e) => {
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
e.stopPropagation();
|
|
261
|
+
setState((prev) => ({ ...prev, isDragging: true }));
|
|
262
|
+
}, []);
|
|
263
|
+
const handleDragLeave = (0, import_react.useCallback)((e) => {
|
|
264
|
+
e.preventDefault();
|
|
265
|
+
e.stopPropagation();
|
|
266
|
+
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
270
|
+
}, []);
|
|
271
|
+
const handleDragOver = (0, import_react.useCallback)((e) => {
|
|
272
|
+
e.preventDefault();
|
|
273
|
+
e.stopPropagation();
|
|
274
|
+
}, []);
|
|
275
|
+
const handleDrop = (0, import_react.useCallback)(
|
|
276
|
+
(e) => {
|
|
277
|
+
var _a;
|
|
278
|
+
e.preventDefault();
|
|
279
|
+
e.stopPropagation();
|
|
280
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
281
|
+
if ((_a = inputRef.current) == null ? void 0 : _a.disabled) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
285
|
+
if (!multiple) {
|
|
286
|
+
const file = e.dataTransfer.files[0];
|
|
287
|
+
addFiles([file]);
|
|
288
|
+
} else {
|
|
289
|
+
addFiles(e.dataTransfer.files);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
[addFiles, multiple]
|
|
294
|
+
);
|
|
295
|
+
const handleFileChange = (0, import_react.useCallback)(
|
|
296
|
+
(e) => {
|
|
297
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
298
|
+
addFiles(e.target.files);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
[addFiles]
|
|
302
|
+
);
|
|
303
|
+
const openFileDialog = (0, import_react.useCallback)(() => {
|
|
304
|
+
if (inputRef.current) {
|
|
305
|
+
inputRef.current.click();
|
|
306
|
+
}
|
|
307
|
+
}, []);
|
|
308
|
+
const getInputProps = (0, import_react.useCallback)(
|
|
309
|
+
(props = {}) => {
|
|
310
|
+
return {
|
|
311
|
+
...props,
|
|
312
|
+
type: "file",
|
|
313
|
+
onChange: handleFileChange,
|
|
314
|
+
accept: props.accept || accept,
|
|
315
|
+
multiple: props.multiple !== void 0 ? props.multiple : multiple,
|
|
316
|
+
ref: inputRef
|
|
317
|
+
};
|
|
318
|
+
},
|
|
319
|
+
[accept, multiple, handleFileChange]
|
|
320
|
+
);
|
|
321
|
+
return [
|
|
322
|
+
state,
|
|
323
|
+
{
|
|
324
|
+
addFiles,
|
|
325
|
+
removeFile,
|
|
326
|
+
clearFiles,
|
|
327
|
+
clearErrors,
|
|
328
|
+
handleDragEnter,
|
|
329
|
+
handleDragLeave,
|
|
330
|
+
handleDragOver,
|
|
331
|
+
handleDrop,
|
|
332
|
+
handleFileChange,
|
|
333
|
+
openFileDialog,
|
|
334
|
+
getInputProps
|
|
335
|
+
}
|
|
336
|
+
];
|
|
337
|
+
};
|
|
338
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
339
|
+
0 && (module.exports = {
|
|
340
|
+
useFileUpload
|
|
341
|
+
});
|