@form-eng/chakra 1.1.1

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.mjs ADDED
@@ -0,0 +1,781 @@
1
+ // src/fields/Textbox.tsx
2
+ import { Input } from "@chakra-ui/react";
3
+
4
+ // src/components/ReadOnlyText.tsx
5
+ import { jsx } from "react/jsx-runtime";
6
+ var ReadOnlyText = (props) => {
7
+ const { value, fieldName, ellipsifyTextCharacters } = props;
8
+ const cutoff = (ellipsifyTextCharacters || 0) - 3;
9
+ const displayValue = value ? ellipsifyTextCharacters && value.length > ellipsifyTextCharacters ? `${value.substring(0, cutoff)}...` : value : "-";
10
+ return /* @__PURE__ */ jsx(
11
+ "span",
12
+ {
13
+ id: `${fieldName}-read-only`,
14
+ className: "fe-read-only-text",
15
+ title: value,
16
+ children: displayValue
17
+ }
18
+ );
19
+ };
20
+
21
+ // src/helpers.ts
22
+ import {
23
+ FieldClassName,
24
+ GetFieldDataTestId,
25
+ getFieldState,
26
+ formatDateTime,
27
+ DocumentLinksStrings
28
+ } from "@form-eng/core";
29
+
30
+ // src/fields/Textbox.tsx
31
+ import { jsx as jsx2 } from "react/jsx-runtime";
32
+ var Textbox = (props) => {
33
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, placeholder, setFieldValue } = props;
34
+ const onChange = (event) => {
35
+ setFieldValue(fieldName, event.target.value, false, 3e3);
36
+ };
37
+ if (readOnly) {
38
+ return /* @__PURE__ */ jsx2(
39
+ ReadOnlyText,
40
+ {
41
+ fieldName,
42
+ value,
43
+ ellipsifyTextCharacters: config?.ellipsifyTextCharacters
44
+ }
45
+ );
46
+ }
47
+ return /* @__PURE__ */ jsx2(
48
+ Input,
49
+ {
50
+ type: "text",
51
+ autoComplete: "off",
52
+ value: value ?? "",
53
+ onChange,
54
+ placeholder: placeholder ?? config?.placeHolder,
55
+ "aria-invalid": !!error,
56
+ "aria-required": required,
57
+ "data-field-type": "Textbox",
58
+ "data-field-state": getFieldState({ error, required, readOnly }),
59
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
60
+ }
61
+ );
62
+ };
63
+ var Textbox_default = Textbox;
64
+
65
+ // src/fields/Number.tsx
66
+ import { isNull } from "@form-eng/core";
67
+ import { Input as Input2 } from "@chakra-ui/react";
68
+ import { jsx as jsx3 } from "react/jsx-runtime";
69
+ var NumberField = (props) => {
70
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, setFieldValue } = props;
71
+ const onChange = (event) => {
72
+ const number = Number(event.target.value);
73
+ if (!isNaN(number)) {
74
+ setFieldValue(fieldName, number, false, 1500);
75
+ }
76
+ };
77
+ if (readOnly) {
78
+ return /* @__PURE__ */ jsx3(ReadOnlyText, { fieldName, value: String(value) });
79
+ }
80
+ return /* @__PURE__ */ jsx3(
81
+ Input2,
82
+ {
83
+ type: "number",
84
+ autoComplete: "off",
85
+ value: !isNull(value) ? String(value) : "",
86
+ onChange,
87
+ "aria-invalid": !!error,
88
+ "aria-required": required,
89
+ "data-field-type": "Number",
90
+ "data-field-state": getFieldState({ error, required, readOnly }),
91
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
92
+ }
93
+ );
94
+ };
95
+ var Number_default = NumberField;
96
+
97
+ // src/fields/Toggle.tsx
98
+ import { convertBooleanToYesOrNoText } from "@form-eng/core";
99
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
100
+ var Toggle = (props) => {
101
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, label, setFieldValue } = props;
102
+ const onChange = (event) => {
103
+ setFieldValue(fieldName, event.target.checked);
104
+ };
105
+ if (readOnly) {
106
+ return /* @__PURE__ */ jsx4(ReadOnlyText, { fieldName, value: convertBooleanToYesOrNoText(value) });
107
+ }
108
+ return /* @__PURE__ */ jsxs(
109
+ "label",
110
+ {
111
+ style: {
112
+ display: "inline-flex",
113
+ alignItems: "center",
114
+ gap: "8px",
115
+ cursor: "pointer"
116
+ },
117
+ "data-field-type": "Toggle",
118
+ "data-field-state": getFieldState({ error, required, readOnly }),
119
+ children: [
120
+ /* @__PURE__ */ jsx4(
121
+ "input",
122
+ {
123
+ type: "checkbox",
124
+ role: "switch",
125
+ checked: !!value,
126
+ onChange,
127
+ "aria-invalid": !!error,
128
+ "aria-required": required,
129
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
130
+ style: { accentColor: "var(--chakra-colors-blue-500, #3182CE)" }
131
+ }
132
+ ),
133
+ label && /* @__PURE__ */ jsx4("span", { style: { fontSize: "var(--chakra-fontSizes-md, 16px)" }, children: label })
134
+ ]
135
+ }
136
+ );
137
+ };
138
+ var Toggle_default = Toggle;
139
+
140
+ // src/fields/Dropdown.tsx
141
+ import { NativeSelect } from "@chakra-ui/react";
142
+ import React from "react";
143
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
144
+ var Dropdown = (props) => {
145
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, options, placeholder, setFieldValue } = props;
146
+ const onChange = (event) => {
147
+ setFieldValue(fieldName, event.target.value);
148
+ };
149
+ React.useEffect(() => {
150
+ if (!value && !readOnly && config?.setDefaultKeyIfOnlyOneOption && options?.length === 1) {
151
+ setFieldValue(fieldName, String(options[0].value));
152
+ }
153
+ }, [options]);
154
+ if (readOnly) {
155
+ return /* @__PURE__ */ jsx5(ReadOnlyText, { fieldName, value });
156
+ }
157
+ return /* @__PURE__ */ jsxs2(
158
+ NativeSelect.Root,
159
+ {
160
+ "data-field-type": "Dropdown",
161
+ "data-field-state": getFieldState({ error, required, readOnly }),
162
+ children: [
163
+ /* @__PURE__ */ jsxs2(
164
+ NativeSelect.Field,
165
+ {
166
+ value: value ?? "",
167
+ onChange,
168
+ "aria-invalid": !!error,
169
+ "aria-required": required,
170
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
171
+ children: [
172
+ /* @__PURE__ */ jsx5("option", { value: "", children: placeholder ?? config?.placeHolder ?? "" }),
173
+ options?.map((option) => /* @__PURE__ */ jsx5("option", { value: String(option.value), disabled: option.disabled, children: option.label }, String(option.value)))
174
+ ]
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsx5(NativeSelect.Indicator, {})
178
+ ]
179
+ }
180
+ );
181
+ };
182
+ var Dropdown_default = Dropdown;
183
+
184
+ // src/fields/SimpleDropdown.tsx
185
+ import { NativeSelect as NativeSelect2 } from "@chakra-ui/react";
186
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
187
+ var SimpleDropdown = (props) => {
188
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, placeholder, setFieldValue } = props;
189
+ const simpleOptions = config?.dropdownOptions ?? [];
190
+ const onChange = (event) => {
191
+ setFieldValue(fieldName, event.target.value);
192
+ };
193
+ if (readOnly) {
194
+ return /* @__PURE__ */ jsx6(ReadOnlyText, { fieldName, value });
195
+ }
196
+ return /* @__PURE__ */ jsxs3(
197
+ NativeSelect2.Root,
198
+ {
199
+ "data-field-type": "SimpleDropdown",
200
+ "data-field-state": getFieldState({ error, required, readOnly }),
201
+ children: [
202
+ /* @__PURE__ */ jsxs3(
203
+ NativeSelect2.Field,
204
+ {
205
+ value: value ?? "",
206
+ onChange,
207
+ "aria-invalid": !!error,
208
+ "aria-required": required,
209
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
210
+ children: [
211
+ /* @__PURE__ */ jsx6("option", { value: "", children: placeholder ?? config?.placeHolder ?? "" }),
212
+ simpleOptions.map((option) => /* @__PURE__ */ jsx6("option", { value: option, children: option }, option))
213
+ ]
214
+ }
215
+ ),
216
+ /* @__PURE__ */ jsx6(NativeSelect2.Indicator, {})
217
+ ]
218
+ }
219
+ );
220
+ };
221
+ var SimpleDropdown_default = SimpleDropdown;
222
+
223
+ // src/fields/MultiSelect.tsx
224
+ import { jsx as jsx7 } from "react/jsx-runtime";
225
+ var MultiSelect = (props) => {
226
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options, setFieldValue } = props;
227
+ const selectedValues = value ?? [];
228
+ const onChange = (event) => {
229
+ const selected = Array.from(event.target.selectedOptions, (opt) => opt.value);
230
+ setFieldValue(fieldName, selected, false, 1500);
231
+ };
232
+ if (readOnly) {
233
+ return selectedValues.length > 0 ? /* @__PURE__ */ jsx7(
234
+ "ul",
235
+ {
236
+ style: { listStyle: "none", padding: 0, margin: 0 },
237
+ "data-field-type": "MultiSelect",
238
+ "data-field-state": "readonly",
239
+ children: selectedValues.map((v, i) => /* @__PURE__ */ jsx7("li", { style: { padding: "2px 0" }, children: v }, i))
240
+ }
241
+ ) : /* @__PURE__ */ jsx7("span", { className: "fe-read-only-text", children: "-" });
242
+ }
243
+ return /* @__PURE__ */ jsx7(
244
+ "select",
245
+ {
246
+ multiple: true,
247
+ style: {
248
+ width: "100%",
249
+ minHeight: "80px",
250
+ padding: "8px",
251
+ borderWidth: "1px",
252
+ borderStyle: "solid",
253
+ borderColor: error ? "var(--chakra-colors-red-500, #E53E3E)" : "var(--chakra-colors-gray-200, #E2E8F0)",
254
+ borderRadius: "var(--chakra-radii-md, 6px)",
255
+ fontSize: "var(--chakra-fontSizes-md, 16px)",
256
+ background: "var(--chakra-colors-white, #FFFFFF)"
257
+ },
258
+ value: selectedValues,
259
+ onChange,
260
+ "aria-invalid": !!error,
261
+ "aria-required": required,
262
+ "data-field-type": "MultiSelect",
263
+ "data-field-state": getFieldState({ error, required, readOnly }),
264
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
265
+ children: options?.map((option) => /* @__PURE__ */ jsx7("option", { value: String(option.value), disabled: option.disabled, children: option.label }, String(option.value)))
266
+ }
267
+ );
268
+ };
269
+ var MultiSelect_default = MultiSelect;
270
+
271
+ // src/fields/DateControl.tsx
272
+ import { FormStrings } from "@form-eng/core";
273
+ import { Input as Input3 } from "@chakra-ui/react";
274
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
275
+ var DateControl = (props) => {
276
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, setFieldValue } = props;
277
+ const onChange = (event) => {
278
+ const date = new Date(event.target.value);
279
+ if (!isNaN(date.getTime())) {
280
+ setFieldValue(fieldName, date.toISOString());
281
+ }
282
+ };
283
+ const onClear = () => {
284
+ setFieldValue(fieldName, null);
285
+ };
286
+ const dateInputValue = value ? new Date(value).toISOString().split("T")[0] : "";
287
+ if (readOnly) {
288
+ return value ? /* @__PURE__ */ jsx8(
289
+ "time",
290
+ {
291
+ className: "fe-read-only-date",
292
+ dateTime: value,
293
+ "data-field-type": "DateControl",
294
+ "data-field-state": "readonly",
295
+ children: formatDateTime(value, { hideTimestamp: true })
296
+ }
297
+ ) : /* @__PURE__ */ jsx8("span", { className: "fe-read-only-text", children: "-" });
298
+ }
299
+ return /* @__PURE__ */ jsxs4(
300
+ "div",
301
+ {
302
+ style: { display: "flex", alignItems: "center", gap: "8px" },
303
+ "data-field-type": "DateControl",
304
+ "data-field-state": getFieldState({ error, required, readOnly }),
305
+ children: [
306
+ /* @__PURE__ */ jsx8(
307
+ Input3,
308
+ {
309
+ type: "date",
310
+ value: dateInputValue,
311
+ onChange,
312
+ "aria-invalid": !!error,
313
+ "aria-required": required,
314
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
315
+ }
316
+ ),
317
+ /* @__PURE__ */ jsx8(
318
+ "button",
319
+ {
320
+ type: "button",
321
+ onClick: onClear,
322
+ title: FormStrings.clickToClear,
323
+ "aria-label": `${fieldName} ${FormStrings.clear}`,
324
+ style: {
325
+ background: "none",
326
+ border: "none",
327
+ cursor: "pointer",
328
+ fontSize: "18px",
329
+ color: "var(--chakra-colors-gray-500, #718096)",
330
+ padding: "4px 8px"
331
+ },
332
+ children: "\xD7"
333
+ }
334
+ )
335
+ ]
336
+ }
337
+ );
338
+ };
339
+ var DateControl_default = DateControl;
340
+
341
+ // src/fields/Slider.tsx
342
+ import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
343
+ var Slider = (props) => {
344
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, setFieldValue } = props;
345
+ const onChange = (event) => {
346
+ setFieldValue(fieldName, Number(event.target.value));
347
+ };
348
+ if (readOnly) {
349
+ return /* @__PURE__ */ jsx9(ReadOnlyText, { fieldName, value: String(value) });
350
+ }
351
+ return /* @__PURE__ */ jsxs5(
352
+ "div",
353
+ {
354
+ style: { display: "flex", alignItems: "center", gap: "12px" },
355
+ "data-field-type": "Slider",
356
+ "data-field-state": getFieldState({ error, required, readOnly }),
357
+ children: [
358
+ /* @__PURE__ */ jsx9(
359
+ "input",
360
+ {
361
+ type: "range",
362
+ style: {
363
+ flex: 1,
364
+ accentColor: "var(--chakra-colors-blue-500, #3182CE)"
365
+ },
366
+ value: value ?? 0,
367
+ onChange,
368
+ max: config?.max ?? 100,
369
+ min: config?.min ?? 0,
370
+ step: config?.step ?? 1,
371
+ "aria-invalid": !!error,
372
+ "aria-required": required,
373
+ "aria-valuenow": value ?? 0,
374
+ "aria-valuemin": config?.min ?? 0,
375
+ "aria-valuemax": config?.max ?? 100,
376
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
377
+ }
378
+ ),
379
+ /* @__PURE__ */ jsx9("output", { style: { minWidth: "32px", textAlign: "center", fontSize: "var(--chakra-fontSizes-md, 16px)" }, children: String(value) })
380
+ ]
381
+ }
382
+ );
383
+ };
384
+ var Slider_default = Slider;
385
+
386
+ // src/fields/RadioGroup.tsx
387
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
388
+ var RadioGroup = (props) => {
389
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options, setFieldValue } = props;
390
+ const onChange = (event) => {
391
+ setFieldValue(fieldName, event.target.value);
392
+ };
393
+ if (readOnly) {
394
+ const label = options?.find((o) => String(o.value) === String(value))?.label ?? value;
395
+ return /* @__PURE__ */ jsx10(ReadOnlyText, { fieldName, value: label });
396
+ }
397
+ return /* @__PURE__ */ jsx10(
398
+ "div",
399
+ {
400
+ role: "radiogroup",
401
+ style: { display: "flex", flexDirection: "column", gap: "8px" },
402
+ "aria-invalid": !!error,
403
+ "aria-required": required,
404
+ "data-field-type": "RadioGroup",
405
+ "data-field-state": getFieldState({ error, required, readOnly }),
406
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
407
+ children: options?.map((option) => /* @__PURE__ */ jsxs6(
408
+ "label",
409
+ {
410
+ style: {
411
+ display: "flex",
412
+ alignItems: "center",
413
+ gap: "8px",
414
+ cursor: option.disabled ? "not-allowed" : "pointer",
415
+ opacity: option.disabled ? 0.5 : 1,
416
+ fontSize: "var(--chakra-fontSizes-md, 16px)"
417
+ },
418
+ children: [
419
+ /* @__PURE__ */ jsx10(
420
+ "input",
421
+ {
422
+ type: "radio",
423
+ name: fieldName,
424
+ value: String(option.value),
425
+ checked: String(value) === String(option.value),
426
+ onChange,
427
+ disabled: option.disabled,
428
+ style: { accentColor: "var(--chakra-colors-blue-500, #3182CE)" }
429
+ }
430
+ ),
431
+ /* @__PURE__ */ jsx10("span", { children: option.label })
432
+ ]
433
+ },
434
+ String(option.value)
435
+ ))
436
+ }
437
+ );
438
+ };
439
+ var RadioGroup_default = RadioGroup;
440
+
441
+ // src/fields/CheckboxGroup.tsx
442
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
443
+ var CheckboxGroup = (props) => {
444
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options, setFieldValue } = props;
445
+ const selected = Array.isArray(value) ? value : [];
446
+ const onChange = (optionValue) => (event) => {
447
+ const next = event.target.checked ? [...selected, optionValue] : selected.filter((v) => v !== optionValue);
448
+ setFieldValue(fieldName, next);
449
+ };
450
+ if (readOnly) {
451
+ const labels = options?.filter((o) => selected.includes(String(o.value))).map((o) => o.label).join(", ");
452
+ return /* @__PURE__ */ jsx11(ReadOnlyText, { fieldName, value: labels ?? "" });
453
+ }
454
+ return /* @__PURE__ */ jsx11(
455
+ "div",
456
+ {
457
+ style: { display: "flex", flexDirection: "column", gap: "8px" },
458
+ "aria-invalid": !!error,
459
+ "aria-required": required,
460
+ "data-field-type": "CheckboxGroup",
461
+ "data-field-state": getFieldState({ error, required, readOnly }),
462
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
463
+ children: options?.map((option) => /* @__PURE__ */ jsxs7(
464
+ "label",
465
+ {
466
+ style: {
467
+ display: "flex",
468
+ alignItems: "center",
469
+ gap: "8px",
470
+ cursor: option.disabled ? "not-allowed" : "pointer",
471
+ opacity: option.disabled ? 0.5 : 1,
472
+ fontSize: "var(--chakra-fontSizes-md, 16px)"
473
+ },
474
+ children: [
475
+ /* @__PURE__ */ jsx11(
476
+ "input",
477
+ {
478
+ type: "checkbox",
479
+ value: String(option.value),
480
+ checked: selected.includes(String(option.value)),
481
+ onChange: onChange(String(option.value)),
482
+ disabled: option.disabled,
483
+ style: { accentColor: "var(--chakra-colors-blue-500, #3182CE)" }
484
+ }
485
+ ),
486
+ /* @__PURE__ */ jsx11("span", { children: option.label })
487
+ ]
488
+ },
489
+ String(option.value)
490
+ ))
491
+ }
492
+ );
493
+ };
494
+ var CheckboxGroup_default = CheckboxGroup;
495
+
496
+ // src/fields/Textarea.tsx
497
+ import { FormStrings as FormStrings3 } from "@form-eng/core";
498
+ import { Textarea as ChakraTextarea } from "@chakra-ui/react";
499
+ import React2, { useState } from "react";
500
+
501
+ // src/components/StatusMessage.tsx
502
+ import { FormStrings as FormStrings2 } from "@form-eng/core";
503
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
504
+ var StatusMessage = (props) => {
505
+ const { id, error, errorCount, savePending, saving } = props;
506
+ return /* @__PURE__ */ jsx12("div", { className: "fe-status-message", children: error ? /* @__PURE__ */ jsx12("span", { id, role: "alert", style: { color: "var(--chakra-colors-red-500, #E53E3E)" }, children: error.message || "Error" }) : savePending ? /* @__PURE__ */ jsxs8("span", { id, role: "alert", style: { color: "var(--chakra-colors-orange-500, #DD6B20)" }, children: [
507
+ FormStrings2.autoSavePending,
508
+ " (",
509
+ errorCount,
510
+ " ",
511
+ FormStrings2.remaining,
512
+ ")"
513
+ ] }) : saving ? /* @__PURE__ */ jsx12("span", { id, role: "status", style: { color: "var(--chakra-colors-gray-500, #718096)" }, children: FormStrings2.saving }) : null });
514
+ };
515
+
516
+ // src/fields/Textarea.tsx
517
+ import { Fragment, jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
518
+ var Textarea = (props) => {
519
+ const {
520
+ error,
521
+ fieldName,
522
+ programName,
523
+ entityType,
524
+ entityId,
525
+ config,
526
+ readOnly,
527
+ required,
528
+ savePending,
529
+ saving,
530
+ value,
531
+ label,
532
+ setFieldValue
533
+ } = props;
534
+ const [modalValue, setModalValue] = useState();
535
+ const [modalVisible, setModalVisible] = useState(false);
536
+ const [confirmVisible, setConfirmVisible] = useState(false);
537
+ const dialogRef = React2.useRef(null);
538
+ const confirmRef = React2.useRef(null);
539
+ const onChange = (event) => {
540
+ const newValue = event.target.value;
541
+ modalVisible ? setModalValue(newValue) : setFieldValue(fieldName, newValue, false, 3e3);
542
+ };
543
+ const onExpand = () => {
544
+ setModalVisible(true);
545
+ setModalValue(value ? `${value}` : "");
546
+ dialogRef.current?.showModal();
547
+ };
548
+ const onSave = () => {
549
+ setFieldValue(fieldName, modalValue, false);
550
+ setConfirmVisible(false);
551
+ setModalVisible(false);
552
+ dialogRef.current?.close();
553
+ confirmRef.current?.close();
554
+ config?.saveCallback?.();
555
+ };
556
+ const onCancel = () => {
557
+ if (confirmVisible) {
558
+ setConfirmVisible(false);
559
+ setModalVisible(false);
560
+ dialogRef.current?.close();
561
+ confirmRef.current?.close();
562
+ } else if (modalValue !== value) {
563
+ setConfirmVisible(true);
564
+ confirmRef.current?.showModal();
565
+ } else {
566
+ setModalVisible(false);
567
+ dialogRef.current?.close();
568
+ }
569
+ };
570
+ if (readOnly) {
571
+ return /* @__PURE__ */ jsx13(
572
+ ReadOnlyText,
573
+ {
574
+ fieldName,
575
+ value: value ? `${value}` : "",
576
+ ellipsifyTextCharacters: config?.ellipsifyTextCharacters
577
+ }
578
+ );
579
+ }
580
+ return /* @__PURE__ */ jsxs9(Fragment, { children: [
581
+ /* @__PURE__ */ jsxs9(
582
+ "div",
583
+ {
584
+ "data-field-type": "Textarea",
585
+ "data-field-state": getFieldState({ error, required, readOnly }),
586
+ children: [
587
+ /* @__PURE__ */ jsx13(
588
+ ChakraTextarea,
589
+ {
590
+ autoComplete: "off",
591
+ value: modalVisible ? `${modalValue}` : value ? `${value}` : "",
592
+ onChange,
593
+ rows: config?.numberOfRows ?? 4,
594
+ "aria-invalid": !!error,
595
+ "aria-required": required,
596
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
597
+ }
598
+ ),
599
+ /* @__PURE__ */ jsx13(
600
+ "button",
601
+ {
602
+ type: "button",
603
+ onClick: onExpand,
604
+ "aria-label": FormStrings3.openExpandedTextEditor,
605
+ style: {
606
+ marginTop: "4px",
607
+ background: "none",
608
+ border: "none",
609
+ cursor: "pointer",
610
+ color: "var(--chakra-colors-blue-500, #3182CE)",
611
+ fontSize: "var(--chakra-fontSizes-sm, 14px)",
612
+ padding: "2px 0"
613
+ },
614
+ children: FormStrings3.expand
615
+ }
616
+ )
617
+ ]
618
+ }
619
+ ),
620
+ /* @__PURE__ */ jsxs9("dialog", { ref: dialogRef, style: { padding: "24px", borderRadius: "8px", border: "1px solid var(--chakra-colors-gray-200, #E2E8F0)", maxWidth: "640px", width: "100%" }, "aria-label": `${label} editor`, children: [
621
+ /* @__PURE__ */ jsxs9("header", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "16px" }, children: [
622
+ /* @__PURE__ */ jsxs9("h2", { style: { margin: 0, fontSize: "18px" }, children: [
623
+ label,
624
+ required && /* @__PURE__ */ jsx13("span", { style: { color: "var(--chakra-colors-red-500, #E53E3E)" }, children: " *" })
625
+ ] }),
626
+ /* @__PURE__ */ jsx13(
627
+ "button",
628
+ {
629
+ type: "button",
630
+ onClick: onCancel,
631
+ "aria-label": FormStrings3.closeExpandedTextEditor,
632
+ style: { background: "none", border: "none", cursor: "pointer", fontSize: "20px" },
633
+ children: "\xD7"
634
+ }
635
+ )
636
+ ] }),
637
+ /* @__PURE__ */ jsx13("div", { style: { marginBottom: "16px" }, children: /* @__PURE__ */ jsx13(
638
+ ChakraTextarea,
639
+ {
640
+ autoComplete: "off",
641
+ value: modalVisible ? `${modalValue}` : value ? `${value}` : "",
642
+ onChange,
643
+ rows: 12,
644
+ "aria-invalid": !!error
645
+ }
646
+ ) }),
647
+ /* @__PURE__ */ jsxs9("footer", { style: { display: "flex", justifyContent: "flex-end", alignItems: "center", gap: "8px" }, children: [
648
+ config?.renderExtraModalFooter && /* @__PURE__ */ jsx13("div", { children: config.renderExtraModalFooter() }),
649
+ (savePending || saving) && /* @__PURE__ */ jsx13(StatusMessage, { savePending: !error ? savePending : void 0, saving, error }),
650
+ /* @__PURE__ */ jsx13(
651
+ "button",
652
+ {
653
+ type: "button",
654
+ onClick: onCancel,
655
+ style: { padding: "6px 16px", borderRadius: "6px", border: "1px solid var(--chakra-colors-gray-200, #E2E8F0)", background: "white", cursor: "pointer" },
656
+ children: FormStrings3.cancel
657
+ }
658
+ ),
659
+ /* @__PURE__ */ jsx13(
660
+ "button",
661
+ {
662
+ type: "button",
663
+ onClick: onSave,
664
+ disabled: !config?.saveCallback && modalValue === value,
665
+ style: { padding: "6px 16px", borderRadius: "6px", border: "none", background: "var(--chakra-colors-blue-500, #3182CE)", color: "white", cursor: "pointer" },
666
+ "data-testid": `${programName}-${entityType}-${entityId}-save-note`,
667
+ children: FormStrings3.save
668
+ }
669
+ )
670
+ ] })
671
+ ] }),
672
+ /* @__PURE__ */ jsxs9("dialog", { ref: confirmRef, style: { padding: "24px", borderRadius: "8px", border: "1px solid var(--chakra-colors-gray-200, #E2E8F0)" }, children: [
673
+ /* @__PURE__ */ jsx13("h2", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: FormStrings3.unsavedChanges }),
674
+ /* @__PURE__ */ jsx13("p", { children: FormStrings3.saveChangesTo(label) }),
675
+ /* @__PURE__ */ jsxs9("footer", { style: { display: "flex", justifyContent: "flex-end", gap: "8px", marginTop: "16px" }, children: [
676
+ /* @__PURE__ */ jsx13(
677
+ "button",
678
+ {
679
+ type: "button",
680
+ onClick: onCancel,
681
+ style: { padding: "6px 16px", borderRadius: "6px", border: "1px solid var(--chakra-colors-gray-200, #E2E8F0)", background: "white", cursor: "pointer" },
682
+ children: FormStrings3.dontSave
683
+ }
684
+ ),
685
+ /* @__PURE__ */ jsx13(
686
+ "button",
687
+ {
688
+ type: "button",
689
+ onClick: onSave,
690
+ style: { padding: "6px 16px", borderRadius: "6px", border: "none", background: "var(--chakra-colors-blue-500, #3182CE)", color: "white", cursor: "pointer" },
691
+ children: FormStrings3.save
692
+ }
693
+ )
694
+ ] })
695
+ ] })
696
+ ] });
697
+ };
698
+ var Textarea_default = Textarea;
699
+
700
+ // src/fields/DynamicFragment.tsx
701
+ import { jsx as jsx14 } from "react/jsx-runtime";
702
+ var DynamicFragment = (props) => {
703
+ const { value } = props;
704
+ return /* @__PURE__ */ jsx14("input", { type: "hidden", value });
705
+ };
706
+ var DynamicFragment_default = DynamicFragment;
707
+
708
+ // src/fields/readonly/ReadOnly.tsx
709
+ import { jsx as jsx15 } from "react/jsx-runtime";
710
+ var ReadOnly = (props) => {
711
+ const { fieldName, value, config } = props;
712
+ return /* @__PURE__ */ jsx15(ReadOnlyText, { fieldName, value, ...config });
713
+ };
714
+ var ReadOnly_default = ReadOnly;
715
+
716
+ // src/components/FormLoading.tsx
717
+ import { FormConstants } from "@form-eng/core";
718
+ import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
719
+ var FormLoading = (props) => {
720
+ const { loadingShimmerCount, loadingFieldShimmerHeight, inPanel, hideTitleShimmer } = props;
721
+ const count = loadingShimmerCount || FormConstants.loadingShimmerCount;
722
+ const height = loadingFieldShimmerHeight || FormConstants.loadingFieldShimmerHeight;
723
+ return /* @__PURE__ */ jsx16(
724
+ "div",
725
+ {
726
+ className: `fe-form-loading ${inPanel ? "fe-form-loading--panel" : ""}`,
727
+ role: "status",
728
+ "aria-label": "Loading form",
729
+ children: [...Array(count)].map((_, i) => /* @__PURE__ */ jsxs10("div", { style: { marginBottom: 16 }, children: [
730
+ !hideTitleShimmer && /* @__PURE__ */ jsx16("div", { className: "fe-skeleton", style: { width: "33%", height: 16, marginBottom: 8, background: "var(--chakra-colors-gray-200, #E2E8F0)", borderRadius: 4 } }),
731
+ /* @__PURE__ */ jsx16("div", { className: "fe-skeleton", style: { width: "100%", height, background: "var(--chakra-colors-gray-200, #E2E8F0)", borderRadius: 4 } })
732
+ ] }, `fe-loading-${i}`))
733
+ }
734
+ );
735
+ };
736
+
737
+ // src/registry.ts
738
+ import { ComponentTypes } from "@form-eng/core";
739
+ import React3 from "react";
740
+ function createChakraFieldRegistry() {
741
+ return {
742
+ [ComponentTypes.Textbox]: React3.createElement(Textbox_default),
743
+ [ComponentTypes.Number]: React3.createElement(Number_default),
744
+ [ComponentTypes.Toggle]: React3.createElement(Toggle_default),
745
+ [ComponentTypes.Dropdown]: React3.createElement(Dropdown_default),
746
+ [ComponentTypes.SimpleDropdown]: React3.createElement(SimpleDropdown_default),
747
+ [ComponentTypes.MultiSelect]: React3.createElement(MultiSelect_default),
748
+ [ComponentTypes.DateControl]: React3.createElement(DateControl_default),
749
+ [ComponentTypes.Slider]: React3.createElement(Slider_default),
750
+ [ComponentTypes.RadioGroup]: React3.createElement(RadioGroup_default),
751
+ [ComponentTypes.CheckboxGroup]: React3.createElement(CheckboxGroup_default),
752
+ [ComponentTypes.Textarea]: React3.createElement(Textarea_default),
753
+ [ComponentTypes.Fragment]: React3.createElement(DynamicFragment_default),
754
+ [ComponentTypes.ReadOnly]: React3.createElement(ReadOnly_default)
755
+ };
756
+ }
757
+ export {
758
+ CheckboxGroup_default as CheckboxGroup,
759
+ DateControl_default as DateControl,
760
+ DocumentLinksStrings,
761
+ Dropdown_default as Dropdown,
762
+ DynamicFragment_default as DynamicFragment,
763
+ FieldClassName,
764
+ FormLoading,
765
+ GetFieldDataTestId,
766
+ MultiSelect_default as MultiSelect,
767
+ Number_default as Number,
768
+ RadioGroup_default as RadioGroup,
769
+ ReadOnly_default as ReadOnly,
770
+ ReadOnlyText,
771
+ SimpleDropdown_default as SimpleDropdown,
772
+ Slider_default as Slider,
773
+ StatusMessage,
774
+ Textarea_default as Textarea,
775
+ Textbox_default as Textbox,
776
+ Toggle_default as Toggle,
777
+ createChakraFieldRegistry,
778
+ formatDateTime,
779
+ getFieldState
780
+ };
781
+ //# sourceMappingURL=index.mjs.map