@form-eng/mui 1.0.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 ADDED
@@ -0,0 +1,1036 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ DateControl: () => DateControl_default,
33
+ DocumentLinks: () => DocumentLinks_default,
34
+ DocumentLinksStrings: () => DocumentLinksStrings,
35
+ Dropdown: () => Dropdown_default,
36
+ DynamicFragment: () => DynamicFragment_default,
37
+ FieldClassName: () => FieldClassName,
38
+ FormLoading: () => FormLoading,
39
+ GetFieldDataTestId: () => GetFieldDataTestId,
40
+ MultiSelect: () => MultiSelect_default,
41
+ MultiSelectSearch: () => MultiSelectSearch_default,
42
+ Number: () => Number_default,
43
+ PopOutEditor: () => PopOutEditor_default,
44
+ ReadOnly: () => ReadOnly_default,
45
+ ReadOnlyArray: () => ReadOnlyArray_default,
46
+ ReadOnlyCumulativeNumber: () => ReadOnlyCumulativeNumber_default,
47
+ ReadOnlyDateTime: () => ReadOnlyDateTime_default,
48
+ ReadOnlyRichText: () => ReadOnlyRichText_default,
49
+ ReadOnlyText: () => ReadOnlyText,
50
+ ReadOnlyWithButton: () => ReadOnlyWithButton_default,
51
+ SimpleDropdown: () => SimpleDropdown_default,
52
+ Slider: () => Slider_default,
53
+ StatusDropdown: () => StatusDropdown_default,
54
+ StatusMessage: () => StatusMessage,
55
+ Textbox: () => Textbox_default,
56
+ Toggle: () => Toggle_default,
57
+ createMuiFieldRegistry: () => createMuiFieldRegistry,
58
+ formatDateTime: () => formatDateTime
59
+ });
60
+ module.exports = __toCommonJS(index_exports);
61
+
62
+ // src/fields/Textbox.tsx
63
+ var import_material2 = require("@mui/material");
64
+
65
+ // src/components/ReadOnlyText.tsx
66
+ var import_material = require("@mui/material");
67
+ var import_jsx_runtime = require("react/jsx-runtime");
68
+ var ReadOnlyText = (props) => {
69
+ const { value, fieldName, valueClassName, showControlOnSide, containerClassName, ellipsifyTextCharacters } = props;
70
+ const classNameValue = valueClassName === void 0 ? "read-only-field" : valueClassName;
71
+ const cutoff = (ellipsifyTextCharacters || 0) - 3;
72
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${showControlOnSide ? "flexBox" : ""} ${containerClassName ?? ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
73
+ import_material.Typography,
74
+ {
75
+ variant: "body2",
76
+ id: `${fieldName}-read-only`,
77
+ className: classNameValue,
78
+ title: value,
79
+ component: "span",
80
+ children: value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ellipsifyTextCharacters && value.length > ellipsifyTextCharacters ? `${value.substring(0, cutoff)}...` : value }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "-" })
81
+ }
82
+ ) });
83
+ };
84
+
85
+ // src/helpers.ts
86
+ var FieldClassName = (className, error) => {
87
+ return error ? `${className} error` : className;
88
+ };
89
+ var GetFieldDataTestId = (fieldName, programName, entityType, entityId) => {
90
+ return `${programName}-${entityType}-${entityId}-${fieldName}`;
91
+ };
92
+ function formatDateTime(dateStr, options) {
93
+ if (!dateStr) return "";
94
+ const date = new Date(dateStr);
95
+ if (isNaN(date.getTime())) return dateStr;
96
+ if (options?.hideTimestamp) {
97
+ return date.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
98
+ }
99
+ return date.toLocaleString(void 0, { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
100
+ }
101
+ var DocumentLinksStrings = {
102
+ link: "Link",
103
+ addLink: "Add Link",
104
+ addAnotherLink: "Add Another Link",
105
+ deleteLink: "Delete Link",
106
+ confirmDeleteLink: "Are you sure you want to delete",
107
+ delete: "Delete",
108
+ cancel: "Cancel",
109
+ saveChanges: "Save Changes",
110
+ save: "Save"
111
+ };
112
+
113
+ // src/fields/Textbox.tsx
114
+ var import_jsx_runtime2 = require("react/jsx-runtime");
115
+ var Textbox = (props) => {
116
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, placeholder, setFieldValue } = props;
117
+ const onChange = (event) => {
118
+ setFieldValue(fieldName, event.target.value, false, 3e3);
119
+ };
120
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
121
+ ReadOnlyText,
122
+ {
123
+ fieldName,
124
+ value,
125
+ ellipsifyTextCharacters: config?.ellipsifyTextCharacters
126
+ }
127
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
128
+ import_material2.TextField,
129
+ {
130
+ className: FieldClassName("hook-textbox", error),
131
+ autoComplete: "off",
132
+ value: value ?? "",
133
+ onChange,
134
+ size: "small",
135
+ fullWidth: true,
136
+ error: !!error,
137
+ required,
138
+ placeholder: placeholder ?? config?.placeHolder,
139
+ helperText: error?.message,
140
+ inputProps: {
141
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
142
+ }
143
+ }
144
+ );
145
+ };
146
+ var Textbox_default = Textbox;
147
+
148
+ // src/fields/Number.tsx
149
+ var import_core = require("@form-eng/core");
150
+ var import_material3 = require("@mui/material");
151
+ var import_jsx_runtime3 = require("react/jsx-runtime");
152
+ var NumberField = (props) => {
153
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, setFieldValue } = props;
154
+ const onChange = (event) => {
155
+ const number = Number(event.target.value);
156
+ if (!isNaN(number)) {
157
+ setFieldValue(fieldName, number, false, 1500);
158
+ }
159
+ };
160
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ReadOnlyText, { fieldName, value: String(value) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
161
+ import_material3.TextField,
162
+ {
163
+ className: FieldClassName("hook-number", error),
164
+ autoComplete: "off",
165
+ type: "number",
166
+ value: !(0, import_core.isNull)(value) ? String(value) : "",
167
+ onChange,
168
+ size: "small",
169
+ fullWidth: true,
170
+ error: !!error,
171
+ required,
172
+ helperText: error?.message,
173
+ inputProps: {
174
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
175
+ }
176
+ }
177
+ );
178
+ };
179
+ var Number_default = NumberField;
180
+
181
+ // src/fields/Toggle.tsx
182
+ var import_core2 = require("@form-eng/core");
183
+ var import_material4 = require("@mui/material");
184
+ var import_jsx_runtime4 = require("react/jsx-runtime");
185
+ var Toggle = (props) => {
186
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, setFieldValue } = props;
187
+ const onChange = (_, checked) => {
188
+ setFieldValue(fieldName, checked);
189
+ };
190
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ReadOnlyText, { fieldName, value: (0, import_core2.convertBooleanToYesOrNoText)(value) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
191
+ import_material4.FormControlLabel,
192
+ {
193
+ className: "hook-toggle",
194
+ control: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
195
+ import_material4.Switch,
196
+ {
197
+ checked: value,
198
+ onChange,
199
+ "aria-invalid": !!error,
200
+ "aria-required": required,
201
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
202
+ }
203
+ ),
204
+ label: ""
205
+ }
206
+ );
207
+ };
208
+ var Toggle_default = Toggle;
209
+
210
+ // src/fields/Dropdown.tsx
211
+ var import_material5 = require("@mui/material");
212
+ var import_react = __toESM(require("react"));
213
+ var import_jsx_runtime5 = require("react/jsx-runtime");
214
+ var Dropdown = (props) => {
215
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, placeholder, options, setFieldValue } = props;
216
+ const onChange = (event) => {
217
+ setFieldValue(fieldName, event.target.value);
218
+ };
219
+ import_react.default.useEffect(() => {
220
+ if (!value && !readOnly && config?.setDefaultKeyIfOnlyOneOption && options?.length === 1) {
221
+ setFieldValue(fieldName, String(options[0].value));
222
+ }
223
+ }, [options]);
224
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReadOnlyText, { fieldName, value }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.FormControl, { fullWidth: true, size: "small", error: !!error, required, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
225
+ import_material5.Select,
226
+ {
227
+ className: FieldClassName("hook-dropdown", error),
228
+ value: value ? String(value) : "",
229
+ onChange,
230
+ displayEmpty: true,
231
+ "aria-required": required,
232
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
233
+ children: [
234
+ !value && (placeholder ?? config?.placeHolder) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.MenuItem, { value: "", disabled: true, children: placeholder ?? config?.placeHolder }),
235
+ options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.MenuItem, { value: String(option.value), disabled: option.disabled, children: option.label }, String(option.value)))
236
+ ]
237
+ }
238
+ ) });
239
+ };
240
+ var Dropdown_default = Dropdown;
241
+
242
+ // src/fields/MultiSelect.tsx
243
+ var import_material6 = require("@mui/material");
244
+ var import_react_hook_form = require("react-hook-form");
245
+ var import_jsx_runtime6 = require("react/jsx-runtime");
246
+ var MultiSelect = (props) => {
247
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options, setFieldValue } = props;
248
+ const { watch } = (0, import_react_hook_form.useFormContext)();
249
+ const selectedOptions = watch(`${fieldName}`) ?? [];
250
+ const onChange = (event) => {
251
+ const newValue = event.target.value;
252
+ setFieldValue(fieldName, typeof newValue === "string" ? newValue.split(",") : newValue, false, 1500);
253
+ };
254
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: value && value.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.Box, { className: "hook-multi-select-read-only", sx: { display: "flex", flexWrap: "wrap", gap: 0.5 }, children: value.map((v) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.Chip, { label: v, size: "small" }, v)) }) : null }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.FormControl, { fullWidth: true, size: "small", error: !!error, required, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
255
+ import_material6.Select,
256
+ {
257
+ className: FieldClassName("hook-multi-select", error),
258
+ multiple: true,
259
+ value: selectedOptions,
260
+ onChange,
261
+ "aria-invalid": !!error,
262
+ "aria-required": required,
263
+ renderValue: (selected) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5 }, children: selected.map((val) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.Chip, { label: val, size: "small" }, val)) }),
264
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
265
+ children: options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.MenuItem, { 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
+ var import_core3 = require("@form-eng/core");
273
+ var import_material7 = require("@mui/material");
274
+ var import_jsx_runtime7 = require("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 onClearDate = () => {
284
+ setFieldValue(fieldName, null);
285
+ };
286
+ const dateInputValue = value ? new Date(value).toISOString().split("T")[0] : "";
287
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: value ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hook-read-only-date", children: formatDateTime(value, { hideTimestamp: true }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: "-" }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hook-date-control-container", style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
288
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
289
+ import_material7.TextField,
290
+ {
291
+ className: FieldClassName("hook-date-control", error),
292
+ type: "date",
293
+ value: dateInputValue,
294
+ onChange,
295
+ size: "small",
296
+ fullWidth: true,
297
+ error: !!error,
298
+ required,
299
+ helperText: error?.message,
300
+ InputLabelProps: { shrink: true },
301
+ inputProps: {
302
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
303
+ }
304
+ }
305
+ ),
306
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
307
+ import_material7.IconButton,
308
+ {
309
+ size: "small",
310
+ onClick: onClearDate,
311
+ title: import_core3.FormStrings.clickToClear,
312
+ "aria-label": `${fieldName} ${import_core3.FormStrings.clear}`,
313
+ children: "\u2715"
314
+ }
315
+ )
316
+ ] });
317
+ };
318
+ var DateControl_default = DateControl;
319
+
320
+ // src/fields/Slider.tsx
321
+ var import_material8 = require("@mui/material");
322
+ var import_jsx_runtime8 = require("react/jsx-runtime");
323
+ var Slider = (props) => {
324
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, setFieldValue } = props;
325
+ const onChange = (_, newValue) => {
326
+ setFieldValue(fieldName, newValue);
327
+ };
328
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ReadOnlyText, { fieldName, value: String(value) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
329
+ import_material8.Slider,
330
+ {
331
+ className: FieldClassName("hook-slider", error),
332
+ value: value ?? 0,
333
+ onChange,
334
+ max: config?.max,
335
+ min: config?.min,
336
+ step: config?.step,
337
+ valueLabelDisplay: "auto",
338
+ "aria-invalid": !!error,
339
+ "aria-required": required,
340
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
341
+ }
342
+ );
343
+ };
344
+ var Slider_default = Slider;
345
+
346
+ // src/fields/DynamicFragment.tsx
347
+ var import_jsx_runtime9 = require("react/jsx-runtime");
348
+ var DynamicFragment = (props) => {
349
+ const { value } = props;
350
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { type: "hidden", value });
351
+ };
352
+ var DynamicFragment_default = DynamicFragment;
353
+
354
+ // src/fields/SimpleDropdown.tsx
355
+ var import_material9 = require("@mui/material");
356
+ var import_jsx_runtime10 = require("react/jsx-runtime");
357
+ var SimpleDropdown = (props) => {
358
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, placeholder, setFieldValue } = props;
359
+ const simpleOptions = config?.dropdownOptions ?? [];
360
+ const onChange = (event) => {
361
+ setFieldValue(fieldName, event.target.value);
362
+ };
363
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ReadOnlyText, { fieldName, value }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material9.FormControl, { fullWidth: true, size: "small", error: !!error, required, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
364
+ import_material9.Select,
365
+ {
366
+ className: FieldClassName("hook-dropdown", error),
367
+ value: value ?? "",
368
+ onChange,
369
+ displayEmpty: true,
370
+ "aria-required": required,
371
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
372
+ children: [
373
+ !value && (placeholder ?? config?.placeHolder) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material9.MenuItem, { value: "", disabled: true, children: placeholder ?? config?.placeHolder }),
374
+ simpleOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material9.MenuItem, { value: option, children: option }, option))
375
+ ]
376
+ }
377
+ ) });
378
+ };
379
+ var SimpleDropdown_default = SimpleDropdown;
380
+
381
+ // src/fields/MultiSelectSearch.tsx
382
+ var import_material10 = require("@mui/material");
383
+ var import_jsx_runtime11 = require("react/jsx-runtime");
384
+ var import_react2 = require("react");
385
+ var MultiSelectSearch = (props) => {
386
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options: dropdownOptions, setFieldValue } = props;
387
+ const selectedValues = value ?? [];
388
+ const mappedOptions = dropdownOptions?.map((o) => ({
389
+ value: String(o.value),
390
+ label: o.label,
391
+ disabled: !!o.disabled
392
+ })) ?? [];
393
+ const onChange = (_, newValue) => {
394
+ setFieldValue(fieldName, newValue.map((v) => v.value), false, 3e3);
395
+ };
396
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: value && value.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material10.Box, { className: "hook-multi-select-search-read-only", sx: { display: "flex", flexWrap: "wrap", gap: 0.5 }, children: value.map((v) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material10.Chip, { label: v, size: "small" }, v)) }) : null }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
397
+ import_material10.Autocomplete,
398
+ {
399
+ className: FieldClassName("hook-multi-select-search", error),
400
+ multiple: true,
401
+ freeSolo: true,
402
+ "aria-required": required,
403
+ options: mappedOptions,
404
+ getOptionLabel: (option) => typeof option === "string" ? option : option.label,
405
+ getOptionDisabled: (option) => typeof option === "string" ? false : !!option.disabled,
406
+ value: mappedOptions.filter((o) => selectedValues.includes(o.value)),
407
+ onChange,
408
+ renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ (0, import_react2.createElement)(
409
+ import_material10.Chip,
410
+ {
411
+ size: "small",
412
+ label: typeof option === "string" ? option : option.label,
413
+ ...getTagProps({ index }),
414
+ key: typeof option === "string" ? option : option.value
415
+ }
416
+ )),
417
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
418
+ import_material10.TextField,
419
+ {
420
+ ...params,
421
+ size: "small",
422
+ error: !!error,
423
+ required,
424
+ helperText: error?.message,
425
+ inputProps: {
426
+ ...params.inputProps,
427
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
428
+ }
429
+ }
430
+ )
431
+ }
432
+ );
433
+ };
434
+ var MultiSelectSearch_default = MultiSelectSearch;
435
+
436
+ // src/fields/PopOutEditor.tsx
437
+ var import_core5 = require("@form-eng/core");
438
+ var import_material12 = require("@mui/material");
439
+ var import_react3 = require("react");
440
+
441
+ // src/components/StatusMessage.tsx
442
+ var import_core4 = require("@form-eng/core");
443
+ var import_material11 = require("@mui/material");
444
+ var import_jsx_runtime12 = require("react/jsx-runtime");
445
+ var StatusMessage = (props) => {
446
+ const { id, error, errorCount, savePending, saving } = props;
447
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "message", children: error ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
448
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "error-icon", style: { color: "#d32f2f", fontSize: "16px" }, children: "\u26A0" }),
449
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "error-message", id, role: "alert", children: error.message || "Error" })
450
+ ] }) : savePending ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
451
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "warning-icon", style: { color: "#ed6c02", fontSize: "16px" }, children: "\u26A0" }),
452
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "warning-message", id, role: "alert", children: [
453
+ import_core4.FormStrings.autoSavePending,
454
+ " (",
455
+ errorCount,
456
+ " ",
457
+ import_core4.FormStrings.remaining,
458
+ ")"
459
+ ] })
460
+ ] }) : saving ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
461
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material11.CircularProgress, { size: 16 }),
462
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "save-message", id, role: "alert", children: import_core4.FormStrings.saving })
463
+ ] }) : null });
464
+ };
465
+
466
+ // src/fields/PopOutEditor.tsx
467
+ var import_jsx_runtime13 = require("react/jsx-runtime");
468
+ var PopOutEditor = (props) => {
469
+ const {
470
+ error,
471
+ fieldName,
472
+ programName,
473
+ entityType,
474
+ entityId,
475
+ config,
476
+ readOnly,
477
+ required,
478
+ savePending,
479
+ saving,
480
+ value,
481
+ label,
482
+ setFieldValue
483
+ } = props;
484
+ const [modalValue, setModalValue] = (0, import_react3.useState)();
485
+ const [modalVisible, setModalVisible] = (0, import_react3.useState)(false);
486
+ const [dialogVisible, setDialogVisible] = (0, import_react3.useState)(false);
487
+ const onChange = (event) => {
488
+ const newValue = event.target.value;
489
+ modalVisible ? setModalValue(newValue) : setFieldValue(fieldName, newValue, false, 3e3);
490
+ };
491
+ const onExpandButtonClick = () => {
492
+ setModalVisible(true);
493
+ setModalValue(value ? `${value}` : "");
494
+ };
495
+ const onSaveButtonClick = () => {
496
+ setFieldValue(fieldName, modalValue, false);
497
+ setDialogVisible(false);
498
+ setModalVisible(false);
499
+ config?.saveCallback?.();
500
+ };
501
+ const onCancelButtonClick = () => {
502
+ if (dialogVisible) {
503
+ setDialogVisible(false);
504
+ setModalVisible(false);
505
+ } else if (modalValue !== value) {
506
+ setDialogVisible(true);
507
+ } else {
508
+ setModalVisible(false);
509
+ }
510
+ };
511
+ if (readOnly) {
512
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
513
+ ReadOnlyText,
514
+ {
515
+ fieldName,
516
+ value: value ? `${value}` : "",
517
+ ellipsifyTextCharacters: config?.ellipsifyTextCharacters
518
+ }
519
+ );
520
+ }
521
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
522
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "hook-textarea", children: [
523
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
524
+ import_material12.TextField,
525
+ {
526
+ className: FieldClassName("hook-text-area", error),
527
+ autoComplete: "off",
528
+ multiline: true,
529
+ rows: config?.numberOfRows ?? 4,
530
+ value: modalVisible ? `${modalValue}` : value ? `${value}` : "",
531
+ onChange,
532
+ size: "small",
533
+ fullWidth: true,
534
+ error: !!error,
535
+ helperText: error?.message,
536
+ inputProps: {
537
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId)
538
+ }
539
+ }
540
+ ),
541
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
542
+ import_material12.Button,
543
+ {
544
+ className: "expand-button",
545
+ variant: "outlined",
546
+ size: "small",
547
+ onClick: onExpandButtonClick,
548
+ "aria-label": import_core5.FormStrings.openExpandedTextEditor,
549
+ sx: { mt: 1 },
550
+ children: import_core5.FormStrings.expand
551
+ }
552
+ )
553
+ ] }),
554
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
555
+ import_material12.Dialog,
556
+ {
557
+ open: modalVisible,
558
+ onClose: onCancelButtonClick,
559
+ maxWidth: "md",
560
+ fullWidth: true,
561
+ children: [
562
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_material12.DialogTitle, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
563
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
564
+ label,
565
+ required && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "required-indicator", children: " *" })
566
+ ] }),
567
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
568
+ import_material12.IconButton,
569
+ {
570
+ size: "small",
571
+ onClick: onCancelButtonClick,
572
+ "aria-label": import_core5.FormStrings.closeExpandedTextEditor,
573
+ children: "\u2715"
574
+ }
575
+ )
576
+ ] }),
577
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
578
+ import_material12.TextField,
579
+ {
580
+ className: FieldClassName("hook-text-area", error),
581
+ autoComplete: "off",
582
+ multiline: true,
583
+ rows: 12,
584
+ value: modalVisible ? `${modalValue}` : value ? `${value}` : "",
585
+ onChange,
586
+ fullWidth: true,
587
+ error: !!error,
588
+ sx: { mt: 1 }
589
+ }
590
+ ) }),
591
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_material12.DialogActions, { children: [
592
+ config?.renderExtraModalFooter && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "custom-footer", children: config.renderExtraModalFooter() }),
593
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: (savePending || saving) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StatusMessage, { savePending: !error ? savePending : void 0, saving, error }) }),
594
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.Button, { variant: "outlined", onClick: onCancelButtonClick, children: import_core5.FormStrings.cancel }),
595
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
596
+ import_material12.Button,
597
+ {
598
+ variant: "contained",
599
+ onClick: onSaveButtonClick,
600
+ disabled: !config?.saveCallback && modalValue === value,
601
+ "data-testid": `${programName}-${entityType}-${entityId}-save-note`,
602
+ children: import_core5.FormStrings.save
603
+ }
604
+ )
605
+ ] })
606
+ ]
607
+ }
608
+ ),
609
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_material12.Dialog, { open: dialogVisible, onClose: () => setDialogVisible(false), children: [
610
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.DialogTitle, { children: import_core5.FormStrings.unsavedChanges }),
611
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.DialogContent, { children: import_core5.FormStrings.saveChangesTo(label) }),
612
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_material12.DialogActions, { children: [
613
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.Button, { variant: "outlined", onClick: onCancelButtonClick, children: import_core5.FormStrings.dontSave }),
614
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.Button, { variant: "contained", onClick: onSaveButtonClick, children: import_core5.FormStrings.save })
615
+ ] })
616
+ ] })
617
+ ] });
618
+ };
619
+ var PopOutEditor_default = PopOutEditor;
620
+
621
+ // src/fields/DocumentLinks.tsx
622
+ var import_core6 = require("@form-eng/core");
623
+ var import_material13 = require("@mui/material");
624
+ var import_react4 = __toESM(require("react"));
625
+ var import_react_hook_form2 = require("react-hook-form");
626
+ var import_jsx_runtime14 = require("react/jsx-runtime");
627
+ var DocumentLinkItem = (props) => {
628
+ const {
629
+ fieldName,
630
+ programName,
631
+ entityType,
632
+ entityId,
633
+ readOnly,
634
+ index,
635
+ title,
636
+ url,
637
+ addNewLink,
638
+ saveLinks,
639
+ onCancelAddLink,
640
+ onConfirmDeleteLink
641
+ } = props;
642
+ const { confirm, cancel, linkTitleLabel, linkUrlLabel, add, edit, deleteLabel } = import_core6.FormStrings;
643
+ const [editingLink, setEditingLink] = import_react4.default.useState(false);
644
+ const { control, handleSubmit, setValue, reset, trigger } = (0, import_react_hook_form2.useForm)({
645
+ mode: "onChange",
646
+ defaultValues: { title: addNewLink ? "" : title, url: addNewLink ? "" : url }
647
+ });
648
+ const onSubmit = (data) => {
649
+ saveLinks({ title: data.title, url: data.url }, addNewLink, index);
650
+ setEditingLink(false);
651
+ };
652
+ import_react4.default.useEffect(() => {
653
+ setEditingLink(addNewLink);
654
+ }, [title, url, addNewLink]);
655
+ const onLinkTitleChange = (e) => {
656
+ setValue("title", e.target.value);
657
+ trigger("title");
658
+ };
659
+ const onLinkUrlChange = (e) => {
660
+ setValue("url", e.target.value);
661
+ trigger("url");
662
+ };
663
+ const onEditDocumentLink = () => setEditingLink(true);
664
+ const onCancelFormChanges = () => {
665
+ reset();
666
+ setEditingLink(false);
667
+ onCancelAddLink?.();
668
+ };
669
+ const onDelete = () => onConfirmDeleteLink(index);
670
+ return editingLink ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "editing-link", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { onSubmit: handleSubmit(onSubmit), children: [
671
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "header", style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "8px" }, children: [
672
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material13.Typography, { variant: "subtitle2", children: [
673
+ addNewLink ? add : edit,
674
+ " ",
675
+ DocumentLinksStrings.link
676
+ ] }),
677
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", gap: "4px" }, children: [
678
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.IconButton, { size: "small", "aria-label": confirm, onClick: handleSubmit(onSubmit), children: "\u2713" }),
679
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.IconButton, { size: "small", "aria-label": cancel, onClick: onCancelFormChanges, children: "\u2715" })
680
+ ] })
681
+ ] }),
682
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
683
+ import_react_hook_form2.Controller,
684
+ {
685
+ name: "title",
686
+ control,
687
+ rules: { required: { value: true, message: import_core6.FormStrings.required } },
688
+ render: ({ field, fieldState: { error } }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
689
+ import_material13.TextField,
690
+ {
691
+ label: linkTitleLabel,
692
+ value: field.value,
693
+ onChange: onLinkTitleChange,
694
+ required: true,
695
+ size: "small",
696
+ fullWidth: true,
697
+ error: !!error,
698
+ helperText: error?.message,
699
+ inputProps: {
700
+ "data-testid": `${GetFieldDataTestId(fieldName, programName, entityType, entityId)}-link-title`
701
+ }
702
+ }
703
+ ) })
704
+ }
705
+ ),
706
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
707
+ import_react_hook_form2.Controller,
708
+ {
709
+ name: "url",
710
+ control,
711
+ rules: {
712
+ required: { value: true, message: import_core6.FormStrings.required },
713
+ pattern: { value: import_core6.FormConstants.urlRegex, message: import_core6.FormStrings.urlRequired }
714
+ },
715
+ render: ({ field, fieldState: { error } }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
716
+ import_material13.TextField,
717
+ {
718
+ label: linkUrlLabel,
719
+ value: field.value,
720
+ onChange: onLinkUrlChange,
721
+ required: true,
722
+ size: "small",
723
+ fullWidth: true,
724
+ error: !!error,
725
+ helperText: error?.message,
726
+ inputProps: {
727
+ "data-testid": `${GetFieldDataTestId(fieldName, programName, entityType, entityId)}-link-url`
728
+ }
729
+ }
730
+ ) })
731
+ }
732
+ )
733
+ ] }) }) : addNewLink ? null : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
734
+ import_material13.ListItem,
735
+ {
736
+ className: "document-link-item",
737
+ disableGutters: true,
738
+ secondaryAction: !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", gap: "2px" }, children: [
739
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Tooltip, { title: edit, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.IconButton, { size: "small", "aria-label": edit, onClick: onEditDocumentLink, children: "\u270E" }) }),
740
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Tooltip, { title: deleteLabel, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.IconButton, { size: "small", "aria-label": deleteLabel, onClick: onDelete, children: "\u{1F5D1}" }) })
741
+ ] }) : void 0,
742
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
743
+ import_material13.ListItemText,
744
+ {
745
+ primary: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("a", { className: "link", href: url, target: "_blank", rel: "noopener noreferrer", children: title })
746
+ }
747
+ )
748
+ }
749
+ );
750
+ };
751
+ var DocumentLinks = (props) => {
752
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, setFieldValue } = props;
753
+ const { watch } = (0, import_react_hook_form2.useFormContext)();
754
+ const documentLinks = watch(`${fieldName}`);
755
+ const [addNewLink, setAddNewLink] = import_react4.default.useState(false);
756
+ const [deleteLinkIndex, setDeleteLinkIndex] = import_react4.default.useState(void 0);
757
+ const onUpdateLinks = (newLink, addNew, index) => {
758
+ let newDocumentLinks = [];
759
+ if (addNew && !documentLinks) {
760
+ newDocumentLinks = [newLink];
761
+ } else if (addNew) {
762
+ newDocumentLinks = [...documentLinks, newLink];
763
+ } else {
764
+ newDocumentLinks = [...documentLinks];
765
+ newDocumentLinks[index] = newLink;
766
+ }
767
+ setFieldValue(fieldName, newDocumentLinks);
768
+ };
769
+ const onDeleteLink = (index) => {
770
+ const newDocumentLinks = [...documentLinks];
771
+ newDocumentLinks.splice(index, 1);
772
+ setFieldValue(fieldName, newDocumentLinks);
773
+ };
774
+ const onAddNewLink = () => setAddNewLink(true);
775
+ const onCancelAddLink = () => setAddNewLink(false);
776
+ const onConfirmDeleteLink = (index) => setDeleteLinkIndex(index);
777
+ const onCloseDeleteDialog = () => setDeleteLinkIndex(void 0);
778
+ const commitDeleteLink = () => {
779
+ onDeleteLink(deleteLinkIndex);
780
+ setDeleteLinkIndex(void 0);
781
+ };
782
+ const saveLinks = (newLink, addNew, index) => {
783
+ onUpdateLinks(newLink, addNew, index);
784
+ setAddNewLink(false);
785
+ };
786
+ const links = value;
787
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: FieldClassName("hook-document-links", readOnly ? void 0 : error), children: [
788
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.List, { disablePadding: true, children: links?.length > 0 ? links.map((link, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
789
+ DocumentLinkItem,
790
+ {
791
+ fieldName,
792
+ programName,
793
+ entityType,
794
+ entityId,
795
+ index,
796
+ title: link.title,
797
+ url: link.url,
798
+ saveLinks,
799
+ onConfirmDeleteLink,
800
+ readOnly
801
+ },
802
+ `${link.url}-${index}`
803
+ )) : null }),
804
+ addNewLink ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
805
+ DocumentLinkItem,
806
+ {
807
+ fieldName,
808
+ programName,
809
+ entityType,
810
+ entityId,
811
+ addNewLink: true,
812
+ saveLinks,
813
+ onCancelAddLink
814
+ }
815
+ ) : !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "add-link", style: { marginTop: "8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Tooltip, { title: DocumentLinksStrings.addAnotherLink, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
816
+ import_material13.Button,
817
+ {
818
+ variant: "outlined",
819
+ size: "small",
820
+ onClick: onAddNewLink,
821
+ "data-testid": `${GetFieldDataTestId(fieldName, programName, entityType, entityId)}-add-link`,
822
+ children: links?.length > 0 ? DocumentLinksStrings.addAnotherLink : DocumentLinksStrings.addLink
823
+ }
824
+ ) }) }) : null,
825
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material13.Dialog, { open: deleteLinkIndex !== void 0, onClose: onCloseDeleteDialog, children: [
826
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.DialogTitle, { children: DocumentLinksStrings.deleteLink }),
827
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.DialogContent, { children: `${DocumentLinksStrings.confirmDeleteLink} ${links?.[deleteLinkIndex]?.title || ""}?` }),
828
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material13.DialogActions, { children: [
829
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Button, { variant: "outlined", onClick: onCloseDeleteDialog, children: DocumentLinksStrings.cancel }),
830
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Button, { variant: "contained", onClick: commitDeleteLink, children: DocumentLinksStrings.delete })
831
+ ] })
832
+ ] })
833
+ ] });
834
+ };
835
+ var DocumentLinks_default = DocumentLinks;
836
+
837
+ // src/fields/StatusDropdown.tsx
838
+ var import_material14 = require("@mui/material");
839
+ var import_jsx_runtime15 = require("react/jsx-runtime");
840
+ var StatusDot = ({ color }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
841
+ "span",
842
+ {
843
+ className: "status-color",
844
+ style: {
845
+ display: "inline-block",
846
+ backgroundColor: color || "transparent",
847
+ width: "12px",
848
+ height: "12px",
849
+ borderRadius: "50%",
850
+ flexShrink: 0,
851
+ marginRight: "8px"
852
+ }
853
+ }
854
+ );
855
+ var StatusDropdown = (props) => {
856
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, config, options, setFieldValue } = props;
857
+ const statusColors = config?.statusColors ?? {};
858
+ const onChange = (event) => {
859
+ setFieldValue(fieldName, event.target.value);
860
+ };
861
+ return readOnly ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "hook-read-only-status-dropdown", style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
862
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StatusDot, { color: statusColors && value ? statusColors[value] : void 0 }),
863
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ReadOnlyText, { fieldName, value })
864
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: FieldClassName("hook-status-dropdown", error), style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
865
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StatusDot, { color: statusColors && value ? statusColors[value] : void 0 }),
866
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material14.FormControl, { fullWidth: true, size: "small", error: !!error, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
867
+ import_material14.Select,
868
+ {
869
+ value: value ? String(value) : "",
870
+ onChange,
871
+ displayEmpty: true,
872
+ "data-testid": GetFieldDataTestId(fieldName, programName, entityType, entityId),
873
+ renderValue: (selected) => {
874
+ const option = options?.find((o) => String(o.value) === selected);
875
+ return option?.label ?? "";
876
+ },
877
+ children: options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_material14.MenuItem, { value: String(option.value), disabled: option.disabled, children: [
878
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StatusDot, { color: statusColors[String(option.value)] }),
879
+ option.label
880
+ ] }, String(option.value)))
881
+ }
882
+ ) })
883
+ ] });
884
+ };
885
+ var StatusDropdown_default = StatusDropdown;
886
+
887
+ // src/fields/readonly/ReadOnly.tsx
888
+ var import_jsx_runtime16 = require("react/jsx-runtime");
889
+ var ReadOnly = (props) => {
890
+ const { fieldName, value, config } = props;
891
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ReadOnlyText, { fieldName, value, ...config });
892
+ };
893
+ var ReadOnly_default = ReadOnly;
894
+
895
+ // src/fields/readonly/ReadOnlyArray.tsx
896
+ var import_jsx_runtime17 = require("react/jsx-runtime");
897
+ var ReadOnlyArray = (props) => {
898
+ const { fieldName, value, config } = props;
899
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: value?.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ReadOnlyText, { fieldName, value: v, ...config }, i)) });
900
+ };
901
+ var ReadOnlyArray_default = ReadOnlyArray;
902
+
903
+ // src/fields/readonly/ReadOnlyDateTime.tsx
904
+ var import_material15 = require("@mui/material");
905
+ var import_jsx_runtime18 = require("react/jsx-runtime");
906
+ var ReadOnlyDateTime = (props) => {
907
+ const { config, value } = props;
908
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: value ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material15.Typography, { variant: "body2", className: "hook-read-only-date-time", component: "span", children: formatDateTime(value, { hideTimestamp: config?.hidetimeStamp }) }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: "-" }) });
909
+ };
910
+ var ReadOnlyDateTime_default = ReadOnlyDateTime;
911
+
912
+ // src/fields/readonly/ReadOnlyCumulativeNumber.tsx
913
+ var import_core7 = require("@form-eng/core");
914
+ var import_react5 = __toESM(require("react"));
915
+ var import_react_hook_form3 = require("react-hook-form");
916
+ var import_jsx_runtime19 = require("react/jsx-runtime");
917
+ var ReadOnlyCumulativeNumber = (props) => {
918
+ const { fieldName, config } = props;
919
+ const { formState, getValues } = (0, import_react_hook_form3.useFormContext)();
920
+ const [value, setValue] = import_react5.default.useState();
921
+ const { dependencyFields } = config || {};
922
+ import_react5.default.useEffect(() => {
923
+ const formValues = getValues();
924
+ if (!(0, import_core7.isEmpty)(dependencyFields)) {
925
+ let totalCount = 0;
926
+ dependencyFields.map((fn) => {
927
+ totalCount += Number(formValues[fn]) || 0;
928
+ });
929
+ setValue(totalCount);
930
+ }
931
+ }, [formState]);
932
+ return fieldName ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ReadOnlyText, { fieldName, value: String(value), ...config }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {});
933
+ };
934
+ var ReadOnlyCumulativeNumber_default = ReadOnlyCumulativeNumber;
935
+
936
+ // src/fields/readonly/ReadOnlyRichText.tsx
937
+ var import_jsx_runtime20 = require("react/jsx-runtime");
938
+ var ReadOnlyRichText = (props) => {
939
+ const { value } = props;
940
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
941
+ "div",
942
+ {
943
+ className: "hook-read-only-rich-text-editor",
944
+ dangerouslySetInnerHTML: { __html: value || "" }
945
+ }
946
+ );
947
+ };
948
+ var ReadOnlyRichText_default = ReadOnlyRichText;
949
+
950
+ // src/fields/readonly/ReadOnlyWithButton.tsx
951
+ var import_material16 = require("@mui/material");
952
+ var import_jsx_runtime21 = require("react/jsx-runtime");
953
+ var ReadOnlyWithButton = (props) => {
954
+ const { fieldName, value, config } = props;
955
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, className: config?.containerClassName, children: [
956
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ReadOnlyText, { fieldName, value: `${value}` }),
957
+ config?.buttonText && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_material16.Button, { variant: "outlined", size: "small", onClick: config.onButtonClick, children: config.buttonText })
958
+ ] });
959
+ };
960
+ var ReadOnlyWithButton_default = ReadOnlyWithButton;
961
+
962
+ // src/components/FormLoading.tsx
963
+ var import_core8 = require("@form-eng/core");
964
+ var import_material17 = require("@mui/material");
965
+ var import_jsx_runtime22 = require("react/jsx-runtime");
966
+ var FormLoading = (props) => {
967
+ const { loadingShimmerCount, loadingFieldShimmerHeight, inPanel, hideTitleShimmer } = props;
968
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: `fe-loading ${inPanel ? "in-panel" : ""}`, children: [...Array(loadingShimmerCount || import_core8.FormConstants.loadingShimmerCount)].map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "form-field-loading", style: { marginBottom: "16px" }, children: [
969
+ !hideTitleShimmer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material17.Skeleton, { variant: "text", width: "33%" }),
970
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
971
+ import_material17.Skeleton,
972
+ {
973
+ variant: "rectangular",
974
+ height: loadingFieldShimmerHeight || import_core8.FormConstants.loadingFieldShimmerHeight
975
+ }
976
+ )
977
+ ] }, `fe-loading-${i}`)) });
978
+ };
979
+
980
+ // src/registry.ts
981
+ var import_core9 = require("@form-eng/core");
982
+ var import_react6 = __toESM(require("react"));
983
+ function createMuiFieldRegistry() {
984
+ return {
985
+ [import_core9.ComponentTypes.Textbox]: import_react6.default.createElement(Textbox_default),
986
+ [import_core9.ComponentTypes.Number]: import_react6.default.createElement(Number_default),
987
+ [import_core9.ComponentTypes.Toggle]: import_react6.default.createElement(Toggle_default),
988
+ [import_core9.ComponentTypes.Dropdown]: import_react6.default.createElement(Dropdown_default),
989
+ [import_core9.ComponentTypes.MultiSelect]: import_react6.default.createElement(MultiSelect_default),
990
+ [import_core9.ComponentTypes.DateControl]: import_react6.default.createElement(DateControl_default),
991
+ [import_core9.ComponentTypes.Slider]: import_react6.default.createElement(Slider_default),
992
+ [import_core9.ComponentTypes.Fragment]: import_react6.default.createElement(DynamicFragment_default),
993
+ [import_core9.ComponentTypes.SimpleDropdown]: import_react6.default.createElement(SimpleDropdown_default),
994
+ [import_core9.ComponentTypes.MultiSelectSearch]: import_react6.default.createElement(MultiSelectSearch_default),
995
+ [import_core9.ComponentTypes.Textarea]: import_react6.default.createElement(PopOutEditor_default),
996
+ [import_core9.ComponentTypes.DocumentLinks]: import_react6.default.createElement(DocumentLinks_default),
997
+ [import_core9.ComponentTypes.StatusDropdown]: import_react6.default.createElement(StatusDropdown_default),
998
+ [import_core9.ComponentTypes.ReadOnly]: import_react6.default.createElement(ReadOnly_default),
999
+ [import_core9.ComponentTypes.ReadOnlyArray]: import_react6.default.createElement(ReadOnlyArray_default),
1000
+ [import_core9.ComponentTypes.ReadOnlyDateTime]: import_react6.default.createElement(ReadOnlyDateTime_default),
1001
+ [import_core9.ComponentTypes.ReadOnlyCumulativeNumber]: import_react6.default.createElement(ReadOnlyCumulativeNumber_default),
1002
+ [import_core9.ComponentTypes.ReadOnlyRichText]: import_react6.default.createElement(ReadOnlyRichText_default),
1003
+ [import_core9.ComponentTypes.ReadOnlyWithButton]: import_react6.default.createElement(ReadOnlyWithButton_default)
1004
+ };
1005
+ }
1006
+ // Annotate the CommonJS export names for ESM import in node:
1007
+ 0 && (module.exports = {
1008
+ DateControl,
1009
+ DocumentLinks,
1010
+ DocumentLinksStrings,
1011
+ Dropdown,
1012
+ DynamicFragment,
1013
+ FieldClassName,
1014
+ FormLoading,
1015
+ GetFieldDataTestId,
1016
+ MultiSelect,
1017
+ MultiSelectSearch,
1018
+ Number,
1019
+ PopOutEditor,
1020
+ ReadOnly,
1021
+ ReadOnlyArray,
1022
+ ReadOnlyCumulativeNumber,
1023
+ ReadOnlyDateTime,
1024
+ ReadOnlyRichText,
1025
+ ReadOnlyText,
1026
+ ReadOnlyWithButton,
1027
+ SimpleDropdown,
1028
+ Slider,
1029
+ StatusDropdown,
1030
+ StatusMessage,
1031
+ Textbox,
1032
+ Toggle,
1033
+ createMuiFieldRegistry,
1034
+ formatDateTime
1035
+ });
1036
+ //# sourceMappingURL=index.js.map