@scm-manager/ui-core 4.0.0-REACT19-20250825-073633 → 4.0.0-REACT19-20250910-124634
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-test.log +174 -0
- package/.turbo/turbo-typecheck.log +1 -1
- package/package.json +4 -4
- package/src/base/buttons/Button.tsx +74 -60
- package/src/base/buttons/Icon.tsx +4 -3
- package/src/base/forms/ConfigurationForm.tsx +7 -7
- package/src/base/forms/FormRow.tsx +9 -9
- package/src/base/forms/base/Control.tsx +7 -3
- package/src/base/forms/base/ExpandableText.tsx +11 -12
- package/src/base/forms/checkbox/Checkbox.tsx +63 -65
- package/src/base/forms/checkbox/CheckboxField.tsx +4 -4
- package/src/base/forms/chip-input/ChipInputField.tsx +28 -30
- package/src/base/forms/chip-input/ControlledChipInputField.tsx +20 -22
- package/src/base/forms/combobox/Combobox.tsx +3 -13
- package/src/base/forms/combobox/ComboboxField.tsx +11 -14
- package/src/base/forms/headless-chip-input/ChipInput.tsx +49 -46
- package/src/base/forms/helpers.ts +3 -7
- package/src/base/forms/input/Input.tsx +4 -3
- package/src/base/forms/input/InputField.tsx +55 -43
- package/src/base/forms/input/Textarea.tsx +4 -3
- package/src/base/forms/radio-button/RadioButton.tsx +37 -27
- package/src/base/forms/radio-button/RadioGroup.tsx +4 -3
- package/src/base/forms/radio-button/RadioGroupField.tsx +15 -16
- package/src/base/forms/select/Select.tsx +15 -16
- package/src/base/forms/select/SelectField.tsx +19 -19
- package/src/base/layout/_helpers/with-classes.tsx +15 -12
- package/src/base/layout/card/Card.tsx +28 -21
- package/src/base/layout/card/CardDetail.tsx +65 -76
- package/src/base/layout/card/CardRow.tsx +9 -9
- package/src/base/layout/card/CardTitle.tsx +5 -5
- package/src/base/layout/card-list/CardList.tsx +9 -9
- package/src/base/layout/collapsible/Collapsible.tsx +42 -35
- package/src/base/layout/tabs/TabTrigger.tsx +5 -4
- package/src/base/layout/tabs/Tabs.tsx +4 -4
- package/src/base/layout/tabs/TabsList.tsx +5 -3
- package/src/base/layout/templates/data-page/DataPageHeader.tsx +10 -11
- package/src/base/misc/Image.tsx +5 -5
- package/src/base/misc/Level.tsx +4 -3
- package/src/base/misc/Loading.tsx +25 -25
- package/src/base/misc/SubSubtitle.tsx +9 -9
- package/src/base/misc/Subtitle.tsx +10 -10
- package/src/base/misc/Title.tsx +22 -14
- package/src/base/notifications/Notification.tsx +12 -13
- package/src/base/overlays/dialog/Dialog.tsx +39 -40
- package/src/base/overlays/menu/Menu.tsx +49 -52
- package/src/base/overlays/menu/MenuTrigger.tsx +6 -6
- package/src/base/overlays/popover/Popover.tsx +4 -6
- package/src/base/overlays/tooltip/ExpandableHint.tsx +7 -8
- package/src/base/overlays/tooltip/Tooltip.tsx +5 -3
- package/src/base/status/StatusIcon.tsx +46 -39
- package/src/index.ts +1 -0
- package/src/routing/admin.ts +38 -0
- package/src/routing/group.ts +22 -0
- package/src/routing/help.ts +21 -0
- package/src/routing/import.ts +17 -0
- package/src/routing/index.ts +24 -0
- package/src/routing/me.ts +26 -0
- package/src/routing/namespace.ts +39 -0
- package/src/routing/repository.ts +91 -0
- package/src/routing/user.ts +22 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { InputHTMLAttributes } from "react";
|
|
17
|
+
import React, { FC, InputHTMLAttributes, Ref } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import { createVariantClass, Variant } from "../variants";
|
|
20
20
|
import { createAttributesForTesting } from "../../helpers";
|
|
@@ -22,9 +22,10 @@ import { createAttributesForTesting } from "../../helpers";
|
|
|
22
22
|
type Props = {
|
|
23
23
|
variant?: Variant;
|
|
24
24
|
testId?: string;
|
|
25
|
+
ref?: Ref<HTMLInputElement>;
|
|
25
26
|
} & InputHTMLAttributes<HTMLInputElement>;
|
|
26
27
|
|
|
27
|
-
const Input
|
|
28
|
+
const Input: FC<Props> = ({ variant, className, testId, ref, ...props }) => {
|
|
28
29
|
return (
|
|
29
30
|
<input
|
|
30
31
|
ref={ref}
|
|
@@ -33,6 +34,6 @@ const Input = React.forwardRef<HTMLInputElement, Props>(({ variant, className, t
|
|
|
33
34
|
{...createAttributesForTesting(testId)}
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
|
-
}
|
|
37
|
+
};
|
|
37
38
|
|
|
38
39
|
export default Input;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React from "react";
|
|
17
|
+
import React, { FC, Ref } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import Field from "../base/Field";
|
|
20
20
|
import Control from "../base/Control";
|
|
@@ -36,52 +36,64 @@ export type InputFieldProps = {
|
|
|
36
36
|
extendedText?: string;
|
|
37
37
|
error?: string;
|
|
38
38
|
icon?: string;
|
|
39
|
+
ref?: Ref<HTMLInputElement>;
|
|
39
40
|
} & React.ComponentProps<typeof Input>;
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* @see https://bulma.io/documentation/form/input/
|
|
43
44
|
*/
|
|
44
|
-
const InputField
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
45
|
+
const InputField: FC<InputFieldProps> = ({
|
|
46
|
+
name,
|
|
47
|
+
label,
|
|
48
|
+
helpText,
|
|
49
|
+
descriptionText,
|
|
50
|
+
extendedText,
|
|
51
|
+
error,
|
|
52
|
+
icon,
|
|
53
|
+
className,
|
|
54
|
+
id,
|
|
55
|
+
ref,
|
|
56
|
+
...props
|
|
57
|
+
}) => {
|
|
58
|
+
const inputId = useAriaId(id ?? props.testId);
|
|
59
|
+
const helpTextId = helpText ? `input-helptext-${name}` : undefined;
|
|
60
|
+
const descriptionId = descriptionText ? `input-description-${name}` : undefined;
|
|
61
|
+
const errorId = error ? `input-error-${name}` : undefined;
|
|
62
|
+
const variant = error ? "danger" : undefined;
|
|
63
|
+
return (
|
|
64
|
+
<Field className={className}>
|
|
65
|
+
<Label htmlFor={inputId}>
|
|
66
|
+
{label}
|
|
67
|
+
{helpText ? <Help className="ml-1" text={helpText} /> : null}
|
|
68
|
+
</Label>
|
|
69
|
+
{extendedText && descriptionText ? (
|
|
70
|
+
<ExpandableText id={descriptionId} descriptionText={descriptionText} extendedDescriptionText={extendedText} />
|
|
71
|
+
) : (
|
|
72
|
+
<p className="mb-2" id={descriptionId}>
|
|
73
|
+
{descriptionText}
|
|
74
|
+
</p>
|
|
75
|
+
)}
|
|
76
|
+
<Control className={classNames({ "has-icons-left": icon })}>
|
|
77
|
+
<Input
|
|
78
|
+
variant={variant}
|
|
79
|
+
ref={ref}
|
|
80
|
+
id={inputId}
|
|
81
|
+
aria-describedby={descriptionId || helpTextId}
|
|
82
|
+
{...props}
|
|
83
|
+
></Input>
|
|
84
|
+
{icon ? (
|
|
85
|
+
<span className="icon is-small is-left">
|
|
86
|
+
<i className={icon} />
|
|
87
|
+
</span>
|
|
82
88
|
) : null}
|
|
83
|
-
</
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
</Control>
|
|
90
|
+
{error ? (
|
|
91
|
+
<FieldMessage id={errorId} variant={variant}>
|
|
92
|
+
{error}
|
|
93
|
+
</FieldMessage>
|
|
94
|
+
) : null}
|
|
95
|
+
</Field>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
87
99
|
export default InputField;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { InputHTMLAttributes } from "react";
|
|
17
|
+
import React, { FC, InputHTMLAttributes, Ref } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import { createVariantClass, Variant } from "../variants";
|
|
20
20
|
import { createAttributesForTesting } from "../../helpers";
|
|
@@ -22,9 +22,10 @@ import { createAttributesForTesting } from "../../helpers";
|
|
|
22
22
|
type Props = {
|
|
23
23
|
variant?: Variant;
|
|
24
24
|
testId?: string;
|
|
25
|
+
ref?: Ref<HTMLTextAreaElement>;
|
|
25
26
|
} & InputHTMLAttributes<HTMLTextAreaElement>;
|
|
26
27
|
|
|
27
|
-
const Textarea
|
|
28
|
+
const Textarea: FC<Props> = ({ variant, className, testId, ref, ...props }) => {
|
|
28
29
|
return (
|
|
29
30
|
<textarea
|
|
30
31
|
ref={ref}
|
|
@@ -33,6 +34,6 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, Props>(({ variant, classN
|
|
|
33
34
|
{...createAttributesForTesting(testId)}
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
|
-
}
|
|
37
|
+
};
|
|
37
38
|
|
|
38
39
|
export default Textarea;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React from "react";
|
|
17
|
+
import React, { FC, Ref } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import Help from "../base/help/Help";
|
|
20
20
|
import * as RadioGroup from "@radix-ui/react-radio-group";
|
|
@@ -65,7 +65,7 @@ const StyledIndicator = styled(RadioGroup.Indicator)`
|
|
|
65
65
|
}
|
|
66
66
|
`;
|
|
67
67
|
|
|
68
|
-
type RadioGroupItemElement = React.
|
|
68
|
+
type RadioGroupItemElement = React.ComponentRef<typeof RadioGroup.Item>;
|
|
69
69
|
type RadioGroupItemProps = React.ComponentPropsWithoutRef<typeof RadioGroup.Item>;
|
|
70
70
|
|
|
71
71
|
type Props = {
|
|
@@ -76,37 +76,47 @@ type Props = {
|
|
|
76
76
|
label?: string;
|
|
77
77
|
labelClassName?: string;
|
|
78
78
|
helpText?: string;
|
|
79
|
+
ref?: Ref<RadioGroupItemElement>;
|
|
79
80
|
} & RadioGroupItemProps;
|
|
80
81
|
|
|
81
82
|
/**
|
|
82
83
|
* @beta
|
|
83
84
|
* @since 2.48.0
|
|
84
85
|
*/
|
|
85
|
-
const RadioButton
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
const RadioButton: FC<Props> = ({
|
|
87
|
+
id,
|
|
88
|
+
testId,
|
|
89
|
+
indicatorClassName,
|
|
90
|
+
label,
|
|
91
|
+
labelClassName,
|
|
92
|
+
className,
|
|
93
|
+
helpText,
|
|
94
|
+
value,
|
|
95
|
+
ref,
|
|
96
|
+
...props
|
|
97
|
+
}) => {
|
|
98
|
+
const context = useRadioButtonContext();
|
|
99
|
+
const inputId = useAriaId(id);
|
|
100
|
+
const labelKey = `${context?.prefix}.radio.${value}`;
|
|
101
|
+
const displayLabel = label ?? context?.t(labelKey) ?? value ?? "";
|
|
91
102
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
103
|
+
return (
|
|
104
|
+
<div className={classNames("radio is-flex is-align-items-center", labelClassName)}>
|
|
105
|
+
<StyledRadioButton
|
|
106
|
+
form={context?.formId}
|
|
107
|
+
id={inputId}
|
|
108
|
+
value={value}
|
|
109
|
+
ref={ref}
|
|
110
|
+
className={classNames("mr-3 mt-3 mb-3", className)}
|
|
111
|
+
{...props}
|
|
112
|
+
{...createAttributesForTesting(testId)}
|
|
113
|
+
>
|
|
114
|
+
<StyledIndicator className={indicatorClassName} />
|
|
115
|
+
</StyledRadioButton>
|
|
116
|
+
<label htmlFor={inputId}>{displayLabel}</label>
|
|
117
|
+
{helpText ? <Help className="ml-3" text={helpText} /> : null}
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
111
121
|
|
|
112
122
|
export default RadioButton;
|
|
@@ -14,20 +14,21 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentProps } from "react";
|
|
17
|
+
import React, { ComponentProps, FC, Ref } from "react";
|
|
18
18
|
import Control from "../base/Control";
|
|
19
19
|
import * as RadixRadio from "@radix-ui/react-radio-group";
|
|
20
20
|
import RadioButton from "./RadioButton";
|
|
21
21
|
|
|
22
22
|
type Props = {
|
|
23
23
|
options?: { value: string; label?: string; helpText?: string }[];
|
|
24
|
+
ref?: Ref<HTMLDivElement>;
|
|
24
25
|
} & ComponentProps<typeof RadixRadio.Root>;
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* @beta
|
|
28
29
|
* @since 2.48.0
|
|
29
30
|
*/
|
|
30
|
-
const RadioGroup
|
|
31
|
+
const RadioGroup: FC<Props> = ({ options, children, className, ref, ...props }) => (
|
|
31
32
|
<RadixRadio.Root {...props} asChild>
|
|
32
33
|
<Control ref={ref} className={className}>
|
|
33
34
|
{children ??
|
|
@@ -36,6 +37,6 @@ const RadioGroup = React.forwardRef<HTMLDivElement, Props>(({ options, children,
|
|
|
36
37
|
))}
|
|
37
38
|
</Control>
|
|
38
39
|
</RadixRadio.Root>
|
|
39
|
-
)
|
|
40
|
+
);
|
|
40
41
|
|
|
41
42
|
export default RadioGroup;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentProps } from "react";
|
|
17
|
+
import React, { ComponentProps, FC, Ref } from "react";
|
|
18
18
|
import Field from "../base/Field";
|
|
19
19
|
import Label from "../base/label/Label";
|
|
20
20
|
import Help from "../base/help/Help";
|
|
@@ -25,26 +25,25 @@ type Props = {
|
|
|
25
25
|
labelClassName?: string;
|
|
26
26
|
label: string;
|
|
27
27
|
helpText?: string;
|
|
28
|
+
ref?: Ref<HTMLDivElement>;
|
|
28
29
|
} & ComponentProps<typeof RadioGroup>;
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* @beta
|
|
32
33
|
* @since 2.48.0
|
|
33
34
|
*/
|
|
34
|
-
const RadioGroupField =
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
);
|
|
35
|
+
const RadioGroupField: FC<Props> = ({ fieldClassName, labelClassName, label, helpText, children, ref, ...props }) => {
|
|
36
|
+
return (
|
|
37
|
+
<Field className={fieldClassName} as="fieldset">
|
|
38
|
+
<Label className={labelClassName} as="legend">
|
|
39
|
+
{label}
|
|
40
|
+
{helpText ? <Help className="ml-1" text={helpText} /> : null}
|
|
41
|
+
</Label>
|
|
42
|
+
<RadioGroup ref={ref} {...props}>
|
|
43
|
+
{children}
|
|
44
|
+
</RadioGroup>
|
|
45
|
+
</Field>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
49
48
|
|
|
50
49
|
export default RadioGroupField;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { InputHTMLAttributes, Key, OptionHTMLAttributes } from "react";
|
|
17
|
+
import React, { FC, InputHTMLAttributes, Key, OptionHTMLAttributes, Ref } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import { createVariantClass, Variant } from "../variants";
|
|
20
20
|
import { createAttributesForTesting } from "../../helpers";
|
|
@@ -23,27 +23,26 @@ type Props = {
|
|
|
23
23
|
variant?: Variant;
|
|
24
24
|
options?: Array<OptionHTMLAttributes<HTMLOptionElement> & { label: string }>;
|
|
25
25
|
testId?: string;
|
|
26
|
+
ref?: Ref<HTMLSelectElement>;
|
|
26
27
|
} & InputHTMLAttributes<HTMLSelectElement>;
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* @beta
|
|
30
31
|
* @since 2.44.0
|
|
31
32
|
*/
|
|
32
|
-
const Select =
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</div>
|
|
46
|
-
)
|
|
33
|
+
const Select: FC<Props> = ({ variant, children, className, options, testId, ref, ...props }) => (
|
|
34
|
+
<div className={classNames("select", { "is-multiple": props.multiple }, createVariantClass(variant), className)}>
|
|
35
|
+
<select ref={ref} {...props} {...createAttributesForTesting(testId)} className={className}>
|
|
36
|
+
{options
|
|
37
|
+
? options.map((opt) => (
|
|
38
|
+
<option {...opt} key={opt.value as Key}>
|
|
39
|
+
{opt.label}
|
|
40
|
+
{opt.children}
|
|
41
|
+
</option>
|
|
42
|
+
))
|
|
43
|
+
: children}
|
|
44
|
+
</select>
|
|
45
|
+
</div>
|
|
47
46
|
);
|
|
48
47
|
|
|
49
48
|
export default Select;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React from "react";
|
|
17
|
+
import React, { FC, Ref } from "react";
|
|
18
18
|
import Field from "../base/Field";
|
|
19
19
|
import Control from "../base/Control";
|
|
20
20
|
import Label from "../base/label/Label";
|
|
@@ -27,6 +27,7 @@ type Props = {
|
|
|
27
27
|
label: string;
|
|
28
28
|
helpText?: string;
|
|
29
29
|
error?: string;
|
|
30
|
+
ref?: Ref<HTMLSelectElement>;
|
|
30
31
|
} & React.ComponentProps<typeof Select>;
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -34,22 +35,21 @@ type Props = {
|
|
|
34
35
|
* @beta
|
|
35
36
|
* @since 2.44.0
|
|
36
37
|
*/
|
|
37
|
-
const SelectField =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
38
|
+
const SelectField: FC<Props> = ({ label, helpText, error, className, id, ref, ...props }) => {
|
|
39
|
+
const selectId = useAriaId(id ?? props.testId);
|
|
40
|
+
const variant = error ? "danger" : undefined;
|
|
41
|
+
return (
|
|
42
|
+
<Field className={className}>
|
|
43
|
+
<Label htmlFor={selectId}>
|
|
44
|
+
{label}
|
|
45
|
+
{helpText ? <Help className="ml-1" text={helpText} /> : null}
|
|
46
|
+
</Label>
|
|
47
|
+
<Control>
|
|
48
|
+
<Select id={selectId} variant={variant} ref={ref} className="is-full-width" {...props}></Select>
|
|
49
|
+
</Control>
|
|
50
|
+
{error ? <FieldMessage variant={variant}>{error}</FieldMessage> : null}
|
|
51
|
+
</Field>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
55
|
export default SelectField;
|
|
@@ -14,20 +14,23 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentProps, ElementRef, ForwardRefExoticComponent, ReactElement } from "react";
|
|
17
|
+
import React, { ComponentProps, ElementRef, ForwardRefExoticComponent, ReactElement, Ref } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import { Slot } from "@radix-ui/react-slot";
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
type Props<Element extends React.ElementType | ForwardRefExoticComponent<any>> = (
|
|
22
|
+
| (ComponentProps<Element> & { asChild?: false; className?: string })
|
|
23
|
+
| { asChild: true; children: ReactElement<{ className?: string }> }
|
|
24
|
+
) & { ref?: Ref<Element> };
|
|
25
|
+
|
|
26
|
+
const withClasses =
|
|
27
|
+
<Element extends React.ElementType | ForwardRefExoticComponent<any>>(
|
|
28
|
+
typ: Element,
|
|
29
|
+
additionalClassNames: string[],
|
|
30
|
+
additionalProps?: Partial<ComponentProps<Element>>,
|
|
31
|
+
) =>
|
|
32
|
+
// @ts-ignore TypeScript for some reason does not understand that ref will always be part of the Props
|
|
33
|
+
({ ref, ...props }: Props<Element>) => {
|
|
31
34
|
// @ts-ignore Typescript doesn't get it for some reason
|
|
32
35
|
if (props.asChild) {
|
|
33
36
|
return <Slot {...props} className={classNames(...additionalClassNames)} />;
|
|
@@ -39,6 +42,6 @@ const withClasses = <Element extends React.ElementType | ForwardRefExoticCompone
|
|
|
39
42
|
ref,
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
|
-
}
|
|
45
|
+
};
|
|
43
46
|
|
|
44
47
|
export default withClasses;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentType, HTMLAttributes, JSX, Ref } from "react";
|
|
17
|
+
import React, { ComponentType, FC, HTMLAttributes, JSX, Ref } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import styled from "styled-components";
|
|
20
20
|
|
|
@@ -31,12 +31,12 @@ type Props = HTMLAttributes<HTMLElement> & {
|
|
|
31
31
|
* @default "div"
|
|
32
32
|
*/
|
|
33
33
|
as?: keyof JSX.IntrinsicElements | ComponentType<HTMLAttributes<HTMLElement> & { ref?: Ref<HTMLElement> }>;
|
|
34
|
-
|
|
35
34
|
/**
|
|
36
35
|
* @default "0.5rem"
|
|
37
36
|
* @since 2.46.0
|
|
38
37
|
*/
|
|
39
38
|
rowGap?: Gap;
|
|
39
|
+
ref?: Ref<HTMLElement>;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -46,24 +46,31 @@ type Props = HTMLAttributes<HTMLElement> & {
|
|
|
46
46
|
* @beta
|
|
47
47
|
* @since 2.44.0
|
|
48
48
|
*/
|
|
49
|
-
const Card
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
const Card: FC<Props> = ({
|
|
50
|
+
className,
|
|
51
|
+
avatar,
|
|
52
|
+
rowGap = "0.25rem",
|
|
53
|
+
children,
|
|
54
|
+
as: Comp = "div",
|
|
55
|
+
action,
|
|
56
|
+
ref,
|
|
57
|
+
...props
|
|
58
|
+
}) =>
|
|
59
|
+
React.createElement(
|
|
60
|
+
Comp,
|
|
61
|
+
{
|
|
62
|
+
className: classNames(className, "is-relative", "is-flex", "scmm-card"),
|
|
63
|
+
ref,
|
|
64
|
+
...props,
|
|
65
|
+
},
|
|
66
|
+
avatar ? avatar : null,
|
|
67
|
+
<RowsContainer
|
|
68
|
+
className="is-flex is-flex-direction-column is-justify-content-center is-flex-grow-1 is-overflow-hidden is-overflow-wrap-anywhere"
|
|
69
|
+
style={{ gap: rowGap }}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</RowsContainer>,
|
|
73
|
+
action ? action : null,
|
|
74
|
+
);
|
|
68
75
|
|
|
69
76
|
export default Card;
|