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