@scm-manager/ui-forms 2.44.2 → 2.44.3-20230527-064447
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/.turbo/turbo-build.log +7 -7
- package/build/index.d.ts +106 -45
- package/build/index.js +525 -255
- package/build/index.mjs +396 -122
- package/package.json +7 -6
- package/src/Form.stories.tsx +22 -0
- package/src/chip-input/ChipInputField.stories.tsx +41 -12
- package/src/chip-input/ChipInputField.tsx +83 -56
- package/src/chip-input/ControlledChipInputField.tsx +12 -4
- package/src/combobox/Combobox.stories.tsx +96 -0
- package/src/combobox/Combobox.tsx +217 -0
- package/src/combobox/ComboboxField.tsx +62 -0
- package/src/combobox/ControlledComboboxField.tsx +96 -0
- package/src/headless-chip-input/ChipInput.tsx +127 -59
- package/src/helpers.ts +23 -0
- package/src/index.ts +4 -0
package/build/index.js
CHANGED
|
@@ -27,6 +27,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
27
27
|
var src_exports = {};
|
|
28
28
|
__export(src_exports, {
|
|
29
29
|
ChipInputField: () => ChipInputField_default,
|
|
30
|
+
Combobox: () => Combobox_default,
|
|
31
|
+
ComboboxField: () => ComboboxField_default,
|
|
30
32
|
ConfigurationForm: () => ConfigurationForm_default,
|
|
31
33
|
Form: () => Form2,
|
|
32
34
|
Select: () => Select_default,
|
|
@@ -38,7 +40,7 @@ __export(src_exports, {
|
|
|
38
40
|
module.exports = __toCommonJS(src_exports);
|
|
39
41
|
|
|
40
42
|
// src/Form.tsx
|
|
41
|
-
var
|
|
43
|
+
var import_react3 = __toESM(require("react"));
|
|
42
44
|
var import_react_hook_form = require("react-hook-form");
|
|
43
45
|
var import_ui_components = require("@scm-manager/ui-components");
|
|
44
46
|
|
|
@@ -60,6 +62,7 @@ var import_ui_buttons = require("@scm-manager/ui-buttons");
|
|
|
60
62
|
var import_styled_components = __toESM(require("styled-components"));
|
|
61
63
|
|
|
62
64
|
// src/helpers.ts
|
|
65
|
+
var import_react2 = require("react");
|
|
63
66
|
function prefixWithoutIndices(path) {
|
|
64
67
|
return path.replace(/(\.\d+)/g, "");
|
|
65
68
|
}
|
|
@@ -77,6 +80,21 @@ function setValues(newValues, setValue, path = "") {
|
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
83
|
+
function withForwardRef(component) {
|
|
84
|
+
return (0, import_react2.forwardRef)(component);
|
|
85
|
+
}
|
|
86
|
+
var defaultOptionFactory = (item) => typeof item === "object" && item !== null && "value" in item && typeof item["label"] === "string" ? item : { label: item, value: item };
|
|
87
|
+
function mergeRefs(...refs) {
|
|
88
|
+
return (el) => refs.forEach((ref) => {
|
|
89
|
+
if (ref) {
|
|
90
|
+
if (typeof ref === "function") {
|
|
91
|
+
ref(el);
|
|
92
|
+
} else {
|
|
93
|
+
ref.current = el;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
80
98
|
|
|
81
99
|
// src/Form.tsx
|
|
82
100
|
var ButtonsContainer = import_styled_components.default.div`
|
|
@@ -87,9 +105,9 @@ var SuccessNotification = ({ label, hide }) => {
|
|
|
87
105
|
if (!label) {
|
|
88
106
|
return null;
|
|
89
107
|
}
|
|
90
|
-
return /* @__PURE__ */
|
|
108
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
91
109
|
className: "notification is-success"
|
|
92
|
-
}, /* @__PURE__ */
|
|
110
|
+
}, /* @__PURE__ */ import_react3.default.createElement("button", {
|
|
93
111
|
className: "delete",
|
|
94
112
|
onClick: hide
|
|
95
113
|
}), label);
|
|
@@ -113,7 +131,7 @@ function Form({
|
|
|
113
131
|
const [ns, prefix] = translationPath;
|
|
114
132
|
const { t } = (0, import_react_i18next.useTranslation)(ns, { keyPrefix: prefix });
|
|
115
133
|
const [defaultTranslate] = (0, import_react_i18next.useTranslation)("commons", { keyPrefix: "form" });
|
|
116
|
-
const translateWithFallback = (0,
|
|
134
|
+
const translateWithFallback = (0, import_react3.useCallback)(
|
|
117
135
|
(key, ...args) => {
|
|
118
136
|
const translation = t(key, ...args);
|
|
119
137
|
if (translation === `${prefix}.${key}`) {
|
|
@@ -124,31 +142,31 @@ function Form({
|
|
|
124
142
|
[prefix, t]
|
|
125
143
|
);
|
|
126
144
|
const { isDirty, isValid, isSubmitting, isSubmitSuccessful } = formState;
|
|
127
|
-
const [error, setError] = (0,
|
|
128
|
-
const [showSuccessNotification, setShowSuccessNotification] = (0,
|
|
145
|
+
const [error, setError] = (0, import_react3.useState)();
|
|
146
|
+
const [showSuccessNotification, setShowSuccessNotification] = (0, import_react3.useState)(false);
|
|
129
147
|
const submitButtonLabel = t("submit", { defaultValue: defaultTranslate("submit") });
|
|
130
148
|
const resetButtonLabel = t("reset", { defaultValue: defaultTranslate("reset") });
|
|
131
149
|
const discardChangesButtonLabel = t("discardChanges", { defaultValue: defaultTranslate("discardChanges") });
|
|
132
150
|
const successNotification = translateWithFallback("submit-success-notification", {
|
|
133
151
|
defaultValue: successMessageFallback
|
|
134
152
|
});
|
|
135
|
-
const overwriteValues = (0,
|
|
153
|
+
const overwriteValues = (0, import_react3.useCallback)(() => {
|
|
136
154
|
if (withResetTo) {
|
|
137
155
|
setValues(withResetTo, setValue);
|
|
138
156
|
}
|
|
139
157
|
}, [setValue, withResetTo]);
|
|
140
|
-
(0,
|
|
158
|
+
(0, import_react3.useEffect)(() => {
|
|
141
159
|
if (isSubmitSuccessful) {
|
|
142
160
|
setShowSuccessNotification(true);
|
|
143
161
|
}
|
|
144
162
|
}, [isSubmitSuccessful]);
|
|
145
|
-
(0,
|
|
146
|
-
(0,
|
|
163
|
+
(0, import_react3.useEffect)(() => reset(defaultValues), [defaultValues, reset]);
|
|
164
|
+
(0, import_react3.useEffect)(() => {
|
|
147
165
|
if (isDirty) {
|
|
148
166
|
setShowSuccessNotification(false);
|
|
149
167
|
}
|
|
150
168
|
}, [isDirty]);
|
|
151
|
-
const submit = (0,
|
|
169
|
+
const submit = (0, import_react3.useCallback)(
|
|
152
170
|
async (data) => {
|
|
153
171
|
setError(null);
|
|
154
172
|
try {
|
|
@@ -163,34 +181,34 @@ function Form({
|
|
|
163
181
|
},
|
|
164
182
|
[onSubmit]
|
|
165
183
|
);
|
|
166
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ import_react3.default.createElement(ScmFormContextProvider, {
|
|
167
185
|
...form,
|
|
168
186
|
readOnly: isSubmitting || readOnly,
|
|
169
187
|
t: translateWithFallback,
|
|
170
188
|
formId: prefix
|
|
171
|
-
}, /* @__PURE__ */
|
|
189
|
+
}, /* @__PURE__ */ import_react3.default.createElement("form", {
|
|
172
190
|
onSubmit: handleSubmit(submit),
|
|
173
191
|
onReset: () => reset(),
|
|
174
192
|
id: prefix,
|
|
175
193
|
noValidate: true
|
|
176
|
-
}), showSuccessNotification ? /* @__PURE__ */
|
|
194
|
+
}), showSuccessNotification ? /* @__PURE__ */ import_react3.default.createElement(SuccessNotification, {
|
|
177
195
|
label: successNotification,
|
|
178
196
|
hide: () => setShowSuccessNotification(false)
|
|
179
|
-
}) : null, typeof children === "function" ? children(form) : children, error ? /* @__PURE__ */
|
|
197
|
+
}) : null, typeof children === "function" ? children(form) : children, error ? /* @__PURE__ */ import_react3.default.createElement(import_ui_components.ErrorNotification, {
|
|
180
198
|
error
|
|
181
|
-
}) : null, !readOnly ? /* @__PURE__ */
|
|
182
|
-
right: /* @__PURE__ */
|
|
199
|
+
}) : null, !readOnly ? /* @__PURE__ */ import_react3.default.createElement(import_ui_components.Level, {
|
|
200
|
+
right: /* @__PURE__ */ import_react3.default.createElement(ButtonsContainer, null, /* @__PURE__ */ import_react3.default.createElement(import_ui_buttons.Button, {
|
|
183
201
|
type: "submit",
|
|
184
202
|
variant: "primary",
|
|
185
203
|
testId: submitButtonTestId ?? "submit-button",
|
|
186
204
|
disabled: !isDirty || !isValid,
|
|
187
205
|
isLoading: isSubmitting,
|
|
188
206
|
form: prefix
|
|
189
|
-
}, submitButtonLabel), withDiscardChanges ? /* @__PURE__ */
|
|
207
|
+
}, submitButtonLabel), withDiscardChanges ? /* @__PURE__ */ import_react3.default.createElement(import_ui_buttons.Button, {
|
|
190
208
|
type: "reset",
|
|
191
209
|
form: prefix,
|
|
192
210
|
testId: `${prefix}-discard-changes-button`
|
|
193
|
-
}, discardChangesButtonLabel) : null, withResetTo ? /* @__PURE__ */
|
|
211
|
+
}, discardChangesButtonLabel) : null, withResetTo ? /* @__PURE__ */ import_react3.default.createElement(import_ui_buttons.Button, {
|
|
194
212
|
form: prefix,
|
|
195
213
|
onClick: overwriteValues,
|
|
196
214
|
testId: `${prefix}-reset-button`
|
|
@@ -200,10 +218,10 @@ function Form({
|
|
|
200
218
|
var Form_default = Form;
|
|
201
219
|
|
|
202
220
|
// src/FormRow.tsx
|
|
203
|
-
var
|
|
221
|
+
var import_react4 = __toESM(require("react"));
|
|
204
222
|
var import_classnames = __toESM(require("classnames"));
|
|
205
|
-
var FormRow =
|
|
206
|
-
({ className, children, hidden, ...rest }, ref) => hidden ? null : /* @__PURE__ */
|
|
223
|
+
var FormRow = import_react4.default.forwardRef(
|
|
224
|
+
({ className, children, hidden, ...rest }, ref) => hidden ? null : /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
207
225
|
ref,
|
|
208
226
|
className: (0, import_classnames.default)("columns", className),
|
|
209
227
|
...rest
|
|
@@ -212,58 +230,58 @@ var FormRow = import_react3.default.forwardRef(
|
|
|
212
230
|
var FormRow_default = FormRow;
|
|
213
231
|
|
|
214
232
|
// src/input/ControlledInputField.tsx
|
|
215
|
-
var
|
|
233
|
+
var import_react13 = __toESM(require("react"));
|
|
216
234
|
var import_react_hook_form2 = require("react-hook-form");
|
|
217
235
|
|
|
218
236
|
// src/input/InputField.tsx
|
|
219
|
-
var
|
|
237
|
+
var import_react11 = __toESM(require("react"));
|
|
220
238
|
|
|
221
239
|
// src/base/Field.tsx
|
|
222
|
-
var
|
|
240
|
+
var import_react5 = __toESM(require("react"));
|
|
223
241
|
var import_classnames2 = __toESM(require("classnames"));
|
|
224
|
-
var Field = ({ className, children, ...rest }) => /* @__PURE__ */
|
|
242
|
+
var Field = ({ className, children, ...rest }) => /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
225
243
|
className: (0, import_classnames2.default)("field", className),
|
|
226
244
|
...rest
|
|
227
245
|
}, children);
|
|
228
246
|
var Field_default = Field;
|
|
229
247
|
|
|
230
248
|
// src/base/Control.tsx
|
|
231
|
-
var
|
|
249
|
+
var import_react6 = __toESM(require("react"));
|
|
232
250
|
var import_classnames3 = __toESM(require("classnames"));
|
|
233
|
-
var Control = ({ className, children, ...rest }) => /* @__PURE__ */
|
|
251
|
+
var Control = ({ className, children, ...rest }) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
234
252
|
className: (0, import_classnames3.default)("control", className),
|
|
235
253
|
...rest
|
|
236
254
|
}, children);
|
|
237
255
|
var Control_default = Control;
|
|
238
256
|
|
|
239
257
|
// src/base/label/Label.tsx
|
|
240
|
-
var
|
|
258
|
+
var import_react7 = __toESM(require("react"));
|
|
241
259
|
var import_classnames4 = __toESM(require("classnames"));
|
|
242
|
-
var Label = ({ className, children, ...rest }) => /* @__PURE__ */
|
|
260
|
+
var Label = ({ className, children, ...rest }) => /* @__PURE__ */ import_react7.default.createElement("label", {
|
|
243
261
|
className: (0, import_classnames4.default)("label", className),
|
|
244
262
|
...rest
|
|
245
263
|
}, children);
|
|
246
264
|
var Label_default = Label;
|
|
247
265
|
|
|
248
266
|
// src/base/field-message/FieldMessage.tsx
|
|
249
|
-
var
|
|
267
|
+
var import_react8 = __toESM(require("react"));
|
|
250
268
|
var import_classnames5 = __toESM(require("classnames"));
|
|
251
269
|
|
|
252
270
|
// src/variants.ts
|
|
253
271
|
var createVariantClass = (variant) => variant ? `is-${variant}` : void 0;
|
|
254
272
|
|
|
255
273
|
// src/base/field-message/FieldMessage.tsx
|
|
256
|
-
var FieldMessage = ({ variant, className, children }) => /* @__PURE__ */
|
|
274
|
+
var FieldMessage = ({ variant, className, children }) => /* @__PURE__ */ import_react8.default.createElement("p", {
|
|
257
275
|
className: (0, import_classnames5.default)("help", createVariantClass(variant), className)
|
|
258
276
|
}, children);
|
|
259
277
|
var FieldMessage_default = FieldMessage;
|
|
260
278
|
|
|
261
279
|
// src/input/Input.tsx
|
|
262
|
-
var
|
|
280
|
+
var import_react9 = __toESM(require("react"));
|
|
263
281
|
var import_classnames6 = __toESM(require("classnames"));
|
|
264
282
|
var import_ui_components2 = require("@scm-manager/ui-components");
|
|
265
|
-
var Input =
|
|
266
|
-
return /* @__PURE__ */
|
|
283
|
+
var Input = import_react9.default.forwardRef(({ variant, className, testId, ...props }, ref) => {
|
|
284
|
+
return /* @__PURE__ */ import_react9.default.createElement("input", {
|
|
267
285
|
ref,
|
|
268
286
|
className: (0, import_classnames6.default)("input", createVariantClass(variant), className),
|
|
269
287
|
...props,
|
|
@@ -273,12 +291,12 @@ var Input = import_react8.default.forwardRef(({ variant, className, testId, ...p
|
|
|
273
291
|
var Input_default = Input;
|
|
274
292
|
|
|
275
293
|
// src/base/help/Help.tsx
|
|
276
|
-
var
|
|
294
|
+
var import_react10 = __toESM(require("react"));
|
|
277
295
|
var import_ui_overlays = require("@scm-manager/ui-overlays");
|
|
278
|
-
var Help = ({ text, className }) => /* @__PURE__ */
|
|
296
|
+
var Help = ({ text, className }) => /* @__PURE__ */ import_react10.default.createElement(import_ui_overlays.Tooltip, {
|
|
279
297
|
className,
|
|
280
298
|
message: text
|
|
281
|
-
}, /* @__PURE__ */
|
|
299
|
+
}, /* @__PURE__ */ import_react10.default.createElement("i", {
|
|
282
300
|
className: "fas fa-fw fa-question-circle has-text-blue-light",
|
|
283
301
|
"aria-hidden": true
|
|
284
302
|
}));
|
|
@@ -286,23 +304,23 @@ var Help_default = Help;
|
|
|
286
304
|
|
|
287
305
|
// src/input/InputField.tsx
|
|
288
306
|
var import_ui_components3 = require("@scm-manager/ui-components");
|
|
289
|
-
var InputField =
|
|
307
|
+
var InputField = import_react11.default.forwardRef(
|
|
290
308
|
({ label, helpText, error, className, id, ...props }, ref) => {
|
|
291
309
|
const inputId = (0, import_ui_components3.useGeneratedId)(id ?? props.testId);
|
|
292
310
|
const variant = error ? "danger" : void 0;
|
|
293
|
-
return /* @__PURE__ */
|
|
311
|
+
return /* @__PURE__ */ import_react11.default.createElement(Field_default, {
|
|
294
312
|
className
|
|
295
|
-
}, /* @__PURE__ */
|
|
313
|
+
}, /* @__PURE__ */ import_react11.default.createElement(Label_default, {
|
|
296
314
|
htmlFor: inputId
|
|
297
|
-
}, label, helpText ? /* @__PURE__ */
|
|
315
|
+
}, label, helpText ? /* @__PURE__ */ import_react11.default.createElement(Help_default, {
|
|
298
316
|
className: "ml-1",
|
|
299
317
|
text: helpText
|
|
300
|
-
}) : null), /* @__PURE__ */
|
|
318
|
+
}) : null), /* @__PURE__ */ import_react11.default.createElement(Control_default, null, /* @__PURE__ */ import_react11.default.createElement(Input_default, {
|
|
301
319
|
variant,
|
|
302
320
|
ref,
|
|
303
321
|
id: inputId,
|
|
304
322
|
...props
|
|
305
|
-
})), error ? /* @__PURE__ */
|
|
323
|
+
})), error ? /* @__PURE__ */ import_react11.default.createElement(FieldMessage_default, {
|
|
306
324
|
variant
|
|
307
325
|
}, error) : null);
|
|
308
326
|
}
|
|
@@ -310,18 +328,18 @@ var InputField = import_react10.default.forwardRef(
|
|
|
310
328
|
var InputField_default = InputField;
|
|
311
329
|
|
|
312
330
|
// src/FormPathContext.tsx
|
|
313
|
-
var
|
|
314
|
-
var ScmFormPathContext =
|
|
331
|
+
var import_react12 = __toESM(require("react"));
|
|
332
|
+
var ScmFormPathContext = import_react12.default.createContext("");
|
|
315
333
|
function useScmFormPathContext() {
|
|
316
|
-
return (0,
|
|
334
|
+
return (0, import_react12.useContext)(ScmFormPathContext);
|
|
317
335
|
}
|
|
318
|
-
var ScmFormPathContextProvider = ({ children, path }) => /* @__PURE__ */
|
|
336
|
+
var ScmFormPathContextProvider = ({ children, path }) => /* @__PURE__ */ import_react12.default.createElement(ScmFormPathContext.Provider, {
|
|
319
337
|
value: path
|
|
320
338
|
}, children);
|
|
321
339
|
var ScmNestedFormPathContextProvider = ({ children, path }) => {
|
|
322
340
|
const prefix = useScmFormPathContext();
|
|
323
|
-
const pathWithPrefix = (0,
|
|
324
|
-
return /* @__PURE__ */
|
|
341
|
+
const pathWithPrefix = (0, import_react12.useMemo)(() => prefix ? `${prefix}.${path}` : path, [path, prefix]);
|
|
342
|
+
return /* @__PURE__ */ import_react12.default.createElement(ScmFormPathContext.Provider, {
|
|
325
343
|
value: pathWithPrefix
|
|
326
344
|
}, children);
|
|
327
345
|
};
|
|
@@ -345,12 +363,12 @@ function ControlledInputField({
|
|
|
345
363
|
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
346
364
|
const labelTranslation = label || t(`${prefixedNameWithoutIndices}.label`) || "";
|
|
347
365
|
const helpTextTranslation = helpText || t(`${prefixedNameWithoutIndices}.helpText`);
|
|
348
|
-
return /* @__PURE__ */
|
|
366
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react_hook_form2.Controller, {
|
|
349
367
|
control,
|
|
350
368
|
name: nameWithPrefix,
|
|
351
369
|
rules,
|
|
352
370
|
defaultValue,
|
|
353
|
-
render: ({ field, fieldState }) => /* @__PURE__ */
|
|
371
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ import_react13.default.createElement(InputField_default, {
|
|
354
372
|
readOnly: readOnly ?? formReadonly,
|
|
355
373
|
required: rules == null ? void 0 : rules.required,
|
|
356
374
|
className: (0, import_classnames7.default)("column", className),
|
|
@@ -367,20 +385,20 @@ function ControlledInputField({
|
|
|
367
385
|
var ControlledInputField_default = ControlledInputField;
|
|
368
386
|
|
|
369
387
|
// src/checkbox/ControlledCheckboxField.tsx
|
|
370
|
-
var
|
|
388
|
+
var import_react16 = __toESM(require("react"));
|
|
371
389
|
var import_react_hook_form3 = require("react-hook-form");
|
|
372
390
|
|
|
373
391
|
// src/checkbox/CheckboxField.tsx
|
|
374
|
-
var
|
|
392
|
+
var import_react15 = __toESM(require("react"));
|
|
375
393
|
|
|
376
394
|
// src/checkbox/Checkbox.tsx
|
|
377
|
-
var
|
|
395
|
+
var import_react14 = __toESM(require("react"));
|
|
378
396
|
var import_ui_components4 = require("@scm-manager/ui-components");
|
|
379
|
-
var Checkbox =
|
|
380
|
-
({ readOnly, label, value, name, checked, defaultChecked, defaultValue, testId, helpText, ...props }, ref) => /* @__PURE__ */
|
|
397
|
+
var Checkbox = import_react14.default.forwardRef(
|
|
398
|
+
({ readOnly, label, value, name, checked, defaultChecked, defaultValue, testId, helpText, ...props }, ref) => /* @__PURE__ */ import_react14.default.createElement("label", {
|
|
381
399
|
className: "checkbox",
|
|
382
400
|
disabled: readOnly || props.disabled
|
|
383
|
-
}, readOnly ? /* @__PURE__ */
|
|
401
|
+
}, readOnly ? /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("input", {
|
|
384
402
|
type: "hidden",
|
|
385
403
|
name,
|
|
386
404
|
value,
|
|
@@ -388,7 +406,7 @@ var Checkbox = import_react13.default.forwardRef(
|
|
|
388
406
|
checked,
|
|
389
407
|
defaultChecked,
|
|
390
408
|
readOnly: true
|
|
391
|
-
}), /* @__PURE__ */
|
|
409
|
+
}), /* @__PURE__ */ import_react14.default.createElement("input", {
|
|
392
410
|
type: "checkbox",
|
|
393
411
|
className: "mr-1",
|
|
394
412
|
ref,
|
|
@@ -399,7 +417,7 @@ var Checkbox = import_react13.default.forwardRef(
|
|
|
399
417
|
...props,
|
|
400
418
|
...(0, import_ui_components4.createAttributesForTesting)(testId),
|
|
401
419
|
disabled: true
|
|
402
|
-
})) : /* @__PURE__ */
|
|
420
|
+
})) : /* @__PURE__ */ import_react14.default.createElement("input", {
|
|
403
421
|
type: "checkbox",
|
|
404
422
|
className: "mr-1",
|
|
405
423
|
ref,
|
|
@@ -410,7 +428,7 @@ var Checkbox = import_react13.default.forwardRef(
|
|
|
410
428
|
defaultChecked,
|
|
411
429
|
...props,
|
|
412
430
|
...(0, import_ui_components4.createAttributesForTesting)(testId)
|
|
413
|
-
}), label, helpText ? /* @__PURE__ */
|
|
431
|
+
}), label, helpText ? /* @__PURE__ */ import_react14.default.createElement(Help_default, {
|
|
414
432
|
className: "ml-1",
|
|
415
433
|
text: helpText
|
|
416
434
|
}) : null)
|
|
@@ -418,9 +436,9 @@ var Checkbox = import_react13.default.forwardRef(
|
|
|
418
436
|
var Checkbox_default = Checkbox;
|
|
419
437
|
|
|
420
438
|
// src/checkbox/CheckboxField.tsx
|
|
421
|
-
var CheckboxField =
|
|
439
|
+
var CheckboxField = import_react15.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ import_react15.default.createElement(Field_default, {
|
|
422
440
|
className
|
|
423
|
-
}, /* @__PURE__ */
|
|
441
|
+
}, /* @__PURE__ */ import_react15.default.createElement(Control_default, null, /* @__PURE__ */ import_react15.default.createElement(Checkbox_default, {
|
|
424
442
|
ref,
|
|
425
443
|
...props
|
|
426
444
|
}))));
|
|
@@ -445,12 +463,12 @@ function ControlledInputField2({
|
|
|
445
463
|
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
446
464
|
const labelTranslation = label || t(`${prefixedNameWithoutIndices}.label`) || "";
|
|
447
465
|
const helpTextTranslation = helpText || t(`${prefixedNameWithoutIndices}.helpText`);
|
|
448
|
-
return /* @__PURE__ */
|
|
466
|
+
return /* @__PURE__ */ import_react16.default.createElement(import_react_hook_form3.Controller, {
|
|
449
467
|
control,
|
|
450
468
|
name: nameWithPrefix,
|
|
451
469
|
rules,
|
|
452
470
|
defaultValue: defaultChecked,
|
|
453
|
-
render: ({ field }) => /* @__PURE__ */
|
|
471
|
+
render: ({ field }) => /* @__PURE__ */ import_react16.default.createElement(CheckboxField_default, {
|
|
454
472
|
form: formId,
|
|
455
473
|
readOnly: readOnly ?? formReadonly,
|
|
456
474
|
checked: field.value,
|
|
@@ -466,7 +484,7 @@ function ControlledInputField2({
|
|
|
466
484
|
var ControlledCheckboxField_default = ControlledInputField2;
|
|
467
485
|
|
|
468
486
|
// src/input/ControlledSecretConfirmationField.tsx
|
|
469
|
-
var
|
|
487
|
+
var import_react17 = __toESM(require("react"));
|
|
470
488
|
var import_react_hook_form4 = require("react-hook-form");
|
|
471
489
|
var import_classnames9 = __toESM(require("classnames"));
|
|
472
490
|
function ControlledSecretConfirmationField({
|
|
@@ -494,17 +512,17 @@ function ControlledSecretConfirmationField({
|
|
|
494
512
|
const confirmationHelpTextTranslation = confirmationHelpText || t(`${prefixedNameWithoutIndices}.confirmation.helpText`);
|
|
495
513
|
const confirmationErrorMessageTranslation = confirmationErrorMessage || t(`${prefixedNameWithoutIndices}.confirmation.errorMessage`);
|
|
496
514
|
const secretValue = watch(nameWithPrefix);
|
|
497
|
-
const validateConfirmField = (0,
|
|
515
|
+
const validateConfirmField = (0, import_react17.useCallback)(
|
|
498
516
|
(value) => secretValue === value || confirmationErrorMessageTranslation,
|
|
499
517
|
[confirmationErrorMessageTranslation, secretValue]
|
|
500
518
|
);
|
|
501
|
-
const confirmFieldRules = (0,
|
|
519
|
+
const confirmFieldRules = (0, import_react17.useMemo)(
|
|
502
520
|
() => ({
|
|
503
521
|
validate: validateConfirmField
|
|
504
522
|
}),
|
|
505
523
|
[validateConfirmField]
|
|
506
524
|
);
|
|
507
|
-
return /* @__PURE__ */
|
|
525
|
+
return /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, /* @__PURE__ */ import_react17.default.createElement(import_react_hook_form4.Controller, {
|
|
508
526
|
control,
|
|
509
527
|
name: nameWithPrefix,
|
|
510
528
|
defaultValue,
|
|
@@ -512,7 +530,7 @@ function ControlledSecretConfirmationField({
|
|
|
512
530
|
...rules,
|
|
513
531
|
deps: [`${nameWithPrefix}Confirmation`]
|
|
514
532
|
},
|
|
515
|
-
render: ({ field, fieldState }) => /* @__PURE__ */
|
|
533
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ import_react17.default.createElement(InputField_default, {
|
|
516
534
|
className: (0, import_classnames9.default)("column", className),
|
|
517
535
|
readOnly: readOnly ?? formReadonly,
|
|
518
536
|
...props,
|
|
@@ -525,11 +543,11 @@ function ControlledSecretConfirmationField({
|
|
|
525
543
|
error: fieldState.error ? fieldState.error.message || t(`${prefixedNameWithoutIndices}.error.${fieldState.error.type}`) : void 0,
|
|
526
544
|
testId: testId ?? `input-${nameWithPrefix}`
|
|
527
545
|
})
|
|
528
|
-
}), /* @__PURE__ */
|
|
546
|
+
}), /* @__PURE__ */ import_react17.default.createElement(import_react_hook_form4.Controller, {
|
|
529
547
|
control,
|
|
530
548
|
name: `${nameWithPrefix}Confirmation`,
|
|
531
549
|
defaultValue,
|
|
532
|
-
render: ({ field, fieldState: { error } }) => /* @__PURE__ */
|
|
550
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ import_react17.default.createElement(InputField_default, {
|
|
533
551
|
className: (0, import_classnames9.default)("column", className),
|
|
534
552
|
type: "password",
|
|
535
553
|
readOnly: readOnly ?? formReadonly,
|
|
@@ -546,25 +564,25 @@ function ControlledSecretConfirmationField({
|
|
|
546
564
|
}
|
|
547
565
|
|
|
548
566
|
// src/select/ControlledSelectField.tsx
|
|
549
|
-
var
|
|
567
|
+
var import_react20 = __toESM(require("react"));
|
|
550
568
|
var import_react_hook_form5 = require("react-hook-form");
|
|
551
569
|
|
|
552
570
|
// src/select/SelectField.tsx
|
|
553
|
-
var
|
|
571
|
+
var import_react19 = __toESM(require("react"));
|
|
554
572
|
|
|
555
573
|
// src/select/Select.tsx
|
|
556
|
-
var
|
|
574
|
+
var import_react18 = __toESM(require("react"));
|
|
557
575
|
var import_classnames10 = __toESM(require("classnames"));
|
|
558
576
|
var import_ui_components5 = require("@scm-manager/ui-components");
|
|
559
|
-
var Select =
|
|
560
|
-
({ variant, children, className, options, testId, ...props }, ref) => /* @__PURE__ */
|
|
577
|
+
var Select = import_react18.default.forwardRef(
|
|
578
|
+
({ variant, children, className, options, testId, ...props }, ref) => /* @__PURE__ */ import_react18.default.createElement("div", {
|
|
561
579
|
className: (0, import_classnames10.default)("select", { "is-multiple": props.multiple }, createVariantClass(variant), className)
|
|
562
|
-
}, /* @__PURE__ */
|
|
580
|
+
}, /* @__PURE__ */ import_react18.default.createElement("select", {
|
|
563
581
|
ref,
|
|
564
582
|
...props,
|
|
565
583
|
...(0, import_ui_components5.createAttributesForTesting)(testId),
|
|
566
584
|
className
|
|
567
|
-
}, options ? options.map((opt) => /* @__PURE__ */
|
|
585
|
+
}, options ? options.map((opt) => /* @__PURE__ */ import_react18.default.createElement("option", {
|
|
568
586
|
...opt,
|
|
569
587
|
key: opt.value
|
|
570
588
|
}, opt.label, opt.children)) : children))
|
|
@@ -573,24 +591,24 @@ var Select_default = Select;
|
|
|
573
591
|
|
|
574
592
|
// src/select/SelectField.tsx
|
|
575
593
|
var import_ui_components6 = require("@scm-manager/ui-components");
|
|
576
|
-
var SelectField =
|
|
594
|
+
var SelectField = import_react19.default.forwardRef(
|
|
577
595
|
({ label, helpText, error, className, id, ...props }, ref) => {
|
|
578
596
|
const selectId = (0, import_ui_components6.useGeneratedId)(id ?? props.testId);
|
|
579
597
|
const variant = error ? "danger" : void 0;
|
|
580
|
-
return /* @__PURE__ */
|
|
598
|
+
return /* @__PURE__ */ import_react19.default.createElement(Field_default, {
|
|
581
599
|
className
|
|
582
|
-
}, /* @__PURE__ */
|
|
600
|
+
}, /* @__PURE__ */ import_react19.default.createElement(Label_default, {
|
|
583
601
|
htmlFor: selectId
|
|
584
|
-
}, label, helpText ? /* @__PURE__ */
|
|
602
|
+
}, label, helpText ? /* @__PURE__ */ import_react19.default.createElement(Help_default, {
|
|
585
603
|
className: "ml-1",
|
|
586
604
|
text: helpText
|
|
587
|
-
}) : null), /* @__PURE__ */
|
|
605
|
+
}) : null), /* @__PURE__ */ import_react19.default.createElement(Control_default, null, /* @__PURE__ */ import_react19.default.createElement(Select_default, {
|
|
588
606
|
id: selectId,
|
|
589
607
|
variant,
|
|
590
608
|
ref,
|
|
591
609
|
className: "is-full-width",
|
|
592
610
|
...props
|
|
593
|
-
})), error ? /* @__PURE__ */
|
|
611
|
+
})), error ? /* @__PURE__ */ import_react19.default.createElement(FieldMessage_default, {
|
|
594
612
|
variant
|
|
595
613
|
}, error) : null);
|
|
596
614
|
}
|
|
@@ -616,12 +634,12 @@ function ControlledSelectField({
|
|
|
616
634
|
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
617
635
|
const labelTranslation = label || t(`${prefixedNameWithoutIndices}.label`) || "";
|
|
618
636
|
const helpTextTranslation = helpText || t(`${prefixedNameWithoutIndices}.helpText`);
|
|
619
|
-
return /* @__PURE__ */
|
|
637
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_react_hook_form5.Controller, {
|
|
620
638
|
control,
|
|
621
639
|
name: nameWithPrefix,
|
|
622
640
|
rules,
|
|
623
641
|
defaultValue,
|
|
624
|
-
render: ({ field, fieldState }) => /* @__PURE__ */
|
|
642
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ import_react20.default.createElement(SelectField_default, {
|
|
625
643
|
form: formId,
|
|
626
644
|
readOnly: readOnly ?? formReadonly,
|
|
627
645
|
required: rules == null ? void 0 : rules.required,
|
|
@@ -638,93 +656,117 @@ function ControlledSelectField({
|
|
|
638
656
|
var ControlledSelectField_default = ControlledSelectField;
|
|
639
657
|
|
|
640
658
|
// src/chip-input/ControlledChipInputField.tsx
|
|
641
|
-
var
|
|
659
|
+
var import_react23 = __toESM(require("react"));
|
|
642
660
|
var import_react_hook_form6 = require("react-hook-form");
|
|
643
661
|
var import_classnames13 = __toESM(require("classnames"));
|
|
644
662
|
|
|
645
663
|
// src/chip-input/ChipInputField.tsx
|
|
646
|
-
var
|
|
664
|
+
var import_react22 = __toESM(require("react"));
|
|
647
665
|
var import_ui_components7 = require("@scm-manager/ui-components");
|
|
648
666
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
649
667
|
var import_classnames12 = __toESM(require("classnames"));
|
|
650
668
|
|
|
651
669
|
// src/headless-chip-input/ChipInput.tsx
|
|
652
|
-
var
|
|
670
|
+
var import_react21 = __toESM(require("react"));
|
|
653
671
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
654
|
-
var ChipInputContext = (0,
|
|
655
|
-
|
|
656
|
-
|
|
672
|
+
var ChipInputContext = (0, import_react21.createContext)(null);
|
|
673
|
+
function getChipInputContext() {
|
|
674
|
+
return ChipInputContext;
|
|
675
|
+
}
|
|
676
|
+
var DefaultNewChipInput = import_react21.default.forwardRef(
|
|
677
|
+
({ onChange, value, ...props }, ref) => {
|
|
678
|
+
const handleKeyDown = (0, import_react21.useCallback)(
|
|
679
|
+
(e) => {
|
|
680
|
+
if (e.key === "Enter") {
|
|
681
|
+
e.preventDefault();
|
|
682
|
+
if (e.currentTarget.value) {
|
|
683
|
+
onChange({ label: e.currentTarget.value, value: e.currentTarget.value });
|
|
684
|
+
}
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
[onChange]
|
|
689
|
+
);
|
|
690
|
+
return /* @__PURE__ */ import_react21.default.createElement("div", {
|
|
691
|
+
className: "is-flex-grow-1"
|
|
692
|
+
}, /* @__PURE__ */ import_react21.default.createElement("input", {
|
|
693
|
+
onKeyDown: handleKeyDown,
|
|
694
|
+
...props,
|
|
695
|
+
ref
|
|
696
|
+
}));
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
var ChipDelete = import_react21.default.forwardRef(({ asChild, index, ...props }, ref) => {
|
|
700
|
+
const { remove, disabled } = (0, import_react21.useContext)(ChipInputContext);
|
|
657
701
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
658
702
|
if (disabled) {
|
|
659
703
|
return null;
|
|
660
704
|
}
|
|
661
|
-
return /* @__PURE__ */
|
|
705
|
+
return /* @__PURE__ */ import_react21.default.createElement(Comp, {
|
|
662
706
|
...props,
|
|
663
707
|
ref,
|
|
664
708
|
type: "button",
|
|
665
709
|
onClick: () => remove(index)
|
|
666
710
|
});
|
|
667
711
|
});
|
|
668
|
-
var NewChipInput =
|
|
669
|
-
const { add,
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
if (e.key === "Enter") {
|
|
673
|
-
e.preventDefault();
|
|
674
|
-
const newValue = e.currentTarget.value.trim();
|
|
675
|
-
if (newValue && !(value == null ? void 0 : value.includes(newValue))) {
|
|
676
|
-
add(newValue);
|
|
677
|
-
e.currentTarget.value = "";
|
|
678
|
-
}
|
|
679
|
-
return false;
|
|
680
|
-
}
|
|
681
|
-
},
|
|
682
|
-
[add, value]
|
|
683
|
-
);
|
|
684
|
-
const Comp = asChild ? import_react_slot.Slot : "input";
|
|
685
|
-
return /* @__PURE__ */ import_react20.default.createElement(Comp, {
|
|
712
|
+
var NewChipInput = withForwardRef(function NewChipInput2(props, ref) {
|
|
713
|
+
const { add, disabled, readOnly, inputRef } = (0, import_react21.useContext)(getChipInputContext());
|
|
714
|
+
const Comp = props.children ? import_react_slot.Slot : DefaultNewChipInput;
|
|
715
|
+
return import_react21.default.createElement(Comp, {
|
|
686
716
|
...props,
|
|
687
|
-
|
|
717
|
+
onChange: add,
|
|
688
718
|
readOnly,
|
|
689
719
|
disabled,
|
|
690
|
-
|
|
720
|
+
value: null,
|
|
721
|
+
ref: mergeRefs(ref, inputRef)
|
|
691
722
|
});
|
|
692
723
|
});
|
|
693
|
-
var Chip =
|
|
724
|
+
var Chip = import_react21.default.forwardRef(({ asChild, ...props }, ref) => {
|
|
694
725
|
const Comp = asChild ? import_react_slot.Slot : "li";
|
|
695
|
-
return /* @__PURE__ */
|
|
726
|
+
return /* @__PURE__ */ import_react21.default.createElement(Comp, {
|
|
696
727
|
...props,
|
|
697
728
|
ref
|
|
698
729
|
});
|
|
699
730
|
});
|
|
700
|
-
var ChipInput =
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
731
|
+
var ChipInput = withForwardRef(function ChipInput2({ children, value = [], disabled, readOnly, onChange, isNewItemDuplicate, ...props }, ref) {
|
|
732
|
+
const inputRef = (0, import_react21.useRef)(null);
|
|
733
|
+
const isInactive = (0, import_react21.useMemo)(() => disabled || readOnly, [disabled, readOnly]);
|
|
734
|
+
const add = (0, import_react21.useCallback)(
|
|
735
|
+
(newItem) => {
|
|
736
|
+
if (!isInactive && !(value == null ? void 0 : value.some(
|
|
737
|
+
(item) => isNewItemDuplicate ? isNewItemDuplicate(item, newItem) : item.label === newItem.label || item.value === newItem.value
|
|
738
|
+
))) {
|
|
739
|
+
if (onChange) {
|
|
740
|
+
onChange([...value ?? [], newItem]);
|
|
741
|
+
}
|
|
742
|
+
if (inputRef.current) {
|
|
743
|
+
inputRef.current.value = "";
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
[isInactive, isNewItemDuplicate, onChange, value]
|
|
748
|
+
);
|
|
749
|
+
const remove = (0, import_react21.useCallback)(
|
|
750
|
+
(index) => !isInactive && onChange && onChange(value == null ? void 0 : value.filter((_, itdx) => itdx !== index)),
|
|
751
|
+
[isInactive, onChange, value]
|
|
752
|
+
);
|
|
753
|
+
const Context2 = getChipInputContext();
|
|
754
|
+
return /* @__PURE__ */ import_react21.default.createElement(Context2.Provider, {
|
|
755
|
+
value: (0, import_react21.useMemo)(
|
|
756
|
+
() => ({
|
|
757
|
+
disabled,
|
|
758
|
+
readOnly,
|
|
759
|
+
add,
|
|
760
|
+
remove,
|
|
761
|
+
inputRef
|
|
762
|
+
}),
|
|
763
|
+
[add, disabled, readOnly, remove]
|
|
764
|
+
)
|
|
765
|
+
}, /* @__PURE__ */ import_react21.default.createElement("ul", {
|
|
766
|
+
...props,
|
|
767
|
+
ref
|
|
768
|
+
}, children));
|
|
769
|
+
});
|
|
728
770
|
var ChipInput_default = Object.assign(ChipInput, {
|
|
729
771
|
Chip: Object.assign(Chip, {
|
|
730
772
|
Delete: ChipDelete
|
|
@@ -746,78 +788,94 @@ var StyledChipInput = (0, import_styled_components2.default)(ChipInput_default)`
|
|
|
746
788
|
var StyledInput = (0, import_styled_components2.default)(NewChipInput)`
|
|
747
789
|
color: var(--scm-secondary-more-color);
|
|
748
790
|
font-size: 1rem;
|
|
791
|
+
height: initial;
|
|
792
|
+
padding: 0;
|
|
793
|
+
border-radius: 0;
|
|
749
794
|
&:focus {
|
|
750
795
|
outline: none;
|
|
751
796
|
}
|
|
752
797
|
`;
|
|
753
|
-
var
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
helpText,
|
|
757
|
-
readOnly,
|
|
758
|
-
disabled,
|
|
759
|
-
error,
|
|
760
|
-
createDeleteText,
|
|
761
|
-
onChange,
|
|
762
|
-
placeholder,
|
|
763
|
-
value,
|
|
764
|
-
className,
|
|
765
|
-
testId,
|
|
766
|
-
id,
|
|
767
|
-
...props
|
|
768
|
-
}, ref) => {
|
|
769
|
-
const [t] = (0, import_react_i18next2.useTranslation)("commons", { keyPrefix: "form.chipList" });
|
|
770
|
-
const deleteTextCallback = (0, import_react21.useCallback)(
|
|
771
|
-
(item) => createDeleteText ? createDeleteText(item) : t("delete", { item }),
|
|
772
|
-
[createDeleteText, t]
|
|
773
|
-
);
|
|
774
|
-
const inputId = (0, import_ui_components7.useGeneratedId)(id ?? testId);
|
|
775
|
-
const labelId = (0, import_ui_components7.useGeneratedId)();
|
|
776
|
-
const inputDescriptionId = (0, import_ui_components7.useGeneratedId)();
|
|
777
|
-
const variant = error ? "danger" : void 0;
|
|
778
|
-
return /* @__PURE__ */ import_react21.default.createElement(Field_default, {
|
|
779
|
-
className,
|
|
780
|
-
"aria-owns": inputId
|
|
781
|
-
}, /* @__PURE__ */ import_react21.default.createElement(Label_default, {
|
|
782
|
-
id: labelId
|
|
783
|
-
}, label, helpText ? /* @__PURE__ */ import_react21.default.createElement(Help_default, {
|
|
784
|
-
className: "ml-1",
|
|
785
|
-
text: helpText
|
|
786
|
-
}) : null), /* @__PURE__ */ import_react21.default.createElement(StyledChipInput, {
|
|
787
|
-
value,
|
|
788
|
-
onChange,
|
|
789
|
-
className: "is-flex is-flex-wrap-wrap input",
|
|
790
|
-
"aria-labelledby": labelId,
|
|
791
|
-
disabled: readOnly || disabled
|
|
792
|
-
}, value == null ? void 0 : value.map((val, index) => /* @__PURE__ */ import_react21.default.createElement(ChipInput_default.Chip, {
|
|
793
|
-
key: `${val}-${index}`,
|
|
794
|
-
className: "tag is-light"
|
|
795
|
-
}, val, /* @__PURE__ */ import_react21.default.createElement(ChipInput_default.Chip.Delete, {
|
|
796
|
-
"aria-label": deleteTextCallback(val),
|
|
797
|
-
index,
|
|
798
|
-
className: "delete is-small"
|
|
799
|
-
}))), /* @__PURE__ */ import_react21.default.createElement(StyledInput, {
|
|
800
|
-
...props,
|
|
801
|
-
className: (0, import_classnames12.default)(
|
|
802
|
-
"is-borderless",
|
|
803
|
-
"is-flex-grow-1",
|
|
804
|
-
"has-background-transparent",
|
|
805
|
-
createVariantClass(variant)
|
|
806
|
-
),
|
|
807
|
-
placeholder: !readOnly && !disabled ? placeholder : "",
|
|
808
|
-
id: inputId,
|
|
809
|
-
ref,
|
|
810
|
-
"aria-describedby": inputDescriptionId,
|
|
811
|
-
...(0, import_ui_components7.createAttributesForTesting)(testId)
|
|
812
|
-
})), /* @__PURE__ */ import_react21.default.createElement(import_react_visually_hidden.VisuallyHidden, {
|
|
813
|
-
"aria-hidden": true,
|
|
814
|
-
id: inputDescriptionId
|
|
815
|
-
}, t("input.description")), error ? /* @__PURE__ */ import_react21.default.createElement(FieldMessage_default, {
|
|
816
|
-
variant
|
|
817
|
-
}, error) : null);
|
|
798
|
+
var StyledDelete = (0, import_styled_components2.default)(ChipInput_default.Chip.Delete)`
|
|
799
|
+
&:focus {
|
|
800
|
+
outline-offset: 0;
|
|
818
801
|
}
|
|
819
|
-
|
|
820
|
-
var
|
|
802
|
+
`;
|
|
803
|
+
var ChipInputField = function ChipInputField2({
|
|
804
|
+
label,
|
|
805
|
+
helpText,
|
|
806
|
+
readOnly,
|
|
807
|
+
disabled,
|
|
808
|
+
error,
|
|
809
|
+
createDeleteText,
|
|
810
|
+
onChange,
|
|
811
|
+
placeholder,
|
|
812
|
+
value,
|
|
813
|
+
className,
|
|
814
|
+
testId,
|
|
815
|
+
id,
|
|
816
|
+
children,
|
|
817
|
+
isLoading,
|
|
818
|
+
isNewItemDuplicate,
|
|
819
|
+
...props
|
|
820
|
+
}, ref) {
|
|
821
|
+
const [t] = (0, import_react_i18next2.useTranslation)("commons", { keyPrefix: "form.chipList" });
|
|
822
|
+
const deleteTextCallback = (0, import_react22.useCallback)(
|
|
823
|
+
(item) => createDeleteText ? createDeleteText(item) : t("delete", { item }),
|
|
824
|
+
[createDeleteText, t]
|
|
825
|
+
);
|
|
826
|
+
const inputId = (0, import_ui_components7.useGeneratedId)(id ?? testId);
|
|
827
|
+
const labelId = (0, import_ui_components7.useGeneratedId)();
|
|
828
|
+
const inputDescriptionId = (0, import_ui_components7.useGeneratedId)();
|
|
829
|
+
const variant = error ? "danger" : void 0;
|
|
830
|
+
return /* @__PURE__ */ import_react22.default.createElement(Field_default, {
|
|
831
|
+
className,
|
|
832
|
+
"aria-owns": inputId
|
|
833
|
+
}, /* @__PURE__ */ import_react22.default.createElement(Label_default, {
|
|
834
|
+
id: labelId
|
|
835
|
+
}, label, helpText ? /* @__PURE__ */ import_react22.default.createElement(Help_default, {
|
|
836
|
+
className: "ml-1",
|
|
837
|
+
text: helpText
|
|
838
|
+
}) : null), /* @__PURE__ */ import_react22.default.createElement("div", {
|
|
839
|
+
className: (0, import_classnames12.default)("control", { "is-loading": isLoading })
|
|
840
|
+
}, /* @__PURE__ */ import_react22.default.createElement(StyledChipInput, {
|
|
841
|
+
value,
|
|
842
|
+
onChange: (e) => onChange && onChange(e ?? []),
|
|
843
|
+
className: "is-flex is-flex-wrap-wrap input",
|
|
844
|
+
"aria-labelledby": labelId,
|
|
845
|
+
disabled: readOnly || disabled,
|
|
846
|
+
isNewItemDuplicate
|
|
847
|
+
}, value == null ? void 0 : value.map((option, index) => /* @__PURE__ */ import_react22.default.createElement(ChipInput_default.Chip, {
|
|
848
|
+
key: option.label,
|
|
849
|
+
className: "tag is-light is-overflow-hidden"
|
|
850
|
+
}, /* @__PURE__ */ import_react22.default.createElement("span", {
|
|
851
|
+
className: "is-ellipsis-overflow"
|
|
852
|
+
}, option.label), /* @__PURE__ */ import_react22.default.createElement(StyledDelete, {
|
|
853
|
+
"aria-label": deleteTextCallback(option.label),
|
|
854
|
+
index,
|
|
855
|
+
className: "delete is-small"
|
|
856
|
+
}))), /* @__PURE__ */ import_react22.default.createElement(StyledInput, {
|
|
857
|
+
...props,
|
|
858
|
+
className: (0, import_classnames12.default)(
|
|
859
|
+
"is-borderless",
|
|
860
|
+
"has-background-transparent",
|
|
861
|
+
"is-shadowless",
|
|
862
|
+
"input",
|
|
863
|
+
"is-ellipsis-overflow",
|
|
864
|
+
createVariantClass(variant)
|
|
865
|
+
),
|
|
866
|
+
placeholder: !readOnly && !disabled ? placeholder : "",
|
|
867
|
+
id: inputId,
|
|
868
|
+
ref,
|
|
869
|
+
"aria-describedby": inputDescriptionId,
|
|
870
|
+
...(0, import_ui_components7.createAttributesForTesting)(testId)
|
|
871
|
+
}, children ? children : null))), /* @__PURE__ */ import_react22.default.createElement(import_react_visually_hidden.VisuallyHidden, {
|
|
872
|
+
"aria-hidden": true,
|
|
873
|
+
id: inputDescriptionId
|
|
874
|
+
}, t("input.description")), error ? /* @__PURE__ */ import_react22.default.createElement(FieldMessage_default, {
|
|
875
|
+
variant
|
|
876
|
+
}, error) : null);
|
|
877
|
+
};
|
|
878
|
+
var ChipInputField_default = withForwardRef(ChipInputField);
|
|
821
879
|
|
|
822
880
|
// src/chip-input/ControlledChipInputField.tsx
|
|
823
881
|
function ControlledChipInputField({
|
|
@@ -831,6 +889,8 @@ function ControlledChipInputField({
|
|
|
831
889
|
placeholder,
|
|
832
890
|
className,
|
|
833
891
|
createDeleteText,
|
|
892
|
+
children,
|
|
893
|
+
optionFactory = defaultOptionFactory,
|
|
834
894
|
...props
|
|
835
895
|
}) {
|
|
836
896
|
const { control, t, readOnly: formReadonly } = useScmFormContext();
|
|
@@ -841,53 +901,55 @@ function ControlledChipInputField({
|
|
|
841
901
|
const placeholderTranslation = placeholder || t(`${prefixedNameWithoutIndices}.placeholder`) || "";
|
|
842
902
|
const ariaLabelTranslation = t(`${prefixedNameWithoutIndices}.ariaLabel`);
|
|
843
903
|
const helpTextTranslation = helpText || t(`${prefixedNameWithoutIndices}.helpText`);
|
|
844
|
-
return /* @__PURE__ */
|
|
904
|
+
return /* @__PURE__ */ import_react23.default.createElement(import_react_hook_form6.Controller, {
|
|
845
905
|
control,
|
|
846
906
|
name: nameWithPrefix,
|
|
847
907
|
rules,
|
|
848
908
|
defaultValue,
|
|
849
|
-
render: ({ field, fieldState }) => /* @__PURE__ */
|
|
909
|
+
render: ({ field: { value, onChange, ...field }, fieldState }) => /* @__PURE__ */ import_react23.default.createElement(ChipInputField_default, {
|
|
850
910
|
label: labelTranslation,
|
|
851
911
|
helpText: helpTextTranslation,
|
|
852
912
|
placeholder: placeholderTranslation,
|
|
853
913
|
"aria-label": ariaLabelTranslation,
|
|
914
|
+
value: value ? value.map(optionFactory) : [],
|
|
915
|
+
onChange: (selectedOptions) => onChange(selectedOptions.map((item) => item.value)),
|
|
854
916
|
...props,
|
|
855
917
|
...field,
|
|
856
918
|
readOnly: readOnly ?? formReadonly,
|
|
857
919
|
className: (0, import_classnames13.default)("column", className),
|
|
858
920
|
error: fieldState.error ? fieldState.error.message || t(`${prefixedNameWithoutIndices}.error.${fieldState.error.type}`) : void 0,
|
|
859
921
|
testId: testId ?? `input-${nameWithPrefix}`
|
|
860
|
-
})
|
|
922
|
+
}, children)
|
|
861
923
|
});
|
|
862
924
|
}
|
|
863
925
|
var ControlledChipInputField_default = ControlledChipInputField;
|
|
864
926
|
|
|
865
927
|
// src/ScmFormListContext.tsx
|
|
866
|
-
var
|
|
928
|
+
var import_react24 = __toESM(require("react"));
|
|
867
929
|
var import_react_hook_form7 = require("react-hook-form");
|
|
868
|
-
var ScmFormListContext =
|
|
930
|
+
var ScmFormListContext = import_react24.default.createContext(null);
|
|
869
931
|
var ScmFormListContextProvider = ({ name, children }) => {
|
|
870
932
|
const { control } = useScmFormContext();
|
|
871
933
|
const prefix = useScmFormPathContext();
|
|
872
934
|
const parentForm = useScmFormListContext();
|
|
873
|
-
const nameWithPrefix = (0,
|
|
935
|
+
const nameWithPrefix = (0, import_react24.useMemo)(() => prefix ? `${prefix}.${name}` : name, [name, prefix]);
|
|
874
936
|
const fieldArray = (0, import_react_hook_form7.useFieldArray)({
|
|
875
937
|
control,
|
|
876
938
|
name: nameWithPrefix
|
|
877
939
|
});
|
|
878
|
-
const value = (0,
|
|
879
|
-
return /* @__PURE__ */
|
|
940
|
+
const value = (0, import_react24.useMemo)(() => ({ ...fieldArray, isNested: !!parentForm }), [fieldArray, parentForm]);
|
|
941
|
+
return /* @__PURE__ */ import_react24.default.createElement(ScmFormPathContextProvider, {
|
|
880
942
|
path: nameWithPrefix
|
|
881
|
-
}, /* @__PURE__ */
|
|
943
|
+
}, /* @__PURE__ */ import_react24.default.createElement(ScmFormListContext.Provider, {
|
|
882
944
|
value
|
|
883
945
|
}, children));
|
|
884
946
|
};
|
|
885
947
|
function useScmFormListContext() {
|
|
886
|
-
return (0,
|
|
948
|
+
return (0, import_react24.useContext)(ScmFormListContext);
|
|
887
949
|
}
|
|
888
950
|
|
|
889
951
|
// src/list/ControlledList.tsx
|
|
890
|
-
var
|
|
952
|
+
var import_react25 = __toESM(require("react"));
|
|
891
953
|
var import_ui_buttons2 = require("@scm-manager/ui-buttons");
|
|
892
954
|
var import_react_i18next3 = require("react-i18next");
|
|
893
955
|
function ControlledList({
|
|
@@ -904,20 +966,20 @@ function ControlledList({
|
|
|
904
966
|
entity: t(`${prefixedNameWithoutIndices}.entity`)
|
|
905
967
|
})
|
|
906
968
|
});
|
|
907
|
-
return /* @__PURE__ */
|
|
969
|
+
return /* @__PURE__ */ import_react25.default.createElement(import_react25.default.Fragment, null, fields.map((value, index) => /* @__PURE__ */ import_react25.default.createElement(ScmFormPathContextProvider, {
|
|
908
970
|
key: value.id,
|
|
909
971
|
path: `${nameWithPrefix}.${index}`
|
|
910
|
-
}, typeof children === "function" ? children({ value, index, remove: () => remove(index) }) : children, withDelete && !readOnly ? /* @__PURE__ */
|
|
972
|
+
}, typeof children === "function" ? children({ value, index, remove: () => remove(index) }) : children, withDelete && !readOnly ? /* @__PURE__ */ import_react25.default.createElement("div", {
|
|
911
973
|
className: "level-right"
|
|
912
|
-
}, /* @__PURE__ */
|
|
974
|
+
}, /* @__PURE__ */ import_react25.default.createElement(import_ui_buttons2.Button, {
|
|
913
975
|
variant: "signal",
|
|
914
976
|
onClick: () => remove(index)
|
|
915
|
-
}, deleteButtonTranslation)) : null, /* @__PURE__ */
|
|
977
|
+
}, deleteButtonTranslation)) : null, /* @__PURE__ */ import_react25.default.createElement("hr", null))));
|
|
916
978
|
}
|
|
917
979
|
var ControlledList_default = ControlledList;
|
|
918
980
|
|
|
919
981
|
// src/table/ControlledTable.tsx
|
|
920
|
-
var
|
|
982
|
+
var import_react26 = __toESM(require("react"));
|
|
921
983
|
var import_ui_buttons3 = require("@scm-manager/ui-buttons");
|
|
922
984
|
var import_classnames14 = __toESM(require("classnames"));
|
|
923
985
|
var import_react_i18next4 = require("react-i18next");
|
|
@@ -935,48 +997,48 @@ function ControlledTable({
|
|
|
935
997
|
const deleteLabel = t(`${prefixedNameWithoutIndices}.delete`) || defaultTranslate("delete.label");
|
|
936
998
|
const emptyTableLabel = t(`${prefixedNameWithoutIndices}.empty`) || defaultTranslate("empty.label");
|
|
937
999
|
const actionHeaderLabel = t(`${prefixedNameWithoutIndices}.action.label`) || defaultTranslate("headers.action.label");
|
|
938
|
-
return /* @__PURE__ */
|
|
1000
|
+
return /* @__PURE__ */ import_react26.default.createElement("table", {
|
|
939
1001
|
className: (0, import_classnames14.default)("table content is-hoverable", className)
|
|
940
|
-
}, /* @__PURE__ */
|
|
1002
|
+
}, /* @__PURE__ */ import_react26.default.createElement("thead", null, /* @__PURE__ */ import_react26.default.createElement("tr", null, import_react26.default.Children.map(children, (child) => /* @__PURE__ */ import_react26.default.createElement("th", null, t(`${prefixedNameWithoutIndices}.${child.props.name}.label`))), withDelete && !readOnly ? /* @__PURE__ */ import_react26.default.createElement("th", {
|
|
941
1003
|
className: "has-text-right"
|
|
942
|
-
}, actionHeaderLabel) : null)), /* @__PURE__ */
|
|
1004
|
+
}, actionHeaderLabel) : null)), /* @__PURE__ */ import_react26.default.createElement("tbody", null, fields.length === 0 ? /* @__PURE__ */ import_react26.default.createElement("tr", null, /* @__PURE__ */ import_react26.default.createElement("td", {
|
|
943
1005
|
colSpan: 1e3
|
|
944
|
-
}, /* @__PURE__ */
|
|
1006
|
+
}, /* @__PURE__ */ import_react26.default.createElement(import_ui_components8.Notification, {
|
|
945
1007
|
type: "info"
|
|
946
|
-
}, emptyTableLabel))) : null, fields.map((value, index) => /* @__PURE__ */
|
|
1008
|
+
}, emptyTableLabel))) : null, fields.map((value, index) => /* @__PURE__ */ import_react26.default.createElement(ScmFormPathContextProvider, {
|
|
947
1009
|
key: value.id,
|
|
948
1010
|
path: `${nameWithPrefix}.${index}`
|
|
949
|
-
}, /* @__PURE__ */
|
|
1011
|
+
}, /* @__PURE__ */ import_react26.default.createElement("tr", null, children, withDelete && !readOnly ? /* @__PURE__ */ import_react26.default.createElement("td", {
|
|
950
1012
|
className: "has-text-right"
|
|
951
|
-
}, /* @__PURE__ */
|
|
1013
|
+
}, /* @__PURE__ */ import_react26.default.createElement(import_ui_buttons3.Button, {
|
|
952
1014
|
className: "px-4",
|
|
953
1015
|
onClick: () => remove(index),
|
|
954
1016
|
"aria-label": deleteLabel
|
|
955
|
-
}, /* @__PURE__ */
|
|
1017
|
+
}, /* @__PURE__ */ import_react26.default.createElement("span", {
|
|
956
1018
|
className: "icon is-small"
|
|
957
|
-
}, /* @__PURE__ */
|
|
1019
|
+
}, /* @__PURE__ */ import_react26.default.createElement("i", {
|
|
958
1020
|
className: "fas fa-trash"
|
|
959
1021
|
})))) : null)))));
|
|
960
1022
|
}
|
|
961
1023
|
var ControlledTable_default = ControlledTable;
|
|
962
1024
|
|
|
963
1025
|
// src/table/ControlledColumn.tsx
|
|
964
|
-
var
|
|
1026
|
+
var import_react27 = __toESM(require("react"));
|
|
965
1027
|
var import_react_hook_form8 = require("react-hook-form");
|
|
966
1028
|
var ControlledColumn = ({ name, children, ...props }) => {
|
|
967
1029
|
const { control } = useScmFormContext();
|
|
968
1030
|
const formPathPrefix = useScmFormPathContext();
|
|
969
|
-
const nameWithPrefix = (0,
|
|
1031
|
+
const nameWithPrefix = (0, import_react27.useMemo)(() => formPathPrefix ? `${formPathPrefix}.${name}` : name, [formPathPrefix, name]);
|
|
970
1032
|
const value = (0, import_react_hook_form8.useWatch)({ control, name: nameWithPrefix, disabled: typeof children === "function" });
|
|
971
1033
|
const allValues = (0, import_react_hook_form8.useWatch)({ control, name: formPathPrefix, disabled: typeof children !== "function" });
|
|
972
|
-
return /* @__PURE__ */
|
|
1034
|
+
return /* @__PURE__ */ import_react27.default.createElement("td", {
|
|
973
1035
|
...props
|
|
974
1036
|
}, typeof children === "function" ? children(allValues) : value);
|
|
975
1037
|
};
|
|
976
1038
|
var ControlledColumn_default = ControlledColumn;
|
|
977
1039
|
|
|
978
1040
|
// src/AddListEntryForm.tsx
|
|
979
|
-
var
|
|
1041
|
+
var import_react28 = __toESM(require("react"));
|
|
980
1042
|
var import_react_hook_form9 = require("react-hook-form");
|
|
981
1043
|
var import_ui_buttons4 = require("@scm-manager/ui-buttons");
|
|
982
1044
|
var import_react_i18next5 = require("react-i18next");
|
|
@@ -1005,18 +1067,18 @@ function AddListEntryForm({
|
|
|
1005
1067
|
reset,
|
|
1006
1068
|
formState: { isSubmitSuccessful, isDirty, isValid }
|
|
1007
1069
|
} = form;
|
|
1008
|
-
const translateWithExtraPrefix = (0,
|
|
1070
|
+
const translateWithExtraPrefix = (0, import_react28.useCallback)(
|
|
1009
1071
|
(key, ...args) => t(`${prefixedNameWithoutIndices}.${key}`, ...args),
|
|
1010
1072
|
[prefixedNameWithoutIndices, t]
|
|
1011
1073
|
);
|
|
1012
|
-
const onSubmit = (0,
|
|
1074
|
+
const onSubmit = (0, import_react28.useCallback)((data) => submit ? submit(data, append) : append(data), [append, submit]);
|
|
1013
1075
|
const submitButtonLabel = translateWithExtraPrefix("add", {
|
|
1014
1076
|
defaultValue: defaultTranslate("list.add.label", { entity: translateWithExtraPrefix("entity") })
|
|
1015
1077
|
});
|
|
1016
1078
|
const titleLabel = translateWithExtraPrefix("title", {
|
|
1017
1079
|
defaultValue: defaultTranslate("list.title.label", { entity: translateWithExtraPrefix("entity") })
|
|
1018
1080
|
});
|
|
1019
|
-
(0,
|
|
1081
|
+
(0, import_react28.useEffect)(() => {
|
|
1020
1082
|
if (isSubmitSuccessful) {
|
|
1021
1083
|
reset(defaultValues);
|
|
1022
1084
|
}
|
|
@@ -1024,41 +1086,246 @@ function AddListEntryForm({
|
|
|
1024
1086
|
if (readOnly) {
|
|
1025
1087
|
return null;
|
|
1026
1088
|
}
|
|
1027
|
-
return /* @__PURE__ */
|
|
1089
|
+
return /* @__PURE__ */ import_react28.default.createElement(ScmFormContextProvider, {
|
|
1028
1090
|
...form,
|
|
1029
1091
|
t: translateWithExtraPrefix,
|
|
1030
1092
|
formId: nameWithPrefix
|
|
1031
|
-
}, /* @__PURE__ */
|
|
1093
|
+
}, /* @__PURE__ */ import_react28.default.createElement(ScmFormPathContextProvider, {
|
|
1032
1094
|
path: ""
|
|
1033
|
-
}, /* @__PURE__ */
|
|
1095
|
+
}, /* @__PURE__ */ import_react28.default.createElement("h3", {
|
|
1034
1096
|
className: "subtitle is-5"
|
|
1035
|
-
}, titleLabel), /* @__PURE__ */
|
|
1097
|
+
}, titleLabel), /* @__PURE__ */ import_react28.default.createElement("form", {
|
|
1036
1098
|
id: nameWithPrefix,
|
|
1037
1099
|
onSubmit: form.handleSubmit(onSubmit),
|
|
1038
1100
|
noValidate: true
|
|
1039
|
-
}), typeof children === "function" ? children(form) : children, /* @__PURE__ */
|
|
1101
|
+
}), typeof children === "function" ? children(form) : children, /* @__PURE__ */ import_react28.default.createElement("div", {
|
|
1040
1102
|
className: "level-left"
|
|
1041
|
-
}, /* @__PURE__ */
|
|
1103
|
+
}, /* @__PURE__ */ import_react28.default.createElement(import_ui_buttons4.Button, {
|
|
1042
1104
|
form: nameWithPrefix,
|
|
1043
1105
|
type: "submit",
|
|
1044
1106
|
variant: isNested ? void 0 : "secondary",
|
|
1045
1107
|
disabled: disableSubmitWhenDirty && !isDirty || !isValid
|
|
1046
|
-
}, submitButtonLabel)), /* @__PURE__ */
|
|
1108
|
+
}, submitButtonLabel)), /* @__PURE__ */ import_react28.default.createElement(StyledHr, null)));
|
|
1047
1109
|
}
|
|
1048
1110
|
var AddListEntryForm_default = AddListEntryForm;
|
|
1049
1111
|
|
|
1112
|
+
// src/combobox/ControlledComboboxField.tsx
|
|
1113
|
+
var import_react32 = __toESM(require("react"));
|
|
1114
|
+
var import_react_hook_form10 = require("react-hook-form");
|
|
1115
|
+
var import_classnames17 = __toESM(require("classnames"));
|
|
1116
|
+
|
|
1117
|
+
// src/combobox/ComboboxField.tsx
|
|
1118
|
+
var import_react31 = __toESM(require("react"));
|
|
1119
|
+
var import_ui_components10 = require("@scm-manager/ui-components");
|
|
1120
|
+
|
|
1121
|
+
// src/combobox/Combobox.tsx
|
|
1122
|
+
var import_react29 = __toESM(require("react"));
|
|
1123
|
+
var import_react30 = require("@headlessui/react");
|
|
1124
|
+
var import_classnames15 = __toESM(require("classnames"));
|
|
1125
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
1126
|
+
var import_ui_components9 = require("@scm-manager/ui-components");
|
|
1127
|
+
var OptionsWrapper = (0, import_styled_components4.default)(import_react30.Combobox.Options).attrs({
|
|
1128
|
+
className: "is-flex is-flex-direction-column has-rounded-border has-box-shadow is-overflow-hidden"
|
|
1129
|
+
})`
|
|
1130
|
+
z-index: 400;
|
|
1131
|
+
top: 2.5rem;
|
|
1132
|
+
border: var(--scm-border);
|
|
1133
|
+
background-color: var(--scm-secondary-background);
|
|
1134
|
+
max-width: 35ch;
|
|
1135
|
+
|
|
1136
|
+
&:empty {
|
|
1137
|
+
border: 0;
|
|
1138
|
+
clip: rect(0 0 0 0);
|
|
1139
|
+
height: 1px;
|
|
1140
|
+
margin: -1px;
|
|
1141
|
+
overflow: hidden;
|
|
1142
|
+
padding: 0;
|
|
1143
|
+
position: absolute;
|
|
1144
|
+
white-space: nowrap;
|
|
1145
|
+
width: 1px;
|
|
1146
|
+
}
|
|
1147
|
+
`;
|
|
1148
|
+
var StyledComboboxOption = import_styled_components4.default.li.attrs({
|
|
1149
|
+
className: "px-3 py-2 has-text-inherit is-clickable is-size-6 is-borderless has-background-transparent"
|
|
1150
|
+
})`
|
|
1151
|
+
line-height: inherit;
|
|
1152
|
+
background-color: ${({ isActive }) => isActive ? "var(--scm-column-selection)" : ""};
|
|
1153
|
+
word-break: break-all;
|
|
1154
|
+
&[data-disabled] {
|
|
1155
|
+
color: unset !important;
|
|
1156
|
+
opacity: 40%;
|
|
1157
|
+
cursor: unset !important;
|
|
1158
|
+
}
|
|
1159
|
+
`;
|
|
1160
|
+
function ComboboxComponent(props, ref) {
|
|
1161
|
+
var _a;
|
|
1162
|
+
const [query, setQuery] = (0, import_react29.useState)("");
|
|
1163
|
+
const { onQueryChange } = props;
|
|
1164
|
+
(0, import_react29.useEffect)(() => onQueryChange && onQueryChange(query), [onQueryChange, query]);
|
|
1165
|
+
let options;
|
|
1166
|
+
if (Array.isArray(props.children)) {
|
|
1167
|
+
options = props.children;
|
|
1168
|
+
} else if (typeof props.options === "function") {
|
|
1169
|
+
options = /* @__PURE__ */ import_react29.default.createElement(ComboboxOptions, {
|
|
1170
|
+
children: props.children,
|
|
1171
|
+
options: props.options,
|
|
1172
|
+
query
|
|
1173
|
+
});
|
|
1174
|
+
} else {
|
|
1175
|
+
options = (_a = props.options) == null ? void 0 : _a.map(
|
|
1176
|
+
(o, index) => typeof props.children === "function" ? props.children(o, index) : /* @__PURE__ */ import_react29.default.createElement(import_react30.Combobox.Option, {
|
|
1177
|
+
value: o,
|
|
1178
|
+
key: o.label,
|
|
1179
|
+
as: import_react29.Fragment
|
|
1180
|
+
}, ({ active }) => /* @__PURE__ */ import_react29.default.createElement(StyledComboboxOption, {
|
|
1181
|
+
isActive: active
|
|
1182
|
+
}, o.displayValue ?? o.label))
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1185
|
+
return /* @__PURE__ */ import_react29.default.createElement(import_react30.Combobox, {
|
|
1186
|
+
as: "div",
|
|
1187
|
+
value: props.value,
|
|
1188
|
+
onChange: (e) => props.onChange && props.onChange(e),
|
|
1189
|
+
disabled: props.disabled || props.readOnly,
|
|
1190
|
+
onKeyDown: (e) => props.onKeyDown && props.onKeyDown(e),
|
|
1191
|
+
name: props.name,
|
|
1192
|
+
form: props.form,
|
|
1193
|
+
defaultValue: props.defaultValue,
|
|
1194
|
+
nullable: props.nullable,
|
|
1195
|
+
className: "is-relative is-flex-grow-1 is-flex",
|
|
1196
|
+
by: "value"
|
|
1197
|
+
}, /* @__PURE__ */ import_react29.default.createElement(import_react30.Combobox.Input, {
|
|
1198
|
+
displayValue: (o) => o == null ? void 0 : o.label,
|
|
1199
|
+
ref,
|
|
1200
|
+
onChange: (e) => setQuery(e.target.value),
|
|
1201
|
+
className: (0, import_classnames15.default)(props.className, "is-full-width", "input", "is-ellipsis-overflow"),
|
|
1202
|
+
"aria-describedby": props["aria-describedby"],
|
|
1203
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
1204
|
+
"aria-label": props["aria-label"],
|
|
1205
|
+
id: props.id,
|
|
1206
|
+
placeholder: props.placeholder,
|
|
1207
|
+
onBlur: props.onBlur,
|
|
1208
|
+
...(0, import_ui_components9.createAttributesForTesting)(props.testId)
|
|
1209
|
+
}), /* @__PURE__ */ import_react29.default.createElement(OptionsWrapper, {
|
|
1210
|
+
className: "is-absolute"
|
|
1211
|
+
}, options));
|
|
1212
|
+
}
|
|
1213
|
+
function ComboboxOptions({ query, options, children }) {
|
|
1214
|
+
const [optionsData, setOptionsData] = (0, import_react29.useState)([]);
|
|
1215
|
+
const activePromise = (0, import_react29.useRef)();
|
|
1216
|
+
(0, import_react29.useEffect)(() => {
|
|
1217
|
+
const optionsExec = options(query);
|
|
1218
|
+
if (optionsExec instanceof Promise) {
|
|
1219
|
+
activePromise.current = optionsExec;
|
|
1220
|
+
optionsExec.then((newOptions) => {
|
|
1221
|
+
if (activePromise.current === optionsExec) {
|
|
1222
|
+
setOptionsData(newOptions);
|
|
1223
|
+
}
|
|
1224
|
+
}).catch(() => {
|
|
1225
|
+
if (activePromise.current === optionsExec) {
|
|
1226
|
+
setOptionsData([]);
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
} else {
|
|
1230
|
+
setOptionsData(optionsExec);
|
|
1231
|
+
}
|
|
1232
|
+
}, [options, query]);
|
|
1233
|
+
return /* @__PURE__ */ import_react29.default.createElement(import_react29.default.Fragment, null, optionsData == null ? void 0 : optionsData.map(
|
|
1234
|
+
(o, index) => typeof children === "function" ? children(o, index) : /* @__PURE__ */ import_react29.default.createElement(import_react30.Combobox.Option, {
|
|
1235
|
+
value: o,
|
|
1236
|
+
key: o.label,
|
|
1237
|
+
as: import_react29.Fragment
|
|
1238
|
+
}, ({ active }) => /* @__PURE__ */ import_react29.default.createElement(StyledComboboxOption, {
|
|
1239
|
+
isActive: active
|
|
1240
|
+
}, o.displayValue ?? o.label))
|
|
1241
|
+
));
|
|
1242
|
+
}
|
|
1243
|
+
var Combobox = Object.assign(withForwardRef(ComboboxComponent), {
|
|
1244
|
+
Option: StyledComboboxOption
|
|
1245
|
+
});
|
|
1246
|
+
var Combobox_default = Combobox;
|
|
1247
|
+
|
|
1248
|
+
// src/combobox/ComboboxField.tsx
|
|
1249
|
+
var import_classnames16 = __toESM(require("classnames"));
|
|
1250
|
+
var ComboboxField = function ComboboxField2({
|
|
1251
|
+
label,
|
|
1252
|
+
helpText,
|
|
1253
|
+
error,
|
|
1254
|
+
className,
|
|
1255
|
+
isLoading,
|
|
1256
|
+
...props
|
|
1257
|
+
}, ref) {
|
|
1258
|
+
const labelId = (0, import_ui_components10.useGeneratedId)();
|
|
1259
|
+
return /* @__PURE__ */ import_react31.default.createElement(Field_default, {
|
|
1260
|
+
className
|
|
1261
|
+
}, /* @__PURE__ */ import_react31.default.createElement(Label_default, {
|
|
1262
|
+
id: labelId
|
|
1263
|
+
}, label, helpText ? /* @__PURE__ */ import_react31.default.createElement(Help_default, {
|
|
1264
|
+
className: "ml-1",
|
|
1265
|
+
text: helpText
|
|
1266
|
+
}) : null), /* @__PURE__ */ import_react31.default.createElement("div", {
|
|
1267
|
+
className: (0, import_classnames16.default)("control", { "is-loading": isLoading })
|
|
1268
|
+
}, /* @__PURE__ */ import_react31.default.createElement(Combobox_default, {
|
|
1269
|
+
...props,
|
|
1270
|
+
ref,
|
|
1271
|
+
"aria-labelledby": labelId
|
|
1272
|
+
})));
|
|
1273
|
+
};
|
|
1274
|
+
var ComboboxField_default = withForwardRef(ComboboxField);
|
|
1275
|
+
|
|
1276
|
+
// src/combobox/ControlledComboboxField.tsx
|
|
1277
|
+
function ControlledComboboxField({
|
|
1278
|
+
name,
|
|
1279
|
+
label,
|
|
1280
|
+
helpText,
|
|
1281
|
+
rules,
|
|
1282
|
+
testId,
|
|
1283
|
+
defaultValue,
|
|
1284
|
+
readOnly,
|
|
1285
|
+
className,
|
|
1286
|
+
optionFactory = defaultOptionFactory,
|
|
1287
|
+
...props
|
|
1288
|
+
}) {
|
|
1289
|
+
const { control, t, readOnly: formReadonly, formId } = useScmFormContext();
|
|
1290
|
+
const formPathPrefix = useScmFormPathContext();
|
|
1291
|
+
const nameWithPrefix = formPathPrefix ? `${formPathPrefix}.${name}` : name;
|
|
1292
|
+
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
1293
|
+
const labelTranslation = label || t(`${prefixedNameWithoutIndices}.label`) || "";
|
|
1294
|
+
const helpTextTranslation = helpText || t(`${prefixedNameWithoutIndices}.helpText`);
|
|
1295
|
+
return /* @__PURE__ */ import_react32.default.createElement(import_react_hook_form10.Controller, {
|
|
1296
|
+
control,
|
|
1297
|
+
name: nameWithPrefix,
|
|
1298
|
+
rules,
|
|
1299
|
+
defaultValue,
|
|
1300
|
+
render: ({ field: { onChange, value, ...field }, fieldState }) => /* @__PURE__ */ import_react32.default.createElement(ComboboxField_default, {
|
|
1301
|
+
form: formId,
|
|
1302
|
+
readOnly: readOnly ?? formReadonly,
|
|
1303
|
+
className: (0, import_classnames17.default)("column", className),
|
|
1304
|
+
...props,
|
|
1305
|
+
...field,
|
|
1306
|
+
label: labelTranslation,
|
|
1307
|
+
helpText: helpTextTranslation,
|
|
1308
|
+
onChange: (e) => onChange(e == null ? void 0 : e.value),
|
|
1309
|
+
value: optionFactory(value),
|
|
1310
|
+
error: fieldState.error ? fieldState.error.message || t(`${prefixedNameWithoutIndices}.error.${fieldState.error.type}`) : void 0,
|
|
1311
|
+
testId: testId ?? `select-${nameWithPrefix}`
|
|
1312
|
+
})
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
var ControlledComboboxField_default = ControlledComboboxField;
|
|
1316
|
+
|
|
1050
1317
|
// src/ConfigurationForm.tsx
|
|
1051
1318
|
var import_ui_api = require("@scm-manager/ui-api");
|
|
1052
|
-
var
|
|
1053
|
-
var
|
|
1319
|
+
var import_ui_components11 = require("@scm-manager/ui-components");
|
|
1320
|
+
var import_react33 = __toESM(require("react"));
|
|
1054
1321
|
var import_react_i18next6 = require("react-i18next");
|
|
1055
1322
|
function ConfigurationForm({ link, children, ...formProps }) {
|
|
1056
1323
|
const { initialConfiguration, isReadOnly, update, isLoading } = (0, import_ui_api.useConfigLink)(link);
|
|
1057
1324
|
const [t] = (0, import_react_i18next6.useTranslation)("commons", { keyPrefix: "form" });
|
|
1058
1325
|
if (isLoading || !initialConfiguration) {
|
|
1059
|
-
return /* @__PURE__ */
|
|
1326
|
+
return /* @__PURE__ */ import_react33.default.createElement(import_ui_components11.Loading, null);
|
|
1060
1327
|
}
|
|
1061
|
-
return /* @__PURE__ */
|
|
1328
|
+
return /* @__PURE__ */ import_react33.default.createElement(Form_default, {
|
|
1062
1329
|
onSubmit: update,
|
|
1063
1330
|
defaultValues: initialConfiguration,
|
|
1064
1331
|
readOnly: isReadOnly,
|
|
@@ -1168,11 +1435,14 @@ var Form2 = Object.assign(Form_default, {
|
|
|
1168
1435
|
Table: Object.assign(ControlledTable_default, {
|
|
1169
1436
|
Column: ControlledColumn_default
|
|
1170
1437
|
}),
|
|
1171
|
-
ChipInput: ControlledChipInputField_default
|
|
1438
|
+
ChipInput: ControlledChipInputField_default,
|
|
1439
|
+
Combobox: ControlledComboboxField_default
|
|
1172
1440
|
});
|
|
1173
1441
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1174
1442
|
0 && (module.exports = {
|
|
1175
1443
|
ChipInputField,
|
|
1444
|
+
Combobox,
|
|
1445
|
+
ComboboxField,
|
|
1176
1446
|
ConfigurationForm,
|
|
1177
1447
|
Form,
|
|
1178
1448
|
Select,
|