diginet-core-ui 1.3.44 → 1.3.46

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.
@@ -105,6 +105,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
105
105
  children,
106
106
  dropdownItemStyle
107
107
  }, reference) => {
108
+ if (multiple && selectBox === undefined) selectBox = true;
108
109
  const dropdownRef = useRef(null);
109
110
  const timerRef = useRef(null);
110
111
  const formRef = useRef(null);
@@ -169,14 +170,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
169
170
  }
170
171
 
171
172
  setOpenState(true);
172
- setTimeout(() => {
173
- showDropdown();
174
- setTimeout(() => {
175
- if (children && boxRef.current && boxRef.current.querySelector('input')) {
176
- boxRef.current.querySelector('input').focus();
177
- }
178
- }, 10);
179
- }, timing[unique + 'Box'] ? 200 : 0);
180
173
  }
181
174
  } else if (multiple || itemMode === 'treeview') {
182
175
  if (searchRef.current) {
@@ -459,7 +452,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
459
452
  const icon = getIconFromData(data);
460
453
 
461
454
  if (multiple && selectBox) {
462
- const checked = currentValue[unique].includes(value);
455
+ const checked = Array.isArray(currentValue[unique]) ? currentValue[unique].includes(value) : [currentValue[unique]].includes(value);
463
456
  items.push(jsx("div", {
464
457
  key: index,
465
458
  css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
@@ -607,7 +600,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
607
600
  }
608
601
 
609
602
  const dropdownItem = document.createElement('div');
610
- dropdownItem.className = `css-${_DropdownItemCSS.name}`;
603
+ dropdownItem.className = `DGN-UI-Dropdown-Item css-${_DropdownItemCSS.name}`;
611
604
  dropdownItem.tabIndex = -1;
612
605
  dropdownItem.addEventListener('click', () => onChangeValue(displayText, value, icon, data, i));
613
606
  dropdownItem.addEventListener('keypress', e => {
@@ -616,7 +609,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
616
609
  let item = null;
617
610
 
618
611
  if (multiple && selectBox) {
619
- const checked = currentValue[unique].includes(value);
612
+ const checked = Array.isArray(currentValue[unique]) ? currentValue[unique].includes(value) : [currentValue[unique]].includes(value);
620
613
  item = jsx(Checkbox, {
621
614
  defaultChecked: checked,
622
615
  style: {
@@ -899,7 +892,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
899
892
  }
900
893
  }
901
894
 
902
- if (closeAfterSelect) {
895
+ if (closeAfterSelect === true || closeAfterSelect === undefined && !multiple) {
903
896
  closeDropdown();
904
897
  }
905
898
  };
@@ -952,6 +945,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
952
945
 
953
946
  e && e.target && e.target.blur();
954
947
  updatePositionDropdown();
948
+ onInput === null || onInput === void 0 ? void 0 : onInput({ ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
949
+ target: {
950
+ value: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.value
951
+ }
952
+ });
955
953
  !!onChange && onChange({
956
954
  value: currentValue[unique]
957
955
  });
@@ -1035,7 +1033,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1035
1033
  }
1036
1034
 
1037
1035
  if (!isSearch[unique]) {
1038
- inputRef.current.value = '';
1036
+ inputRef.current.value = source;
1039
1037
  }
1040
1038
  }
1041
1039
  };
@@ -1130,13 +1128,18 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1130
1128
 
1131
1129
  currentRef.showDropdown = () => showDropdown();
1132
1130
 
1133
- currentRef.onClear = onClear, currentRef.setPreviousValue = setPreviousValue, currentRef.setValue = value => {
1131
+ currentRef.onClear = onClear;
1132
+ currentRef.setPreviousValue = setPreviousValue;
1133
+
1134
+ currentRef.setValue = value => {
1134
1135
  if (allValue[unique][allValue[unique].length - 1] !== value) {
1135
1136
  allValue[unique].push(value);
1136
1137
  }
1137
1138
 
1138
1139
  setValueIntoInput(value);
1139
- }, currentRef.DOM = dropdownRef.current;
1140
+ };
1141
+
1142
+ currentRef.DOM = dropdownRef.current;
1140
1143
  return currentRef;
1141
1144
  });
1142
1145
  useEffect(() => {
@@ -1298,7 +1301,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1298
1301
  !!onLoadMore && dataSource.length < total && boxRef.current.addEventListener('scroll', onLoadMoreHandler);
1299
1302
  } else {
1300
1303
  isSearch[unique] = false;
1301
- renderDropdown();
1302
1304
  }
1303
1305
  } else {
1304
1306
  if (!multiple && !disabled && !readOnly) {
@@ -1406,6 +1408,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1406
1408
  ...errorStyle
1407
1409
  }
1408
1410
  }, error), [error, disabled, errorStyle]);
1411
+ const dropdownComp = useMemo(() => {
1412
+ return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
1413
+ }, [openState, dataSource]);
1409
1414
  /* End component */
1410
1415
 
1411
1416
  return jsx(Fragment, null, jsx("div", {
@@ -1413,7 +1418,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1413
1418
  css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear),
1414
1419
  className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
1415
1420
  style: style
1416
- }, labelComp, inputComp, errorComp), openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null);
1421
+ }, labelComp, inputComp, errorComp), dropdownComp);
1417
1422
  }));
