glints-aries 4.1.0 → 4.1.4
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,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> {
|
|
2
|
+
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange' | 'onClick'> {
|
|
3
3
|
id?: string;
|
|
4
4
|
label?: ReactNode;
|
|
5
5
|
hasError?: boolean;
|
|
@@ -9,5 +9,6 @@ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
9
9
|
helpText?: string;
|
|
10
10
|
onChange?(newChecked: boolean, id: string): void;
|
|
11
11
|
isPadded?: boolean;
|
|
12
|
+
isControlled?: boolean;
|
|
12
13
|
}
|
|
13
14
|
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText", "isPadded"];
|
|
3
|
+
var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText", "isPadded", "isControlled"];
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { StyledCheckbox, StyledCheckboxContainer, StyledColumn, StyledContainer, StyledLeftColumn, StyledRow } from './CheckboxStyle';
|
|
6
6
|
import { noop } from 'lodash-es';
|
|
@@ -18,6 +18,8 @@ export var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref)
|
|
|
18
18
|
helpText = _ref.helpText,
|
|
19
19
|
_ref$isPadded = _ref.isPadded,
|
|
20
20
|
isPadded = _ref$isPadded === void 0 ? true : _ref$isPadded,
|
|
21
|
+
_ref$isControlled = _ref.isControlled,
|
|
22
|
+
isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
|
|
21
23
|
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
24
|
var randomId = nextId('glints-checkbox');
|
|
23
25
|
var checkBoxId = id ? id : randomId;
|
|
@@ -52,7 +54,7 @@ export var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref)
|
|
|
52
54
|
}, /*#__PURE__*/React.createElement(StyledLeftColumn, null, /*#__PURE__*/React.createElement(StyledCheckboxContainer, null, /*#__PURE__*/React.createElement(StyledCheckbox, {
|
|
53
55
|
role: "checkbox",
|
|
54
56
|
"aria-labelledby": labelId,
|
|
55
|
-
"aria-checked": checkedState,
|
|
57
|
+
"aria-checked": isControlled ? checked : checkedState,
|
|
56
58
|
"data-focus": isFocused,
|
|
57
59
|
onClick: function onClick() {
|
|
58
60
|
return handleClick();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> {
|
|
2
|
+
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange' | 'onClick'> {
|
|
3
3
|
id?: string;
|
|
4
4
|
label?: ReactNode;
|
|
5
5
|
hasError?: boolean;
|
|
@@ -9,5 +9,6 @@ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
9
9
|
helpText?: string;
|
|
10
10
|
onChange?(newChecked: boolean, id: string): void;
|
|
11
11
|
isPadded?: boolean;
|
|
12
|
+
isControlled?: boolean;
|
|
12
13
|
}
|
|
13
14
|
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -11,7 +11,7 @@ var _lodash = require("lodash");
|
|
|
11
11
|
var _Icon = require("../Icon");
|
|
12
12
|
var _Typography = require("../Typography");
|
|
13
13
|
var _reactIdGenerator = _interopRequireDefault(require("react-id-generator"));
|
|
14
|
-
var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText", "isPadded"];
|
|
14
|
+
var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText", "isPadded", "isControlled"];
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
var Checkbox = /*#__PURE__*/_react["default"].forwardRef(function Checkbox(_ref, ref) {
|
|
@@ -25,6 +25,8 @@ var Checkbox = /*#__PURE__*/_react["default"].forwardRef(function Checkbox(_ref,
|
|
|
25
25
|
helpText = _ref.helpText,
|
|
26
26
|
_ref$isPadded = _ref.isPadded,
|
|
27
27
|
isPadded = _ref$isPadded === void 0 ? true : _ref$isPadded,
|
|
28
|
+
_ref$isControlled = _ref.isControlled,
|
|
29
|
+
isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
|
|
28
30
|
otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
29
31
|
var randomId = (0, _reactIdGenerator["default"])('glints-checkbox');
|
|
30
32
|
var checkBoxId = id ? id : randomId;
|
|
@@ -59,7 +61,7 @@ var Checkbox = /*#__PURE__*/_react["default"].forwardRef(function Checkbox(_ref,
|
|
|
59
61
|
}, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledLeftColumn, null, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledCheckboxContainer, null, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledCheckbox, {
|
|
60
62
|
role: "checkbox",
|
|
61
63
|
"aria-labelledby": labelId,
|
|
62
|
-
"aria-checked": checkedState,
|
|
64
|
+
"aria-checked": isControlled ? checked : checkedState,
|
|
63
65
|
"data-focus": isFocused,
|
|
64
66
|
onClick: function onClick() {
|
|
65
67
|
return handleClick();
|