@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260924115534 → 0.8.1-dev.20260926063530

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.
@@ -1,1836 +0,0 @@
1
- "use client";
2
- import {
3
- Icon_default
4
- } from "./chunk-6PW2RLUJ.mjs";
5
- import {
6
- Hyperlink
7
- } from "./chunk-2R26M6CK.mjs";
8
- import {
9
- InputControlType_default
10
- } from "./chunk-HRDHAIZF.mjs";
11
- import {
12
- Button_default,
13
- ClientButton_default
14
- } from "./chunk-4WMSS6CE.mjs";
15
- import "./chunk-56HSDML5.mjs";
16
- import {
17
- AssetUtility_default
18
- } from "./chunk-TQ6BXQ3A.mjs";
19
-
20
- // src/components/controls/edit/InputControlClient.tsx
21
- import React20 from "react";
22
-
23
- // src/components/controls/edit/MultilineTextInput.tsx
24
- import React from "react";
25
- import { jsx, jsxs } from "react/jsx-runtime";
26
- var MultilineTextInput = (props) => {
27
- const textChangeHandler = (event) => {
28
- const text = event.target.value;
29
- if (props.callback !== void 0) {
30
- props.callback(
31
- {
32
- name: props.name,
33
- value: text,
34
- index: props.index,
35
- groupKey: props.groupKey
36
- }
37
- );
38
- }
39
- };
40
- let value = "";
41
- if (props.value !== void 0 && props.value !== null) {
42
- value = props.value;
43
- }
44
- return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsxs("label", { className: "block mb-1", children: [
45
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
46
- " ",
47
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx("span", { className: "bg-error-weak", children: "*" }),
48
- /* @__PURE__ */ jsx(
49
- "textarea",
50
- {
51
- name: props.name,
52
- id: props.name,
53
- value,
54
- onChange: textChangeHandler,
55
- onBlur: props?.onBlur,
56
- rows: 4,
57
- required: props?.attributes?.required,
58
- placeholder: props?.attributes?.placeholder,
59
- maxLength: props?.attributes?.maxLength,
60
- disabled: props?.attributes?.readOnly,
61
- minLength: props?.attributes?.minLength,
62
- className: "peer mt-1 py-1.5 block w-full rounded shadow-sm input"
63
- }
64
- ),
65
- /* @__PURE__ */ jsx("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
66
- ] }) });
67
- };
68
- var MultilineTextInput_default = MultilineTextInput;
69
-
70
- // src/components/controls/edit/LineTextInput.tsx
71
- import React2 from "react";
72
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
73
- var LineTextInput = (props) => {
74
- const textChangeHandler = (event) => {
75
- const text = event.target.value;
76
- if (props.callback !== void 0) {
77
- props.callback(
78
- {
79
- name: props.name,
80
- value: text,
81
- index: props.index,
82
- groupKey: props.groupKey
83
- }
84
- );
85
- }
86
- };
87
- let value = "";
88
- if (props.value !== void 0 && props.value !== null) {
89
- value = props.value;
90
- }
91
- return /* @__PURE__ */ jsx2(React2.Fragment, { children: /* @__PURE__ */ jsxs2("label", { className: "block", children: [
92
- props?.attributes?.label && /* @__PURE__ */ jsx2("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
93
- " ",
94
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx2("span", { className: "bg-error-weak !bg-transparent", children: "*" }),
95
- /* @__PURE__ */ jsx2(
96
- "input",
97
- {
98
- type: "text",
99
- name: props.name,
100
- id: props.name,
101
- value,
102
- onChange: textChangeHandler,
103
- onBlur: props?.onBlur,
104
- autoFocus: props?.attributes?.autoFocus,
105
- required: props?.attributes?.required,
106
- placeholder: props?.attributes?.placeholder,
107
- maxLength: props?.attributes?.maxLength,
108
- pattern: props?.attributes?.pattern,
109
- disabled: props?.attributes?.readOnly,
110
- minLength: props?.attributes?.minLength,
111
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm transition-all duration-500 ease-in-out
112
- ${props?.inputClasses ? props.inputClasses : ``}
113
- `
114
- }
115
- ),
116
- /* @__PURE__ */ jsx2("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
117
- ] }) });
118
- };
119
- var LineTextInput_default = LineTextInput;
120
-
121
- // src/components/controls/edit/MoneyInput.tsx
122
- import React3 from "react";
123
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
124
- var MoneyInput = (props) => {
125
- const textChangeHandler = (event) => {
126
- const rawValue = event.target.value;
127
- const numericValue = parseFloat(rawValue);
128
- if (rawValue === "" || !isNaN(numericValue) && numericValue >= 0) {
129
- if (props.callback !== void 0) {
130
- props.callback({
131
- name: props.name,
132
- value: rawValue,
133
- index: props.index,
134
- groupKey: props.groupKey
135
- });
136
- }
137
- }
138
- };
139
- const handleWheel = (event) => {
140
- event.preventDefault();
141
- event.target.blur();
142
- };
143
- let value = "";
144
- if (props.value !== void 0 && props.value !== null) {
145
- value = props.value;
146
- }
147
- const preventNegative = (e) => {
148
- if (e.key === "-") {
149
- e.preventDefault();
150
- }
151
- };
152
- return /* @__PURE__ */ jsx3(React3.Fragment, { children: /* @__PURE__ */ jsxs3("label", { className: "block", children: [
153
- props?.attributes?.label && /* @__PURE__ */ jsx3("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
154
- " ",
155
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx3("span", { className: "bg-error-weak", children: "*" }),
156
- /* @__PURE__ */ jsx3(
157
- "input",
158
- {
159
- type: "number",
160
- name: props.name,
161
- id: props.name,
162
- value,
163
- min: 0,
164
- onChange: textChangeHandler,
165
- onBlur: props?.onBlur,
166
- autoFocus: props?.attributes?.autoFocus,
167
- onWheel: handleWheel,
168
- onKeyDown: preventNegative,
169
- required: props?.attributes?.required,
170
- placeholder: props?.attributes?.placeholder,
171
- maxLength: props?.attributes?.maxLength,
172
- pattern: props?.attributes?.pattern,
173
- disabled: props?.attributes?.readOnly,
174
- minLength: props?.attributes?.minLength,
175
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm number-input transition-all duration-500 ease-in-out
176
- ${props?.inputClasses ? props.inputClasses : ``}
177
- `
178
- }
179
- ),
180
- /* @__PURE__ */ jsx3("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
181
- ] }) });
182
- };
183
- var MoneyInput_default = MoneyInput;
184
-
185
- // src/components/controls/edit/Select.tsx
186
- import { useState, useEffect } from "react";
187
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
188
- var Select = (props) => {
189
- const [list, setList] = useState();
190
- const getSafeValue = (val) => {
191
- if (val === null || val === void 0) return "";
192
- if (typeof val === "boolean") return val ? "1" : "0";
193
- return val;
194
- };
195
- const textChangeHandler = (event) => {
196
- let rawValue = event.target.value;
197
- if (rawValue === "") rawValue = null;
198
- let finalValue = rawValue;
199
- if (list && props.dataKeyFieldName) {
200
- const key = props.dataKeyFieldName;
201
- const selectedItem = list.find(
202
- (item) => String(item[key]) === String(rawValue)
203
- );
204
- if (selectedItem) {
205
- const keyValue = selectedItem[key];
206
- if (typeof keyValue === "number") {
207
- finalValue = Number(rawValue);
208
- }
209
- }
210
- }
211
- props.callback?.({
212
- name: props.name,
213
- value: finalValue,
214
- index: props.index,
215
- groupKey: props.groupKey
216
- });
217
- };
218
- const inputChangeHandler = (event) => {
219
- props.callback?.({
220
- name: props.name,
221
- value: event.target.value,
222
- index: props.index,
223
- groupKey: props.groupKey
224
- });
225
- };
226
- useEffect(() => {
227
- async function fetchData() {
228
- if (props.dataset) {
229
- setList(props.dataset);
230
- return;
231
- }
232
- if (props.dataSource && props.serviceClient) {
233
- let dataSource = props.dataSource;
234
- let response;
235
- if (props.dataSourceDependsOn) {
236
- if (!props.dependentValue) {
237
- setList([]);
238
- return;
239
- }
240
- dataSource = dataSource.replace(
241
- `{${props.dataSourceDependsOn}}`,
242
- props.dependentValue
243
- );
244
- }
245
- response = await props.serviceClient.get(dataSource);
246
- setList(response.result ?? []);
247
- return;
248
- }
249
- setList([]);
250
- }
251
- fetchData();
252
- }, [
253
- props.dataset,
254
- props.dataSource,
255
- props.dependentValue,
256
- props.dataSourceDependsOn
257
- ]);
258
- const value = getSafeValue(props.value);
259
- return /* @__PURE__ */ jsxs4("label", { className: "block", children: [
260
- props.attributes?.label && /* @__PURE__ */ jsx4("span", { className: "text-sm font-medium inline-block pb-1", children: props.attributes?.label }),
261
- " ",
262
- props.attributes?.label && props.attributes?.required && /* @__PURE__ */ jsx4("span", { className: "bg-error-weak", children: "*" }),
263
- list && list.length === 0 && /* @__PURE__ */ jsx4(
264
- "input",
265
- {
266
- type: "text",
267
- name: props.name,
268
- id: props.name,
269
- value,
270
- onChange: inputChangeHandler,
271
- required: props.attributes?.required,
272
- placeholder: props.attributes?.placeholder,
273
- maxLength: props.attributes?.maxLength,
274
- pattern: props.attributes?.pattern,
275
- disabled: props.attributes?.readOnly,
276
- minLength: props.attributes?.minLength,
277
- className: `peer input select mt-1 py-1.5 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`
278
- }
279
- ),
280
- list && list.length > 0 && /* @__PURE__ */ jsxs4(
281
- "select",
282
- {
283
- name: props.name,
284
- id: props.name,
285
- value,
286
- onChange: textChangeHandler,
287
- required: props.attributes?.required,
288
- disabled: props.attributes?.readOnly,
289
- className: `peer select py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
290
- focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
291
- disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none ${props.inputClasses ?? ""}`,
292
- children: [
293
- /* @__PURE__ */ jsx4("option", { value: "", children: props.attributes?.placeholder || "Select" }),
294
- list.map((item, index) => {
295
- const keyField = props.dataKeyFieldName;
296
- const textField = props.dataTextFieldName;
297
- return /* @__PURE__ */ jsx4("option", { value: item[keyField], children: item[textField] }, index);
298
- })
299
- ]
300
- }
301
- ),
302
- /* @__PURE__ */ jsx4("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: props.attributes?.errorMessage || "" })
303
- ] });
304
- };
305
- var Select_default = Select;
306
-
307
- // src/components/controls/edit/PercentageInput.tsx
308
- import React5 from "react";
309
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
310
- var PercentageInput = (props) => {
311
- const textChangeHandler = (event) => {
312
- const rawValue = event.target.value;
313
- const numericValue = parseFloat(rawValue);
314
- if (rawValue === "" || !isNaN(numericValue) && numericValue >= 0) {
315
- if (props.callback !== void 0) {
316
- props.callback({
317
- name: props.name,
318
- value: rawValue,
319
- index: props.index,
320
- groupKey: props.groupKey
321
- });
322
- }
323
- }
324
- };
325
- const handleWheel = (event) => {
326
- event.preventDefault();
327
- event.target.blur();
328
- };
329
- let value = "";
330
- if (props.value !== void 0 && props.value !== null) {
331
- value = props.value;
332
- }
333
- const preventNegative = (e) => {
334
- if (e.key === "-") {
335
- e.preventDefault();
336
- }
337
- };
338
- return /* @__PURE__ */ jsx5(React5.Fragment, { children: /* @__PURE__ */ jsxs5("label", { className: "block", children: [
339
- props?.attributes?.label && /* @__PURE__ */ jsx5("span", { className: "text-sm inline-block pb-1 font-medium ", children: props.attributes.label + " %" }),
340
- " ",
341
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx5("span", { className: "bg-error-weak", children: "*" }),
342
- /* @__PURE__ */ jsx5(
343
- "input",
344
- {
345
- type: "number",
346
- name: props.name,
347
- id: props.name,
348
- value,
349
- min: 0,
350
- onChange: textChangeHandler,
351
- onBlur: props?.onBlur,
352
- autoFocus: props?.attributes?.autoFocus,
353
- onKeyDown: preventNegative,
354
- onWheel: handleWheel,
355
- required: props?.attributes?.required,
356
- placeholder: props?.attributes?.placeholder,
357
- pattern: props?.attributes?.pattern,
358
- disabled: props?.attributes?.readOnly,
359
- max: "100",
360
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm number-input transition-all duration-500 ease-in-out
361
- ${props?.inputClasses ? props.inputClasses : ``}
362
- `
363
- }
364
- ),
365
- /* @__PURE__ */ jsx5("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
366
- ] }) });
367
- };
368
- var PercentageInput_default = PercentageInput;
369
-
370
- // src/components/controls/edit/PhoneInput.tsx
371
- import React6 from "react";
372
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
373
- var PhoneInput = (props) => {
374
- const textChangeHandler = (event) => {
375
- const text = event.target.value;
376
- if (props.callback !== void 0) {
377
- props.callback(
378
- {
379
- name: props.name,
380
- value: text,
381
- index: props.index,
382
- groupKey: props.groupKey
383
- }
384
- );
385
- }
386
- };
387
- let value = "";
388
- if (props.value !== void 0 && props.value !== null) {
389
- value = props.value;
390
- }
391
- return /* @__PURE__ */ jsx6(React6.Fragment, { children: /* @__PURE__ */ jsxs6("label", { className: "block mb-1", children: [
392
- /* @__PURE__ */ jsx6("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
393
- " ",
394
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx6("span", { className: "bg-error-weak", children: "*" }),
395
- /* @__PURE__ */ jsxs6("div", { className: "flex items-center rounded border ", children: [
396
- /* @__PURE__ */ jsx6("span", { className: "px-3", children: props.prefix }),
397
- /* @__PURE__ */ jsx6(
398
- "input",
399
- {
400
- type: "text",
401
- name: props.name,
402
- id: props.name,
403
- value,
404
- onChange: textChangeHandler,
405
- required: props?.attributes?.required,
406
- placeholder: props?.attributes?.placeholder,
407
- maxLength: props?.attributes?.maxLength,
408
- pattern: props?.attributes?.pattern,
409
- disabled: props?.attributes?.readOnly,
410
- minLength: props?.attributes?.minLength,
411
- className: "py-1.5 block w-full outline-none border-0 mr-0.5"
412
- }
413
- )
414
- ] }),
415
- /* @__PURE__ */ jsx6("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
416
- ] }) });
417
- };
418
- var PhoneInput_default = PhoneInput;
419
-
420
- // src/components/controls/edit/NumberInput.tsx
421
- import React7 from "react";
422
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
423
- var NumberInput = (props) => {
424
- const textChangeHandler = (event) => {
425
- const text = event.target.value;
426
- if (props.callback !== void 0) {
427
- props.callback({
428
- name: props.name,
429
- value: text,
430
- index: props.index,
431
- groupKey: props.groupKey
432
- });
433
- }
434
- };
435
- const handleWheel = (event) => {
436
- event.preventDefault();
437
- event.target.blur();
438
- };
439
- let value = "";
440
- if (props.value !== void 0 && props.value !== null) {
441
- value = props.value;
442
- }
443
- return /* @__PURE__ */ jsx7(React7.Fragment, { children: /* @__PURE__ */ jsxs7("label", { className: "block", children: [
444
- props?.attributes?.label && /* @__PURE__ */ jsx7("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
445
- " ",
446
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx7("span", { className: "bg-error-weak", children: "*" }),
447
- /* @__PURE__ */ jsx7(
448
- "input",
449
- {
450
- type: "number",
451
- name: props.name,
452
- id: props.name,
453
- value,
454
- onChange: textChangeHandler,
455
- onWheel: handleWheel,
456
- onBlur: props?.onBlur,
457
- autoFocus: props?.attributes?.autoFocus,
458
- required: props?.attributes?.required,
459
- placeholder: props?.attributes?.placeholder,
460
- pattern: props?.attributes?.pattern,
461
- disabled: props?.attributes?.readOnly,
462
- max: props?.attributes?.maxValue,
463
- min: props?.attributes?.minValue,
464
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm number-input transition-all duration-500 ease-in-out
465
- ${props?.inputClasses ? props.inputClasses : ``}
466
- `
467
- }
468
- ),
469
- /* @__PURE__ */ jsx7("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
470
- ] }) });
471
- };
472
- var NumberInput_default = NumberInput;
473
-
474
- // src/components/controls/edit/CheckboxInput.tsx
475
- import React8 from "react";
476
- import { Fragment, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
477
- var CheckboxInput = (props) => {
478
- const isReadOnly = props.attributes?.readOnly === true || props.attributes?.readOnly === "true" || props?.readOnly === true || props.disable === true || props.attributes?.disable === true || props.attributes?.disabled === true || props.attributes?.disabled === "true";
479
- const textChangeHandler = (event) => {
480
- if (isReadOnly) return;
481
- const text = event.target.checked;
482
- if (props.callback !== void 0) {
483
- props.callback({
484
- name: props.name,
485
- value: text,
486
- index: props.index,
487
- groupKey: props.groupKey
488
- });
489
- }
490
- };
491
- let value = false;
492
- if (props.value !== void 0 && props.value !== null && props.value !== "" && (props.value === true || props.value === "true" || props.value.toString().toLowerCase() === "true" || props.value === 1 || props.value === "1")) {
493
- value = true;
494
- }
495
- const customClasses = (props?.inputClasses || "").split(/\s+/).filter((c) => !/^(w-|h-|block|inline-block|py-|px-|p-)/.test(c)).join(" ");
496
- return /* @__PURE__ */ jsx8(React8.Fragment, { children: /* @__PURE__ */ jsxs8("div", { className: `mb-1 ${isReadOnly ? "cursor-not-allowed" : ""}`, children: [
497
- props?.attributes?.label && /* @__PURE__ */ jsxs8(Fragment, { children: [
498
- /* @__PURE__ */ jsx8(
499
- "label",
500
- {
501
- htmlFor: props.name,
502
- className: "inline-block text-sm font-medium pb-1",
503
- children: props.attributes.label
504
- }
505
- ),
506
- " ",
507
- props?.attributes?.required && /* @__PURE__ */ jsx8("span", { className: "bg-error-weak", children: "*" })
508
- ] }),
509
- /* @__PURE__ */ jsx8(
510
- "input",
511
- {
512
- type: "checkbox",
513
- name: props.name,
514
- id: props.name,
515
- checked: value,
516
- onChange: textChangeHandler,
517
- onBlur: props?.onBlur,
518
- autoFocus: props?.attributes?.autoFocus,
519
- required: !isReadOnly && Boolean(props?.attributes?.required),
520
- placeholder: props?.attributes?.placeholder,
521
- maxLength: props?.attributes?.maxLength,
522
- pattern: props?.attributes?.pattern,
523
- disabled: isReadOnly,
524
- readOnly: isReadOnly,
525
- tabIndex: isReadOnly ? -1 : void 0,
526
- onClick: (e) => {
527
- if (isReadOnly) {
528
- e.preventDefault();
529
- e.stopPropagation();
530
- }
531
- },
532
- minLength: props?.attributes?.minLength,
533
- className: `peer mt-1 h-4 w-4 shrink-0 rounded shadow-sm transition-all duration-200 ${isReadOnly ? "cursor-not-allowed pointer-events-none" : "cursor-pointer"} ${customClasses}`
534
- }
535
- ),
536
- /* @__PURE__ */ jsx8("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage || "" })
537
- ] }) });
538
- };
539
- var CheckboxInput_default = CheckboxInput;
540
-
541
- // src/components/controls/edit/OtpInput.tsx
542
- import React9 from "react";
543
- import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
544
- var OtpInput = (props) => {
545
- const textChangeHandler = (event) => {
546
- const text = event.target.value;
547
- if (props.callback !== void 0) {
548
- props.callback({
549
- name: props.name,
550
- value: text,
551
- index: props.index,
552
- groupKey: props.groupKey
553
- });
554
- }
555
- };
556
- const handleWheel = (event) => {
557
- event.preventDefault();
558
- };
559
- let value = "";
560
- if (props.value !== void 0 && props.value !== null) {
561
- value = props.value;
562
- }
563
- return /* @__PURE__ */ jsx9(React9.Fragment, { children: /* @__PURE__ */ jsxs9("label", { htmlFor: props.name, className: "block w-full", children: [
564
- props?.attributes?.label && /* @__PURE__ */ jsx9("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
565
- " ",
566
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx9("span", { className: "bg-error-weak", children: "*" }),
567
- /* @__PURE__ */ jsx9(
568
- "input",
569
- {
570
- type: "text",
571
- name: props.name,
572
- id: props.name,
573
- value,
574
- onChange: textChangeHandler,
575
- onBlur: props?.onBlur,
576
- autoComplete: "off",
577
- required: props?.attributes?.required,
578
- placeholder: props?.attributes?.placeholder,
579
- maxLength: 4,
580
- pattern: props?.attributes?.pattern,
581
- disabled: props?.attributes?.readOnly,
582
- minLength: props?.attributes?.minLength,
583
- autoFocus: props?.attributes?.autoFocus,
584
- onWheel: handleWheel,
585
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm tracking-[1.25em] text-center transition-all duration-500 ease-in-out
586
- ${props?.inputClasses ? props.inputClasses : ``}
587
- `
588
- }
589
- ),
590
- /* @__PURE__ */ jsx9("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
591
- ] }) });
592
- };
593
- var OtpInput_default = OtpInput;
594
-
595
- // src/components/controls/edit/DateTimeInput.tsx
596
- import React10 from "react";
597
- import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
598
- var DateTimeInput = (props) => {
599
- const textChangeHandler = (event) => {
600
- const localDate = new Date(event.target.value);
601
- if (props.callback !== void 0) {
602
- const utcISOString = localDate.toISOString();
603
- props.callback({
604
- name: props.name,
605
- value: utcISOString,
606
- index: props.index,
607
- groupKey: props.groupKey
608
- });
609
- }
610
- };
611
- let value;
612
- let localvalue;
613
- let timeZoneAbbr;
614
- if (props.value !== void 0 && props.value !== null) {
615
- value = props.value;
616
- const now = /* @__PURE__ */ new Date();
617
- const offsetMinutes = now.getTimezoneOffset();
618
- const offsetMilliseconds = offsetMinutes * 60 * 1e3;
619
- const valDate = value.toString().includes("Z") ? new Date(value) : /* @__PURE__ */ new Date(value + "Z");
620
- const localDate = new Date(valDate.getTime() - offsetMilliseconds);
621
- timeZoneAbbr = now.toLocaleTimeString("en", { timeZoneName: "short" }).split(" ")[2];
622
- localvalue = localDate?.toISOString()?.slice(0, 16);
623
- }
624
- const handleKeyDown = (e) => {
625
- if (e.key === "Backspace") {
626
- e.preventDefault();
627
- }
628
- };
629
- return /* @__PURE__ */ jsx10(React10.Fragment, { children: /* @__PURE__ */ jsxs10("label", { className: "block mb-1", children: [
630
- /* @__PURE__ */ jsx10("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
631
- " ",
632
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx10("span", { className: "bg-error-weak", children: "*" }),
633
- /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
634
- /* @__PURE__ */ jsx10(
635
- "input",
636
- {
637
- type: "datetime-local",
638
- name: props.name,
639
- id: props.name,
640
- value: localvalue,
641
- onChange: textChangeHandler,
642
- onKeyDown: handleKeyDown,
643
- required: props?.attributes?.required,
644
- placeholder: props?.attributes?.placeholder,
645
- maxLength: props?.attributes?.maxLength,
646
- pattern: props?.attributes?.pattern,
647
- disabled: props?.attributes?.readOnly,
648
- minLength: props?.attributes?.minLength,
649
- className: "peer mt-1 py-1.5 block w-full rounded shadow-sm\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\n "
650
- }
651
- ),
652
- /* @__PURE__ */ jsx10("span", { children: timeZoneAbbr })
653
- ] }),
654
- /* @__PURE__ */ jsx10("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
655
- ] }) });
656
- };
657
- var DateTimeInput_default = DateTimeInput;
658
-
659
- // src/components/controls/edit/ColorInput.tsx
660
- import React11, { useEffect as useEffect2 } from "react";
661
- import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
662
- var DEFAULT_COLOR = "#3b82f6";
663
- var isValidHex = (val) => typeof val === "string" && /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(val.trim());
664
- var normalizeColor = (val) => {
665
- if (isValidHex(val)) {
666
- return val.trim();
667
- }
668
- return DEFAULT_COLOR;
669
- };
670
- var ColorInput = (props) => {
671
- const isReadOnly = props.attributes?.readOnly === true || props.attributes?.readOnly === "true" || props?.readOnly === true || props.disable === true || props.attributes?.disable === true || props.attributes?.disabled === true || props.attributes?.disabled === "true";
672
- const [color, setColor] = React11.useState(
673
- () => normalizeColor(props.value)
674
- );
675
- useEffect2(() => {
676
- const hasValue = props.value !== void 0 && props.value !== null && props.value !== "";
677
- if (!hasValue && props.callback && !isReadOnly) {
678
- props.callback({
679
- name: props.name,
680
- value: DEFAULT_COLOR,
681
- index: props.index,
682
- groupKey: props.groupKey
683
- });
684
- }
685
- }, [isReadOnly]);
686
- useEffect2(() => {
687
- if (props.value !== void 0 && props.value !== null && props.value !== "") {
688
- if (typeof props.value === "string") {
689
- setColor(normalizeColor(props.value));
690
- }
691
- }
692
- }, [props.value]);
693
- const handleColorChange = (event) => {
694
- if (isReadOnly) return;
695
- const newColor = event.target.value;
696
- setColor(newColor);
697
- if (props.callback) {
698
- props.callback({
699
- name: props.name,
700
- value: newColor,
701
- index: props.index,
702
- groupKey: props.groupKey
703
- });
704
- }
705
- };
706
- const displayColor = normalizeColor(color || props.value);
707
- return /* @__PURE__ */ jsx11(React11.Fragment, { children: /* @__PURE__ */ jsxs11("label", { className: `block ${isReadOnly ? "cursor-not-allowed" : ""}`, children: [
708
- props?.attributes?.label && /* @__PURE__ */ jsx11("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
709
- " ",
710
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx11("span", { className: "bg-error-weak", children: "*" }),
711
- /* @__PURE__ */ jsx11(
712
- "input",
713
- {
714
- type: "color",
715
- name: props.name,
716
- title: displayColor,
717
- id: props.name,
718
- value: displayColor,
719
- onChange: handleColorChange,
720
- onBlur: props?.onBlur,
721
- autoFocus: props?.attributes?.autoFocus,
722
- required: !isReadOnly && Boolean(props?.attributes?.required),
723
- disabled: isReadOnly,
724
- readOnly: isReadOnly,
725
- tabIndex: isReadOnly ? -1 : void 0,
726
- onClick: (e) => {
727
- if (isReadOnly) {
728
- e.preventDefault();
729
- e.stopPropagation();
730
- }
731
- },
732
- className: `peer block rounded ${isReadOnly ? "cursor-not-allowed pointer-events-none" : "cursor-pointer"} ${props?.inputClasses ? props.inputClasses : ""}`,
733
- style: {
734
- width: "78px",
735
- height: "33px",
736
- padding: 0,
737
- margin: 0,
738
- border: isReadOnly ? "1px solid var(--border, #e2e8f0)" : "1px solid #e2e8f0",
739
- borderRadius: "5px",
740
- overflow: "hidden",
741
- backgroundColor: isReadOnly ? "var(--bg-color, transparent)" : "transparent",
742
- appearance: "none",
743
- cursor: isReadOnly ? "not-allowed" : "pointer",
744
- pointerEvents: isReadOnly ? "none" : "auto"
745
- }
746
- }
747
- ),
748
- /* @__PURE__ */ jsx11("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
749
- ] }) });
750
- };
751
- var ColorInput_default = ColorInput;
752
-
753
- // src/components/controls/edit/SelectWithSearchInput.tsx
754
- import React12, { useEffect as useEffect3, useRef, useState as useState2 } from "react";
755
- import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
756
- var SelectWithSearchInput = (props) => {
757
- const [isOpen, setIsOpen] = useState2(false);
758
- const [searchTerm, setSearchTerm] = useState2("");
759
- const [highlightedIndex, setHighlightedIndex] = useState2(-1);
760
- const [selectedItem, setSelectedItem] = useState2(
761
- null
762
- );
763
- const [list, setList] = useState2([]);
764
- const loadData = React12.useCallback(async () => {
765
- if (props.dataset) {
766
- setList(props.dataset);
767
- return;
768
- }
769
- if (props.dataSource && props.serviceClient) {
770
- let url = props.dataSource;
771
- if (props.dataSourceDependsOn && props.dependentValue) {
772
- url = url.replace(
773
- `{${props.dataSourceDependsOn}}`,
774
- props.dependentValue
775
- );
776
- }
777
- const response = await props.serviceClient.get(url);
778
- if (response?.result) {
779
- setList(response.result);
780
- }
781
- }
782
- }, [
783
- props.dataset,
784
- props.dataSource,
785
- props.serviceClient,
786
- props.dataSourceDependsOn,
787
- props.dependentValue
788
- ]);
789
- useEffect3(() => {
790
- loadData();
791
- }, [loadData]);
792
- useEffect3(() => {
793
- if (props.value && list.length && props.dataKeyFieldName && props.dataTextFieldName) {
794
- const selected = list.find(
795
- (x) => String(x[props.dataKeyFieldName]) === String(props.value)
796
- );
797
- if (selected) {
798
- setSearchTerm(selected[props.dataTextFieldName]);
799
- setSelectedItem(selected);
800
- }
801
- }
802
- }, [props.value, list, props.dataKeyFieldName, props.dataTextFieldName]);
803
- const filteredItems = list.filter((item) => {
804
- const text = item[props.dataTextFieldName] ?? "";
805
- return text.toString().toLowerCase().includes(searchTerm.toLowerCase());
806
- });
807
- const handleSelect = (event, item) => {
808
- event.preventDefault();
809
- setSearchTerm(item[props.dataTextFieldName]);
810
- setSelectedItem(item);
811
- setIsOpen(false);
812
- setHighlightedIndex(-1);
813
- const selectedValue = item[props.dataKeyFieldName];
814
- if (props.onChange) {
815
- props.onChange(selectedValue);
816
- }
817
- if (props.callback) {
818
- props.callback({
819
- name: props.name,
820
- value: selectedValue,
821
- index: props.index,
822
- groupKey: props.groupKey
823
- });
824
- }
825
- };
826
- const handleKeyDown = (e) => {
827
- if (e.key === "ArrowDown") {
828
- setHighlightedIndex(
829
- (prev) => prev < filteredItems.length - 1 ? prev + 1 : 0
830
- );
831
- } else if (e.key === "ArrowUp") {
832
- setHighlightedIndex(
833
- (prev) => prev > 0 ? prev - 1 : filteredItems.length - 1
834
- );
835
- } else if (e.key === "Enter" && highlightedIndex >= 0) {
836
- handleSelect(e, filteredItems[highlightedIndex]);
837
- }
838
- };
839
- const dropdownRef = useRef(null);
840
- useEffect3(() => {
841
- if (highlightedIndex >= 0 && dropdownRef.current) {
842
- const highlightedItem = dropdownRef.current.children[highlightedIndex];
843
- highlightedItem?.scrollIntoView({
844
- behavior: "smooth",
845
- block: "nearest"
846
- });
847
- }
848
- }, [highlightedIndex]);
849
- const isReadOnly = props.attributes?.readOnly || props.disable || props.attributes?.disable;
850
- return /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
851
- /* @__PURE__ */ jsxs12("label", { className: "pb-1", children: [
852
- props.attributes?.label,
853
- " ",
854
- props?.attributes?.required && /* @__PURE__ */ jsx12("span", { className: "bg-error-weak", children: "*" })
855
- ] }),
856
- /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
857
- /* @__PURE__ */ jsx12(
858
- "input",
859
- {
860
- type: "text",
861
- name: props.name,
862
- id: props.name,
863
- value: searchTerm,
864
- onChange: (e) => {
865
- if (!isReadOnly) {
866
- setSearchTerm(e.target.value);
867
- setIsOpen(true);
868
- setHighlightedIndex(-1);
869
- }
870
- },
871
- onFocus: () => {
872
- if (!isReadOnly) {
873
- setIsOpen(true);
874
- }
875
- },
876
- onKeyDown: handleKeyDown,
877
- placeholder: props.attributes?.placeholder ?? "Search...",
878
- readOnly: isReadOnly,
879
- disabled: isReadOnly,
880
- required: props.attributes?.required,
881
- className: `peer mt-2 py-1.5 select block w-full text-black rounded border-gray-300 shadow-sm
882
- focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
883
- disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none
884
- ${isReadOnly ? "bg-neutral-soft opacity-50 cursor-not-allowed" : "bg-default"}
885
- `
886
- }
887
- ),
888
- /* @__PURE__ */ jsx12(
889
- "button",
890
- {
891
- type: "button",
892
- disabled: isReadOnly,
893
- onClick: () => {
894
- if (!isReadOnly) {
895
- setIsOpen(!isOpen);
896
- }
897
- },
898
- className: "absolute right-2 top-3 h-5 w-5 text-gray-500 focus:outline-none",
899
- children: /* @__PURE__ */ jsx12(
900
- "svg",
901
- {
902
- xmlns: "http://www.w3.org/2000/svg",
903
- fill: "none",
904
- viewBox: "0 0 24 24",
905
- strokeWidth: 1.5,
906
- stroke: "currentColor",
907
- className: "w-full h-full",
908
- children: /* @__PURE__ */ jsx12(
909
- "path",
910
- {
911
- strokeLinecap: "round",
912
- strokeLinejoin: "round",
913
- d: "M19.5 8.25l-7.5 7.5-7.5-7.5"
914
- }
915
- )
916
- }
917
- )
918
- }
919
- ),
920
- /* @__PURE__ */ jsx12("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props.attributes?.errorMessage ?? "" })
921
- ] }),
922
- !isReadOnly && isOpen && /* @__PURE__ */ jsx12(
923
- "div",
924
- {
925
- ref: dropdownRef,
926
- className: "absolute z-10 w-full bg-default border border-gray-200 shadow-lg max-h-48 overflow-y-auto",
927
- children: filteredItems.length > 0 ? filteredItems.map((item, index) => /* @__PURE__ */ jsx12(
928
- "button",
929
- {
930
- onClick: (e) => handleSelect(e, item),
931
- className: `w-full px-4 py-2 flex items-center space-x-2 text-left ${index === highlightedIndex ? "bg-gray-200" : "hover:bg-gray-100"}`,
932
- role: "option",
933
- tabIndex: -1,
934
- onMouseEnter: () => setHighlightedIndex(index),
935
- children: /* @__PURE__ */ jsx12("span", { children: item[props.dataTextFieldName] })
936
- },
937
- item[props.dataKeyFieldName]
938
- )) : /* @__PURE__ */ jsx12("div", { className: "px-4 py-2 text-gray-500", children: "No results found" })
939
- }
940
- )
941
- ] });
942
- };
943
- var SelectWithSearchInput_default = SelectWithSearchInput;
944
-
945
- // src/components/controls/edit/SelectWithSearchPanel.tsx
946
- import React13, {
947
- useEffect as useEffect4,
948
- useRef as useRef2,
949
- useState as useState3,
950
- useCallback
951
- } from "react";
952
- import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
953
- var SelectWithSearchPanel = (props) => {
954
- const [isOpen, setIsOpen] = useState3(false);
955
- const [searchTerm, setSearchTerm] = useState3("");
956
- const [highlightedIndex, setHighlightedIndex] = useState3(0);
957
- const [list, setList] = useState3([]);
958
- const listRef = useRef2(null);
959
- const [isError, setIsError] = useState3(false);
960
- const containerRef = useRef2(null);
961
- const [isCreateOpen, setIsCreateOpen] = useState3(false);
962
- const [formData, setFormData] = useState3({});
963
- const getNestedValue = (obj, path) => {
964
- return path.split(".").reduce((acc, key) => acc?.[key], obj);
965
- };
966
- useEffect4(() => {
967
- const handleClickOutside = (event) => {
968
- if (containerRef.current && !containerRef.current.contains(event.target)) {
969
- setIsOpen(false);
970
- }
971
- };
972
- document.addEventListener("mousedown", handleClickOutside);
973
- return () => {
974
- document.removeEventListener("mousedown", handleClickOutside);
975
- };
976
- }, []);
977
- useEffect4(() => {
978
- async function fetchData() {
979
- if (props.dataset) {
980
- setList(props.dataset);
981
- } else if (props.dataSource && props.serviceClient) {
982
- let dataSource = props.dataSource;
983
- if (props.dataSourceDependsOn && props.dependentValue) {
984
- dataSource = dataSource.replace(
985
- `{${props.dataSourceDependsOn}}`,
986
- props.dependentValue
987
- );
988
- }
989
- const response = await props.serviceClient.get(dataSource);
990
- if (response?.result) setList(response.result);
991
- }
992
- }
993
- fetchData();
994
- }, [
995
- props.dataSource,
996
- props.dependentValue,
997
- props.dataset,
998
- props.dataSourceDependsOn
999
- ]);
1000
- const filteredItems = list?.filter((item) => {
1001
- const value = getNestedValue(item, props.dataTextFieldName);
1002
- return value?.toLowerCase().includes(searchTerm?.toLowerCase());
1003
- });
1004
- const playBeep = () => {
1005
- const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
1006
- const oscillator = audioCtx.createOscillator();
1007
- const gainNode = audioCtx.createGain();
1008
- oscillator.type = "square";
1009
- oscillator.frequency.setValueAtTime(300, audioCtx.currentTime);
1010
- gainNode.gain.setValueAtTime(0.02, audioCtx.currentTime);
1011
- oscillator.connect(gainNode);
1012
- gainNode.connect(audioCtx.destination);
1013
- oscillator.start();
1014
- setTimeout(() => {
1015
- oscillator.stop();
1016
- audioCtx.close();
1017
- }, 250);
1018
- };
1019
- useEffect4(() => {
1020
- const filteredItems2 = list?.filter(
1021
- (item) => item[props?.dataTextFieldName]?.toLowerCase().includes(searchTerm?.toLowerCase())
1022
- );
1023
- if (searchTerm.length > 0 && filteredItems2.length === 0) {
1024
- playBeep();
1025
- setIsError(true);
1026
- } else {
1027
- setIsError(false);
1028
- }
1029
- }, [searchTerm]);
1030
- const handleSelect = (event, item) => {
1031
- event.preventDefault();
1032
- setSearchTerm(getNestedValue(item, props.dataTextFieldName));
1033
- if (props.callback) {
1034
- const val = {};
1035
- props.callback({
1036
- name: props.name,
1037
- value: item[props.dataKeyFieldName],
1038
- index: props.index,
1039
- groupKey: props.groupKey
1040
- });
1041
- }
1042
- setHighlightedIndex(0);
1043
- setIsOpen(false);
1044
- };
1045
- const handleKeyDown = (e) => {
1046
- if (e.key === "Escape") {
1047
- setIsOpen(false);
1048
- setHighlightedIndex(-1);
1049
- } else if (e.key === "ArrowDown") {
1050
- e.preventDefault();
1051
- setHighlightedIndex((prev) => {
1052
- const nextIndex = prev < filteredItems.length - 1 ? prev + 1 : prev;
1053
- scrollIntoView(nextIndex);
1054
- return nextIndex;
1055
- });
1056
- } else if (e.key === "ArrowUp") {
1057
- e.preventDefault();
1058
- setHighlightedIndex((prev) => {
1059
- const prevIndex = prev > 0 ? prev - 1 : prev;
1060
- scrollIntoView(prevIndex);
1061
- return prevIndex;
1062
- });
1063
- } else if (e.key === "Enter" && highlightedIndex >= 0) {
1064
- handleSelect(e, filteredItems[highlightedIndex]);
1065
- }
1066
- };
1067
- const scrollIntoView = (index) => {
1068
- if (listRef.current) {
1069
- const item = listRef.current.children[index];
1070
- if (item) {
1071
- item.scrollIntoView();
1072
- }
1073
- }
1074
- };
1075
- const textChangeHandler = (event) => {
1076
- const newSearchTerm = event.target.value;
1077
- setSearchTerm(newSearchTerm);
1078
- setIsOpen(true);
1079
- setHighlightedIndex(0);
1080
- };
1081
- const handleInputChange = (event, field) => {
1082
- setFormData((prev) => ({ ...prev, [field]: event.target.value }));
1083
- };
1084
- const handleSaveModal = useCallback(async () => {
1085
- console.log("Form Data:", formData);
1086
- return formData;
1087
- }, []);
1088
- return /* @__PURE__ */ jsxs13("div", { className: "relative", children: [
1089
- /* @__PURE__ */ jsxs13("label", { className: "text-sm mb-1 font-medium", children: [
1090
- props.attributes?.label,
1091
- " ",
1092
- " ",
1093
- props?.attributes?.required && /* @__PURE__ */ jsx13("span", { className: "bg-error-weak", children: "*" })
1094
- ] }),
1095
- /* @__PURE__ */ jsxs13("div", { children: [
1096
- /* @__PURE__ */ jsx13(
1097
- "input",
1098
- {
1099
- type: "text",
1100
- name: props.name,
1101
- id: props.name,
1102
- value: searchTerm,
1103
- onChange: textChangeHandler,
1104
- onFocus: () => setIsOpen(true),
1105
- onKeyDown: handleKeyDown,
1106
- placeholder: props.attributes?.placeholder,
1107
- required: props.attributes?.required,
1108
- className: `peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
1109
- ${isError ? "focus:border-red-300 focus:ring focus:ring-red-200 focus:ring-opacity-50" : "focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"}
1110
- disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none`
1111
- }
1112
- ),
1113
- /* @__PURE__ */ jsx13("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props.attributes?.errorMessage ?? "" })
1114
- ] }),
1115
- /* @__PURE__ */ jsx13("div", { ref: containerRef, children: isOpen && /* @__PURE__ */ jsxs13(React13.Fragment, { children: [
1116
- /* @__PURE__ */ jsxs13("div", { className: "fixed z-50 right-0 bg-white top-[62px] w-1/4 border-l border-gray-200", children: [
1117
- /* @__PURE__ */ jsx13("div", { className: "flex flex-col p-2 bg-accent-950 text-white", children: /* @__PURE__ */ jsxs13("h5", { className: "text-md text-white font-medium", children: [
1118
- "Select a",
1119
- " ",
1120
- props.attributes?.label || props.attributes?.heading
1121
- ] }) }),
1122
- /* @__PURE__ */ jsx13("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200 h-10", children: props.createFields && props.createFields.length > 0 && /* @__PURE__ */ jsx13(
1123
- "button",
1124
- {
1125
- type: "button",
1126
- className: "text-primary hover:text-primary-800",
1127
- onMouseDown: (e) => {
1128
- e.preventDefault();
1129
- setIsCreateOpen(true);
1130
- },
1131
- children: "Create"
1132
- }
1133
- ) })
1134
- ] }),
1135
- isCreateOpen && /* @__PURE__ */ jsxs13("div", { className: "fixed right-0 w-1/4 h-full top-[62px] bg-white shadow-lg border-l border-gray-200 z-50", children: [
1136
- /* @__PURE__ */ jsx13("div", { className: "flex flex-col p-2 bg-accent-950", children: /* @__PURE__ */ jsxs13("h5", { className: "text-md font-medium text-white", children: [
1137
- "Create New ",
1138
- props.attributes?.label
1139
- ] }) }),
1140
- /* @__PURE__ */ jsx13("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200", children: /* @__PURE__ */ jsx13(
1141
- "button",
1142
- {
1143
- type: "button",
1144
- onClick: () => setIsCreateOpen(false),
1145
- className: "text-red-600 hover:text-red-800",
1146
- children: "Close"
1147
- }
1148
- ) }),
1149
- /* @__PURE__ */ jsxs13("div", { className: "p-4", children: [
1150
- props.createFields?.map((field) => /* @__PURE__ */ jsxs13("div", { className: "mb-4", children: [
1151
- /* @__PURE__ */ jsx13("label", { className: "text-sm mb-1 font-medium block", children: field.label }),
1152
- /* @__PURE__ */ jsx13(
1153
- "input",
1154
- {
1155
- type: field.type,
1156
- value: formData[field.name] || "",
1157
- onChange: (e) => handleInputChange(e, field.name),
1158
- placeholder: field.placeholder,
1159
- required: field.required,
1160
- disabled: field.disabled,
1161
- pattern: field.pattern,
1162
- minLength: field.minLength,
1163
- maxLength: field.maxLength,
1164
- className: "peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
1165
- }
1166
- )
1167
- ] }, field.name)),
1168
- /* @__PURE__ */ jsxs13(Button_default, { onClick: async () => {
1169
- handleSaveModal();
1170
- return { isSuccessful: true };
1171
- }, className: "w-full", children: [
1172
- "Save ",
1173
- props.attributes?.label
1174
- ] })
1175
- ] })
1176
- ] }),
1177
- /* @__PURE__ */ jsx13(
1178
- "div",
1179
- {
1180
- ref: listRef,
1181
- className: "fixed z-10 right-0 mt-[130px] top-0 w-1/4 bg-white border-l border-gray-200 shadow-lg overflow-y-auto",
1182
- style: { height: "calc(100vh - 130px)" },
1183
- children: filteredItems.length > 0 ? filteredItems.map((item, index) => /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13(
1184
- "button",
1185
- {
1186
- onClick: (e) => {
1187
- handleSelect(e, item);
1188
- },
1189
- className: `w-full px-4 py-2 flex items-center space-x-2 text-left border-b border-gray-200 ${index === highlightedIndex ? "bg-gray-200" : "hover:bg-gray-100"}`,
1190
- role: "option",
1191
- tabIndex: -1,
1192
- onMouseEnter: () => setHighlightedIndex(index),
1193
- children: /* @__PURE__ */ jsx13("span", { children: getNestedValue(item, props.dataTextFieldName) })
1194
- }
1195
- ) }, item[props.dataKeyFieldName])) : /* @__PURE__ */ jsx13("div", { className: "px-4 py-2 text-gray-500", children: "No results found" })
1196
- }
1197
- )
1198
- ] }) })
1199
- ] });
1200
- };
1201
- var SelectWithSearchPanel_default = SelectWithSearchPanel;
1202
-
1203
- // src/components/controls/edit/EmailInput.tsx
1204
- import React14 from "react";
1205
- import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
1206
- var EmailInput = (props) => {
1207
- const textChangeHandler = (event) => {
1208
- const text = event.target.value;
1209
- if (text) {
1210
- const atIndex = text.indexOf("@");
1211
- const dotIndex = text.indexOf(".", atIndex);
1212
- if (dotIndex < atIndex || text.length - dotIndex <= 2) {
1213
- event.target.setCustomValidity("invaild-value");
1214
- } else {
1215
- event.target.setCustomValidity("");
1216
- }
1217
- }
1218
- if (props.callback !== void 0) {
1219
- props.callback({
1220
- name: props.name,
1221
- value: text,
1222
- index: props.index,
1223
- groupKey: props.groupKey
1224
- });
1225
- }
1226
- };
1227
- let value = "";
1228
- if (props.value !== void 0 && props.value !== null) {
1229
- value = props.value;
1230
- }
1231
- return /* @__PURE__ */ jsx14(React14.Fragment, { children: /* @__PURE__ */ jsxs14("label", { className: "block", children: [
1232
- props?.attributes?.label && /* @__PURE__ */ jsx14("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
1233
- " ",
1234
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx14("span", { className: "bg-error-weak", children: "*" }),
1235
- /* @__PURE__ */ jsx14(
1236
- "input",
1237
- {
1238
- type: "email",
1239
- name: props.name,
1240
- id: props.name,
1241
- value,
1242
- onChange: textChangeHandler,
1243
- onBlur: props?.onBlur,
1244
- autoFocus: props?.attributes?.autoFocus,
1245
- required: props?.attributes?.required,
1246
- placeholder: props?.attributes?.placeholder,
1247
- maxLength: props?.attributes?.maxLength,
1248
- pattern: props?.attributes?.pattern,
1249
- disabled: props?.attributes?.readOnly,
1250
- minLength: props?.attributes?.minLength,
1251
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm transition-all duration-500 ease-in-out
1252
- ${props?.inputClasses ? props.inputClasses : ``}
1253
- `
1254
- }
1255
- ),
1256
- /* @__PURE__ */ jsx14("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
1257
- ] }) });
1258
- };
1259
- var EmailInput_default = EmailInput;
1260
-
1261
- // src/components/controls/edit/TimeInput.tsx
1262
- import React15 from "react";
1263
- import { jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
1264
- var TimeInput = (props) => {
1265
- const timeChangeHandler = (event) => {
1266
- const timeValue = event.target.value;
1267
- if (props.callback) {
1268
- props.callback({
1269
- name: props.name,
1270
- value: timeValue,
1271
- index: props.index,
1272
- groupKey: props.groupKey
1273
- });
1274
- }
1275
- };
1276
- return /* @__PURE__ */ jsx15(React15.Fragment, { children: /* @__PURE__ */ jsxs15("label", { className: "block", children: [
1277
- props?.attributes?.label && /* @__PURE__ */ jsx15("span", { className: "text-sm inline-block pb-1 font-medium", children: props?.attributes?.label }),
1278
- " ",
1279
- props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx15("span", { className: "bg-error-weak", children: "*" }),
1280
- /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx15(
1281
- "input",
1282
- {
1283
- type: "time",
1284
- name: props.name,
1285
- id: props.name,
1286
- value: typeof props.value === "boolean" ? "" : props.value ?? "",
1287
- onChange: timeChangeHandler,
1288
- onBlur: props?.onBlur,
1289
- autoFocus: props?.attributes?.autoFocus,
1290
- required: props?.attributes?.required,
1291
- disabled: props?.attributes?.readOnly,
1292
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm transition-all duration-500 ease-in-out
1293
- ${props?.inputClasses ? props.inputClasses : ``}
1294
- `
1295
- }
1296
- ) }),
1297
- /* @__PURE__ */ jsx15("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ?? "" })
1298
- ] }) });
1299
- };
1300
- var TimeInput_default = TimeInput;
1301
-
1302
- // src/components/controls/edit/AssetUpload.tsx
1303
- import React16, { useEffect as useEffect5 } from "react";
1304
- import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
1305
- var AssetUpload = (props) => {
1306
- const isDisabled = props.attributes?.disable ?? false;
1307
- let allValues = [];
1308
- if (props.value !== void 0 && props.value !== null && props.value !== "") {
1309
- try {
1310
- allValues = JSON.parse(props.value.toString());
1311
- } catch (error) {
1312
- }
1313
- }
1314
- const getInitialTab = () => {
1315
- if (allValues.length > 0) {
1316
- const asset = allValues[0];
1317
- if (asset.posterUrl) {
1318
- return "video";
1319
- } else if (asset.assetUrl) {
1320
- return "image";
1321
- }
1322
- }
1323
- return "image";
1324
- };
1325
- const [assetType, setAssetType] = React16.useState(getInitialTab);
1326
- useEffect5(() => {
1327
- setAssetType(getInitialTab());
1328
- }, [props.value]);
1329
- const assetUploadCallback = (newAsset) => {
1330
- if (isDisabled) return;
1331
- let updated = [];
1332
- updated.push({
1333
- assetUrl: newAsset.assetUrl,
1334
- title: newAsset.title,
1335
- posterUrl: newAsset.posterUrl,
1336
- intrinsicHeight: newAsset.intrinsicHeight,
1337
- intrinsicWidth: newAsset.intrinsicWidth
1338
- });
1339
- props.callback?.({
1340
- name: props.name,
1341
- value: JSON.stringify(updated),
1342
- index: props.index,
1343
- groupKey: props.groupKey
1344
- });
1345
- };
1346
- const deleteFile = (index) => {
1347
- if (isDisabled) return;
1348
- let existingValue = [];
1349
- if (props.value) {
1350
- try {
1351
- existingValue = JSON.parse(props.value.toString());
1352
- } catch (error) {
1353
- }
1354
- }
1355
- if (existingValue.length > index) {
1356
- existingValue.splice(index, 1);
1357
- props.callback?.({
1358
- name: props.name,
1359
- value: JSON.stringify(existingValue),
1360
- index: props.index,
1361
- groupKey: props.groupKey
1362
- });
1363
- }
1364
- };
1365
- const textChangeHandler = (index, event) => {
1366
- if (isDisabled) return;
1367
- let existingValue = [];
1368
- if (props.value) {
1369
- try {
1370
- existingValue = JSON.parse(props.value.toString());
1371
- } catch (error) {
1372
- }
1373
- }
1374
- const text = event.target.value;
1375
- if (existingValue.length > index) {
1376
- const updatedArray = [...existingValue];
1377
- updatedArray[index] = { ...updatedArray[index], title: text };
1378
- props.callback?.({
1379
- name: props.name,
1380
- value: JSON.stringify(updatedArray),
1381
- index: props.index,
1382
- groupKey: props.groupKey
1383
- });
1384
- }
1385
- };
1386
- const getAssetType = (asset) => {
1387
- if (asset.assetUrl?.endsWith(".m3u8") || asset.posterUrl) return "video";
1388
- return "image";
1389
- };
1390
- const shouldShowDetails = () => {
1391
- if (allValues.length === 0) return false;
1392
- const asset = allValues[0];
1393
- if (assetType === "video") {
1394
- return Boolean(asset.posterUrl && asset.assetUrl && asset.assetUrl.endsWith(".m3u8"));
1395
- }
1396
- if (assetType === "image") {
1397
- return Boolean(asset.assetUrl && !asset.assetUrl.endsWith(".m3u8"));
1398
- }
1399
- return false;
1400
- };
1401
- return /* @__PURE__ */ jsxs16(React16.Fragment, { children: [
1402
- /* @__PURE__ */ jsx16("label", { className: "block mb-1", children: /* @__PURE__ */ jsx16("span", { className: "text-sm font-medium", children: props?.attributes?.label }) }),
1403
- /* @__PURE__ */ jsxs16("div", { className: "flex gap-6 bg-neutral-100 rounded p-2", children: [
1404
- /* @__PURE__ */ jsx16(
1405
- ClientButton_default,
1406
- {
1407
- className: assetType === "image" ? "px-2 py-1 rounded bg-body-200 scale-95" : "text-neutral-700",
1408
- ButtonType: "Link" /* Link */,
1409
- onClick: () => setAssetType("image"),
1410
- disabled: isDisabled,
1411
- children: "Image Upload"
1412
- }
1413
- ),
1414
- /* @__PURE__ */ jsx16(
1415
- ClientButton_default,
1416
- {
1417
- className: assetType === "video" ? "bg-body-200 px-2 py-1 rounded-md scale-95" : "text-neutral-700",
1418
- ButtonType: "Link" /* Link */,
1419
- onClick: () => setAssetType("video"),
1420
- disabled: isDisabled,
1421
- children: "Video Upload"
1422
- }
1423
- )
1424
- ] }),
1425
- shouldShowDetails() && /* @__PURE__ */ jsxs16("div", { className: "relative mt-4 rounded-md p-4 border-2 border-dotted border-gray-300 bg-gray-50", children: [
1426
- /* @__PURE__ */ jsx16("span", { className: "absolute -top-2.5 left-3 bg-primary-600 text-white text-xs px-2 py-0.5 rounded-full", children: getAssetType(allValues[0]) === "video" ? "Video" : "Image" }),
1427
- /* @__PURE__ */ jsx16("div", { className: "flex flex-col gap-3", children: allValues.map((digitalAsset, index) => /* @__PURE__ */ jsxs16("div", { className: "flex justify-between items-start gap-5", children: [
1428
- /* @__PURE__ */ jsxs16("div", { className: "grid grid-cols-2 gap-x-8 gap-y-3 text-sm w-full", children: [
1429
- /* @__PURE__ */ jsxs16("div", { children: [
1430
- /* @__PURE__ */ jsx16("p", { className: "text-gray-500", children: "Title" }),
1431
- /* @__PURE__ */ jsx16(
1432
- "input",
1433
- {
1434
- type: "text",
1435
- value: digitalAsset.title,
1436
- onChange: (event) => textChangeHandler(index, event),
1437
- placeholder: "title",
1438
- disabled: isDisabled,
1439
- className: "w-full mt-1 py-1.5 block rounded border-gray-300 shadow-sm bg-white\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\n disabled:bg-gray-100 disabled:text-gray-400 disabled:cursor-not-allowed"
1440
- }
1441
- )
1442
- ] }),
1443
- digitalAsset.intrinsicWidth && digitalAsset.intrinsicHeight && /* @__PURE__ */ jsxs16("div", { children: [
1444
- /* @__PURE__ */ jsx16("p", { className: "text-gray-500", children: "Resolution" }),
1445
- /* @__PURE__ */ jsxs16("p", { className: "font-medium text-gray-900 mt-3", children: [
1446
- digitalAsset.intrinsicWidth,
1447
- "\xD7",
1448
- digitalAsset.intrinsicHeight
1449
- ] })
1450
- ] }),
1451
- (digitalAsset.assetUrl || digitalAsset.posterUrl) && /* @__PURE__ */ jsxs16("div", { children: [
1452
- /* @__PURE__ */ jsx16("p", { className: "text-gray-500", children: "Image / Poster" }),
1453
- /* @__PURE__ */ jsxs16("div", { className: "flex-shrink-0 flex flex-col gap-3 mt-1", children: [
1454
- getAssetType(digitalAsset) === "video" && digitalAsset.posterUrl && /* @__PURE__ */ jsx16(
1455
- "img",
1456
- {
1457
- src: AssetUtility_default.resolveUrl(props.serviceClient?.baseUrl, digitalAsset.posterUrl),
1458
- alt: digitalAsset.title || "Video poster",
1459
- className: "w-32 h-auto object-cover rounded border p-1"
1460
- }
1461
- ),
1462
- getAssetType(digitalAsset) === "image" && digitalAsset.assetUrl && /* @__PURE__ */ jsx16(
1463
- "img",
1464
- {
1465
- src: AssetUtility_default.resolveUrl(props.serviceClient?.baseUrl, digitalAsset.assetUrl),
1466
- alt: digitalAsset.title || "Uploaded image",
1467
- className: "w-32 h-auto object-cover rounded border p-1"
1468
- }
1469
- )
1470
- ] })
1471
- ] }),
1472
- digitalAsset.assetUrl?.endsWith(".m3u8") && /* @__PURE__ */ jsxs16("div", { className: "col-span-2", children: [
1473
- /* @__PURE__ */ jsx16("p", { className: "text-gray-500", children: "HLS Link" }),
1474
- /* @__PURE__ */ jsx16(
1475
- Hyperlink,
1476
- {
1477
- href: digitalAsset.assetUrl,
1478
- className: "text-primary-600 underline mt-1 break-all",
1479
- title: digitalAsset.assetUrl,
1480
- children: digitalAsset.assetUrl
1481
- }
1482
- )
1483
- ] })
1484
- ] }),
1485
- /* @__PURE__ */ jsx16(
1486
- "span",
1487
- {
1488
- onClick: () => !isDisabled && deleteFile(index),
1489
- className: isDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer",
1490
- children: /* @__PURE__ */ jsx16(Icon_default, { className: "w-4 h-4 text-primary", name: "delete" })
1491
- }
1492
- )
1493
- ] }, index)) })
1494
- ] })
1495
- ] });
1496
- };
1497
- var AssetUpload_default = AssetUpload;
1498
-
1499
- // src/components/controls/edit/SwitchInput.tsx
1500
- import React17 from "react";
1501
- import { jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
1502
- var SwitchInput = (props) => {
1503
- const textChangeHandler = (event) => {
1504
- let text = event.target.checked;
1505
- if (props.callback !== void 0) {
1506
- props.callback({
1507
- name: props.name,
1508
- value: text,
1509
- index: props.index,
1510
- groupKey: props.groupKey
1511
- });
1512
- }
1513
- };
1514
- let value = false;
1515
- if (props.value != void 0 && props.value != null && props.value != "" && (props.value == "true" || props.value.toString() == "true")) {
1516
- value = true;
1517
- }
1518
- return /* @__PURE__ */ jsx17(React17.Fragment, { children: /* @__PURE__ */ jsxs17("div", { className: "relative flex items-start justify-between gap-4 py-3", children: [
1519
- /* @__PURE__ */ jsx17("div", { className: "min-w-0", children: props?.attributes?.label && /* @__PURE__ */ jsxs17(
1520
- "label",
1521
- {
1522
- htmlFor: props.name,
1523
- className: "inline-block text-sm font-semibold text-slate-800",
1524
- children: [
1525
- props.attributes.label,
1526
- props?.attributes?.required && /* @__PURE__ */ jsx17("span", { className: "bg-error-weak", children: "*" })
1527
- ]
1528
- }
1529
- ) }),
1530
- /* @__PURE__ */ jsxs17(
1531
- "label",
1532
- {
1533
- htmlFor: props.name,
1534
- className: "relative inline-flex shrink-0 cursor-pointer items-center peer-disabled:cursor-not-allowed",
1535
- children: [
1536
- /* @__PURE__ */ jsx17(
1537
- "input",
1538
- {
1539
- type: "checkbox",
1540
- name: props.name,
1541
- id: props.name,
1542
- checked: value,
1543
- onChange: textChangeHandler,
1544
- required: props?.attributes?.required,
1545
- disabled: props?.attributes?.readOnly,
1546
- className: "peer sr-only"
1547
- }
1548
- ),
1549
- /* @__PURE__ */ jsx17(
1550
- "div",
1551
- {
1552
- className: "h-6 w-11 rounded-full bg-slate-200 shadow-inner\n transition-colors duration-200 ease-in-out\n peer-checked:bg-blue-600\n peer-focus-visible:ring-2 peer-focus-visible:ring-blue-300 peer-focus-visible:ring-offset-2\n peer-disabled:bg-slate-100"
1553
- }
1554
- ),
1555
- /* @__PURE__ */ jsx17(
1556
- "div",
1557
- {
1558
- className: "absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-default shadow\n transition-transform duration-200 ease-in-out\n peer-checked:translate-x-5\n peer-disabled:bg-slate-50"
1559
- }
1560
- ),
1561
- /* @__PURE__ */ jsx17("p", { className: "hidden group-[.validated]:peer-invalid:block absolute left-0 top-full mt-1 w-max max-w-[220px] whitespace-normal bg-error-weak text-sm", children: props?.attributes?.errorMessage || "" })
1562
- ]
1563
- }
1564
- )
1565
- ] }) });
1566
- };
1567
- var SwitchInput_default = SwitchInput;
1568
-
1569
- // src/components/controls/edit/DateInput.tsx
1570
- import { useMemo } from "react";
1571
-
1572
- // src/components/utilities/DateTimeUtility.tsx
1573
- var DateTimeUtility = class {
1574
- constructor() {
1575
- }
1576
- static formatDate(date) {
1577
- if (!date) {
1578
- throw new Error("Invalid date");
1579
- }
1580
- const pad = (num) => num.toString().padStart(2, "0");
1581
- const year = date.getFullYear();
1582
- const month = pad(date.getMonth() + 1);
1583
- const day = pad(date.getDate());
1584
- const hours = pad(date.getHours());
1585
- const minutes = pad(date.getMinutes());
1586
- const seconds = pad(date.getSeconds());
1587
- return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
1588
- }
1589
- static getMonthShortNameCustom(month) {
1590
- const monthNames = [
1591
- "Jan",
1592
- "Feb",
1593
- "Mar",
1594
- "Apr",
1595
- "May",
1596
- "Jun",
1597
- "Jul",
1598
- "Aug",
1599
- "Sep",
1600
- "Oct",
1601
- "Nov",
1602
- "Dec"
1603
- ];
1604
- if (month < 1 || month > 12) {
1605
- throw new Error(
1606
- "Invalid month. Please provide a value between 1 and 12."
1607
- );
1608
- }
1609
- return monthNames[month - 1];
1610
- }
1611
- static getCurrentWeekRange() {
1612
- const today = /* @__PURE__ */ new Date();
1613
- const day = today.getDay();
1614
- const diffToMonday = (day === 0 ? -6 : 1) - day;
1615
- const monday = new Date(today);
1616
- monday.setDate(today.getDate() + diffToMonday);
1617
- monday.setHours(0, 0, 0, 0);
1618
- const sunday = new Date(monday);
1619
- sunday.setDate(monday.getDate() + 6);
1620
- sunday.setHours(23, 59, 59, 999);
1621
- return { start: monday, end: sunday };
1622
- }
1623
- static getCurrentMonthRange() {
1624
- const now = /* @__PURE__ */ new Date();
1625
- const start = new Date(now.getFullYear(), now.getMonth(), 1);
1626
- const end = new Date(now.getFullYear(), now.getMonth() + 1, 0);
1627
- return { start, end };
1628
- }
1629
- static formatShortDate(date) {
1630
- const day = date.getDate();
1631
- const month = this.getMonthShortNameCustom(date.getMonth() + 1);
1632
- return `${day} ${month}`;
1633
- }
1634
- static formatIndianCurrencyShort(value) {
1635
- if (value >= 1e7) {
1636
- return `${(value / 1e7).toFixed(2)} Cr`;
1637
- } else if (value >= 1e5) {
1638
- return `${(value / 1e5).toFixed(2)} L`;
1639
- } else if (value >= 1e3) {
1640
- return `${(value / 1e3).toFixed(2)} K`;
1641
- } else {
1642
- return `${value}`;
1643
- }
1644
- }
1645
- };
1646
- var DateTimeUtility_default = DateTimeUtility;
1647
-
1648
- // src/components/controls/edit/DateInput.tsx
1649
- import { jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
1650
- var DateInput = (props) => {
1651
- const value = useMemo(() => {
1652
- if (props.value === void 0 || props.value === null || props.value === "") {
1653
- return "";
1654
- }
1655
- try {
1656
- const rawValue = String(props.value);
1657
- const utcDate = new Date(rawValue.endsWith("Z") ? rawValue : `${rawValue}Z`);
1658
- const localDate = new Date(
1659
- utcDate.getTime() - utcDate.getTimezoneOffset() * 6e4
1660
- );
1661
- return localDate.toISOString().slice(0, 10);
1662
- } catch {
1663
- return String(props.value);
1664
- }
1665
- }, [props.value]);
1666
- const changeHandler = (event) => {
1667
- const dateValue = event.target.value;
1668
- let callbackValue = dateValue;
1669
- const parsedDate = new Date(dateValue);
1670
- if (dateValue && !Number.isNaN(parsedDate.getTime())) {
1671
- const adjustedDate = new Date(
1672
- parsedDate.getTime() + 2 * parsedDate.getTimezoneOffset() * 6e4
1673
- );
1674
- callbackValue = DateTimeUtility_default.formatDate(adjustedDate);
1675
- }
1676
- props.callback?.({
1677
- name: props.name,
1678
- value: callbackValue,
1679
- index: props.index,
1680
- groupKey: props.groupKey
1681
- });
1682
- };
1683
- return /* @__PURE__ */ jsxs18("label", { className: "block mb-1", children: [
1684
- props.attributes?.label && /* @__PURE__ */ jsx18("span", { className: "text-sm font-medium", children: props.attributes.label }),
1685
- " ",
1686
- props.attributes?.label && props.attributes.required && /* @__PURE__ */ jsx18("span", { className: "bg-error-weak", children: "*" }),
1687
- /* @__PURE__ */ jsx18(
1688
- "input",
1689
- {
1690
- type: "date",
1691
- name: props.name,
1692
- id: props.name,
1693
- value,
1694
- onChange: changeHandler,
1695
- required: props.attributes?.required,
1696
- disabled: props.attributes?.readOnly,
1697
- max: String(props.attributes?.maxValue ?? "9999-12-31"),
1698
- className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`
1699
- }
1700
- ),
1701
- /* @__PURE__ */ jsx18("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props.attributes?.errorMessage ?? "" })
1702
- ] });
1703
- };
1704
- var DateInput_default = DateInput;
1705
-
1706
- // src/components/controls/edit/RadioInput.tsx
1707
- import { useEffect as useEffect6, useState as useState4 } from "react";
1708
- import { jsx as jsx19, jsxs as jsxs19 } from "react/jsx-runtime";
1709
- var RadioInput = (props) => {
1710
- const [list, setList] = useState4([]);
1711
- useEffect6(() => {
1712
- async function loadData() {
1713
- if (props.dataset) {
1714
- setList(props.dataset);
1715
- return;
1716
- }
1717
- if (!props.dataSource || !props.serviceClient) {
1718
- setList([]);
1719
- return;
1720
- }
1721
- let dataSource = props.dataSource;
1722
- if (props.dataSourceDependsOn) {
1723
- if (!props.dependentValue) {
1724
- setList([]);
1725
- return;
1726
- }
1727
- dataSource = dataSource.replace(
1728
- `{${props.dataSourceDependsOn}}`,
1729
- props.dependentValue
1730
- );
1731
- }
1732
- const response = await props.serviceClient.get(dataSource);
1733
- setList(response.result ?? []);
1734
- }
1735
- loadData();
1736
- }, [
1737
- props.dataSource,
1738
- props.dataSourceDependsOn,
1739
- props.dataset,
1740
- props.dependentValue,
1741
- props.serviceClient
1742
- ]);
1743
- const changeHandler = (event) => {
1744
- if (!props.attributes?.readOnly) {
1745
- props.callback?.({
1746
- name: props.name,
1747
- value: event.target.value,
1748
- index: props.index,
1749
- groupKey: props.groupKey
1750
- });
1751
- }
1752
- };
1753
- return /* @__PURE__ */ jsxs19("div", { className: "block", children: [
1754
- /* @__PURE__ */ jsx19("span", { className: "text-sm font-medium", children: props.attributes?.label }),
1755
- /* @__PURE__ */ jsx19("div", { className: "flex flex-col gap-3", children: list.map((item, index) => {
1756
- const itemValue = item[props.dataKeyFieldName];
1757
- const isSelected = String(itemValue) === String(props.value ?? "");
1758
- const isRecommended = props.dataRecommendedValue !== void 0 && String(itemValue) === String(props.dataRecommendedValue);
1759
- const resultClassName = isSelected ? isRecommended ? "bg-success" : props.dataRecommendedValue ? "bg-alert" : "border-transparent" : "border-transparent";
1760
- const iconName = isSelected && props.dataRecommendedValue ? isRecommended ? "checkCircle" : "xCircle" : void 0;
1761
- const inputId = `${props.name}-${props.index ?? 0}-id-${index}`;
1762
- return /* @__PURE__ */ jsxs19(
1763
- "div",
1764
- {
1765
- className: `font-normal flex items-center justify-between gap-4 cursor-pointer border rounded p-2 ${resultClassName}`,
1766
- children: [
1767
- /* @__PURE__ */ jsxs19("div", { className: "flex gap-4 items-start", children: [
1768
- /* @__PURE__ */ jsx19(
1769
- "input",
1770
- {
1771
- type: "radio",
1772
- className: "form-radio mt-1.5 focus:outline-none",
1773
- name: `${props.name}-${props.index ?? 0}`,
1774
- id: inputId,
1775
- value: itemValue,
1776
- checked: isSelected,
1777
- readOnly: props.attributes?.readOnly,
1778
- onChange: changeHandler,
1779
- required: props.attributes?.required
1780
- }
1781
- ),
1782
- /* @__PURE__ */ jsx19("label", { className: "text-body-950 pr-2", htmlFor: inputId, children: item[props.dataTextFieldName] })
1783
- ] }),
1784
- iconName && /* @__PURE__ */ jsx19(Icon_default, { className: "w-5 h-5 text-success", name: iconName })
1785
- ]
1786
- },
1787
- String(itemValue)
1788
- );
1789
- }) }),
1790
- /* @__PURE__ */ jsx19("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props.attributes?.errorMessage ?? "" })
1791
- ] });
1792
- };
1793
- var RadioInput_default = RadioInput;
1794
-
1795
- // src/components/controls/edit/ReferenceInput.tsx
1796
- import { jsx as jsx20 } from "react/jsx-runtime";
1797
- var ReferenceInput = (props) => {
1798
- return /* @__PURE__ */ jsx20(SelectWithSearchInput_default, { ...props });
1799
- };
1800
- var ReferenceInput_default = ReferenceInput;
1801
-
1802
- // src/components/controls/edit/InputControlClient.tsx
1803
- import { jsx as jsx21 } from "react/jsx-runtime";
1804
- var InputControl = React20.forwardRef(
1805
- (props, ref) => {
1806
- const ControlComponents = {
1807
- [InputControlType_default.lineTextInput]: LineTextInput_default,
1808
- [InputControlType_default.emailInput]: EmailInput_default,
1809
- [InputControlType_default.multilineTextInput]: MultilineTextInput_default,
1810
- [InputControlType_default.moneyInput]: MoneyInput_default,
1811
- [InputControlType_default.select]: Select_default,
1812
- [InputControlType_default.percentageInput]: PercentageInput_default,
1813
- [InputControlType_default.phoneInput]: PhoneInput_default,
1814
- [InputControlType_default.numberInput]: NumberInput_default,
1815
- [InputControlType_default.checkboxInput]: CheckboxInput_default,
1816
- [InputControlType_default.otpInput]: OtpInput_default,
1817
- [InputControlType_default.datetimeInput]: DateTimeInput_default,
1818
- [InputControlType_default.colorInput]: ColorInput_default,
1819
- [InputControlType_default.selectWithSearchInput]: SelectWithSearchInput_default,
1820
- [InputControlType_default.selectWithSearchPanel]: SelectWithSearchPanel_default,
1821
- [InputControlType_default.timeInput]: TimeInput_default,
1822
- [InputControlType_default.assetUpload]: AssetUpload_default,
1823
- [InputControlType_default.switchInput]: SwitchInput_default,
1824
- [InputControlType_default.dateInput]: DateInput_default,
1825
- [InputControlType_default.radioInput]: RadioInput_default,
1826
- [InputControlType_default.referenceInput]: ReferenceInput_default
1827
- };
1828
- const SelectedControlComponent = ControlComponents[props.controlType];
1829
- return /* @__PURE__ */ jsx21(React20.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ jsx21(SelectedControlComponent, { ...props }) : "Control not found:" + props.controlType });
1830
- }
1831
- );
1832
- InputControl.displayName = "InputControl";
1833
- var InputControlClient_default = InputControl;
1834
- export {
1835
- InputControlClient_default as default
1836
- };