@form-eng/react-aria 1.5.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,723 @@
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
+ CheckboxGroup: () => CheckboxGroup_default,
33
+ DateControl: () => DateControl_default,
34
+ Dropdown: () => Dropdown_default,
35
+ DynamicFragment: () => DynamicFragment_default,
36
+ FormLoading: () => FormLoading,
37
+ GetFieldDataTestId: () => import_adapter_utils.GetFieldDataTestId,
38
+ MultiSelect: () => MultiSelect_default,
39
+ Number: () => Number_default,
40
+ RadioGroup: () => RadioGroup_default,
41
+ ReadOnly: () => ReadOnly_default,
42
+ ReadOnlyText: () => ReadOnlyText,
43
+ SimpleDropdown: () => SimpleDropdown_default,
44
+ Slider: () => Slider_default,
45
+ StatusMessage: () => StatusMessage,
46
+ Textarea: () => Textarea_default,
47
+ Textbox: () => Textbox_default,
48
+ Toggle: () => Toggle_default,
49
+ createReactAriaFieldRegistry: () => createReactAriaFieldRegistry,
50
+ formatDateTime: () => import_adapter_utils.formatDateTime,
51
+ getFieldState: () => import_adapter_utils.getFieldState
52
+ });
53
+ module.exports = __toCommonJS(index_exports);
54
+
55
+ // src/components/ReadOnlyText.tsx
56
+ var import_jsx_runtime = require("react/jsx-runtime");
57
+ var ReadOnlyText = (props) => {
58
+ const { value, fieldName, ellipsifyTextCharacters } = props;
59
+ const cutoff = (ellipsifyTextCharacters || 0) - 3;
60
+ const displayValue = value ? ellipsifyTextCharacters && value.length > ellipsifyTextCharacters ? `${value.substring(0, cutoff)}...` : value : "-";
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
62
+ "span",
63
+ {
64
+ id: `${fieldName}-read-only`,
65
+ className: "df-read-only-text",
66
+ "data-field-type": "ReadOnlyText",
67
+ title: value,
68
+ children: displayValue
69
+ }
70
+ );
71
+ };
72
+
73
+ // src/helpers.ts
74
+ var import_adapter_utils = require("@form-eng/core/adapter-utils");
75
+
76
+ // src/fields/Textbox.tsx
77
+ var import_react_aria_components = require("react-aria-components");
78
+ var import_jsx_runtime2 = require("react/jsx-runtime");
79
+ var Textbox = (props) => {
80
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, placeholder, setFieldValue } = props;
81
+ if (readOnly) {
82
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
83
+ ReadOnlyText,
84
+ {
85
+ fieldName,
86
+ value,
87
+ ellipsifyTextCharacters: config?.ellipsifyTextCharacters
88
+ }
89
+ );
90
+ }
91
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
92
+ import_react_aria_components.TextField,
93
+ {
94
+ className: "df-textbox",
95
+ value: value ?? "",
96
+ onChange: (val) => setFieldValue(fieldName, val, false, 3e3),
97
+ isInvalid: !!error,
98
+ isRequired: required,
99
+ "data-field-type": "Textbox",
100
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
101
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
102
+ import_react_aria_components.Input,
103
+ {
104
+ autoComplete: "off",
105
+ placeholder: placeholder ?? config?.placeHolder,
106
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId)
107
+ }
108
+ )
109
+ }
110
+ );
111
+ };
112
+ var Textbox_default = Textbox;
113
+
114
+ // src/fields/Number.tsx
115
+ var import_react_aria_components2 = require("react-aria-components");
116
+ var import_jsx_runtime3 = require("react/jsx-runtime");
117
+ var NumberFieldComponent = (props) => {
118
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, setFieldValue } = props;
119
+ if (readOnly) {
120
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ReadOnlyText, { fieldName, value: String(value) });
121
+ }
122
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
123
+ import_react_aria_components2.NumberField,
124
+ {
125
+ className: "df-number",
126
+ value: !(0, import_adapter_utils.isNull)(value) ? value : void 0,
127
+ onChange: (num) => {
128
+ if (!isNaN(num)) {
129
+ setFieldValue(fieldName, num, false, 1500);
130
+ }
131
+ },
132
+ isInvalid: !!error,
133
+ isRequired: required,
134
+ formatOptions: { useGrouping: false },
135
+ "data-field-type": "Number",
136
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
137
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
138
+ import_react_aria_components2.Input,
139
+ {
140
+ autoComplete: "off",
141
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId)
142
+ }
143
+ )
144
+ }
145
+ );
146
+ };
147
+ var Number_default = NumberFieldComponent;
148
+
149
+ // src/fields/Toggle.tsx
150
+ var import_react_aria_components3 = require("react-aria-components");
151
+ var import_jsx_runtime4 = require("react/jsx-runtime");
152
+ var Toggle = (props) => {
153
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, label, setFieldValue } = props;
154
+ if (readOnly) {
155
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ReadOnlyText, { fieldName, value: (0, import_adapter_utils.convertBooleanToYesOrNoText)(value) });
156
+ }
157
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
158
+ import_react_aria_components3.Switch,
159
+ {
160
+ className: "df-toggle",
161
+ isSelected: !!value,
162
+ onChange: (checked) => setFieldValue(fieldName, checked),
163
+ "data-field-type": "Toggle",
164
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
165
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId),
166
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "df-toggle__label", children: label })
167
+ }
168
+ );
169
+ };
170
+ var Toggle_default = Toggle;
171
+
172
+ // src/fields/Dropdown.tsx
173
+ var import_react = __toESM(require("react"));
174
+ var import_react_aria_components4 = require("react-aria-components");
175
+ var import_jsx_runtime5 = require("react/jsx-runtime");
176
+ var Dropdown = (props) => {
177
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, options, placeholder, setFieldValue } = props;
178
+ import_react.default.useEffect(() => {
179
+ if (!value && !readOnly && config?.setDefaultKeyIfOnlyOneOption && options?.length === 1) {
180
+ setFieldValue(fieldName, String(options[0].value));
181
+ }
182
+ }, [options]);
183
+ if (readOnly) {
184
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReadOnlyText, { fieldName, value });
185
+ }
186
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
187
+ import_react_aria_components4.Select,
188
+ {
189
+ className: "df-dropdown",
190
+ selectedKey: value || null,
191
+ onSelectionChange: (key) => setFieldValue(fieldName, String(key)),
192
+ isInvalid: !!error,
193
+ isRequired: required,
194
+ "data-field-type": "Dropdown",
195
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
196
+ children: [
197
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
198
+ import_react_aria_components4.Button,
199
+ {
200
+ className: "df-dropdown__trigger",
201
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId),
202
+ children: [
203
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_aria_components4.SelectValue, { children: placeholder ?? config?.placeHolder ?? "" }),
204
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "df-dropdown__icon", "aria-hidden": "true", children: "\u25BC" })
205
+ ]
206
+ }
207
+ ),
208
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_aria_components4.Popover, { className: "df-dropdown__popover", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_aria_components4.ListBox, { className: "df-dropdown__listbox", children: options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
209
+ import_react_aria_components4.ListBoxItem,
210
+ {
211
+ id: String(option.value),
212
+ className: "df-dropdown__item",
213
+ isDisabled: option.disabled,
214
+ children: option.label
215
+ },
216
+ String(option.value)
217
+ )) }) })
218
+ ]
219
+ }
220
+ );
221
+ };
222
+ var Dropdown_default = Dropdown;
223
+
224
+ // src/fields/MultiSelect.tsx
225
+ var import_jsx_runtime6 = require("react/jsx-runtime");
226
+ var MultiSelect = (props) => {
227
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options, setFieldValue } = props;
228
+ const selectedValues = value ?? [];
229
+ const onChange = (event) => {
230
+ const selected = Array.from(event.target.selectedOptions, (opt) => opt.value);
231
+ setFieldValue(fieldName, selected, false, 1500);
232
+ };
233
+ if (readOnly) {
234
+ return selectedValues.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
235
+ "ul",
236
+ {
237
+ className: "df-multiselect-readonly",
238
+ "data-field-type": "MultiSelect",
239
+ "data-field-state": "readonly",
240
+ children: selectedValues.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { children: v }, i))
241
+ }
242
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "df-read-only-text", children: "-" });
243
+ }
244
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
245
+ "select",
246
+ {
247
+ multiple: true,
248
+ className: "df-multiselect",
249
+ value: selectedValues,
250
+ onChange,
251
+ "aria-invalid": !!error,
252
+ "aria-required": required,
253
+ "data-field-type": "MultiSelect",
254
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
255
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId),
256
+ children: options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: String(option.value), disabled: option.disabled, children: option.label }, String(option.value)))
257
+ }
258
+ );
259
+ };
260
+ var MultiSelect_default = MultiSelect;
261
+
262
+ // src/fields/DateControl.tsx
263
+ var import_core = require("@form-eng/core");
264
+ var import_jsx_runtime7 = require("react/jsx-runtime");
265
+ var DateControl = (props) => {
266
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, setFieldValue } = props;
267
+ const onChange = (event) => {
268
+ const date = new Date(event.target.value);
269
+ if (!isNaN(date.getTime())) {
270
+ setFieldValue(fieldName, date.toISOString());
271
+ }
272
+ };
273
+ const onClear = () => {
274
+ setFieldValue(fieldName, null);
275
+ };
276
+ const dateInputValue = value ? new Date(value).toISOString().split("T")[0] : "";
277
+ if (readOnly) {
278
+ return value ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
279
+ "time",
280
+ {
281
+ className: "df-read-only-date",
282
+ dateTime: value,
283
+ "data-field-type": "DateControl",
284
+ "data-field-state": "readonly",
285
+ children: (0, import_adapter_utils.formatDateTime)(value, { hideTimestamp: true })
286
+ }
287
+ ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "df-read-only-text", children: "-" });
288
+ }
289
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
290
+ "div",
291
+ {
292
+ className: "df-date-control",
293
+ "data-field-type": "DateControl",
294
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
295
+ children: [
296
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
297
+ "input",
298
+ {
299
+ type: "date",
300
+ className: "df-date-control__input",
301
+ value: dateInputValue,
302
+ onChange,
303
+ "aria-invalid": !!error,
304
+ "aria-required": required,
305
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId)
306
+ }
307
+ ),
308
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
309
+ "button",
310
+ {
311
+ type: "button",
312
+ className: "df-date-control__clear",
313
+ onClick: onClear,
314
+ title: import_core.FormStrings.clickToClear,
315
+ "aria-label": `${fieldName} ${import_core.FormStrings.clear}`,
316
+ children: "\xD7"
317
+ }
318
+ )
319
+ ]
320
+ }
321
+ );
322
+ };
323
+ var DateControl_default = DateControl;
324
+
325
+ // src/fields/Slider.tsx
326
+ var import_react_aria_components5 = require("react-aria-components");
327
+ var import_jsx_runtime8 = require("react/jsx-runtime");
328
+ var Slider = (props) => {
329
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, setFieldValue } = props;
330
+ if (readOnly) {
331
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ReadOnlyText, { fieldName, value: String(value) });
332
+ }
333
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
334
+ import_react_aria_components5.Slider,
335
+ {
336
+ className: "df-slider",
337
+ value: value ?? 0,
338
+ onChange: (num) => setFieldValue(fieldName, num),
339
+ maxValue: config?.max,
340
+ minValue: config?.min,
341
+ step: config?.step,
342
+ "data-field-type": "Slider",
343
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
344
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId),
345
+ children: [
346
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_aria_components5.SliderTrack, { className: "df-slider__track", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_aria_components5.SliderThumb, { className: "df-slider__thumb" }) }),
347
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_aria_components5.SliderOutput, { className: "df-slider__value" })
348
+ ]
349
+ }
350
+ );
351
+ };
352
+ var Slider_default = Slider;
353
+
354
+ // src/fields/DynamicFragment.tsx
355
+ var import_jsx_runtime9 = require("react/jsx-runtime");
356
+ var DynamicFragment = (props) => {
357
+ const { value } = props;
358
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { type: "hidden", value });
359
+ };
360
+ var DynamicFragment_default = DynamicFragment;
361
+
362
+ // src/fields/SimpleDropdown.tsx
363
+ var import_react_aria_components6 = require("react-aria-components");
364
+ var import_jsx_runtime10 = require("react/jsx-runtime");
365
+ var SimpleDropdown = (props) => {
366
+ const { fieldName, programName, entityType, entityId, value, readOnly, config, error, required, placeholder, setFieldValue } = props;
367
+ const simpleOptions = config?.dropdownOptions ?? [];
368
+ if (readOnly) {
369
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ReadOnlyText, { fieldName, value });
370
+ }
371
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
372
+ import_react_aria_components6.Select,
373
+ {
374
+ className: "df-simple-dropdown",
375
+ selectedKey: value || null,
376
+ onSelectionChange: (key) => setFieldValue(fieldName, String(key)),
377
+ isInvalid: !!error,
378
+ isRequired: required,
379
+ "data-field-type": "SimpleDropdown",
380
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
381
+ children: [
382
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
383
+ import_react_aria_components6.Button,
384
+ {
385
+ className: "df-simple-dropdown__trigger",
386
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId),
387
+ children: [
388
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_aria_components6.SelectValue, { children: placeholder ?? config?.placeHolder ?? "" }),
389
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "df-simple-dropdown__icon", "aria-hidden": "true", children: "\u25BC" })
390
+ ]
391
+ }
392
+ ),
393
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_aria_components6.Popover, { className: "df-simple-dropdown__popover", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_aria_components6.ListBox, { className: "df-simple-dropdown__listbox", children: simpleOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_aria_components6.ListBoxItem, { id: option, className: "df-simple-dropdown__item", children: option }, option)) }) })
394
+ ]
395
+ }
396
+ );
397
+ };
398
+ var SimpleDropdown_default = SimpleDropdown;
399
+
400
+ // src/fields/Textarea.tsx
401
+ var import_core3 = require("@form-eng/core");
402
+ var import_react2 = __toESM(require("react"));
403
+
404
+ // src/components/StatusMessage.tsx
405
+ var import_core2 = require("@form-eng/core");
406
+ var import_jsx_runtime11 = require("react/jsx-runtime");
407
+ var StatusMessage = (props) => {
408
+ const { id, error, errorCount, savePending, saving } = props;
409
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "df-status-message", "data-field-type": "StatusMessage", children: error ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "df-status-error", id, role: "alert", children: error.message || "Error" }) : savePending ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "df-status-warning", id, role: "alert", children: [
410
+ import_core2.FormStrings.autoSavePending,
411
+ " (",
412
+ errorCount,
413
+ " ",
414
+ import_core2.FormStrings.remaining,
415
+ ")"
416
+ ] }) : saving ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "df-status-saving", id, role: "status", children: import_core2.FormStrings.saving }) : null });
417
+ };
418
+
419
+ // src/fields/Textarea.tsx
420
+ var import_react_aria_components7 = require("react-aria-components");
421
+ var import_jsx_runtime12 = require("react/jsx-runtime");
422
+ var Textarea = (props) => {
423
+ const {
424
+ error,
425
+ fieldName,
426
+ programName,
427
+ entityType,
428
+ entityId,
429
+ config,
430
+ readOnly,
431
+ required,
432
+ savePending,
433
+ saving,
434
+ value,
435
+ label,
436
+ setFieldValue
437
+ } = props;
438
+ const [modalValue, setModalValue] = (0, import_react2.useState)();
439
+ const [modalVisible, setModalVisible] = (0, import_react2.useState)(false);
440
+ const [confirmVisible, setConfirmVisible] = (0, import_react2.useState)(false);
441
+ const dialogRef = import_react2.default.useRef(null);
442
+ const confirmRef = import_react2.default.useRef(null);
443
+ const onExpand = () => {
444
+ setModalVisible(true);
445
+ setModalValue(value ? `${value}` : "");
446
+ dialogRef.current?.showModal();
447
+ };
448
+ const onSave = () => {
449
+ setFieldValue(fieldName, modalValue, false);
450
+ setConfirmVisible(false);
451
+ setModalVisible(false);
452
+ dialogRef.current?.close();
453
+ confirmRef.current?.close();
454
+ config?.saveCallback?.();
455
+ };
456
+ const onCancel = () => {
457
+ if (confirmVisible) {
458
+ setConfirmVisible(false);
459
+ setModalVisible(false);
460
+ dialogRef.current?.close();
461
+ confirmRef.current?.close();
462
+ } else if (modalValue !== value) {
463
+ setConfirmVisible(true);
464
+ confirmRef.current?.showModal();
465
+ } else {
466
+ setModalVisible(false);
467
+ dialogRef.current?.close();
468
+ }
469
+ };
470
+ if (readOnly) {
471
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
472
+ ReadOnlyText,
473
+ {
474
+ fieldName,
475
+ value: value ? `${value}` : "",
476
+ ellipsifyTextCharacters: config?.ellipsifyTextCharacters
477
+ }
478
+ );
479
+ }
480
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
481
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
482
+ "div",
483
+ {
484
+ className: "df-textarea",
485
+ "data-field-type": "Textarea",
486
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
487
+ children: [
488
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
489
+ import_react_aria_components7.TextField,
490
+ {
491
+ className: "df-textarea__field",
492
+ value: modalVisible ? `${modalValue}` : value ? `${value}` : "",
493
+ onChange: (val) => {
494
+ modalVisible ? setModalValue(val) : setFieldValue(fieldName, val, false, 3e3);
495
+ },
496
+ isInvalid: !!error,
497
+ isRequired: required,
498
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
499
+ import_react_aria_components7.TextArea,
500
+ {
501
+ className: "df-textarea__input",
502
+ autoComplete: "off",
503
+ rows: config?.numberOfRows ?? 4,
504
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId)
505
+ }
506
+ )
507
+ }
508
+ ),
509
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
510
+ "button",
511
+ {
512
+ type: "button",
513
+ className: "df-textarea__expand",
514
+ onClick: onExpand,
515
+ "aria-label": import_core3.FormStrings.openExpandedTextEditor,
516
+ children: import_core3.FormStrings.expand
517
+ }
518
+ )
519
+ ]
520
+ }
521
+ ),
522
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dialog", { ref: dialogRef, className: "df-textarea-dialog", "aria-label": `${label} editor`, children: [
523
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("header", { className: "df-textarea-dialog__header", children: [
524
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("h2", { className: "df-textarea-dialog__title", children: [
525
+ label,
526
+ required && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "df-required-indicator", children: " *" })
527
+ ] }),
528
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
529
+ "button",
530
+ {
531
+ type: "button",
532
+ className: "df-textarea-dialog__close",
533
+ onClick: onCancel,
534
+ "aria-label": import_core3.FormStrings.closeExpandedTextEditor,
535
+ children: "\xD7"
536
+ }
537
+ )
538
+ ] }),
539
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "df-textarea-dialog__body", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
540
+ "textarea",
541
+ {
542
+ className: "df-textarea-dialog__input",
543
+ autoComplete: "off",
544
+ value: modalVisible ? `${modalValue}` : value ? `${value}` : "",
545
+ onChange: (e) => setModalValue(e.target.value),
546
+ rows: 12,
547
+ "aria-invalid": !!error
548
+ }
549
+ ) }),
550
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("footer", { className: "df-textarea-dialog__footer", children: [
551
+ config?.renderExtraModalFooter && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: config.renderExtraModalFooter() }),
552
+ (savePending || saving) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(StatusMessage, { savePending: !error ? savePending : void 0, saving, error }),
553
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "df-btn df-btn--secondary", onClick: onCancel, children: import_core3.FormStrings.cancel }),
554
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
555
+ "button",
556
+ {
557
+ type: "button",
558
+ className: "df-btn df-btn--primary",
559
+ onClick: onSave,
560
+ disabled: !config?.saveCallback && modalValue === value,
561
+ "data-testid": `${programName}-${entityType}-${entityId}-save-note`,
562
+ children: import_core3.FormStrings.save
563
+ }
564
+ )
565
+ ] })
566
+ ] }),
567
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dialog", { ref: confirmRef, className: "df-confirm-dialog", children: [
568
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { children: import_core3.FormStrings.unsavedChanges }),
569
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: import_core3.FormStrings.saveChangesTo(label) }),
570
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("footer", { className: "df-confirm-dialog__footer", children: [
571
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "df-btn df-btn--secondary", onClick: onCancel, children: import_core3.FormStrings.dontSave }),
572
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "df-btn df-btn--primary", onClick: onSave, children: import_core3.FormStrings.save })
573
+ ] })
574
+ ] })
575
+ ] });
576
+ };
577
+ var Textarea_default = Textarea;
578
+
579
+ // src/fields/RadioGroup.tsx
580
+ var import_react_aria_components8 = require("react-aria-components");
581
+ var import_jsx_runtime13 = require("react/jsx-runtime");
582
+ var RadioGroup = (props) => {
583
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options, setFieldValue } = props;
584
+ if (readOnly) {
585
+ const label = options?.find((o) => String(o.value) === String(value))?.label ?? value;
586
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ReadOnlyText, { fieldName, value: label });
587
+ }
588
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
589
+ import_react_aria_components8.RadioGroup,
590
+ {
591
+ className: "df-radio-group",
592
+ value: value ?? "",
593
+ onChange: (val) => setFieldValue(fieldName, val),
594
+ isInvalid: !!error,
595
+ isRequired: required,
596
+ "data-field-type": "RadioGroup",
597
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
598
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId),
599
+ children: options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
600
+ import_react_aria_components8.Radio,
601
+ {
602
+ value: String(option.value),
603
+ className: "df-radio-group__option",
604
+ isDisabled: option.disabled,
605
+ children: option.label
606
+ },
607
+ String(option.value)
608
+ ))
609
+ }
610
+ );
611
+ };
612
+ var RadioGroup_default = RadioGroup;
613
+
614
+ // src/fields/CheckboxGroup.tsx
615
+ var import_react_aria_components9 = require("react-aria-components");
616
+ var import_jsx_runtime14 = require("react/jsx-runtime");
617
+ var CheckboxGroup = (props) => {
618
+ const { fieldName, programName, entityType, entityId, value, readOnly, error, required, options, setFieldValue } = props;
619
+ const selected = Array.isArray(value) ? value : [];
620
+ if (readOnly) {
621
+ const labels = options?.filter((o) => selected.includes(String(o.value))).map((o) => o.label).join(", ");
622
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ReadOnlyText, { fieldName, value: labels ?? "" });
623
+ }
624
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
625
+ import_react_aria_components9.CheckboxGroup,
626
+ {
627
+ className: "df-checkbox-group",
628
+ value: selected,
629
+ onChange: (vals) => setFieldValue(fieldName, vals),
630
+ isInvalid: !!error,
631
+ isRequired: required,
632
+ "data-field-type": "CheckboxGroup",
633
+ "data-field-state": (0, import_adapter_utils.getFieldState)({ error, required, readOnly }),
634
+ "data-testid": (0, import_adapter_utils.GetFieldDataTestId)(fieldName, programName, entityType, entityId),
635
+ children: options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
636
+ import_react_aria_components9.Checkbox,
637
+ {
638
+ value: String(option.value),
639
+ className: "df-checkbox-group__option",
640
+ isDisabled: option.disabled,
641
+ children: option.label
642
+ },
643
+ String(option.value)
644
+ ))
645
+ }
646
+ );
647
+ };
648
+ var CheckboxGroup_default = CheckboxGroup;
649
+
650
+ // src/fields/readonly/ReadOnly.tsx
651
+ var import_jsx_runtime15 = require("react/jsx-runtime");
652
+ var ReadOnly = (props) => {
653
+ const { fieldName, value, config } = props;
654
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ReadOnlyText, { fieldName, value, ...config });
655
+ };
656
+ var ReadOnly_default = ReadOnly;
657
+
658
+ // src/components/FormLoading.tsx
659
+ var import_core4 = require("@form-eng/core");
660
+ var import_jsx_runtime16 = require("react/jsx-runtime");
661
+ var FormLoading = (props) => {
662
+ const { loadingShimmerCount, loadingFieldShimmerHeight, inPanel, hideTitleShimmer } = props;
663
+ const count = loadingShimmerCount || import_core4.FormConstants.loadingShimmerCount;
664
+ const height = loadingFieldShimmerHeight || import_core4.FormConstants.loadingFieldShimmerHeight;
665
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
666
+ "div",
667
+ {
668
+ className: `df-form-loading ${inPanel ? "df-form-loading--panel" : ""}`,
669
+ "data-field-type": "FormLoading",
670
+ role: "status",
671
+ "aria-label": "Loading form",
672
+ children: [...Array(count)].map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "df-form-loading__field", children: [
673
+ !hideTitleShimmer && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "df-skeleton df-skeleton--label", style: { width: "33%" } }),
674
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "df-skeleton df-skeleton--input", style: { height: `${height}px` } })
675
+ ] }, `df-loading-${i}`))
676
+ }
677
+ );
678
+ };
679
+
680
+ // src/registry.ts
681
+ var import_core5 = require("@form-eng/core");
682
+ var import_react3 = __toESM(require("react"));
683
+ function createReactAriaFieldRegistry() {
684
+ return {
685
+ [import_core5.ComponentTypes.Textbox]: import_react3.default.createElement(Textbox_default),
686
+ [import_core5.ComponentTypes.Number]: import_react3.default.createElement(Number_default),
687
+ [import_core5.ComponentTypes.Toggle]: import_react3.default.createElement(Toggle_default),
688
+ [import_core5.ComponentTypes.Dropdown]: import_react3.default.createElement(Dropdown_default),
689
+ [import_core5.ComponentTypes.MultiSelect]: import_react3.default.createElement(MultiSelect_default),
690
+ [import_core5.ComponentTypes.DateControl]: import_react3.default.createElement(DateControl_default),
691
+ [import_core5.ComponentTypes.Slider]: import_react3.default.createElement(Slider_default),
692
+ [import_core5.ComponentTypes.Fragment]: import_react3.default.createElement(DynamicFragment_default),
693
+ [import_core5.ComponentTypes.SimpleDropdown]: import_react3.default.createElement(SimpleDropdown_default),
694
+ [import_core5.ComponentTypes.Textarea]: import_react3.default.createElement(Textarea_default),
695
+ [import_core5.ComponentTypes.RadioGroup]: import_react3.default.createElement(RadioGroup_default),
696
+ [import_core5.ComponentTypes.CheckboxGroup]: import_react3.default.createElement(CheckboxGroup_default),
697
+ [import_core5.ComponentTypes.ReadOnly]: import_react3.default.createElement(ReadOnly_default)
698
+ };
699
+ }
700
+ // Annotate the CommonJS export names for ESM import in node:
701
+ 0 && (module.exports = {
702
+ CheckboxGroup,
703
+ DateControl,
704
+ Dropdown,
705
+ DynamicFragment,
706
+ FormLoading,
707
+ GetFieldDataTestId,
708
+ MultiSelect,
709
+ Number,
710
+ RadioGroup,
711
+ ReadOnly,
712
+ ReadOnlyText,
713
+ SimpleDropdown,
714
+ Slider,
715
+ StatusMessage,
716
+ Textarea,
717
+ Textbox,
718
+ Toggle,
719
+ createReactAriaFieldRegistry,
720
+ formatDateTime,
721
+ getFieldState
722
+ });
723
+ //# sourceMappingURL=index.js.map