@acoustte-digital-services/digitalstore-controls 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
9
  var __getProtoOf = Object.getPrototypeOf;
@@ -19,6 +21,7 @@ var __spreadValues = (a, b) => {
19
21
  }
20
22
  return a;
21
23
  };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
25
  var __export = (target, all) => {
23
26
  for (var name in all)
24
27
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -44,6 +47,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
44
47
  // src/index.ts
45
48
  var index_exports = {};
46
49
  __export(index_exports, {
50
+ InputControl: () => InputControl_default,
51
+ InputControlType: () => InputControlType_default,
47
52
  ViewControl: () => ViewControl_default,
48
53
  ViewControlTypes: () => ViewControlTypes_default
49
54
  });
@@ -251,8 +256,1566 @@ var ViewControl = (props) => {
251
256
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.default.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectedControlComponent, __spreadValues({}, props)) : "Control not found" });
252
257
  };
253
258
  var ViewControl_default = ViewControl;
259
+
260
+ // src/controls/edit/InputControl.tsx
261
+ var import_react31 = __toESM(require("react"));
262
+
263
+ // src/controls/edit/MultilineTextInput.tsx
264
+ var import_react12 = __toESM(require("react"));
265
+ var import_jsx_runtime12 = require("react/jsx-runtime");
266
+ var MultilineTextInput = (props) => {
267
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
268
+ const textChangeHandler = (event) => {
269
+ const text = event.target.value;
270
+ if (props.callback !== void 0) {
271
+ props.callback(
272
+ {
273
+ name: props.name,
274
+ value: text,
275
+ index: props.index,
276
+ groupKey: props.groupKey
277
+ }
278
+ );
279
+ }
280
+ };
281
+ let value = "";
282
+ if (props.value !== void 0 && props.value !== null) {
283
+ value = props.value;
284
+ }
285
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "block mb-1", children: [
286
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-sm font-medium ", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
287
+ " ",
288
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) && ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.required) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-alert", children: "*" }),
289
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
290
+ "textarea",
291
+ {
292
+ name: props.name,
293
+ id: props.name,
294
+ value,
295
+ onChange: textChangeHandler,
296
+ onBlur: props == null ? void 0 : props.onBlur,
297
+ rows: 4,
298
+ required: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required,
299
+ placeholder: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.placeholder,
300
+ maxLength: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.maxLength,
301
+ disabled: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.readOnly,
302
+ minLength: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.minLength,
303
+ className: "peer mt-1 py-1.5 block w-full rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
304
+ }
305
+ ),
306
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.errorMessage) ? props.attributes.errorMessage : "" })
307
+ ] }) });
308
+ };
309
+ var MultilineTextInput_default = MultilineTextInput;
310
+
311
+ // src/controls/edit/LineTextInput.tsx
312
+ var import_react13 = __toESM(require("react"));
313
+ var import_jsx_runtime13 = require("react/jsx-runtime");
314
+ var LineTextInput = (props) => {
315
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
316
+ const textChangeHandler = (event) => {
317
+ const text = event.target.value;
318
+ if (props.callback !== void 0) {
319
+ props.callback(
320
+ {
321
+ name: props.name,
322
+ value: text,
323
+ index: props.index,
324
+ groupKey: props.groupKey
325
+ }
326
+ );
327
+ }
328
+ };
329
+ let value = "";
330
+ if (props.value !== void 0 && props.value !== null) {
331
+ value = props.value;
332
+ }
333
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "block", children: [
334
+ ((_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-sm inline-block pb-1 font-medium ", children: (_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label }),
335
+ " ",
336
+ ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.label) && ((_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-alert", children: "*" }),
337
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
338
+ "input",
339
+ {
340
+ type: "text",
341
+ name: props.name,
342
+ id: props.name,
343
+ value,
344
+ onChange: textChangeHandler,
345
+ onBlur: props == null ? void 0 : props.onBlur,
346
+ required: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.required,
347
+ placeholder: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.placeholder,
348
+ maxLength: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.maxLength,
349
+ pattern: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.pattern,
350
+ disabled: (_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.readOnly,
351
+ minLength: (_j = props == null ? void 0 : props.attributes) == null ? void 0 : _j.minLength,
352
+ className: `peer py-1.5 block w-full rounded border-gray-300 shadow-sm
353
+ focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
354
+ disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none
355
+ ${(props == null ? void 0 : props.inputClasses) ? props.inputClasses : ``}
356
+ `
357
+ }
358
+ ),
359
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_k = props == null ? void 0 : props.attributes) == null ? void 0 : _k.errorMessage) ? props.attributes.errorMessage : "" })
360
+ ] }) });
361
+ };
362
+ var LineTextInput_default = LineTextInput;
363
+
364
+ // src/controls/edit/MoneyInput.tsx
365
+ var import_react14 = __toESM(require("react"));
366
+ var import_jsx_runtime14 = require("react/jsx-runtime");
367
+ var MoneyInput = (props) => {
368
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
369
+ const textChangeHandler = (event) => {
370
+ const rawValue = event.target.value;
371
+ const numericValue = parseFloat(rawValue);
372
+ if (rawValue === "" || !isNaN(numericValue) && numericValue >= 0) {
373
+ if (props.callback !== void 0) {
374
+ props.callback({
375
+ name: props.name,
376
+ value: rawValue,
377
+ index: props.index,
378
+ groupKey: props.groupKey
379
+ });
380
+ }
381
+ }
382
+ };
383
+ const handleWheel = (event) => {
384
+ event.preventDefault();
385
+ event.target.blur();
386
+ };
387
+ let value;
388
+ if (props.value !== void 0 && props.value !== null) {
389
+ value = props.value;
390
+ }
391
+ const preventNegative = (e) => {
392
+ if (e.key === "-") {
393
+ e.preventDefault();
394
+ }
395
+ };
396
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "block mb-1", children: [
397
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-sm font-medium ", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
398
+ " ",
399
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) && ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.required) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-alert", children: "*" }),
400
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
401
+ "input",
402
+ {
403
+ type: "number",
404
+ name: props.name,
405
+ id: props.name,
406
+ value,
407
+ min: 0,
408
+ onChange: textChangeHandler,
409
+ onWheel: handleWheel,
410
+ onKeyDown: preventNegative,
411
+ required: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required,
412
+ placeholder: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.placeholder,
413
+ maxLength: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.maxLength,
414
+ pattern: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.pattern,
415
+ disabled: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.readOnly,
416
+ minLength: (_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.minLength,
417
+ className: "peer mt-1 py-1.5 block w-full rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 number-input"
418
+ }
419
+ ),
420
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_j = props == null ? void 0 : props.attributes) == null ? void 0 : _j.errorMessage) ? props.attributes.errorMessage : "" })
421
+ ] }) });
422
+ };
423
+ var MoneyInput_default = MoneyInput;
424
+
425
+ // src/controls/edit/Select.tsx
426
+ var import_react15 = require("react");
427
+ var import_jsx_runtime15 = require("react/jsx-runtime");
428
+ var Select = (props) => {
429
+ var _a, _b, _c, _d, _e, _f, _g, _h;
430
+ const [list, setList] = (0, import_react15.useState)([]);
431
+ const getSafeValue = (val) => {
432
+ if (val === null || val === void 0) return "";
433
+ if (typeof val === "boolean") return val ? "1" : "0";
434
+ return val;
435
+ };
436
+ const textChangeHandler = (event) => {
437
+ var _a2;
438
+ let rawValue = event.target.value;
439
+ if (rawValue === "") rawValue = null;
440
+ let finalValue = rawValue;
441
+ if (list && props.dataKeyFieldName) {
442
+ const key = props.dataKeyFieldName;
443
+ const selectedItem = list.find(
444
+ (item) => String(item[key]) === String(rawValue)
445
+ );
446
+ if (selectedItem) {
447
+ const keyValue = selectedItem[key];
448
+ if (typeof keyValue === "number") {
449
+ finalValue = Number(rawValue);
450
+ }
451
+ }
452
+ }
453
+ (_a2 = props.callback) == null ? void 0 : _a2.call(props, {
454
+ name: props.name,
455
+ value: finalValue,
456
+ index: props.index,
457
+ groupKey: props.groupKey
458
+ });
459
+ };
460
+ (0, import_react15.useEffect)(() => {
461
+ async function fetchData() {
462
+ var _a2;
463
+ if (props.dataset) {
464
+ setList(props.dataset);
465
+ return;
466
+ }
467
+ if (props.dataSource && props.serviceClient) {
468
+ let dataSource = props.dataSource;
469
+ let response;
470
+ if (props.dataSourceDependsOn && props.dependentValue) {
471
+ dataSource = dataSource.replace(
472
+ `{${props.dataSourceDependsOn}}`,
473
+ props.dependentValue
474
+ );
475
+ }
476
+ response = await props.serviceClient.get(dataSource);
477
+ setList((_a2 = response.result) != null ? _a2 : []);
478
+ }
479
+ }
480
+ fetchData();
481
+ }, [
482
+ props.dataset,
483
+ props.dataSource,
484
+ props.dependentValue,
485
+ props.dataSourceDependsOn
486
+ ]);
487
+ const value = getSafeValue(props.value);
488
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "block", children: [
489
+ ((_a = props.attributes) == null ? void 0 : _a.label) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-sm font-medium inline-block pb-1", children: (_b = props.attributes) == null ? void 0 : _b.label }),
490
+ ((_c = props.attributes) == null ? void 0 : _c.label) && ((_d = props.attributes) == null ? void 0 : _d.required) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-alert", children: "*" }),
491
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
492
+ "select",
493
+ {
494
+ name: props.name,
495
+ id: props.name,
496
+ value,
497
+ onChange: textChangeHandler,
498
+ required: (_e = props.attributes) == null ? void 0 : _e.required,
499
+ disabled: (_f = props.attributes) == null ? void 0 : _f.readOnly,
500
+ className: "peer py-1.5 block w-full text-black rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\r\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none",
501
+ children: [
502
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: ((_g = props.attributes) == null ? void 0 : _g.placeholder) || "Select" }),
503
+ list.map((item, index) => {
504
+ const keyField = props.dataKeyFieldName;
505
+ const textField = props.dataTextFieldName;
506
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: item[keyField], children: item[textField] }, index);
507
+ })
508
+ ]
509
+ }
510
+ ),
511
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_h = props.attributes) == null ? void 0 : _h.errorMessage) || "" })
512
+ ] });
513
+ };
514
+ var Select_default = Select;
515
+
516
+ // src/controls/edit/PercentageInput.tsx
517
+ var import_react16 = __toESM(require("react"));
518
+ var import_jsx_runtime16 = require("react/jsx-runtime");
519
+ var PercentageInput = (props) => {
520
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
521
+ const textChangeHandler = (event) => {
522
+ const rawValue = event.target.value;
523
+ const numericValue = parseFloat(rawValue);
524
+ if (rawValue === "" || !isNaN(numericValue) && numericValue >= 0) {
525
+ if (props.callback !== void 0) {
526
+ props.callback({
527
+ name: props.name,
528
+ value: rawValue,
529
+ index: props.index,
530
+ groupKey: props.groupKey
531
+ });
532
+ }
533
+ }
534
+ };
535
+ const handleWheel = (event) => {
536
+ event.preventDefault();
537
+ event.target.blur();
538
+ };
539
+ let value;
540
+ if (props.value !== void 0 && props.value !== null) {
541
+ value = props.value;
542
+ }
543
+ const preventNegative = (e) => {
544
+ if (e.key === "-") {
545
+ e.preventDefault();
546
+ }
547
+ };
548
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "block mb-1", children: [
549
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-sm font-medium ", children: ((_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label) ? ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) + " %" : "" }),
550
+ " ",
551
+ ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.label) && ((_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-alert", children: "*" }),
552
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
553
+ "input",
554
+ {
555
+ type: "number",
556
+ name: props.name,
557
+ id: props.name,
558
+ value,
559
+ min: 0,
560
+ onChange: textChangeHandler,
561
+ onKeyDown: preventNegative,
562
+ onWheel: handleWheel,
563
+ required: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.required,
564
+ placeholder: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.placeholder,
565
+ pattern: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.pattern,
566
+ disabled: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.readOnly,
567
+ max: "100",
568
+ className: "peer mt-1 py-1.5 block w-full rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 number-input"
569
+ }
570
+ ),
571
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.errorMessage) ? props.attributes.errorMessage : "" })
572
+ ] }) });
573
+ };
574
+ var PercentageInput_default = PercentageInput;
575
+
576
+ // src/controls/edit/PhoneInput.tsx
577
+ var import_react17 = __toESM(require("react"));
578
+ var import_jsx_runtime17 = require("react/jsx-runtime");
579
+ var PhoneInput = (props) => {
580
+ var _a, _b, _c, _d, _e, _f, _g, _h;
581
+ const textChangeHandler = (event) => {
582
+ const text = event.target.value;
583
+ if (props.callback !== void 0) {
584
+ props.callback(
585
+ {
586
+ name: props.name,
587
+ value: text,
588
+ index: props.index,
589
+ groupKey: props.groupKey
590
+ }
591
+ );
592
+ }
593
+ };
594
+ let value = "";
595
+ if (props.value !== void 0 && props.value !== null) {
596
+ value = props.value;
597
+ }
598
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react17.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "block mb-1", children: [
599
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-sm font-medium ", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
600
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center bg-gray-100 rounded border border-gray-300 \r\n focus-within:border-indigo-300 focus-within:ring focus-within:ring-indigo-200 focus-within:ring-opacity-50", children: [
601
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "px-3 text-gray-700", children: props.prefix }),
602
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
603
+ "input",
604
+ {
605
+ type: "text",
606
+ name: props.name,
607
+ id: props.name,
608
+ value,
609
+ onChange: textChangeHandler,
610
+ required: (_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.required,
611
+ placeholder: (_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.placeholder,
612
+ maxLength: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.maxLength,
613
+ pattern: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.pattern,
614
+ disabled: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.readOnly,
615
+ minLength: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.minLength,
616
+ className: "py-1.5 block w-full outline-none focus:ring-0 border-0 mr-0.5"
617
+ }
618
+ )
619
+ ] }),
620
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.errorMessage) ? props.attributes.errorMessage : "" })
621
+ ] }) });
622
+ };
623
+ var PhoneInput_default = PhoneInput;
624
+
625
+ // src/controls/edit/NumberInput.tsx
626
+ var import_react18 = __toESM(require("react"));
627
+ var import_jsx_runtime18 = require("react/jsx-runtime");
628
+ var NumberInput = (props) => {
629
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
630
+ const textChangeHandler = (event) => {
631
+ const text = event.target.value;
632
+ if (props.callback !== void 0) {
633
+ props.callback(
634
+ {
635
+ name: props.name,
636
+ value: text,
637
+ index: props.index,
638
+ groupKey: props.groupKey
639
+ }
640
+ );
641
+ }
642
+ };
643
+ const handleWheel = (event) => {
644
+ event.preventDefault();
645
+ event.target.blur();
646
+ };
647
+ let value;
648
+ if (props.value !== void 0 && props.value !== null) {
649
+ value = props.value;
650
+ }
651
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react18.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "block", children: [
652
+ ((_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm inline-block pb-1 font-medium ", children: (_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label }),
653
+ " ",
654
+ ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.label) && ((_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-alert", children: "*" }),
655
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
656
+ "input",
657
+ {
658
+ type: "number",
659
+ name: props.name,
660
+ id: props.name,
661
+ value,
662
+ onChange: textChangeHandler,
663
+ onWheel: handleWheel,
664
+ required: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.required,
665
+ placeholder: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.placeholder,
666
+ onBlur: props == null ? void 0 : props.onBlur,
667
+ pattern: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.pattern,
668
+ disabled: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.readOnly,
669
+ max: (_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.maxValue,
670
+ min: (_j = props == null ? void 0 : props.attributes) == null ? void 0 : _j.minValue,
671
+ className: "peer py-1.5 block w-full rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 number-input\r\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\r\n "
672
+ }
673
+ ),
674
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_k = props == null ? void 0 : props.attributes) == null ? void 0 : _k.errorMessage) ? props.attributes.errorMessage : "" })
675
+ ] }) });
676
+ };
677
+ var NumberInput_default = NumberInput;
678
+
679
+ // src/controls/edit/CheckboxInput.tsx
680
+ var import_react19 = __toESM(require("react"));
681
+ var import_jsx_runtime19 = require("react/jsx-runtime");
682
+ var CheckboxInput = (props) => {
683
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
684
+ const textChangeHandler = (event) => {
685
+ let text = event.target.checked;
686
+ console.log(text);
687
+ if (props.callback !== void 0) {
688
+ props.callback(
689
+ {
690
+ name: props.name,
691
+ value: text,
692
+ index: props.index,
693
+ groupKey: props.groupKey
694
+ }
695
+ );
696
+ }
697
+ };
698
+ const trueValue = true;
699
+ let value = false;
700
+ if (props.value != void 0 && props.value != null && props.value != "" && (props.value == "true" || props.value.toString() == "true")) {
701
+ value = true;
702
+ }
703
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react19.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "block mb-1", children: [
704
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-sm font-medium", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
705
+ " ",
706
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) && ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.required) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-alert", children: "*" }),
707
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
708
+ "input",
709
+ {
710
+ type: "checkbox",
711
+ name: props.name,
712
+ id: props.name,
713
+ checked: value,
714
+ onChange: textChangeHandler,
715
+ required: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required,
716
+ placeholder: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.placeholder,
717
+ maxLength: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.maxLength,
718
+ pattern: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.pattern,
719
+ disabled: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.readOnly,
720
+ minLength: (_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.minLength,
721
+ className: "peer mt-1 py-1.5 block rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\r\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\r\n "
722
+ }
723
+ ),
724
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_j = props == null ? void 0 : props.attributes) == null ? void 0 : _j.errorMessage) ? props.attributes.errorMessage : "" })
725
+ ] }) });
726
+ };
727
+ var CheckboxInput_default = CheckboxInput;
728
+
729
+ // src/controls/edit/OtpInput.tsx
730
+ var import_react20 = __toESM(require("react"));
731
+ var import_jsx_runtime20 = require("react/jsx-runtime");
732
+ var OtpInput = (props) => {
733
+ var _a, _b, _c, _d, _e, _f, _g, _h;
734
+ const textChangeHandler = (event) => {
735
+ const text = event.target.value;
736
+ if (props.callback !== void 0) {
737
+ props.callback(
738
+ {
739
+ name: props.name,
740
+ value: text,
741
+ index: props.index,
742
+ groupKey: props.groupKey
743
+ }
744
+ );
745
+ }
746
+ };
747
+ const handleWheel = (event) => {
748
+ event.preventDefault();
749
+ };
750
+ let value;
751
+ if (props.value !== void 0 && props.value !== null) {
752
+ value = props.value;
753
+ }
754
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react20.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { htmlFor: props.name, className: "block mb-1 w-full", children: [
755
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-sm font-medium ", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
756
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
757
+ "input",
758
+ {
759
+ type: "text",
760
+ name: props.name,
761
+ id: props.name,
762
+ value,
763
+ onChange: textChangeHandler,
764
+ autoComplete: "off",
765
+ required: (_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.required,
766
+ placeholder: (_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.placeholder,
767
+ maxLength: 4,
768
+ pattern: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.pattern,
769
+ disabled: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.readOnly,
770
+ minLength: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.minLength,
771
+ autoFocus: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.autoFocus,
772
+ onWheel: handleWheel,
773
+ className: "peer mt-1 py-1.5 block w-full rounded border-gray-300 shadow-sm tracking-[1.25em] text-center\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
774
+ }
775
+ ),
776
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.errorMessage) ? props.attributes.errorMessage : "" })
777
+ ] }) });
778
+ };
779
+ var OtpInput_default = OtpInput;
780
+
781
+ // src/controls/edit/DateTimeInput.tsx
782
+ var import_react21 = __toESM(require("react"));
783
+
784
+ // src/controls/utilities/DateTimeUtility.tsx
785
+ var DateTimeUtility = class {
786
+ constructor() {
787
+ }
788
+ static formatDate(date) {
789
+ if (!date) {
790
+ throw new Error("Invalid date");
791
+ }
792
+ const pad = (num) => num.toString().padStart(2, "0");
793
+ const year = date.getFullYear();
794
+ const month = pad(date.getMonth() + 1);
795
+ const day = pad(date.getDate());
796
+ const hours = pad(date.getHours());
797
+ const minutes = pad(date.getMinutes());
798
+ const seconds = pad(date.getSeconds());
799
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
800
+ }
801
+ static getMonthShortNameCustom(month) {
802
+ const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
803
+ if (month < 1 || month > 12) {
804
+ throw new Error("Invalid month. Please provide a value between 1 and 12.");
805
+ }
806
+ return monthNames[month - 1];
807
+ }
808
+ static getCurrentWeekRange() {
809
+ const today = /* @__PURE__ */ new Date();
810
+ const day = today.getDay();
811
+ const diffToMonday = (day === 0 ? -6 : 1) - day;
812
+ const monday = new Date(today);
813
+ monday.setDate(today.getDate() + diffToMonday);
814
+ monday.setHours(0, 0, 0, 0);
815
+ const sunday = new Date(monday);
816
+ sunday.setDate(monday.getDate() + 6);
817
+ sunday.setHours(23, 59, 59, 999);
818
+ return { start: monday, end: sunday };
819
+ }
820
+ static getCurrentMonthRange() {
821
+ const now = /* @__PURE__ */ new Date();
822
+ const start = new Date(now.getFullYear(), now.getMonth(), 1);
823
+ const end = new Date(now.getFullYear(), now.getMonth() + 1, 0);
824
+ return { start, end };
825
+ }
826
+ static formatShortDate(date) {
827
+ const day = date.getDate();
828
+ const month = this.getMonthShortNameCustom(date.getMonth() + 1);
829
+ return `${day} ${month}`;
830
+ }
831
+ static formatIndianCurrencyShort(value) {
832
+ if (value >= 1e7) {
833
+ return `${(value / 1e7).toFixed(2)} Cr`;
834
+ } else if (value >= 1e5) {
835
+ return `${(value / 1e5).toFixed(2)} L`;
836
+ } else if (value >= 1e3) {
837
+ return `${(value / 1e3).toFixed(2)} K`;
838
+ } else {
839
+ return `${value}`;
840
+ }
841
+ }
842
+ };
843
+ var DateTimeUtility_default = DateTimeUtility;
844
+
845
+ // src/controls/edit/DateTimeInput.tsx
846
+ var import_jsx_runtime21 = require("react/jsx-runtime");
847
+ var DateTimeInput = (props) => {
848
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
849
+ const textChangeHandler = (event) => {
850
+ const localDate = new Date(event.target.value);
851
+ if (props.callback !== void 0) {
852
+ const utcDate = new Date(localDate.getTime() + localDate.getTimezoneOffset() * 6e4);
853
+ let formattedDate = DateTimeUtility_default.formatDate(utcDate);
854
+ props.callback(
855
+ {
856
+ name: props.name,
857
+ value: formattedDate,
858
+ index: props.index,
859
+ groupKey: props.groupKey
860
+ }
861
+ );
862
+ }
863
+ };
864
+ let value;
865
+ let localvalue;
866
+ let timeZoneAbbr;
867
+ const now = /* @__PURE__ */ new Date();
868
+ const utcOffset = now.getTimezoneOffset();
869
+ if (props.value !== void 0 && props.value !== null) {
870
+ value = props.value;
871
+ const now2 = /* @__PURE__ */ new Date();
872
+ const offsetMinutes = now2.getTimezoneOffset();
873
+ const offsetMilliseconds = offsetMinutes * 60 * 1e3;
874
+ const valDate = value.toString().includes("Z") ? new Date(value) : /* @__PURE__ */ new Date(value + "Z");
875
+ let localDate = new Date(valDate.getTime() - offsetMilliseconds);
876
+ timeZoneAbbr = now2.toLocaleTimeString("en", { timeZoneName: "short" }).split(" ")[2];
877
+ localvalue = (_a = localDate == null ? void 0 : localDate.toISOString()) == null ? void 0 : _a.slice(0, 16);
878
+ }
879
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react21.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "block mb-1", children: [
880
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-sm font-medium ", children: (_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label }),
881
+ " ",
882
+ ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.label) && ((_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-alert", children: "*" }),
883
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-2", children: [
884
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
885
+ "input",
886
+ {
887
+ type: "datetime-local",
888
+ name: props.name,
889
+ id: props.name,
890
+ value: localvalue,
891
+ onChange: textChangeHandler,
892
+ required: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.required,
893
+ placeholder: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.placeholder,
894
+ maxLength: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.maxLength,
895
+ pattern: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.pattern,
896
+ disabled: (_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.readOnly,
897
+ minLength: (_j = props == null ? void 0 : props.attributes) == null ? void 0 : _j.minLength,
898
+ className: "peer mt-1 py-1.5 block w-full rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\r\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\r\n "
899
+ }
900
+ ),
901
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: timeZoneAbbr })
902
+ ] }),
903
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_k = props == null ? void 0 : props.attributes) == null ? void 0 : _k.errorMessage) ? props.attributes.errorMessage : "" })
904
+ ] }) });
905
+ };
906
+ var DateTimeInput_default = DateTimeInput;
907
+
908
+ // src/controls/edit/ColorInput.tsx
909
+ var import_react22 = __toESM(require("react"));
910
+ var import_jsx_runtime22 = require("react/jsx-runtime");
911
+ var ColorInput = (props) => {
912
+ var _a, _b, _c, _d, _e;
913
+ const [color, setColor] = import_react22.default.useState("#3b82f6");
914
+ (0, import_react22.useEffect)(() => {
915
+ if (props.value !== void 0 && props.value !== null) {
916
+ if (typeof props.value === "string") {
917
+ setColor(props.value);
918
+ }
919
+ }
920
+ }, [props.value]);
921
+ const handleColorChange = (event) => {
922
+ const newColor = event.target.value;
923
+ setColor(newColor);
924
+ if (props.callback) {
925
+ props.callback(
926
+ {
927
+ name: props.name,
928
+ value: newColor,
929
+ index: props.index,
930
+ groupKey: props.groupKey
931
+ }
932
+ );
933
+ }
934
+ };
935
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "block mb-1", children: [
936
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-sm font-medium", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
937
+ " ",
938
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) && ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.required) && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-alert", children: "*" }),
939
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
940
+ "input",
941
+ {
942
+ type: "color",
943
+ name: props.name,
944
+ id: props.name,
945
+ value: color,
946
+ onChange: handleColorChange,
947
+ required: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required,
948
+ className: `w-[88px] h-12 block cursor-pointer focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50`
949
+ }
950
+ ),
951
+ ((_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.errorMessage) && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "mt-1 text-alert text-sm", children: props.attributes.errorMessage })
952
+ ] });
953
+ };
954
+ var ColorInput_default = ColorInput;
955
+
956
+ // src/controls/edit/SelectWithSearchInput.tsx
957
+ var import_react23 = require("react");
958
+ var import_jsx_runtime23 = require("react/jsx-runtime");
959
+ var SelectWithSearchInput = (props) => {
960
+ var _a, _b;
961
+ const [isOpen, setIsOpen] = (0, import_react23.useState)(false);
962
+ const [searchTerm, setSearchTerm] = (0, import_react23.useState)("");
963
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react23.useState)(-1);
964
+ const [selectedItem, setSelectedItem] = (0, import_react23.useState)(null);
965
+ const [list, setList] = (0, import_react23.useState)([]);
966
+ (0, import_react23.useEffect)(() => {
967
+ async function fetchData() {
968
+ if (props.dataset) {
969
+ setList(props.dataset);
970
+ } else if (props.dataSource && props.serviceClient) {
971
+ let dataSource = props.dataSource;
972
+ if (props.dataSourceDependsOn && props.dependentValue) {
973
+ dataSource = dataSource.replace(
974
+ `{${props.dataSourceDependsOn}}`,
975
+ props.dependentValue
976
+ );
977
+ }
978
+ const response = await props.serviceClient.get(dataSource);
979
+ if (response == null ? void 0 : response.result) setList(response.result);
980
+ }
981
+ }
982
+ fetchData();
983
+ }, [
984
+ props.dataSource,
985
+ props.dependentValue,
986
+ props.dataset,
987
+ props.dataSourceDependsOn
988
+ ]);
989
+ const filteredItems = list == null ? void 0 : list.filter(
990
+ (item) => {
991
+ var _a2;
992
+ return (_a2 = item[props == null ? void 0 : props.dataTextFieldName]) == null ? void 0 : _a2.toLowerCase().includes(searchTerm.toLowerCase());
993
+ }
994
+ );
995
+ const handleSelect = (event, item) => {
996
+ event.preventDefault();
997
+ setSearchTerm(item[props.dataTextFieldName]);
998
+ setSelectedItem(item);
999
+ setIsOpen(false);
1000
+ setHighlightedIndex(-1);
1001
+ if (props.callback) {
1002
+ props.callback({
1003
+ name: props.name,
1004
+ value: item[props.dataKeyFieldName],
1005
+ index: props.index,
1006
+ groupKey: props.groupKey
1007
+ });
1008
+ }
1009
+ };
1010
+ const handleKeyDown = (e) => {
1011
+ if (e.key === "ArrowDown") {
1012
+ setHighlightedIndex(
1013
+ (prev) => prev < filteredItems.length - 1 ? prev + 1 : 0
1014
+ );
1015
+ } else if (e.key === "ArrowUp") {
1016
+ setHighlightedIndex(
1017
+ (prev) => prev > 0 ? prev - 1 : filteredItems.length - 1
1018
+ );
1019
+ } else if (e.key === "Enter" && highlightedIndex >= 0) {
1020
+ handleSelect(e, filteredItems[highlightedIndex]);
1021
+ }
1022
+ };
1023
+ const dropdownRef = (0, import_react23.useRef)(null);
1024
+ (0, import_react23.useEffect)(() => {
1025
+ if (highlightedIndex >= 0 && dropdownRef.current) {
1026
+ const highlightedItem = dropdownRef.current.children[highlightedIndex];
1027
+ highlightedItem == null ? void 0 : highlightedItem.scrollIntoView({
1028
+ behavior: "smooth",
1029
+ block: "nearest"
1030
+ });
1031
+ }
1032
+ }, [highlightedIndex]);
1033
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative", children: [
1034
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("label", { children: (_a = props.attributes) == null ? void 0 : _a.label }),
1035
+ " ",
1036
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.required) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-alert", children: "*" }),
1037
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative", children: [
1038
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1039
+ "input",
1040
+ {
1041
+ type: "text",
1042
+ value: searchTerm,
1043
+ onChange: (e) => {
1044
+ setSearchTerm(e.target.value);
1045
+ setIsOpen(true);
1046
+ setHighlightedIndex(-1);
1047
+ },
1048
+ onFocus: () => setIsOpen(true),
1049
+ onKeyDown: handleKeyDown,
1050
+ placeholder: "Select or search for a name",
1051
+ className: "peer py-1.5 block w-full text-black rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\r\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\r\n "
1052
+ }
1053
+ ),
1054
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1055
+ "button",
1056
+ {
1057
+ type: "button",
1058
+ onClick: () => setIsOpen(!isOpen),
1059
+ className: "absolute right-2 top-3 h-5 w-5 text-gray-500 focus:outline-none",
1060
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1061
+ "svg",
1062
+ {
1063
+ xmlns: "http://www.w3.org/2000/svg",
1064
+ fill: "none",
1065
+ viewBox: "0 0 24 24",
1066
+ strokeWidth: 1.5,
1067
+ stroke: "currentColor",
1068
+ className: "w-full h-full",
1069
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1070
+ "path",
1071
+ {
1072
+ strokeLinecap: "round",
1073
+ strokeLinejoin: "round",
1074
+ d: "M19.5 8.25l-7.5 7.5-7.5-7.5"
1075
+ }
1076
+ )
1077
+ }
1078
+ )
1079
+ }
1080
+ )
1081
+ ] }),
1082
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1083
+ "div",
1084
+ {
1085
+ ref: dropdownRef,
1086
+ className: "absolute z-10 mt-2 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-48 overflow-y-auto",
1087
+ children: filteredItems.length > 0 ? filteredItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1088
+ "button",
1089
+ {
1090
+ onClick: (e) => handleSelect(e, item),
1091
+ className: `w-full px-4 py-2 flex items-center space-x-2 text-left ${index === highlightedIndex ? "bg-gray-200" : "hover:bg-gray-100"}`,
1092
+ role: "option",
1093
+ tabIndex: -1,
1094
+ onMouseEnter: () => setHighlightedIndex(index),
1095
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: item[props.dataTextFieldName] })
1096
+ },
1097
+ item[props.dataKeyFieldName]
1098
+ )) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "px-4 py-2 text-gray-500", children: "No results found" })
1099
+ }
1100
+ )
1101
+ ] });
1102
+ };
1103
+ var SelectWithSearchInput_default = SelectWithSearchInput;
1104
+
1105
+ // src/controls/components/Button.tsx
1106
+ var import_react26 = __toESM(require("react"));
1107
+
1108
+ // src/controls/components/ToastService.tsx
1109
+ var ToastService = class _ToastService {
1110
+ static initialize(showToast, closeToast) {
1111
+ _ToastService.showToast = showToast;
1112
+ _ToastService.closeToast = closeToast;
1113
+ }
1114
+ static showError(message) {
1115
+ if (_ToastService.showToast) {
1116
+ _ToastService.showToast(message, "error");
1117
+ }
1118
+ }
1119
+ static showInfo(message) {
1120
+ if (_ToastService.showToast) {
1121
+ _ToastService.showToast(message, "info");
1122
+ }
1123
+ }
1124
+ static close() {
1125
+ if (_ToastService.closeToast) {
1126
+ _ToastService.closeToast();
1127
+ }
1128
+ }
1129
+ };
1130
+ var ToastService_default = ToastService;
1131
+
1132
+ // src/controls/components/StyleTypes.tsx
1133
+ var buttonClasses = /* @__PURE__ */ new Map([
1134
+ ["Primary" /* Primary */, "relative inline-flex items-center justify-center bg-primary rounded px-4 py-3 lg:py-2 font-medium shadow-sm hover:shadow-lg hover:bg-primary-strong focus:outline-none active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed transition duration-150 ease-in-out text-body"],
1135
+ ["Secondary" /* Secondary */, "relative inline-flex items-center justify-center bg-gradient-to-b from-secondary to-secondary-strong rounded px-4 py-3 lg:py-2 font-medium shadow-sm hover:shadow-lg focus:outline-none active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed transition duration-150 ease-in-out text-body hover:bg-secondary-strong"],
1136
+ ["Neutral" /* Neutral */, "relative inline-flex items-center justify-center bg-neutral-strong rounded px-4 py-3 lg:py-2 font-medium shadow-sm hover:shadow-lg focus:outline-none active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed transition duration-150 ease-in-out text-body hover:bg-neutral-stronger"],
1137
+ ["PrimaryHollow" /* PrimaryHollow */, "inline-flex font-medium items-center justify-center px-4 py-3 lg:py-2 transparent border-primary border text-primary rounded hover:shadow-md focus:outline-none transition duration-150 ease-in-out active:scale-95"],
1138
+ ["SecondaryHollow" /* SecondaryHollow */, "inline-flex font-medium items-center justify-center px-4 py-3 lg:py-2 transparent border-secondary border text-secondary rounded hover:shadow-md focus:outline-none transition duration-150 ease-in-out active:scale-95"],
1139
+ ["NeutralHollow" /* NeutralHollow */, "inline-flex font-medium items-center justify-center px-4 py-3 lg:py-2 transparent border-neutral border text-neutral rounded hover:shadow-md focus:outline-none transition duration-150 ease-in-out active:scale-95"],
1140
+ ["Ripple" /* Ripple */, "px-3 py-1.5 inline-flex items-center text-sm font-medium rounded border-[1.5px] border-primary ripple btn-bg-primary btn-primary-text"],
1141
+ ["Danger" /* Danger */, "inline-flex text-sm font-medium items-center justify-center px-4 py-2 border border-alert bg-alert text-white rounded hover:bg-alert-600 hover:border-alert-600 focus:outline-none active:ring-1 active:ring-alert"],
1142
+ ["Link" /* Link */, ""],
1143
+ ["Light" /* Light */, "inline-flex items-center justify-center rounded bg-white border px-4 py-2 leading-6 text-primary shadow-sm hover:shadow focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:opacity-50 disabled:cursor-not-allowed"]
1144
+ ]);
1145
+ var progressClasses = /* @__PURE__ */ new Map([
1146
+ ["Primary" /* Primary */, ""],
1147
+ ["PrimaryHollow" /* PrimaryHollow */, ""],
1148
+ ["Secondary" /* Secondary */, ""],
1149
+ ["SecondaryHollow" /* SecondaryHollow */, ""],
1150
+ ["Neutral" /* Neutral */, ""],
1151
+ ["NeutralHollow" /* NeutralHollow */, ""],
1152
+ ["Ripple" /* Ripple */, ""],
1153
+ ["Danger" /* Danger */, ""],
1154
+ ["Link" /* Link */, ""]
1155
+ ]);
1156
+
1157
+ // src/controls/components/Confirm.tsx
1158
+ var import_react25 = require("react");
1159
+
1160
+ // src/controls/components/ClientButton.tsx
1161
+ var import_react24 = __toESM(require("react"));
1162
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1163
+ var ClientButton = (props) => {
1164
+ const execute = async (event) => {
1165
+ event.preventDefault();
1166
+ if (props.onClick !== void 0) {
1167
+ props.onClick();
1168
+ } else {
1169
+ ToastService_default.showError("No action defined.");
1170
+ }
1171
+ };
1172
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Primary */);
1173
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react24.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1174
+ "button",
1175
+ {
1176
+ type: "button",
1177
+ onClick: execute,
1178
+ "data-role": props.dataRole,
1179
+ disabled: props.disabled,
1180
+ tabIndex: props.tabIndex,
1181
+ className: buttonClass + " " + props.className,
1182
+ children: props.children
1183
+ }
1184
+ ) });
1185
+ };
1186
+ var ClientButton_default = ClientButton;
1187
+
1188
+ // src/controls/components/Confirm.tsx
1189
+ var import_jsx_runtime25 = require("react/jsx-runtime");
1190
+ var Confirm = ({ message, onConfirm, onCancel }) => {
1191
+ const [showModal, setShowModal] = (0, import_react25.useState)(true);
1192
+ const handleConfirmAction = () => {
1193
+ setShowModal(false);
1194
+ if (onConfirm) {
1195
+ onConfirm();
1196
+ }
1197
+ };
1198
+ const handleCancelAction = () => {
1199
+ setShowModal(false);
1200
+ if (onCancel) {
1201
+ onCancel();
1202
+ }
1203
+ };
1204
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: showModal && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "fixed inset-0 flex items-center justify-center z-20", children: [
1205
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute inset-0 bg-black opacity-70" }),
1206
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "bg-white rounded-md p-6 shadow border z-50", children: [
1207
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xl font-semibold mb-4", children: "Confirmation" }),
1208
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "mb-4", children: message }),
1209
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-end gap-8", children: [
1210
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1211
+ ClientButton_default,
1212
+ {
1213
+ onClick: handleCancelAction,
1214
+ ButtonType: "PrimaryHollow" /* PrimaryHollow */,
1215
+ children: "Cancel"
1216
+ }
1217
+ ),
1218
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1219
+ ClientButton_default,
1220
+ {
1221
+ onClick: handleConfirmAction,
1222
+ children: "Confirm"
1223
+ }
1224
+ )
1225
+ ] })
1226
+ ] })
1227
+ ] }) });
1228
+ };
1229
+ var Confirm_default = Confirm;
1230
+ {
1231
+ }
1232
+
1233
+ // src/controls/components/Button.tsx
1234
+ var import_jsx_runtime26 = require("react/jsx-runtime");
1235
+ var Button = (props) => {
1236
+ const [inProgress, setInProgress] = (0, import_react26.useState)(false);
1237
+ const [isActionPerformed, setIsActionPerformed] = (0, import_react26.useState)(false);
1238
+ const [responseMessage, setResponseMessage] = (0, import_react26.useState)(null);
1239
+ const [showModal, setShowModal] = (0, import_react26.useState)(null);
1240
+ const execute = async (event) => {
1241
+ event.preventDefault();
1242
+ if (props.confirm) {
1243
+ const confirmed = await showConfirmation(
1244
+ "Are you sure you want to delete this item?"
1245
+ );
1246
+ setShowModal(null);
1247
+ if (!confirmed) {
1248
+ return;
1249
+ }
1250
+ }
1251
+ if (props.oneTimeAction && isActionPerformed) {
1252
+ return;
1253
+ }
1254
+ setInProgress(true);
1255
+ let isValid = true;
1256
+ if (props.onValidate !== void 0) {
1257
+ isValid = await props.onValidate();
1258
+ if (!isValid) {
1259
+ setInProgress(false);
1260
+ ToastService_default.showError(
1261
+ "There are error in the form. Please fix them before proceeding."
1262
+ );
1263
+ return;
1264
+ }
1265
+ }
1266
+ if (props.onClick !== void 0) {
1267
+ let response = await props.onClick(props.index);
1268
+ console.log(response);
1269
+ if (response.isSuccessful) {
1270
+ setIsActionPerformed(true);
1271
+ setResponseMessage(response.message);
1272
+ if (props.showToast) {
1273
+ ToastService_default.showInfo(response.message || "");
1274
+ }
1275
+ } else {
1276
+ ToastService_default.showError(response.message || "");
1277
+ }
1278
+ } else {
1279
+ ToastService_default.showError("No action defined.");
1280
+ }
1281
+ setInProgress(false);
1282
+ };
1283
+ const showConfirmation = (message) => {
1284
+ return new Promise((resolve) => {
1285
+ const onConfirm = () => resolve(true);
1286
+ const onCancel = () => resolve(false);
1287
+ setShowModal(
1288
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1289
+ Confirm_default,
1290
+ {
1291
+ message: props.confirmationMessage,
1292
+ onConfirm,
1293
+ onCancel
1294
+ }
1295
+ )
1296
+ );
1297
+ });
1298
+ };
1299
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Primary */);
1300
+ let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Primary */);
1301
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_react26.default.Fragment, { children: [
1302
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
1303
+ "button",
1304
+ {
1305
+ type: "submit",
1306
+ onClick: execute,
1307
+ id: props.id,
1308
+ disabled: props.disabled,
1309
+ className: buttonClass + " relative " + (props.className || "") + (props.isActive ? " scale-95 shadow-inner" : ""),
1310
+ children: [
1311
+ isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
1312
+ inProgress && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react26.default.Fragment, { children: props.hideProgressIndicator === true ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
1313
+ "svg",
1314
+ {
1315
+ className: "animate-spin ml-2 mr-3 h-5 w-5 " + progressClass,
1316
+ xmlns: "http://www.w3.org/2000/svg",
1317
+ fill: "none",
1318
+ viewBox: "0 0 24 24",
1319
+ children: [
1320
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1321
+ "circle",
1322
+ {
1323
+ className: "opacity-25",
1324
+ cx: "12",
1325
+ cy: "12",
1326
+ r: "10",
1327
+ stroke: "currentColor",
1328
+ strokeWidth: "4"
1329
+ }
1330
+ ),
1331
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1332
+ "path",
1333
+ {
1334
+ className: "opacity-75",
1335
+ fill: "currentColor",
1336
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
1337
+ }
1338
+ )
1339
+ ]
1340
+ }
1341
+ ) })
1342
+ ]
1343
+ }
1344
+ ),
1345
+ showModal
1346
+ ] });
1347
+ };
1348
+ var Button_default = Button;
1349
+
1350
+ // src/controls/edit/SelectWithSearchPanel.tsx
1351
+ var import_react27 = __toESM(require("react"));
1352
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1353
+ var SelectWithSearchPanel = (props) => {
1354
+ var _a, _b, _c, _d, _e, _f, _g;
1355
+ const [isOpen, setIsOpen] = (0, import_react27.useState)(false);
1356
+ const [searchTerm, setSearchTerm] = (0, import_react27.useState)("");
1357
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react27.useState)(0);
1358
+ const [list, setList] = (0, import_react27.useState)([]);
1359
+ const listRef = (0, import_react27.useRef)(null);
1360
+ const [isError, setIsError] = (0, import_react27.useState)(false);
1361
+ const containerRef = (0, import_react27.useRef)(null);
1362
+ const [isCreateOpen, setIsCreateOpen] = (0, import_react27.useState)(false);
1363
+ const [formData, setFormData] = (0, import_react27.useState)({});
1364
+ const getNestedValue = (obj, path) => {
1365
+ return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
1366
+ };
1367
+ (0, import_react27.useEffect)(() => {
1368
+ const handleClickOutside = (event) => {
1369
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
1370
+ setIsOpen(false);
1371
+ }
1372
+ };
1373
+ document.addEventListener("mousedown", handleClickOutside);
1374
+ return () => {
1375
+ document.removeEventListener("mousedown", handleClickOutside);
1376
+ };
1377
+ }, []);
1378
+ (0, import_react27.useEffect)(() => {
1379
+ async function fetchData() {
1380
+ if (props.dataset) {
1381
+ setList(props.dataset);
1382
+ } else if (props.dataSource && props.serviceClient) {
1383
+ let dataSource = props.dataSource;
1384
+ if (props.dataSourceDependsOn && props.dependentValue) {
1385
+ dataSource = dataSource.replace(`{${props.dataSourceDependsOn}}`, props.dependentValue);
1386
+ }
1387
+ const response = await props.serviceClient.get(dataSource);
1388
+ if (response == null ? void 0 : response.result) setList(response.result);
1389
+ }
1390
+ }
1391
+ fetchData();
1392
+ }, [props.dataSource, props.dependentValue, props.dataset, props.dataSourceDependsOn]);
1393
+ const filteredItems = list == null ? void 0 : list.filter((item) => {
1394
+ const value = getNestedValue(item, props.dataTextFieldName);
1395
+ return value == null ? void 0 : value.toLowerCase().includes(searchTerm == null ? void 0 : searchTerm.toLowerCase());
1396
+ });
1397
+ const playBeep = () => {
1398
+ const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
1399
+ const oscillator = audioCtx.createOscillator();
1400
+ const gainNode = audioCtx.createGain();
1401
+ oscillator.type = "square";
1402
+ oscillator.frequency.setValueAtTime(300, audioCtx.currentTime);
1403
+ gainNode.gain.setValueAtTime(0.02, audioCtx.currentTime);
1404
+ oscillator.connect(gainNode);
1405
+ gainNode.connect(audioCtx.destination);
1406
+ oscillator.start();
1407
+ setTimeout(() => {
1408
+ oscillator.stop();
1409
+ audioCtx.close();
1410
+ }, 250);
1411
+ };
1412
+ (0, import_react27.useEffect)(() => {
1413
+ const filteredItems2 = list == null ? void 0 : list.filter(
1414
+ (item) => {
1415
+ var _a2;
1416
+ return (_a2 = item[props == null ? void 0 : props.dataTextFieldName]) == null ? void 0 : _a2.toLowerCase().includes(searchTerm == null ? void 0 : searchTerm.toLowerCase());
1417
+ }
1418
+ );
1419
+ if (searchTerm.length > 0 && filteredItems2.length === 0) {
1420
+ playBeep();
1421
+ setIsError(true);
1422
+ } else {
1423
+ setIsError(false);
1424
+ }
1425
+ }, [searchTerm]);
1426
+ const handleSelect = (event, item) => {
1427
+ event.preventDefault();
1428
+ setSearchTerm(getNestedValue(item, props.dataTextFieldName));
1429
+ if (props.callback) {
1430
+ const val = {};
1431
+ props.callback({
1432
+ name: props.name,
1433
+ value: item[props.dataKeyFieldName],
1434
+ index: props.index,
1435
+ groupKey: props.groupKey
1436
+ });
1437
+ }
1438
+ setHighlightedIndex(0);
1439
+ setIsOpen(false);
1440
+ };
1441
+ const handleKeyDown = (e) => {
1442
+ if (e.key === "Escape") {
1443
+ setIsOpen(false);
1444
+ setHighlightedIndex(-1);
1445
+ } else if (e.key === "ArrowDown") {
1446
+ e.preventDefault();
1447
+ setHighlightedIndex((prev) => {
1448
+ const nextIndex = prev < filteredItems.length - 1 ? prev + 1 : prev;
1449
+ scrollIntoView(nextIndex);
1450
+ return nextIndex;
1451
+ });
1452
+ } else if (e.key === "ArrowUp") {
1453
+ e.preventDefault();
1454
+ setHighlightedIndex((prev) => {
1455
+ const prevIndex = prev > 0 ? prev - 1 : prev;
1456
+ scrollIntoView(prevIndex);
1457
+ return prevIndex;
1458
+ });
1459
+ } else if (e.key === "Enter" && highlightedIndex >= 0) {
1460
+ handleSelect(e, filteredItems[highlightedIndex]);
1461
+ }
1462
+ };
1463
+ const scrollIntoView = (index) => {
1464
+ if (listRef.current) {
1465
+ const item = listRef.current.children[index];
1466
+ if (item) {
1467
+ item.scrollIntoView();
1468
+ }
1469
+ }
1470
+ };
1471
+ const textChangeHandler = (event) => {
1472
+ const newSearchTerm = event.target.value;
1473
+ setSearchTerm(newSearchTerm);
1474
+ setIsOpen(true);
1475
+ setHighlightedIndex(0);
1476
+ };
1477
+ const handleInputChange = (event, field) => {
1478
+ setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [field]: event.target.value }));
1479
+ };
1480
+ const handleSaveModal = (0, import_react27.useCallback)(async (index) => {
1481
+ console.log("Form Data:", formData);
1482
+ return {
1483
+ isSuccessful: true,
1484
+ result: formData
1485
+ };
1486
+ }, [formData]);
1487
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "relative", children: [
1488
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { className: "text-sm mb-1 font-medium", children: (_a = props.attributes) == null ? void 0 : _a.label }),
1489
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1490
+ "input",
1491
+ {
1492
+ type: "text",
1493
+ value: searchTerm,
1494
+ onChange: textChangeHandler,
1495
+ onFocus: () => setIsOpen(true),
1496
+ onKeyDown: handleKeyDown,
1497
+ placeholder: (_b = props.attributes) == null ? void 0 : _b.placeholder,
1498
+ className: `peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
1499
+ ${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"}
1500
+ disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none`
1501
+ }
1502
+ ) }),
1503
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: containerRef, children: isOpen && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_react27.default.Fragment, { children: [
1504
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "fixed z-50 right-0 bg-white top-[62px] w-1/4 border-l border-gray-200", children: [
1505
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex flex-col p-2 bg-accent-950 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("h5", { className: "text-md text-white font-medium", children: [
1506
+ "Select a ",
1507
+ ((_c = props.attributes) == null ? void 0 : _c.label) || ((_d = props.attributes) == null ? void 0 : _d.heading)
1508
+ ] }) }),
1509
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200 h-10", children: props.createFields && props.createFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1510
+ "button",
1511
+ {
1512
+ type: "button",
1513
+ className: "text-primary hover:text-primary-800",
1514
+ onMouseDown: (e) => {
1515
+ e.preventDefault();
1516
+ setIsCreateOpen(true);
1517
+ },
1518
+ children: "Create"
1519
+ }
1520
+ ) })
1521
+ ] }),
1522
+ isCreateOpen && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "fixed right-0 w-1/4 h-full top-[62px] bg-white shadow-lg border-l border-gray-200 z-50", children: [
1523
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex flex-col p-2 bg-accent-950", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("h5", { className: "text-md font-medium text-white", children: [
1524
+ "Create New ",
1525
+ (_e = props.attributes) == null ? void 0 : _e.label
1526
+ ] }) }),
1527
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1528
+ "button",
1529
+ {
1530
+ type: "button",
1531
+ onClick: () => setIsCreateOpen(false),
1532
+ className: "text-red-600 hover:text-red-800",
1533
+ children: "Close"
1534
+ }
1535
+ ) }),
1536
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "p-4", children: [
1537
+ (_f = props.createFields) == null ? void 0 : _f.map((field) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "mb-4", children: [
1538
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { className: "text-sm mb-1 font-medium block", children: field.label }),
1539
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1540
+ "input",
1541
+ {
1542
+ type: field.type,
1543
+ value: formData[field.name] || "",
1544
+ onChange: (e) => handleInputChange(e, field.name),
1545
+ placeholder: field.placeholder,
1546
+ required: field.required,
1547
+ disabled: field.disabled,
1548
+ pattern: field.pattern,
1549
+ minLength: field.minLength,
1550
+ maxLength: field.maxLength,
1551
+ 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"
1552
+ }
1553
+ )
1554
+ ] }, field.name)),
1555
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
1556
+ Button_default,
1557
+ {
1558
+ onClick: async () => {
1559
+ await handleSaveModal();
1560
+ return { isSuccessful: true };
1561
+ },
1562
+ className: "w-full",
1563
+ children: [
1564
+ "Save ",
1565
+ (_g = props.attributes) == null ? void 0 : _g.label
1566
+ ]
1567
+ }
1568
+ )
1569
+ ] })
1570
+ ] }),
1571
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1572
+ "div",
1573
+ {
1574
+ ref: listRef,
1575
+ 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",
1576
+ style: { height: "calc(100vh - 130px)" },
1577
+ children: filteredItems.length > 0 ? filteredItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1578
+ "button",
1579
+ {
1580
+ onClick: (e) => {
1581
+ handleSelect(e, item);
1582
+ },
1583
+ 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"}`,
1584
+ role: "option",
1585
+ tabIndex: -1,
1586
+ onMouseEnter: () => setHighlightedIndex(index),
1587
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: getNestedValue(item, props.dataTextFieldName) })
1588
+ }
1589
+ ) }, item[props.dataKeyFieldName])) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "px-4 py-2 text-gray-500", children: "No results found" })
1590
+ }
1591
+ )
1592
+ ] }) })
1593
+ ] });
1594
+ };
1595
+ var SelectWithSearchPanel_default = SelectWithSearchPanel;
1596
+
1597
+ // src/controls/edit/BooleanSelect.tsx
1598
+ var import_react28 = __toESM(require("react"));
1599
+ var import_jsx_runtime28 = require("react/jsx-runtime");
1600
+ var BooleanSelect = (props) => {
1601
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1602
+ const [list, setList] = (0, import_react28.useState)();
1603
+ const textChangeHandler = (event) => {
1604
+ const text = event.target.value;
1605
+ const boolValue = (text == null ? void 0 : text.toLowerCase()) === "true" || text === "1";
1606
+ if (props.callback !== void 0) {
1607
+ props.callback(
1608
+ {
1609
+ name: props.name,
1610
+ value: boolValue,
1611
+ index: props.index,
1612
+ groupKey: props.groupKey
1613
+ }
1614
+ );
1615
+ }
1616
+ };
1617
+ (0, import_react28.useEffect)(() => {
1618
+ async function fetchData() {
1619
+ console.log("in select");
1620
+ if (props.dataset) {
1621
+ setList(props.dataset);
1622
+ } else if (props.dataSource && props.dataSource != "" && props.serviceClient) {
1623
+ let dataSource = props.dataSource;
1624
+ let response;
1625
+ if (props.dataSourceDependsOn) {
1626
+ if (props.dependentValue) {
1627
+ dataSource = dataSource.replace(`{${props.dataSourceDependsOn}}`, props.dependentValue);
1628
+ response = await props.serviceClient.get(dataSource);
1629
+ setList(response.result);
1630
+ }
1631
+ } else {
1632
+ response = await props.serviceClient.get(dataSource);
1633
+ setList(response.result);
1634
+ }
1635
+ }
1636
+ }
1637
+ fetchData();
1638
+ }, [props.dataSource, props.dependentValue, props.dataset, props.dataSourceDependsOn]);
1639
+ let value;
1640
+ if (props.value !== void 0 && props.value !== null) {
1641
+ value = props.value;
1642
+ }
1643
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react28.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "block", children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-sm font-medium ", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
1645
+ " ",
1646
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) && ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.required) && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-alert", children: "*" }),
1647
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
1648
+ "select",
1649
+ {
1650
+ name: props.name,
1651
+ id: props.name,
1652
+ value,
1653
+ onChange: textChangeHandler,
1654
+ required: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required,
1655
+ placeholder: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.placeholder,
1656
+ disabled: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.readOnly,
1657
+ className: "peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\r\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\r\n ",
1658
+ children: [
1659
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { className: "", value: "", children: ((_g = props.attributes) == null ? void 0 : _g.placeholder) || "Select" }),
1660
+ list && list.map((item, i) => {
1661
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1662
+ "option",
1663
+ {
1664
+ className: "fac-select-option",
1665
+ value: item[props.dataKeyFieldName],
1666
+ children: item[props.dataTextFieldName]
1667
+ },
1668
+ item[props.dataKeyFieldName]
1669
+ );
1670
+ })
1671
+ ]
1672
+ }
1673
+ ),
1674
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: ((_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.errorMessage) ? props.attributes.errorMessage : "" })
1675
+ ] }) });
1676
+ };
1677
+ var BooleanSelect_default = BooleanSelect;
1678
+
1679
+ // src/controls/edit/EmailInput.tsx
1680
+ var import_react29 = __toESM(require("react"));
1681
+ var import_jsx_runtime29 = require("react/jsx-runtime");
1682
+ var EmailInput = (props) => {
1683
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1684
+ const textChangeHandler = (event) => {
1685
+ const text = event.target.value;
1686
+ if (text) {
1687
+ const atIndex = text.indexOf("@");
1688
+ const dotIndex = text.indexOf(".", atIndex);
1689
+ if (dotIndex < atIndex || text.length - dotIndex <= 2) {
1690
+ event.target.setCustomValidity("invaild-value");
1691
+ } else {
1692
+ event.target.setCustomValidity("");
1693
+ }
1694
+ }
1695
+ if (props.callback !== void 0) {
1696
+ props.callback({
1697
+ name: props.name,
1698
+ value: text,
1699
+ index: props.index
1700
+ });
1701
+ }
1702
+ };
1703
+ let value = "";
1704
+ if (props.value !== void 0 && props.value !== null) {
1705
+ value = props.value;
1706
+ }
1707
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react29.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "block mb-1", children: [
1708
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-sm font-medium text-slate-700", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
1709
+ " ",
1710
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) && ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.required) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-alert", children: "*" }),
1711
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1712
+ "input",
1713
+ {
1714
+ type: "email",
1715
+ name: props.name,
1716
+ id: props.name,
1717
+ value,
1718
+ onChange: textChangeHandler,
1719
+ required: (_d = props == null ? void 0 : props.attributes) == null ? void 0 : _d.required,
1720
+ placeholder: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.placeholder,
1721
+ maxLength: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.maxLength,
1722
+ disabled: (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.readOnly,
1723
+ minLength: (_h = props == null ? void 0 : props.attributes) == null ? void 0 : _h.minLength,
1724
+ className: "peer mt-1 py-1.5 block w-full rounded border-gray-300 shadow-sm\r\n focus-within:border-neutral-300 focus-within:ring focus-within:ring-neutral-300 focus-within:ring-opacity-50 transition-all duration-500 ease-in-out"
1725
+ }
1726
+ ),
1727
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 mb-0 text-alert text-sm", children: ((_i = props == null ? void 0 : props.attributes) == null ? void 0 : _i.errorMessage) ? props.attributes.errorMessage : "" })
1728
+ ] }) });
1729
+ };
1730
+ var EmailInput_default = EmailInput;
1731
+
1732
+ // src/controls/edit/TimeInput.tsx
1733
+ var import_react30 = __toESM(require("react"));
1734
+ var import_jsx_runtime30 = require("react/jsx-runtime");
1735
+ var TimeInput = (props) => {
1736
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1737
+ const timeChangeHandler = (event) => {
1738
+ const timeValue = event.target.value;
1739
+ if (props.callback) {
1740
+ props.callback({
1741
+ name: props.name,
1742
+ value: timeValue,
1743
+ index: props.index,
1744
+ groupKey: props.groupKey
1745
+ });
1746
+ }
1747
+ };
1748
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react30.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "block mb-1", children: [
1749
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "text-sm font-medium", children: (_a = props == null ? void 0 : props.attributes) == null ? void 0 : _a.label }),
1750
+ ((_b = props == null ? void 0 : props.attributes) == null ? void 0 : _b.label) && ((_c = props == null ? void 0 : props.attributes) == null ? void 0 : _c.required) && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "text-alert", children: "*" }),
1751
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1752
+ "input",
1753
+ {
1754
+ type: "time",
1755
+ name: props.name,
1756
+ id: props.name,
1757
+ value: typeof props.value === "boolean" ? "" : (_d = props.value) != null ? _d : "",
1758
+ onChange: timeChangeHandler,
1759
+ required: (_e = props == null ? void 0 : props.attributes) == null ? void 0 : _e.required,
1760
+ disabled: (_f = props == null ? void 0 : props.attributes) == null ? void 0 : _f.readOnly,
1761
+ className: "peer mt-1 py-1.5 block w-full rounded border-gray-300 shadow-sm\r\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\r\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none"
1762
+ }
1763
+ ) }),
1764
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: (_h = (_g = props == null ? void 0 : props.attributes) == null ? void 0 : _g.errorMessage) != null ? _h : "" })
1765
+ ] }) });
1766
+ };
1767
+ var TimeInput_default = TimeInput;
1768
+
1769
+ // src/controls/edit/InputControlType.tsx
1770
+ var InputControlType = {
1771
+ lineTextInput: "text",
1772
+ multilineTextInput: "multilinetext",
1773
+ emailInput: "email",
1774
+ moneyInput: "money",
1775
+ select: "select",
1776
+ percentageInput: "percentage",
1777
+ phoneInput: "phone",
1778
+ numberInput: "number",
1779
+ checkboxInput: "boolean",
1780
+ otpInput: "otp",
1781
+ datetimeInput: "datetime",
1782
+ timeInput: "time",
1783
+ colorInput: "colorInput",
1784
+ selectWithSearchInput: "selectWithSearchInput",
1785
+ selectWithSearchPanel: "selectWithSearchPanel",
1786
+ booleanSelect: "booleanSelect"
1787
+ };
1788
+ var InputControlType_default = InputControlType;
1789
+
1790
+ // src/controls/edit/InputControl.tsx
1791
+ var import_jsx_runtime31 = require("react/jsx-runtime");
1792
+ var InputControl = (props) => {
1793
+ const ControlComponents = {
1794
+ [InputControlType_default.lineTextInput]: LineTextInput_default,
1795
+ [InputControlType_default.emailInput]: EmailInput_default,
1796
+ [InputControlType_default.multilineTextInput]: MultilineTextInput_default,
1797
+ [InputControlType_default.moneyInput]: MoneyInput_default,
1798
+ [InputControlType_default.select]: Select_default,
1799
+ [InputControlType_default.percentageInput]: PercentageInput_default,
1800
+ [InputControlType_default.phoneInput]: PhoneInput_default,
1801
+ [InputControlType_default.numberInput]: NumberInput_default,
1802
+ [InputControlType_default.checkboxInput]: CheckboxInput_default,
1803
+ [InputControlType_default.otpInput]: OtpInput_default,
1804
+ [InputControlType_default.datetimeInput]: DateTimeInput_default,
1805
+ [InputControlType_default.colorInput]: ColorInput_default,
1806
+ [InputControlType_default.selectWithSearchInput]: SelectWithSearchInput_default,
1807
+ [InputControlType_default.selectWithSearchPanel]: SelectWithSearchPanel_default,
1808
+ [InputControlType_default.booleanSelect]: BooleanSelect_default,
1809
+ [InputControlType_default.timeInput]: TimeInput_default
1810
+ };
1811
+ const SelectedControlComponent = ControlComponents[props.controlType];
1812
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react31.default.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(SelectedControlComponent, __spreadValues({}, props)) : "Control not found" });
1813
+ };
1814
+ var InputControl_default = InputControl;
254
1815
  // Annotate the CommonJS export names for ESM import in node:
255
1816
  0 && (module.exports = {
1817
+ InputControl,
1818
+ InputControlType,
256
1819
  ViewControl,
257
1820
  ViewControlTypes
258
1821
  });