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