@scm-manager/ui-forms 2.47.0 → 2.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -7
- package/build/index.d.ts +168 -67
- package/build/index.js +215 -24
- package/build/index.mjs +212 -23
- package/package.json +9 -8
- package/src/Form.stories.tsx +21 -1
- package/src/base/Control.tsx +4 -4
- package/src/base/Field.tsx +7 -5
- package/src/base/label/Label.tsx +7 -5
- package/src/chip-input/ControlledChipInputField.tsx +22 -17
- package/src/index.ts +12 -0
- package/src/radio-button/ControlledRadioGroupField.tsx +94 -0
- package/src/radio-button/RadioButton.stories.tsx +226 -0
- package/src/radio-button/RadioButton.tsx +116 -0
- package/src/radio-button/RadioButtonContext.tsx +42 -0
- package/src/radio-button/RadioGroup.tsx +49 -0
- package/src/radio-button/RadioGroupField.tsx +58 -0
package/build/index.js
CHANGED
|
@@ -35,6 +35,8 @@ __export(src_exports, {
|
|
|
35
35
|
Form: () => Form2,
|
|
36
36
|
Input: () => Input_default,
|
|
37
37
|
Label: () => Label_default,
|
|
38
|
+
RadioGroup: () => RadioGroup3,
|
|
39
|
+
RadioGroupField: () => RadioGroupField2,
|
|
38
40
|
Select: () => Select_default,
|
|
39
41
|
SelectField: () => SelectField_default,
|
|
40
42
|
Textarea: () => Textarea_default,
|
|
@@ -244,28 +246,33 @@ var import_react11 = __toESM(require("react"));
|
|
|
244
246
|
// src/base/Field.tsx
|
|
245
247
|
var import_react5 = __toESM(require("react"));
|
|
246
248
|
var import_classnames2 = __toESM(require("classnames"));
|
|
247
|
-
var Field = ({
|
|
248
|
-
|
|
249
|
+
var Field = ({
|
|
250
|
+
as = "div",
|
|
251
|
+
className,
|
|
252
|
+
children,
|
|
249
253
|
...rest
|
|
250
|
-
}, children);
|
|
254
|
+
}) => import_react5.default.createElement(as, { className: (0, import_classnames2.default)("field", className), ...rest }, children);
|
|
251
255
|
var Field_default = Field;
|
|
252
256
|
|
|
253
257
|
// src/base/Control.tsx
|
|
254
258
|
var import_react6 = __toESM(require("react"));
|
|
255
259
|
var import_classnames3 = __toESM(require("classnames"));
|
|
256
|
-
var Control = ({ className, children, ...rest }) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
260
|
+
var Control = import_react6.default.forwardRef(({ className, children, ...rest }, ref) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
257
261
|
className: (0, import_classnames3.default)("control", className),
|
|
258
|
-
...rest
|
|
259
|
-
|
|
262
|
+
...rest,
|
|
263
|
+
ref
|
|
264
|
+
}, children));
|
|
260
265
|
var Control_default = Control;
|
|
261
266
|
|
|
262
267
|
// src/base/label/Label.tsx
|
|
263
268
|
var import_react7 = __toESM(require("react"));
|
|
264
269
|
var import_classnames4 = __toESM(require("classnames"));
|
|
265
|
-
var Label = ({
|
|
266
|
-
|
|
270
|
+
var Label = ({
|
|
271
|
+
as = "label",
|
|
272
|
+
className,
|
|
273
|
+
children,
|
|
267
274
|
...rest
|
|
268
|
-
}, children);
|
|
275
|
+
}) => import_react7.default.createElement(as, { className: (0, import_classnames4.default)("label", className), ...rest }, children);
|
|
269
276
|
var Label_default = Label;
|
|
270
277
|
|
|
271
278
|
// src/base/field-message/FieldMessage.tsx
|
|
@@ -929,7 +936,7 @@ function ControlledChipInputField({
|
|
|
929
936
|
children,
|
|
930
937
|
optionFactory = defaultOptionFactory,
|
|
931
938
|
...props
|
|
932
|
-
}) {
|
|
939
|
+
}, ref) {
|
|
933
940
|
const { control, t, readOnly: formReadonly } = useScmFormContext();
|
|
934
941
|
const formPathPrefix = useScmFormPathContext();
|
|
935
942
|
const nameWithPrefix = formPathPrefix ? `${formPathPrefix}.${name}` : name;
|
|
@@ -955,11 +962,12 @@ function ControlledChipInputField({
|
|
|
955
962
|
readOnly: readOnly ?? formReadonly,
|
|
956
963
|
className: (0, import_classnames14.default)("column", className),
|
|
957
964
|
error: fieldState.error ? fieldState.error.message || t(`${prefixedNameWithoutIndices}.error.${fieldState.error.type}`) : void 0,
|
|
958
|
-
testId: testId ?? `input-${nameWithPrefix}
|
|
965
|
+
testId: testId ?? `input-${nameWithPrefix}`,
|
|
966
|
+
ref
|
|
959
967
|
}, children)
|
|
960
968
|
});
|
|
961
969
|
}
|
|
962
|
-
var ControlledChipInputField_default = ControlledChipInputField;
|
|
970
|
+
var ControlledChipInputField_default = withForwardRef(ControlledChipInputField);
|
|
963
971
|
|
|
964
972
|
// src/ScmFormListContext.tsx
|
|
965
973
|
var import_react24 = __toESM(require("react"));
|
|
@@ -1358,18 +1366,193 @@ function ControlledComboboxField({
|
|
|
1358
1366
|
}
|
|
1359
1367
|
var ControlledComboboxField_default = ControlledComboboxField;
|
|
1360
1368
|
|
|
1361
|
-
// src/
|
|
1362
|
-
var
|
|
1369
|
+
// src/radio-button/ControlledRadioGroupField.tsx
|
|
1370
|
+
var import_react37 = __toESM(require("react"));
|
|
1371
|
+
|
|
1372
|
+
// src/radio-button/RadioGroupField.tsx
|
|
1373
|
+
var import_react36 = __toESM(require("react"));
|
|
1374
|
+
|
|
1375
|
+
// src/radio-button/RadioGroup.tsx
|
|
1376
|
+
var import_react35 = __toESM(require("react"));
|
|
1377
|
+
var RadixRadio = __toESM(require("@radix-ui/react-radio-group"));
|
|
1378
|
+
|
|
1379
|
+
// src/radio-button/RadioButton.tsx
|
|
1380
|
+
var import_react34 = __toESM(require("react"));
|
|
1381
|
+
var import_classnames19 = __toESM(require("classnames"));
|
|
1382
|
+
var RadioGroup = __toESM(require("@radix-ui/react-radio-group"));
|
|
1363
1383
|
var import_ui_components11 = require("@scm-manager/ui-components");
|
|
1384
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
1385
|
+
|
|
1386
|
+
// src/radio-button/RadioButtonContext.tsx
|
|
1364
1387
|
var import_react33 = __toESM(require("react"));
|
|
1388
|
+
var RadioButtonContext = (0, import_react33.createContext)(null);
|
|
1389
|
+
function useRadioButtonContext() {
|
|
1390
|
+
return (0, import_react33.useContext)(RadioButtonContext);
|
|
1391
|
+
}
|
|
1392
|
+
var RadioButtonContextProvider = ({ children, ...props }) => /* @__PURE__ */ import_react33.default.createElement(RadioButtonContext.Provider, {
|
|
1393
|
+
value: props
|
|
1394
|
+
}, children);
|
|
1395
|
+
|
|
1396
|
+
// src/radio-button/RadioButton.tsx
|
|
1397
|
+
var StyledRadioButton = (0, import_styled_components6.default)(RadioGroup.Item)`
|
|
1398
|
+
all: unset;
|
|
1399
|
+
width: 1rem;
|
|
1400
|
+
height: 1rem;
|
|
1401
|
+
border: var(--scm-border);
|
|
1402
|
+
border-radius: 100%;
|
|
1403
|
+
|
|
1404
|
+
:hover {
|
|
1405
|
+
border-color: var(--scm-hover-color);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
:hover *::after {
|
|
1409
|
+
background-color: var(--scm-info-hover-color);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
:disabled {
|
|
1413
|
+
background-color: var(--scm-dark-color-25);
|
|
1414
|
+
border-color: var(--scm-hover-color);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
:disabled *::after {
|
|
1418
|
+
background-color: var(--scm-info-color);
|
|
1419
|
+
}
|
|
1420
|
+
`;
|
|
1421
|
+
var StyledIndicator = (0, import_styled_components6.default)(RadioGroup.Indicator)`
|
|
1422
|
+
display: flex;
|
|
1423
|
+
align-items: center;
|
|
1424
|
+
justify-content: center;
|
|
1425
|
+
width: 100%;
|
|
1426
|
+
height: 100%;
|
|
1427
|
+
position: relative;
|
|
1428
|
+
|
|
1429
|
+
::after {
|
|
1430
|
+
content: "";
|
|
1431
|
+
display: block;
|
|
1432
|
+
width: 0.5rem;
|
|
1433
|
+
height: 0.5rem;
|
|
1434
|
+
border-radius: 50%;
|
|
1435
|
+
background-color: var(--scm-info-color);
|
|
1436
|
+
}
|
|
1437
|
+
`;
|
|
1438
|
+
var RadioButton = import_react34.default.forwardRef(
|
|
1439
|
+
({ id, testId, indicatorClassName, label, labelClassName, className, helpText, value, ...props }, ref) => {
|
|
1440
|
+
const context = useRadioButtonContext();
|
|
1441
|
+
const inputId = (0, import_ui_components11.useGeneratedId)(id);
|
|
1442
|
+
const labelKey = `${context == null ? void 0 : context.prefix}.radio.${value}`;
|
|
1443
|
+
return /* @__PURE__ */ import_react34.default.createElement("label", {
|
|
1444
|
+
className: (0, import_classnames19.default)("radio is-flex is-align-items-center", labelClassName),
|
|
1445
|
+
htmlFor: inputId
|
|
1446
|
+
}, /* @__PURE__ */ import_react34.default.createElement(StyledRadioButton, {
|
|
1447
|
+
form: context == null ? void 0 : context.formId,
|
|
1448
|
+
id: inputId,
|
|
1449
|
+
value,
|
|
1450
|
+
ref,
|
|
1451
|
+
className: (0, import_classnames19.default)("mr-3 mt-3 mb-3", className),
|
|
1452
|
+
...props,
|
|
1453
|
+
...(0, import_ui_components11.createAttributesForTesting)(testId)
|
|
1454
|
+
}, /* @__PURE__ */ import_react34.default.createElement(StyledIndicator, {
|
|
1455
|
+
className: indicatorClassName
|
|
1456
|
+
})), label ?? (context == null ? void 0 : context.t(labelKey)) ?? value, helpText ? /* @__PURE__ */ import_react34.default.createElement(Help_default, {
|
|
1457
|
+
className: "ml-3",
|
|
1458
|
+
text: helpText
|
|
1459
|
+
}) : null);
|
|
1460
|
+
}
|
|
1461
|
+
);
|
|
1462
|
+
var RadioButton_default = RadioButton;
|
|
1463
|
+
|
|
1464
|
+
// src/radio-button/RadioGroup.tsx
|
|
1465
|
+
var RadioGroup2 = import_react35.default.forwardRef(({ options, children, className, ...props }, ref) => /* @__PURE__ */ import_react35.default.createElement(RadixRadio.Root, {
|
|
1466
|
+
...props,
|
|
1467
|
+
asChild: true
|
|
1468
|
+
}, /* @__PURE__ */ import_react35.default.createElement(Control_default, {
|
|
1469
|
+
ref,
|
|
1470
|
+
className
|
|
1471
|
+
}, children ?? (options == null ? void 0 : options.map((option) => /* @__PURE__ */ import_react35.default.createElement(RadioButton_default, {
|
|
1472
|
+
key: option.value,
|
|
1473
|
+
value: option.value,
|
|
1474
|
+
label: option.label,
|
|
1475
|
+
helpText: option.helpText
|
|
1476
|
+
}))))));
|
|
1477
|
+
var RadioGroup_default = RadioGroup2;
|
|
1478
|
+
|
|
1479
|
+
// src/radio-button/RadioGroupField.tsx
|
|
1480
|
+
var RadioGroupField = import_react36.default.forwardRef(
|
|
1481
|
+
({ fieldClassName, labelClassName, label, helpText, children, ...props }, ref) => {
|
|
1482
|
+
return /* @__PURE__ */ import_react36.default.createElement(Field_default, {
|
|
1483
|
+
className: fieldClassName,
|
|
1484
|
+
as: "fieldset"
|
|
1485
|
+
}, /* @__PURE__ */ import_react36.default.createElement(Label_default, {
|
|
1486
|
+
className: labelClassName,
|
|
1487
|
+
as: "legend"
|
|
1488
|
+
}, label, helpText ? /* @__PURE__ */ import_react36.default.createElement(Help_default, {
|
|
1489
|
+
className: "ml-1",
|
|
1490
|
+
text: helpText
|
|
1491
|
+
}) : null), /* @__PURE__ */ import_react36.default.createElement(RadioGroup_default, {
|
|
1492
|
+
ref,
|
|
1493
|
+
...props
|
|
1494
|
+
}, children));
|
|
1495
|
+
}
|
|
1496
|
+
);
|
|
1497
|
+
var RadioGroupField_default = RadioGroupField;
|
|
1498
|
+
|
|
1499
|
+
// src/radio-button/ControlledRadioGroupField.tsx
|
|
1500
|
+
var import_react_hook_form11 = require("react-hook-form");
|
|
1501
|
+
var import_classnames20 = __toESM(require("classnames"));
|
|
1502
|
+
function ControlledRadioGroupField({
|
|
1503
|
+
name,
|
|
1504
|
+
label,
|
|
1505
|
+
helpText,
|
|
1506
|
+
rules,
|
|
1507
|
+
defaultValue,
|
|
1508
|
+
children,
|
|
1509
|
+
fieldClassName,
|
|
1510
|
+
readOnly,
|
|
1511
|
+
...props
|
|
1512
|
+
}) {
|
|
1513
|
+
const { control, t, readOnly: formReadOnly, formId } = useScmFormContext();
|
|
1514
|
+
const formPathPrefix = useScmFormPathContext();
|
|
1515
|
+
const nameWithPrefix = formPathPrefix ? `${formPathPrefix}.${name}` : name;
|
|
1516
|
+
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
1517
|
+
const labelTranslation = label ?? t(`${prefixedNameWithoutIndices}.label`) ?? "";
|
|
1518
|
+
const helpTextTranslation = helpText ?? t(`${prefixedNameWithoutIndices}.helpText`);
|
|
1519
|
+
return /* @__PURE__ */ import_react37.default.createElement(import_react_hook_form11.Controller, {
|
|
1520
|
+
control,
|
|
1521
|
+
name: nameWithPrefix,
|
|
1522
|
+
rules,
|
|
1523
|
+
defaultValue,
|
|
1524
|
+
render: ({ field }) => /* @__PURE__ */ import_react37.default.createElement(RadioButtonContextProvider, {
|
|
1525
|
+
t,
|
|
1526
|
+
prefix: prefixedNameWithoutIndices,
|
|
1527
|
+
formId
|
|
1528
|
+
}, /* @__PURE__ */ import_react37.default.createElement(RadioGroupField_default, {
|
|
1529
|
+
defaultValue,
|
|
1530
|
+
disabled: readOnly ?? formReadOnly,
|
|
1531
|
+
required: rules == null ? void 0 : rules.required,
|
|
1532
|
+
label: labelTranslation,
|
|
1533
|
+
helpText: helpTextTranslation,
|
|
1534
|
+
fieldClassName: (0, import_classnames20.default)("column", fieldClassName),
|
|
1535
|
+
onValueChange: field.onChange,
|
|
1536
|
+
...props,
|
|
1537
|
+
...field,
|
|
1538
|
+
name: nameWithPrefix
|
|
1539
|
+
}, children))
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
var ControlledRadioGroupField_default = ControlledRadioGroupField;
|
|
1543
|
+
|
|
1544
|
+
// src/ConfigurationForm.tsx
|
|
1545
|
+
var import_ui_api = require("@scm-manager/ui-api");
|
|
1546
|
+
var import_ui_components12 = require("@scm-manager/ui-components");
|
|
1547
|
+
var import_react38 = __toESM(require("react"));
|
|
1365
1548
|
var import_react_i18next6 = require("react-i18next");
|
|
1366
1549
|
function ConfigurationForm({ link, children, ...formProps }) {
|
|
1367
1550
|
const { initialConfiguration, isReadOnly, update, isLoading } = (0, import_ui_api.useConfigLink)(link);
|
|
1368
1551
|
const [t] = (0, import_react_i18next6.useTranslation)("commons", { keyPrefix: "form" });
|
|
1369
1552
|
if (isLoading || !initialConfiguration) {
|
|
1370
|
-
return /* @__PURE__ */
|
|
1553
|
+
return /* @__PURE__ */ import_react38.default.createElement(import_ui_components12.Loading, null);
|
|
1371
1554
|
}
|
|
1372
|
-
return /* @__PURE__ */
|
|
1555
|
+
return /* @__PURE__ */ import_react38.default.createElement(Form_default, {
|
|
1373
1556
|
onSubmit: update,
|
|
1374
1557
|
defaultValues: initialConfiguration,
|
|
1375
1558
|
readOnly: isReadOnly,
|
|
@@ -1380,15 +1563,15 @@ function ConfigurationForm({ link, children, ...formProps }) {
|
|
|
1380
1563
|
var ConfigurationForm_default = ConfigurationForm;
|
|
1381
1564
|
|
|
1382
1565
|
// src/input/Textarea.tsx
|
|
1383
|
-
var
|
|
1384
|
-
var
|
|
1385
|
-
var
|
|
1386
|
-
var Textarea =
|
|
1387
|
-
return /* @__PURE__ */
|
|
1566
|
+
var import_react39 = __toESM(require("react"));
|
|
1567
|
+
var import_classnames21 = __toESM(require("classnames"));
|
|
1568
|
+
var import_ui_components13 = require("@scm-manager/ui-components");
|
|
1569
|
+
var Textarea = import_react39.default.forwardRef(({ variant, className, testId, ...props }, ref) => {
|
|
1570
|
+
return /* @__PURE__ */ import_react39.default.createElement("textarea", {
|
|
1388
1571
|
ref,
|
|
1389
|
-
className: (0,
|
|
1572
|
+
className: (0, import_classnames21.default)("textarea", createVariantClass(variant), className),
|
|
1390
1573
|
...props,
|
|
1391
|
-
...(0,
|
|
1574
|
+
...(0, import_ui_components13.createAttributesForTesting)(testId)
|
|
1392
1575
|
});
|
|
1393
1576
|
});
|
|
1394
1577
|
var Textarea_default = Textarea;
|
|
@@ -1480,6 +1663,11 @@ var useDeleteResource = (idFactory, { collectionName: [entityQueryKey, collectio
|
|
|
1480
1663
|
};
|
|
1481
1664
|
|
|
1482
1665
|
// src/index.ts
|
|
1666
|
+
var RadioGroupExport = {
|
|
1667
|
+
Option: RadioButton_default
|
|
1668
|
+
};
|
|
1669
|
+
var RadioGroup3 = Object.assign(RadioGroup_default, RadioGroupExport);
|
|
1670
|
+
var RadioGroupField2 = Object.assign(RadioGroupField_default, RadioGroupExport);
|
|
1483
1671
|
var ChipInputField3 = Object.assign(ChipInputField_default, {
|
|
1484
1672
|
AddButton: ChipInput_default.AddButton
|
|
1485
1673
|
});
|
|
@@ -1497,7 +1685,8 @@ var Form2 = Object.assign(Form_default, {
|
|
|
1497
1685
|
Column: ControlledColumn_default
|
|
1498
1686
|
}),
|
|
1499
1687
|
ChipInput: ControlledChipInputField_default,
|
|
1500
|
-
Combobox: ControlledComboboxField_default
|
|
1688
|
+
Combobox: ControlledComboboxField_default,
|
|
1689
|
+
RadioGroup: Object.assign(ControlledRadioGroupField_default, RadioGroupExport)
|
|
1501
1690
|
});
|
|
1502
1691
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1503
1692
|
0 && (module.exports = {
|
|
@@ -1510,6 +1699,8 @@ var Form2 = Object.assign(Form_default, {
|
|
|
1510
1699
|
Form,
|
|
1511
1700
|
Input,
|
|
1512
1701
|
Label,
|
|
1702
|
+
RadioGroup,
|
|
1703
|
+
RadioGroupField,
|
|
1513
1704
|
Select,
|
|
1514
1705
|
SelectField,
|
|
1515
1706
|
Textarea,
|
package/build/index.mjs
CHANGED
|
@@ -198,28 +198,33 @@ import React10 from "react";
|
|
|
198
198
|
// src/base/Field.tsx
|
|
199
199
|
import React4 from "react";
|
|
200
200
|
import classNames2 from "classnames";
|
|
201
|
-
var Field = ({
|
|
202
|
-
|
|
201
|
+
var Field = ({
|
|
202
|
+
as = "div",
|
|
203
|
+
className,
|
|
204
|
+
children,
|
|
203
205
|
...rest
|
|
204
|
-
}, children);
|
|
206
|
+
}) => React4.createElement(as, { className: classNames2("field", className), ...rest }, children);
|
|
205
207
|
var Field_default = Field;
|
|
206
208
|
|
|
207
209
|
// src/base/Control.tsx
|
|
208
210
|
import React5 from "react";
|
|
209
211
|
import classNames3 from "classnames";
|
|
210
|
-
var Control = ({ className, children, ...rest }) => /* @__PURE__ */ React5.createElement("div", {
|
|
212
|
+
var Control = React5.forwardRef(({ className, children, ...rest }, ref) => /* @__PURE__ */ React5.createElement("div", {
|
|
211
213
|
className: classNames3("control", className),
|
|
212
|
-
...rest
|
|
213
|
-
|
|
214
|
+
...rest,
|
|
215
|
+
ref
|
|
216
|
+
}, children));
|
|
214
217
|
var Control_default = Control;
|
|
215
218
|
|
|
216
219
|
// src/base/label/Label.tsx
|
|
217
220
|
import React6 from "react";
|
|
218
221
|
import classNames4 from "classnames";
|
|
219
|
-
var Label = ({
|
|
220
|
-
|
|
222
|
+
var Label = ({
|
|
223
|
+
as = "label",
|
|
224
|
+
className,
|
|
225
|
+
children,
|
|
221
226
|
...rest
|
|
222
|
-
}, children);
|
|
227
|
+
}) => React6.createElement(as, { className: classNames4("label", className), ...rest }, children);
|
|
223
228
|
var Label_default = Label;
|
|
224
229
|
|
|
225
230
|
// src/base/field-message/FieldMessage.tsx
|
|
@@ -889,7 +894,7 @@ function ControlledChipInputField({
|
|
|
889
894
|
children,
|
|
890
895
|
optionFactory = defaultOptionFactory,
|
|
891
896
|
...props
|
|
892
|
-
}) {
|
|
897
|
+
}, ref) {
|
|
893
898
|
const { control, t, readOnly: formReadonly } = useScmFormContext();
|
|
894
899
|
const formPathPrefix = useScmFormPathContext();
|
|
895
900
|
const nameWithPrefix = formPathPrefix ? `${formPathPrefix}.${name}` : name;
|
|
@@ -915,11 +920,12 @@ function ControlledChipInputField({
|
|
|
915
920
|
readOnly: readOnly ?? formReadonly,
|
|
916
921
|
className: classNames14("column", className),
|
|
917
922
|
error: fieldState.error ? fieldState.error.message || t(`${prefixedNameWithoutIndices}.error.${fieldState.error.type}`) : void 0,
|
|
918
|
-
testId: testId ?? `input-${nameWithPrefix}
|
|
923
|
+
testId: testId ?? `input-${nameWithPrefix}`,
|
|
924
|
+
ref
|
|
919
925
|
}, children)
|
|
920
926
|
});
|
|
921
927
|
}
|
|
922
|
-
var ControlledChipInputField_default = ControlledChipInputField;
|
|
928
|
+
var ControlledChipInputField_default = withForwardRef(ControlledChipInputField);
|
|
923
929
|
|
|
924
930
|
// src/ScmFormListContext.tsx
|
|
925
931
|
import React23, { useContext as useContext4, useMemo as useMemo4 } from "react";
|
|
@@ -1323,18 +1329,193 @@ function ControlledComboboxField({
|
|
|
1323
1329
|
}
|
|
1324
1330
|
var ControlledComboboxField_default = ControlledComboboxField;
|
|
1325
1331
|
|
|
1332
|
+
// src/radio-button/ControlledRadioGroupField.tsx
|
|
1333
|
+
import React35 from "react";
|
|
1334
|
+
|
|
1335
|
+
// src/radio-button/RadioGroupField.tsx
|
|
1336
|
+
import React34 from "react";
|
|
1337
|
+
|
|
1338
|
+
// src/radio-button/RadioGroup.tsx
|
|
1339
|
+
import React33 from "react";
|
|
1340
|
+
import * as RadixRadio from "@radix-ui/react-radio-group";
|
|
1341
|
+
|
|
1342
|
+
// src/radio-button/RadioButton.tsx
|
|
1343
|
+
import React32 from "react";
|
|
1344
|
+
import classNames19 from "classnames";
|
|
1345
|
+
import * as RadioGroup from "@radix-ui/react-radio-group";
|
|
1346
|
+
import { createAttributesForTesting as createAttributesForTesting6, useGeneratedId as useGeneratedId5 } from "@scm-manager/ui-components";
|
|
1347
|
+
import styled6 from "styled-components";
|
|
1348
|
+
|
|
1349
|
+
// src/radio-button/RadioButtonContext.tsx
|
|
1350
|
+
import React31, { createContext as createContext2, useContext as useContext5 } from "react";
|
|
1351
|
+
var RadioButtonContext = createContext2(null);
|
|
1352
|
+
function useRadioButtonContext() {
|
|
1353
|
+
return useContext5(RadioButtonContext);
|
|
1354
|
+
}
|
|
1355
|
+
var RadioButtonContextProvider = ({ children, ...props }) => /* @__PURE__ */ React31.createElement(RadioButtonContext.Provider, {
|
|
1356
|
+
value: props
|
|
1357
|
+
}, children);
|
|
1358
|
+
|
|
1359
|
+
// src/radio-button/RadioButton.tsx
|
|
1360
|
+
var StyledRadioButton = styled6(RadioGroup.Item)`
|
|
1361
|
+
all: unset;
|
|
1362
|
+
width: 1rem;
|
|
1363
|
+
height: 1rem;
|
|
1364
|
+
border: var(--scm-border);
|
|
1365
|
+
border-radius: 100%;
|
|
1366
|
+
|
|
1367
|
+
:hover {
|
|
1368
|
+
border-color: var(--scm-hover-color);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
:hover *::after {
|
|
1372
|
+
background-color: var(--scm-info-hover-color);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
:disabled {
|
|
1376
|
+
background-color: var(--scm-dark-color-25);
|
|
1377
|
+
border-color: var(--scm-hover-color);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
:disabled *::after {
|
|
1381
|
+
background-color: var(--scm-info-color);
|
|
1382
|
+
}
|
|
1383
|
+
`;
|
|
1384
|
+
var StyledIndicator = styled6(RadioGroup.Indicator)`
|
|
1385
|
+
display: flex;
|
|
1386
|
+
align-items: center;
|
|
1387
|
+
justify-content: center;
|
|
1388
|
+
width: 100%;
|
|
1389
|
+
height: 100%;
|
|
1390
|
+
position: relative;
|
|
1391
|
+
|
|
1392
|
+
::after {
|
|
1393
|
+
content: "";
|
|
1394
|
+
display: block;
|
|
1395
|
+
width: 0.5rem;
|
|
1396
|
+
height: 0.5rem;
|
|
1397
|
+
border-radius: 50%;
|
|
1398
|
+
background-color: var(--scm-info-color);
|
|
1399
|
+
}
|
|
1400
|
+
`;
|
|
1401
|
+
var RadioButton = React32.forwardRef(
|
|
1402
|
+
({ id, testId, indicatorClassName, label, labelClassName, className, helpText, value, ...props }, ref) => {
|
|
1403
|
+
const context = useRadioButtonContext();
|
|
1404
|
+
const inputId = useGeneratedId5(id);
|
|
1405
|
+
const labelKey = `${context == null ? void 0 : context.prefix}.radio.${value}`;
|
|
1406
|
+
return /* @__PURE__ */ React32.createElement("label", {
|
|
1407
|
+
className: classNames19("radio is-flex is-align-items-center", labelClassName),
|
|
1408
|
+
htmlFor: inputId
|
|
1409
|
+
}, /* @__PURE__ */ React32.createElement(StyledRadioButton, {
|
|
1410
|
+
form: context == null ? void 0 : context.formId,
|
|
1411
|
+
id: inputId,
|
|
1412
|
+
value,
|
|
1413
|
+
ref,
|
|
1414
|
+
className: classNames19("mr-3 mt-3 mb-3", className),
|
|
1415
|
+
...props,
|
|
1416
|
+
...createAttributesForTesting6(testId)
|
|
1417
|
+
}, /* @__PURE__ */ React32.createElement(StyledIndicator, {
|
|
1418
|
+
className: indicatorClassName
|
|
1419
|
+
})), label ?? (context == null ? void 0 : context.t(labelKey)) ?? value, helpText ? /* @__PURE__ */ React32.createElement(Help_default, {
|
|
1420
|
+
className: "ml-3",
|
|
1421
|
+
text: helpText
|
|
1422
|
+
}) : null);
|
|
1423
|
+
}
|
|
1424
|
+
);
|
|
1425
|
+
var RadioButton_default = RadioButton;
|
|
1426
|
+
|
|
1427
|
+
// src/radio-button/RadioGroup.tsx
|
|
1428
|
+
var RadioGroup2 = React33.forwardRef(({ options, children, className, ...props }, ref) => /* @__PURE__ */ React33.createElement(RadixRadio.Root, {
|
|
1429
|
+
...props,
|
|
1430
|
+
asChild: true
|
|
1431
|
+
}, /* @__PURE__ */ React33.createElement(Control_default, {
|
|
1432
|
+
ref,
|
|
1433
|
+
className
|
|
1434
|
+
}, children ?? (options == null ? void 0 : options.map((option) => /* @__PURE__ */ React33.createElement(RadioButton_default, {
|
|
1435
|
+
key: option.value,
|
|
1436
|
+
value: option.value,
|
|
1437
|
+
label: option.label,
|
|
1438
|
+
helpText: option.helpText
|
|
1439
|
+
}))))));
|
|
1440
|
+
var RadioGroup_default = RadioGroup2;
|
|
1441
|
+
|
|
1442
|
+
// src/radio-button/RadioGroupField.tsx
|
|
1443
|
+
var RadioGroupField = React34.forwardRef(
|
|
1444
|
+
({ fieldClassName, labelClassName, label, helpText, children, ...props }, ref) => {
|
|
1445
|
+
return /* @__PURE__ */ React34.createElement(Field_default, {
|
|
1446
|
+
className: fieldClassName,
|
|
1447
|
+
as: "fieldset"
|
|
1448
|
+
}, /* @__PURE__ */ React34.createElement(Label_default, {
|
|
1449
|
+
className: labelClassName,
|
|
1450
|
+
as: "legend"
|
|
1451
|
+
}, label, helpText ? /* @__PURE__ */ React34.createElement(Help_default, {
|
|
1452
|
+
className: "ml-1",
|
|
1453
|
+
text: helpText
|
|
1454
|
+
}) : null), /* @__PURE__ */ React34.createElement(RadioGroup_default, {
|
|
1455
|
+
ref,
|
|
1456
|
+
...props
|
|
1457
|
+
}, children));
|
|
1458
|
+
}
|
|
1459
|
+
);
|
|
1460
|
+
var RadioGroupField_default = RadioGroupField;
|
|
1461
|
+
|
|
1462
|
+
// src/radio-button/ControlledRadioGroupField.tsx
|
|
1463
|
+
import { Controller as Controller7 } from "react-hook-form";
|
|
1464
|
+
import classNames20 from "classnames";
|
|
1465
|
+
function ControlledRadioGroupField({
|
|
1466
|
+
name,
|
|
1467
|
+
label,
|
|
1468
|
+
helpText,
|
|
1469
|
+
rules,
|
|
1470
|
+
defaultValue,
|
|
1471
|
+
children,
|
|
1472
|
+
fieldClassName,
|
|
1473
|
+
readOnly,
|
|
1474
|
+
...props
|
|
1475
|
+
}) {
|
|
1476
|
+
const { control, t, readOnly: formReadOnly, formId } = useScmFormContext();
|
|
1477
|
+
const formPathPrefix = useScmFormPathContext();
|
|
1478
|
+
const nameWithPrefix = formPathPrefix ? `${formPathPrefix}.${name}` : name;
|
|
1479
|
+
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
1480
|
+
const labelTranslation = label ?? t(`${prefixedNameWithoutIndices}.label`) ?? "";
|
|
1481
|
+
const helpTextTranslation = helpText ?? t(`${prefixedNameWithoutIndices}.helpText`);
|
|
1482
|
+
return /* @__PURE__ */ React35.createElement(Controller7, {
|
|
1483
|
+
control,
|
|
1484
|
+
name: nameWithPrefix,
|
|
1485
|
+
rules,
|
|
1486
|
+
defaultValue,
|
|
1487
|
+
render: ({ field }) => /* @__PURE__ */ React35.createElement(RadioButtonContextProvider, {
|
|
1488
|
+
t,
|
|
1489
|
+
prefix: prefixedNameWithoutIndices,
|
|
1490
|
+
formId
|
|
1491
|
+
}, /* @__PURE__ */ React35.createElement(RadioGroupField_default, {
|
|
1492
|
+
defaultValue,
|
|
1493
|
+
disabled: readOnly ?? formReadOnly,
|
|
1494
|
+
required: rules == null ? void 0 : rules.required,
|
|
1495
|
+
label: labelTranslation,
|
|
1496
|
+
helpText: helpTextTranslation,
|
|
1497
|
+
fieldClassName: classNames20("column", fieldClassName),
|
|
1498
|
+
onValueChange: field.onChange,
|
|
1499
|
+
...props,
|
|
1500
|
+
...field,
|
|
1501
|
+
name: nameWithPrefix
|
|
1502
|
+
}, children))
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
var ControlledRadioGroupField_default = ControlledRadioGroupField;
|
|
1506
|
+
|
|
1326
1507
|
// src/ConfigurationForm.tsx
|
|
1327
1508
|
import { useConfigLink } from "@scm-manager/ui-api";
|
|
1328
1509
|
import { Loading } from "@scm-manager/ui-components";
|
|
1329
|
-
import
|
|
1510
|
+
import React36 from "react";
|
|
1330
1511
|
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
1331
1512
|
function ConfigurationForm({ link, children, ...formProps }) {
|
|
1332
1513
|
const { initialConfiguration, isReadOnly, update, isLoading } = useConfigLink(link);
|
|
1333
1514
|
const [t] = useTranslation6("commons", { keyPrefix: "form" });
|
|
1334
1515
|
if (isLoading || !initialConfiguration) {
|
|
1335
|
-
return /* @__PURE__ */
|
|
1516
|
+
return /* @__PURE__ */ React36.createElement(Loading, null);
|
|
1336
1517
|
}
|
|
1337
|
-
return /* @__PURE__ */
|
|
1518
|
+
return /* @__PURE__ */ React36.createElement(Form_default, {
|
|
1338
1519
|
onSubmit: update,
|
|
1339
1520
|
defaultValues: initialConfiguration,
|
|
1340
1521
|
readOnly: isReadOnly,
|
|
@@ -1345,15 +1526,15 @@ function ConfigurationForm({ link, children, ...formProps }) {
|
|
|
1345
1526
|
var ConfigurationForm_default = ConfigurationForm;
|
|
1346
1527
|
|
|
1347
1528
|
// src/input/Textarea.tsx
|
|
1348
|
-
import
|
|
1349
|
-
import
|
|
1350
|
-
import { createAttributesForTesting as
|
|
1351
|
-
var Textarea =
|
|
1352
|
-
return /* @__PURE__ */
|
|
1529
|
+
import React37 from "react";
|
|
1530
|
+
import classNames21 from "classnames";
|
|
1531
|
+
import { createAttributesForTesting as createAttributesForTesting7 } from "@scm-manager/ui-components";
|
|
1532
|
+
var Textarea = React37.forwardRef(({ variant, className, testId, ...props }, ref) => {
|
|
1533
|
+
return /* @__PURE__ */ React37.createElement("textarea", {
|
|
1353
1534
|
ref,
|
|
1354
|
-
className:
|
|
1535
|
+
className: classNames21("textarea", createVariantClass(variant), className),
|
|
1355
1536
|
...props,
|
|
1356
|
-
...
|
|
1537
|
+
...createAttributesForTesting7(testId)
|
|
1357
1538
|
});
|
|
1358
1539
|
});
|
|
1359
1540
|
var Textarea_default = Textarea;
|
|
@@ -1445,6 +1626,11 @@ var useDeleteResource = (idFactory, { collectionName: [entityQueryKey, collectio
|
|
|
1445
1626
|
};
|
|
1446
1627
|
|
|
1447
1628
|
// src/index.ts
|
|
1629
|
+
var RadioGroupExport = {
|
|
1630
|
+
Option: RadioButton_default
|
|
1631
|
+
};
|
|
1632
|
+
var RadioGroup3 = Object.assign(RadioGroup_default, RadioGroupExport);
|
|
1633
|
+
var RadioGroupField2 = Object.assign(RadioGroupField_default, RadioGroupExport);
|
|
1448
1634
|
var ChipInputField3 = Object.assign(ChipInputField_default, {
|
|
1449
1635
|
AddButton: ChipInput_default.AddButton
|
|
1450
1636
|
});
|
|
@@ -1462,7 +1648,8 @@ var Form2 = Object.assign(Form_default, {
|
|
|
1462
1648
|
Column: ControlledColumn_default
|
|
1463
1649
|
}),
|
|
1464
1650
|
ChipInput: ControlledChipInputField_default,
|
|
1465
|
-
Combobox: ControlledComboboxField_default
|
|
1651
|
+
Combobox: ControlledComboboxField_default,
|
|
1652
|
+
RadioGroup: Object.assign(ControlledRadioGroupField_default, RadioGroupExport)
|
|
1466
1653
|
});
|
|
1467
1654
|
export {
|
|
1468
1655
|
Checkbox_default as Checkbox,
|
|
@@ -1474,6 +1661,8 @@ export {
|
|
|
1474
1661
|
Form2 as Form,
|
|
1475
1662
|
Input_default as Input,
|
|
1476
1663
|
Label_default as Label,
|
|
1664
|
+
RadioGroup3 as RadioGroup,
|
|
1665
|
+
RadioGroupField2 as RadioGroupField,
|
|
1477
1666
|
Select_default as Select,
|
|
1478
1667
|
SelectField_default as SelectField,
|
|
1479
1668
|
Textarea_default as Textarea,
|