@daoyi/nmtl-ui 2.0.1-beta.120 → 2.0.1-beta.121

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.
@@ -13,7 +13,8 @@ var Input = function Input(props) {
13
13
  defaultValue = props.defaultValue,
14
14
  value = props.value,
15
15
  type = props.type,
16
- error = props.error; // Attributes
16
+ error = props.error,
17
+ ariaLabel = props.ariaLabel; // Attributes
17
18
 
18
19
  var _onChange = props.onChange,
19
20
  _onKeyPress = props.onKeyPress,
@@ -22,8 +23,11 @@ var Input = function Input(props) {
22
23
  var suffix = props.suffix; // Dom Status
23
24
 
24
25
  var OutlinedInputProps = {
26
+ /* WCAG 3.3.2(Freego HM1130104C):placeholder 不是 label,包裹式 label 檢測工具也不認,
27
+ 需要時由呼叫端傳 ariaLabel,直接標在 input 元素上 */
25
28
  inputProps: {
26
- className: classNames('input', className)
29
+ className: classNames('input', className),
30
+ 'aria-label': ariaLabel
27
31
  },
28
32
  placeholder: placeholder,
29
33
  defaultValue: defaultValue,
@@ -52,7 +56,8 @@ Input.defaultProps = {
52
56
  onPressEnter: undefined,
53
57
  suffix: null,
54
58
  type: 'text',
55
- error: false
59
+ error: false,
60
+ ariaLabel: undefined
56
61
  };
57
62
 
58
63
  /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
@@ -76,7 +81,9 @@ Input.propTypes = {
76
81
  /** HTML5 Input type */
77
82
  type: PropTypes.string,
78
83
  /** Input error */
79
- error: PropTypes.bool
84
+ error: PropTypes.bool,
85
+ /** 無可見 label 時的可及名稱(WCAG 3.3.2);會標在 input 元素上 */
86
+ ariaLabel: PropTypes.string
80
87
  };
81
88
 
82
89
  export { Input as default };
@@ -32,11 +32,16 @@ var Radio = function Radio(props) {
32
32
  }, Array.isArray(options) && options.map(function (option) {
33
33
  return /*#__PURE__*/React__default.createElement(FormControlLabel, {
34
34
  value: option.value,
35
- key: option.value,
35
+ key: option.value
36
+ /* WCAG 4.1.2(Freego HM1130104C):FormControlLabel 產生的是「包裹式」隱式 label,
37
+ 檢測工具只認 input 自身的 for/title/aria-*,故把選項文字同步標在 input 上 */,
36
38
  control: /*#__PURE__*/React__default.createElement(Radio$1, {
37
39
  disabled: option.disabled || false,
38
40
  size: size,
39
- className: className
41
+ className: className,
42
+ inputProps: {
43
+ 'aria-label': typeof option.label === 'string' ? option.label : String(option.value)
44
+ }
40
45
  }),
41
46
  label: option.label
42
47
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daoyi/nmtl-ui",
3
- "version": "2.0.1-beta.120",
3
+ "version": "2.0.1-beta.121",
4
4
  "description": "This project is to be used as a starter kit for building React component using Storybook and Rollup",
5
5
  "author": "daoyi",
6
6
  "main": "lib/index.js",