@happeouikit/form-elements 2.3.27 → 2.3.29
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/dist/Badge.d.ts +21 -0
- package/dist/Checkbox.d.ts +27 -0
- package/dist/CheckboxGroup.d.ts +90 -0
- package/dist/DatePicker.d.ts +54 -0
- package/dist/DateTimePicker.d.ts +21 -0
- package/dist/Dropdown.d.ts +7 -0
- package/dist/Input.d.ts +13 -0
- package/dist/Input.types.d.ts +18 -0
- package/dist/Link.d.ts +3 -0
- package/dist/RadioButton.d.ts +19 -0
- package/dist/Switch.d.ts +19 -0
- package/dist/Tag.d.ts +15 -0
- package/dist/Textarea.d.ts +20 -0
- package/dist/Typeahead/Typeahead.d.ts +46 -0
- package/dist/Typeahead/TypeaheadDropdown.d.ts +5 -0
- package/dist/Typeahead/TypeaheadError.d.ts +2 -0
- package/dist/Typeahead/TypeaheadList.d.ts +3 -0
- package/dist/Typeahead/TypeaheadLoading.d.ts +4 -0
- package/dist/Typeahead/TypeaheadMessage.d.ts +7 -0
- package/dist/Typeahead/TypeaheadNoResults.d.ts +4 -0
- package/dist/Typeahead/messages.d.ts +37 -0
- package/dist/index.cjs.js +780 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/{index.js → index.d.ts} +1 -1
- package/dist/index.es.js +12478 -0
- package/dist/index.es.js.map +1 -0
- package/dist/messages.d.ts +91 -0
- package/dist/style.css +1 -0
- package/dist/utils.d.ts +8 -0
- package/messages.json +1 -0
- package/package.json +18 -15
- package/dist/Badge.js +0 -41
- package/dist/Checkbox.js +0 -107
- package/dist/CheckboxGroup.js +0 -134
- package/dist/DatePicker.js +0 -445
- package/dist/DateTimePicker.js +0 -191
- package/dist/Dropdown.js +0 -65
- package/dist/Input.js +0 -160
- package/dist/Link.js +0 -51
- package/dist/RadioButton.js +0 -41
- package/dist/Switch.js +0 -70
- package/dist/Tag.js +0 -59
- package/dist/Textarea.js +0 -88
- package/dist/Typeahead/Typeahead.js +0 -214
- package/dist/Typeahead/TypeaheadDropdown.js +0 -25
- package/dist/Typeahead/TypeaheadError.js +0 -14
- package/dist/Typeahead/TypeaheadList.js +0 -37
- package/dist/Typeahead/TypeaheadLoading.js +0 -23
- package/dist/Typeahead/TypeaheadMessage.js +0 -39
- package/dist/Typeahead/TypeaheadNoResults.js +0 -17
- package/dist/Typeahead/messages.js +0 -29
- package/dist/messages.js +0 -63
- package/dist/utils.js +0 -51
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
namespace dateTimePickerLabel {
|
|
3
|
+
let id: string;
|
|
4
|
+
let defaultMessage: string;
|
|
5
|
+
}
|
|
6
|
+
namespace am {
|
|
7
|
+
let id_1: string;
|
|
8
|
+
export { id_1 as id };
|
|
9
|
+
let defaultMessage_1: string;
|
|
10
|
+
export { defaultMessage_1 as defaultMessage };
|
|
11
|
+
}
|
|
12
|
+
namespace pm {
|
|
13
|
+
let id_2: string;
|
|
14
|
+
export { id_2 as id };
|
|
15
|
+
let defaultMessage_2: string;
|
|
16
|
+
export { defaultMessage_2 as defaultMessage };
|
|
17
|
+
}
|
|
18
|
+
namespace twentyFourHour {
|
|
19
|
+
let id_3: string;
|
|
20
|
+
export { id_3 as id };
|
|
21
|
+
let defaultMessage_3: string;
|
|
22
|
+
export { defaultMessage_3 as defaultMessage };
|
|
23
|
+
}
|
|
24
|
+
namespace timeInputPlaceholder {
|
|
25
|
+
let id_4: string;
|
|
26
|
+
export { id_4 as id };
|
|
27
|
+
let defaultMessage_4: string;
|
|
28
|
+
export { defaultMessage_4 as defaultMessage };
|
|
29
|
+
}
|
|
30
|
+
namespace timeInputLabel {
|
|
31
|
+
let id_5: string;
|
|
32
|
+
export { id_5 as id };
|
|
33
|
+
let defaultMessage_5: string;
|
|
34
|
+
export { defaultMessage_5 as defaultMessage };
|
|
35
|
+
}
|
|
36
|
+
namespace invalidTime {
|
|
37
|
+
let id_6: string;
|
|
38
|
+
export { id_6 as id };
|
|
39
|
+
let defaultMessage_6: string;
|
|
40
|
+
export { defaultMessage_6 as defaultMessage };
|
|
41
|
+
}
|
|
42
|
+
namespace selectDateFormatDescription {
|
|
43
|
+
let id_7: string;
|
|
44
|
+
export { id_7 as id };
|
|
45
|
+
let defaultMessage_7: string;
|
|
46
|
+
export { defaultMessage_7 as defaultMessage };
|
|
47
|
+
}
|
|
48
|
+
namespace wrongFormat {
|
|
49
|
+
let id_8: string;
|
|
50
|
+
export { id_8 as id };
|
|
51
|
+
let defaultMessage_8: string;
|
|
52
|
+
export { defaultMessage_8 as defaultMessage };
|
|
53
|
+
}
|
|
54
|
+
namespace notNumber {
|
|
55
|
+
let id_9: string;
|
|
56
|
+
export { id_9 as id };
|
|
57
|
+
let defaultMessage_9: string;
|
|
58
|
+
export { defaultMessage_9 as defaultMessage };
|
|
59
|
+
}
|
|
60
|
+
namespace pickerPrevMonth {
|
|
61
|
+
let id_10: string;
|
|
62
|
+
export { id_10 as id };
|
|
63
|
+
let defaultMessage_10: string;
|
|
64
|
+
export { defaultMessage_10 as defaultMessage };
|
|
65
|
+
}
|
|
66
|
+
namespace pickerNextMonth {
|
|
67
|
+
let id_11: string;
|
|
68
|
+
export { id_11 as id };
|
|
69
|
+
let defaultMessage_11: string;
|
|
70
|
+
export { defaultMessage_11 as defaultMessage };
|
|
71
|
+
}
|
|
72
|
+
namespace pickerSelectYear {
|
|
73
|
+
let id_12: string;
|
|
74
|
+
export { id_12 as id };
|
|
75
|
+
let defaultMessage_12: string;
|
|
76
|
+
export { defaultMessage_12 as defaultMessage };
|
|
77
|
+
}
|
|
78
|
+
namespace selectYearDropdown {
|
|
79
|
+
let id_13: string;
|
|
80
|
+
export { id_13 as id };
|
|
81
|
+
let defaultMessage_13: string;
|
|
82
|
+
export { defaultMessage_13 as defaultMessage };
|
|
83
|
+
}
|
|
84
|
+
namespace closeYearMonthPicker {
|
|
85
|
+
let id_14: string;
|
|
86
|
+
export { id_14 as id };
|
|
87
|
+
let defaultMessage_14: string;
|
|
88
|
+
export { defaultMessage_14 as defaultMessage };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export default _default;
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.DayPicker{display:inline-block;font-size:1rem}.DayPicker-wrapper{position:relative;flex-direction:row;padding-bottom:1em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.DayPicker-Months{display:flex;flex-wrap:wrap;justify-content:center}.DayPicker-Month{display:table;margin:1em 1em 0;border-spacing:0;border-collapse:collapse;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.DayPicker-NavButton{position:absolute;top:1em;right:1.5em;left:auto;display:inline-block;margin-top:2px;width:1.25em;height:1.25em;background-position:center;background-size:50%;background-repeat:no-repeat;color:#8b9898;cursor:pointer}.DayPicker-NavButton:hover{opacity:.8}.DayPicker-NavButton--prev{margin-right:1.5em;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAwCAYAAAB5R9gVAAAABGdBTUEAALGPC/xhBQAAAVVJREFUWAnN2G0KgjAYwPHpGfRkaZeqvgQaK+hY3SUHrk1YzNLay/OiEFp92I+/Mp2F2Mh2lLISWnflFjzH263RQjzMZ19wgs73ez0o1WmtW+dgA01VxrE3p6l2GLsnBy1VYQOtVSEH/atCCgqpQgKKqYIOiq2CBkqtggLKqQIKgqgCBjpJ2Y5CdJ+zrT9A7HHSTA1dxUdHgzCqJIEwq0SDsKsEg6iqBIEoq/wEcVRZBXFV+QJxV5mBtlDFB5VjYTaGZ2sf4R9PM7U9ZU+lLuaetPP/5Die3ToO1+u+MKtHs06qODB2zBnI/jBd4MPQm1VkY79Tb18gB+C62FdBFsZR6yeIo1YQiLJWMIiqVjQIu1YSCLNWFgijVjYIuhYYCKoWKAiiFgoopxYaKLUWOii2FgkophYp6F3r42W5A9s9OcgNvva8xQaysKXlFytoqdYmQH6tF3toSUo0INq9AAAAAElFTkSuQmCC)}.DayPicker-NavButton--next{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAwCAYAAAB5R9gVAAAABGdBTUEAALGPC/xhBQAAAXRJREFUWAnN119ugjAcwPHWzJ1gnmxzB/BBE0n24m4xfNkTaOL7wOtsl3AXMMb+Vjaa1BG00N8fSEibPpAP3xAKKs2yjzTPH9RAjhEo9WzPr/Vm8zgE0+gXATAxxuxtqeJ9t5tIwv5AtQAApsfT6TPdbp+kUBcgVwvO51KqVhMkXKsVJFXrOkigVhCIs1Y4iKlWZxB1rX4gwlpRIIpa8SDkWmggrFq4IIRaJKCYWnSgnrXIQV1r8YD+1Vrn+bReagysIFfLABRt31v8oBu1xEBttfRbltmfjgEcWh9snUS2kNdBK6WN1vrOWxObWsz+fjxevsxmB1GQDfINWiev83nhaoiB/CoOU438oPrhXS0WpQ9xc1ZQWxWHqUYe0I0qrKCQKjygDlXIQV2r0IF6ViEBxVTBBSFUQQNhVYkHIVeJAtkNsbQ7c1LtzP6FsObhb2rCKv7NBIGoq4SDmKoEgTirXAcJVGkFSVVpgoSrXICGUMUH/QBZNSUy5XWUhwAAAABJRU5ErkJggg==)}.DayPicker-NavButton--interactionDisabled{display:none}.DayPicker-Caption{display:table-caption;margin-bottom:.5em;padding:0 .5em;text-align:left}.DayPicker-Caption>div{font-weight:500;font-size:1.15em}.DayPicker-Weekdays{display:table-header-group;margin-top:1em}.DayPicker-WeekdaysRow{display:table-row}.DayPicker-Weekday{display:table-cell;padding:.5em;color:#8b9898;text-align:center;font-size:.875em}.DayPicker-Weekday abbr[title]{border-bottom:none;text-decoration:none}.DayPicker-Body{display:table-row-group}.DayPicker-Week{display:table-row}.DayPicker-Day{display:table-cell;padding:.5em;border-radius:50%;vertical-align:middle;text-align:center;cursor:pointer}.DayPicker-WeekNumber{display:table-cell;padding:.5em;min-width:1em;border-right:1px solid #EAECEC;color:#8b9898;vertical-align:middle;text-align:right;font-size:.75em;cursor:pointer}.DayPicker--interactionDisabled .DayPicker-Day{cursor:default}.DayPicker-Footer{padding-top:.5em}.DayPicker-TodayButton{border:none;background-color:transparent;background-image:none;box-shadow:none;color:#4a90e2;font-size:.875em;cursor:pointer}.DayPicker-Day--today{color:#d0021b;font-weight:700}.DayPicker-Day--outside{color:#8b9898;cursor:default}.DayPicker-Day--disabled{color:#dce0e0;cursor:default}.DayPicker-Day--sunday{background-color:#f7f8f8}.DayPicker-Day--sunday:not(.DayPicker-Day--today){color:#dce0e0}.DayPicker-Day--selected:not(.DayPicker-Day--disabled):not(.DayPicker-Day--outside){position:relative;background-color:#4a90e2;color:#f0f8ff}.DayPicker-Day--selected:not(.DayPicker-Day--disabled):not(.DayPicker-Day--outside):hover{background-color:#51a0fa}.DayPicker:not(.DayPicker--interactionDisabled) .DayPicker-Day:not(.DayPicker-Day--disabled):not(.DayPicker-Day--selected):not(.DayPicker-Day--outside):hover{background-color:#f0f8ff}.DayPickerInput{display:inline-block}.DayPickerInput-OverlayWrapper{position:relative}.DayPickerInput-Overlay{position:absolute;left:0;z-index:1;background:#fff;box-shadow:0 2px 5px #00000026}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function toCamelCase(str: any): any;
|
|
2
|
+
export function sanitiseHashtag(hashtag: any): string;
|
|
3
|
+
export function isString(value: any): boolean;
|
|
4
|
+
export function getValidChildrenArray(children: any): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>[];
|
|
5
|
+
export function devWarning(message: any): void;
|
|
6
|
+
export function useDevWarningOnce(shouldWarn: any, message: any): void;
|
|
7
|
+
export function uuidv4(): string;
|
|
8
|
+
import React from "react";
|
package/messages.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"id":"datePicker.label.date.time.picker","defaultMessage":"Select date"},{"id":"datePicker.label.am","defaultMessage":"AM"},{"id":"datePicker.label.pm","defaultMessage":"PM"},{"id":"datePicker.label.24h","defaultMessage":"24h"},{"id":"datePicker.placeholder.time","defaultMessage":"hh:mm"},{"id":"datePicker.label.time","defaultMessage":"Time"},{"id":"datePicker.message.invalid.time","defaultMessage":"Invalid Time"},{"id":"datePicker.message.formatDescription","defaultMessage":"Provide a date using the format {localeFormat}"},{"id":"datePicker.message.invalid.format","defaultMessage":"Invalid Format"},{"id":"datePicker.message.invalid.not.number","defaultMessage":"Given time is not a number"},{"id":"datePicker.button.prevMonth","defaultMessage":"Previous month"},{"id":"datePicker.button.nextMonth","defaultMessage":"Next month"},{"id":"datePicker.button.selectYear","defaultMessage":"Select year and month"},{"id":"datePicker.dropdown.selectYear","defaultMessage":"Select year"},{"id":"datePicker.button.closeYearMonthPicker","defaultMessage":"Done"}]
|
package/package.json
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happeouikit/form-elements",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.29",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"jsnext:main": "dist/index.es.js",
|
|
7
|
+
"module": "dist/index.es.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
7
9
|
"files": [
|
|
8
|
-
"dist",
|
|
10
|
+
"/dist",
|
|
9
11
|
"messages.json"
|
|
10
12
|
],
|
|
11
13
|
"scripts": {
|
|
12
|
-
"
|
|
14
|
+
"build": "tsc && vite build"
|
|
13
15
|
},
|
|
16
|
+
"main": "dist/index.js",
|
|
14
17
|
"public": true,
|
|
15
18
|
"author": "Happeo Oy",
|
|
16
19
|
"license": "MIT",
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"@happeo/react-core": "^0.9.0",
|
|
19
|
-
"@happeouikit/buttons": "^2.0.3",
|
|
20
|
-
"@happeouikit/colors": "^1.0.4",
|
|
21
|
-
"@happeouikit/icons": "^2.0.5",
|
|
22
|
-
"@happeouikit/layout": "^1.1.11",
|
|
23
|
-
"@happeouikit/loaders": "^1.0.4",
|
|
24
|
-
"@happeouikit/theme": "^1.0.4",
|
|
25
|
-
"@happeouikit/tooltip": "^1.0.11",
|
|
26
|
-
"@happeouikit/typography": "^1.0.10",
|
|
27
21
|
"lodash.debounce": "^4.0.8",
|
|
28
22
|
"moment": "^2.29.1",
|
|
29
23
|
"polished": "^2.3.3",
|
|
@@ -36,6 +30,15 @@
|
|
|
36
30
|
"@babel/plugin-proposal-unicode-property-regex": "^7.16.0"
|
|
37
31
|
},
|
|
38
32
|
"peerDependencies": {
|
|
33
|
+
"@happeo/react-core": "^0.9.0",
|
|
34
|
+
"@happeouikit/buttons": "^2.0.3",
|
|
35
|
+
"@happeouikit/colors": "^1.0.4",
|
|
36
|
+
"@happeouikit/icons": "^2.0.5",
|
|
37
|
+
"@happeouikit/layout": "^1.1.11",
|
|
38
|
+
"@happeouikit/loaders": "^1.0.4",
|
|
39
|
+
"@happeouikit/theme": "^1.0.4",
|
|
40
|
+
"@happeouikit/tooltip": "^1.0.11",
|
|
41
|
+
"@happeouikit/typography": "^1.0.10",
|
|
39
42
|
"@testing-library/jest-dom": "^5.13.0",
|
|
40
43
|
"@testing-library/react": "^11.2.7",
|
|
41
44
|
"prop-types": "^15.7.2",
|
|
@@ -45,5 +48,5 @@
|
|
|
45
48
|
"publishConfig": {
|
|
46
49
|
"access": "public"
|
|
47
50
|
},
|
|
48
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "a586500fabd9c9e71a8a3be2c3856b6401c407e5"
|
|
49
52
|
}
|
package/dist/Badge.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
import { TinyText } from "@happeouikit/typography";
|
|
5
|
-
import { toBgLight, active, white } from "@happeouikit/colors";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
var Badge = function Badge(_ref) {
|
|
8
|
-
var text = _ref.text,
|
|
9
|
-
isFilled = _ref.isFilled,
|
|
10
|
-
_ref$color = _ref.color,
|
|
11
|
-
color = _ref$color === void 0 ? active : _ref$color,
|
|
12
|
-
applyCustomStylings = _ref.applyCustomStylings;
|
|
13
|
-
return /*#__PURE__*/_jsx(Wrapper, {
|
|
14
|
-
color: color,
|
|
15
|
-
isFilled: isFilled,
|
|
16
|
-
children: applyCustomStylings ? applyCustomStylings(text) : /*#__PURE__*/_jsx(TinyText, {
|
|
17
|
-
color: isFilled ? white : color,
|
|
18
|
-
uppercase: true,
|
|
19
|
-
bold: true,
|
|
20
|
-
children: text
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var Wrapper = styled.span.withConfig({
|
|
25
|
-
displayName: "Badge__Wrapper",
|
|
26
|
-
componentId: "sc-xyqvne-0"
|
|
27
|
-
})(["display:inline-block;background:", ";padding:4px 8px;border-radius:100px;"], function (_ref2) {
|
|
28
|
-
var color = _ref2.color,
|
|
29
|
-
isFilled = _ref2.isFilled;
|
|
30
|
-
return isFilled ? color : toBgLight(color);
|
|
31
|
-
});
|
|
32
|
-
Badge.propTypes = {
|
|
33
|
-
text: PropTypes.node.isRequired,
|
|
34
|
-
isFilled: PropTypes.bool,
|
|
35
|
-
color: PropTypes.string,
|
|
36
|
-
applyCustomStylings: PropTypes.func
|
|
37
|
-
};
|
|
38
|
-
Badge.defaultProps = {
|
|
39
|
-
color: active
|
|
40
|
-
};
|
|
41
|
-
export default Badge;
|
package/dist/Checkbox.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["label", "background", "role", "indeterminate"];
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
import { useRef } from "react";
|
|
7
|
-
import styled from "styled-components";
|
|
8
|
-
import PropTypes from "prop-types";
|
|
9
|
-
import { white, active, gray01, gray06, gray08 } from "@happeouikit/colors";
|
|
10
|
-
import { TextZeta } from "@happeouikit/typography";
|
|
11
|
-
import { IconCheck, IconRemove } from "@happeouikit/icons";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
var Checkbox = function Checkbox(_ref) {
|
|
15
|
-
var label = _ref.label,
|
|
16
|
-
background = _ref.background,
|
|
17
|
-
role = _ref.role,
|
|
18
|
-
indeterminate = _ref.indeterminate,
|
|
19
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
-
var checkboxRef = useRef();
|
|
21
|
-
var onKeyDown = function onKeyDown(event) {
|
|
22
|
-
if (event.key.match(/enter|spacebar|\W{1}/i)) {
|
|
23
|
-
event.preventDefault();
|
|
24
|
-
checkboxRef.current.checked = !checkboxRef.current.checked;
|
|
25
|
-
if (typeof rest.onChange === "function") {
|
|
26
|
-
Object.defineProperty(event, "target", {
|
|
27
|
-
value: checkboxRef.current
|
|
28
|
-
});
|
|
29
|
-
rest.onChange(event);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
return /*#__PURE__*/_jsxs(CheckboxWrapper, {
|
|
34
|
-
background: background,
|
|
35
|
-
disabled: rest.disabled,
|
|
36
|
-
children: [/*#__PURE__*/_jsx("input", _objectSpread({
|
|
37
|
-
ref: checkboxRef,
|
|
38
|
-
type: "checkbox",
|
|
39
|
-
tabIndex: "-1",
|
|
40
|
-
role: role
|
|
41
|
-
}, rest)), indeterminate ? /*#__PURE__*/_jsx(StyledIndeterminate, _objectSpread(_objectSpread({
|
|
42
|
-
onKeyDown: onKeyDown,
|
|
43
|
-
tabIndex: 0
|
|
44
|
-
}, rest), {}, {
|
|
45
|
-
children: /*#__PURE__*/_jsx(Indeterminate, {})
|
|
46
|
-
})) : /*#__PURE__*/_jsx(StyledCheckbox, _objectSpread(_objectSpread({
|
|
47
|
-
onKeyDown: onKeyDown,
|
|
48
|
-
tabIndex: 0
|
|
49
|
-
}, rest), {}, {
|
|
50
|
-
children: /*#__PURE__*/_jsx(Checkmark, {})
|
|
51
|
-
})), label && /*#__PURE__*/_jsx(Label, {
|
|
52
|
-
children: label
|
|
53
|
-
})]
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
Checkbox.propTypes = {
|
|
57
|
-
label: PropTypes.node,
|
|
58
|
-
checked: PropTypes.bool,
|
|
59
|
-
background: PropTypes.string,
|
|
60
|
-
indeterminate: PropTypes.bool
|
|
61
|
-
};
|
|
62
|
-
Checkbox.defaultProps = {
|
|
63
|
-
label: null,
|
|
64
|
-
checked: undefined,
|
|
65
|
-
background: null,
|
|
66
|
-
indeterminate: false
|
|
67
|
-
};
|
|
68
|
-
var StyledCheckbox = styled.span.withConfig({
|
|
69
|
-
displayName: "Checkbox__StyledCheckbox",
|
|
70
|
-
componentId: "sc-tc08iy-0"
|
|
71
|
-
})(["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);
|
|
72
|
-
var StyledIndeterminate = styled.span.withConfig({
|
|
73
|
-
displayName: "Checkbox__StyledIndeterminate",
|
|
74
|
-
componentId: "sc-tc08iy-1"
|
|
75
|
-
})(["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);
|
|
76
|
-
var Checkmark = styled(IconCheck).withConfig({
|
|
77
|
-
displayName: "Checkbox__Checkmark",
|
|
78
|
-
componentId: "sc-tc08iy-2"
|
|
79
|
-
})(["position:absolute;display:none;fill:", ";width:18px;height:16px;top:50%;transform:translateY(-50%);"], white);
|
|
80
|
-
var Indeterminate = styled(IconRemove).withConfig({
|
|
81
|
-
displayName: "Checkbox__Indeterminate",
|
|
82
|
-
componentId: "sc-tc08iy-3"
|
|
83
|
-
})(["position:absolute;fill:", ";width:18px;height:16px;top:50%;transform:translateY(-50%);"], white);
|
|
84
|
-
var CheckboxWrapper = styled.label.withConfig({
|
|
85
|
-
displayName: "Checkbox__CheckboxWrapper",
|
|
86
|
-
componentId: "sc-tc08iy-4"
|
|
87
|
-
})(["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) {
|
|
88
|
-
var disabled = _ref2.disabled;
|
|
89
|
-
return disabled ? "not-allowed" : " pointer";
|
|
90
|
-
}, StyledCheckbox, function (_ref3) {
|
|
91
|
-
var background = _ref3.background;
|
|
92
|
-
return background || active;
|
|
93
|
-
}, function (_ref4) {
|
|
94
|
-
var background = _ref4.background;
|
|
95
|
-
return "2px solid ".concat(background || active);
|
|
96
|
-
}, StyledCheckbox, StyledCheckbox, gray08, gray08, StyledIndeterminate, function (_ref5) {
|
|
97
|
-
var background = _ref5.background;
|
|
98
|
-
return background || active;
|
|
99
|
-
}, function (_ref6) {
|
|
100
|
-
var background = _ref6.background;
|
|
101
|
-
return "2px solid ".concat(background || active);
|
|
102
|
-
}, StyledIndeterminate, StyledIndeterminate, gray08, gray08, gray06);
|
|
103
|
-
var Label = styled(TextZeta).withConfig({
|
|
104
|
-
displayName: "Checkbox__Label",
|
|
105
|
-
componentId: "sc-tc08iy-5"
|
|
106
|
-
})(["display:inline-block;position:relative;margin-left:30px;color:", ";"], gray01);
|
|
107
|
-
export default Checkbox;
|
package/dist/CheckboxGroup.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import React, { useEffect, useMemo, useState } from "react";
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import Checkbox from "./Checkbox";
|
|
6
|
-
import { devWarning, getValidChildrenArray, isString, useDevWarningOnce } from "./utils";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
var getOptions = function getOptions(options) {
|
|
9
|
-
return options.map(function (option) {
|
|
10
|
-
return isString(option) ? {
|
|
11
|
-
label: option,
|
|
12
|
-
value: option
|
|
13
|
-
} : option;
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var sortValuesByOrderInOptions = function sortValuesByOrderInOptions(options) {
|
|
17
|
-
return function (a, b) {
|
|
18
|
-
var indexA = options.findIndex(function (opt) {
|
|
19
|
-
return opt.value === a;
|
|
20
|
-
});
|
|
21
|
-
var indexB = options.findIndex(function (opt) {
|
|
22
|
-
return opt.value === b;
|
|
23
|
-
});
|
|
24
|
-
return indexA - indexB;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
var getOptionsFromChildren = function getOptionsFromChildren(children) {
|
|
28
|
-
return getValidChildrenArray(children).map(function (_ref) {
|
|
29
|
-
var option = _ref.props;
|
|
30
|
-
return option;
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
var getChildrenDefaultValue = function getChildrenDefaultValue(options) {
|
|
34
|
-
return options.filter(function (_ref2) {
|
|
35
|
-
var defaultChecked = _ref2.defaultChecked;
|
|
36
|
-
return defaultChecked;
|
|
37
|
-
}).map(function (_ref3) {
|
|
38
|
-
var value = _ref3.value;
|
|
39
|
-
return value;
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
var optionsWarning = "[CheckboxGroup] Both the `children` and `options` props have been used.\n The `options` prop will be ignored. To get rid of this warning, remove one of these props.";
|
|
43
|
-
var defaultValueWarning = "[CheckboxGroup] Both the `defaultChecked` and `defaultValue` props have been used.\n The `defaultValue` prop will be ignored. To get rid of this warning, remove one of these props.";
|
|
44
|
-
var CheckboxGroup = function CheckboxGroup(_ref4) {
|
|
45
|
-
var value = _ref4.value,
|
|
46
|
-
disabled = _ref4.disabled,
|
|
47
|
-
name = _ref4.name,
|
|
48
|
-
children = _ref4.children,
|
|
49
|
-
className = _ref4.className,
|
|
50
|
-
rawOptions = _ref4.options,
|
|
51
|
-
onGroupChange = _ref4.onChange,
|
|
52
|
-
groupDefaultValue = _ref4.defaultValue;
|
|
53
|
-
useDevWarningOnce(children && rawOptions, optionsWarning);
|
|
54
|
-
var options = useMemo(function () {
|
|
55
|
-
return children ? getOptionsFromChildren(children) : getOptions(rawOptions);
|
|
56
|
-
}, [children, rawOptions]);
|
|
57
|
-
var defaultValue = useMemo(function () {
|
|
58
|
-
var childrenDefaultValue = getChildrenDefaultValue(options);
|
|
59
|
-
var hasChildrenDefaultValue = Boolean(childrenDefaultValue.length);
|
|
60
|
-
if (hasChildrenDefaultValue && groupDefaultValue) {
|
|
61
|
-
devWarning(defaultValueWarning);
|
|
62
|
-
}
|
|
63
|
-
return hasChildrenDefaultValue ? childrenDefaultValue : groupDefaultValue;
|
|
64
|
-
}, [options, groupDefaultValue]);
|
|
65
|
-
var _useState = useState(value || defaultValue || []),
|
|
66
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
-
groupValue = _useState2[0],
|
|
68
|
-
setGroupValue = _useState2[1];
|
|
69
|
-
useEffect(function () {
|
|
70
|
-
if (value) {
|
|
71
|
-
setGroupValue(value);
|
|
72
|
-
}
|
|
73
|
-
}, [value]);
|
|
74
|
-
var isChecked = function isChecked(optionValue) {
|
|
75
|
-
return groupValue.includes(optionValue);
|
|
76
|
-
};
|
|
77
|
-
var handleChange = function handleChange(option, event) {
|
|
78
|
-
if (option.onChange) {
|
|
79
|
-
option.onChange(event);
|
|
80
|
-
}
|
|
81
|
-
var newValue = event.target.checked ? [].concat(_toConsumableArray(groupValue), [option.value]) : groupValue.filter(function (val) {
|
|
82
|
-
return val !== option.value;
|
|
83
|
-
});
|
|
84
|
-
var newSortedValue = newValue.sort(sortValuesByOrderInOptions(options));
|
|
85
|
-
setGroupValue(newSortedValue);
|
|
86
|
-
if (onGroupChange) {
|
|
87
|
-
onGroupChange(newSortedValue);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
return /*#__PURE__*/_jsx("div", {
|
|
91
|
-
className: className,
|
|
92
|
-
children: options.map(function (option) {
|
|
93
|
-
return /*#__PURE__*/_jsx(Checkbox, {
|
|
94
|
-
label: option.label,
|
|
95
|
-
name: name,
|
|
96
|
-
disabled: option.disabled || disabled,
|
|
97
|
-
checked: isChecked(option.value),
|
|
98
|
-
onChange: function onChange(event) {
|
|
99
|
-
return handleChange(option, event);
|
|
100
|
-
}
|
|
101
|
-
}, option.value);
|
|
102
|
-
})
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
var optionPropType = PropTypes.oneOfType([PropTypes.shape({
|
|
106
|
-
label: PropTypes.string,
|
|
107
|
-
value: PropTypes.string.isRequired,
|
|
108
|
-
onChange: PropTypes.func
|
|
109
|
-
}), PropTypes.string]);
|
|
110
|
-
CheckboxGroup.propTypes = {
|
|
111
|
-
className: PropTypes.string,
|
|
112
|
-
options: PropTypes.arrayOf(optionPropType),
|
|
113
|
-
onChange: PropTypes.func,
|
|
114
|
-
value: PropTypes.arrayOf(PropTypes.string),
|
|
115
|
-
defaultValue: PropTypes.arrayOf(PropTypes.string),
|
|
116
|
-
disabled: PropTypes.bool,
|
|
117
|
-
name: PropTypes.string,
|
|
118
|
-
children: PropTypes.oneOfType([PropTypes.shape({
|
|
119
|
-
type: PropTypes.oneOf([Checkbox])
|
|
120
|
-
}), PropTypes.arrayOf(PropTypes.shape({
|
|
121
|
-
type: PropTypes.oneOf([Checkbox])
|
|
122
|
-
}))])
|
|
123
|
-
};
|
|
124
|
-
CheckboxGroup.defaultProps = {
|
|
125
|
-
className: "",
|
|
126
|
-
options: null,
|
|
127
|
-
onChange: null,
|
|
128
|
-
value: null,
|
|
129
|
-
defaultValue: null,
|
|
130
|
-
disabled: false,
|
|
131
|
-
name: "",
|
|
132
|
-
children: null
|
|
133
|
-
};
|
|
134
|
-
export default CheckboxGroup;
|