@ltht-react/select 1.3.97 → 1.3.102

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
@@ -3,6 +3,46 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.3.102 (2022-08-05)
7
+
8
+ **Note:** Version bump only for package @ltht-react/select
9
+
10
+
11
+
12
+
13
+
14
+ ## 1.3.101 (2022-08-05)
15
+
16
+ **Note:** Version bump only for package @ltht-react/select
17
+
18
+
19
+
20
+
21
+
22
+ ## 1.3.100 (2022-08-04)
23
+
24
+ **Note:** Version bump only for package @ltht-react/select
25
+
26
+
27
+
28
+
29
+
30
+ ## 1.3.99 (2022-08-03)
31
+
32
+ **Note:** Version bump only for package @ltht-react/select
33
+
34
+
35
+
36
+
37
+
38
+ ## 1.3.98 (2022-08-03)
39
+
40
+ **Note:** Version bump only for package @ltht-react/select
41
+
42
+
43
+
44
+
45
+
6
46
  ## 1.3.97 (2022-08-02)
7
47
 
8
48
  **Note:** Version bump only for package @ltht-react/select
@@ -1,6 +1,6 @@
1
- import { FC, HTMLAttributes } from 'react';
2
- declare const Option: FC<IProps>;
3
- export interface IProps extends HTMLAttributes<HTMLSpanElement> {
4
- active: boolean;
5
- }
6
- export default Option;
1
+ import { FC, HTMLAttributes } from 'react';
2
+ declare const Option: FC<IProps>;
3
+ export interface IProps extends HTMLAttributes<HTMLSpanElement> {
4
+ active: boolean;
5
+ }
6
+ export default Option;
@@ -1,48 +1,48 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __rest = (this && this.__rest) || function (s, e) {
18
- var t = {};
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
- t[p] = s[p];
21
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
- t[p[i]] = s[p[i]];
25
- }
26
- return t;
27
- };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- var jsx_runtime_1 = require("react/jsx-runtime");
33
- var styled_1 = __importDefault(require("@emotion/styled"));
34
- var styles_1 = require("@ltht-react/styles");
35
- var StyledOption = styled_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n display: block;\n border: 1px solid black;\n border-top: 0;\n padding: 0.5rem 1rem;\n background: ", ";\n cursor: pointer;\n font-weight: ", ";\n transition: all 0.2s ease-in-out;\n\n &:hover {\n background-color: ", ";\n }\n"], ["\n width: 100%;\n display: block;\n border: 1px solid black;\n border-top: 0;\n padding: 0.5rem 1rem;\n background: ", ";\n cursor: pointer;\n font-weight: ", ";\n transition: all 0.2s ease-in-out;\n\n &:hover {\n background-color: ", ";\n }\n"])), function (_a) {
36
- var active = _a.active;
37
- return (active ? "" + styles_1.SELECT_COLOURS.OPTION_SELECTED : 'white');
38
- }, function (_a) {
39
- var active = _a.active;
40
- return (active ? 'bold' : 'normal');
41
- }, styles_1.SELECT_COLOURS.OPTION_HOVER);
42
- var Option = function (_a) {
43
- var children = _a.children, _b = _a.active, active = _b === void 0 ? false : _b, rest = __rest(_a, ["children", "active"]);
44
- return (jsx_runtime_1.jsx(StyledOption, __assign({ active: active }, rest, { children: children }), void 0));
45
- };
46
- exports.default = Option;
47
- var templateObject_1;
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __rest = (this && this.__rest) || function (s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ var jsx_runtime_1 = require("react/jsx-runtime");
33
+ var styled_1 = __importDefault(require("@emotion/styled"));
34
+ var styles_1 = require("@ltht-react/styles");
35
+ var StyledOption = styled_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n display: block;\n border: 1px solid black;\n border-top: 0;\n padding: 0.5rem 1rem;\n background: ", ";\n cursor: pointer;\n font-weight: ", ";\n transition: all 0.2s ease-in-out;\n\n &:hover {\n background-color: ", ";\n }\n"], ["\n width: 100%;\n display: block;\n border: 1px solid black;\n border-top: 0;\n padding: 0.5rem 1rem;\n background: ", ";\n cursor: pointer;\n font-weight: ", ";\n transition: all 0.2s ease-in-out;\n\n &:hover {\n background-color: ", ";\n }\n"])), function (_a) {
36
+ var active = _a.active;
37
+ return (active ? "" + styles_1.SELECT_COLOURS.OPTION_SELECTED : 'white');
38
+ }, function (_a) {
39
+ var active = _a.active;
40
+ return (active ? 'bold' : 'normal');
41
+ }, styles_1.SELECT_COLOURS.OPTION_HOVER);
42
+ var Option = function (_a) {
43
+ var children = _a.children, _b = _a.active, active = _b === void 0 ? false : _b, rest = __rest(_a, ["children", "active"]);
44
+ return (jsx_runtime_1.jsx(StyledOption, __assign({ active: active }, rest, { children: children }), void 0));
45
+ };
46
+ exports.default = Option;
47
+ var templateObject_1;
48
48
  //# sourceMappingURL=option.js.map