1418
1423
  /* Start styled */
1419
1424
 
@@ -1756,7 +1761,6 @@ Dropdown.defaultProps = {
1756
1761
  required: false,
1757
1762
  multiple: false,
1758
1763
  allowSearch: false,
1759
- selectBox: false,
1760
1764
  closeAfterSelect: true,
1761
1765
  inputProps: {},
1762
1766
  formStyle: {},
@@ -1797,14 +1801,14 @@ Dropdown.propTypes = {
1797
1801
  /** display this icon if not found the icon follow iconExpr */
1798
1802
  iconDefault: PropTypes.string,
1799
1803
 
1800
- /** field name used for icon display<br/>
1801
- * Example:<br/>
1802
- * &nbsp;&nbsp;string: 'icon'<br/>
1803
- * &nbsp;&nbsp;object: {<br/>
1804
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1805
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1806
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1807
- * &nbsp;&nbsp;}
1804
+ /** field name used for icon display<br/>
1805
+ * Example:<br/>
1806
+ * &nbsp;&nbsp;string: 'icon'<br/>
1807
+ * &nbsp;&nbsp;object: {<br/>
1808
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1809
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1810
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1811
+ * &nbsp;&nbsp;}
1808
1812
  */
1809
1813
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1810
1814
  key: PropTypes.string,
@@ -1822,9 +1826,9 @@ Dropdown.propTypes = {
1822
1826
  /** field name used for text display in input */
1823
1827
  keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1824
1828
 
1825
- /** field name used for text display<br/>
1826
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1827
- * Note: don't use 'id - name', return undefined
1829
+ /** field name used for text display<br/>
1830
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1831
+ * Note: don't use 'id - name', return undefined
1828
1832
  */
1829
1833
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1830
1834
 
@@ -1834,9 +1838,9 @@ Dropdown.propTypes = {
1834
1838
  /** the field name used for the returned result */
1835
1839
  valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1836
1840
 
1837
- /**
1838
- * duration wait enter search content on search<br/>
1839
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1841
+ /**
1842
+ * duration wait enter search content on search<br/>
1843
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1840
1844
  */
1841
1845
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1842
1846
 
@@ -1903,19 +1907,19 @@ Dropdown.propTypes = {
1903
1907
  /** The array of elements that appear in the dropdown */
1904
1908
  dataSource: PropTypes.array,
1905
1909
 
1906
- /** function displays items by custom<br/>
1907
- * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1908
- * --> such as: displayExpr={'name - role'}
1910
+ /** function displays items by custom<br/>
1911
+ * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1912
+ * --> such as: displayExpr={'name - role'}
1909
1913
  */
1910
1914
  renderItem: PropTypes.func,
1911
1915
 
1912
- /** function displays selected items by custom, example:<br/>
1913
- * renderItem={(data, index) => index + ' - ' + data.name}<br/>
1916
+ /** function displays selected items by custom, example:<br/>
1917
+ * renderItem={(data, index) => index + ' - ' + data.name}<br/>
1914
1918
  */
1915
1919
  renderSelectedItem: PropTypes.func,
1916
1920
 
1917
- /** the function will run when entering input<br/>
1918
- * if undefined: the filter function will run (default)
1921
+ /** the function will run when entering input<br/>
1922
+ * if undefined: the filter function will run (default)
1919
1923
  */
1920
1924
  onInput: PropTypes.func,
1921
1925
 
@@ -1934,19 +1938,19 @@ Dropdown.propTypes = {
1934
1938
  /** the contents in Dropdown box (Exp: TreeView) */
1935
1939
  children: PropTypes.node,
1936
1940
 
1937
- /**
1938
- * ref methods
1939
- *
1940
- * how to get component element? ref.current
1941
- *
1942
- * how to call method? ref.current.instance.{method}
1943
- *
1944
- * * showDropdown(): Show dropdown
1945
- * * closeDropdown(): Close dropdown
1946
- * * onClear(): Clear selected value
1947
- * * setPreviousValue(): Set value to previous value
1948
- * * setValue(value): Set value of dropdown
1949
- * * @param {value} - string || number || array
1941
+ /**
1942
+ * ref methods
1943
+ *
1944
+ * how to get component element? ref.current
1945
+ *
1946
+ * how to call method? ref.current.instance.{method}
1947
+ *
1948
+ * * showDropdown(): Show dropdown
1949
+ * * closeDropdown(): Close dropdown
1950
+ * * onClear(): Clear selected value
1951
+ * * setPreviousValue(): Set value to previous value
1952
+ * * setValue(value): Set value of dropdown
1953
+ * * @param {value} - string || number || array
1950
1954
  */
1951
1955
  reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
1952
1956
  current: PropTypes.instanceOf(Element)
@@ -5,66 +5,68 @@ import { memo, forwardRef } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
7
  import { Typography } from '../../';
8
- import theme from '../../../theme/settings';
9
8
  import { getGlobal } from '../../../global';
9
+ import theme from '../../../theme/settings';
10
+ const {
11
+ colors: {
12
+ system: {
13
+ disabled: systemDisabled
14
+ },
15
+ semantic: {
16
+ success,
17
+ warning,
18
+ danger,
19
+ info
20
+ }
21
+ },
22
+ spacing
23
+ } = theme;
24
+ const colorMap = new Map([['default', danger], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
10
25
  const HelperText = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
11
26
  disabled,
12
27
  status,
13
28
  className,
29
+ style,
14
30
  children,
15
- ...props
31
+ id
16
32
  }, ref) => {
17
- /* Start styled */
18
- const HelperTextRoot = css`
19
- margin-top: 4px;
20
- &.info {
21
- color: ${theme.colors.info};
22
- }
23
- &.success {
24
- color: ${theme.colors.success};
25
- }
26
- &.warning {
27
- color: ${theme.colors.warning};
28
- }
29
- &.danger {
30
- color: ${theme.colors.danger};
31
- }
32
- &.disabled {
33
- color: ${theme.colors.disabled};
34
- }
35
- `;
36
- /* End styled */
37
-
33
+ const color = colorMap.get(status);
38
34
  return jsx(Typography, {
39
35
  ref: ref,
36
+ id: id,
40
37
  type: 'p3',
41
- color: theme.colors.danger,
38
+ color: disabled ? systemDisabled : color,
42
39
  fullWidth: false,
43
- css: HelperTextRoot,
44
- className: ['DGN-UI-HelperText', className, status, disabled ? 'disabled' : ''].join(' ').trim(),
45
- ...props
40
+ css: HelperTextRootCSS,
41
+ className: ['DGN-UI-HelperText', className].join(' ').trim().replace(/\s+/g, ' '),
42
+ style: style,
43
+ lineClamp: 1
46
44
  }, typeof children === 'boolean' ? getGlobal('thisFieldIsRequired') : children);
47
45
  }));
46
+ const HelperTextRootCSS = css`
47
+ margin-top: ${spacing()}px;
48
+ `;
48
49
  HelperText.defaultProps = {
49
50
  disabled: false,
50
51
  status: 'default',
51
52
  className: '',
53
+ style: {},
52
54
  children: ''
53
55
  };
54
56
  HelperText.propTypes = {
55
- /** prevent all event if true */
57
+ /** If true, the component is disabled. */
56
58
  disabled: PropTypes.bool,
57
59
 
58
60
  /** status type to display color for input (only available for type is inform) */
59
61
  status: PropTypes.oneOf(['default', 'warning', 'success', 'danger', 'info']),
60
62
 
61
- /** class use in for helper text */
63
+ /** Class for component. */
62
64
  className: PropTypes.string,
63
65
 
64
- /** the content to display in HelperText */
65
- children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
66
+ /** Style inline of component. */
67
+ style: PropTypes.object,
66
68
 
67
- /** any props else */
68
- props: PropTypes.any
69
+ /** Content to display in component. */
70
+ children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
69
71
  };
70
72
  export default HelperText;
@@ -221,14 +221,14 @@ const NumberInput = /*#__PURE__*/forwardRef(({
221
221
  e.preventDefault();
222
222
  } // key arrow down
223
223
  else if (keyCode === 40) {
224
- _onInput({ ...e,
225
- target: { ...e.target,
226
- value: Number(convertMoneyToNumber(value) || 0) - step
227
- }
228
- });
224
+ _onInput({ ...e,
225
+ target: { ...e.target,
226
+ value: Number(convertMoneyToNumber(value) || 0) - step
227
+ }
228
+ });
229
229
 
230
- e.preventDefault();
231
- } // disabled negative
230
+ e.preventDefault();
231
+ } // disabled negative
232
232
 
233
233
 
234
234
  const disabled180 = (keyCode === 189 || keyCode === 109) && (disabledNegative || value.includes('-')); // Block event if include conditions
@@ -3,11 +3,11 @@
3
3
  /** @jsx jsx */
4
4
  import { css, jsx } from '@emotion/core';
5
5
  import PropTypes from 'prop-types';
6
- import { forwardRef, memo, useState, useRef } from 'react';
6
+ import { forwardRef, memo, useState, useRef, useEffect, useMemo } from 'react';
7
7
  import theme from '../../../theme/settings';
8
8
  import { randomString } from '../../../utils';
9
9
  import Typography from './../../typography';
10
- import { cursorPointer, borderBox, positionAbsolute, positionRelative, displayNone, displayBlock, pointerEventsNone, cursorNotAllowed } from '../../../styles/general';
10
+ import { cursorPointer, borderBox, positionAbsolute, positionRelative, displayNone, displayBlock, cursorNoDrop } from '../../../styles/general';
11
11
  const {
12
12
  spacing,
13
13
  colors: {
@@ -24,6 +24,7 @@ const {
24
24
  const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
25
25
  id,
26
26
  disabled,
27
+ readOnly,
27
28
  name,
28
29
  defaultChecked,
29
30
  checked,
@@ -34,8 +35,7 @@ const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
34
35
  onChange,
35
36
  inputRef,
36
37
  inputProps,
37
- lineClamp,
38
- hoverTooltip,
38
+ labelProps,
39
39
  ...props
40
40
  }, ref) => {
41
41
  if (!inputRef) {
@@ -46,127 +46,140 @@ const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
46
46
  allowNumber: false,
47
47
  allowSymbol: false
48
48
  }));
49
- const formCheck = css`
50
- ${positionRelative};
51
- ${displayBlock};
52
- &.disabled {
53
- ${pointerEventsNone};
54
- }
55
- `;
56
- const formCheckInput = css`
57
- ${positionAbsolute};
58
- ${borderBox};
59
- ${displayNone};
60
- &:hover ~ label::before {
61
- box-shadow: 0 0 0 2px ${clFillHover};
62
- background: ${clFillHover};
63
- }
64
- &:checked ~ label:after {
65
- ${borderBox};
66
- ${positionAbsolute};
67
- width: ${width / 2}px;
68
- height: ${width / 2}px;
69
- left: ${width / 4}px;
70
- background: ${clSystemActive};
71
- border-radius: 50%;
72
- top: 50%;
73
- transform: translateY(-50%);
74
- content: '';
75
- transition: 0.28s ease;
76
- }
77
- &:checked ~ label:before {
78
- border-color: ${clSystemActive};
79
- }
80
- &:disabled + label {
81
- ${pointerEventsNone};
82
- ${cursorNotAllowed};
83
- color: ${clDisabled};
84
- &::after {
85
- background: ${clDisabled};
86
- }
87
- &::before {
88
- border-color: ${clDisabled};
89
- }
90
- }
91
- `;
92
- const formCheckLabel = css`
93
- ${displayBlock};
94
- ${positionRelative};
95
- ${cursorPointer};
96
- padding-left: ${width + spacing(1.5)}px;
97
- min-height: ${width}px;
98
- margin: 2px;
99
- &:before {
100
- ${positionAbsolute};
101
- ${borderBox};
102
- width: ${width}px;
103
- height: ${width}px;
104
- border-radius: 50%;
105
- top: 50%;
106
- transform: translateY(-50%);
107
- left: 0;
108
- content: '';
109
- border: 2px solid ${clSystemRest};
110
- transition: 0.28s ease;
111
- }
112
- `;
49
+ const [checkedState, setCheckedState] = useState(Boolean(checked !== undefined ? checked : defaultChecked));
50
+
51
+ const _formCheckInputCSS = formCheckInputCSS(width);
52
+
53
+ const _formCheckLabelCSS = formCheckLabelCSS(width);
113
54
 
114
55
  const handleChange = e => {
115
- const el = { ...e
56
+ if (disabled || readOnly) return;
57
+ if (checked === undefined) setCheckedState(true);
58
+ e = {
59
+ value: value,
60
+ target: { ...inputRef.current,
61
+ checked: true
62
+ }
116
63
  };
117
- el.value = value !== null && value !== void 0 ? value : label;
118
- onChange && onChange(el);
64
+ if (onChange) onChange(e);
119
65
  };
120
66
 
121
- return jsx("div", {
122
- id: 'DGN-Core-Radio-' + (id || unique),
123
- css: formCheck,
124
- className: ['DGN-UI-Radio', disabled ? 'disabled' : '', className].join(' ').trim(),
125
- ref: ref,
126
- ...props
127
- }, jsx("input", { ...inputProps,
128
- disabled: disabled,
129
- ref: inputRef,
130
- name: name,
131
- hidden: true,
132
- checked: checked,
133
- type: "radio",
134
- defaultChecked: defaultChecked,
135
- css: formCheckInput,
136
- id: id || unique,
137
- onChange: handleChange
138
- }), jsx("label", {
139
- css: formCheckLabel,
140
- htmlFor: id || unique
141
- }, jsx(Typography, {
142
- color: disabled ? clDisabled : '',
143
- type: 'p1',
144
- lineClamp: lineClamp,
145
- hoverTooltip: hoverTooltip
146
- }, label !== null && label !== void 0 ? label : value)));
67
+ useEffect(() => {
68
+ if (checked !== undefined) setCheckedState(Boolean(checked));
69
+ }, [checked]);
70
+ return useMemo(() => {
71
+ return jsx("div", {
72
+ id: 'DGN-Core-Radio-' + (id || unique),
73
+ css: formCheckCSS,
74
+ className: ['DGN-UI-Radio', className].join(' ').trim().replace(/\s+/g, ' '),
75
+ ref: ref,
76
+ ...props
77
+ }, jsx("input", { ...inputProps,
78
+ disabled: disabled,
79
+ ref: inputRef,
80
+ name: name,
81
+ hidden: true,
82
+ checked: checkedState,
83
+ type: "radio",
84
+ css: _formCheckInputCSS,
85
+ id: id || unique,
86
+ onChange: handleChange
87
+ }), jsx("label", {
88
+ css: _formCheckLabelCSS,
89
+ className: `${disabled ? 'disabled' : ''} ${readOnly ? 'read-only' : ''}`,
90
+ htmlFor: id || unique,
91
+ onClick: handleChange
92
+ }, jsx(Typography, {
93
+ color: disabled ? clDisabled : '',
94
+ type: 'p1',
95
+ ...labelProps
96
+ }, label !== null && label !== void 0 ? label : value)));
97
+ }, [disabled, onChange, readOnly, checkedState]);
147
98
  }));
99
+ const formCheckCSS = css`
100
+ ${displayBlock};
101
+ padding: ${spacing(0.5)}px;
102
+ `;
103
+
104
+ const formCheckInputCSS = width => css`
105
+ ${positionAbsolute};
106
+ ${borderBox};
107
+ ${displayNone};
108
+ &:checked ~ label:after {
109
+ ${borderBox};
110
+ ${positionAbsolute};
111
+ width: ${width / 2}px;
112
+ height: ${width / 2}px;
113
+ left: ${width / 4}px;
114
+ background: ${clSystemActive};
115
+ border-radius: 50%;
116
+ top: 50%;
117
+ transform: translateY(-50%);
118
+ content: '';
119
+ transition: 0.28s ease;
120
+ }
121
+ &:checked ~ label:before {
122
+ border-color: ${clSystemActive};
123
+ }
124
+ `;
125
+
126
+ const formCheckLabelCSS = width => css`
127
+ ${displayBlock};
128
+ ${positionRelative};
129
+ ${cursorPointer};
130
+ margin-bottom: 0 !important;
131
+ padding-left: ${width + spacing(1.5)}px;
132
+ min-height: ${width}px;
133
+ &:hover:not(.disabled):not(.read-only)::before {
134
+ box-shadow: 0 0 0 2px ${clFillHover};
135
+ background: ${clFillHover};
136
+ }
137
+ &.disabled,
138
+ &.read-only {
139
+ ${cursorNoDrop};
140
+ }
141
+ &.disabled {
142
+ color: ${clDisabled};
143
+ &:after {
144
+ background: ${clDisabled} !important;
145
+ }
146
+ &:before {
147
+ border-color: ${clDisabled} !important;
148
+ }
149
+ }
150
+ &:before {
151
+ ${positionAbsolute};
152
+ ${borderBox};
153
+ width: ${width}px;
154
+ height: ${width}px;
155
+ border-radius: 50%;
156
+ top: 50%;
157
+ transform: translateY(-50%);
158
+ left: 0;
159
+ content: '';
160
+ border: 2px solid ${clSystemRest};
161
+ transition: 0.28s ease;
162
+ }
163
+ `;
164
+
148
165
  Radio.defaultProps = {
149
166
  disabled: false,
167
+ readOnly: false,
150
168
  defaultChecked: false,
151
169
  label: '',
152
170
  value: '',
153
171
  className: '',
154
- width: 20
172
+ width: 20,
173
+ labelProps: {}
155
174
  };
156
175
  Radio.propTypes = {
157
- /**
158
- * If `true`, the component is disabled.
159
- */
176
+ /** If `true`, the component is disabled. */
160
177
  disabled: PropTypes.bool,
161
178
 
162
- /**
163
- * If `true`, the component is checked.
164
- */
179
+ /** If `true`, the component is checked. */
165
180
  checked: PropTypes.bool,
166
181
 
167
- /**
168
- * If `true`, the component is defaultChecked.
169
- */
182
+ /** If `true`, the component is defaultChecked. */
170
183
  defaultChecked: PropTypes.bool,
171
184
 
172
185
  /** Id is randomized randomly to avoid duplication. */
@@ -176,7 +189,7 @@ Radio.propTypes = {
176
189
  name: PropTypes.string,
177
190
 
178
191
  /** The value of the component. The DOM API casts this to a string. */
179
- value: PropTypes.string,
192
+ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
180
193
 
181
194
  /** The name of the Radio is displayed on the interface */
182
195
  label: PropTypes.string,
@@ -184,7 +197,7 @@ Radio.propTypes = {
184
197
  /** The class for Radio component */
185
198
  className: PropTypes.string,
186
199
 
187
- /** props for input */
200
+ /** Props for input. */
188
201
  inputProps: PropTypes.object,
189
202
 
190
203
  /** Callback fired when the state is changed.
@@ -195,10 +208,10 @@ Radio.propTypes = {
195
208
  * */
196
209
  onChange: PropTypes.func,
197
210
 
198
- /** The line-clamp property truncates text at a specific number of lines. */
199
- lineClamp: PropTypes.number,
211
+ /** Prevent all event if true. */
212
+ readOnly: PropTypes.bool,
200
213
 
201
- /** If true, hover will show tooltip when text clamped. */
202
- hoverTooltip: PropTypes.bool
214
+ /** Props for Typography of label. */
215
+ labelProps: PropTypes.object
203
216
  };
204
217
  export default Radio;