@scm-manager/ui-forms 2.43.1 → 2.43.2-20230419-125637
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 +8 -2
- package/build/index.js +24 -12
- package/build/index.mjs +20 -10
- package/package.json +6 -6
- package/src/AddListEntryForm.tsx +5 -1
- package/src/index.ts +2 -0
- package/src/select/Select.tsx +8 -4
- package/src/select/SelectField.tsx +2 -0
- package/src/table/ControlledTable.tsx +3 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@scm-manager/ui-forms:build: cache hit, replaying output
|
|
1
|
+
@scm-manager/ui-forms:build: cache hit, replaying output ba53194cea81ebc1
|
|
2
2
|
@scm-manager/ui-forms:build: $ tsup ./src/index.ts -d build --format esm,cjs --dts
|
|
3
3
|
@scm-manager/ui-forms:build: CLI Building entry: ./src/index.ts
|
|
4
4
|
@scm-manager/ui-forms:build: CLI Using tsconfig: tsconfig.json
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
@scm-manager/ui-forms:build: CLI Target: node14
|
|
7
7
|
@scm-manager/ui-forms:build: ESM Build start
|
|
8
8
|
@scm-manager/ui-forms:build: CJS Build start
|
|
9
|
-
@scm-manager/ui-forms:build: ESM build/index.mjs
|
|
10
|
-
@scm-manager/ui-forms:build: ESM ⚡️ Build success in
|
|
11
|
-
@scm-manager/ui-forms:build: CJS build/index.js
|
|
12
|
-
@scm-manager/ui-forms:build: CJS ⚡️ Build success in
|
|
9
|
+
@scm-manager/ui-forms:build: ESM build/index.mjs 33.03 KB
|
|
10
|
+
@scm-manager/ui-forms:build: ESM ⚡️ Build success in 755ms
|
|
11
|
+
@scm-manager/ui-forms:build: CJS build/index.js 38.09 KB
|
|
12
|
+
@scm-manager/ui-forms:build: CJS ⚡️ Build success in 707ms
|
|
13
13
|
@scm-manager/ui-forms:build: DTS Build start
|
|
14
|
-
@scm-manager/ui-forms:build: DTS ⚡️ Build success in
|
|
15
|
-
@scm-manager/ui-forms:build: DTS build/index.d.ts 21.
|
|
14
|
+
@scm-manager/ui-forms:build: DTS ⚡️ Build success in 45213ms
|
|
15
|
+
@scm-manager/ui-forms:build: DTS build/index.d.ts 21.65 KB
|
package/build/index.d.ts
CHANGED
|
@@ -93,6 +93,10 @@ declare type Props$6<T extends Record<string, unknown>> = Omit<ComponentProps<ty
|
|
|
93
93
|
};
|
|
94
94
|
declare function ControlledSecretConfirmationField<T extends Record<string, unknown>>({ name, label, confirmationLabel, helpText, confirmationHelpText, rules, confirmationErrorMessage, className, testId, confirmationTestId, defaultValue, readOnly, ...props }: Props$6<T>): JSX.Element;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @beta
|
|
98
|
+
* @since 2.44.0
|
|
99
|
+
*/
|
|
96
100
|
declare const Select: React__default.ForwardRefExoticComponent<{
|
|
97
101
|
variant?: "danger" | undefined;
|
|
98
102
|
options?: (React__default.OptionHTMLAttributes<HTMLOptionElement> & {
|
|
@@ -108,6 +112,8 @@ declare type Props$5 = {
|
|
|
108
112
|
} & React__default.ComponentProps<typeof Select>;
|
|
109
113
|
/**
|
|
110
114
|
* @see https://bulma.io/documentation/form/select/
|
|
115
|
+
* @beta
|
|
116
|
+
* @since 2.44.0
|
|
111
117
|
*/
|
|
112
118
|
declare const SelectField: React__default.ForwardRefExoticComponent<Pick<Props$5, "label" | "key" | "testId" | "error" | "helpText" | "options" | "variant" | keyof React__default.InputHTMLAttributes<HTMLSelectElement>> & React__default.RefAttributes<HTMLSelectElement>>;
|
|
113
119
|
|
|
@@ -148,7 +154,7 @@ declare type Props$2<T extends Record<string, unknown>, PATH extends Path<T>> =
|
|
|
148
154
|
* @beta
|
|
149
155
|
* @since 2.43.0
|
|
150
156
|
*/
|
|
151
|
-
declare function ControlledTable<T extends Record<string, unknown>, PATH extends Path<T>>({ withDelete, children, className, }: Props$2<T, PATH>): JSX.Element
|
|
157
|
+
declare function ControlledTable<T extends Record<string, unknown>, PATH extends Path<T>>({ withDelete, children, className, }: Props$2<T, PATH>): JSX.Element;
|
|
152
158
|
|
|
153
159
|
declare type RenderProps<T extends Record<string, unknown>> = Omit<UseFormReturn<T>, "register" | "unregister" | "handleSubmit" | "control">;
|
|
154
160
|
declare type Props$1<FormType extends Record<string, unknown>, DefaultValues extends FormType> = {
|
|
@@ -231,4 +237,4 @@ declare const Form: typeof Form$1 & {
|
|
|
231
237
|
};
|
|
232
238
|
};
|
|
233
239
|
|
|
234
|
-
export { ConfigurationForm, Form, useCreateResource, useDeleteResource, useUpdateResource };
|
|
240
|
+
export { ConfigurationForm, Form, Select, SelectField, useCreateResource, useDeleteResource, useUpdateResource };
|
package/build/index.js
CHANGED
|
@@ -28,6 +28,8 @@ var src_exports = {};
|
|
|
28
28
|
__export(src_exports, {
|
|
29
29
|
ConfigurationForm: () => ConfigurationForm_default,
|
|
30
30
|
Form: () => Form2,
|
|
31
|
+
Select: () => Select_default,
|
|
32
|
+
SelectField: () => SelectField_default,
|
|
31
33
|
useCreateResource: () => useCreateResource,
|
|
32
34
|
useDeleteResource: () => useDeleteResource,
|
|
33
35
|
useUpdateResource: () => useUpdateResource
|
|
@@ -560,10 +562,10 @@ var Select = import_react17.default.forwardRef(
|
|
|
560
562
|
...props,
|
|
561
563
|
...(0, import_ui_components5.createAttributesForTesting)(testId),
|
|
562
564
|
className
|
|
563
|
-
}, options ? options.map((
|
|
564
|
-
...
|
|
565
|
-
key:
|
|
566
|
-
},
|
|
565
|
+
}, options ? options.map((opt) => /* @__PURE__ */ import_react17.default.createElement("option", {
|
|
566
|
+
...opt,
|
|
567
|
+
key: opt.value
|
|
568
|
+
}, opt.label, opt.children)) : children))
|
|
567
569
|
);
|
|
568
570
|
var Select_default = Select;
|
|
569
571
|
|
|
@@ -692,6 +694,7 @@ var import_react22 = __toESM(require("react"));
|
|
|
692
694
|
var import_ui_buttons3 = require("@scm-manager/ui-buttons");
|
|
693
695
|
var import_classnames12 = __toESM(require("classnames"));
|
|
694
696
|
var import_react_i18next3 = require("react-i18next");
|
|
697
|
+
var import_ui_components7 = require("@scm-manager/ui-components");
|
|
695
698
|
function ControlledTable({
|
|
696
699
|
withDelete,
|
|
697
700
|
children,
|
|
@@ -703,15 +706,17 @@ function ControlledTable({
|
|
|
703
706
|
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
704
707
|
const { fields, remove } = useScmFormListContext();
|
|
705
708
|
const deleteLabel = t(`${prefixedNameWithoutIndices}.delete`) || defaultTranslate("delete.label");
|
|
709
|
+
const emptyTableLabel = t(`${prefixedNameWithoutIndices}.empty`) || defaultTranslate("empty.label");
|
|
706
710
|
const actionHeaderLabel = t(`${prefixedNameWithoutIndices}.action.label`) || defaultTranslate("headers.action.label");
|
|
707
|
-
if (!fields.length) {
|
|
708
|
-
return null;
|
|
709
|
-
}
|
|
710
711
|
return /* @__PURE__ */ import_react22.default.createElement("table", {
|
|
711
712
|
className: (0, import_classnames12.default)("table content is-hoverable", className)
|
|
712
713
|
}, /* @__PURE__ */ import_react22.default.createElement("thead", null, /* @__PURE__ */ import_react22.default.createElement("tr", null, import_react22.default.Children.map(children, (child) => /* @__PURE__ */ import_react22.default.createElement("th", null, t(`${prefixedNameWithoutIndices}.${child.props.name}.label`))), withDelete && !readOnly ? /* @__PURE__ */ import_react22.default.createElement("th", {
|
|
713
714
|
className: "has-text-right"
|
|
714
|
-
}, actionHeaderLabel) : null)), /* @__PURE__ */ import_react22.default.createElement("tbody", null, fields.
|
|
715
|
+
}, actionHeaderLabel) : null)), /* @__PURE__ */ import_react22.default.createElement("tbody", null, fields.length === 0 ? /* @__PURE__ */ import_react22.default.createElement("tr", null, /* @__PURE__ */ import_react22.default.createElement("td", {
|
|
716
|
+
colSpan: 1e3
|
|
717
|
+
}, /* @__PURE__ */ import_react22.default.createElement(import_ui_components7.Notification, {
|
|
718
|
+
type: "info"
|
|
719
|
+
}, emptyTableLabel))) : null, fields.map((value, index) => /* @__PURE__ */ import_react22.default.createElement(ScmFormPathContextProvider, {
|
|
715
720
|
key: value.id,
|
|
716
721
|
path: `${nameWithPrefix}.${index}`
|
|
717
722
|
}, /* @__PURE__ */ import_react22.default.createElement("tr", null, children, withDelete && !readOnly ? /* @__PURE__ */ import_react22.default.createElement("td", {
|
|
@@ -781,6 +786,9 @@ function AddListEntryForm({
|
|
|
781
786
|
const submitButtonLabel = translateWithExtraPrefix("add", {
|
|
782
787
|
defaultValue: defaultTranslate("list.add.label", { entity: translateWithExtraPrefix("entity") })
|
|
783
788
|
});
|
|
789
|
+
const titleLabel = translateWithExtraPrefix("title", {
|
|
790
|
+
defaultValue: defaultTranslate("list.title.label", { entity: translateWithExtraPrefix("entity") })
|
|
791
|
+
});
|
|
784
792
|
(0, import_react24.useEffect)(() => {
|
|
785
793
|
if (isSubmitSuccessful) {
|
|
786
794
|
reset(defaultValues);
|
|
@@ -795,12 +803,14 @@ function AddListEntryForm({
|
|
|
795
803
|
formId: nameWithPrefix
|
|
796
804
|
}, /* @__PURE__ */ import_react24.default.createElement(ScmFormPathContextProvider, {
|
|
797
805
|
path: ""
|
|
798
|
-
}, /* @__PURE__ */ import_react24.default.createElement("
|
|
806
|
+
}, /* @__PURE__ */ import_react24.default.createElement("h3", {
|
|
807
|
+
className: "subtitle is-5"
|
|
808
|
+
}, titleLabel), /* @__PURE__ */ import_react24.default.createElement("form", {
|
|
799
809
|
id: nameWithPrefix,
|
|
800
810
|
onSubmit: form.handleSubmit(onSubmit),
|
|
801
811
|
noValidate: true
|
|
802
812
|
}), typeof children === "function" ? children(form) : children, /* @__PURE__ */ import_react24.default.createElement("div", {
|
|
803
|
-
className: "level-
|
|
813
|
+
className: "level-left"
|
|
804
814
|
}, /* @__PURE__ */ import_react24.default.createElement(import_ui_buttons4.Button, {
|
|
805
815
|
form: nameWithPrefix,
|
|
806
816
|
type: "submit",
|
|
@@ -812,14 +822,14 @@ var AddListEntryForm_default = AddListEntryForm;
|
|
|
812
822
|
|
|
813
823
|
// src/ConfigurationForm.tsx
|
|
814
824
|
var import_ui_api = require("@scm-manager/ui-api");
|
|
815
|
-
var
|
|
825
|
+
var import_ui_components8 = require("@scm-manager/ui-components");
|
|
816
826
|
var import_react25 = __toESM(require("react"));
|
|
817
827
|
var import_react_i18next5 = require("react-i18next");
|
|
818
828
|
function ConfigurationForm({ link, children, ...formProps }) {
|
|
819
829
|
const { initialConfiguration, isReadOnly, update, isLoading } = (0, import_ui_api.useConfigLink)(link);
|
|
820
830
|
const [t] = (0, import_react_i18next5.useTranslation)("commons", { keyPrefix: "form" });
|
|
821
831
|
if (isLoading || !initialConfiguration) {
|
|
822
|
-
return /* @__PURE__ */ import_react25.default.createElement(
|
|
832
|
+
return /* @__PURE__ */ import_react25.default.createElement(import_ui_components8.Loading, null);
|
|
823
833
|
}
|
|
824
834
|
return /* @__PURE__ */ import_react25.default.createElement(Form_default, {
|
|
825
835
|
onSubmit: update,
|
|
@@ -936,6 +946,8 @@ var Form2 = Object.assign(Form_default, {
|
|
|
936
946
|
0 && (module.exports = {
|
|
937
947
|
ConfigurationForm,
|
|
938
948
|
Form,
|
|
949
|
+
Select,
|
|
950
|
+
SelectField,
|
|
939
951
|
useCreateResource,
|
|
940
952
|
useDeleteResource,
|
|
941
953
|
useUpdateResource
|
package/build/index.mjs
CHANGED
|
@@ -524,10 +524,10 @@ var Select = React17.forwardRef(
|
|
|
524
524
|
...props,
|
|
525
525
|
...createAttributesForTesting3(testId),
|
|
526
526
|
className
|
|
527
|
-
}, options ? options.map((
|
|
528
|
-
...
|
|
529
|
-
key:
|
|
530
|
-
},
|
|
527
|
+
}, options ? options.map((opt) => /* @__PURE__ */ React17.createElement("option", {
|
|
528
|
+
...opt,
|
|
529
|
+
key: opt.value
|
|
530
|
+
}, opt.label, opt.children)) : children))
|
|
531
531
|
);
|
|
532
532
|
var Select_default = Select;
|
|
533
533
|
|
|
@@ -656,6 +656,7 @@ import React22 from "react";
|
|
|
656
656
|
import { Button as Button3 } from "@scm-manager/ui-buttons";
|
|
657
657
|
import classNames12 from "classnames";
|
|
658
658
|
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
659
|
+
import { Notification } from "@scm-manager/ui-components";
|
|
659
660
|
function ControlledTable({
|
|
660
661
|
withDelete,
|
|
661
662
|
children,
|
|
@@ -667,15 +668,17 @@ function ControlledTable({
|
|
|
667
668
|
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
668
669
|
const { fields, remove } = useScmFormListContext();
|
|
669
670
|
const deleteLabel = t(`${prefixedNameWithoutIndices}.delete`) || defaultTranslate("delete.label");
|
|
671
|
+
const emptyTableLabel = t(`${prefixedNameWithoutIndices}.empty`) || defaultTranslate("empty.label");
|
|
670
672
|
const actionHeaderLabel = t(`${prefixedNameWithoutIndices}.action.label`) || defaultTranslate("headers.action.label");
|
|
671
|
-
if (!fields.length) {
|
|
672
|
-
return null;
|
|
673
|
-
}
|
|
674
673
|
return /* @__PURE__ */ React22.createElement("table", {
|
|
675
674
|
className: classNames12("table content is-hoverable", className)
|
|
676
675
|
}, /* @__PURE__ */ React22.createElement("thead", null, /* @__PURE__ */ React22.createElement("tr", null, React22.Children.map(children, (child) => /* @__PURE__ */ React22.createElement("th", null, t(`${prefixedNameWithoutIndices}.${child.props.name}.label`))), withDelete && !readOnly ? /* @__PURE__ */ React22.createElement("th", {
|
|
677
676
|
className: "has-text-right"
|
|
678
|
-
}, actionHeaderLabel) : null)), /* @__PURE__ */ React22.createElement("tbody", null, fields.
|
|
677
|
+
}, actionHeaderLabel) : null)), /* @__PURE__ */ React22.createElement("tbody", null, fields.length === 0 ? /* @__PURE__ */ React22.createElement("tr", null, /* @__PURE__ */ React22.createElement("td", {
|
|
678
|
+
colSpan: 1e3
|
|
679
|
+
}, /* @__PURE__ */ React22.createElement(Notification, {
|
|
680
|
+
type: "info"
|
|
681
|
+
}, emptyTableLabel))) : null, fields.map((value, index) => /* @__PURE__ */ React22.createElement(ScmFormPathContextProvider, {
|
|
679
682
|
key: value.id,
|
|
680
683
|
path: `${nameWithPrefix}.${index}`
|
|
681
684
|
}, /* @__PURE__ */ React22.createElement("tr", null, children, withDelete && !readOnly ? /* @__PURE__ */ React22.createElement("td", {
|
|
@@ -745,6 +748,9 @@ function AddListEntryForm({
|
|
|
745
748
|
const submitButtonLabel = translateWithExtraPrefix("add", {
|
|
746
749
|
defaultValue: defaultTranslate("list.add.label", { entity: translateWithExtraPrefix("entity") })
|
|
747
750
|
});
|
|
751
|
+
const titleLabel = translateWithExtraPrefix("title", {
|
|
752
|
+
defaultValue: defaultTranslate("list.title.label", { entity: translateWithExtraPrefix("entity") })
|
|
753
|
+
});
|
|
748
754
|
useEffect2(() => {
|
|
749
755
|
if (isSubmitSuccessful) {
|
|
750
756
|
reset(defaultValues);
|
|
@@ -759,12 +765,14 @@ function AddListEntryForm({
|
|
|
759
765
|
formId: nameWithPrefix
|
|
760
766
|
}, /* @__PURE__ */ React24.createElement(ScmFormPathContextProvider, {
|
|
761
767
|
path: ""
|
|
762
|
-
}, /* @__PURE__ */ React24.createElement("
|
|
768
|
+
}, /* @__PURE__ */ React24.createElement("h3", {
|
|
769
|
+
className: "subtitle is-5"
|
|
770
|
+
}, titleLabel), /* @__PURE__ */ React24.createElement("form", {
|
|
763
771
|
id: nameWithPrefix,
|
|
764
772
|
onSubmit: form.handleSubmit(onSubmit),
|
|
765
773
|
noValidate: true
|
|
766
774
|
}), typeof children === "function" ? children(form) : children, /* @__PURE__ */ React24.createElement("div", {
|
|
767
|
-
className: "level-
|
|
775
|
+
className: "level-left"
|
|
768
776
|
}, /* @__PURE__ */ React24.createElement(Button4, {
|
|
769
777
|
form: nameWithPrefix,
|
|
770
778
|
type: "submit",
|
|
@@ -899,6 +907,8 @@ var Form2 = Object.assign(Form_default, {
|
|
|
899
907
|
export {
|
|
900
908
|
ConfigurationForm_default as ConfigurationForm,
|
|
901
909
|
Form2 as Form,
|
|
910
|
+
Select_default as Select,
|
|
911
|
+
SelectField_default as SelectField,
|
|
902
912
|
useCreateResource,
|
|
903
913
|
useDeleteResource,
|
|
904
914
|
useUpdateResource
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scm-manager/ui-forms",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.43.
|
|
4
|
+
"version": "2.43.2-20230419-125637",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
7
|
"module": "build/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@scm-manager/eslint-config": "^2.16.0",
|
|
17
17
|
"@scm-manager/prettier-config": "^2.10.1",
|
|
18
18
|
"@scm-manager/tsconfig": "^2.13.0",
|
|
19
|
-
"@scm-manager/ui-styles": "2.43.
|
|
19
|
+
"@scm-manager/ui-styles": "2.43.2-20230419-125637",
|
|
20
20
|
"@storybook/addon-actions": "^6.5.10",
|
|
21
21
|
"@storybook/addon-essentials": "^6.5.10",
|
|
22
22
|
"@storybook/addon-interactions": "^6.5.10",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"tsup": "^6.2.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@scm-manager/ui-components": "2.43.
|
|
35
|
+
"@scm-manager/ui-components": "2.43.2-20230419-125637",
|
|
36
36
|
"classnames": "^2.3.1",
|
|
37
37
|
"react": "17",
|
|
38
38
|
"react-hook-form": "7",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"styled-components": "5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@scm-manager/ui-buttons": "2.43.
|
|
45
|
-
"@scm-manager/ui-overlays": "2.43.
|
|
46
|
-
"@scm-manager/ui-api": "2.43.
|
|
44
|
+
"@scm-manager/ui-buttons": "2.43.2-20230419-125637",
|
|
45
|
+
"@scm-manager/ui-overlays": "2.43.2-20230419-125637",
|
|
46
|
+
"@scm-manager/ui-api": "2.43.2-20230419-125637"
|
|
47
47
|
},
|
|
48
48
|
"prettier": "@scm-manager/prettier-config",
|
|
49
49
|
"eslintConfig": {
|
package/src/AddListEntryForm.tsx
CHANGED
|
@@ -88,6 +88,9 @@ function AddListEntryForm<FormType extends Record<string, unknown>, DefaultValue
|
|
|
88
88
|
const submitButtonLabel = translateWithExtraPrefix("add", {
|
|
89
89
|
defaultValue: defaultTranslate("list.add.label", { entity: translateWithExtraPrefix("entity") }),
|
|
90
90
|
});
|
|
91
|
+
const titleLabel = translateWithExtraPrefix("title", {
|
|
92
|
+
defaultValue: defaultTranslate("list.title.label", { entity: translateWithExtraPrefix("entity") }),
|
|
93
|
+
});
|
|
91
94
|
|
|
92
95
|
useEffect(() => {
|
|
93
96
|
if (isSubmitSuccessful) {
|
|
@@ -102,9 +105,10 @@ function AddListEntryForm<FormType extends Record<string, unknown>, DefaultValue
|
|
|
102
105
|
return (
|
|
103
106
|
<ScmFormContextProvider {...form} t={translateWithExtraPrefix} formId={nameWithPrefix}>
|
|
104
107
|
<ScmFormPathContextProvider path="">
|
|
108
|
+
<h3 className="subtitle is-5">{titleLabel}</h3>
|
|
105
109
|
<form id={nameWithPrefix} onSubmit={form.handleSubmit(onSubmit)} noValidate></form>
|
|
106
110
|
{typeof children === "function" ? children(form) : children}
|
|
107
|
-
<div className="level-
|
|
111
|
+
<div className="level-left">
|
|
108
112
|
<Button
|
|
109
113
|
form={nameWithPrefix}
|
|
110
114
|
type="submit"
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,8 @@ import AddListEntryForm from "./AddListEntryForm";
|
|
|
36
36
|
import { ScmNestedFormPathContextProvider } from "./FormPathContext";
|
|
37
37
|
|
|
38
38
|
export { default as ConfigurationForm } from "./ConfigurationForm";
|
|
39
|
+
export { default as SelectField } from "./select/SelectField";
|
|
40
|
+
export { default as Select } from "./select/Select";
|
|
39
41
|
export * from "./resourceHooks";
|
|
40
42
|
|
|
41
43
|
export const Form = Object.assign(FormCmp, {
|
package/src/select/Select.tsx
CHANGED
|
@@ -33,15 +33,19 @@ type Props = {
|
|
|
33
33
|
testId?: string;
|
|
34
34
|
} & InputHTMLAttributes<HTMLSelectElement>;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @beta
|
|
38
|
+
* @since 2.44.0
|
|
39
|
+
*/
|
|
36
40
|
const Select = React.forwardRef<HTMLSelectElement, Props>(
|
|
37
41
|
({ variant, children, className, options, testId, ...props }, ref) => (
|
|
38
42
|
<div className={classNames("select", { "is-multiple": props.multiple }, createVariantClass(variant), className)}>
|
|
39
43
|
<select ref={ref} {...props} {...createAttributesForTesting(testId)} className={className}>
|
|
40
44
|
{options
|
|
41
|
-
? options.map((
|
|
42
|
-
<option {...
|
|
43
|
-
{
|
|
44
|
-
{
|
|
45
|
+
? options.map((opt) => (
|
|
46
|
+
<option {...opt} key={opt.value as Key}>
|
|
47
|
+
{opt.label}
|
|
48
|
+
{opt.children}
|
|
45
49
|
</option>
|
|
46
50
|
))
|
|
47
51
|
: children}
|
|
@@ -31,6 +31,7 @@ import { prefixWithoutIndices } from "../helpers";
|
|
|
31
31
|
import classNames from "classnames";
|
|
32
32
|
import { useScmFormListContext } from "../ScmFormListContext";
|
|
33
33
|
import { useTranslation } from "react-i18next";
|
|
34
|
+
import { Notification } from "@scm-manager/ui-components";
|
|
34
35
|
|
|
35
36
|
type RenderProps<T extends Record<string, unknown>, PATH extends Path<T>> = {
|
|
36
37
|
value: PathValue<T, PATH>;
|
|
@@ -59,12 +60,9 @@ function ControlledTable<T extends Record<string, unknown>, PATH extends Path<T>
|
|
|
59
60
|
const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
|
|
60
61
|
const { fields, remove } = useScmFormListContext();
|
|
61
62
|
const deleteLabel = t(`${prefixedNameWithoutIndices}.delete`) || defaultTranslate("delete.label");
|
|
63
|
+
const emptyTableLabel = t(`${prefixedNameWithoutIndices}.empty`) || defaultTranslate("empty.label");
|
|
62
64
|
const actionHeaderLabel = t(`${prefixedNameWithoutIndices}.action.label`) || defaultTranslate("headers.action.label");
|
|
63
65
|
|
|
64
|
-
if (!fields.length) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
66
|
return (
|
|
69
67
|
<table className={classNames("table content is-hoverable", className)}>
|
|
70
68
|
<thead>
|
|
@@ -76,6 +74,7 @@ function ControlledTable<T extends Record<string, unknown>, PATH extends Path<T>
|
|
|
76
74
|
</tr>
|
|
77
75
|
</thead>
|
|
78
76
|
<tbody>
|
|
77
|
+
{fields.length === 0 ? <tr><td colSpan={1000}><Notification type="info">{emptyTableLabel}</Notification></td></tr> : null}
|
|
79
78
|
{fields.map((value, index) => (
|
|
80
79
|
<ScmFormPathContextProvider key={value.id} path={`${nameWithPrefix}.${index}`}>
|
|
81
80
|
<tr>
|