@rescui/checkbox 0.9.5-RUI-286-Fix-tooltip-stacking-f4145b01.1 → 0.10.1-RUI-280-Update-select-component-026338d06.52
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/lib/checkbox.d.ts +6 -0
- package/lib/checkbox.js +18 -10
- package/lib/index.css +381 -346
- package/lib/parts/checkbox-control-inner.d.ts +1 -0
- package/lib/parts/checkbox-control-inner.js +7 -4
- package/lib/parts/checkbox-control.js +3 -0
- package/lib/parts/checkbox-list.d.ts +11 -1
- package/lib/parts/checkbox-list.js +49 -22
- package/lib/parts/checkbox-list.p.module.css.js +16 -0
- package/lib/parts/checkbox.p.module.css.js +22 -28
- package/lib/parts/group-context.d.ts +1 -0
- package/lib/parts/use-backward-compatible-id.d.ts +4 -0
- package/lib/parts/use-backward-compatible-id.js +14 -0
- package/lib/public-api.p.css +174 -224
- package/lib/public-api.pcss +174 -224
- package/package.json +6 -5
- package/lib/_virtual/index.css.js +0 -15
- package/lib/_virtual/warning.js +0 -106
|
@@ -30,6 +30,7 @@ export declare type CheckboxControlProps = {
|
|
|
30
30
|
notUseLabelTag?: boolean;
|
|
31
31
|
size?: CheckboxSize;
|
|
32
32
|
mode?: CheckboxMode;
|
|
33
|
+
errorId?: string;
|
|
33
34
|
};
|
|
34
35
|
declare const CheckboxControlInner: React.ForwardRefExoticComponent<CheckboxControlProps & React.RefAttributes<HTMLInputElement>>;
|
|
35
36
|
export default CheckboxControlInner;
|
|
@@ -22,11 +22,11 @@ const DEFAULT_MODE = 'classic';
|
|
|
22
22
|
const CheckboxControlInner = /*#__PURE__*/React.forwardRef(function CheckboxControlInner(_ref, ref) {
|
|
23
23
|
let {
|
|
24
24
|
className,
|
|
25
|
-
//
|
|
26
|
-
// @ts-ignore
|
|
25
|
+
// @ts-expect-error: omit children from restProps
|
|
27
26
|
children,
|
|
28
27
|
theme: themeFromProps,
|
|
29
28
|
isError,
|
|
29
|
+
errorId,
|
|
30
30
|
disabled,
|
|
31
31
|
size = DEFAULT_SIZE,
|
|
32
32
|
mode = DEFAULT_MODE,
|
|
@@ -46,7 +46,9 @@ const CheckboxControlInner = /*#__PURE__*/React.forwardRef(function CheckboxCont
|
|
|
46
46
|
ref: ref,
|
|
47
47
|
className: styles.input,
|
|
48
48
|
type: "checkbox",
|
|
49
|
-
disabled: disabled
|
|
49
|
+
disabled: disabled,
|
|
50
|
+
"aria-errormessage": isError ? errorId : undefined,
|
|
51
|
+
"aria-invalid": Boolean(isError)
|
|
50
52
|
}), /*#__PURE__*/React.createElement("span", {
|
|
51
53
|
className: cn(styles.icon, isError && styles.iconError),
|
|
52
54
|
"data-test": 'checkbox-icon'
|
|
@@ -69,6 +71,7 @@ CheckboxControlInner.propTypes = {
|
|
|
69
71
|
indeterminate: PropTypes.bool,
|
|
70
72
|
notUseLabelTag: PropTypes.bool,
|
|
71
73
|
size: PropTypes.oneOf(['s', 'm', 'l']),
|
|
72
|
-
mode: PropTypes.oneOf(['classic', 'rock'])
|
|
74
|
+
mode: PropTypes.oneOf(['classic', 'rock']),
|
|
75
|
+
errorId: PropTypes.string
|
|
73
76
|
};
|
|
74
77
|
export { CheckboxControlInner as default };
|
|
@@ -10,6 +10,7 @@ const CheckboxControl = /*#__PURE__*/React.forwardRef(function CheckboxControl(p
|
|
|
10
10
|
handleCheckboxChange,
|
|
11
11
|
value: groupValue,
|
|
12
12
|
isError,
|
|
13
|
+
errorId,
|
|
13
14
|
theme,
|
|
14
15
|
size,
|
|
15
16
|
mode,
|
|
@@ -29,6 +30,7 @@ const CheckboxControl = /*#__PURE__*/React.forwardRef(function CheckboxControl(p
|
|
|
29
30
|
onChange,
|
|
30
31
|
checked,
|
|
31
32
|
isError: propsIsError,
|
|
33
|
+
errorId: propsErrorId,
|
|
32
34
|
disabled: propsDisabled,
|
|
33
35
|
theme: propsTheme,
|
|
34
36
|
size: propsSize,
|
|
@@ -37,6 +39,7 @@ const CheckboxControl = /*#__PURE__*/React.forwardRef(function CheckboxControl(p
|
|
|
37
39
|
} = props;
|
|
38
40
|
return /*#__PURE__*/React.createElement(CheckboxControlInner, {
|
|
39
41
|
isError: isError || propsIsError,
|
|
42
|
+
errorId: errorId || propsErrorId,
|
|
40
43
|
value: value,
|
|
41
44
|
onChange: handleCheckboxChange,
|
|
42
45
|
checked: _includesInstanceProperty(groupValue).call(groupValue, value),
|
|
@@ -3,13 +3,23 @@ import { Theme } from '@rescui/ui-contexts';
|
|
|
3
3
|
import CSS from 'csstype';
|
|
4
4
|
export declare type CheckboxListProps = {
|
|
5
5
|
className?: string;
|
|
6
|
+
id?: string;
|
|
6
7
|
style?: CSS.Properties;
|
|
7
8
|
mode?: 'classic' | 'rock';
|
|
8
9
|
size?: 's' | 'm' | 'l';
|
|
9
10
|
onChange?: (val: string[]) => void;
|
|
10
11
|
value?: string[];
|
|
11
12
|
defaultValue?: string[];
|
|
12
|
-
|
|
13
|
+
label?: React.ReactNode;
|
|
14
|
+
note?: React.ReactNode;
|
|
15
|
+
/** Error flag or message */
|
|
16
|
+
error?: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* If `true`, there will be reserved a space for a 1-line error message. Subsequent lines will be placed below normally.
|
|
19
|
+
* If `false`, there will be no reservation.
|
|
20
|
+
*/
|
|
21
|
+
reserveErrorLine?: boolean;
|
|
22
|
+
boldLabel?: boolean;
|
|
13
23
|
theme?: Theme;
|
|
14
24
|
disabled?: boolean;
|
|
15
25
|
children?: React.ReactNode;
|
|
@@ -4,18 +4,19 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { Menu } from '@rescui/menu';
|
|
5
5
|
import cn from 'classnames';
|
|
6
6
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
7
|
-
import
|
|
8
|
-
import styles from './checkbox.p.module.css.js';
|
|
7
|
+
import { ErrorMessage, shouldRenderErrorMessage } from '@rescui/form-field';
|
|
8
|
+
import styles from './checkbox-list.p.module.css.js';
|
|
9
9
|
import CheckboxManager from './checkbox-manager.js';
|
|
10
|
+
import { useBackwardCompatibleId } from './use-backward-compatible-id.js';
|
|
10
11
|
const THEME_STYLES = {
|
|
11
12
|
light: styles.themeLight,
|
|
12
13
|
dark: styles.themeDark
|
|
13
14
|
};
|
|
14
15
|
const SIZE_STYLES = {
|
|
15
|
-
s: styles.
|
|
16
|
-
m: styles.
|
|
17
|
-
l: styles.
|
|
18
|
-
};
|
|
16
|
+
s: styles.sizeS,
|
|
17
|
+
m: styles.sizeM,
|
|
18
|
+
l: styles.sizeL
|
|
19
|
+
}; // eslint-disable-next-line complexity
|
|
19
20
|
|
|
20
21
|
const CheckboxList = _ref => {
|
|
21
22
|
let {
|
|
@@ -27,13 +28,20 @@ const CheckboxList = _ref => {
|
|
|
27
28
|
onChange,
|
|
28
29
|
value,
|
|
29
30
|
defaultValue,
|
|
31
|
+
label,
|
|
32
|
+
note,
|
|
30
33
|
error,
|
|
34
|
+
reserveErrorLine = false,
|
|
31
35
|
className,
|
|
32
|
-
|
|
36
|
+
id,
|
|
33
37
|
style,
|
|
38
|
+
boldLabel = true,
|
|
34
39
|
...restProps
|
|
35
40
|
} = _ref;
|
|
36
41
|
const theme = useThemeWithUndefined(themeFromProps);
|
|
42
|
+
const uniqueId = `checkbox-list-${useBackwardCompatibleId()}`;
|
|
43
|
+
const errorId = `${id ? id : uniqueId}-error`;
|
|
44
|
+
const hasFooter = Boolean(note) || shouldRenderErrorMessage(error, reserveErrorLine);
|
|
37
45
|
return /*#__PURE__*/React.createElement(CheckboxManager, {
|
|
38
46
|
theme: theme,
|
|
39
47
|
defaultValue: defaultValue,
|
|
@@ -45,18 +53,18 @@ const CheckboxList = _ref => {
|
|
|
45
53
|
disabled: disabled,
|
|
46
54
|
size: size,
|
|
47
55
|
mode: mode
|
|
48
|
-
}, /*#__PURE__*/React.createElement("
|
|
49
|
-
className: cn(className, styles.container, THEME_STYLES[theme], SIZE_STYLES[size] || styles.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"data-
|
|
55
|
-
}, /*#__PURE__*/React.createElement(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"data-
|
|
59
|
-
}
|
|
56
|
+
}, /*#__PURE__*/React.createElement("fieldset", {
|
|
57
|
+
className: cn(className, styles.container, THEME_STYLES[theme], SIZE_STYLES[size] || styles.sizeM, Boolean(error) && styles.error, disabled && styles.disabled),
|
|
58
|
+
id: id,
|
|
59
|
+
style: style,
|
|
60
|
+
"aria-errormessage": error ? errorId : undefined,
|
|
61
|
+
"aria-invalid": Boolean(error),
|
|
62
|
+
"data-test": "checkbox-list"
|
|
63
|
+
}, label && /*#__PURE__*/React.createElement("legend", {
|
|
64
|
+
className: styles.label,
|
|
65
|
+
"data-test": 'checkbox-list__label',
|
|
66
|
+
"data-rs-internal": boldLabel ? 'checkbox-list__bold-label' : 'checkbox-list__label'
|
|
67
|
+
}, label), /*#__PURE__*/React.createElement(Menu, {
|
|
60
68
|
tag: 'div',
|
|
61
69
|
itemTag: null,
|
|
62
70
|
size: size,
|
|
@@ -64,8 +72,20 @@ const CheckboxList = _ref => {
|
|
|
64
72
|
disabled: disabled,
|
|
65
73
|
"data-rs-internal": 'checkbox__menu',
|
|
66
74
|
theme: theme,
|
|
75
|
+
className: styles.inner,
|
|
67
76
|
...restProps
|
|
68
|
-
}, children)
|
|
77
|
+
}, children), hasFooter && /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: styles.footer
|
|
79
|
+
}, /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
80
|
+
id: errorId,
|
|
81
|
+
className: styles.errorMessage,
|
|
82
|
+
"data-test": 'checkbox-list__error',
|
|
83
|
+
reserveLine: reserveErrorLine
|
|
84
|
+
}, error), note && /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: styles.note,
|
|
86
|
+
"data-test": 'checkbox-list__note',
|
|
87
|
+
"data-rs-internal": "checkbox-list__note"
|
|
88
|
+
}, note))));
|
|
69
89
|
};
|
|
70
90
|
|
|
71
91
|
CheckboxList.propTypes = {
|
|
@@ -74,8 +94,15 @@ CheckboxList.propTypes = {
|
|
|
74
94
|
onChange: PropTypes.func,
|
|
75
95
|
value: PropTypes.array,
|
|
76
96
|
defaultValue: PropTypes.array,
|
|
77
|
-
error:
|
|
97
|
+
error: ErrorMessage.propTypes.children,
|
|
98
|
+
style: PropTypes.object,
|
|
78
99
|
theme: PropTypes.oneOf(['light', 'dark']),
|
|
79
|
-
disabled: PropTypes.bool
|
|
100
|
+
disabled: PropTypes.bool,
|
|
101
|
+
className: PropTypes.string,
|
|
102
|
+
id: PropTypes.string,
|
|
103
|
+
reserveErrorLine: PropTypes.bool,
|
|
104
|
+
label: PropTypes.node,
|
|
105
|
+
note: PropTypes.node,
|
|
106
|
+
boldLabel: PropTypes.bool
|
|
80
107
|
};
|
|
81
108
|
export { CheckboxList as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"themeLight": "_themeLight_lfhwqa_6",
|
|
3
|
+
"themeDark": "_themeDark_lfhwqa_9",
|
|
4
|
+
"container": "_container_lfhwqa_13",
|
|
5
|
+
"sizeS": "_sizeS_lfhwqa_18",
|
|
6
|
+
"sizeM": "_sizeM_lfhwqa_21",
|
|
7
|
+
"sizeL": "_sizeL_lfhwqa_24",
|
|
8
|
+
"inner": "_inner_lfhwqa_28",
|
|
9
|
+
"label": "_label_lfhwqa_32",
|
|
10
|
+
"disabled": "_disabled_lfhwqa_39",
|
|
11
|
+
"footer": "_footer_lfhwqa_44",
|
|
12
|
+
"errorMessage": "_errorMessage_lfhwqa_49",
|
|
13
|
+
"error": "_error_lfhwqa_49",
|
|
14
|
+
"note": "_note_lfhwqa_58"
|
|
15
|
+
};
|
|
16
|
+
export { styles as default };
|
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"disabled": "_disabled_1yjjktt_138",
|
|
25
|
-
"error": "_error_1yjjktt_79",
|
|
26
|
-
"checkmark": "_checkmark_1yjjktt_194",
|
|
27
|
-
"markS": "_markS_1yjjktt_219",
|
|
28
|
-
"markM": "_markM_1yjjktt_222",
|
|
29
|
-
"markL": "_markL_1yjjktt_225"
|
|
2
|
+
"themeLight": "_themeLight_1bdum4x_8",
|
|
3
|
+
"themeDark": "_themeDark_1bdum4x_11",
|
|
4
|
+
"checkboxSizeS": "_checkboxSizeS_1bdum4x_15",
|
|
5
|
+
"checkboxSizeM": "_checkboxSizeM_1bdum4x_18",
|
|
6
|
+
"checkboxSizeL": "_checkboxSizeL_1bdum4x_21",
|
|
7
|
+
"sizeS": "_sizeS_1bdum4x_25",
|
|
8
|
+
"sizeM": "_sizeM_1bdum4x_28",
|
|
9
|
+
"sizeL": "_sizeL_1bdum4x_31",
|
|
10
|
+
"classic": "_classic_1bdum4x_35",
|
|
11
|
+
"rock": "_rock_1bdum4x_38",
|
|
12
|
+
"checkbox": "_checkbox_1bdum4x_15",
|
|
13
|
+
"input": "_input_1bdum4x_65",
|
|
14
|
+
"icon": "_icon_1bdum4x_76",
|
|
15
|
+
"enabled": "_enabled_1bdum4x_92",
|
|
16
|
+
"indeterminate": "_indeterminate_1bdum4x_96",
|
|
17
|
+
"disabled": "_disabled_1bdum4x_104",
|
|
18
|
+
"error": "_error_1bdum4x_133",
|
|
19
|
+
"checkmark": "_checkmark_1bdum4x_160",
|
|
20
|
+
"markS": "_markS_1bdum4x_185",
|
|
21
|
+
"markM": "_markM_1bdum4x_188",
|
|
22
|
+
"markL": "_markL_1bdum4x_191",
|
|
23
|
+
"errorMessage": "_errorMessage_1bdum4x_195"
|
|
30
24
|
};
|
|
31
25
|
export { styles as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const useBackwardCompatibleId = () => {
|
|
4
|
+
const id = useRef(null);
|
|
5
|
+
|
|
6
|
+
if (id.current === null) {
|
|
7
|
+
id.current = useBackwardCompatibleId.counter++;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return (React.useId ? React.useId : () => id.current)();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
useBackwardCompatibleId.counter = 0;
|
|
14
|
+
export { useBackwardCompatibleId };
|