@scm-manager/ui-core 3.7.2 → 3.7.4-20250125-130119

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,2 +1,2 @@
1
- @scm-manager/ui-core:typecheck: cache hit, replaying output 34604f48788bce34
1
+ @scm-manager/ui-core:typecheck: cache hit, replaying output e3a1d7a588e447bd
2
2
  @scm-manager/ui-core:typecheck: $ tsc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-manager/ui-core",
3
- "version": "3.7.2",
3
+ "version": "3.7.4-20250125-130119",
4
4
  "main": "./src/index.ts",
5
5
  "license": "AGPL-3.0-only",
6
6
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  "styled-components": "5"
21
21
  },
22
22
  "dependencies": {
23
- "@scm-manager/ui-api": "3.7.2",
23
+ "@scm-manager/ui-api": "3.7.4-20250125-130119",
24
24
  "@radix-ui/react-radio-group": "^1.1.3",
25
25
  "@radix-ui/react-slot": "^1.0.1",
26
26
  "@radix-ui/react-visually-hidden": "^1.0.3",
@@ -37,7 +37,7 @@
37
37
  "@scm-manager/eslint-config": "^2.17.0",
38
38
  "@scm-manager/tsconfig": "^2.12.0",
39
39
  "@scm-manager/babel-preset": "^2.13.1",
40
- "@scm-manager/ui-types": "3.7.2",
40
+ "@scm-manager/ui-types": "3.7.4-20250125-130119",
41
41
  "@types/mousetrap": "1.6.5",
42
42
  "@testing-library/react-hooks": "8.0.1",
43
43
  "@testing-library/react": "12.1.5",
@@ -17,7 +17,7 @@
17
17
  import React, { FC, useCallback, useEffect, useState } from "react";
18
18
  import { DeepPartial, SubmitHandler, useForm, UseFormReturn } from "react-hook-form";
19
19
  import { ErrorNotification } from "../notifications";
20
- import { Level } from "../misc";
20
+ import { Level } from "../misc";
21
21
  import { ScmFormContextProvider } from "./ScmFormContext";
22
22
  import { useTranslation } from "react-i18next";
23
23
  import { Button } from "../buttons";
@@ -135,10 +135,10 @@ function Form<FormType extends Record<string, unknown>, DefaultValues extends Fo
135
135
 
136
136
  // See https://react-hook-form.com/api/useform/reset/
137
137
  useEffect(() => {
138
- if (isSubmitSuccessful) {
138
+ if (isSubmitSuccessful && !error) {
139
139
  setShowSuccessNotification(true);
140
140
  }
141
- }, [isSubmitSuccessful]);
141
+ }, [isSubmitSuccessful, error]);
142
142
 
143
143
  useEffect(() => reset(defaultValues as never), [defaultValues, reset]);
144
144
 
