@scm-manager/ui-forms 2.43.1-20230408-141027 → 2.43.1

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