@happeouikit/form-elements 2.3.19 → 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 +8 -0
- package/dist/Checkbox.js +34 -12
- package/dist/Typeahead/Typeahead.js +10 -6
- package/dist/Typeahead/TypeaheadList.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
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(
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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-
|
|
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,
|
|
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-
|
|
111
|
+
componentId: "sc-tc08iy-5"
|
|
90
112
|
})(["display:inline-block;position:relative;margin-left:30px;color:", ";"], gray01);
|
|
91
113
|
export default Checkbox;
|
|
@@ -18,6 +18,7 @@ var Typeahead = function Typeahead(_ref) {
|
|
|
18
18
|
loading = _ref.loading,
|
|
19
19
|
results = _ref.results,
|
|
20
20
|
onSelect = _ref.onSelect,
|
|
21
|
+
onClear = _ref.onClear,
|
|
21
22
|
keepResult = _ref.keepResult,
|
|
22
23
|
placeholder = _ref.placeholder,
|
|
23
24
|
errorMessage = _ref.errorMessage,
|
|
@@ -97,7 +98,7 @@ var Typeahead = function Typeahead(_ref) {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
setSelectedResult(result);
|
|
100
|
-
onSelect(result);
|
|
101
|
+
onSelect(result.data);
|
|
101
102
|
setFocusedResultIndex(null);
|
|
102
103
|
};
|
|
103
104
|
|
|
@@ -110,8 +111,8 @@ var Typeahead = function Typeahead(_ref) {
|
|
|
110
111
|
setSelectedResult(null);
|
|
111
112
|
setFocusedResultIndex(null); // notify parent that selection was erased
|
|
112
113
|
|
|
113
|
-
if (selectedResult) {
|
|
114
|
-
|
|
114
|
+
if (keepResult && selectedResult) {
|
|
115
|
+
onClear();
|
|
115
116
|
}
|
|
116
117
|
};
|
|
117
118
|
|
|
@@ -212,12 +213,14 @@ Typeahead.propTypes = {
|
|
|
212
213
|
loading: PropTypes.bool.isRequired,
|
|
213
214
|
results: PropTypes.arrayOf(PropTypes.shape({
|
|
214
215
|
text: PropTypes.string,
|
|
215
|
-
//
|
|
216
|
+
// If keepResult, this is showed when selecting a result
|
|
216
217
|
component: PropTypes.element.isRequired,
|
|
217
|
-
data: PropTypes.shape //
|
|
218
|
+
data: PropTypes.shape.isRequired // Data will be passed with onSelect
|
|
218
219
|
|
|
219
220
|
})).isRequired,
|
|
220
221
|
onSelect: PropTypes.func.isRequired,
|
|
222
|
+
onClear: PropTypes.func,
|
|
223
|
+
// If keepResult, this is called if user clears the result from input
|
|
221
224
|
keepResult: PropTypes.bool,
|
|
222
225
|
placeholder: PropTypes.string,
|
|
223
226
|
errorMessage: PropTypes.string,
|
|
@@ -229,6 +232,7 @@ Typeahead.defaultProps = {
|
|
|
229
232
|
placeholder: "",
|
|
230
233
|
errorMessage: null,
|
|
231
234
|
queryError: false,
|
|
232
|
-
dropdownMaxHeight: "350px"
|
|
235
|
+
dropdownMaxHeight: "350px",
|
|
236
|
+
onClear: function onClear() {}
|
|
233
237
|
};
|
|
234
238
|
export default Typeahead;
|
|
@@ -33,5 +33,5 @@ var Container = styled.ul.withConfig({
|
|
|
33
33
|
var Row = styled.li.withConfig({
|
|
34
34
|
displayName: "TypeaheadList__Row",
|
|
35
35
|
componentId: "sc-ce1llk-1"
|
|
36
|
-
})(["padding:9px 15px 9px 15px;border:solid 1px transparent;list-style-type:none;&:hover{background:", ";}"], toBgLight(active));
|
|
36
|
+
})(["padding:9px 15px 9px 15px;border:solid 1px transparent;list-style-type:none;cursor:pointer;&:hover{background:", ";}"], toBgLight(active));
|
|
37
37
|
export default TypeaheadList;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happeouikit/form-elements",
|
|
3
|
-
"version": "2.3.
|
|
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": "
|
|
48
|
+
"gitHead": "1feeb8bb81d0e12faa95d6a7b98a555e3f5d4ce8"
|
|
49
49
|
}
|