@@ -33,6 +33,7 @@ const StyledLabel = styled.label`
33
33
  type InputFieldProps = {
34
34
  label: string;
35
35
  helpText?: string;
36
+ descriptionText?: string;
36
37
  testId?: string;
37
38
  labelClassName?: string;
38
39
  } & Omit<InputHTMLAttributes<HTMLInputElement>, "type">;
@@ -45,6 +46,7 @@ const Checkbox = React.forwardRef<HTMLInputElement, InputFieldProps>(
45
46
  {
46
47
  readOnly,
47
48
  label,
49
+ descriptionText,
48
50
  className,
49
51
  labelClassName,
50
52
  value,
@@ -57,54 +59,63 @@ const Checkbox = React.forwardRef<HTMLInputElement, InputFieldProps>(
57
59
  ...props
58
60
  },
59
61
  ref
60
- ) => (
61
- <StyledLabel
62
- className={classNames("checkbox is-align-items-center", labelClassName)}
63
- // @ts-ignore bulma uses the disabled attribute on labels, although it is not part of the html spec
64
- disabled={readOnly || props.disabled}
65
- >
66
- {readOnly ? (
67
- <>
68
- <input
69
- type="hidden"
70
- name={name}
71
- value={value}
72
- defaultValue={defaultValue}
73
- checked={checked}
74
- defaultChecked={defaultChecked}
75
- readOnly
76
- />
77
- <StyledInput
78
- type="checkbox"
79
- className={classNames("m-3", className)}
80
- ref={ref}
81
- value={value}
82
- defaultValue={defaultValue}
83
- checked={checked}
84
- defaultChecked={defaultChecked}
85
- {...props}
86
- {...createAttributesForTesting(testId)}
87
- disabled
88
- />
89
- </>
90
- ) : (
91
- <StyledInput
92
- type="checkbox"
93
- className={classNames("m-3", className)}
94
- ref={ref}
95
- name={name}
96
- value={value}
97
- defaultValue={defaultValue}
98
- checked={checked}
99
- defaultChecked={defaultChecked}
100
- {...props}
101
- {...createAttributesForTesting(testId)}
102
- />
103
- )}
62
+ ) => {
63
+ const descriptionId = descriptionText ? `checkbox-description-${name}` : undefined;
64
+ return (
65
+ <>
66
+ {descriptionText ? <p id={descriptionId}>{descriptionText}</p> : null}
67
+ <StyledLabel
68
+ className={classNames("checkbox is-align-items-center", labelClassName)}
69
+ // @ts-ignore bulma uses the disabled attribute on labels, although it is not part of the html spec
70
+ disabled={readOnly || props.disabled}
71
+ >
72
+ {readOnly ? (
73
+ <>
74
+ <input
75
+ type="hidden"
76
+ name={name}
77
+ value={value}
78
+ defaultValue={defaultValue}
79
+ checked={checked}
80
+ defaultChecked={defaultChecked}
81
+ aria-describedby={descriptionId}
82
+ readOnly
83
+ />
84
+ <StyledInput
85
+ type="checkbox"
86
+ className={classNames("m-3", className)}
87
+ ref={ref}
88
+ value={value}
89
+ defaultValue={defaultValue}
90
+ checked={checked}
91
+ defaultChecked={defaultChecked}
92
+ aria-describedby={descriptionId}
93
+ {...props}
94
+ {...createAttributesForTesting(testId)}
95
+ disabled
96
+ />
97
+ </>
98
+ ) : (
99
+ <StyledInput
100
+ type="checkbox"
101
+ className={classNames("m-3", className)}
102
+ ref={ref}
103
+ name={name}
104
+ value={value}
105
+ defaultValue={defaultValue}
106
+ checked={checked}
107
+ defaultChecked={defaultChecked}
108
+ aria-describedby={descriptionId}
109
+ {...props}
110
+ {...createAttributesForTesting(testId)}
111
+ />
112
+ )}
104
113
 
105
- {label}
106
- {helpText ? <Help className="ml-1" text={helpText} /> : null}
107
- </StyledLabel>
108
- )
114
+ {label}
115
+ {helpText ? <Help className="ml-1" text={helpText} /> : null}
116
+ </StyledLabel>
117
+ </>
118
+ );
119
+ }
109
120
  );
110
121
  export default Checkbox;
@@ -35,6 +35,7 @@ function ControlledInputField<T extends Record<string, unknown>>({
35
35
  name,
36
36
  label,
37
37
  helpText,
38
+ descriptionText,
38
39
  rules,
39
40
  testId,
40
41
  defaultChecked,
@@ -48,6 +49,8 @@ function ControlledInputField<T extends Record<string, unknown>>({
48
49
  const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
49
50
  const labelTranslation = label || t(`${prefixedNameWithoutIndices}.label`) || "";
50
51
  const helpTextTranslation = helpText || t(`${prefixedNameWithoutIndices}.helpText`);
52
+ const descriptionTextTranslation = descriptionText || t(`${prefixedNameWithoutIndices}.descriptionText`);
53
+
51
54
  return (
52
55
  <Controller
53
56
  control={control}
@@ -64,6 +67,7 @@ function ControlledInputField<T extends Record<string, unknown>>({
64
67
  {...field}
65
68
  label={labelTranslation}
66
69
  helpText={helpTextTranslation}
70
+ descriptionText={descriptionTextTranslation}
67
71
  testId={testId ?? `checkbox-${nameWithPrefix}`}
68
72
  />
69
73
  )}
@@ -28,7 +28,6 @@ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
28
28
  import { useTranslation } from "react-i18next";
29
29
  import { withForwardRef } from "../helpers";
30
30
  import { Option } from "@scm-manager/ui-types";
31
- import { waitForRestartAfter } from "@scm-manager/ui-api";
32
31
 
33
32
  const StyledChipInput: typeof ChipInput = styled(ChipInput)`