package/lib/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { FC, HTMLAttributes } from 'react';
2
- import { IProps as OptionProps } from './atoms/option';
3
- declare const Select: FC<IProps> & SelectComposition;
4
- interface SelectComposition {
5
- Option: FC<OptionProps>;
6
- }
7
- interface IProps extends HTMLAttributes<HTMLDivElement> {
8
- activeOption?: string;
9
- }
10
- export default Select;
1
+ import { FC, HTMLAttributes } from 'react';
2
+ import { IProps as OptionProps } from './atoms/option';
3
+ declare const Select: FC<IProps> & SelectComposition;
4
+ interface SelectComposition {
5
+ Option: FC<OptionProps>;
6
+ }
7
+ interface IProps extends HTMLAttributes<HTMLDivElement> {
8
+ activeOption?: string;
9
+ }
10
+ export default Select;
package/lib/index.js CHANGED
@@ -1,76 +1,76 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __rest = (this && this.__rest) || function (s, e) {
18
- var t = {};
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
- t[p] = s[p];
21
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
- t[p[i]] = s[p[i]];
25
- }
26
- return t;
27
- };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- var jsx_runtime_1 = require("react/jsx-runtime");
33
- var react_1 = require("react");
34
- var styled_1 = __importDefault(require("@emotion/styled"));
35
- var styles_1 = require("@ltht-react/styles");
36
- var icon_1 = require("@ltht-react/icon");
37
- var option_1 = __importDefault(require("./atoms/option"));
38
- var StyledSelect = styled_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n flex-direction: column;\n position: relative;\n"], ["\n ", ";\n display: flex;\n flex-direction: column;\n position: relative;\n"])), styles_1.CSS_RESET);
39
- var SelectTrigger = styled_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n min-height: 32px;\n border: 1px solid black;\n padding: 0.5rem 1rem;\n background: white;\n cursor: pointer;\n\n ", " {\n min-height: 39px;\n }\n"], ["\n display: flex;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n min-height: 32px;\n border: 1px solid black;\n padding: 0.5rem 1rem;\n background: white;\n cursor: pointer;\n\n ", " {\n min-height: 39px;\n }\n"])), styles_1.DESKTOP_MINIMUM_MEDIA_QUERY);
40
- var ActiveOption = styled_1.default.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-weight: bold;\n flex: 1;\n"], ["\n font-weight: bold;\n flex: 1;\n"])));
41
- var SelectOptions = styled_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n display: ", ";\n position: absolute;\n top: 100%;\n left: 0;\n"], ["\n width: 100%;\n display: ", ";\n position: absolute;\n top: 100%;\n left: 0;\n"])), function (_a) {
42
- var open = _a.open;
43
- return (open ? 'block' : 'none');
44
- });
45
- var Select = function (_a) {
46
- var children = _a.children, _b = _a.activeOption, activeOption = _b === void 0 ? '' : _b, rest = __rest(_a, ["children", "activeOption"]);
47
- var _c = react_1.useState(false), open = _c[0], setOpen = _c[1];
48
- var selectRef = react_1.useRef(null);
49
- var handleOnEscapeKey = function (e) {
50
- // IE11 has the key of 'Esc'
51
- if (e.key === 'Escape' || e.key === 'Esc') {
52
- setOpen(false);
53
- }
54
- };
55
- var handleOutsideClick = function (e) {
56
- if (selectRef.current && !selectRef.current.contains(e.target)) {
57
- setOpen(false);
58
- }
59
- };
60
- react_1.useEffect(function () {
61
- document.addEventListener('keydown', handleOnEscapeKey, true);
62
- document.addEventListener('click', handleOutsideClick, true);
63
- // Cleanup
64
- return function () {
65
- document.removeEventListener('keydown', handleOnEscapeKey, true);
66
- document.removeEventListener('click', handleOutsideClick, true);
67
- };
68
- });
69
- return (jsx_runtime_1.jsxs(StyledSelect, __assign({}, rest, { ref: selectRef }, { children: [jsx_runtime_1.jsxs(SelectTrigger, __assign({ "data-testid": "select-trigger", onClick: function () { return setOpen(function (open) { return !open; }); } }, { children: [jsx_runtime_1.jsx(ActiveOption, __assign({ "data-testid": "select-active-option" }, { children: activeOption }), void 0),
70
- jsx_runtime_1.jsx(icon_1.ChevronIcon, { direction: open ? 'up' : 'down', size: "small" }, void 0)] }), void 0),
71
- jsx_runtime_1.jsx(SelectOptions, __assign({ "data-testid": "select-options", open: open, onClick: function () { return setOpen(false); } }, { children: children }), void 0)] }), void 0));
72
- };
73
- Select.Option = option_1.default;
74
- exports.default = Select;
75
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __rest = (this && this.__rest) || function (s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ var jsx_runtime_1 = require("react/jsx-runtime");
33
+ var react_1 = require("react");
34
+ var styled_1 = __importDefault(require("@emotion/styled"));
35
+ var styles_1 = require("@ltht-react/styles");
36
+ var icon_1 = require("@ltht-react/icon");
37
+ var option_1 = __importDefault(require("./atoms/option"));
38
+ var StyledSelect = styled_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n flex-direction: column;\n position: relative;\n"], ["\n ", ";\n display: flex;\n flex-direction: column;\n position: relative;\n"])), styles_1.CSS_RESET);
39
+ var SelectTrigger = styled_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n min-height: 32px;\n border: 1px solid black;\n padding: 0.5rem 1rem;\n background: white;\n cursor: pointer;\n\n ", " {\n min-height: 39px;\n }\n"], ["\n display: flex;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n min-height: 32px;\n border: 1px solid black;\n padding: 0.5rem 1rem;\n background: white;\n cursor: pointer;\n\n ", " {\n min-height: 39px;\n }\n"])), styles_1.DESKTOP_MINIMUM_MEDIA_QUERY);
40
+ var ActiveOption = styled_1.default.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-weight: bold;\n flex: 1;\n"], ["\n font-weight: bold;\n flex: 1;\n"])));
41
+ var SelectOptions = styled_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n display: ", ";\n position: absolute;\n top: 100%;\n left: 0;\n"], ["\n width: 100%;\n display: ", ";\n position: absolute;\n top: 100%;\n left: 0;\n"])), function (_a) {
42
+ var open = _a.open;
43
+ return (open ? 'block' : 'none');
44
+ });
45
+ var Select = function (_a) {
46
+ var children = _a.children, _b = _a.activeOption, activeOption = _b === void 0 ? '' : _b, rest = __rest(_a, ["children", "activeOption"]);
47
+ var _c = react_1.useState(false), open = _c[0], setOpen = _c[1];
48
+ var selectRef = react_1.useRef(null);
49
+ var handleOnEscapeKey = function (e) {
50
+ // IE11 has the key of 'Esc'
51
+ if (e.key === 'Escape' || e.key === 'Esc') {
52
+ setOpen(false);
53
+ }
54
+ };
55
+ var handleOutsideClick = function (e) {
56
+ if (selectRef.current && !selectRef.current.contains(e.target)) {
57
+ setOpen(false);
58
+ }
59
+ };
60
+ react_1.useEffect(function () {
61
+ document.addEventListener('keydown', handleOnEscapeKey, true);
62
+ document.addEventListener('click', handleOutsideClick, true);
63
+ // Cleanup
64
+ return function () {
65
+ document.removeEventListener('keydown', handleOnEscapeKey, true);
66
+ document.removeEventListener('click', handleOutsideClick, true);
67
+ };
68
+ });
69
+ return (jsx_runtime_1.jsxs(StyledSelect, __assign({}, rest, { ref: selectRef }, { children: [jsx_runtime_1.jsxs(SelectTrigger, __assign({ "data-testid": "select-trigger", onClick: function () { return setOpen(function (open) { return !open; }); } }, { children: [jsx_runtime_1.jsx(ActiveOption, __assign({ "data-testid": "select-active-option" }, { children: activeOption }), void 0),
70
+ jsx_runtime_1.jsx(icon_1.ChevronIcon, { direction: open ? 'up' : 'down', size: "small" }, void 0)] }), void 0),
71
+ jsx_runtime_1.jsx(SelectOptions, __assign({ "data-testid": "select-options", open: open, onClick: function () { return setOpen(false); } }, { children: children }), void 0)] }), void 0));
72
+ };
73
+ Select.Option = option_1.default;
74
+ exports.default = Select;
75
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
76
76
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ltht-react/select",
3
- "version": "1.3.97",
3
+ "version": "1.3.102",
4
4
  "description": "ltht-react atoms Select component.",
5
5
  "author": "LTHT",
6
6
  "homepage": "",
@@ -27,11 +27,11 @@
27
27
  "dependencies": {
28
28
  "@emotion/react": "^11.0.0",
29
29
  "@emotion/styled": "^11.0.0",
30
- "@ltht-react/icon": "^1.3.97",
31
- "@ltht-react/styles": "^1.3.89",
32
- "@ltht-react/types": "^1.0.93",
33
- "@ltht-react/utils": "^1.1.95",
30
+ "@ltht-react/icon": "^1.3.102",
31
+ "@ltht-react/styles": "^1.3.94",
32
+ "@ltht-react/types": "^1.0.98",
33
+ "@ltht-react/utils": "^1.1.100",
34
34
  "react": "^17.0.0"
35
35
  },
36
- "gitHead": "4007295972361bf9b74d594c439a0d7908ec1bda"
36
+ "gitHead": "0df7b363c079586ccf5938661dfc455d5b60ec72"
37
37
  }