@happeouikit/form-elements 2.3.20 → 2.3.21

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.21
4
+
5
+ - [Added] support for indeterminate state of checkbox
6
+
3
7
  ## 2.3.19
4
8
 
5
9
  - [Improved] Typeahead component with `onClear` handler and other tweaks
package/dist/Checkbox.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["label", "background", "role"];
3
+ var _excluded = ["label", "background", "role", "indeterminate"];
4
4
 
5
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
@@ -11,7 +11,7 @@ import styled from "styled-components";
11
11
  import PropTypes from "prop-types";
12
12
  import { white, active, gray01, gray06, gray08 } from "@happeouikit/colors";
13
13
  import { TextZeta } from "@happeouikit/typography";
14
- import { IconCheck } from "@happeouikit/icons";
14
+ import { IconCheck, IconRemove } from "@happeouikit/icons";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
17
 
@@ -19,6 +19,7 @@ var Checkbox = function Checkbox(_ref) {
19
19
  var label = _ref.label,
20
20
  background = _ref.background,
21
21
  role = _ref.role,
22
+ indeterminate = _ref.indeterminate,
22
23
  rest = _objectWithoutProperties(_ref, _excluded);
23
24
 
24
25
  var checkboxRef = useRef();
@@ -42,7 +43,12 @@ var Checkbox = function Checkbox(_ref) {
42
43
  type: "checkbox",
43
44
  tabIndex: "-1",
44
45
  role: role
45
- }, rest)), /*#__PURE__*/_jsx(StyledCheckbox, _objectSpread(_objectSpread({
46
+ }, rest)), indeterminate ? /*#__PURE__*/_jsx(StyledIndeterminate, _objectSpread(_objectSpread({
47
+ onKeyDown: onKeyDown,
48
+ tabIndex: 0
49
+ }, rest), {}, {
50
+ children: /*#__PURE__*/_jsx(Indeterminate, {})
51
+ })) : /*#__PURE__*/_jsx(StyledCheckbox, _objectSpread(_objectSpread({
46
52
  onKeyDown: onKeyDown,
47
53
  tabIndex: 0
48
54
  }, rest), {}, {
@@ -55,26 +61,36 @@ var Checkbox = function Checkbox(_ref) {
55
61
 
56
62
  Checkbox.propTypes = {
57
63
  label: PropTypes.node,
58
- value: PropTypes.string,
59
- background: PropTypes.string
64
+ checked: PropTypes.bool,
65
+ background: PropTypes.string,
66
+ indeterminate: PropTypes.bool
60
67
  };
61
68
  Checkbox.defaultProps = {
62
69
  label: null,
63
- value: undefined,
64
- background: null
70
+ checked: undefined,
71
+ background: null,
72
+ indeterminate: false
65
73
  };
66
74
  var StyledCheckbox = styled.span.withConfig({
67
75
  displayName: "Checkbox__StyledCheckbox",
68
76
  componentId: "sc-tc08iy-0"
69
77
  })(["cursor:pointer;position:absolute;height:18px;width:18px;border-radius:3px;background-color:", ";border:2px solid ", ";box-sizing:content-box !important;&:focus-visible{outline:0;box-shadow:0 0 0 1px ", ";}"], white, gray06, active);
78
+ var StyledIndeterminate = styled.span.withConfig({
79
+ displayName: "Checkbox__StyledIndeterminate",
80
+ componentId: "sc-tc08iy-1"
81
+ })(["cursor:pointer;position:absolute;height:18px;width:18px;border-radius:3px;background-color:", ";border:2px solid ", ";box-sizing:content-box !important;&:focus-visible{outline:0;box-shadow:0 0 0 1px ", ";}"], white, gray06, active);
70
82
  var Checkmark = styled(IconCheck).withConfig({
71
83
  displayName: "Checkbox__Checkmark",
72
- componentId: "sc-tc08iy-1"
84
+ componentId: "sc-tc08iy-2"
73
85
  })(["position:absolute;display:none;fill:", ";width:18px;height:16px;top:50%;transform:translateY(-50%);"], white);
86
+ var Indeterminate = styled(IconRemove).withConfig({
87
+ displayName: "Checkbox__Indeterminate",
88
+ componentId: "sc-tc08iy-3"
89
+ })(["position:absolute;fill:", ";width:18px;height:16px;top:50%;transform:translateY(-50%);"], white);
74
90
  var CheckboxWrapper = styled.label.withConfig({
75
91
  displayName: "Checkbox__CheckboxWrapper",
76
- componentId: "sc-tc08iy-2"
77
- })(["display:flex;align-items:center;position:relative;cursor:", ";user-select:none;padding:4px 0;input{opacity:0;width:0;height:0;}input:checked + ", "{background:", ";border:", ";}input:checked + ", " > svg{display:block;}input:disabled + ", "{cursor:not-allowed;background:", ";border:2px solid ", ";}input:disabled ~ p{color:", ";}"], function (_ref2) {
92
+ componentId: "sc-tc08iy-4"
93
+ })(["display:flex;align-items:center;position:relative;cursor:", ";user-select:none;padding:4px 0;input{opacity:0;width:0;height:0;}input:checked + ", "{background:", ";border:", ";}input:checked + ", " > svg{display:block;}input:disabled + ", "{cursor:not-allowed;background:", ";border:2px solid ", ";}input + ", "{background:", ";border:", ";}input + ", " > svg{display:block;}input:disabled + ", "{cursor:not-allowed;background:", ";border:2px solid ", ";}input:disabled ~ p{color:", ";}"], function (_ref2) {
78
94
  var disabled = _ref2.disabled;
79
95
  return disabled ? "not-allowed" : " pointer";
80
96
  }, StyledCheckbox, function (_ref3) {
@@ -83,9 +99,15 @@ var CheckboxWrapper = styled.label.withConfig({
83
99
  }, function (_ref4) {
84
100
  var background = _ref4.background;
85
101
  return "2px solid ".concat(background || active);
86
- }, StyledCheckbox, StyledCheckbox, gray08, gray08, gray06);
102
+ }, StyledCheckbox, StyledCheckbox, gray08, gray08, StyledIndeterminate, function (_ref5) {
103
+ var background = _ref5.background;
104
+ return background || active;
105
+ }, function (_ref6) {
106
+ var background = _ref6.background;
107
+ return "2px solid ".concat(background || active);
108
+ }, StyledIndeterminate, StyledIndeterminate, gray08, gray08, gray06);
87
109
  var Label = styled(TextZeta).withConfig({
88
110
  displayName: "Checkbox__Label",
89
- componentId: "sc-tc08iy-3"
111
+ componentId: "sc-tc08iy-5"
90
112
  })(["display:inline-block;position:relative;margin-left:30px;color:", ";"], gray01);
91
113
  export default Checkbox;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happeouikit/form-elements",
3
- "version": "2.3.20",
3
+ "version": "2.3.21",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "ea1698bfe17f6f7b4d53f641fdfcf060ece14ac2"
48
+ "gitHead": "1feeb8bb81d0e12faa95d6a7b98a555e3f5d4ce8"
49
49
  }