34
33
  min-height: 40px;
@@ -35,6 +35,7 @@ function ControlledInputField<T extends Record<string, unknown>>({
35
35
  name,
36
36
  label,
37
37
  helpText,
38
+ descriptionText,
38
39
  rules,
39
40
  testId,
40
41
  defaultValue,
@@ -48,6 +49,8 @@ function ControlledInputField<T extends Record<string, unknown>>({
48
49
  const prefixedNameWithoutIndices = prefixWithoutIndices(nameWithPrefix);
49
50
  const labelTranslation = label || t(`${prefixedNameWithoutIndices}.label`) || "";
50
51
  const helpTextTranslation = helpText || t(`${prefixedNameWithoutIndices}.helpText`);
52
+ const descriptionTextTranslation = descriptionText || t(`${prefixedNameWithoutIndices}.descriptionText`);
53
+
51
54
  return (
52
55
  <Controller
53
56
  control={control}
@@ -64,6 +67,7 @@ function ControlledInputField<T extends Record<string, unknown>>({
64
67
  form={formId}
65
68
  label={labelTranslation}
66
69
  helpText={helpTextTranslation}
70
+ descriptionText={descriptionTextTranslation}
67
71
  error={
68
72
  fieldState.error
69
73
  ? fieldState.error.message || t(`${prefixedNameWithoutIndices}.error.${fieldState.error.type}`)
@@ -26,6 +26,7 @@ import { useAriaId } from "../../helpers";
26
26
  type InputFieldProps = {
27
27
  label: string;
28
28
  helpText?: string;
29
+ descriptionText?: string;
29
30
  error?: string;
30
31
  } & React.ComponentProps<typeof Input>;
31
32
 
@@ -33,8 +34,9 @@ type InputFieldProps = {
33
34
  * @see https://bulma.io/documentation/form/input/
34
35
  */
35
36
  const InputField = React.forwardRef<HTMLInputElement, InputFieldProps>(
36
- ({ label, helpText, error, className, id, ...props }, ref) => {
37
+ ({ name, label, helpText, descriptionText, error, className, id, ...props }, ref) => {
37
38
  const inputId = useAriaId(id ?? props.testId);
39
+ const descriptionId = descriptionText ? `input-description-${name}` : undefined;
38
40
  const variant = error ? "danger" : undefined;
39
41
  return (
40
42
  <Field className={className}>
@@ -42,8 +44,13 @@ const InputField = React.forwardRef<HTMLInputElement, InputFieldProps>(
42
44
  {label}
43
45
  {helpText ? <Help className="ml-1" text={helpText} /> : null}
44
46
  </Label>
47
+ {descriptionText ? (
48
+ <p className="mb-2" id={descriptionId}>
49
+ {descriptionText}
50
+ </p>
51
+ ) : null}
45
52
  <Control>
46
- <Input variant={variant} ref={ref} id={inputId} {...props}></Input>
53
+ <Input variant={variant} ref={ref} id={inputId} aria-describedby={descriptionId} {...props}></Input>
47
54
  </Control>
48
55
  {error ? <FieldMessage variant={variant}>{error}</FieldMessage> : null}
49
56
  </Field>