@rjsf/fluentui-rc 5.14.1

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.
Files changed (210) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +127 -0
  3. package/dist/core.umd.js +940 -0
  4. package/dist/index.esm.js +1091 -0
  5. package/dist/index.esm.js.map +7 -0
  6. package/dist/index.js +1063 -0
  7. package/dist/index.js.map +7 -0
  8. package/lib/AddButton/AddButton.d.ts +3 -0
  9. package/lib/AddButton/AddButton.js +11 -0
  10. package/lib/AddButton/AddButton.js.map +1 -0
  11. package/lib/AddButton/index.d.ts +2 -0
  12. package/lib/AddButton/index.js +3 -0
  13. package/lib/AddButton/index.js.map +1 -0
  14. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +7 -0
  15. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +12 -0
  16. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
  17. package/lib/ArrayFieldItemTemplate/index.d.ts +2 -0
  18. package/lib/ArrayFieldItemTemplate/index.js +3 -0
  19. package/lib/ArrayFieldItemTemplate/index.js.map +1 -0
  20. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +7 -0
  21. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +28 -0
  22. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
  23. package/lib/ArrayFieldTemplate/index.d.ts +2 -0
  24. package/lib/ArrayFieldTemplate/index.js +3 -0
  25. package/lib/ArrayFieldTemplate/index.js.map +1 -0
  26. package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +9 -0
  27. package/lib/BaseInputTemplate/BaseInputTemplate.js +38 -0
  28. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
  29. package/lib/BaseInputTemplate/index.d.ts +2 -0
  30. package/lib/BaseInputTemplate/index.js +3 -0
  31. package/lib/BaseInputTemplate/index.js.map +1 -0
  32. package/lib/CheckboxWidget/CheckboxWidget.d.ts +8 -0
  33. package/lib/CheckboxWidget/CheckboxWidget.js +23 -0
  34. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -0
  35. package/lib/CheckboxWidget/index.d.ts +2 -0
  36. package/lib/CheckboxWidget/index.js +3 -0
  37. package/lib/CheckboxWidget/index.js.map +1 -0
  38. package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +8 -0
  39. package/lib/CheckboxesWidget/CheckboxesWidget.js +30 -0
  40. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
  41. package/lib/CheckboxesWidget/index.d.ts +2 -0
  42. package/lib/CheckboxesWidget/index.js +3 -0
  43. package/lib/CheckboxesWidget/index.js.map +1 -0
  44. package/lib/DescriptionField/DescriptionField.d.ts +7 -0
  45. package/lib/DescriptionField/DescriptionField.js +21 -0
  46. package/lib/DescriptionField/DescriptionField.js.map +1 -0
  47. package/lib/DescriptionField/index.d.ts +2 -0
  48. package/lib/DescriptionField/index.js +3 -0
  49. package/lib/DescriptionField/index.js.map +1 -0
  50. package/lib/ErrorList/ErrorList.d.ts +7 -0
  51. package/lib/ErrorList/ErrorList.js +26 -0
  52. package/lib/ErrorList/ErrorList.js.map +1 -0
  53. package/lib/ErrorList/index.d.ts +2 -0
  54. package/lib/ErrorList/index.js +3 -0
  55. package/lib/ErrorList/index.js.map +1 -0
  56. package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +7 -0
  57. package/lib/FieldErrorTemplate/FieldErrorTemplate.js +28 -0
  58. package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
  59. package/lib/FieldErrorTemplate/index.d.ts +2 -0
  60. package/lib/FieldErrorTemplate/index.js +3 -0
  61. package/lib/FieldErrorTemplate/index.js.map +1 -0
  62. package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +7 -0
  63. package/lib/FieldHelpTemplate/FieldHelpTemplate.js +16 -0
  64. package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
  65. package/lib/FieldHelpTemplate/index.d.ts +2 -0
  66. package/lib/FieldHelpTemplate/index.js +3 -0
  67. package/lib/FieldHelpTemplate/index.js.map +1 -0
  68. package/lib/FieldTemplate/FieldTemplate.d.ts +8 -0
  69. package/lib/FieldTemplate/FieldTemplate.js +18 -0
  70. package/lib/FieldTemplate/FieldTemplate.js.map +1 -0
  71. package/lib/FieldTemplate/index.d.ts +2 -0
  72. package/lib/FieldTemplate/index.js +3 -0
  73. package/lib/FieldTemplate/index.js.map +1 -0
  74. package/lib/FluentForm/FluentForm.d.ts +6 -0
  75. package/lib/FluentForm/FluentForm.js +7 -0
  76. package/lib/FluentForm/FluentForm.js.map +1 -0
  77. package/lib/FluentForm/index.d.ts +2 -0
  78. package/lib/FluentForm/index.js +3 -0
  79. package/lib/FluentForm/index.js.map +1 -0
  80. package/lib/FluentUIRCFrameProvider.d.ts +2 -0
  81. package/lib/FluentUIRCFrameProvider.js +12 -0
  82. package/lib/FluentUIRCFrameProvider.js.map +1 -0
  83. package/lib/IconButton/IconButton.d.ts +7 -0
  84. package/lib/IconButton/IconButton.js +26 -0
  85. package/lib/IconButton/IconButton.js.map +1 -0
  86. package/lib/IconButton/index.d.ts +2 -0
  87. package/lib/IconButton/index.js +3 -0
  88. package/lib/IconButton/index.js.map +1 -0
  89. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +9 -0
  90. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +22 -0
  91. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
  92. package/lib/ObjectFieldTemplate/index.d.ts +2 -0
  93. package/lib/ObjectFieldTemplate/index.js +3 -0
  94. package/lib/ObjectFieldTemplate/index.js.map +1 -0
  95. package/lib/RadioWidget/RadioWidget.d.ts +8 -0
  96. package/lib/RadioWidget/RadioWidget.js +22 -0
  97. package/lib/RadioWidget/RadioWidget.js.map +1 -0
  98. package/lib/RadioWidget/index.d.ts +2 -0
  99. package/lib/RadioWidget/index.js +3 -0
  100. package/lib/RadioWidget/index.js.map +1 -0
  101. package/lib/RangeWidget/RangeWidget.d.ts +8 -0
  102. package/lib/RangeWidget/RangeWidget.js +20 -0
  103. package/lib/RangeWidget/RangeWidget.js.map +1 -0
  104. package/lib/RangeWidget/index.d.ts +2 -0
  105. package/lib/RangeWidget/index.js +3 -0
  106. package/lib/RangeWidget/index.js.map +1 -0
  107. package/lib/SelectWidget/SelectWidget.d.ts +9 -0
  108. package/lib/SelectWidget/SelectWidget.js +41 -0
  109. package/lib/SelectWidget/SelectWidget.js.map +1 -0
  110. package/lib/SelectWidget/index.d.ts +2 -0
  111. package/lib/SelectWidget/index.js +3 -0
  112. package/lib/SelectWidget/index.js.map +1 -0
  113. package/lib/SubmitButton/SubmitButton.d.ts +3 -0
  114. package/lib/SubmitButton/SubmitButton.js +17 -0
  115. package/lib/SubmitButton/SubmitButton.js.map +1 -0
  116. package/lib/SubmitButton/index.d.ts +2 -0
  117. package/lib/SubmitButton/index.js +3 -0
  118. package/lib/SubmitButton/index.js.map +1 -0
  119. package/lib/Templates/Templates.d.ts +4 -0
  120. package/lib/Templates/Templates.js +39 -0
  121. package/lib/Templates/Templates.js.map +1 -0
  122. package/lib/Templates/index.d.ts +2 -0
  123. package/lib/Templates/index.js +3 -0
  124. package/lib/Templates/index.js.map +1 -0
  125. package/lib/TextareaWidget/TextareaWidget.d.ts +7 -0
  126. package/lib/TextareaWidget/TextareaWidget.js +27 -0
  127. package/lib/TextareaWidget/TextareaWidget.js.map +1 -0
  128. package/lib/TextareaWidget/index.d.ts +2 -0
  129. package/lib/TextareaWidget/index.js +3 -0
  130. package/lib/TextareaWidget/index.js.map +1 -0
  131. package/lib/Theme/Theme.d.ts +5 -0
  132. package/lib/Theme/Theme.js +10 -0
  133. package/lib/Theme/Theme.js.map +1 -0
  134. package/lib/Theme/index.d.ts +2 -0
  135. package/lib/Theme/index.js +3 -0
  136. package/lib/Theme/index.js.map +1 -0
  137. package/lib/TitleField/TitleField.d.ts +7 -0
  138. package/lib/TitleField/TitleField.js +17 -0
  139. package/lib/TitleField/TitleField.js.map +1 -0
  140. package/lib/TitleField/index.d.ts +2 -0
  141. package/lib/TitleField/index.js +3 -0
  142. package/lib/TitleField/index.js.map +1 -0
  143. package/lib/Widgets/Widgets.d.ts +4 -0
  144. package/lib/Widgets/Widgets.js +18 -0
  145. package/lib/Widgets/Widgets.js.map +1 -0
  146. package/lib/Widgets/index.d.ts +2 -0
  147. package/lib/Widgets/index.js +3 -0
  148. package/lib/Widgets/index.js.map +1 -0
  149. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +8 -0
  150. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +40 -0
  151. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
  152. package/lib/WrapIfAdditionalTemplate/index.d.ts +2 -0
  153. package/lib/WrapIfAdditionalTemplate/index.js +3 -0
  154. package/lib/WrapIfAdditionalTemplate/index.js.map +1 -0
  155. package/lib/index.d.ts +7 -0
  156. package/lib/index.js +8 -0
  157. package/lib/index.js.map +1 -0
  158. package/lib/tsconfig.tsbuildinfo +1 -0
  159. package/package.json +98 -0
  160. package/src/AddButton/AddButton.tsx +12 -0
  161. package/src/AddButton/index.ts +2 -0
  162. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +72 -0
  163. package/src/ArrayFieldItemTemplate/index.ts +2 -0
  164. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +87 -0
  165. package/src/ArrayFieldTemplate/index.ts +2 -0
  166. package/src/BaseInputTemplate/BaseInputTemplate.tsx +99 -0
  167. package/src/BaseInputTemplate/index.ts +2 -0
  168. package/src/CheckboxWidget/CheckboxWidget.tsx +81 -0
  169. package/src/CheckboxWidget/index.ts +2 -0
  170. package/src/CheckboxesWidget/CheckboxesWidget.tsx +91 -0
  171. package/src/CheckboxesWidget/index.ts +2 -0
  172. package/src/DescriptionField/DescriptionField.tsx +31 -0
  173. package/src/DescriptionField/index.ts +2 -0
  174. package/src/ErrorList/ErrorList.tsx +40 -0
  175. package/src/ErrorList/index.ts +2 -0
  176. package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +44 -0
  177. package/src/FieldErrorTemplate/index.ts +2 -0
  178. package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +19 -0
  179. package/src/FieldHelpTemplate/index.ts +2 -0
  180. package/src/FieldTemplate/FieldTemplate.tsx +80 -0
  181. package/src/FieldTemplate/index.ts +2 -0
  182. package/src/FluentForm/FluentForm.ts +15 -0
  183. package/src/FluentForm/index.ts +2 -0
  184. package/src/FluentUIRCFrameProvider.tsx +21 -0
  185. package/src/IconButton/IconButton.tsx +73 -0
  186. package/src/IconButton/index.ts +2 -0
  187. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +97 -0
  188. package/src/ObjectFieldTemplate/index.ts +2 -0
  189. package/src/RadioWidget/RadioWidget.tsx +77 -0
  190. package/src/RadioWidget/index.ts +2 -0
  191. package/src/RangeWidget/RangeWidget.tsx +49 -0
  192. package/src/RangeWidget/index.ts +2 -0
  193. package/src/SelectWidget/SelectWidget.tsx +98 -0
  194. package/src/SelectWidget/index.ts +2 -0
  195. package/src/SubmitButton/SubmitButton.tsx +27 -0
  196. package/src/SubmitButton/index.ts +2 -0
  197. package/src/Templates/Templates.ts +45 -0
  198. package/src/Templates/index.ts +2 -0
  199. package/src/TextareaWidget/TextareaWidget.tsx +81 -0
  200. package/src/TextareaWidget/index.ts +2 -0
  201. package/src/Theme/Theme.ts +18 -0
  202. package/src/Theme/index.ts +2 -0
  203. package/src/TitleField/TitleField.tsx +28 -0
  204. package/src/TitleField/index.ts +2 -0
  205. package/src/Widgets/Widgets.ts +24 -0
  206. package/src/Widgets/index.ts +2 -0
  207. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +100 -0
  208. package/src/WrapIfAdditionalTemplate/index.ts +2 -0
  209. package/src/index.ts +9 -0
  210. package/src/tsconfig.json +24 -0
