@aziziaziz/react-components 1.0.1 → 1.0.3
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/Button-GX4BPUGQ.css +98 -0
- package/dist/DatePicker-ISUX6NNC.css +44 -0
- package/dist/Drawer-5ZWJQFIQ.css +53 -0
- package/dist/Dropdown-VC55KPC2.css +114 -0
- package/dist/Icon-DCSTRBMX.css +17 -0
- package/dist/WebDatePicker-H2XZEEJG.css +154 -0
- package/dist/{index-MIFCDIS7.css → index-2F2GVZE5.css} +54 -0
- package/dist/index.d.mts +446 -3
- package/dist/index.d.ts +446 -3
- package/dist/index.js +641 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +643 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
- package/src/components/button/Button.css +98 -0
- package/src/components/datePicker/DatePicker.css +44 -0
- package/src/components/datePicker/components/webDatePicker/WebDatePicker.css +154 -0
- package/src/components/drawer/Drawer.css +53 -0
- package/src/components/dropdown/Dropdown.css +114 -0
- package/src/components/icon/Icon.css +17 -0
- package/src/index.css +54 -0
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import "./index-
|
|
2
|
+
import "./index-2F2GVZE5.css";
|
|
3
3
|
|
|
4
4
|
// src/components/input/Input.tsx
|
|
5
5
|
import { useController } from "react-hook-form";
|
|
@@ -58,8 +58,649 @@ var Input = ({
|
|
|
58
58
|
] });
|
|
59
59
|
};
|
|
60
60
|
var Input_default = Input;
|
|
61
|
+
|
|
62
|
+
// src/components/button/Button.tsx
|
|
63
|
+
import { useMemo } from "react";
|
|
64
|
+
import "./Button-GX4BPUGQ.css";
|
|
65
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
66
|
+
var Button = ({
|
|
67
|
+
children,
|
|
68
|
+
onClick,
|
|
69
|
+
className,
|
|
70
|
+
type = "submit",
|
|
71
|
+
disabled = false,
|
|
72
|
+
loading = false,
|
|
73
|
+
size = "default",
|
|
74
|
+
removeMinWidth = false
|
|
75
|
+
}) => {
|
|
76
|
+
const buttonClass = useMemo(() => {
|
|
77
|
+
if (disabled || loading) return "disabledBtn";
|
|
78
|
+
switch (type) {
|
|
79
|
+
case "submit":
|
|
80
|
+
return "submitBtn";
|
|
81
|
+
case "danger":
|
|
82
|
+
return "dangerBtn";
|
|
83
|
+
case "warning":
|
|
84
|
+
return "warningBtn";
|
|
85
|
+
}
|
|
86
|
+
}, [type, disabled, loading]);
|
|
87
|
+
return /* @__PURE__ */ jsxs2(
|
|
88
|
+
"button",
|
|
89
|
+
{
|
|
90
|
+
className: `mainBtn ${className} ${buttonClass} ${`${size}__`} ${removeMinWidth && "noMinWidth__"}`,
|
|
91
|
+
onClick: () => {
|
|
92
|
+
if (!disabled) onClick();
|
|
93
|
+
},
|
|
94
|
+
disabled: disabled || loading,
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx3("div", { className: loading ? "hideContent" : "", children }),
|
|
97
|
+
/* @__PURE__ */ jsx3("div", { className: `loadingCircle ${loading && "show__"}` })
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
var Button_default = Button;
|
|
103
|
+
|
|
104
|
+
// src/components/datePicker/DatePicker.tsx
|
|
105
|
+
import { useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
106
|
+
import "./DatePicker-ISUX6NNC.css";
|
|
107
|
+
|
|
108
|
+
// src/components/icon/Icon.tsx
|
|
109
|
+
import "./Icon-DCSTRBMX.css";
|
|
110
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
111
|
+
var Icon = ({ src, className, flat = true }) => {
|
|
112
|
+
const classNames = ["icon", className, flat ? "flat__" : ""].join(" ");
|
|
113
|
+
return flat ? /* @__PURE__ */ jsx4("img", { className: classNames, src: src && src.toString() }) : /* @__PURE__ */ jsx4(
|
|
114
|
+
"i",
|
|
115
|
+
{
|
|
116
|
+
className: classNames,
|
|
117
|
+
style: {
|
|
118
|
+
maskImage: `url("${src}"`,
|
|
119
|
+
WebkitMaskImage: `url("${src}")`
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
var Icon_default = Icon;
|
|
125
|
+
|
|
126
|
+
// src/assets/dropdown.svg
|
|
127
|
+
var dropdown_default = 'data:image/svg+xml,<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">%0A%0D<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->%0A<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="%23000000">%0A%0D<g id="SVGRepo_bgCarrier" stroke-width="0"/>%0A%0D<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>%0A%0D<g id="SVGRepo_iconCarrier"> <path d="M17.9188 8.17969H11.6888H6.07877C5.11877 8.17969 4.63877 9.33969 5.31877 10.0197L10.4988 15.1997C11.3288 16.0297 12.6788 16.0297 13.5088 15.1997L15.4788 13.2297L18.6888 10.0197C19.3588 9.33969 18.8788 8.17969 17.9188 8.17969Z" fill="%23000000"/> </g>%0A%0D</svg>';
|
|
128
|
+
|
|
129
|
+
// src/components/datePicker/components/webDatePicker/WebDatePicker.tsx
|
|
130
|
+
import { useEffect, useMemo as useMemo2, useState } from "react";
|
|
131
|
+
import "./WebDatePicker-H2XZEEJG.css";
|
|
132
|
+
import {
|
|
133
|
+
addMonths,
|
|
134
|
+
addYears,
|
|
135
|
+
format,
|
|
136
|
+
getDaysInMonth,
|
|
137
|
+
isSameDay,
|
|
138
|
+
isToday,
|
|
139
|
+
setMonth,
|
|
140
|
+
setYear,
|
|
141
|
+
startOfMonth
|
|
142
|
+
} from "date-fns";
|
|
143
|
+
import { useController as useController2 } from "react-hook-form";
|
|
144
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
145
|
+
var daysShortName = ["S", "M", "T", "W", "T", "F", "S"];
|
|
146
|
+
var monthsShortName = [
|
|
147
|
+
"Jan",
|
|
148
|
+
"Feb",
|
|
149
|
+
"Mar",
|
|
150
|
+
"Apr",
|
|
151
|
+
"May",
|
|
152
|
+
"Jun",
|
|
153
|
+
"Jul",
|
|
154
|
+
"Aug",
|
|
155
|
+
"Sep",
|
|
156
|
+
"Oct",
|
|
157
|
+
"Nov",
|
|
158
|
+
"Dec"
|
|
159
|
+
];
|
|
160
|
+
var WebDatePicker = ({
|
|
161
|
+
id,
|
|
162
|
+
show,
|
|
163
|
+
updateShow
|
|
164
|
+
}) => {
|
|
165
|
+
const [currentMonth, setCurrentMonth] = useState(/* @__PURE__ */ new Date());
|
|
166
|
+
const [selectionMode, setSelectionMode] = useState(
|
|
167
|
+
"day"
|
|
168
|
+
);
|
|
169
|
+
const [allYears, setAllYears] = useState([]);
|
|
170
|
+
const {
|
|
171
|
+
field: { onChange, value }
|
|
172
|
+
} = useController2({ name: id });
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (show && value) {
|
|
175
|
+
setCurrentMonth(new Date(value));
|
|
176
|
+
}
|
|
177
|
+
if (show) {
|
|
178
|
+
setSelectionMode("day");
|
|
179
|
+
}
|
|
180
|
+
}, [show]);
|
|
181
|
+
const onAdd = () => {
|
|
182
|
+
if (selectionMode == "day") {
|
|
183
|
+
setCurrentMonth(addMonths(currentMonth, 1));
|
|
184
|
+
} else if (selectionMode == "month") {
|
|
185
|
+
setCurrentMonth(addYears(currentMonth, 1));
|
|
186
|
+
} else if (selectionMode == "year") {
|
|
187
|
+
setCurrentMonth(addYears(currentMonth, 10));
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const onMinus = () => {
|
|
191
|
+
if (selectionMode == "day") {
|
|
192
|
+
setCurrentMonth(addMonths(currentMonth, -1));
|
|
193
|
+
} else if (selectionMode == "month") {
|
|
194
|
+
setCurrentMonth(addYears(currentMonth, -1));
|
|
195
|
+
} else if (selectionMode == "year") {
|
|
196
|
+
setCurrentMonth(addYears(currentMonth, -10));
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const switchMode = () => {
|
|
200
|
+
if (selectionMode == "day") {
|
|
201
|
+
setSelectionMode("month");
|
|
202
|
+
} else if (selectionMode == "month") {
|
|
203
|
+
setSelectionMode("year");
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const allDays = useMemo2(() => {
|
|
207
|
+
const totalDays = getDaysInMonth(currentMonth);
|
|
208
|
+
const firstDay = startOfMonth(currentMonth).getDay() || 7;
|
|
209
|
+
const previousMonth = addMonths(currentMonth, -1);
|
|
210
|
+
const previousMonthTotalDays = getDaysInMonth(previousMonth);
|
|
211
|
+
const nextMonth = addMonths(currentMonth, 1);
|
|
212
|
+
const prevDays = new Array(firstDay).fill("").map((_, index) => {
|
|
213
|
+
const date = previousMonthTotalDays - index;
|
|
214
|
+
const thisDate = new Date(
|
|
215
|
+
previousMonth.getFullYear(),
|
|
216
|
+
previousMonth.getMonth(),
|
|
217
|
+
date
|
|
218
|
+
);
|
|
219
|
+
let isSelected = false;
|
|
220
|
+
if (value) {
|
|
221
|
+
const selectedDate = new Date(value);
|
|
222
|
+
isSelected = isSameDay(selectedDate, thisDate);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
date,
|
|
226
|
+
month: previousMonth.getMonth(),
|
|
227
|
+
isToday: isToday(thisDate),
|
|
228
|
+
isSelected,
|
|
229
|
+
fullDate: thisDate
|
|
230
|
+
};
|
|
231
|
+
}).sort((a, b) => a.date - b.date);
|
|
232
|
+
const allDays2 = new Array(totalDays).fill("").map((_, index) => {
|
|
233
|
+
const date = index + 1;
|
|
234
|
+
const thisDate = new Date(
|
|
235
|
+
currentMonth.getFullYear(),
|
|
236
|
+
currentMonth.getMonth(),
|
|
237
|
+
date
|
|
238
|
+
);
|
|
239
|
+
let isSelected = false;
|
|
240
|
+
if (value) {
|
|
241
|
+
const selectedDate = new Date(value);
|
|
242
|
+
isSelected = isSameDay(selectedDate, thisDate);
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
date,
|
|
246
|
+
month: currentMonth.getMonth(),
|
|
247
|
+
isToday: isToday(thisDate),
|
|
248
|
+
isSelected,
|
|
249
|
+
fullDate: thisDate
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
const nextDays = new Array(
|
|
253
|
+
42 - prevDays.length - allDays2.length
|
|
254
|
+
).fill("").map((_, index) => {
|
|
255
|
+
const date = index + 1;
|
|
256
|
+
const thisDate = new Date(
|
|
257
|
+
nextMonth.getFullYear(),
|
|
258
|
+
nextMonth.getMonth(),
|
|
259
|
+
date
|
|
260
|
+
);
|
|
261
|
+
let isSelected = false;
|
|
262
|
+
if (value) {
|
|
263
|
+
const selectedDate = new Date(value);
|
|
264
|
+
isSelected = isSameDay(selectedDate, thisDate);
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
date,
|
|
268
|
+
month: nextMonth.getMonth(),
|
|
269
|
+
isToday: isToday(thisDate),
|
|
270
|
+
isSelected,
|
|
271
|
+
fullDate: thisDate
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
return [...prevDays, ...allDays2, ...nextDays];
|
|
275
|
+
}, [currentMonth, value]);
|
|
276
|
+
const pickerTopLabel = useMemo2(() => {
|
|
277
|
+
if (selectionMode == "day") {
|
|
278
|
+
return format(currentMonth, "MMM, yyyy");
|
|
279
|
+
} else if (selectionMode == "month") {
|
|
280
|
+
return format(currentMonth, "yyyy");
|
|
281
|
+
} else if (selectionMode == "year") {
|
|
282
|
+
const currentYear = currentMonth.getFullYear();
|
|
283
|
+
const startYear = currentYear - currentYear % 10 - 1;
|
|
284
|
+
const endYear = startYear + 10 + 2;
|
|
285
|
+
setAllYears(
|
|
286
|
+
new Array(endYear - startYear).fill("").map((_, ind) => startYear + ind)
|
|
287
|
+
);
|
|
288
|
+
return format(currentMonth, `${startYear + 1} - ${endYear - 2}`);
|
|
289
|
+
}
|
|
290
|
+
}, [currentMonth, selectionMode]);
|
|
291
|
+
const datesContent = /* @__PURE__ */ jsxs3("div", { className: "dateMainContainer", children: [
|
|
292
|
+
/* @__PURE__ */ jsx5("div", { className: "daysContainer", children: daysShortName.map((day, index) => /* @__PURE__ */ jsx5("div", { className: "dateItem", children: day }, `${day}_${index}`)) }),
|
|
293
|
+
/* @__PURE__ */ jsx5("div", { className: "dateContainer", children: allDays.map((day) => /* @__PURE__ */ jsx5(
|
|
294
|
+
"div",
|
|
295
|
+
{
|
|
296
|
+
className: `dateItem ${day.month != currentMonth.getMonth() && "nextPreviousDate__"} ${day.isToday && "isToday__"} ${day.isSelected && "isSelected__"}`,
|
|
297
|
+
onClick: () => {
|
|
298
|
+
onChange(day.fullDate);
|
|
299
|
+
updateShow(false);
|
|
300
|
+
},
|
|
301
|
+
children: day.date
|
|
302
|
+
}
|
|
303
|
+
)) })
|
|
304
|
+
] });
|
|
305
|
+
const monthsContent = /* @__PURE__ */ jsx5("div", { className: "monthContainer", children: monthsShortName.map((mth, mthInd) => /* @__PURE__ */ jsx5(
|
|
306
|
+
"div",
|
|
307
|
+
{
|
|
308
|
+
className: `monthItem ${mth == monthsShortName[(/* @__PURE__ */ new Date()).getMonth()] && (/* @__PURE__ */ new Date()).getFullYear() == currentMonth.getFullYear() && "isToday__"} ${value && mth == monthsShortName[new Date(value).getMonth()] && currentMonth.getFullYear() == new Date(value).getFullYear() && "isSelected__"}`,
|
|
309
|
+
onClick: () => {
|
|
310
|
+
setCurrentMonth(setMonth(currentMonth, mthInd));
|
|
311
|
+
setTimeout(() => {
|
|
312
|
+
setSelectionMode("day");
|
|
313
|
+
}, 10);
|
|
314
|
+
},
|
|
315
|
+
children: mth
|
|
316
|
+
}
|
|
317
|
+
)) });
|
|
318
|
+
const yearContent = /* @__PURE__ */ jsx5("div", { className: "monthContainer", children: allYears.map((yr, yrInd) => /* @__PURE__ */ jsx5(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
className: `monthItem ${(/* @__PURE__ */ new Date()).getFullYear() == yr && "isToday__"} ${value && yr == new Date(value).getFullYear() && "isSelected__"} ${(yrInd == 0 || yrInd == allYears.length - 1) && "nextPreviousDate__"}`,
|
|
322
|
+
onClick: () => {
|
|
323
|
+
setCurrentMonth(setYear(currentMonth, yr));
|
|
324
|
+
setTimeout(() => {
|
|
325
|
+
setSelectionMode("month");
|
|
326
|
+
}, 10);
|
|
327
|
+
},
|
|
328
|
+
children: yr
|
|
329
|
+
}
|
|
330
|
+
)) });
|
|
331
|
+
const pickerContent = useMemo2(() => {
|
|
332
|
+
if (selectionMode == "day") {
|
|
333
|
+
return datesContent;
|
|
334
|
+
} else if (selectionMode == "month") {
|
|
335
|
+
return monthsContent;
|
|
336
|
+
} else if (selectionMode == "year") {
|
|
337
|
+
return yearContent;
|
|
338
|
+
}
|
|
339
|
+
}, [selectionMode, allDays, currentMonth, allYears]);
|
|
340
|
+
return /* @__PURE__ */ jsxs3("div", { className: `webDatePickerMainContainer ${show ? "show__" : "hide__"}`, children: [
|
|
341
|
+
/* @__PURE__ */ jsxs3("div", { className: "topContainer", children: [
|
|
342
|
+
/* @__PURE__ */ jsx5(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
className: `monthName ${selectionMode == "year" && "noClick__"}`,
|
|
346
|
+
onClick: switchMode,
|
|
347
|
+
children: pickerTopLabel
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ jsx5("div", { onClick: onMinus, children: /* @__PURE__ */ jsx5(Icon_default, { className: `nextPreviousIcon previous__`, src: dropdown_default }) }),
|
|
351
|
+
/* @__PURE__ */ jsx5("div", { onClick: onAdd, children: /* @__PURE__ */ jsx5(Icon_default, { className: "nextPreviousIcon", src: dropdown_default }) })
|
|
352
|
+
] }),
|
|
353
|
+
pickerContent,
|
|
354
|
+
/* @__PURE__ */ jsx5(
|
|
355
|
+
Button_default,
|
|
356
|
+
{
|
|
357
|
+
onClick: () => setCurrentMonth(/* @__PURE__ */ new Date()),
|
|
358
|
+
className: "todayButton",
|
|
359
|
+
size: "small",
|
|
360
|
+
removeMinWidth: true,
|
|
361
|
+
children: "Today"
|
|
362
|
+
}
|
|
363
|
+
)
|
|
364
|
+
] });
|
|
365
|
+
};
|
|
366
|
+
var WebDatePicker_default = WebDatePicker;
|
|
367
|
+
|
|
368
|
+
// src/components/datePicker/DatePicker.tsx
|
|
369
|
+
import { useFormContext } from "react-hook-form";
|
|
370
|
+
import { format as format2 } from "date-fns";
|
|
371
|
+
|
|
372
|
+
// src/components/drawer/Drawer.tsx
|
|
373
|
+
import { useEffect as useEffect2 } from "react";
|
|
374
|
+
import "./Drawer-5ZWJQFIQ.css";
|
|
375
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
376
|
+
var Drawer = ({ show, updateShow, children }) => {
|
|
377
|
+
useEffect2(() => {
|
|
378
|
+
document.body.style.overflow = show ? "hidden" : "auto";
|
|
379
|
+
}, [show]);
|
|
380
|
+
return /* @__PURE__ */ jsxs4("div", { className: "drawerMainContainer", children: [
|
|
381
|
+
/* @__PURE__ */ jsx6(
|
|
382
|
+
"div",
|
|
383
|
+
{
|
|
384
|
+
onClick: () => updateShow(false),
|
|
385
|
+
className: `drawerBackgroundContainer ${show ? "show__" : "hide__"}`
|
|
386
|
+
}
|
|
387
|
+
),
|
|
388
|
+
/* @__PURE__ */ jsx6("div", { className: `drawerContentContainer ${show ? "show__" : "hide__"}`, children })
|
|
389
|
+
] });
|
|
390
|
+
};
|
|
391
|
+
var Drawer_default = Drawer;
|
|
392
|
+
|
|
393
|
+
// src/components/datePicker/DatePicker.tsx
|
|
394
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
395
|
+
var DatePicker = ({
|
|
396
|
+
id,
|
|
397
|
+
label = "Label",
|
|
398
|
+
placeholder = "Placeholder",
|
|
399
|
+
loading = false,
|
|
400
|
+
disabled = false
|
|
401
|
+
}) => {
|
|
402
|
+
const datePickerRef = useRef(null);
|
|
403
|
+
const isMobile = false;
|
|
404
|
+
const { getValues } = useFormContext();
|
|
405
|
+
const [showPicker, setShowPicker] = useState2(false);
|
|
406
|
+
const docOnClickHandler = (e) => {
|
|
407
|
+
if (datePickerRef.current && e.target) {
|
|
408
|
+
if (datePickerRef.current && !datePickerRef.current.contains(e.target)) {
|
|
409
|
+
setShowPicker(false);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
useEffect3(() => {
|
|
414
|
+
document.addEventListener("click", docOnClickHandler);
|
|
415
|
+
return () => {
|
|
416
|
+
document.removeEventListener("click", docOnClickHandler);
|
|
417
|
+
};
|
|
418
|
+
}, []);
|
|
419
|
+
return /* @__PURE__ */ jsxs5("div", { className: "datePickerMainContainer", ref: datePickerRef, children: [
|
|
420
|
+
/* @__PURE__ */ jsx7("div", { children: label }),
|
|
421
|
+
/* @__PURE__ */ jsxs5(
|
|
422
|
+
"div",
|
|
423
|
+
{
|
|
424
|
+
className: `pickerContainer ${disabled && disabled}`,
|
|
425
|
+
onClick: () => {
|
|
426
|
+
if (!disabled) {
|
|
427
|
+
setShowPicker(!showPicker);
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
children: [
|
|
431
|
+
/* @__PURE__ */ jsxs5("div", { className: "valueContainer", children: [
|
|
432
|
+
/* @__PURE__ */ jsx7("div", { className: `${!getValues(id) && placeholder}`, children: getValues(id) ? format2(getValues(id), "dd MMM yyyy") : placeholder }),
|
|
433
|
+
/* @__PURE__ */ jsx7(
|
|
434
|
+
Icon_default,
|
|
435
|
+
{
|
|
436
|
+
src: dropdown_default,
|
|
437
|
+
className: `dropdownIcon ${showPicker ? "dropdownIconFlip" : ""}`
|
|
438
|
+
}
|
|
439
|
+
)
|
|
440
|
+
] }),
|
|
441
|
+
loading && /* @__PURE__ */ jsx7(SkeletonLoading_default, { radius: 8 })
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
),
|
|
445
|
+
isMobile ? /* @__PURE__ */ jsx7(Drawer_default, { show: showPicker, updateShow: setShowPicker, children: /* @__PURE__ */ jsx7(WebDatePicker_default, { id, show: showPicker, updateShow: setShowPicker }) }) : /* @__PURE__ */ jsx7(WebDatePicker_default, { id, show: showPicker, updateShow: setShowPicker })
|
|
446
|
+
] });
|
|
447
|
+
};
|
|
448
|
+
var DatePicker_default = DatePicker;
|
|
449
|
+
|
|
450
|
+
// src/components/dropdown/Dropdown.tsx
|
|
451
|
+
import { useEffect as useEffect4, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
|
|
452
|
+
import { useController as useController3 } from "react-hook-form";
|
|
453
|
+
|
|
454
|
+
// src/assets/check.svg
|
|
455
|
+
var check_default = 'data:image/svg+xml,<?xml version="1.0" encoding="iso-8859-1"?>%0A<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->%0A<svg fill="%231A1A1A" version="1.1" baseProfile="basic" id="Layer_1"%0A%09 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 72 72"%0A%09 xml:space="preserve">%0A<path d="M57.658,12.643c1.854,1.201,2.384,3.678,1.183,5.532l-25.915,40c-0.682,1.051-1.815,1.723-3.064,1.814%0A%09C29.764,59.997,29.665,60,29.568,60c-1.146,0-2.241-0.491-3.003-1.358L13.514,43.807c-1.459-1.659-1.298-4.186,0.36-5.646%0A%09c1.662-1.46,4.188-1.296,5.646,0.361l9.563,10.87l23.043-35.567C53.329,11.971,55.806,11.442,57.658,12.643z"/>%0A</svg>';
|
|
456
|
+
|
|
457
|
+
// src/components/dropdown/Dropdown.tsx
|
|
458
|
+
import "./Dropdown-VC55KPC2.css";
|
|
459
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
460
|
+
var Dropdown = ({
|
|
461
|
+
id,
|
|
462
|
+
options,
|
|
463
|
+
label = "Label",
|
|
464
|
+
placeholder = "Placeholder",
|
|
465
|
+
loading = false,
|
|
466
|
+
disabled = false
|
|
467
|
+
}) => {
|
|
468
|
+
const isMobile = false;
|
|
469
|
+
const dropdownContainerRef = useRef2(null);
|
|
470
|
+
const [showDropdown, setShowDropdown] = useState3(false);
|
|
471
|
+
const {
|
|
472
|
+
field: { onChange, value }
|
|
473
|
+
} = useController3({ name: id });
|
|
474
|
+
const docOnClickHandler = (e) => {
|
|
475
|
+
if (dropdownContainerRef.current && e.target) {
|
|
476
|
+
if (dropdownContainerRef.current && !dropdownContainerRef.current.contains(e.target)) {
|
|
477
|
+
setShowDropdown(false);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
useEffect4(() => {
|
|
482
|
+
document.addEventListener("click", docOnClickHandler);
|
|
483
|
+
return () => {
|
|
484
|
+
document.removeEventListener("click", docOnClickHandler);
|
|
485
|
+
};
|
|
486
|
+
}, []);
|
|
487
|
+
const selectedLabel = useMemo3(() => {
|
|
488
|
+
if (value) {
|
|
489
|
+
const selected = options.find((opt) => opt.value == value);
|
|
490
|
+
return selected ? selected.label : "";
|
|
491
|
+
}
|
|
492
|
+
return "";
|
|
493
|
+
}, [value, options]);
|
|
494
|
+
const dropdownOptionContent = /* @__PURE__ */ jsx8(
|
|
495
|
+
"div",
|
|
496
|
+
{
|
|
497
|
+
className: `dropdownOptionsContainer ${showDropdown ? "show__" : "hide__"}`,
|
|
498
|
+
children: options.map((opt) => /* @__PURE__ */ jsxs6(
|
|
499
|
+
"div",
|
|
500
|
+
{
|
|
501
|
+
className: "dropdownOptions",
|
|
502
|
+
onClick: () => {
|
|
503
|
+
onChange(opt.value);
|
|
504
|
+
setShowDropdown(false);
|
|
505
|
+
},
|
|
506
|
+
children: [
|
|
507
|
+
/* @__PURE__ */ jsx8("div", { children: opt.label }),
|
|
508
|
+
value == opt.value && /* @__PURE__ */ jsx8(Icon_default, { src: check_default, className: "dropdownIcon" })
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
))
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
return /* @__PURE__ */ jsxs6("div", { className: "dropdownContainer", ref: dropdownContainerRef, children: [
|
|
515
|
+
/* @__PURE__ */ jsx8("div", { children: label }),
|
|
516
|
+
/* @__PURE__ */ jsxs6(
|
|
517
|
+
"div",
|
|
518
|
+
{
|
|
519
|
+
className: `dropdown ${!selectedLabel && "placeholder__"} ${disabled && "disabled__"}`,
|
|
520
|
+
onClick: () => {
|
|
521
|
+
if (!disabled) {
|
|
522
|
+
setShowDropdown(!showDropdown);
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
children: [
|
|
526
|
+
/* @__PURE__ */ jsx8("div", { children: selectedLabel || placeholder }),
|
|
527
|
+
/* @__PURE__ */ jsx8(
|
|
528
|
+
Icon_default,
|
|
529
|
+
{
|
|
530
|
+
src: dropdown_default,
|
|
531
|
+
className: `dropdownIcon ${showDropdown && "dropdownIconFlip"}`
|
|
532
|
+
}
|
|
533
|
+
),
|
|
534
|
+
loading && /* @__PURE__ */ jsx8(SkeletonLoading_default, {})
|
|
535
|
+
]
|
|
536
|
+
}
|
|
537
|
+
),
|
|
538
|
+
isMobile ? /* @__PURE__ */ jsx8(Drawer_default, { show: showDropdown, updateShow: setShowDropdown, children: dropdownOptionContent }) : dropdownOptionContent
|
|
539
|
+
] });
|
|
540
|
+
};
|
|
541
|
+
var Dropdown_default = Dropdown;
|
|
542
|
+
|
|
543
|
+
// src/hooks/useSnackbar.ts
|
|
544
|
+
import { useEffect as useEffect5, useRef as useRef3, useState as useState4 } from "react";
|
|
545
|
+
var useSnackbar = (body, id = "snackbarRoot", timeout = 3e3) => {
|
|
546
|
+
const snackbarElement = useRef3(null);
|
|
547
|
+
const timeoutId = useRef3(null);
|
|
548
|
+
let root = document.getElementById(id);
|
|
549
|
+
const [isShowing, setIsShowing] = useState4(false);
|
|
550
|
+
const hoverInHandler = () => {
|
|
551
|
+
if (timeoutId.current) {
|
|
552
|
+
clearTimeout(timeoutId.current);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const hoverOutHandler = () => {
|
|
556
|
+
timeoutId.current = setTimeout(() => {
|
|
557
|
+
closeSnackbar();
|
|
558
|
+
}, timeout);
|
|
559
|
+
};
|
|
560
|
+
useEffect5(() => {
|
|
561
|
+
if (!root) {
|
|
562
|
+
const rootDiv = document.createElement("div");
|
|
563
|
+
rootDiv.setAttribute("id", id);
|
|
564
|
+
const contentDiv = document.createElement("div");
|
|
565
|
+
contentDiv.className = "snackbarContentContainer";
|
|
566
|
+
const contentInnerDiv = document.createElement("div");
|
|
567
|
+
contentInnerDiv.className = "hide__";
|
|
568
|
+
contentDiv.appendChild(contentInnerDiv);
|
|
569
|
+
rootDiv.appendChild(contentDiv);
|
|
570
|
+
if (body) {
|
|
571
|
+
body.appendChild(rootDiv);
|
|
572
|
+
} else {
|
|
573
|
+
document.body.appendChild(rootDiv);
|
|
574
|
+
}
|
|
575
|
+
root = rootDiv;
|
|
576
|
+
}
|
|
577
|
+
if (root) {
|
|
578
|
+
const snackbarContainer = root.children[0];
|
|
579
|
+
if (snackbarContainer) {
|
|
580
|
+
const snackbar = snackbarContainer.children[0];
|
|
581
|
+
if (snackbar) {
|
|
582
|
+
snackbarElement.current = snackbar;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}, []);
|
|
587
|
+
const showSnackbar = (message, type = "info") => {
|
|
588
|
+
let animTimeout = 0;
|
|
589
|
+
if (isShowing) {
|
|
590
|
+
closeSnackbar();
|
|
591
|
+
animTimeout = 300;
|
|
592
|
+
}
|
|
593
|
+
setTimeout(() => {
|
|
594
|
+
if (snackbarElement.current) {
|
|
595
|
+
snackbarElement.current.innerHTML = message;
|
|
596
|
+
snackbarElement.current.className = `show__ ${type}__`;
|
|
597
|
+
setIsShowing(true);
|
|
598
|
+
}
|
|
599
|
+
}, animTimeout);
|
|
600
|
+
};
|
|
601
|
+
const closeSnackbar = () => {
|
|
602
|
+
if (snackbarElement.current) {
|
|
603
|
+
snackbarElement.current.className = `hide__`;
|
|
604
|
+
setIsShowing(false);
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
useEffect5(() => {
|
|
608
|
+
if (isShowing && snackbarElement.current) {
|
|
609
|
+
snackbarElement.current.addEventListener("mouseenter", hoverInHandler);
|
|
610
|
+
snackbarElement.current.addEventListener("mouseleave", hoverOutHandler);
|
|
611
|
+
if (timeoutId.current) {
|
|
612
|
+
clearTimeout(timeoutId.current);
|
|
613
|
+
}
|
|
614
|
+
timeoutId.current = setTimeout(() => {
|
|
615
|
+
closeSnackbar();
|
|
616
|
+
}, timeout);
|
|
617
|
+
} else if (snackbarElement.current) {
|
|
618
|
+
snackbarElement.current.removeEventListener("mouseenter", hoverInHandler);
|
|
619
|
+
snackbarElement.current.removeEventListener(
|
|
620
|
+
"mouseleave",
|
|
621
|
+
hoverOutHandler
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
}, [isShowing]);
|
|
625
|
+
return {
|
|
626
|
+
showSnackbar
|
|
627
|
+
};
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
// src/hooks/usePostMessage.ts
|
|
631
|
+
import { useEffect as useEffect6 } from "react";
|
|
632
|
+
var usePostMessage = (url) => {
|
|
633
|
+
const sendDimension = () => {
|
|
634
|
+
const body = document.body;
|
|
635
|
+
const html = document.documentElement;
|
|
636
|
+
const width = Math.max(
|
|
637
|
+
body.scrollWidth,
|
|
638
|
+
body.offsetWidth,
|
|
639
|
+
html.clientWidth,
|
|
640
|
+
html.scrollWidth,
|
|
641
|
+
html.offsetWidth
|
|
642
|
+
);
|
|
643
|
+
const height = Math.max(
|
|
644
|
+
body.scrollHeight,
|
|
645
|
+
body.offsetHeight,
|
|
646
|
+
html.clientHeight,
|
|
647
|
+
html.scrollHeight,
|
|
648
|
+
html.offsetHeight
|
|
649
|
+
);
|
|
650
|
+
window.parent.postMessage({ type: "resize", height, width }, url);
|
|
651
|
+
};
|
|
652
|
+
const postMessage = (data) => {
|
|
653
|
+
window.parent.postMessage(data, url);
|
|
654
|
+
};
|
|
655
|
+
const postNotification = (data) => {
|
|
656
|
+
window.parent.postMessage(
|
|
657
|
+
{
|
|
658
|
+
type: "noti",
|
|
659
|
+
data
|
|
660
|
+
},
|
|
661
|
+
url
|
|
662
|
+
);
|
|
663
|
+
};
|
|
664
|
+
const postPopup = (data) => {
|
|
665
|
+
window.parent.postMessage({ type: "popup", data }, url);
|
|
666
|
+
};
|
|
667
|
+
const postQuestion = (data) => {
|
|
668
|
+
window.parent.postMessage({ type: "question", data }, url);
|
|
669
|
+
let resolve;
|
|
670
|
+
const prom = new Promise((res) => resolve = res);
|
|
671
|
+
const messageHandler = (ev) => {
|
|
672
|
+
resolve(ev.data);
|
|
673
|
+
window.removeEventListener("message", messageHandler);
|
|
674
|
+
};
|
|
675
|
+
window.addEventListener("message", messageHandler);
|
|
676
|
+
return prom;
|
|
677
|
+
};
|
|
678
|
+
useEffect6(() => {
|
|
679
|
+
sendDimension();
|
|
680
|
+
window.addEventListener("DOMContentLoaded", sendDimension);
|
|
681
|
+
window.addEventListener("resize", sendDimension);
|
|
682
|
+
return () => {
|
|
683
|
+
window.removeEventListener("DOMContentLoaded", sendDimension);
|
|
684
|
+
window.removeEventListener("resize", sendDimension);
|
|
685
|
+
};
|
|
686
|
+
}, []);
|
|
687
|
+
return {
|
|
688
|
+
sendDimension,
|
|
689
|
+
postMessage,
|
|
690
|
+
postNotification,
|
|
691
|
+
postPopup,
|
|
692
|
+
postQuestion
|
|
693
|
+
};
|
|
694
|
+
};
|
|
61
695
|
export {
|
|
696
|
+
Button_default as Button,
|
|
697
|
+
DatePicker_default as DatePicker,
|
|
698
|
+
Drawer_default as Drawer,
|
|
699
|
+
Dropdown_default as Dropdown,
|
|
700
|
+
Icon_default as Icon,
|
|
62
701
|
Input_default as Input,
|
|
63
|
-
SkeletonLoading_default as SkeletonLoading
|
|
702
|
+
SkeletonLoading_default as SkeletonLoading,
|
|
703
|
+
usePostMessage,
|
|
704
|
+
useSnackbar
|
|
64
705
|
};
|
|
65
706
|
//# sourceMappingURL=index.mjs.map
|