dhanasekar-ui 1.2.0 → 1.4.0
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-2CO3UUBT.js +170 -0
- package/dist/chunk-2CO3UUBT.js.map +1 -0
- package/dist/chunk-3HGMPMXD.js +61 -0
- package/dist/chunk-3HGMPMXD.js.map +1 -0
- package/dist/chunk-46U234GX.mjs +42 -0
- package/dist/chunk-46U234GX.mjs.map +1 -0
- package/dist/chunk-5FU43BWK.mjs +121 -0
- package/dist/chunk-5FU43BWK.mjs.map +1 -0
- package/dist/chunk-7XVF6WPJ.js +108 -0
- package/dist/chunk-7XVF6WPJ.js.map +1 -0
- package/dist/{chunk-GNMGJBBO.mjs → chunk-AK3NQBYU.mjs} +3 -3
- package/dist/chunk-AK3NQBYU.mjs.map +1 -0
- package/dist/chunk-ALCHPZY6.js +149 -0
- package/dist/chunk-ALCHPZY6.js.map +1 -0
- package/dist/chunk-BNBEIMM2.mjs +61 -0
- package/dist/chunk-BNBEIMM2.mjs.map +1 -0
- package/dist/chunk-BQVXQWPS.mjs +129 -0
- package/dist/chunk-BQVXQWPS.mjs.map +1 -0
- package/dist/chunk-DBSBLGGH.js +40 -0
- package/dist/chunk-DBSBLGGH.js.map +1 -0
- package/dist/chunk-DVDVLGDJ.js +121 -0
- package/dist/chunk-DVDVLGDJ.js.map +1 -0
- package/dist/chunk-EN76JE3Y.js +64 -0
- package/dist/chunk-EN76JE3Y.js.map +1 -0
- package/dist/chunk-FLTDFXE3.mjs +170 -0
- package/dist/chunk-FLTDFXE3.mjs.map +1 -0
- package/dist/chunk-GSRVWW2G.mjs +177 -0
- package/dist/chunk-GSRVWW2G.mjs.map +1 -0
- package/dist/chunk-GZGTDLFV.js +72 -0
- package/dist/chunk-GZGTDLFV.js.map +1 -0
- package/dist/chunk-HGGQFNUJ.mjs +2 -0
- package/dist/chunk-HGGQFNUJ.mjs.map +1 -0
- package/dist/chunk-HWD2HCCH.js +129 -0
- package/dist/chunk-HWD2HCCH.js.map +1 -0
- package/dist/chunk-I6OJHQZX.mjs +2 -0
- package/dist/chunk-I6OJHQZX.mjs.map +1 -0
- package/dist/chunk-ISHUTZ36.js +42 -0
- package/dist/chunk-ISHUTZ36.js.map +1 -0
- package/dist/chunk-JC4TJWCY.mjs +97 -0
- package/dist/chunk-JC4TJWCY.mjs.map +1 -0
- package/dist/chunk-JM6DZDO3.js +87 -0
- package/dist/chunk-JM6DZDO3.js.map +1 -0
- package/dist/chunk-KUXDQANJ.mjs +72 -0
- package/dist/chunk-KUXDQANJ.mjs.map +1 -0
- package/dist/chunk-LIBHUJ27.js +2 -0
- package/dist/chunk-LIBHUJ27.js.map +1 -0
- package/dist/chunk-MALTBURB.mjs +64 -0
- package/dist/chunk-MALTBURB.mjs.map +1 -0
- package/dist/chunk-MLURKSJZ.js +2 -0
- package/dist/chunk-MLURKSJZ.js.map +1 -0
- package/dist/chunk-MOC6N23X.mjs +151 -0
- package/dist/chunk-MOC6N23X.mjs.map +1 -0
- package/dist/chunk-P5HHRCE5.js +198 -0
- package/dist/chunk-P5HHRCE5.js.map +1 -0
- package/dist/chunk-PL2R3LYL.mjs +198 -0
- package/dist/chunk-PL2R3LYL.mjs.map +1 -0
- package/dist/chunk-PPQ7NSV3.js +97 -0
- package/dist/chunk-PPQ7NSV3.js.map +1 -0
- package/dist/chunk-T3YOHFUU.js +177 -0
- package/dist/chunk-T3YOHFUU.js.map +1 -0
- package/dist/chunk-UCFS7EH2.mjs +40 -0
- package/dist/chunk-UCFS7EH2.mjs.map +1 -0
- package/dist/chunk-ULMQZANW.mjs +87 -0
- package/dist/chunk-ULMQZANW.mjs.map +1 -0
- package/dist/chunk-UYHBKE7G.mjs +108 -0
- package/dist/chunk-UYHBKE7G.mjs.map +1 -0
- package/dist/chunk-W5B5N6BW.mjs +149 -0
- package/dist/chunk-W5B5N6BW.mjs.map +1 -0
- package/dist/{chunk-6SVKDKK7.mjs → chunk-XWEEWNZK.mjs} +4 -4
- package/dist/chunk-XWEEWNZK.mjs.map +1 -0
- package/dist/{chunk-3RAQQWLW.js → chunk-YPMUFP2I.js} +4 -4
- package/dist/chunk-YPMUFP2I.js.map +1 -0
- package/dist/chunk-ZMB4U5RP.js +151 -0
- package/dist/chunk-ZMB4U5RP.js.map +1 -0
- package/dist/{chunk-2TXYJ7YE.js → chunk-ZPJSBORX.js} +3 -3
- package/dist/chunk-ZPJSBORX.js.map +1 -0
- package/dist/components/AppBar/index.d.mts +89 -0
- package/dist/components/AppBar/index.d.ts +89 -0
- package/dist/components/AppBar/index.js +2 -0
- package/dist/components/AppBar/index.js.map +1 -0
- package/dist/components/AppBar/index.mjs +2 -0
- package/dist/components/AppBar/index.mjs.map +1 -0
- package/dist/components/Box/index.d.mts +28 -0
- package/dist/components/Box/index.d.ts +28 -0
- package/dist/components/Box/index.js +2 -0
- package/dist/components/Box/index.js.map +1 -0
- package/dist/components/Box/index.mjs +2 -0
- package/dist/components/Box/index.mjs.map +1 -0
- package/dist/components/Container/index.d.mts +71 -0
- package/dist/components/Container/index.d.ts +71 -0
- package/dist/components/Container/index.js +2 -0
- package/dist/components/Container/index.js.map +1 -0
- package/dist/components/Container/index.mjs +2 -0
- package/dist/components/Container/index.mjs.map +1 -0
- package/dist/components/DateFilter/index.d.mts +8 -1
- package/dist/components/DateFilter/index.d.ts +8 -1
- package/dist/components/DateFilter/index.js +1 -1
- package/dist/components/DateFilter/index.mjs +1 -1
- package/dist/components/FileUploadField/index.d.mts +4 -2
- package/dist/components/FileUploadField/index.d.ts +4 -2
- package/dist/components/FileUploadField/index.js +1 -1
- package/dist/components/FileUploadField/index.mjs +1 -1
- package/dist/components/FormLayout/index.d.mts +8 -2
- package/dist/components/FormLayout/index.d.ts +8 -2
- package/dist/components/FormLayout/index.js +1 -1
- package/dist/components/FormLayout/index.mjs +1 -1
- package/dist/components/Grid/index.d.mts +48 -0
- package/dist/components/Grid/index.d.ts +48 -0
- package/dist/components/Grid/index.js +2 -0
- package/dist/components/Grid/index.js.map +1 -0
- package/dist/components/Grid/index.mjs +2 -0
- package/dist/components/Grid/index.mjs.map +1 -0
- package/dist/components/List/index.d.mts +98 -0
- package/dist/components/List/index.d.ts +98 -0
- package/dist/components/List/index.js +2 -0
- package/dist/components/List/index.js.map +1 -0
- package/dist/components/List/index.mjs +2 -0
- package/dist/components/List/index.mjs.map +1 -0
- package/dist/components/Navigator/index.d.mts +87 -0
- package/dist/components/Navigator/index.d.ts +87 -0
- package/dist/components/Navigator/index.js +2 -0
- package/dist/components/Navigator/index.js.map +1 -0
- package/dist/components/Navigator/index.mjs +2 -0
- package/dist/components/Navigator/index.mjs.map +1 -0
- package/dist/components/Pagination/index.d.mts +89 -0
- package/dist/components/Pagination/index.d.ts +89 -0
- package/dist/components/Pagination/index.js +2 -0
- package/dist/components/Pagination/index.js.map +1 -0
- package/dist/components/Pagination/index.mjs +2 -0
- package/dist/components/Pagination/index.mjs.map +1 -0
- package/dist/components/PdfImageUpload/index.d.mts +30 -0
- package/dist/components/PdfImageUpload/index.d.ts +30 -0
- package/dist/components/PdfImageUpload/index.js +2 -0
- package/dist/components/PdfImageUpload/index.js.map +1 -0
- package/dist/components/PdfImageUpload/index.mjs +2 -0
- package/dist/components/PdfImageUpload/index.mjs.map +1 -0
- package/dist/components/Progress/index.d.mts +52 -0
- package/dist/components/Progress/index.d.ts +52 -0
- package/dist/components/Progress/index.js +2 -0
- package/dist/components/Progress/index.js.map +1 -0
- package/dist/components/Progress/index.mjs +2 -0
- package/dist/components/Progress/index.mjs.map +1 -0
- package/dist/components/RadioGroup/index.d.mts +99 -0
- package/dist/components/RadioGroup/index.d.ts +99 -0
- package/dist/components/RadioGroup/index.js +2 -0
- package/dist/components/RadioGroup/index.js.map +1 -0
- package/dist/components/RadioGroup/index.mjs +2 -0
- package/dist/components/RadioGroup/index.mjs.map +1 -0
- package/dist/components/Skeleton/index.d.mts +45 -0
- package/dist/components/Skeleton/index.d.ts +45 -0
- package/dist/components/Skeleton/index.js +2 -0
- package/dist/components/Skeleton/index.js.map +1 -0
- package/dist/components/Skeleton/index.mjs +2 -0
- package/dist/components/Skeleton/index.mjs.map +1 -0
- package/dist/components/Slider/index.d.mts +181 -0
- package/dist/components/Slider/index.d.ts +181 -0
- package/dist/components/Slider/index.js +2 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Slider/index.mjs +2 -0
- package/dist/components/Slider/index.mjs.map +1 -0
- package/dist/components/Snackbar/index.d.mts +80 -0
- package/dist/components/Snackbar/index.d.ts +80 -0
- package/dist/components/Snackbar/index.js +2 -0
- package/dist/components/Snackbar/index.js.map +1 -0
- package/dist/components/Snackbar/index.mjs +2 -0
- package/dist/components/Snackbar/index.mjs.map +1 -0
- package/dist/components/Text/index.d.mts +2 -1
- package/dist/components/Text/index.d.ts +2 -1
- package/dist/components/ToolBar/index.d.mts +60 -0
- package/dist/components/ToolBar/index.d.ts +60 -0
- package/dist/components/ToolBar/index.js +2 -0
- package/dist/components/ToolBar/index.js.map +1 -0
- package/dist/components/ToolBar/index.mjs +2 -0
- package/dist/components/ToolBar/index.mjs.map +1 -0
- package/dist/components/Tray/index.d.mts +140 -0
- package/dist/components/Tray/index.d.ts +140 -0
- package/dist/components/Tray/index.js +2 -0
- package/dist/components/Tray/index.js.map +1 -0
- package/dist/components/Tray/index.mjs +2 -0
- package/dist/components/Tray/index.mjs.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/types-BJWJOB_w.d.mts +5 -0
- package/dist/types-BJWJOB_w.d.ts +5 -0
- package/package.json +84 -2
- package/dist/chunk-2TXYJ7YE.js.map +0 -1
- package/dist/chunk-3RAQQWLW.js.map +0 -1
- package/dist/chunk-6SVKDKK7.mjs.map +0 -1
- package/dist/chunk-GNMGJBBO.mjs.map +0 -1
- package/dist/chunk-ZEMR63S4.js +0 -198
- package/dist/chunk-ZEMR63S4.js.map +0 -1
- package/dist/chunk-ZY5AHZYZ.mjs +0 -198
- package/dist/chunk-ZY5AHZYZ.mjs.map +0 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use strict';var chunkMLURKSJZ_js=require('./chunk-MLURKSJZ.js'),react=require('react'),reactToastify=require('react-toastify'),jsxRuntime=require('react/jsx-runtime');var J=`
|
|
2
|
+
.fuf-root {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 8px;
|
|
6
|
+
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.fuf-label {
|
|
11
|
+
font-size: 14px;
|
|
12
|
+
font-weight: 500;
|
|
13
|
+
color: #64748b;
|
|
14
|
+
margin-bottom: 4px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.fuf-label.error {
|
|
18
|
+
color: #ef4444;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.fuf-required {
|
|
22
|
+
color: #ef4444;
|
|
23
|
+
margin-left: 2px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.fuf-dropzone {
|
|
27
|
+
border: 2px dashed #cbd5e1;
|
|
28
|
+
border-radius: 12px;
|
|
29
|
+
padding: 32px;
|
|
30
|
+
text-align: center;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
33
|
+
background: #f8fafc;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: 8px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.fuf-dropzone:hover {
|
|
41
|
+
border-color: #3b82f6;
|
|
42
|
+
background: #eff6ff;
|
|
43
|
+
transform: translateY(-1px);
|
|
44
|
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fuf-dropzone.error {
|
|
48
|
+
border-color: #ef4444;
|
|
49
|
+
background: #fef2f2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.fuf-dropzone.error:hover {
|
|
53
|
+
border-color: #dc2626;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.fuf-dropzone.disabled {
|
|
57
|
+
cursor: not-allowed;
|
|
58
|
+
opacity: 0.6;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.fuf-dropzone.disabled:hover {
|
|
62
|
+
transform: none;
|
|
63
|
+
box-shadow: none;
|
|
64
|
+
border-color: #cbd5e1;
|
|
65
|
+
background: #f8fafc;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.fuf-upload-icon {
|
|
69
|
+
color: #3b82f6;
|
|
70
|
+
font-size: 48px;
|
|
71
|
+
margin-bottom: 8px;
|
|
72
|
+
display: block;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.fuf-dropzone.error .fuf-upload-icon {
|
|
76
|
+
color: #ef4444;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.fuf-upload-text {
|
|
80
|
+
font-size: 16px;
|
|
81
|
+
font-weight: 500;
|
|
82
|
+
color: #334155;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.fuf-format-text {
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
color: #94a3b8;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.fuf-preview-list {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: 8px;
|
|
94
|
+
margin-top: 8px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.fuf-preview-item {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: space-between;
|
|
101
|
+
padding: 12px 16px;
|
|
102
|
+
background: white;
|
|
103
|
+
border: 1px solid #e2e8f0;
|
|
104
|
+
border-radius: 12px;
|
|
105
|
+
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
|
106
|
+
transition: all 0.2s ease;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.fuf-preview-item:hover {
|
|
110
|
+
border-color: #cbd5e1;
|
|
111
|
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.fuf-file-info {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: 12px;
|
|
118
|
+
min-width: 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.fuf-thumbnail {
|
|
122
|
+
width: 40px;
|
|
123
|
+
height: 40px;
|
|
124
|
+
object-fit: cover;
|
|
125
|
+
border-radius: 8px;
|
|
126
|
+
border: 1px solid #f1f5f9;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.fuf-file-icon {
|
|
130
|
+
font-size: 24px;
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.fuf-file-icon.pdf {
|
|
137
|
+
color: #ef4444;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.fuf-file-icon.general {
|
|
141
|
+
color: #3b82f6;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.fuf-file-name {
|
|
145
|
+
font-size: 14px;
|
|
146
|
+
color: #1e293b;
|
|
147
|
+
font-weight: 500;
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
text-overflow: ellipsis;
|
|
151
|
+
max-width: 240px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.fuf-actions {
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
gap: 4px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.fuf-action-btn {
|
|
161
|
+
padding: 8px;
|
|
162
|
+
border-radius: 8px;
|
|
163
|
+
border: none;
|
|
164
|
+
background: transparent;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
justify-content: center;
|
|
169
|
+
transition: all 0.2s ease;
|
|
170
|
+
color: #64748b;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.fuf-action-btn i {
|
|
174
|
+
font-size: 18px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.fuf-action-btn.view:hover {
|
|
178
|
+
color: #3b82f6;
|
|
179
|
+
background: #eff6ff;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.fuf-action-btn.remove:hover {
|
|
183
|
+
color: #ef4444;
|
|
184
|
+
background: #fef2f2;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.fuf-error-message {
|
|
188
|
+
font-size: 12px;
|
|
189
|
+
color: #ef4444;
|
|
190
|
+
margin-top: 4px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.fuf-hidden-input {
|
|
194
|
+
display: none;
|
|
195
|
+
}
|
|
196
|
+
`,K=react.forwardRef((C,E)=>{let{label:N,required:I,error:d,accept:k=".pdf,.doc,.docx",maxSizeMB:U=10,disabled:c,uploadType:j,multiple:u,value:l,onChange:m,onDelete:z,previewUrl:$,previewUrls:R,existingFileUrl:b,existingFileName:y,editMode:M=true,viewMode:P=false,className:S="",style:T,sx:O}=C;react.useEffect(()=>{let e="tabler-icons-cdn";if(!document.getElementById(e)){let t=document.createElement("link");t.id=e,t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css",document.head.appendChild(t);}},[]);let p=Array.isArray(b)?b:b?[b]:[],H=Array.isArray(l)?l:l?[l]:[],w=[...p,...H],g=c||P||!M,F=react.useRef(null);react.useImperativeHandle(E,()=>F.current);let[s,x]=react.useState([]);react.useEffect(()=>()=>{s.forEach(e=>{e.startsWith("blob:")&&URL.revokeObjectURL(e);});},[s]);let W=e=>{if(g)return;let t=e.target.files;if(!t||t.length===0)return;let f=Array.from(t),i=[],r=[];for(let n of f){if(n.size>U*1024*1024){reactToastify.toast.error(`File "${n.name}" exceeds the maximum size of ${U}MB`);continue}i.push(n),r.push(URL.createObjectURL(n));}if(i.length===0){e.target.value="";return}if(u){x(v=>[...v,...r]);let h=[...Array.isArray(l)?l:[],...i];m?.(h);}else s[0]?.startsWith("blob:")&&URL.revokeObjectURL(s[0]),x(r),m?.(i[0]);e.target.value="";},q=e=>{if(g)return;if(e<p.length){z?.(e);return}let f=e-p.length;if(u){let i=Array.isArray(l)?[...l]:[];i.splice(f,1),m?.(i.length>0?i:null);let r=[...s];r[f]?.startsWith("blob:")&&URL.revokeObjectURL(r[f]),r.splice(f,1),x(r);}else m?.(null),s[0]?.startsWith("blob:")&&URL.revokeObjectURL(s[0]),x([]);z?.(e);},B=(e,t)=>{t<p.length;let i=typeof e=="string"?(Array.isArray(y)?y[t]:y)||"Uploaded Document":e.name,r=t-p.length,n=typeof e=="string"?e:s[r]||(Array.isArray(R)?R[r]:$),h=i.toLowerCase().endsWith(".pdf")||typeof e!="string"&&e.type==="application/pdf",v=j==="image"||i.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/i);return jsxRuntime.jsxs("div",{className:"fuf-preview-item",children:[jsxRuntime.jsxs("div",{className:"fuf-file-info",children:[v&&n?jsxRuntime.jsx("img",{className:"fuf-thumbnail",src:n,alt:i}):h?jsxRuntime.jsx("i",{className:"ti ti-file-type-pdf fuf-file-icon pdf"}):jsxRuntime.jsx("i",{className:"ti ti-file fuf-file-icon general"}),jsxRuntime.jsx("span",{className:"fuf-file-name",title:i,children:i})]}),jsxRuntime.jsxs("div",{className:"fuf-actions",children:[(h||v)&&n&&jsxRuntime.jsx("button",{type:"button",className:"fuf-action-btn view",onClick:()=>window.open(n,"_blank"),title:"View",children:jsxRuntime.jsx("i",{className:"ti ti-eye"})}),!g&&jsxRuntime.jsx("button",{type:"button",className:"fuf-action-btn remove",onClick:()=>q(t),title:"Remove",children:jsxRuntime.jsx("i",{className:"ti ti-x"})})]})]},`${i}-${t}`)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:J}}),jsxRuntime.jsxs("div",{className:`fuf-root ${S}`,style:{...chunkMLURKSJZ_js.a(O),...T},children:[N&&jsxRuntime.jsxs("label",{className:`fuf-label ${d?"error":""}`,children:[N," ",I&&jsxRuntime.jsx("span",{className:"fuf-required",children:"*"})]}),(!w.length||u)&&!g&&jsxRuntime.jsxs("div",{className:`fuf-dropzone ${d?"error":""} ${c?"disabled":""}`,onClick:()=>!c&&F.current?.click(),children:[jsxRuntime.jsx("i",{className:"ti ti-upload fuf-upload-icon"}),jsxRuntime.jsx("span",{className:"fuf-upload-text",children:c?"Upload disabled":"Click to upload"}),jsxRuntime.jsxs("span",{className:"fuf-format-text",children:["(Supported formats: ",k.replace(/\./g,"").toUpperCase(),")"]}),jsxRuntime.jsx("input",{type:"file",className:"fuf-hidden-input",ref:F,onChange:W,accept:k,disabled:c,multiple:u})]}),w.length>0&&jsxRuntime.jsx("div",{className:"fuf-preview-list",children:w.map((e,t)=>B(e,t))}),d&&jsxRuntime.jsx("span",{className:"fuf-error-message",children:d})]})]})});K.displayName="FileUploadField";
|
|
197
|
+
exports.a=K;//# sourceMappingURL=chunk-P5HHRCE5.js.map
|
|
198
|
+
//# sourceMappingURL=chunk-P5HHRCE5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/FileUploadField/FileUploadField.tsx"],"names":["STYLES","FileUploadField","forwardRef","props","ref","label","required","error","accept","maxSizeMB","disabled","uploadType","multiple","value","onChange","onDelete","previewUrl","previewUrls","existingFileUrl","existingFileName","editMode","viewMode","className","style","sx","useEffect","cdnId","link","existingFiles","currentFiles","filesToRender","isReadOnly","inputRef","useRef","useImperativeHandle","internalPreviews","setInternalPreviews","useState","url","handleFileChange","files","fileList","validFiles","newPreviews","file","toast","prev","updatedFiles","handleRemove","index","currentFileIndex","currentPreviews","renderFileRow","fileName","fileUrl","isPdf","isImage","jsxs","jsx","Fragment","handleSx","idx"],"mappings":"wKAOA,IAAMA,CAAAA,CAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA,CAAA,CAwMFC,EAAkB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F,CAEJ,CAAC,EAEDN,EAAgB,WAAA,CAAc,iBAAA","file":"chunk-P5HHRCE5.js","sourcesContent":["'use client';\n\nimport React, { forwardRef, useImperativeHandle, useRef, useState, useEffect } from 'react';\nimport { toast } from 'react-toastify';\nimport { handleSx } from '../../utils/handleSx';\nimport { FileUploadFieldProps } from './FileUploadField.types';\n\nconst STYLES = `\n .fuf-root {\n display: flex;\n flex-direction: column;\n gap: 8px;\n font-family: 'Inter', system-ui, -apple-system, sans-serif;\n width: 100%;\n }\n\n .fuf-label {\n font-size: 14px;\n font-weight: 500;\n color: #64748b;\n margin-bottom: 4px;\n }\n\n .fuf-label.error {\n color: #ef4444;\n }\n\n .fuf-required {\n color: #ef4444;\n margin-left: 2px;\n }\n\n .fuf-dropzone {\n border: 2px dashed #cbd5e1;\n border-radius: 12px;\n padding: 32px;\n text-align: center;\n cursor: pointer;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n background: #f8fafc;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n }\n\n .fuf-dropzone:hover {\n border-color: #3b82f6;\n background: #eff6ff;\n transform: translateY(-1px);\n box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n }\n\n .fuf-dropzone.error {\n border-color: #ef4444;\n background: #fef2f2;\n }\n\n .fuf-dropzone.error:hover {\n border-color: #dc2626;\n }\n\n .fuf-dropzone.disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n\n .fuf-dropzone.disabled:hover {\n transform: none;\n box-shadow: none;\n border-color: #cbd5e1;\n background: #f8fafc;\n }\n\n .fuf-upload-icon {\n color: #3b82f6;\n font-size: 48px;\n margin-bottom: 8px;\n display: block;\n }\n\n .fuf-dropzone.error .fuf-upload-icon {\n color: #ef4444;\n }\n\n .fuf-upload-text {\n font-size: 16px;\n font-weight: 500;\n color: #334155;\n }\n\n .fuf-format-text {\n font-size: 12px;\n color: #94a3b8;\n }\n\n .fuf-preview-list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: 8px;\n }\n\n .fuf-preview-item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 16px;\n background: white;\n border: 1px solid #e2e8f0;\n border-radius: 12px;\n box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);\n transition: all 0.2s ease;\n }\n\n .fuf-preview-item:hover {\n border-color: #cbd5e1;\n box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);\n }\n\n .fuf-file-info {\n display: flex;\n align-items: center;\n gap: 12px;\n min-width: 0;\n }\n\n .fuf-thumbnail {\n width: 40px;\n height: 40px;\n object-fit: cover;\n border-radius: 8px;\n border: 1px solid #f1f5f9;\n }\n\n .fuf-file-icon {\n font-size: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .fuf-file-icon.pdf {\n color: #ef4444;\n }\n\n .fuf-file-icon.general {\n color: #3b82f6;\n }\n\n .fuf-file-name {\n font-size: 14px;\n color: #1e293b;\n font-weight: 500;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 240px;\n }\n\n .fuf-actions {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .fuf-action-btn {\n padding: 8px;\n border-radius: 8px;\n border: none;\n background: transparent;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n color: #64748b;\n }\n\n .fuf-action-btn i {\n font-size: 18px;\n }\n\n .fuf-action-btn.view:hover {\n color: #3b82f6;\n background: #eff6ff;\n }\n\n .fuf-action-btn.remove:hover {\n color: #ef4444;\n background: #fef2f2;\n }\n\n .fuf-error-message {\n font-size: 12px;\n color: #ef4444;\n margin-top: 4px;\n }\n\n .fuf-hidden-input {\n display: none;\n }\n`;\n\n/**\n * FileUploadField component for single or multiple file uploads with preview support.\n */\nexport const FileUploadField = forwardRef<HTMLInputElement, FileUploadFieldProps>((props, ref) => {\n const {\n label,\n required,\n error,\n accept = '.pdf,.doc,.docx',\n maxSizeMB = 10,\n disabled,\n uploadType,\n multiple,\n value,\n onChange,\n onDelete,\n previewUrl,\n previewUrls,\n existingFileUrl,\n existingFileName,\n editMode = true,\n viewMode = false,\n className = '',\n style,\n sx,\n } = props;\n\n // Inject Tabler Icons CDN if not present\n useEffect(() => {\n const cdnId = 'tabler-icons-cdn';\n if (!document.getElementById(cdnId)) {\n const link = document.createElement('link');\n link.id = cdnId;\n link.rel = 'stylesheet';\n link.href = 'https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css';\n document.head.appendChild(link);\n }\n }, []);\n\n const existingFiles = Array.isArray(existingFileUrl)\n ? existingFileUrl\n : existingFileUrl ? [existingFileUrl] : [];\n\n const currentFiles = Array.isArray(value)\n ? value\n : value ? [value] : [];\n\n const filesToRender = [...existingFiles, ...currentFiles];\n const isReadOnly = disabled || viewMode || !editMode;\n\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current!);\n\n const [internalPreviews, setInternalPreviews] = useState<string[]>([]);\n\n // Cleanup object URLs on unmount\n useEffect(() => {\n return () => {\n internalPreviews.forEach((url) => {\n if (url.startsWith('blob:')) {\n URL.revokeObjectURL(url);\n }\n });\n };\n }, [internalPreviews]);\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (isReadOnly) return;\n const files = e.target.files;\n if (!files || files.length === 0) return;\n\n const fileList = Array.from(files);\n const validFiles: File[] = [];\n const newPreviews: string[] = [];\n\n for (const file of fileList) {\n if (file.size > maxSizeMB * 1024 * 1024) {\n toast.error(`File \"${file.name}\" exceeds the maximum size of ${maxSizeMB}MB`);\n continue;\n }\n validFiles.push(file);\n newPreviews.push(URL.createObjectURL(file));\n }\n\n if (validFiles.length === 0) {\n e.target.value = '';\n return;\n }\n\n if (multiple) {\n setInternalPreviews((prev) => [...prev, ...newPreviews]);\n const currentFiles = Array.isArray(value) ? value : [];\n const updatedFiles = [...currentFiles, ...validFiles];\n (onChange as (files: File[] | null) => void)?.(updatedFiles);\n } else {\n if (internalPreviews[0]?.startsWith('blob:')) {\n URL.revokeObjectURL(internalPreviews[0]);\n }\n setInternalPreviews(newPreviews);\n (onChange as (file: File | null) => void)?.(validFiles[0]);\n }\n\n e.target.value = '';\n };\n\n const handleRemove = (index: number) => {\n if (isReadOnly) return;\n\n const isExisting = index < existingFiles.length;\n if (isExisting) {\n onDelete?.(index);\n return;\n }\n\n const currentFileIndex = index - existingFiles.length;\n\n if (multiple) {\n const currentFiles = Array.isArray(value) ? [...value] : [];\n currentFiles.splice(currentFileIndex, 1);\n (onChange as (files: File[] | null) => void)?.(currentFiles.length > 0 ? currentFiles : null);\n\n const currentPreviews = [...internalPreviews];\n if (currentPreviews[currentFileIndex]?.startsWith('blob:')) {\n URL.revokeObjectURL(currentPreviews[currentFileIndex]);\n }\n currentPreviews.splice(currentFileIndex, 1);\n setInternalPreviews(currentPreviews);\n } else {\n (onChange as (file: File | null) => void)?.(null);\n if (internalPreviews[0]?.startsWith('blob:')) {\n URL.revokeObjectURL(internalPreviews[0]);\n }\n setInternalPreviews([]);\n }\n onDelete?.(index);\n };\n\n const renderFileRow = (file: File | string, index: number) => {\n const isExisting = index < existingFiles.length;\n const fileName = typeof file === 'string'\n ? (Array.isArray(existingFileName) ? existingFileName[index] : existingFileName) || 'Uploaded Document'\n : file.name;\n\n const currentFileIndex = index - existingFiles.length;\n const fileUrl = typeof file === 'string'\n ? file\n : internalPreviews[currentFileIndex] || (Array.isArray(previewUrls) ? previewUrls[currentFileIndex] : previewUrl);\n\n const isPdf = fileName.toLowerCase().endsWith('.pdf') || (typeof file !== 'string' && file.type === 'application/pdf');\n const isImage = uploadType === 'image' || fileName.toLowerCase().match(/\\.(jpg|jpeg|png|gif|webp)$/i);\n\n return (\n <div className=\"fuf-preview-item\" key={`${fileName}-${index}`}>\n <div className=\"fuf-file-info\">\n {isImage && fileUrl ? (\n <img className=\"fuf-thumbnail\" src={fileUrl} alt={fileName} />\n ) : isPdf ? (\n <i className=\"ti ti-file-type-pdf fuf-file-icon pdf\"></i>\n ) : (\n <i className=\"ti ti-file fuf-file-icon general\"></i>\n )}\n <span className=\"fuf-file-name\" title={fileName}>\n {fileName}\n </span>\n </div>\n <div className=\"fuf-actions\">\n {(isPdf || isImage) && fileUrl && (\n <button\n type=\"button\"\n className=\"fuf-action-btn view\"\n onClick={() => window.open(fileUrl, '_blank')}\n title=\"View\"\n >\n <i className=\"ti ti-eye\"></i>\n </button>\n )}\n {!isReadOnly && (\n <button\n type=\"button\"\n className=\"fuf-action-btn remove\"\n onClick={() => handleRemove(index)}\n title=\"Remove\"\n >\n <i className=\"ti ti-x\"></i>\n </button>\n )}\n </div>\n </div>\n );\n };\n\n return (\n <>\n <style dangerouslySetInnerHTML={{ __html: STYLES }} />\n <div className={`fuf-root ${className}`} style={{ ...handleSx(sx), ...style }}>\n {label && (\n <label className={`fuf-label ${error ? 'error' : ''}`}>\n {label} {required && <span className=\"fuf-required\">*</span>}\n </label>\n )}\n\n {(!filesToRender.length || multiple) && !isReadOnly && (\n <div\n className={`fuf-dropzone ${error ? 'error' : ''} ${disabled ? 'disabled' : ''}`}\n onClick={() => !disabled && inputRef.current?.click()}\n >\n <i className=\"ti ti-upload fuf-upload-icon\"></i>\n <span className=\"fuf-upload-text\">\n {disabled ? 'Upload disabled' : 'Click to upload'}\n </span>\n <span className=\"fuf-format-text\">\n (Supported formats: {accept.replace(/\\./g, '').toUpperCase()})\n </span>\n <input\n type=\"file\"\n className=\"fuf-hidden-input\"\n ref={inputRef}\n onChange={handleFileChange}\n accept={accept}\n disabled={disabled}\n multiple={multiple}\n />\n </div>\n )}\n\n {filesToRender.length > 0 && (\n <div className=\"fuf-preview-list\">\n {filesToRender.map((file, idx) => renderFileRow(file, idx))}\n </div>\n )}\n\n {error && (\n <span className=\"fuf-error-message\">\n {error}\n </span>\n )}\n </div>\n </>\n );\n});\n\nFileUploadField.displayName = 'FileUploadField';\n"]}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {a}from'./chunk-HGGQFNUJ.mjs';import {forwardRef,useEffect,useRef,useImperativeHandle,useState}from'react';import {toast}from'react-toastify';import {jsxs,Fragment,jsx}from'react/jsx-runtime';var J=`
|
|
2
|
+
.fuf-root {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 8px;
|
|
6
|
+
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.fuf-label {
|
|
11
|
+
font-size: 14px;
|
|
12
|
+
font-weight: 500;
|
|
13
|
+
color: #64748b;
|
|
14
|
+
margin-bottom: 4px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.fuf-label.error {
|
|
18
|
+
color: #ef4444;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.fuf-required {
|
|
22
|
+
color: #ef4444;
|
|
23
|
+
margin-left: 2px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.fuf-dropzone {
|
|
27
|
+
border: 2px dashed #cbd5e1;
|
|
28
|
+
border-radius: 12px;
|
|
29
|
+
padding: 32px;
|
|
30
|
+
text-align: center;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
33
|
+
background: #f8fafc;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: 8px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.fuf-dropzone:hover {
|
|
41
|
+
border-color: #3b82f6;
|
|
42
|
+
background: #eff6ff;
|
|
43
|
+
transform: translateY(-1px);
|
|
44
|
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fuf-dropzone.error {
|
|
48
|
+
border-color: #ef4444;
|
|
49
|
+
background: #fef2f2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.fuf-dropzone.error:hover {
|
|
53
|
+
border-color: #dc2626;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.fuf-dropzone.disabled {
|
|
57
|
+
cursor: not-allowed;
|
|
58
|
+
opacity: 0.6;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.fuf-dropzone.disabled:hover {
|
|
62
|
+
transform: none;
|
|
63
|
+
box-shadow: none;
|
|
64
|
+
border-color: #cbd5e1;
|
|
65
|
+
background: #f8fafc;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.fuf-upload-icon {
|
|
69
|
+
color: #3b82f6;
|
|
70
|
+
font-size: 48px;
|
|
71
|
+
margin-bottom: 8px;
|
|
72
|
+
display: block;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.fuf-dropzone.error .fuf-upload-icon {
|
|
76
|
+
color: #ef4444;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.fuf-upload-text {
|
|
80
|
+
font-size: 16px;
|
|
81
|
+
font-weight: 500;
|
|
82
|
+
color: #334155;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.fuf-format-text {
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
color: #94a3b8;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.fuf-preview-list {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: 8px;
|
|
94
|
+
margin-top: 8px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.fuf-preview-item {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: space-between;
|
|
101
|
+
padding: 12px 16px;
|
|
102
|
+
background: white;
|
|
103
|
+
border: 1px solid #e2e8f0;
|
|
104
|
+
border-radius: 12px;
|
|
105
|
+
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
|
106
|
+
transition: all 0.2s ease;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.fuf-preview-item:hover {
|
|
110
|
+
border-color: #cbd5e1;
|
|
111
|
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.fuf-file-info {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: 12px;
|
|
118
|
+
min-width: 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.fuf-thumbnail {
|
|
122
|
+
width: 40px;
|
|
123
|
+
height: 40px;
|
|
124
|
+
object-fit: cover;
|
|
125
|
+
border-radius: 8px;
|
|
126
|
+
border: 1px solid #f1f5f9;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.fuf-file-icon {
|
|
130
|
+
font-size: 24px;
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.fuf-file-icon.pdf {
|
|
137
|
+
color: #ef4444;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.fuf-file-icon.general {
|
|
141
|
+
color: #3b82f6;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.fuf-file-name {
|
|
145
|
+
font-size: 14px;
|
|
146
|
+
color: #1e293b;
|
|
147
|
+
font-weight: 500;
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
text-overflow: ellipsis;
|
|
151
|
+
max-width: 240px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.fuf-actions {
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
gap: 4px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.fuf-action-btn {
|
|
161
|
+
padding: 8px;
|
|
162
|
+
border-radius: 8px;
|
|
163
|
+
border: none;
|
|
164
|
+
background: transparent;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
justify-content: center;
|
|
169
|
+
transition: all 0.2s ease;
|
|
170
|
+
color: #64748b;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.fuf-action-btn i {
|
|
174
|
+
font-size: 18px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.fuf-action-btn.view:hover {
|
|
178
|
+
color: #3b82f6;
|
|
179
|
+
background: #eff6ff;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.fuf-action-btn.remove:hover {
|
|
183
|
+
color: #ef4444;
|
|
184
|
+
background: #fef2f2;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.fuf-error-message {
|
|
188
|
+
font-size: 12px;
|
|
189
|
+
color: #ef4444;
|
|
190
|
+
margin-top: 4px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.fuf-hidden-input {
|
|
194
|
+
display: none;
|
|
195
|
+
}
|
|
196
|
+
`,K=forwardRef((C,E)=>{let{label:N,required:I,error:d,accept:k=".pdf,.doc,.docx",maxSizeMB:U=10,disabled:c,uploadType:j,multiple:u,value:l,onChange:m,onDelete:z,previewUrl:$,previewUrls:R,existingFileUrl:b,existingFileName:y,editMode:M=true,viewMode:P=false,className:S="",style:T,sx:O}=C;useEffect(()=>{let e="tabler-icons-cdn";if(!document.getElementById(e)){let t=document.createElement("link");t.id=e,t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css",document.head.appendChild(t);}},[]);let p=Array.isArray(b)?b:b?[b]:[],H=Array.isArray(l)?l:l?[l]:[],w=[...p,...H],g=c||P||!M,F=useRef(null);useImperativeHandle(E,()=>F.current);let[s,x]=useState([]);useEffect(()=>()=>{s.forEach(e=>{e.startsWith("blob:")&&URL.revokeObjectURL(e);});},[s]);let W=e=>{if(g)return;let t=e.target.files;if(!t||t.length===0)return;let f=Array.from(t),i=[],r=[];for(let n of f){if(n.size>U*1024*1024){toast.error(`File "${n.name}" exceeds the maximum size of ${U}MB`);continue}i.push(n),r.push(URL.createObjectURL(n));}if(i.length===0){e.target.value="";return}if(u){x(v=>[...v,...r]);let h=[...Array.isArray(l)?l:[],...i];m?.(h);}else s[0]?.startsWith("blob:")&&URL.revokeObjectURL(s[0]),x(r),m?.(i[0]);e.target.value="";},q=e=>{if(g)return;if(e<p.length){z?.(e);return}let f=e-p.length;if(u){let i=Array.isArray(l)?[...l]:[];i.splice(f,1),m?.(i.length>0?i:null);let r=[...s];r[f]?.startsWith("blob:")&&URL.revokeObjectURL(r[f]),r.splice(f,1),x(r);}else m?.(null),s[0]?.startsWith("blob:")&&URL.revokeObjectURL(s[0]),x([]);z?.(e);},B=(e,t)=>{t<p.length;let i=typeof e=="string"?(Array.isArray(y)?y[t]:y)||"Uploaded Document":e.name,r=t-p.length,n=typeof e=="string"?e:s[r]||(Array.isArray(R)?R[r]:$),h=i.toLowerCase().endsWith(".pdf")||typeof e!="string"&&e.type==="application/pdf",v=j==="image"||i.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/i);return jsxs("div",{className:"fuf-preview-item",children:[jsxs("div",{className:"fuf-file-info",children:[v&&n?jsx("img",{className:"fuf-thumbnail",src:n,alt:i}):h?jsx("i",{className:"ti ti-file-type-pdf fuf-file-icon pdf"}):jsx("i",{className:"ti ti-file fuf-file-icon general"}),jsx("span",{className:"fuf-file-name",title:i,children:i})]}),jsxs("div",{className:"fuf-actions",children:[(h||v)&&n&&jsx("button",{type:"button",className:"fuf-action-btn view",onClick:()=>window.open(n,"_blank"),title:"View",children:jsx("i",{className:"ti ti-eye"})}),!g&&jsx("button",{type:"button",className:"fuf-action-btn remove",onClick:()=>q(t),title:"Remove",children:jsx("i",{className:"ti ti-x"})})]})]},`${i}-${t}`)};return jsxs(Fragment,{children:[jsx("style",{dangerouslySetInnerHTML:{__html:J}}),jsxs("div",{className:`fuf-root ${S}`,style:{...a(O),...T},children:[N&&jsxs("label",{className:`fuf-label ${d?"error":""}`,children:[N," ",I&&jsx("span",{className:"fuf-required",children:"*"})]}),(!w.length||u)&&!g&&jsxs("div",{className:`fuf-dropzone ${d?"error":""} ${c?"disabled":""}`,onClick:()=>!c&&F.current?.click(),children:[jsx("i",{className:"ti ti-upload fuf-upload-icon"}),jsx("span",{className:"fuf-upload-text",children:c?"Upload disabled":"Click to upload"}),jsxs("span",{className:"fuf-format-text",children:["(Supported formats: ",k.replace(/\./g,"").toUpperCase(),")"]}),jsx("input",{type:"file",className:"fuf-hidden-input",ref:F,onChange:W,accept:k,disabled:c,multiple:u})]}),w.length>0&&jsx("div",{className:"fuf-preview-list",children:w.map((e,t)=>B(e,t))}),d&&jsx("span",{className:"fuf-error-message",children:d})]})]})});K.displayName="FileUploadField";
|
|
197
|
+
export{K as a};//# sourceMappingURL=chunk-PL2R3LYL.mjs.map
|
|
198
|
+
//# sourceMappingURL=chunk-PL2R3LYL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/FileUploadField/FileUploadField.tsx"],"names":["STYLES","FileUploadField","forwardRef","props","ref","label","required","error","accept","maxSizeMB","disabled","uploadType","multiple","value","onChange","onDelete","previewUrl","previewUrls","existingFileUrl","existingFileName","editMode","viewMode","className","style","sx","useEffect","cdnId","link","existingFiles","currentFiles","filesToRender","isReadOnly","inputRef","useRef","useImperativeHandle","internalPreviews","setInternalPreviews","useState","url","handleFileChange","files","fileList","validFiles","newPreviews","file","toast","prev","updatedFiles","handleRemove","index","currentFileIndex","currentPreviews","renderFileRow","fileName","fileUrl","isPdf","isImage","jsxs","jsx","Fragment","handleSx","idx"],"mappings":"uMAOA,IAAMA,CAAAA,CAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;A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EAAM,CAEpD,UAAA0B,GAAAA,CAAC,GAAA,CAAA,CAAE,UAAU,8BAAA,CAA+B,CAAA,CAC5CA,IAAC,MAAA,CAAA,CAAK,SAAA,CAAU,kBACb,QAAA,CAAAhD,CAAAA,CAAW,iBAAA,CAAoB,iBAAA,CAClC,EACA+C,IAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,iBAAA,CAAkB,QAAA,CAAA,CAAA,sBAAA,CACXjD,EAAO,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAA,CAAE,WAAA,GAAc,GAAA,CAAA,CAC/D,CAAA,CACAkD,IAAC,OAAA,CAAA,CACC,IAAA,CAAK,OACL,SAAA,CAAU,kBAAA,CACV,GAAA,CAAK1B,CAAAA,CACL,SAAUO,CAAAA,CACV,MAAA,CAAQ/B,EACR,QAAA,CAAUE,CAAAA,CACV,SAAUE,CAAAA,CACZ,CAAA,CAAA,CACF,EAGDkB,CAAAA,CAAc,MAAA,CAAS,GACtB4B,GAAAA,CAAC,KAAA,CAAA,CAAI,UAAU,kBAAA,CACZ,QAAA,CAAA5B,EAAc,GAAA,CAAI,CAACc,CAAAA,CAAMiB,CAAAA,GAAQT,EAAcR,CAAAA,CAAMiB,CAAG,CAAC,CAAA,CAC5D,CAAA,CAGDtD,GACCmD,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,mBAAA,CACb,QAAA,CAAAnD,EACH,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAEJ,CAAC,EAEDN,EAAgB,WAAA,CAAc,iBAAA","file":"chunk-PL2R3LYL.mjs","sourcesContent":["'use client';\n\nimport React, { forwardRef, useImperativeHandle, useRef, useState, useEffect } from 'react';\nimport { toast } from 'react-toastify';\nimport { handleSx } from '../../utils/handleSx';\nimport { FileUploadFieldProps } from './FileUploadField.types';\n\nconst STYLES = `\n .fuf-root {\n display: flex;\n flex-direction: column;\n gap: 8px;\n font-family: 'Inter', system-ui, -apple-system, sans-serif;\n width: 100%;\n }\n\n .fuf-label {\n font-size: 14px;\n font-weight: 500;\n color: #64748b;\n margin-bottom: 4px;\n }\n\n .fuf-label.error {\n color: #ef4444;\n }\n\n .fuf-required {\n color: #ef4444;\n margin-left: 2px;\n }\n\n .fuf-dropzone {\n border: 2px dashed #cbd5e1;\n border-radius: 12px;\n padding: 32px;\n text-align: center;\n cursor: pointer;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n background: #f8fafc;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n }\n\n .fuf-dropzone:hover {\n border-color: #3b82f6;\n background: #eff6ff;\n transform: translateY(-1px);\n box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n }\n\n .fuf-dropzone.error {\n border-color: #ef4444;\n background: #fef2f2;\n }\n\n .fuf-dropzone.error:hover {\n border-color: #dc2626;\n }\n\n .fuf-dropzone.disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n\n .fuf-dropzone.disabled:hover {\n transform: none;\n box-shadow: none;\n border-color: #cbd5e1;\n background: #f8fafc;\n }\n\n .fuf-upload-icon {\n color: #3b82f6;\n font-size: 48px;\n margin-bottom: 8px;\n display: block;\n }\n\n .fuf-dropzone.error .fuf-upload-icon {\n color: #ef4444;\n }\n\n .fuf-upload-text {\n font-size: 16px;\n font-weight: 500;\n color: #334155;\n }\n\n .fuf-format-text {\n font-size: 12px;\n color: #94a3b8;\n }\n\n .fuf-preview-list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: 8px;\n }\n\n .fuf-preview-item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 16px;\n background: white;\n border: 1px solid #e2e8f0;\n border-radius: 12px;\n box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);\n transition: all 0.2s ease;\n }\n\n .fuf-preview-item:hover {\n border-color: #cbd5e1;\n box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);\n }\n\n .fuf-file-info {\n display: flex;\n align-items: center;\n gap: 12px;\n min-width: 0;\n }\n\n .fuf-thumbnail {\n width: 40px;\n height: 40px;\n object-fit: cover;\n border-radius: 8px;\n border: 1px solid #f1f5f9;\n }\n\n .fuf-file-icon {\n font-size: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .fuf-file-icon.pdf {\n color: #ef4444;\n }\n\n .fuf-file-icon.general {\n color: #3b82f6;\n }\n\n .fuf-file-name {\n font-size: 14px;\n color: #1e293b;\n font-weight: 500;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 240px;\n }\n\n .fuf-actions {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .fuf-action-btn {\n padding: 8px;\n border-radius: 8px;\n border: none;\n background: transparent;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n color: #64748b;\n }\n\n .fuf-action-btn i {\n font-size: 18px;\n }\n\n .fuf-action-btn.view:hover {\n color: #3b82f6;\n background: #eff6ff;\n }\n\n .fuf-action-btn.remove:hover {\n color: #ef4444;\n background: #fef2f2;\n }\n\n .fuf-error-message {\n font-size: 12px;\n color: #ef4444;\n margin-top: 4px;\n }\n\n .fuf-hidden-input {\n display: none;\n }\n`;\n\n/**\n * FileUploadField component for single or multiple file uploads with preview support.\n */\nexport const FileUploadField = forwardRef<HTMLInputElement, FileUploadFieldProps>((props, ref) => {\n const {\n label,\n required,\n error,\n accept = '.pdf,.doc,.docx',\n maxSizeMB = 10,\n disabled,\n uploadType,\n multiple,\n value,\n onChange,\n onDelete,\n previewUrl,\n previewUrls,\n existingFileUrl,\n existingFileName,\n editMode = true,\n viewMode = false,\n className = '',\n style,\n sx,\n } = props;\n\n // Inject Tabler Icons CDN if not present\n useEffect(() => {\n const cdnId = 'tabler-icons-cdn';\n if (!document.getElementById(cdnId)) {\n const link = document.createElement('link');\n link.id = cdnId;\n link.rel = 'stylesheet';\n link.href = 'https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css';\n document.head.appendChild(link);\n }\n }, []);\n\n const existingFiles = Array.isArray(existingFileUrl)\n ? existingFileUrl\n : existingFileUrl ? [existingFileUrl] : [];\n\n const currentFiles = Array.isArray(value)\n ? value\n : value ? [value] : [];\n\n const filesToRender = [...existingFiles, ...currentFiles];\n const isReadOnly = disabled || viewMode || !editMode;\n\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current!);\n\n const [internalPreviews, setInternalPreviews] = useState<string[]>([]);\n\n // Cleanup object URLs on unmount\n useEffect(() => {\n return () => {\n internalPreviews.forEach((url) => {\n if (url.startsWith('blob:')) {\n URL.revokeObjectURL(url);\n }\n });\n };\n }, [internalPreviews]);\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (isReadOnly) return;\n const files = e.target.files;\n if (!files || files.length === 0) return;\n\n const fileList = Array.from(files);\n const validFiles: File[] = [];\n const newPreviews: string[] = [];\n\n for (const file of fileList) {\n if (file.size > maxSizeMB * 1024 * 1024) {\n toast.error(`File \"${file.name}\" exceeds the maximum size of ${maxSizeMB}MB`);\n continue;\n }\n validFiles.push(file);\n newPreviews.push(URL.createObjectURL(file));\n }\n\n if (validFiles.length === 0) {\n e.target.value = '';\n return;\n }\n\n if (multiple) {\n setInternalPreviews((prev) => [...prev, ...newPreviews]);\n const currentFiles = Array.isArray(value) ? value : [];\n const updatedFiles = [...currentFiles, ...validFiles];\n (onChange as (files: File[] | null) => void)?.(updatedFiles);\n } else {\n if (internalPreviews[0]?.startsWith('blob:')) {\n URL.revokeObjectURL(internalPreviews[0]);\n }\n setInternalPreviews(newPreviews);\n (onChange as (file: File | null) => void)?.(validFiles[0]);\n }\n\n e.target.value = '';\n };\n\n const handleRemove = (index: number) => {\n if (isReadOnly) return;\n\n const isExisting = index < existingFiles.length;\n if (isExisting) {\n onDelete?.(index);\n return;\n }\n\n const currentFileIndex = index - existingFiles.length;\n\n if (multiple) {\n const currentFiles = Array.isArray(value) ? [...value] : [];\n currentFiles.splice(currentFileIndex, 1);\n (onChange as (files: File[] | null) => void)?.(currentFiles.length > 0 ? currentFiles : null);\n\n const currentPreviews = [...internalPreviews];\n if (currentPreviews[currentFileIndex]?.startsWith('blob:')) {\n URL.revokeObjectURL(currentPreviews[currentFileIndex]);\n }\n currentPreviews.splice(currentFileIndex, 1);\n setInternalPreviews(currentPreviews);\n } else {\n (onChange as (file: File | null) => void)?.(null);\n if (internalPreviews[0]?.startsWith('blob:')) {\n URL.revokeObjectURL(internalPreviews[0]);\n }\n setInternalPreviews([]);\n }\n onDelete?.(index);\n };\n\n const renderFileRow = (file: File | string, index: number) => {\n const isExisting = index < existingFiles.length;\n const fileName = typeof file === 'string'\n ? (Array.isArray(existingFileName) ? existingFileName[index] : existingFileName) || 'Uploaded Document'\n : file.name;\n\n const currentFileIndex = index - existingFiles.length;\n const fileUrl = typeof file === 'string'\n ? file\n : internalPreviews[currentFileIndex] || (Array.isArray(previewUrls) ? previewUrls[currentFileIndex] : previewUrl);\n\n const isPdf = fileName.toLowerCase().endsWith('.pdf') || (typeof file !== 'string' && file.type === 'application/pdf');\n const isImage = uploadType === 'image' || fileName.toLowerCase().match(/\\.(jpg|jpeg|png|gif|webp)$/i);\n\n return (\n <div className=\"fuf-preview-item\" key={`${fileName}-${index}`}>\n <div className=\"fuf-file-info\">\n {isImage && fileUrl ? (\n <img className=\"fuf-thumbnail\" src={fileUrl} alt={fileName} />\n ) : isPdf ? (\n <i className=\"ti ti-file-type-pdf fuf-file-icon pdf\"></i>\n ) : (\n <i className=\"ti ti-file fuf-file-icon general\"></i>\n )}\n <span className=\"fuf-file-name\" title={fileName}>\n {fileName}\n </span>\n </div>\n <div className=\"fuf-actions\">\n {(isPdf || isImage) && fileUrl && (\n <button\n type=\"button\"\n className=\"fuf-action-btn view\"\n onClick={() => window.open(fileUrl, '_blank')}\n title=\"View\"\n >\n <i className=\"ti ti-eye\"></i>\n </button>\n )}\n {!isReadOnly && (\n <button\n type=\"button\"\n className=\"fuf-action-btn remove\"\n onClick={() => handleRemove(index)}\n title=\"Remove\"\n >\n <i className=\"ti ti-x\"></i>\n </button>\n )}\n </div>\n </div>\n );\n };\n\n return (\n <>\n <style dangerouslySetInnerHTML={{ __html: STYLES }} />\n <div className={`fuf-root ${className}`} style={{ ...handleSx(sx), ...style }}>\n {label && (\n <label className={`fuf-label ${error ? 'error' : ''}`}>\n {label} {required && <span className=\"fuf-required\">*</span>}\n </label>\n )}\n\n {(!filesToRender.length || multiple) && !isReadOnly && (\n <div\n className={`fuf-dropzone ${error ? 'error' : ''} ${disabled ? 'disabled' : ''}`}\n onClick={() => !disabled && inputRef.current?.click()}\n >\n <i className=\"ti ti-upload fuf-upload-icon\"></i>\n <span className=\"fuf-upload-text\">\n {disabled ? 'Upload disabled' : 'Click to upload'}\n </span>\n <span className=\"fuf-format-text\">\n (Supported formats: {accept.replace(/\\./g, '').toUpperCase()})\n </span>\n <input\n type=\"file\"\n className=\"fuf-hidden-input\"\n ref={inputRef}\n onChange={handleFileChange}\n accept={accept}\n disabled={disabled}\n multiple={multiple}\n />\n </div>\n )}\n\n {filesToRender.length > 0 && (\n <div className=\"fuf-preview-list\">\n {filesToRender.map((file, idx) => renderFileRow(file, idx))}\n </div>\n )}\n\n {error && (\n <span className=\"fuf-error-message\">\n {error}\n </span>\n )}\n </div>\n </>\n );\n});\n\nFileUploadField.displayName = 'FileUploadField';\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';var chunkDDGBDWFC_js=require('./chunk-DDGBDWFC.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var m=react.createContext(void 0);var N=`
|
|
2
|
+
.ui-radio-group {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
}
|
|
7
|
+
`,S=react.forwardRef((f,g)=>{let{children:a,className:n,defaultValue:t,name:h,onChange:d,value:s,sx:r,...x}=f,v=react.useId(),l=h||`radio-group-${v}`,[b,o]=react.useState(t),c=s!==void 0,y={name:l,onChange:k=>{let z=k.target.value;c||o(z),d&&d(k,z);},value:c?s:b},p=typeof r=="object"&&!Array.isArray(r)?{...r}:{};return jsxRuntime.jsxs(m.Provider,{value:y,children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:N}}),jsxRuntime.jsx("div",{ref:g,role:"radiogroup",className:chunkDDGBDWFC_js.a("ui-radio-group",n),style:p,...x,children:a})]})});S.displayName="RadioGroup";var H=()=>jsxRuntime.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",children:jsxRuntime.jsx("path",{d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"})}),V=()=>jsxRuntime.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",children:jsxRuntime.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"})}),A=`
|
|
8
|
+
.ui-radio {
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
position: relative;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
vertical-align: middle;
|
|
15
|
+
gap: 5px;
|
|
16
|
+
padding: 2px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ui-radio--disabled {
|
|
20
|
+
cursor: default;
|
|
21
|
+
opacity: 0.5;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ui-radio-container {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
position: relative;
|
|
29
|
+
padding: 9px;
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
32
|
+
color: #64748b;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ui-radio-container:hover {
|
|
36
|
+
background-color: rgba(15, 23, 42, 0.04);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ui-radio-input {
|
|
40
|
+
cursor: inherit;
|
|
41
|
+
position: absolute;
|
|
42
|
+
opacity: 0;
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 100%;
|
|
45
|
+
top: 0;
|
|
46
|
+
left: 0;
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: 0;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Colors */
|
|
53
|
+
.ui-radio--primary .ui-radio--checked {
|
|
54
|
+
color: #3b82f6;
|
|
55
|
+
}
|
|
56
|
+
.ui-radio--primary .ui-radio-container:hover {
|
|
57
|
+
background-color: rgba(59, 130, 246, 0.04);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ui-radio--secondary .ui-radio--checked {
|
|
61
|
+
color: #9333ea;
|
|
62
|
+
}
|
|
63
|
+
.ui-radio--secondary .ui-radio-container:hover {
|
|
64
|
+
background-color: rgba(147, 51, 234, 0.04);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ui-radio--error .ui-radio--checked {
|
|
68
|
+
color: #ef4444;
|
|
69
|
+
}
|
|
70
|
+
.ui-radio--error .ui-radio-container:hover {
|
|
71
|
+
background-color: rgba(239, 68, 68, 0.04);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Sizes */
|
|
75
|
+
.ui-radio--small .ui-radio-container {
|
|
76
|
+
padding: 7px;
|
|
77
|
+
}
|
|
78
|
+
.ui-radio--small svg {
|
|
79
|
+
font-size: 1.25rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ui-radio--medium svg {
|
|
83
|
+
font-size: 1.5rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ui-radio-icon {
|
|
87
|
+
display: flex;
|
|
88
|
+
font-size: 1.5rem;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ui-radio-label {
|
|
92
|
+
font-size: 0.875rem;
|
|
93
|
+
font-family: inherit;
|
|
94
|
+
color: #1e293b;
|
|
95
|
+
}
|
|
96
|
+
`,_=react.forwardRef((f,g)=>{let{value:a,children:n,disabled:t=false,color:h="primary",size:d="medium",className:s,sx:r,name:x,checked:v,onChange:l,...b}=f,o=react.useContext(m),c=o?o.name:x,u=o?o.value===a:v,R=p=>{l&&l(p),o&&o.onChange&&o.onChange(p,a);},y=typeof r=="object"&&!Array.isArray(r)?{...r}:{};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:A}}),jsxRuntime.jsxs("label",{className:chunkDDGBDWFC_js.a("ui-radio",`ui-radio--${h}`,`ui-radio--${d}`,t&&"ui-radio--disabled",s),style:y,children:[jsxRuntime.jsxs("span",{className:chunkDDGBDWFC_js.a("ui-radio-container",u&&"ui-radio--checked"),children:[jsxRuntime.jsx("input",{type:"radio",ref:g,name:c,value:a,checked:u,disabled:t,onChange:R,className:"ui-radio-input",...b}),jsxRuntime.jsx("span",{className:"ui-radio-icon",children:u?jsxRuntime.jsx(H,{}):jsxRuntime.jsx(V,{})})]}),n&&jsxRuntime.jsx("span",{className:"ui-radio-label",children:n})]})]})});_.displayName="Radio";exports.a=m;exports.b=S;exports.c=H;exports.d=V;exports.e=_;//# sourceMappingURL=chunk-PPQ7NSV3.js.map
|
|
97
|
+
//# sourceMappingURL=chunk-PPQ7NSV3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/RadioGroupContext.ts","../src/components/RadioGroup/RadioGroup.tsx","../src/components/RadioGroup/Radio.tsx"],"names":["RadioGroupContext","createContext","STYLES","RadioGroup","forwardRef","props","ref","children","className","defaultValue","nameProp","onChange","valueProp","sx","rest","generatedId","useId","name","internalValue","setInternalValue","useState","isControlled","contextValue","event","newValue","style","jsxs","jsx","cn","RadioIcon","RadioUncheckedIcon","Radio","value","disabled","color","size","checkedProp","onChangeProp","context","useContext","isChecked","handleChange","Fragment"],"mappings":"oIAQaA,CAAAA,CAAoBC,mBAAAA,CAAkD,MAAS,ECD5F,IAAMC,CAAAA,CAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAQFC,EAAaC,gBAAAA,CAA4C,CAACC,EAAOC,CAAAA,GAAQ,CACpF,GAAM,CACJ,QAAA,CAAAC,EACA,SAAA,CAAAC,CAAAA,CACA,aAAAC,CAAAA,CACA,IAAA,CAAMC,EACN,QAAA,CAAAC,CAAAA,CACA,MAAOC,CAAAA,CACP,EAAA,CAAAC,EACA,GAAGC,CACL,EAAIT,CAAAA,CAEEU,CAAAA,CAAcC,aAAM,CACpBC,CAAAA,CAAOP,GAAY,CAAA,YAAA,EAAeK,CAAW,GAE7C,CAACG,CAAAA,CAAeC,CAAgB,CAAA,CAAIC,cAAAA,CAASX,CAAY,CAAA,CACzDY,CAAAA,CAAeT,IAAc,MAAA,CAe7BU,CAAAA,CAAe,CACnB,IAAA,CAAAL,CAAAA,CACA,SAdoBM,CAAAA,EAA+C,CACnE,IAAMC,CAAAA,CAAWD,CAAAA,CAAM,OAAO,KAAA,CAEzBF,CAAAA,EACHF,EAAiBK,CAAQ,CAAA,CAGvBb,GACFA,CAAAA,CAASY,CAAAA,CAAOC,CAAQ,EAE5B,CAAA,CAKE,MAjBYH,CAAAA,CAAeT,CAAAA,CAAYM,CAkBzC,CAAA,CAEMO,CAAAA,CAAQ,OAAOZ,CAAAA,EAAO,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,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zB,CAAO,CAAA,CAAG,EACpDwB,eAAAA,CAAC,OAAA,CAAA,CACC,SAAA,CAAWE,kBAAAA,CACT,WACA,CAAA,UAAA,EAAaM,CAAK,GAClB,CAAA,UAAA,EAAaC,CAAI,GACjBF,CAAAA,EAAY,oBAAA,CACZzB,CACF,CAAA,CACA,MAAOiB,CAAAA,CAEP,QAAA,CAAA,CAAAC,gBAAC,MAAA,CAAA,CAAK,SAAA,CAAWE,mBAAG,oBAAA,CAAsBY,CAAAA,EAAa,mBAAmB,CAAA,CACxE,UAAAb,cAAAA,CAAC,OAAA,CAAA,CACC,KAAK,OAAA,CACL,GAAA,CAAKrB,EACL,IAAA,CAAMW,CAAAA,CACN,KAAA,CAAOe,CAAAA,CACP,QAASQ,CAAAA,CACT,QAAA,CAAUP,EACV,QAAA,CAAUQ,CAAAA,CACV,UAAU,gBAAA,CACT,GAAG3B,CAAAA,CACN,CAAA,CACAa,eAAC,MAAA,CAAA,CAAK,SAAA,CAAU,gBACb,QAAA,CAAAa,CAAAA,CAAYb,eAACE,CAAAA,CAAA,EAAU,CAAA,CAAKF,cAAAA,CAACG,EAAA,EAAmB,CAAA,CACnD,GACF,CAAA,CACCvB,CAAAA,EAAYoB,eAAC,MAAA,CAAA,CAAK,SAAA,CAAU,gBAAA,CAAkB,QAAA,CAAApB,EAAS,CAAA,CAAA,CAC1D,CAAA,CAAA,CACF,CAEJ,CAAC,EAEDwB,EAAM,WAAA,CAAc,OAAA","file":"chunk-PPQ7NSV3.js","sourcesContent":["import { createContext, ChangeEvent } from 'react';\n\nexport interface RadioGroupContextValue {\n name?: string;\n onChange?: (event: ChangeEvent<HTMLInputElement>, value: string) => void;\n value?: any;\n}\n\nexport const RadioGroupContext = createContext<RadioGroupContextValue | undefined>(undefined);\n","'use client';\n\nimport React, { forwardRef, useState, useId } from 'react';\nimport { cn } from '../../utils/cn';\nimport { RadioGroupProps } from './types';\nimport { RadioGroupContext } from './RadioGroupContext';\n\nconst STYLES = `\n .ui-radio-group {\n display: flex;\n flex-direction: column;\n flex-wrap: wrap;\n }\n`;\n\nexport const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>((props, ref) => {\n const {\n children,\n className,\n defaultValue,\n name: nameProp,\n onChange,\n value: valueProp,\n sx,\n ...rest\n } = props;\n\n const generatedId = useId();\n const name = nameProp || `radio-group-${generatedId}`;\n\n const [internalValue, setInternalValue] = useState(defaultValue);\n const isControlled = valueProp !== undefined;\n const value = isControlled ? valueProp : internalValue;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n \n if (!isControlled) {\n setInternalValue(newValue);\n }\n\n if (onChange) {\n onChange(event, newValue);\n }\n };\n\n const contextValue = {\n name,\n onChange: handleChange,\n value,\n };\n\n const style = typeof sx === 'object' && !Array.isArray(sx) ? { ...sx } : {};\n\n return (\n <RadioGroupContext.Provider value={contextValue}>\n <style dangerouslySetInnerHTML={{ __html: STYLES }} />\n <div\n ref={ref}\n role=\"radiogroup\"\n className={cn('ui-radio-group', className)}\n style={style}\n {...rest}\n >\n {children}\n </div>\n </RadioGroupContext.Provider>\n );\n});\n\nRadioGroup.displayName = 'RadioGroup';\n\nexport default RadioGroup;\n","'use client';\n\nimport React, { forwardRef, useContext } from 'react';\nimport { cn } from '../../utils/cn';\nimport { RadioProps } from './types';\nimport { RadioGroupContext } from './RadioGroupContext';\n\nexport const RadioIcon = () => (\n <svg focusable=\"false\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"currentColor\" width=\"1em\" height=\"1em\">\n <path d=\"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z\"></path>\n </svg>\n);\n\nexport const RadioUncheckedIcon = () => (\n <svg focusable=\"false\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"currentColor\" width=\"1em\" height=\"1em\">\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z\"></path>\n </svg>\n);\n\nconst STYLES = `\n .ui-radio {\n display: inline-flex;\n align-items: center;\n position: relative;\n box-sizing: border-box;\n cursor: pointer;\n vertical-align: middle;\n gap: 5px;\n padding: 2px;\n }\n\n .ui-radio--disabled {\n cursor: default;\n opacity: 0.5;\n }\n\n .ui-radio-container {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n position: relative;\n padding: 9px;\n border-radius: 50%;\n transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n color: #64748b;\n }\n\n .ui-radio-container:hover {\n background-color: rgba(15, 23, 42, 0.04);\n }\n\n .ui-radio-input {\n cursor: inherit;\n position: absolute;\n opacity: 0;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n margin: 0;\n padding: 0;\n z-index: 1;\n }\n\n /* Colors */\n .ui-radio--primary .ui-radio--checked {\n color: #3b82f6;\n }\n .ui-radio--primary .ui-radio-container:hover {\n background-color: rgba(59, 130, 246, 0.04);\n }\n\n .ui-radio--secondary .ui-radio--checked {\n color: #9333ea;\n }\n .ui-radio--secondary .ui-radio-container:hover {\n background-color: rgba(147, 51, 234, 0.04);\n }\n\n .ui-radio--error .ui-radio--checked {\n color: #ef4444;\n }\n .ui-radio--error .ui-radio-container:hover {\n background-color: rgba(239, 68, 68, 0.04);\n }\n\n /* Sizes */\n .ui-radio--small .ui-radio-container {\n padding: 7px;\n }\n .ui-radio--small svg {\n font-size: 1.25rem;\n }\n\n .ui-radio--medium svg {\n font-size: 1.5rem;\n }\n\n .ui-radio-icon {\n display: flex;\n font-size: 1.5rem;\n }\n\n .ui-radio-label {\n font-size: 0.875rem;\n font-family: inherit;\n color: #1e293b;\n }\n`;\n\nexport const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {\n const {\n value,\n children,\n disabled = false,\n color = 'primary',\n size = 'medium',\n className,\n sx,\n name: nameProp,\n checked: checkedProp,\n onChange: onChangeProp,\n ...rest\n } = props;\n\n const context = useContext(RadioGroupContext);\n\n const name = context ? context.name : nameProp;\n const isChecked = context ? context.value === value : checkedProp;\n \n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChangeProp) {\n onChangeProp(event);\n }\n if (context && context.onChange) {\n context.onChange(event, value);\n }\n };\n\n const style = typeof sx === 'object' && !Array.isArray(sx) ? { ...sx } : {};\n\n return (\n <>\n <style dangerouslySetInnerHTML={{ __html: STYLES }} />\n <label\n className={cn(\n 'ui-radio',\n `ui-radio--${color}`,\n `ui-radio--${size}`,\n disabled && 'ui-radio--disabled',\n className\n )}\n style={style}\n >\n <span className={cn('ui-radio-container', isChecked && 'ui-radio--checked')}>\n <input\n type=\"radio\"\n ref={ref}\n name={name}\n value={value}\n checked={isChecked}\n disabled={disabled}\n onChange={handleChange}\n className=\"ui-radio-input\"\n {...rest}\n />\n <span className=\"ui-radio-icon\">\n {isChecked ? <RadioIcon /> : <RadioUncheckedIcon />}\n </span>\n </span>\n {children && <span className=\"ui-radio-label\">{children}</span>}\n </label>\n </>\n );\n});\n\nRadio.displayName = 'Radio';\n\nexport default Radio;\n"]}
|