@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.js
CHANGED
|
@@ -19,11 +19,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/index.ts
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
|
+
Button: () => Button_default,
|
|
23
|
+
DatePicker: () => DatePicker_default,
|
|
24
|
+
Drawer: () => Drawer_default,
|
|
25
|
+
Dropdown: () => Dropdown_default,
|
|
26
|
+
Icon: () => Icon_default,
|
|
22
27
|
Input: () => Input_default,
|
|
23
|
-
SkeletonLoading: () => SkeletonLoading_default
|
|
28
|
+
SkeletonLoading: () => SkeletonLoading_default,
|
|
29
|
+
usePostMessage: () => usePostMessage,
|
|
30
|
+
useSnackbar: () => useSnackbar
|
|
24
31
|
});
|
|
25
32
|
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
var import_index = require("./index-
|
|
33
|
+
var import_index = require("./index-2F2GVZE5.css");
|
|
27
34
|
|
|
28
35
|
// src/components/input/Input.tsx
|
|
29
36
|
var import_react_hook_form = require("react-hook-form");
|
|
@@ -82,9 +89,640 @@ var Input = ({
|
|
|
82
89
|
] });
|
|
83
90
|
};
|
|
84
91
|
var Input_default = Input;
|
|
92
|
+
|
|
93
|
+
// src/components/button/Button.tsx
|
|
94
|
+
var import_react = require("react");
|
|
95
|
+
var import_Button = require("./Button-GX4BPUGQ.css");
|
|
96
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
97
|
+
var Button = ({
|
|
98
|
+
children,
|
|
99
|
+
onClick,
|
|
100
|
+
className,
|
|
101
|
+
type = "submit",
|
|
102
|
+
disabled = false,
|
|
103
|
+
loading = false,
|
|
104
|
+
size = "default",
|
|
105
|
+
removeMinWidth = false
|
|
106
|
+
}) => {
|
|
107
|
+
const buttonClass = (0, import_react.useMemo)(() => {
|
|
108
|
+
if (disabled || loading) return "disabledBtn";
|
|
109
|
+
switch (type) {
|
|
110
|
+
case "submit":
|
|
111
|
+
return "submitBtn";
|
|
112
|
+
case "danger":
|
|
113
|
+
return "dangerBtn";
|
|
114
|
+
case "warning":
|
|
115
|
+
return "warningBtn";
|
|
116
|
+
}
|
|
117
|
+
}, [type, disabled, loading]);
|
|
118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
119
|
+
"button",
|
|
120
|
+
{
|
|
121
|
+
className: `mainBtn ${className} ${buttonClass} ${`${size}__`} ${removeMinWidth && "noMinWidth__"}`,
|
|
122
|
+
onClick: () => {
|
|
123
|
+
if (!disabled) onClick();
|
|
124
|
+
},
|
|
125
|
+
disabled: disabled || loading,
|
|
126
|
+
children: [
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: loading ? "hideContent" : "", children }),
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `loadingCircle ${loading && "show__"}` })
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
var Button_default = Button;
|
|
134
|
+
|
|
135
|
+
// src/components/datePicker/DatePicker.tsx
|
|
136
|
+
var import_react4 = require("react");
|
|
137
|
+
var import_DatePicker = require("./DatePicker-ISUX6NNC.css");
|
|
138
|
+
|
|
139
|
+
// src/components/icon/Icon.tsx
|
|
140
|
+
var import_Icon = require("./Icon-DCSTRBMX.css");
|
|
141
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
142
|
+
var Icon = ({ src, className, flat = true }) => {
|
|
143
|
+
const classNames = ["icon", className, flat ? "flat__" : ""].join(" ");
|
|
144
|
+
return flat ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { className: classNames, src: src && src.toString() }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
145
|
+
"i",
|
|
146
|
+
{
|
|
147
|
+
className: classNames,
|
|
148
|
+
style: {
|
|
149
|
+
maskImage: `url("${src}"`,
|
|
150
|
+
WebkitMaskImage: `url("${src}")`
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
var Icon_default = Icon;
|
|
156
|
+
|
|
157
|
+
// src/assets/dropdown.svg
|
|
158
|
+
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>';
|
|
159
|
+
|
|
160
|
+
// src/components/datePicker/components/webDatePicker/WebDatePicker.tsx
|
|
161
|
+
var import_react2 = require("react");
|
|
162
|
+
var import_WebDatePicker = require("./WebDatePicker-H2XZEEJG.css");
|
|
163
|
+
var import_date_fns = require("date-fns");
|
|
164
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
165
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
166
|
+
var daysShortName = ["S", "M", "T", "W", "T", "F", "S"];
|
|
167
|
+
var monthsShortName = [
|
|
168
|
+
"Jan",
|
|
169
|
+
"Feb",
|
|
170
|
+
"Mar",
|
|
171
|
+
"Apr",
|
|
172
|
+
"May",
|
|
173
|
+
"Jun",
|
|
174
|
+
"Jul",
|
|
175
|
+
"Aug",
|
|
176
|
+
"Sep",
|
|
177
|
+
"Oct",
|
|
178
|
+
"Nov",
|
|
179
|
+
"Dec"
|
|
180
|
+
];
|
|
181
|
+
var WebDatePicker = ({
|
|
182
|
+
id,
|
|
183
|
+
show,
|
|
184
|
+
updateShow
|
|
185
|
+
}) => {
|
|
186
|
+
const [currentMonth, setCurrentMonth] = (0, import_react2.useState)(/* @__PURE__ */ new Date());
|
|
187
|
+
const [selectionMode, setSelectionMode] = (0, import_react2.useState)(
|
|
188
|
+
"day"
|
|
189
|
+
);
|
|
190
|
+
const [allYears, setAllYears] = (0, import_react2.useState)([]);
|
|
191
|
+
const {
|
|
192
|
+
field: { onChange, value }
|
|
193
|
+
} = (0, import_react_hook_form2.useController)({ name: id });
|
|
194
|
+
(0, import_react2.useEffect)(() => {
|
|
195
|
+
if (show && value) {
|
|
196
|
+
setCurrentMonth(new Date(value));
|
|
197
|
+
}
|
|
198
|
+
if (show) {
|
|
199
|
+
setSelectionMode("day");
|
|
200
|
+
}
|
|
201
|
+
}, [show]);
|
|
202
|
+
const onAdd = () => {
|
|
203
|
+
if (selectionMode == "day") {
|
|
204
|
+
setCurrentMonth((0, import_date_fns.addMonths)(currentMonth, 1));
|
|
205
|
+
} else if (selectionMode == "month") {
|
|
206
|
+
setCurrentMonth((0, import_date_fns.addYears)(currentMonth, 1));
|
|
207
|
+
} else if (selectionMode == "year") {
|
|
208
|
+
setCurrentMonth((0, import_date_fns.addYears)(currentMonth, 10));
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const onMinus = () => {
|
|
212
|
+
if (selectionMode == "day") {
|
|
213
|
+
setCurrentMonth((0, import_date_fns.addMonths)(currentMonth, -1));
|
|
214
|
+
} else if (selectionMode == "month") {
|
|
215
|
+
setCurrentMonth((0, import_date_fns.addYears)(currentMonth, -1));
|
|
216
|
+
} else if (selectionMode == "year") {
|
|
217
|
+
setCurrentMonth((0, import_date_fns.addYears)(currentMonth, -10));
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const switchMode = () => {
|
|
221
|
+
if (selectionMode == "day") {
|
|
222
|
+
setSelectionMode("month");
|
|
223
|
+
} else if (selectionMode == "month") {
|
|
224
|
+
setSelectionMode("year");
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const allDays = (0, import_react2.useMemo)(() => {
|
|
228
|
+
const totalDays = (0, import_date_fns.getDaysInMonth)(currentMonth);
|
|
229
|
+
const firstDay = (0, import_date_fns.startOfMonth)(currentMonth).getDay() || 7;
|
|
230
|
+
const previousMonth = (0, import_date_fns.addMonths)(currentMonth, -1);
|
|
231
|
+
const previousMonthTotalDays = (0, import_date_fns.getDaysInMonth)(previousMonth);
|
|
232
|
+
const nextMonth = (0, import_date_fns.addMonths)(currentMonth, 1);
|
|
233
|
+
const prevDays = new Array(firstDay).fill("").map((_, index) => {
|
|
234
|
+
const date = previousMonthTotalDays - index;
|
|
235
|
+
const thisDate = new Date(
|
|
236
|
+
previousMonth.getFullYear(),
|
|
237
|
+
previousMonth.getMonth(),
|
|
238
|
+
date
|
|
239
|
+
);
|
|
240
|
+
let isSelected = false;
|
|
241
|
+
if (value) {
|
|
242
|
+
const selectedDate = new Date(value);
|
|
243
|
+
isSelected = (0, import_date_fns.isSameDay)(selectedDate, thisDate);
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
date,
|
|
247
|
+
month: previousMonth.getMonth(),
|
|
248
|
+
isToday: (0, import_date_fns.isToday)(thisDate),
|
|
249
|
+
isSelected,
|
|
250
|
+
fullDate: thisDate
|
|
251
|
+
};
|
|
252
|
+
}).sort((a, b) => a.date - b.date);
|
|
253
|
+
const allDays2 = new Array(totalDays).fill("").map((_, index) => {
|
|
254
|
+
const date = index + 1;
|
|
255
|
+
const thisDate = new Date(
|
|
256
|
+
currentMonth.getFullYear(),
|
|
257
|
+
currentMonth.getMonth(),
|
|
258
|
+
date
|
|
259
|
+
);
|
|
260
|
+
let isSelected = false;
|
|
261
|
+
if (value) {
|
|
262
|
+
const selectedDate = new Date(value);
|
|
263
|
+
isSelected = (0, import_date_fns.isSameDay)(selectedDate, thisDate);
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
date,
|
|
267
|
+
month: currentMonth.getMonth(),
|
|
268
|
+
isToday: (0, import_date_fns.isToday)(thisDate),
|
|
269
|
+
isSelected,
|
|
270
|
+
fullDate: thisDate
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
const nextDays = new Array(
|
|
274
|
+
42 - prevDays.length - allDays2.length
|
|
275
|
+
).fill("").map((_, index) => {
|
|
276
|
+
const date = index + 1;
|
|
277
|
+
const thisDate = new Date(
|
|
278
|
+
nextMonth.getFullYear(),
|
|
279
|
+
nextMonth.getMonth(),
|
|
280
|
+
date
|
|
281
|
+
);
|
|
282
|
+
let isSelected = false;
|
|
283
|
+
if (value) {
|
|
284
|
+
const selectedDate = new Date(value);
|
|
285
|
+
isSelected = (0, import_date_fns.isSameDay)(selectedDate, thisDate);
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
date,
|
|
289
|
+
month: nextMonth.getMonth(),
|
|
290
|
+
isToday: (0, import_date_fns.isToday)(thisDate),
|
|
291
|
+
isSelected,
|
|
292
|
+
fullDate: thisDate
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
return [...prevDays, ...allDays2, ...nextDays];
|
|
296
|
+
}, [currentMonth, value]);
|
|
297
|
+
const pickerTopLabel = (0, import_react2.useMemo)(() => {
|
|
298
|
+
if (selectionMode == "day") {
|
|
299
|
+
return (0, import_date_fns.format)(currentMonth, "MMM, yyyy");
|
|
300
|
+
} else if (selectionMode == "month") {
|
|
301
|
+
return (0, import_date_fns.format)(currentMonth, "yyyy");
|
|
302
|
+
} else if (selectionMode == "year") {
|
|
303
|
+
const currentYear = currentMonth.getFullYear();
|
|
304
|
+
const startYear = currentYear - currentYear % 10 - 1;
|
|
305
|
+
const endYear = startYear + 10 + 2;
|
|
306
|
+
setAllYears(
|
|
307
|
+
new Array(endYear - startYear).fill("").map((_, ind) => startYear + ind)
|
|
308
|
+
);
|
|
309
|
+
return (0, import_date_fns.format)(currentMonth, `${startYear + 1} - ${endYear - 2}`);
|
|
310
|
+
}
|
|
311
|
+
}, [currentMonth, selectionMode]);
|
|
312
|
+
const datesContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dateMainContainer", children: [
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "daysContainer", children: daysShortName.map((day, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dateItem", children: day }, `${day}_${index}`)) }),
|
|
314
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "dateContainer", children: allDays.map((day) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
315
|
+
"div",
|
|
316
|
+
{
|
|
317
|
+
className: `dateItem ${day.month != currentMonth.getMonth() && "nextPreviousDate__"} ${day.isToday && "isToday__"} ${day.isSelected && "isSelected__"}`,
|
|
318
|
+
onClick: () => {
|
|
319
|
+
onChange(day.fullDate);
|
|
320
|
+
updateShow(false);
|
|
321
|
+
},
|
|
322
|
+
children: day.date
|
|
323
|
+
}
|
|
324
|
+
)) })
|
|
325
|
+
] });
|
|
326
|
+
const monthsContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "monthContainer", children: monthsShortName.map((mth, mthInd) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
327
|
+
"div",
|
|
328
|
+
{
|
|
329
|
+
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__"}`,
|
|
330
|
+
onClick: () => {
|
|
331
|
+
setCurrentMonth((0, import_date_fns.setMonth)(currentMonth, mthInd));
|
|
332
|
+
setTimeout(() => {
|
|
333
|
+
setSelectionMode("day");
|
|
334
|
+
}, 10);
|
|
335
|
+
},
|
|
336
|
+
children: mth
|
|
337
|
+
}
|
|
338
|
+
)) });
|
|
339
|
+
const yearContent = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "monthContainer", children: allYears.map((yr, yrInd) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
340
|
+
"div",
|
|
341
|
+
{
|
|
342
|
+
className: `monthItem ${(/* @__PURE__ */ new Date()).getFullYear() == yr && "isToday__"} ${value && yr == new Date(value).getFullYear() && "isSelected__"} ${(yrInd == 0 || yrInd == allYears.length - 1) && "nextPreviousDate__"}`,
|
|
343
|
+
onClick: () => {
|
|
344
|
+
setCurrentMonth((0, import_date_fns.setYear)(currentMonth, yr));
|
|
345
|
+
setTimeout(() => {
|
|
346
|
+
setSelectionMode("month");
|
|
347
|
+
}, 10);
|
|
348
|
+
},
|
|
349
|
+
children: yr
|
|
350
|
+
}
|
|
351
|
+
)) });
|
|
352
|
+
const pickerContent = (0, import_react2.useMemo)(() => {
|
|
353
|
+
if (selectionMode == "day") {
|
|
354
|
+
return datesContent;
|
|
355
|
+
} else if (selectionMode == "month") {
|
|
356
|
+
return monthsContent;
|
|
357
|
+
} else if (selectionMode == "year") {
|
|
358
|
+
return yearContent;
|
|
359
|
+
}
|
|
360
|
+
}, [selectionMode, allDays, currentMonth, allYears]);
|
|
361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `webDatePickerMainContainer ${show ? "show__" : "hide__"}`, children: [
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "topContainer", children: [
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
364
|
+
"div",
|
|
365
|
+
{
|
|
366
|
+
className: `monthName ${selectionMode == "year" && "noClick__"}`,
|
|
367
|
+
onClick: switchMode,
|
|
368
|
+
children: pickerTopLabel
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { onClick: onMinus, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon_default, { className: `nextPreviousIcon previous__`, src: dropdown_default }) }),
|
|
372
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { onClick: onAdd, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon_default, { className: "nextPreviousIcon", src: dropdown_default }) })
|
|
373
|
+
] }),
|
|
374
|
+
pickerContent,
|
|
375
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
376
|
+
Button_default,
|
|
377
|
+
{
|
|
378
|
+
onClick: () => setCurrentMonth(/* @__PURE__ */ new Date()),
|
|
379
|
+
className: "todayButton",
|
|
380
|
+
size: "small",
|
|
381
|
+
removeMinWidth: true,
|
|
382
|
+
children: "Today"
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
] });
|
|
386
|
+
};
|
|
387
|
+
var WebDatePicker_default = WebDatePicker;
|
|
388
|
+
|
|
389
|
+
// src/components/datePicker/DatePicker.tsx
|
|
390
|
+
var import_react_hook_form3 = require("react-hook-form");
|
|
391
|
+
var import_date_fns2 = require("date-fns");
|
|
392
|
+
|
|
393
|
+
// src/components/drawer/Drawer.tsx
|
|
394
|
+
var import_react3 = require("react");
|
|
395
|
+
var import_Drawer = require("./Drawer-5ZWJQFIQ.css");
|
|
396
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
397
|
+
var Drawer = ({ show, updateShow, children }) => {
|
|
398
|
+
(0, import_react3.useEffect)(() => {
|
|
399
|
+
document.body.style.overflow = show ? "hidden" : "auto";
|
|
400
|
+
}, [show]);
|
|
401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "drawerMainContainer", children: [
|
|
402
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
403
|
+
"div",
|
|
404
|
+
{
|
|
405
|
+
onClick: () => updateShow(false),
|
|
406
|
+
className: `drawerBackgroundContainer ${show ? "show__" : "hide__"}`
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `drawerContentContainer ${show ? "show__" : "hide__"}`, children })
|
|
410
|
+
] });
|
|
411
|
+
};
|
|
412
|
+
var Drawer_default = Drawer;
|
|
413
|
+
|
|
414
|
+
// src/components/datePicker/DatePicker.tsx
|
|
415
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
416
|
+
var DatePicker = ({
|
|
417
|
+
id,
|
|
418
|
+
label = "Label",
|
|
419
|
+
placeholder = "Placeholder",
|
|
420
|
+
loading = false,
|
|
421
|
+
disabled = false
|
|
422
|
+
}) => {
|
|
423
|
+
const datePickerRef = (0, import_react4.useRef)(null);
|
|
424
|
+
const isMobile = false;
|
|
425
|
+
const { getValues } = (0, import_react_hook_form3.useFormContext)();
|
|
426
|
+
const [showPicker, setShowPicker] = (0, import_react4.useState)(false);
|
|
427
|
+
const docOnClickHandler = (e) => {
|
|
428
|
+
if (datePickerRef.current && e.target) {
|
|
429
|
+
if (datePickerRef.current && !datePickerRef.current.contains(e.target)) {
|
|
430
|
+
setShowPicker(false);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
(0, import_react4.useEffect)(() => {
|
|
435
|
+
document.addEventListener("click", docOnClickHandler);
|
|
436
|
+
return () => {
|
|
437
|
+
document.removeEventListener("click", docOnClickHandler);
|
|
438
|
+
};
|
|
439
|
+
}, []);
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "datePickerMainContainer", ref: datePickerRef, children: [
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: label }),
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
443
|
+
"div",
|
|
444
|
+
{
|
|
445
|
+
className: `pickerContainer ${disabled && disabled}`,
|
|
446
|
+
onClick: () => {
|
|
447
|
+
if (!disabled) {
|
|
448
|
+
setShowPicker(!showPicker);
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
children: [
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "valueContainer", children: [
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `${!getValues(id) && placeholder}`, children: getValues(id) ? (0, import_date_fns2.format)(getValues(id), "dd MMM yyyy") : placeholder }),
|
|
454
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
455
|
+
Icon_default,
|
|
456
|
+
{
|
|
457
|
+
src: dropdown_default,
|
|
458
|
+
className: `dropdownIcon ${showPicker ? "dropdownIconFlip" : ""}`
|
|
459
|
+
}
|
|
460
|
+
)
|
|
461
|
+
] }),
|
|
462
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SkeletonLoading_default, { radius: 8 })
|
|
463
|
+
]
|
|
464
|
+
}
|
|
465
|
+
),
|
|
466
|
+
isMobile ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Drawer_default, { show: showPicker, updateShow: setShowPicker, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WebDatePicker_default, { id, show: showPicker, updateShow: setShowPicker }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WebDatePicker_default, { id, show: showPicker, updateShow: setShowPicker })
|
|
467
|
+
] });
|
|
468
|
+
};
|
|
469
|
+
var DatePicker_default = DatePicker;
|
|
470
|
+
|
|
471
|
+
// src/components/dropdown/Dropdown.tsx
|
|
472
|
+
var import_react5 = require("react");
|
|
473
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
474
|
+
|
|
475
|
+
// src/assets/check.svg
|
|
476
|
+
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>';
|
|
477
|
+
|
|
478
|
+
// src/components/dropdown/Dropdown.tsx
|
|
479
|
+
var import_Dropdown = require("./Dropdown-VC55KPC2.css");
|
|
480
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
481
|
+
var Dropdown = ({
|
|
482
|
+
id,
|
|
483
|
+
options,
|
|
484
|
+
label = "Label",
|
|
485
|
+
placeholder = "Placeholder",
|
|
486
|
+
loading = false,
|
|
487
|
+
disabled = false
|
|
488
|
+
}) => {
|
|
489
|
+
const isMobile = false;
|
|
490
|
+
const dropdownContainerRef = (0, import_react5.useRef)(null);
|
|
491
|
+
const [showDropdown, setShowDropdown] = (0, import_react5.useState)(false);
|
|
492
|
+
const {
|
|
493
|
+
field: { onChange, value }
|
|
494
|
+
} = (0, import_react_hook_form4.useController)({ name: id });
|
|
495
|
+
const docOnClickHandler = (e) => {
|
|
496
|
+
if (dropdownContainerRef.current && e.target) {
|
|
497
|
+
if (dropdownContainerRef.current && !dropdownContainerRef.current.contains(e.target)) {
|
|
498
|
+
setShowDropdown(false);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
(0, import_react5.useEffect)(() => {
|
|
503
|
+
document.addEventListener("click", docOnClickHandler);
|
|
504
|
+
return () => {
|
|
505
|
+
document.removeEventListener("click", docOnClickHandler);
|
|
506
|
+
};
|
|
507
|
+
}, []);
|
|
508
|
+
const selectedLabel = (0, import_react5.useMemo)(() => {
|
|
509
|
+
if (value) {
|
|
510
|
+
const selected = options.find((opt) => opt.value == value);
|
|
511
|
+
return selected ? selected.label : "";
|
|
512
|
+
}
|
|
513
|
+
return "";
|
|
514
|
+
}, [value, options]);
|
|
515
|
+
const dropdownOptionContent = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
516
|
+
"div",
|
|
517
|
+
{
|
|
518
|
+
className: `dropdownOptionsContainer ${showDropdown ? "show__" : "hide__"}`,
|
|
519
|
+
children: options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
520
|
+
"div",
|
|
521
|
+
{
|
|
522
|
+
className: "dropdownOptions",
|
|
523
|
+
onClick: () => {
|
|
524
|
+
onChange(opt.value);
|
|
525
|
+
setShowDropdown(false);
|
|
526
|
+
},
|
|
527
|
+
children: [
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: opt.label }),
|
|
529
|
+
value == opt.value && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon_default, { src: check_default, className: "dropdownIcon" })
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
))
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dropdownContainer", ref: dropdownContainerRef, children: [
|
|
536
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: label }),
|
|
537
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
538
|
+
"div",
|
|
539
|
+
{
|
|
540
|
+
className: `dropdown ${!selectedLabel && "placeholder__"} ${disabled && "disabled__"}`,
|
|
541
|
+
onClick: () => {
|
|
542
|
+
if (!disabled) {
|
|
543
|
+
setShowDropdown(!showDropdown);
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
children: [
|
|
547
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: selectedLabel || placeholder }),
|
|
548
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
549
|
+
Icon_default,
|
|
550
|
+
{
|
|
551
|
+
src: dropdown_default,
|
|
552
|
+
className: `dropdownIcon ${showDropdown && "dropdownIconFlip"}`
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SkeletonLoading_default, {})
|
|
556
|
+
]
|
|
557
|
+
}
|
|
558
|
+
),
|
|
559
|
+
isMobile ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Drawer_default, { show: showDropdown, updateShow: setShowDropdown, children: dropdownOptionContent }) : dropdownOptionContent
|
|
560
|
+
] });
|
|
561
|
+
};
|
|
562
|
+
var Dropdown_default = Dropdown;
|
|
563
|
+
|
|
564
|
+
// src/hooks/useSnackbar.ts
|
|
565
|
+
var import_react6 = require("react");
|
|
566
|
+
var useSnackbar = (body, id = "snackbarRoot", timeout = 3e3) => {
|
|
567
|
+
const snackbarElement = (0, import_react6.useRef)(null);
|
|
568
|
+
const timeoutId = (0, import_react6.useRef)(null);
|
|
569
|
+
let root = document.getElementById(id);
|
|
570
|
+
const [isShowing, setIsShowing] = (0, import_react6.useState)(false);
|
|
571
|
+
const hoverInHandler = () => {
|
|
572
|
+
if (timeoutId.current) {
|
|
573
|
+
clearTimeout(timeoutId.current);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
const hoverOutHandler = () => {
|
|
577
|
+
timeoutId.current = setTimeout(() => {
|
|
578
|
+
closeSnackbar();
|
|
579
|
+
}, timeout);
|
|
580
|
+
};
|
|
581
|
+
(0, import_react6.useEffect)(() => {
|
|
582
|
+
if (!root) {
|
|
583
|
+
const rootDiv = document.createElement("div");
|
|
584
|
+
rootDiv.setAttribute("id", id);
|
|
585
|
+
const contentDiv = document.createElement("div");
|
|
586
|
+
contentDiv.className = "snackbarContentContainer";
|
|
587
|
+
const contentInnerDiv = document.createElement("div");
|
|
588
|
+
contentInnerDiv.className = "hide__";
|
|
589
|
+
contentDiv.appendChild(contentInnerDiv);
|
|
590
|
+
rootDiv.appendChild(contentDiv);
|
|
591
|
+
if (body) {
|
|
592
|
+
body.appendChild(rootDiv);
|
|
593
|
+
} else {
|
|
594
|
+
document.body.appendChild(rootDiv);
|
|
595
|
+
}
|
|
596
|
+
root = rootDiv;
|
|
597
|
+
}
|
|
598
|
+
if (root) {
|
|
599
|
+
const snackbarContainer = root.children[0];
|
|
600
|
+
if (snackbarContainer) {
|
|
601
|
+
const snackbar = snackbarContainer.children[0];
|
|
602
|
+
if (snackbar) {
|
|
603
|
+
snackbarElement.current = snackbar;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}, []);
|
|
608
|
+
const showSnackbar = (message, type = "info") => {
|
|
609
|
+
let animTimeout = 0;
|
|
610
|
+
if (isShowing) {
|
|
611
|
+
closeSnackbar();
|
|
612
|
+
animTimeout = 300;
|
|
613
|
+
}
|
|
614
|
+
setTimeout(() => {
|
|
615
|
+
if (snackbarElement.current) {
|
|
616
|
+
snackbarElement.current.innerHTML = message;
|
|
617
|
+
snackbarElement.current.className = `show__ ${type}__`;
|
|
618
|
+
setIsShowing(true);
|
|
619
|
+
}
|
|
620
|
+
}, animTimeout);
|
|
621
|
+
};
|
|
622
|
+
const closeSnackbar = () => {
|
|
623
|
+
if (snackbarElement.current) {
|
|
624
|
+
snackbarElement.current.className = `hide__`;
|
|
625
|
+
setIsShowing(false);
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
(0, import_react6.useEffect)(() => {
|
|
629
|
+
if (isShowing && snackbarElement.current) {
|
|
630
|
+
snackbarElement.current.addEventListener("mouseenter", hoverInHandler);
|
|
631
|
+
snackbarElement.current.addEventListener("mouseleave", hoverOutHandler);
|
|
632
|
+
if (timeoutId.current) {
|
|
633
|
+
clearTimeout(timeoutId.current);
|
|
634
|
+
}
|
|
635
|
+
timeoutId.current = setTimeout(() => {
|
|
636
|
+
closeSnackbar();
|
|
637
|
+
}, timeout);
|
|
638
|
+
} else if (snackbarElement.current) {
|
|
639
|
+
snackbarElement.current.removeEventListener("mouseenter", hoverInHandler);
|
|
640
|
+
snackbarElement.current.removeEventListener(
|
|
641
|
+
"mouseleave",
|
|
642
|
+
hoverOutHandler
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
}, [isShowing]);
|
|
646
|
+
return {
|
|
647
|
+
showSnackbar
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/hooks/usePostMessage.ts
|
|
652
|
+
var import_react7 = require("react");
|
|
653
|
+
var usePostMessage = (url) => {
|
|
654
|
+
const sendDimension = () => {
|
|
655
|
+
const body = document.body;
|
|
656
|
+
const html = document.documentElement;
|
|
657
|
+
const width = Math.max(
|
|
658
|
+
body.scrollWidth,
|
|
659
|
+
body.offsetWidth,
|
|
660
|
+
html.clientWidth,
|
|
661
|
+
html.scrollWidth,
|
|
662
|
+
html.offsetWidth
|
|
663
|
+
);
|
|
664
|
+
const height = Math.max(
|
|
665
|
+
body.scrollHeight,
|
|
666
|
+
body.offsetHeight,
|
|
667
|
+
html.clientHeight,
|
|
668
|
+
html.scrollHeight,
|
|
669
|
+
html.offsetHeight
|
|
670
|
+
);
|
|
671
|
+
window.parent.postMessage({ type: "resize", height, width }, url);
|
|
672
|
+
};
|
|
673
|
+
const postMessage = (data) => {
|
|
674
|
+
window.parent.postMessage(data, url);
|
|
675
|
+
};
|
|
676
|
+
const postNotification = (data) => {
|
|
677
|
+
window.parent.postMessage(
|
|
678
|
+
{
|
|
679
|
+
type: "noti",
|
|
680
|
+
data
|
|
681
|
+
},
|
|
682
|
+
url
|
|
683
|
+
);
|
|
684
|
+
};
|
|
685
|
+
const postPopup = (data) => {
|
|
686
|
+
window.parent.postMessage({ type: "popup", data }, url);
|
|
687
|
+
};
|
|
688
|
+
const postQuestion = (data) => {
|
|
689
|
+
window.parent.postMessage({ type: "question", data }, url);
|
|
690
|
+
let resolve;
|
|
691
|
+
const prom = new Promise((res) => resolve = res);
|
|
692
|
+
const messageHandler = (ev) => {
|
|
693
|
+
resolve(ev.data);
|
|
694
|
+
window.removeEventListener("message", messageHandler);
|
|
695
|
+
};
|
|
696
|
+
window.addEventListener("message", messageHandler);
|
|
697
|
+
return prom;
|
|
698
|
+
};
|
|
699
|
+
(0, import_react7.useEffect)(() => {
|
|
700
|
+
sendDimension();
|
|
701
|
+
window.addEventListener("DOMContentLoaded", sendDimension);
|
|
702
|
+
window.addEventListener("resize", sendDimension);
|
|
703
|
+
return () => {
|
|
704
|
+
window.removeEventListener("DOMContentLoaded", sendDimension);
|
|
705
|
+
window.removeEventListener("resize", sendDimension);
|
|
706
|
+
};
|
|
707
|
+
}, []);
|
|
708
|
+
return {
|
|
709
|
+
sendDimension,
|
|
710
|
+
postMessage,
|
|
711
|
+
postNotification,
|
|
712
|
+
postPopup,
|
|
713
|
+
postQuestion
|
|
714
|
+
};
|
|
715
|
+
};
|
|
85
716
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
717
|
0 && (module.exports = {
|
|
718
|
+
Button,
|
|
719
|
+
DatePicker,
|
|
720
|
+
Drawer,
|
|
721
|
+
Dropdown,
|
|
722
|
+
Icon,
|
|
87
723
|
Input,
|
|
88
|
-
SkeletonLoading
|
|
724
|
+
SkeletonLoading,
|
|
725
|
+
usePostMessage,
|
|
726
|
+
useSnackbar
|
|
89
727
|
});
|
|
90
728
|
//# sourceMappingURL=index.js.map
|