@@ -0,0 +1,1091 @@
1
+ // src/FluentForm/FluentForm.ts
2
+ import { withTheme } from "@rjsf/core";
3
+
4
+ // src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx
5
+ import { Flex } from "@fluentui/react-migration-v0-v9";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ function ArrayFieldItemTemplate(props) {
8
+ const {
9
+ children,
10
+ disabled,
11
+ hasToolbar,
12
+ hasCopy,
13
+ hasMoveDown,
14
+ hasMoveUp,
15
+ hasRemove,
16
+ index,
17
+ onCopyIndexClick,
18
+ onDropIndexClick,
19
+ onReorderClick,
20
+ readonly,
21
+ uiSchema,
22
+ registry
23
+ } = props;
24
+ const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
25
+ return /* @__PURE__ */ jsxs(Flex, { vAlign: "end", children: [
26
+ /* @__PURE__ */ jsx(Flex, { children }),
27
+ hasToolbar && /* @__PURE__ */ jsxs(Flex, { style: { marginLeft: "8px" }, children: [
28
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx(
29
+ MoveUpButton2,
30
+ {
31
+ disabled: disabled || readonly || !hasMoveUp,
32
+ onClick: onReorderClick(index, index - 1),
33
+ uiSchema,
34
+ registry
35
+ }
36
+ ),
37
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx(
38
+ MoveDownButton2,
39
+ {
40
+ disabled: disabled || readonly || !hasMoveDown,
41
+ onClick: onReorderClick(index, index + 1),
42
+ uiSchema,
43
+ registry
44
+ }
45
+ ),
46
+ hasCopy && /* @__PURE__ */ jsx(
47
+ CopyButton2,
48
+ {
49
+ disabled: disabled || readonly,
50
+ onClick: onCopyIndexClick(index),
51
+ uiSchema,
52
+ registry
53
+ }
54
+ ),
55
+ hasRemove && /* @__PURE__ */ jsx(
56
+ RemoveButton2,
57
+ {
58
+ disabled: disabled || readonly,
59
+ onClick: onDropIndexClick(index),
60
+ uiSchema,
61
+ registry
62
+ }
63
+ )
64
+ ] })
65
+ ] });
66
+ }
67
+
68
+ // src/AddButton/AddButton.tsx
69
+ import { TranslatableString } from "@rjsf/utils";
70
+ import { Button } from "@fluentui/react-components";
71
+ import { AddRegular } from "@fluentui/react-icons";
72
+ import { jsx as jsx2 } from "react/jsx-runtime";
73
+ function AddButton({
74
+ uiSchema,
75
+ registry,
76
+ ...props
77
+ }) {
78
+ const { translateString } = registry;
79
+ return /* @__PURE__ */ jsx2(Button, { ...props, icon: /* @__PURE__ */ jsx2(AddRegular, {}), title: translateString(TranslatableString.AddItemButton) });
80
+ }
81
+
82
+ // src/ArrayFieldTemplate/ArrayFieldTemplate.tsx
83
+ import { makeStyles, shorthands } from "@fluentui/react-components";
84
+ import { Flex as Flex2 } from "@fluentui/react-migration-v0-v9";
85
+ import {
86
+ getTemplate,
87
+ getUiOptions
88
+ } from "@rjsf/utils";
89
+ import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
90
+ var useStyles = makeStyles({
91
+ arrayItemList: {
92
+ ...shorthands.gap("12px")
93
+ }
94
+ });
95
+ function ArrayFieldTemplate(props) {
96
+ const { canAdd, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title } = props;
97
+ const classes = useStyles();
98
+ const uiOptions = getUiOptions(uiSchema);
99
+ const ArrayFieldDescriptionTemplate = getTemplate(
100
+ "ArrayFieldDescriptionTemplate",
101
+ registry,
102
+ uiOptions
103
+ );
104
+ const ArrayFieldItemTemplate2 = getTemplate(
105
+ "ArrayFieldItemTemplate",
106
+ registry,
107
+ uiOptions
108
+ );
109
+ const ArrayFieldTitleTemplate = getTemplate(
110
+ "ArrayFieldTitleTemplate",
111
+ registry,
112
+ uiOptions
113
+ );
114
+ const {
115
+ ButtonTemplates: { AddButton: AddButton2 }
116
+ } = registry.templates;
117
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
118
+ /* @__PURE__ */ jsx3(
119
+ ArrayFieldTitleTemplate,
120
+ {
121
+ idSchema,
122
+ title: uiOptions.title || title,
123
+ schema,
124
+ uiSchema,
125
+ required,
126
+ registry
127
+ }
128
+ ),
129
+ /* @__PURE__ */ jsx3(
130
+ ArrayFieldDescriptionTemplate,
131
+ {
132
+ idSchema,
133
+ description: uiOptions.description || schema.description,
134
+ schema,
135
+ uiSchema,
136
+ registry
137
+ }
138
+ ),
139
+ /* @__PURE__ */ jsxs2(Flex2, { column: true, className: classes.arrayItemList, children: [
140
+ items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx3(ArrayFieldItemTemplate2, { ...itemProps }, key)),
141
+ canAdd && /* @__PURE__ */ jsx3(Flex2, { hAlign: "end", children: /* @__PURE__ */ jsx3(
142
+ AddButton2,
143
+ {
144
+ className: "array-item-add",
145
+ onClick: onAddClick,
146
+ disabled: disabled || readonly,
147
+ uiSchema,
148
+ registry
149
+ }
150
+ ) })
151
+ ] }, `array-item-list-${idSchema.$id}`)
152
+ ] });
153
+ }
154
+
155
+ // src/BaseInputTemplate/BaseInputTemplate.tsx
156
+ import { Input, Label, makeStyles as makeStyles2 } from "@fluentui/react-components";
157
+ import {
158
+ ariaDescribedByIds,
159
+ examplesId,
160
+ getInputProps,
161
+ labelValue
162
+ } from "@rjsf/utils";
163
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
164
+ var useStyles2 = makeStyles2({
165
+ input: {
166
+ width: "100%"
167
+ },
168
+ label: {
169
+ paddingTop: "2px",
170
+ paddingBottom: "2px",
171
+ marginBottom: "2px"
172
+ }
173
+ });
174
+ function BaseInputTemplate(props) {
175
+ const {
176
+ id,
177
+ placeholder,
178
+ required,
179
+ readonly,
180
+ disabled,
181
+ type,
182
+ value,
183
+ label,
184
+ hideLabel,
185
+ onChange,
186
+ onChangeOverride,
187
+ onBlur,
188
+ onFocus,
189
+ autofocus,
190
+ options,
191
+ schema
192
+ } = props;
193
+ const classes = useStyles2();
194
+ const inputProps = getInputProps(schema, type, options);
195
+ const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
196
+ const _onBlur = ({ target: { value: value2 } }) => onBlur(id, value2);
197
+ const _onFocus = ({ target: { value: value2 } }) => onFocus(id, value2);
198
+ return /* @__PURE__ */ jsxs3(Fragment2, { children: [
199
+ labelValue(
200
+ /* @__PURE__ */ jsx4(Label, { htmlFor: id, required, disabled, className: classes.label, children: label }),
201
+ hideLabel
202
+ ),
203
+ /* @__PURE__ */ jsx4(
204
+ Input,
205
+ {
206
+ id,
207
+ name: id,
208
+ placeholder,
209
+ autoFocus: autofocus,
210
+ required,
211
+ disabled: disabled || readonly,
212
+ ...inputProps,
213
+ input: {
214
+ className: classes.input,
215
+ // Due to Fluent UI this does not work correctly
216
+ list: schema.examples ? examplesId(id) : void 0
217
+ },
218
+ value: value || value === 0 ? value : "",
219
+ onChange: onChangeOverride || _onChange,
220
+ onFocus: _onFocus,
221
+ onBlur: _onBlur,
222
+ "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
223
+ }
224
+ ),
225
+ Array.isArray(schema.examples) && /* @__PURE__ */ jsx4("datalist", { id: examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
226
+ return /* @__PURE__ */ jsx4("option", { value: example }, example);
227
+ }) })
228
+ ] });
229
+ }
230
+
231
+ // src/DescriptionField/DescriptionField.tsx
232
+ import { Text, makeStyles as makeStyles3, tokens } from "@fluentui/react-components";
233
+ import { jsx as jsx5 } from "react/jsx-runtime";
234
+ var useStyles3 = makeStyles3({
235
+ label: {
236
+ marginTop: tokens.spacingVerticalS,
237
+ marginBottom: tokens.spacingVerticalM
238
+ }
239
+ });
240
+ function DescriptionField(props) {
241
+ const { id, description } = props;
242
+ const classes = useStyles3();
243
+ if (description) {
244
+ return /* @__PURE__ */ jsx5(Text, { block: true, id, className: classes.label, children: description });
245
+ }
246
+ return null;
247
+ }
248
+
249
+ // src/ErrorList/ErrorList.tsx
250
+ import { Card, Text as Text2, makeStyles as makeStyles4, shorthands as shorthands2, tokens as tokens2 } from "@fluentui/react-components";
251
+ import { TranslatableString as TranslatableString2 } from "@rjsf/utils";
252
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
253
+ var useStyles4 = makeStyles4({
254
+ errorCard: {
255
+ backgroundColor: tokens2.colorStatusDangerBackground1,
256
+ marginBottom: tokens2.spacingVerticalL,
257
+ "&::after": {
258
+ ...shorthands2.borderColor(tokens2.colorStatusDangerBorder1)
259
+ }
260
+ },
261
+ errorTitle: {
262
+ marginTop: 0,
263
+ marginBottom: 0
264
+ }
265
+ });
266
+ function ErrorList({
267
+ errors,
268
+ registry
269
+ }) {
270
+ const { translateString } = registry;
271
+ const classes = useStyles4();
272
+ return /* @__PURE__ */ jsxs4(Card, { appearance: "outline", className: classes.errorCard, children: [
273
+ /* @__PURE__ */ jsx6(Text2, { as: "h6", size: 400, className: classes.errorTitle, children: translateString(TranslatableString2.ErrorsLabel) }),
274
+ /* @__PURE__ */ jsx6("ul", { children: errors.map((error, i) => {
275
+ return /* @__PURE__ */ jsx6("li", { children: error.stack }, i);
276
+ }) })
277
+ ] });
278
+ }
279
+
280
+ // src/IconButton/IconButton.tsx
281
+ import { Button as Button2 } from "@fluentui/react-components";
282
+ import { ArrowSortUpRegular, ArrowSortDownRegular, CopyRegular, SubtractRegular } from "@fluentui/react-icons";
283
+ import { TranslatableString as TranslatableString3 } from "@rjsf/utils";
284
+ import { jsx as jsx7 } from "react/jsx-runtime";
285
+ function FluentIconButton(props) {
286
+ const { color, uiSchema, registry, ...otherProps } = props;
287
+ return /* @__PURE__ */ jsx7(Button2, { ...otherProps, color: "secondary" });
288
+ }
289
+ function CopyButton(props) {
290
+ const {
291
+ registry: { translateString }
292
+ } = props;
293
+ return /* @__PURE__ */ jsx7(
294
+ FluentIconButton,
295
+ {
296
+ title: translateString(TranslatableString3.CopyButton),
297
+ ...props,
298
+ icon: /* @__PURE__ */ jsx7(CopyRegular, {})
299
+ }
300
+ );
301
+ }
302
+ function MoveDownButton(props) {
303
+ const {
304
+ registry: { translateString }
305
+ } = props;
306
+ return /* @__PURE__ */ jsx7(
307
+ FluentIconButton,
308
+ {
309
+ title: translateString(TranslatableString3.MoveDownButton),
310
+ ...props,
311
+ icon: /* @__PURE__ */ jsx7(ArrowSortDownRegular, {})
312
+ }
313
+ );
314
+ }
315
+ function MoveUpButton(props) {
316
+ const {
317
+ registry: { translateString }
318
+ } = props;
319
+ return /* @__PURE__ */ jsx7(
320
+ FluentIconButton,
321
+ {
322
+ title: translateString(TranslatableString3.MoveUpButton),
323
+ ...props,
324
+ icon: /* @__PURE__ */ jsx7(ArrowSortUpRegular, {})
325
+ }
326
+ );
327
+ }
328
+ function RemoveButton(props) {
329
+ const {
330
+ registry: { translateString }
331
+ } = props;
332
+ return /* @__PURE__ */ jsx7(
333
+ FluentIconButton,
334
+ {
335
+ title: translateString(TranslatableString3.RemoveButton),
336
+ ...props,
337
+ icon: /* @__PURE__ */ jsx7(SubtractRegular, {})
338
+ }
339
+ );
340
+ }
341
+
342
+ // src/FieldErrorTemplate/FieldErrorTemplate.tsx
343
+ import { makeStyles as makeStyles5, tokens as tokens3 } from "@fluentui/react-components";
344
+ import { errorId } from "@rjsf/utils";
345
+ import { jsx as jsx8 } from "react/jsx-runtime";
346
+ var useStyles5 = makeStyles5({
347
+ list: { marginTop: 0, marginBottom: 0, paddingLeft: 0, listStyleType: "none" },
348
+ listItem: {
349
+ paddingLeft: tokens3.spacingHorizontalL,
350
+ paddingTop: tokens3.spacingVerticalXS,
351
+ paddingBottom: tokens3.spacingVerticalXS
352
+ },
353
+ errorLabel: { color: tokens3.colorPaletteRedForeground1 }
354
+ });
355
+ function FieldErrorTemplate(props) {
356
+ const { errors = [], idSchema } = props;
357
+ const classes = useStyles5();
358
+ if (errors.length === 0) {
359
+ return null;
360
+ }
361
+ const id = errorId(idSchema);
362
+ return /* @__PURE__ */ jsx8("ul", { className: classes.list, children: errors.map((error, i) => {
363
+ return /* @__PURE__ */ jsx8("li", { className: classes.listItem, children: /* @__PURE__ */ jsx8("small", { className: classes.errorLabel, id, children: error }) }, i);
364
+ }) });
365
+ }
366
+
367
+ // src/FieldHelpTemplate/FieldHelpTemplate.tsx
368
+ import { Caption1 } from "@fluentui/react-components";
369
+ import { helpId } from "@rjsf/utils";
370
+ import { jsx as jsx9 } from "react/jsx-runtime";
371
+ function FieldHelpTemplate(props) {
372
+ const { idSchema, help } = props;
373
+ if (!help) {
374
+ return null;
375
+ }
376
+ const id = helpId(idSchema);
377
+ return /* @__PURE__ */ jsx9(Caption1, { id, children: help });
378
+ }
379
+
380
+ // src/FieldTemplate/FieldTemplate.tsx
381
+ import { Field, Text as Text3 } from "@fluentui/react-components";
382
+ import {
383
+ getTemplate as getTemplate2,
384
+ getUiOptions as getUiOptions2
385
+ } from "@rjsf/utils";
386
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
387
+ function FieldTemplate(props) {
388
+ const {
389
+ id,
390
+ children,
391
+ classNames,
392
+ style,
393
+ disabled,
394
+ displayLabel,
395
+ hidden,
396
+ label,
397
+ onDropPropertyClick,
398
+ onKeyChange,
399
+ readonly,
400
+ required,
401
+ rawErrors = [],
402
+ errors,
403
+ help,
404
+ description,
405
+ rawDescription,
406
+ schema,
407
+ uiSchema,
408
+ registry
409
+ } = props;
410
+ const uiOptions = getUiOptions2(uiSchema);
411
+ const WrapIfAdditionalTemplate2 = getTemplate2(
412
+ "WrapIfAdditionalTemplate",
413
+ registry,
414
+ uiOptions
415
+ );
416
+ if (hidden) {
417
+ return /* @__PURE__ */ jsx10("div", { style: { display: "none" }, children });
418
+ }
419
+ return /* @__PURE__ */ jsx10(
420
+ WrapIfAdditionalTemplate2,
421
+ {
422
+ classNames,
423
+ style,
424
+ disabled,
425
+ id,
426
+ label,
427
+ onDropPropertyClick,
428
+ onKeyChange,
429
+ readonly,
430
+ required,
431
+ schema,
432
+ uiSchema,
433
+ registry,
434
+ children: /* @__PURE__ */ jsxs5(Field, { validationState: rawErrors.length ? "error" : void 0, required, children: [
435
+ children,
436
+ displayLabel && rawDescription ? /* @__PURE__ */ jsx10(Text3, { as: "p", block: true, style: { marginTop: 0, marginBottom: 0 }, children: description }) : null,
437
+ errors,
438
+ help
439
+ ] })
440
+ }
441
+ );
442
+ }
443
+
444
+ // src/ObjectFieldTemplate/ObjectFieldTemplate.tsx
445
+ import { Flex as Flex3 } from "@fluentui/react-migration-v0-v9";
446
+ import {
447
+ canExpand,
448
+ descriptionId,
449
+ getTemplate as getTemplate3,
450
+ getUiOptions as getUiOptions3,
451
+ titleId
452
+ } from "@rjsf/utils";
453
+ import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
454
+ function ObjectFieldTemplate(props) {
455
+ const {
456
+ description,
457
+ title,
458
+ properties,
459
+ required,
460
+ disabled,
461
+ readonly,
462
+ uiSchema,
463
+ idSchema,
464
+ schema,
465
+ formData,
466
+ onAddClick,
467
+ registry
468
+ } = props;
469
+ const uiOptions = getUiOptions3(uiSchema);
470
+ const TitleFieldTemplate = getTemplate3("TitleFieldTemplate", registry, uiOptions);
471
+ const DescriptionFieldTemplate = getTemplate3(
472
+ "DescriptionFieldTemplate",
473
+ registry,
474
+ uiOptions
475
+ );
476
+ const {
477
+ ButtonTemplates: { AddButton: AddButton2 }
478
+ } = registry.templates;
479
+ return /* @__PURE__ */ jsxs6(Fragment3, { children: [
480
+ title && /* @__PURE__ */ jsx11(
481
+ TitleFieldTemplate,
482
+ {
483
+ id: titleId(idSchema),
484
+ title,
485
+ required,
486
+ schema,
487
+ uiSchema,
488
+ registry
489
+ }
490
+ ),
491
+ description && /* @__PURE__ */ jsx11(
492
+ DescriptionFieldTemplate,
493
+ {
494
+ id: descriptionId(idSchema),
495
+ description,
496
+ schema,
497
+ uiSchema,
498
+ registry
499
+ }
500
+ ),
501
+ /* @__PURE__ */ jsxs6(Flex3, { fill: true, column: true, gap: "gap.medium", children: [
502
+ properties.map(
503
+ (element, index) => (
504
+ // Remove the <Grid> if the inner element is hidden as the <Grid>
505
+ // itself would otherwise still take up space.
506
+ element.hidden ? element.content : /* @__PURE__ */ jsx11(Flex3, { column: true, fill: true, style: { marginBottom: "10px" }, children: element.content }, index)
507
+ )
508
+ ),
509
+ canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx11(Flex3, { hAlign: "end", children: /* @__PURE__ */ jsx11(
510
+ AddButton2,
511
+ {
512
+ className: "object-property-expand",
513
+ onClick: onAddClick(schema),
514
+ disabled: disabled || readonly,
515
+ uiSchema,
516
+ registry
517
+ }
518
+ ) })
519
+ ] })
520
+ ] });
521
+ }
522
+
523
+ // src/SubmitButton/SubmitButton.tsx
524
+ import { getSubmitButtonOptions } from "@rjsf/utils";
525
+ import { Button as Button3, makeStyles as makeStyles6, tokens as tokens4 } from "@fluentui/react-components";
526
+ import { jsx as jsx12 } from "react/jsx-runtime";
527
+ var useStyles6 = makeStyles6({
528
+ buttonRow: {
529
+ marginTop: tokens4.spacingVerticalL
530
+ }
531
+ });
532
+ function SubmitButton({ uiSchema }) {
533
+ const classes = useStyles6();
534
+ const { submitText, norender, props: submitButtonProps } = getSubmitButtonOptions(uiSchema);
535
+ if (norender) {
536
+ return null;
537
+ }
538
+ return /* @__PURE__ */ jsx12("div", { className: classes.buttonRow, children: /* @__PURE__ */ jsx12(Button3, { appearance: "primary", type: "submit", ...submitButtonProps, children: submitText }) });
539
+ }
540
+
541
+ // src/TitleField/TitleField.tsx
542
+ import { Text as Text4, Divider, makeStyles as makeStyles7 } from "@fluentui/react-components";
543
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
544
+ var useStyles7 = makeStyles7({
545
+ root: {
546
+ marginTop: "8px",
547
+ marginBottom: "8px"
548
+ }
549
+ });
550
+ function TitleField({
551
+ id,
552
+ title
553
+ }) {
554
+ const classes = useStyles7();
555
+ return /* @__PURE__ */ jsxs7("div", { id, className: classes.root, children: [
556
+ /* @__PURE__ */ jsx13(Text4, { as: "h5", size: 600, children: title }),
557
+ /* @__PURE__ */ jsx13(Divider, {})
558
+ ] });
559
+ }
560
+
561
+ // src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx
562
+ import {
563
+ ADDITIONAL_PROPERTY_FLAG,
564
+ TranslatableString as TranslatableString4
565
+ } from "@rjsf/utils";
566
+ import { Field as Field2, Input as Input2, makeStyles as makeStyles8 } from "@fluentui/react-components";
567
+ import { Flex as Flex4 } from "@fluentui/react-migration-v0-v9";
568
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
569
+ var useStyles8 = makeStyles8({
570
+ input: {
571
+ width: "100%"
572
+ },
573
+ label: {
574
+ marginBottom: "4px"
575
+ }
576
+ });
577
+ function WrapIfAdditionalTemplate(props) {
578
+ const {
579
+ children,
580
+ classNames,
581
+ style,
582
+ disabled,
583
+ id,
584
+ label,
585
+ onDropPropertyClick,
586
+ onKeyChange,
587
+ readonly,
588
+ required,
589
+ schema,
590
+ uiSchema,
591
+ registry
592
+ } = props;
593
+ const { templates, translateString } = registry;
594
+ const classes = useStyles8();
595
+ const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
596
+ const keyLabel = translateString(TranslatableString4.KeyLabel, [label]);
597
+ const additional = ADDITIONAL_PROPERTY_FLAG in schema;
598
+ const btnStyle = {
599
+ flex: 1,
600
+ paddingLeft: 6,
601
+ paddingRight: 6,
602
+ fontWeight: "bold"
603
+ };
604
+ if (!additional) {
605
+ return /* @__PURE__ */ jsx14("div", { className: classNames, style, children });
606
+ }
607
+ const handleBlur = ({ target }) => onKeyChange(target.value);
608
+ return /* @__PURE__ */ jsxs8(Flex4, { gap: "gap.medium", vAlign: "center", className: classNames, style, children: [
609
+ /* @__PURE__ */ jsx14("div", { children: /* @__PURE__ */ jsx14(Field2, { label: keyLabel, required, children: /* @__PURE__ */ jsx14(
610
+ Input2,
611
+ {
612
+ required,
613
+ defaultValue: label,
614
+ disabled: disabled || readonly,
615
+ id: `${id}-key`,
616
+ name: `${id}-key`,
617
+ onBlur: !readonly ? handleBlur : void 0,
618
+ type: "text",
619
+ input: {
620
+ className: classes.input
621
+ }
622
+ }
623
+ ) }) }),
624
+ /* @__PURE__ */ jsx14("div", { children }),
625
+ /* @__PURE__ */ jsx14("div", { children: /* @__PURE__ */ jsx14(
626
+ RemoveButton2,
627
+ {
628
+ iconType: "default",
629
+ style: btnStyle,
630
+ disabled: disabled || readonly,
631
+ onClick: onDropPropertyClick(label),
632
+ uiSchema,
633
+ registry
634
+ }
635
+ ) })
636
+ ] }, `${id}-key`);
637
+ }
638
+
639
+ // src/Templates/Templates.ts
640
+ function generateTemplates() {
641
+ return {
642
+ ArrayFieldItemTemplate,
643
+ ArrayFieldTemplate,
644
+ BaseInputTemplate,
645
+ ButtonTemplates: {
646
+ CopyButton,
647
+ AddButton,
648
+ MoveDownButton,
649
+ MoveUpButton,
650
+ RemoveButton,
651
+ SubmitButton
652
+ },
653
+ DescriptionFieldTemplate: DescriptionField,
654
+ ErrorListTemplate: ErrorList,
655
+ FieldErrorTemplate,
656
+ FieldHelpTemplate,
657
+ FieldTemplate,
658
+ ObjectFieldTemplate,
659
+ TitleFieldTemplate: TitleField,
660
+ WrapIfAdditionalTemplate
661
+ };
662
+ }
663
+ var Templates_default = generateTemplates();
664
+
665
+ // src/CheckboxWidget/CheckboxWidget.tsx
666
+ import {
667
+ ariaDescribedByIds as ariaDescribedByIds2,
668
+ descriptionId as descriptionId2,
669
+ getTemplate as getTemplate4,
670
+ schemaRequiresTrueValue
671
+ } from "@rjsf/utils";
672
+ import { Checkbox } from "@fluentui/react-components";
673
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
674
+ function CheckboxWidget(props) {
675
+ const {
676
+ schema,
677
+ id,
678
+ value,
679
+ disabled,
680
+ readonly,
681
+ label = "",
682
+ hideLabel,
683
+ autofocus,
684
+ onChange,
685
+ onBlur,
686
+ onFocus,
687
+ registry,
688
+ options,
689
+ uiSchema
690
+ } = props;
691
+ const DescriptionFieldTemplate = getTemplate4(
692
+ "DescriptionFieldTemplate",
693
+ registry,
694
+ options
695
+ );
696
+ const required = schemaRequiresTrueValue(schema);
697
+ const _onChange = ({ target: { checked } }) => onChange(checked);
698
+ const _onBlur = ({ target: { value: value2 } }) => onBlur(id, value2);
699
+ const _onFocus = ({ target: { value: value2 } }) => onFocus(id, value2);
700
+ const description = options.description ?? schema.description;
701
+ return /* @__PURE__ */ jsxs9(Fragment4, { children: [
702
+ !hideLabel && !!description && /* @__PURE__ */ jsx15(
703
+ DescriptionFieldTemplate,
704
+ {
705
+ id: descriptionId2(id),
706
+ description,
707
+ schema,
708
+ uiSchema,
709
+ registry
710
+ }
711
+ ),
712
+ /* @__PURE__ */ jsx15(
713
+ Checkbox,
714
+ {
715
+ id,
716
+ name: id,
717
+ label,
718
+ checked: typeof value === "undefined" ? false : Boolean(value),
719
+ required,
720
+ disabled: disabled || readonly,
721
+ autoFocus: autofocus,
722
+ onChange: _onChange,
723
+ onBlur: _onBlur,
724
+ onFocus: _onFocus,
725
+ "aria-describedby": ariaDescribedByIds2(id)
726
+ }
727
+ )
728
+ ] });
729
+ }
730
+
731
+ // src/CheckboxesWidget/CheckboxesWidget.tsx
732
+ import {
733
+ ariaDescribedByIds as ariaDescribedByIds3,
734
+ enumOptionsDeselectValue,
735
+ enumOptionsIsSelected,
736
+ enumOptionsSelectValue,
737
+ enumOptionsValueForIndex,
738
+ labelValue as labelValue2,
739
+ optionId
740
+ } from "@rjsf/utils";
741
+ import { Label as Label2, Checkbox as Checkbox2 } from "@fluentui/react-components";
742
+ import { Flex as Flex5 } from "@fluentui/react-migration-v0-v9";
743
+ import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
744
+ function CheckboxesWidget({
745
+ label,
746
+ hideLabel,
747
+ id,
748
+ disabled,
749
+ options,
750
+ value,
751
+ autofocus,
752
+ readonly,
753
+ required,
754
+ onChange,
755
+ onBlur,
756
+ onFocus
757
+ }) {
758
+ const { enumOptions, enumDisabled, inline, emptyValue } = options;
759
+ const checkboxesValues = Array.isArray(value) ? value : [value];
760
+ const _onChange = (index) => ({ target: { checked } }) => {
761
+ if (checked) {
762
+ onChange(enumOptionsSelectValue(index, checkboxesValues, enumOptions));
763
+ } else {
764
+ onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
765
+ }
766
+ };
767
+ const _onBlur = ({ target: { value: value2 } }) => onBlur(id, enumOptionsValueForIndex(value2, enumOptions, emptyValue));
768
+ const _onFocus = ({ target: { value: value2 } }) => onFocus(id, enumOptionsValueForIndex(value2, enumOptions, emptyValue));
769
+ return /* @__PURE__ */ jsxs10(Fragment5, { children: [
770
+ labelValue2(
771
+ /* @__PURE__ */ jsx16(Label2, { required, htmlFor: id, children: label || void 0 }),
772
+ hideLabel
773
+ ),
774
+ /* @__PURE__ */ jsx16(Flex5, { column: !inline, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
775
+ const checked = enumOptionsIsSelected(option.value, checkboxesValues);
776
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
777
+ return /* @__PURE__ */ jsx16(
778
+ Checkbox2,
779
+ {
780
+ id: optionId(id, index),
781
+ name: id,
782
+ label: option.label,
783
+ checked,
784
+ disabled: disabled || itemDisabled || readonly,
785
+ autoFocus: autofocus && index === 0,
786
+ onChange: _onChange(index),
787
+ onBlur: _onBlur,
788
+ onFocus: _onFocus,
789
+ "aria-describedby": ariaDescribedByIds3(id)
790
+ },
791
+ index
792
+ );
793
+ }) })
794
+ ] });
795
+ }
796
+
797
+ // src/RadioWidget/RadioWidget.tsx
798
+ import {
799
+ ariaDescribedByIds as ariaDescribedByIds4,
800
+ enumOptionsIndexForValue,
801
+ enumOptionsValueForIndex as enumOptionsValueForIndex2,
802
+ labelValue as labelValue3,
803
+ optionId as optionId2
804
+ } from "@rjsf/utils";
805
+ import { Label as Label3, Radio, RadioGroup } from "@fluentui/react-components";
806
+ import { Fragment as Fragment6, jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
807
+ function RadioWidget({
808
+ id,
809
+ options,
810
+ value,
811
+ required,
812
+ disabled,
813
+ readonly,
814
+ label,
815
+ hideLabel,
816
+ onChange,
817
+ onBlur,
818
+ onFocus
819
+ }) {
820
+ const { enumOptions, enumDisabled, emptyValue } = options;
821
+ const _onChange = (_, data) => onChange(enumOptionsValueForIndex2(data.value, enumOptions, emptyValue));
822
+ const _onBlur = ({ target: { value: value2 } }) => onBlur(id, enumOptionsValueForIndex2(value2, enumOptions, emptyValue));
823
+ const _onFocus = ({ target: { value: value2 } }) => onFocus(id, enumOptionsValueForIndex2(value2, enumOptions, emptyValue));
824
+ const selectedIndex = enumOptionsIndexForValue(value, enumOptions) ?? void 0;
825
+ return /* @__PURE__ */ jsxs11(Fragment6, { children: [
826
+ labelValue3(
827
+ /* @__PURE__ */ jsx17(Label3, { required, htmlFor: id, children: label || void 0 }),
828
+ hideLabel
829
+ ),
830
+ /* @__PURE__ */ jsx17(
831
+ RadioGroup,
832
+ {
833
+ id,
834
+ name: id,
835
+ value: selectedIndex,
836
+ onChange: _onChange,
837
+ onBlur: _onBlur,
838
+ onFocus: _onFocus,
839
+ "aria-describedby": ariaDescribedByIds4(id),
840
+ children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
841
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
842
+ return /* @__PURE__ */ jsx17(
843
+ Radio,
844
+ {
845
+ id: optionId2(id, index),
846
+ label: option.label,
847
+ value: String(index),
848
+ disabled: disabled || itemDisabled || readonly
849
+ },
850
+ index
851
+ );
852
+ })
853
+ }
854
+ )
855
+ ] });
856
+ }
857
+
858
+ // src/RangeWidget/RangeWidget.tsx
859
+ import {
860
+ ariaDescribedByIds as ariaDescribedByIds5,
861
+ labelValue as labelValue4,
862
+ rangeSpec
863
+ } from "@rjsf/utils";
864
+ import { Label as Label4, Slider } from "@fluentui/react-components";
865
+ import { Fragment as Fragment7, jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
866
+ function RangeWidget(props) {
867
+ const { value, readonly, disabled, onBlur, onFocus, options, schema, onChange, required, label, hideLabel, id } = props;
868
+ const sliderProps = { value, label, id, name: id, ...rangeSpec(schema) };
869
+ const _onChange = (_, data) => {
870
+ onChange(data.value ?? options.emptyValue);
871
+ };
872
+ const _onBlur = ({ target: { value: value2 } }) => onBlur(id, value2);
873
+ const _onFocus = ({ target: { value: value2 } }) => onFocus(id, value2);
874
+ return /* @__PURE__ */ jsxs12(Fragment7, { children: [
875
+ labelValue4(
876
+ /* @__PURE__ */ jsx18(Label4, { required, htmlFor: id, children: label || void 0 }),
877
+ hideLabel
878
+ ),
879
+ /* @__PURE__ */ jsx18(
880
+ Slider,
881
+ {
882
+ disabled: disabled || readonly,
883
+ onChange: _onChange,
884
+ onBlur: _onBlur,
885
+ onFocus: _onFocus,
886
+ ...sliderProps,
887
+ "aria-describedby": ariaDescribedByIds5(id)
888
+ }
889
+ )
890
+ ] });
891
+ }
892
+
893
+ // src/SelectWidget/SelectWidget.tsx
894
+ import {
895
+ ariaDescribedByIds as ariaDescribedByIds6,
896
+ enumOptionsIndexForValue as enumOptionsIndexForValue2,
897
+ enumOptionsValueForIndex as enumOptionsValueForIndex3,
898
+ labelValue as labelValue5
899
+ } from "@rjsf/utils";
900
+ import { Dropdown, Field as Field3, Option } from "@fluentui/react-components";
901
+ import { jsx as jsx19 } from "react/jsx-runtime";
902
+ function getValue(data, multiple) {
903
+ if (multiple) {
904
+ return data.selectedOptions;
905
+ }
906
+ return data.selectedOptions[0];
907
+ }
908
+ function SelectWidget({
909
+ id,
910
+ options,
911
+ label,
912
+ hideLabel,
913
+ value,
914
+ required,
915
+ disabled,
916
+ readonly,
917
+ multiple = false,
918
+ autofocus = false,
919
+ rawErrors = [],
920
+ onChange,
921
+ onBlur,
922
+ onFocus
923
+ }) {
924
+ const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
925
+ const selectedIndexes = enumOptionsIndexForValue2(value, enumOptions, multiple);
926
+ let selectedIndexesAsArray = [];
927
+ if (typeof selectedIndexes === "string") {
928
+ selectedIndexesAsArray = [selectedIndexes];
929
+ } else if (Array.isArray(selectedIndexes)) {
930
+ selectedIndexesAsArray = selectedIndexes.map((index) => String(index));
931
+ }
932
+ const dropdownValue = selectedIndexesAsArray.map((index) => enumOptions ? enumOptions[Number(index)].label : void 0).join(", ");
933
+ const _onBlur = () => onBlur(id, selectedIndexes);
934
+ const _onFocus = () => onFocus(id, selectedIndexes);
935
+ const _onChange = (_, data) => {
936
+ const newValue = getValue(data, multiple);
937
+ return onChange(enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
938
+ };
939
+ return /* @__PURE__ */ jsx19(
940
+ Field3,
941
+ {
942
+ label: labelValue5(label, hideLabel),
943
+ validationState: rawErrors.length ? "error" : void 0,
944
+ required,
945
+ children: /* @__PURE__ */ jsx19(
946
+ Dropdown,
947
+ {
948
+ id,
949
+ name: id,
950
+ multiselect: multiple,
951
+ className: "form-control",
952
+ value: dropdownValue,
953
+ disabled: disabled || readonly,
954
+ autoFocus: autofocus,
955
+ onBlur: _onBlur,
956
+ onFocus: _onFocus,
957
+ onOptionSelect: _onChange,
958
+ selectedOptions: selectedIndexesAsArray,
959
+ "aria-describedby": ariaDescribedByIds6(id),
960
+ children: Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label: label2 }, i) => {
961
+ const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
962
+ return /* @__PURE__ */ jsx19(Option, { value: String(i), disabled: disabled2, children: label2 }, i);
963
+ })
964
+ }
965
+ )
966
+ }
967
+ );
968
+ }
969
+ var SelectWidget_default = SelectWidget;
970
+
971
+ // src/TextareaWidget/TextareaWidget.tsx
972
+ import { Label as Label5, Textarea, makeStyles as makeStyles9 } from "@fluentui/react-components";
973
+ import {
974
+ ariaDescribedByIds as ariaDescribedByIds7,
975
+ labelValue as labelValue6
976
+ } from "@rjsf/utils";
977
+ import { Fragment as Fragment8, jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
978
+ var useStyles9 = makeStyles9({
979
+ label: {
980
+ paddingTop: "2px",
981
+ paddingBottom: "2px",
982
+ marginBottom: "2px"
983
+ }
984
+ });
985
+ function TextareaWidget(props) {
986
+ const {
987
+ id,
988
+ placeholder,
989
+ required,
990
+ readonly,
991
+ disabled,
992
+ value,
993
+ label,
994
+ hideLabel,
995
+ onChange,
996
+ onChangeOverride,
997
+ onBlur,
998
+ onFocus,
999
+ autofocus,
1000
+ options,
1001
+ schema
1002
+ } = props;
1003
+ const classes = useStyles9();
1004
+ const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
1005
+ const _onBlur = ({ target: { value: value2 } }) => onBlur(id, value2);
1006
+ const _onFocus = ({ target: { value: value2 } }) => onFocus(id, value2);
1007
+ let rows = 5;
1008
+ if (typeof options.rows === "string" || typeof options.rows === "number") {
1009
+ rows = options.rows;
1010
+ }
1011
+ return /* @__PURE__ */ jsxs13(Fragment8, { children: [
1012
+ labelValue6(
1013
+ /* @__PURE__ */ jsx20(Label5, { htmlFor: id, required, disabled, className: classes.label, children: label }),
1014
+ hideLabel
1015
+ ),
1016
+ /* @__PURE__ */ jsx20(
1017
+ Textarea,
1018
+ {
1019
+ id,
1020
+ name: id,
1021
+ placeholder,
1022
+ autoFocus: autofocus,
1023
+ required,
1024
+ disabled: disabled || readonly,
1025
+ value: value || value === 0 ? value : "",
1026
+ onChange: onChangeOverride || _onChange,
1027
+ onFocus: _onFocus,
1028
+ onBlur: _onBlur,
1029
+ "aria-describedby": ariaDescribedByIds7(id, !!schema.examples),
1030
+ rows
1031
+ }
1032
+ )
1033
+ ] });
1034
+ }
1035
+
1036
+ // src/Widgets/Widgets.ts
1037
+ function generateWidgets() {
1038
+ return {
1039
+ CheckboxWidget,
1040
+ CheckboxesWidget,
1041
+ RadioWidget,
1042
+ RangeWidget,
1043
+ SelectWidget: SelectWidget_default,
1044
+ TextareaWidget
1045
+ };
1046
+ }
1047
+ var Widgets_default = generateWidgets();
1048
+
1049
+ // src/Theme/Theme.ts
1050
+ function generateTheme() {
1051
+ return {
1052
+ templates: generateTemplates(),
1053
+ widgets: generateWidgets()
1054
+ };
1055
+ }
1056
+ var Theme_default = generateTheme();
1057
+
1058
+ // src/FluentForm/FluentForm.ts
1059
+ function generateForm() {
1060
+ return withTheme(generateTheme());
1061
+ }
1062
+ var FluentForm_default = generateForm();
1063
+
1064
+ // src/FluentUIRCFrameProvider.tsx
1065
+ import { FluentProvider, RendererProvider, createDOMRenderer, teamsLightTheme } from "@fluentui/react-components";
1066
+ import { useMemo } from "react";
1067
+ import { jsx as jsx21 } from "react/jsx-runtime";
1068
+ var FluentWrapper = (props) => {
1069
+ const { children, targetDocument } = props;
1070
+ const renderer = useMemo(() => createDOMRenderer(targetDocument), [targetDocument]);
1071
+ return /* @__PURE__ */ jsx21(RendererProvider, { renderer, targetDocument, children: /* @__PURE__ */ jsx21(FluentProvider, { targetDocument, theme: teamsLightTheme, children }) });
1072
+ };
1073
+ var __createFluentUIRCFrameProvider = (props) => ({ document }) => {
1074
+ return /* @__PURE__ */ jsx21(FluentWrapper, { targetDocument: document, children: props.children });
1075
+ };
1076
+
1077
+ // src/index.ts
1078
+ var src_default = FluentForm_default;
1079
+ export {
1080
+ FluentForm_default as Form,
1081
+ Templates_default as Templates,
1082
+ Theme_default as Theme,
1083
+ Widgets_default as Widgets,
1084
+ __createFluentUIRCFrameProvider,
1085
+ src_default as default,
1086
+ generateForm,
1087
+ generateTemplates,
1088
+ generateTheme,
1089
+ generateWidgets
1090
+ };
1091
+ //# sourceMappingURL=index.esm.js.map