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