funuicss 3.8.7 → 3.8.9
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/css/fun.css +702 -87
- package/index.d.ts +3 -0
- package/index.js +8 -2
- package/package.json +1 -1
- package/ui/button/Button.d.ts +6 -5
- package/ui/button/Button.js +190 -84
- package/ui/div/Div.d.ts +3 -1
- package/ui/div/Div.js +2 -2
- package/ui/feature/Feature.d.ts +9 -38
- package/ui/feature/Feature.js +62 -147
- package/ui/flex/Flex.d.ts +11 -10
- package/ui/flex/Flex.js +102 -6
- package/ui/form/Form.d.ts +77 -0
- package/ui/form/Form.js +724 -0
- package/ui/input/FileUpload.js +370 -21
- package/ui/input/Input.d.ts +44 -15
- package/ui/input/Input.js +1145 -369
- package/ui/products/CartModal.d.ts +0 -2
- package/ui/products/CartModal.js +59 -39
- package/ui/products/ProductCard.js +9 -22
- package/ui/products/ProductDetail.js +136 -97
- package/ui/products/ProductLoader.d.ts +3 -0
- package/ui/products/ProductLoader.js +22 -0
- package/ui/products/Store.d.ts +32 -7
- package/ui/products/Store.js +393 -94
- package/ui/progress/Bar.js +2 -2
- package/ui/sidebar/SideBar.js +1 -2
- package/ui/specials/CircleGroup.d.ts +2 -1
- package/ui/specials/CircleGroup.js +3 -3
- package/ui/theme/theme.d.ts +4 -0
- package/ui/theme/theme.js +336 -133
package/ui/input/FileUpload.js
CHANGED
|
@@ -66,15 +66,19 @@ var Button_1 = __importDefault(require("../button/Button"));
|
|
|
66
66
|
var Text_1 = __importDefault(require("../text/Text"));
|
|
67
67
|
var FileUpload = function (_a) {
|
|
68
68
|
var _b = _a.id, id = _b === void 0 ? 'fileInput' : _b, name = _a.name, onChange = _a.onChange, onDrop = _a.onDrop, status = _a.status, _c = _a.label, label = _c === void 0 ? 'Upload File' : _c, helperText = _a.helperText, icon = _a.icon, extra = _a.extra, button = _a.button, btn = _a.btn, value = _a.value, _d = _a.fullWidth, fullWidth = _d === void 0 ? true : _d, accept = _a.accept, multiple = _a.multiple, rest = __rest(_a, ["id", "name", "onChange", "onDrop", "status", "label", "helperText", "icon", "extra", "button", "btn", "value", "fullWidth", "accept", "multiple"]);
|
|
69
|
-
var _e = (0, react_1.useState)(
|
|
69
|
+
var _e = (0, react_1.useState)([]), fileNames = _e[0], setFileNames = _e[1];
|
|
70
70
|
var _f = (0, react_1.useState)(false), isDragging = _f[0], setIsDragging = _f[1];
|
|
71
71
|
var _g = (0, react_1.useState)(false), isDragOver = _g[0], setIsDragOver = _g[1];
|
|
72
72
|
var inputRef = (0, react_1.useRef)(null);
|
|
73
73
|
var handleChange = function (e) {
|
|
74
74
|
var files = e.target.files;
|
|
75
75
|
if (files && files.length > 0) {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// Store all file names
|
|
77
|
+
var names = Array.from(files).map(function (file) { return file.name; });
|
|
78
|
+
setFileNames(names);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
setFileNames([]);
|
|
78
82
|
}
|
|
79
83
|
if (onChange)
|
|
80
84
|
onChange(e);
|
|
@@ -89,7 +93,6 @@ var FileUpload = function (_a) {
|
|
|
89
93
|
e.preventDefault();
|
|
90
94
|
e.stopPropagation();
|
|
91
95
|
setIsDragOver(false);
|
|
92
|
-
// Only set dragging to false if we're leaving the actual drop zone
|
|
93
96
|
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
94
97
|
setIsDragging(false);
|
|
95
98
|
}
|
|
@@ -106,8 +109,8 @@ var FileUpload = function (_a) {
|
|
|
106
109
|
setIsDragOver(false);
|
|
107
110
|
var files = e.dataTransfer.files;
|
|
108
111
|
if (files && files.length > 0) {
|
|
109
|
-
var
|
|
110
|
-
|
|
112
|
+
var names = Array.from(files).map(function (file) { return file.name; });
|
|
113
|
+
setFileNames(names);
|
|
111
114
|
// Update the input element's files
|
|
112
115
|
if (inputRef.current) {
|
|
113
116
|
var dataTransfer = new DataTransfer();
|
|
@@ -124,7 +127,6 @@ var FileUpload = function (_a) {
|
|
|
124
127
|
onChange(event_1);
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
|
-
// Call onDrop callback if provided
|
|
128
130
|
if (onDrop) {
|
|
129
131
|
onDrop(files);
|
|
130
132
|
}
|
|
@@ -167,9 +169,9 @@ var FileUpload = function (_a) {
|
|
|
167
169
|
}
|
|
168
170
|
return {};
|
|
169
171
|
};
|
|
170
|
-
// Render file info when
|
|
172
|
+
// Render file info when files are selected
|
|
171
173
|
var renderFileInfo = function () {
|
|
172
|
-
if (
|
|
174
|
+
if (fileNames.length === 0)
|
|
173
175
|
return null;
|
|
174
176
|
return (react_1.default.createElement("div", { className: "file-info", style: {
|
|
175
177
|
marginTop: 'var(--space-3)',
|
|
@@ -178,18 +180,56 @@ var FileUpload = function (_a) {
|
|
|
178
180
|
borderRadius: '8px',
|
|
179
181
|
border: '1px solid var(--borderColor)',
|
|
180
182
|
display: 'flex',
|
|
181
|
-
|
|
182
|
-
gap: 'var(--space-
|
|
183
|
-
|
|
183
|
+
flexDirection: 'column',
|
|
184
|
+
gap: 'var(--space-2)',
|
|
185
|
+
alignItems: 'center'
|
|
184
186
|
} },
|
|
185
|
-
react_1.default.createElement(
|
|
186
|
-
|
|
187
|
+
react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--space-2)' } },
|
|
188
|
+
react_1.default.createElement(pi_1.PiFiles, { style: { color: 'var(--primary)', fontSize: '1.2rem' } }),
|
|
189
|
+
react_1.default.createElement(Text_1.default, { text: "".concat(fileNames.length, " file").concat(fileNames.length !== 1 ? 's' : '', " selected"), truncate: 1, block: true, size: 'sm', bold: true })),
|
|
190
|
+
fileNames.length > 0 && (react_1.default.createElement("div", { style: {
|
|
191
|
+
maxHeight: '100px',
|
|
192
|
+
overflowY: 'auto',
|
|
193
|
+
width: '100%',
|
|
194
|
+
textAlign: 'left',
|
|
195
|
+
padding: '0 var(--space-2)'
|
|
196
|
+
} }, fileNames.map(function (name, index) { return (react_1.default.createElement("div", { key: index, style: {
|
|
197
|
+
display: 'flex',
|
|
198
|
+
alignItems: 'center',
|
|
199
|
+
gap: 'var(--space-2)',
|
|
200
|
+
padding: 'var(--space-1) 0',
|
|
201
|
+
borderBottom: index < fileNames.length - 1 ? '1px solid var(--borderColor)' : 'none'
|
|
202
|
+
} },
|
|
203
|
+
react_1.default.createElement(pi_1.PiFile, { style: { color: 'var(--secondary)', fontSize: '0.9rem' } }),
|
|
204
|
+
react_1.default.createElement(Text_1.default, { text: name, truncate: 1, block: true, size: 'xs', color: 'secondary' }))); })))));
|
|
205
|
+
};
|
|
206
|
+
// Get display text based on number of files
|
|
207
|
+
var getDisplayText = function () {
|
|
208
|
+
if (isDragOver)
|
|
209
|
+
return 'Drop files to upload';
|
|
210
|
+
if (fileNames.length === 0)
|
|
211
|
+
return label;
|
|
212
|
+
if (fileNames.length === 1)
|
|
213
|
+
return fileNames[0];
|
|
214
|
+
return "".concat(fileNames.length, " files selected");
|
|
187
215
|
};
|
|
188
216
|
if (btn) {
|
|
189
|
-
return (react_1.default.createElement("div", { className: "fileInput", style: {
|
|
217
|
+
return (react_1.default.createElement("div", { className: "fileInput", style: {
|
|
218
|
+
width: fullWidth ? '100%' : 'fit-content',
|
|
219
|
+
position: 'relative'
|
|
220
|
+
} },
|
|
190
221
|
button || (react_1.default.createElement("div", { onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleClick, style: { position: 'relative' } },
|
|
191
|
-
react_1.default.createElement(Button_1.default, { startIcon: icon || react_1.default.createElement(pi_1.PiCloudArrowUp, null), bg: isDragOver ? "primary600" : "primary", fullWidth: fullWidth, raised: true, style: getButtonStyles() }, isDragOver ? 'Drop files here' :
|
|
192
|
-
react_1.default.createElement("input", __assign({ ref: inputRef, id: id, name: name, onChange: handleChange, type: "file",
|
|
222
|
+
react_1.default.createElement(Button_1.default, { startIcon: icon || react_1.default.createElement(pi_1.PiCloudArrowUp, null), bg: isDragOver ? "primary600" : "primary", fullWidth: fullWidth, raised: true, style: getButtonStyles() }, isDragOver ? 'Drop files here' : getDisplayText()))),
|
|
223
|
+
react_1.default.createElement("input", __assign({ ref: inputRef, id: id, name: name, onChange: handleChange, type: "file", accept: accept, multiple: multiple, className: "filedInput", style: {
|
|
224
|
+
position: 'absolute',
|
|
225
|
+
top: 0,
|
|
226
|
+
left: 0,
|
|
227
|
+
width: '100%',
|
|
228
|
+
height: '100%',
|
|
229
|
+
opacity: 0,
|
|
230
|
+
cursor: 'pointer',
|
|
231
|
+
zIndex: 1
|
|
232
|
+
} }, rest)),
|
|
193
233
|
renderFileInfo(),
|
|
194
234
|
helperText && (react_1.default.createElement("div", { className: "input-helper-text ".concat(status ? "helper-".concat(status) : ''), style: { marginTop: 'var(--space-3)' } },
|
|
195
235
|
react_1.default.createElement("span", null, helperText)))));
|
|
@@ -204,7 +244,7 @@ var FileUpload = function (_a) {
|
|
|
204
244
|
transform: isDragOver ? 'translateY(-2px)' : 'none'
|
|
205
245
|
} }, icon || react_1.default.createElement(pi_1.PiCloudArrowUp, null)),
|
|
206
246
|
react_1.default.createElement("div", { className: "_upload_text fit" },
|
|
207
|
-
react_1.default.createElement(Text_1.default, { text: isDragOver ? 'Drop files to upload' :
|
|
247
|
+
react_1.default.createElement(Text_1.default, { text: isDragOver ? 'Drop files to upload' : getDisplayText(), truncate: 1, block: true, style: {
|
|
208
248
|
color: isDragOver ? 'var(--primary600)' : 'var(--text-color)',
|
|
209
249
|
fontWeight: isDragOver ? '600' : '400'
|
|
210
250
|
} })),
|
|
@@ -219,17 +259,326 @@ var FileUpload = function (_a) {
|
|
|
219
259
|
borderRadius: '14px',
|
|
220
260
|
pointerEvents: 'none'
|
|
221
261
|
} })),
|
|
222
|
-
!
|
|
262
|
+
!fileNames.length && !isDragOver && (react_1.default.createElement("div", { style: {
|
|
223
263
|
marginTop: 'var(--space-3)',
|
|
224
264
|
fontSize: '0.8rem',
|
|
225
265
|
color: 'var(--text-muted)',
|
|
226
266
|
opacity: 0.7
|
|
227
|
-
} },
|
|
267
|
+
} }, multiple ? 'Click or drag multiple files to upload' : 'Click or drag a file to upload')),
|
|
228
268
|
extra && react_1.default.createElement("div", { className: "text-small opacity-3", style: { marginTop: 'var(--space-2)' } }, extra)),
|
|
229
|
-
react_1.default.createElement("input", __assign({ ref: inputRef, onChange: handleChange, type: "file", id: id, name: name, className: "_upload_input",
|
|
269
|
+
react_1.default.createElement("input", __assign({ ref: inputRef, onChange: handleChange, type: "file", id: id, name: name, className: "_upload_input", accept: accept, multiple: multiple, style: {
|
|
270
|
+
position: 'absolute',
|
|
271
|
+
top: 0,
|
|
272
|
+
left: 0,
|
|
273
|
+
width: '100%',
|
|
274
|
+
height: '100%',
|
|
275
|
+
opacity: 0,
|
|
276
|
+
cursor: 'pointer',
|
|
277
|
+
zIndex: 1
|
|
278
|
+
} }, rest)),
|
|
230
279
|
renderFileInfo(),
|
|
231
280
|
helperText && (react_1.default.createElement("div", { className: "input-helper-text ".concat(status ? "helper-".concat(status) : ''), style: { marginTop: 'var(--space-3)' } },
|
|
232
281
|
react_1.default.createElement("span", null, helperText)))));
|
|
233
282
|
};
|
|
234
283
|
exports.FileUpload = FileUpload;
|
|
235
284
|
exports.default = exports.FileUpload;
|
|
285
|
+
// 'use client'
|
|
286
|
+
// import React, { useState, useRef } from 'react';
|
|
287
|
+
// import { PiCloudArrowUp, PiFile } from 'react-icons/pi';
|
|
288
|
+
// import Button from '../button/Button';
|
|
289
|
+
// import Text from '../text/Text';
|
|
290
|
+
// interface FileUploadProps {
|
|
291
|
+
// id?: string;
|
|
292
|
+
// name?: string;
|
|
293
|
+
// onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
294
|
+
// onDrop?: (files: FileList) => void;
|
|
295
|
+
// status?: 'success' | 'warning' | 'danger' | 'info' | '';
|
|
296
|
+
// label?: string;
|
|
297
|
+
// helperText?: string;
|
|
298
|
+
// icon?: React.ReactNode;
|
|
299
|
+
// extra?: React.ReactNode;
|
|
300
|
+
// button?: React.ReactNode;
|
|
301
|
+
// btn?: boolean;
|
|
302
|
+
// value?: any;
|
|
303
|
+
// fullWidth?: boolean;
|
|
304
|
+
// accept?: string;
|
|
305
|
+
// multiple?: boolean;
|
|
306
|
+
// [key: string]: any;
|
|
307
|
+
// }
|
|
308
|
+
// export const FileUpload: React.FC<FileUploadProps & React.InputHTMLAttributes<HTMLInputElement>> = ({
|
|
309
|
+
// id = 'fileInput',
|
|
310
|
+
// name,
|
|
311
|
+
// onChange,
|
|
312
|
+
// onDrop,
|
|
313
|
+
// status,
|
|
314
|
+
// label = 'Upload File',
|
|
315
|
+
// helperText,
|
|
316
|
+
// icon,
|
|
317
|
+
// extra,
|
|
318
|
+
// button,
|
|
319
|
+
// btn,
|
|
320
|
+
// value,
|
|
321
|
+
// fullWidth = true,
|
|
322
|
+
// accept,
|
|
323
|
+
// multiple,
|
|
324
|
+
// ...rest
|
|
325
|
+
// }) => {
|
|
326
|
+
// const [fileName, setFileName] = useState('');
|
|
327
|
+
// const [isDragging, setIsDragging] = useState(false);
|
|
328
|
+
// const [isDragOver, setIsDragOver] = useState(false);
|
|
329
|
+
// const inputRef = useRef<HTMLInputElement>(null);
|
|
330
|
+
// const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
331
|
+
// const files = e.target.files;
|
|
332
|
+
// if (files && files.length > 0) {
|
|
333
|
+
// const file = files[0];
|
|
334
|
+
// setFileName(file.name);
|
|
335
|
+
// }
|
|
336
|
+
// if (onChange) onChange(e);
|
|
337
|
+
// };
|
|
338
|
+
// const handleDragEnter = (e: React.DragEvent) => {
|
|
339
|
+
// e.preventDefault();
|
|
340
|
+
// e.stopPropagation();
|
|
341
|
+
// setIsDragging(true);
|
|
342
|
+
// setIsDragOver(true);
|
|
343
|
+
// };
|
|
344
|
+
// const handleDragLeave = (e: React.DragEvent) => {
|
|
345
|
+
// e.preventDefault();
|
|
346
|
+
// e.stopPropagation();
|
|
347
|
+
// setIsDragOver(false);
|
|
348
|
+
// // Only set dragging to false if we're leaving the actual drop zone
|
|
349
|
+
// if (!e.currentTarget.contains(e.relatedTarget as Node)) {
|
|
350
|
+
// setIsDragging(false);
|
|
351
|
+
// }
|
|
352
|
+
// };
|
|
353
|
+
// const handleDragOver = (e: React.DragEvent) => {
|
|
354
|
+
// e.preventDefault();
|
|
355
|
+
// e.stopPropagation();
|
|
356
|
+
// setIsDragOver(true);
|
|
357
|
+
// };
|
|
358
|
+
// const handleDrop = (e: React.DragEvent) => {
|
|
359
|
+
// e.preventDefault();
|
|
360
|
+
// e.stopPropagation();
|
|
361
|
+
// setIsDragging(false);
|
|
362
|
+
// setIsDragOver(false);
|
|
363
|
+
// const files = e.dataTransfer.files;
|
|
364
|
+
// if (files && files.length > 0) {
|
|
365
|
+
// const file = files[0];
|
|
366
|
+
// setFileName(file.name);
|
|
367
|
+
// // Update the input element's files
|
|
368
|
+
// if (inputRef.current) {
|
|
369
|
+
// const dataTransfer = new DataTransfer();
|
|
370
|
+
// for (let i = 0; i < files.length; i++) {
|
|
371
|
+
// dataTransfer.items.add(files[i]);
|
|
372
|
+
// }
|
|
373
|
+
// inputRef.current.files = dataTransfer.files;
|
|
374
|
+
// // Trigger onChange if provided
|
|
375
|
+
// if (onChange) {
|
|
376
|
+
// const event = {
|
|
377
|
+
// target: inputRef.current,
|
|
378
|
+
// currentTarget: inputRef.current,
|
|
379
|
+
// } as React.ChangeEvent<HTMLInputElement>;
|
|
380
|
+
// onChange(event);
|
|
381
|
+
// }
|
|
382
|
+
// }
|
|
383
|
+
// // Call onDrop callback if provided
|
|
384
|
+
// if (onDrop) {
|
|
385
|
+
// onDrop(files);
|
|
386
|
+
// }
|
|
387
|
+
// }
|
|
388
|
+
// };
|
|
389
|
+
// const handleClick = () => {
|
|
390
|
+
// if (inputRef.current) {
|
|
391
|
+
// inputRef.current.click();
|
|
392
|
+
// }
|
|
393
|
+
// };
|
|
394
|
+
// // Enhanced drag and drop styles
|
|
395
|
+
// const getContainerStyles = () => {
|
|
396
|
+
// const baseStyles = {
|
|
397
|
+
// border: '0.17rem dashed var(--borderColor)',
|
|
398
|
+
// borderRadius: '16px',
|
|
399
|
+
// padding: 'var(--space-5)',
|
|
400
|
+
// textAlign: 'center' as const,
|
|
401
|
+
// transition: 'all 0.3s ease',
|
|
402
|
+
// cursor: 'pointer',
|
|
403
|
+
// margin: 'auto',
|
|
404
|
+
// color: 'var(--text-color)',
|
|
405
|
+
// position: 'relative' as const,
|
|
406
|
+
// };
|
|
407
|
+
// if (isDragOver) {
|
|
408
|
+
// return {
|
|
409
|
+
// ...baseStyles,
|
|
410
|
+
// borderColor: 'var(--primary)',
|
|
411
|
+
// backgroundColor: 'var(--lighter)',
|
|
412
|
+
// transform: 'scale(1.02)',
|
|
413
|
+
// boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
|
|
414
|
+
// };
|
|
415
|
+
// }
|
|
416
|
+
// if (isDragging) {
|
|
417
|
+
// return {
|
|
418
|
+
// ...baseStyles,
|
|
419
|
+
// borderColor: 'var(--primary600)',
|
|
420
|
+
// backgroundColor: 'var(--lighter)',
|
|
421
|
+
// };
|
|
422
|
+
// }
|
|
423
|
+
// return baseStyles;
|
|
424
|
+
// };
|
|
425
|
+
// const getButtonStyles = () => {
|
|
426
|
+
// if (isDragOver) {
|
|
427
|
+
// return {
|
|
428
|
+
// opacity: 0.8,
|
|
429
|
+
// transform: 'scale(1.05)',
|
|
430
|
+
// transition: 'all 0.2s ease',
|
|
431
|
+
// backgroundColor: 'var(--primary600)',
|
|
432
|
+
// };
|
|
433
|
+
// }
|
|
434
|
+
// return {};
|
|
435
|
+
// };
|
|
436
|
+
// // Render file info when file is selected
|
|
437
|
+
// const renderFileInfo = () => {
|
|
438
|
+
// if (!fileName) return null;
|
|
439
|
+
// return (
|
|
440
|
+
// <div className="file-info" style={{
|
|
441
|
+
// marginTop: 'var(--space-3)',
|
|
442
|
+
// padding: 'var(--space-3)',
|
|
443
|
+
// backgroundColor: 'var(--light)',
|
|
444
|
+
// borderRadius: '8px',
|
|
445
|
+
// border: '1px solid var(--borderColor)',
|
|
446
|
+
// display: 'flex',
|
|
447
|
+
// alignItems: 'center',
|
|
448
|
+
// gap: 'var(--space-3)',
|
|
449
|
+
// justifyContent: 'center'
|
|
450
|
+
// }}>
|
|
451
|
+
// <PiFile style={{ color: 'var(--primary)', fontSize: '1.2rem' }} />
|
|
452
|
+
// <Text
|
|
453
|
+
// text={fileName}
|
|
454
|
+
// truncate={1}
|
|
455
|
+
// block
|
|
456
|
+
// size='sm'
|
|
457
|
+
// />
|
|
458
|
+
// </div>
|
|
459
|
+
// );
|
|
460
|
+
// };
|
|
461
|
+
// if (btn) {
|
|
462
|
+
// return (
|
|
463
|
+
// <div className="fileInput" style={{ width: fullWidth ? '100%' : 'fit-content' }}>
|
|
464
|
+
// {button || (
|
|
465
|
+
// <div
|
|
466
|
+
// onDragEnter={handleDragEnter}
|
|
467
|
+
// onDragLeave={handleDragLeave}
|
|
468
|
+
// onDragOver={handleDragOver}
|
|
469
|
+
// onDrop={handleDrop}
|
|
470
|
+
// onClick={handleClick}
|
|
471
|
+
// style={{ position: 'relative' }}
|
|
472
|
+
// >
|
|
473
|
+
// <Button
|
|
474
|
+
// startIcon={icon || <PiCloudArrowUp />}
|
|
475
|
+
// bg={isDragOver ? "primary600" : "primary"}
|
|
476
|
+
// fullWidth={fullWidth}
|
|
477
|
+
// raised
|
|
478
|
+
// style={getButtonStyles()}
|
|
479
|
+
// >
|
|
480
|
+
// {isDragOver ? 'Drop files here' : fileName || label}
|
|
481
|
+
// </Button>
|
|
482
|
+
// </div>
|
|
483
|
+
// )}
|
|
484
|
+
// <input
|
|
485
|
+
// ref={inputRef}
|
|
486
|
+
// id={id}
|
|
487
|
+
// name={name}
|
|
488
|
+
// onChange={handleChange}
|
|
489
|
+
// type="file"
|
|
490
|
+
// value={value}
|
|
491
|
+
// accept={accept}
|
|
492
|
+
// multiple={multiple}
|
|
493
|
+
// className="filedInput"
|
|
494
|
+
// {...rest}
|
|
495
|
+
// />
|
|
496
|
+
// {renderFileInfo()}
|
|
497
|
+
// {helperText && (
|
|
498
|
+
// <div className={`input-helper-text ${status ? `helper-${status}` : ''}`} style={{ marginTop: 'var(--space-3)' }}>
|
|
499
|
+
// <span>{helperText}</span>
|
|
500
|
+
// </div>
|
|
501
|
+
// )}
|
|
502
|
+
// </div>
|
|
503
|
+
// );
|
|
504
|
+
// }
|
|
505
|
+
// return (
|
|
506
|
+
// <div
|
|
507
|
+
// className="_upload_container"
|
|
508
|
+
// style={getContainerStyles()}
|
|
509
|
+
// onDragEnter={handleDragEnter}
|
|
510
|
+
// onDragLeave={handleDragLeave}
|
|
511
|
+
// onDragOver={handleDragOver}
|
|
512
|
+
// onDrop={handleDrop}
|
|
513
|
+
// onClick={handleClick}
|
|
514
|
+
// >
|
|
515
|
+
// <div className="_upload_label">
|
|
516
|
+
// <div className="_upload_icon" style={{
|
|
517
|
+
// fontSize: '2.4rem',
|
|
518
|
+
// color: isDragOver ? 'var(--primary600)' : 'var(--primary)',
|
|
519
|
+
// marginBottom: '0.5rem',
|
|
520
|
+
// transition: 'color 0.3s ease',
|
|
521
|
+
// transform: isDragOver ? 'translateY(-2px)' : 'none'
|
|
522
|
+
// }}>
|
|
523
|
+
// {icon || <PiCloudArrowUp />}
|
|
524
|
+
// </div>
|
|
525
|
+
// <div className="_upload_text fit">
|
|
526
|
+
// <Text
|
|
527
|
+
// text={isDragOver ? 'Drop files to upload' : fileName || label}
|
|
528
|
+
// truncate={1}
|
|
529
|
+
// block
|
|
530
|
+
// style={{
|
|
531
|
+
// color: isDragOver ? 'var(--primary600)' : 'var(--text-color)',
|
|
532
|
+
// fontWeight: isDragOver ? '600' : '400'
|
|
533
|
+
// }}
|
|
534
|
+
// />
|
|
535
|
+
// </div>
|
|
536
|
+
// {/* Drag overlay indicator */}
|
|
537
|
+
// {isDragOver && (
|
|
538
|
+
// <div style={{
|
|
539
|
+
// position: 'absolute',
|
|
540
|
+
// top: 0,
|
|
541
|
+
// left: 0,
|
|
542
|
+
// right: 0,
|
|
543
|
+
// bottom: 0,
|
|
544
|
+
// backgroundColor: 'var(--primary)',
|
|
545
|
+
// opacity: 0.1,
|
|
546
|
+
// borderRadius: '14px',
|
|
547
|
+
// pointerEvents: 'none'
|
|
548
|
+
// }} />
|
|
549
|
+
// )}
|
|
550
|
+
// {/* Drag hint text */}
|
|
551
|
+
// {!fileName && !isDragOver && (
|
|
552
|
+
// <div style={{
|
|
553
|
+
// marginTop: 'var(--space-3)',
|
|
554
|
+
// fontSize: '0.8rem',
|
|
555
|
+
// color: 'var(--text-muted)',
|
|
556
|
+
// opacity: 0.7
|
|
557
|
+
// }}>
|
|
558
|
+
// Click or drag files to upload
|
|
559
|
+
// </div>
|
|
560
|
+
// )}
|
|
561
|
+
// {extra && <div className="text-small opacity-3" style={{ marginTop: 'var(--space-2)' }}>{extra}</div>}
|
|
562
|
+
// </div>
|
|
563
|
+
// <input
|
|
564
|
+
// ref={inputRef}
|
|
565
|
+
// onChange={handleChange}
|
|
566
|
+
// type="file"
|
|
567
|
+
// id={id}
|
|
568
|
+
// name={name}
|
|
569
|
+
// className="_upload_input"
|
|
570
|
+
// value={value}
|
|
571
|
+
// accept={accept}
|
|
572
|
+
// multiple={multiple}
|
|
573
|
+
// {...rest}
|
|
574
|
+
// />
|
|
575
|
+
// {renderFileInfo()}
|
|
576
|
+
// {helperText && (
|
|
577
|
+
// <div className={`input-helper-text ${status ? `helper-${status}` : ''}`} style={{ marginTop: 'var(--space-3)' }}>
|
|
578
|
+
// <span>{helperText}</span>
|
|
579
|
+
// </div>
|
|
580
|
+
// )}
|
|
581
|
+
// </div>
|
|
582
|
+
// );
|
|
583
|
+
// };
|
|
584
|
+
// export default FileUpload;
|
package/ui/input/Input.d.ts
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ChangeEvent, FocusEvent, MouseEvent, KeyboardEvent, FormEvent } from 'react';
|
|
2
2
|
interface BaseInputProps {
|
|
3
3
|
id?: string;
|
|
4
4
|
name?: string;
|
|
5
5
|
value?: any;
|
|
6
6
|
defaultValue?: string;
|
|
7
|
-
onChange?: (event:
|
|
8
|
-
|
|
7
|
+
onChange?: (event: ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
8
|
+
onBlur?: (event: FocusEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
9
|
+
onFocus?: (event: FocusEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
10
|
+
onClick?: (event: MouseEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
11
|
+
onKeyDown?: (event: KeyboardEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
12
|
+
onKeyUp?: (event: KeyboardEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
13
|
+
onKeyPress?: (event: KeyboardEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
14
|
+
onSubmit?: (event: FormEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
15
|
+
type?: string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
autoFocus?: boolean;
|
|
21
|
+
autoComplete?: string;
|
|
22
|
+
pattern?: string;
|
|
23
|
+
minLength?: number;
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
min?: string | number;
|
|
26
|
+
max?: string | number;
|
|
27
|
+
step?: string | number;
|
|
28
|
+
multiple?: boolean;
|
|
29
|
+
accept?: string;
|
|
30
|
+
size?: number;
|
|
31
|
+
form?: string;
|
|
32
|
+
formNoValidate?: boolean;
|
|
33
|
+
formTarget?: string;
|
|
34
|
+
list?: string;
|
|
35
|
+
autoCapitalize?: 'on' | 'off' | 'none' | 'sentences' | 'words' | 'characters';
|
|
36
|
+
autoCorrect?: 'on' | 'off';
|
|
37
|
+
spellCheck?: boolean | 'true' | 'false';
|
|
38
|
+
inputMode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
39
|
+
dirname?: string;
|
|
40
|
+
status?: 'success' | 'warning' | 'danger' | 'info';
|
|
9
41
|
funcss?: string;
|
|
10
42
|
bg?: string;
|
|
11
43
|
fullWidth?: boolean;
|
|
@@ -15,10 +47,10 @@ interface BaseInputProps {
|
|
|
15
47
|
rounded?: boolean;
|
|
16
48
|
leftRounded?: boolean;
|
|
17
49
|
rightRounded?: boolean;
|
|
18
|
-
startIcon?: React.ReactNode;
|
|
19
|
-
endIcon?: React.ReactNode;
|
|
20
|
-
prefix?: React.ReactNode;
|
|
21
|
-
suffix?: React.ReactNode;
|
|
50
|
+
startIcon?: string | React.ReactNode;
|
|
51
|
+
endIcon?: string | React.ReactNode;
|
|
52
|
+
prefix?: string | React.ReactNode;
|
|
53
|
+
suffix?: string | React.ReactNode;
|
|
22
54
|
stringPrefix?: string;
|
|
23
55
|
stringSuffix?: string;
|
|
24
56
|
iconicBg?: string;
|
|
@@ -38,19 +70,16 @@ interface SelectProps extends BaseInputProps {
|
|
|
38
70
|
}
|
|
39
71
|
interface TextareaProps extends BaseInputProps {
|
|
40
72
|
rows?: number;
|
|
73
|
+
cols?: number;
|
|
74
|
+
wrap?: 'hard' | 'soft' | 'off';
|
|
41
75
|
}
|
|
42
|
-
export declare const TextInput: React.FC<TextInputProps
|
|
43
|
-
export declare const SelectInput: React.FC<SelectProps
|
|
44
|
-
export declare const TextareaInput: React.FC<TextareaProps
|
|
76
|
+
export declare const TextInput: React.FC<TextInputProps>;
|
|
77
|
+
export declare const SelectInput: React.FC<SelectProps>;
|
|
78
|
+
export declare const TextareaInput: React.FC<TextareaProps>;
|
|
45
79
|
interface InputProps extends BaseInputProps {
|
|
46
80
|
select?: boolean;
|
|
47
81
|
multiline?: boolean;
|
|
48
|
-
file?: boolean;
|
|
49
82
|
noBorder?: boolean;
|
|
50
|
-
icon?: React.ReactNode;
|
|
51
|
-
extra?: React.ReactNode;
|
|
52
|
-
button?: React.ReactNode;
|
|
53
|
-
btn?: boolean;
|
|
54
83
|
type?: string;
|
|
55
84
|
options?: SelectOption[];
|
|
56
85
|
rows?: number;
|