@opentripplanner/building-blocks 3.0.1 → 3.0.2-alpha.1
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/README.md +4 -0
- package/esm/stories/ColorPalette.js +2 -1
- package/esm/stories/ColorPalette.js.map +1 -1
- package/lib/alert/Alert.js +103 -72
- package/lib/alert/Alert.js.map +1 -1
- package/lib/colors/blue.js +14 -18
- package/lib/colors/blue.js.map +1 -1
- package/lib/colors/grey.js +14 -18
- package/lib/colors/grey.js.map +1 -1
- package/lib/colors/red.js +14 -18
- package/lib/colors/red.js.map +1 -1
- package/lib/dropdown/index.js +87 -102
- package/lib/dropdown/index.js.map +1 -1
- package/lib/dropdown/styled.js +72 -19
- package/lib/dropdown/styled.js.map +1 -1
- package/lib/focus-trap-wrapper/dom-query.js +20 -36
- package/lib/focus-trap-wrapper/dom-query.js.map +1 -1
- package/lib/focus-trap-wrapper/index.js +52 -51
- package/lib/focus-trap-wrapper/index.js.map +1 -1
- package/lib/index.js +36 -41
- package/lib/index.js.map +1 -1
- package/lib/stories/ColorPalette.d.ts.map +1 -1
- package/lib/stories/ColorPalette.js +37 -23
- package/lib/stories/ColorPalette.js.map +1 -1
- package/package.json +3 -3
- package/src/stories/ColorPalette.tsx +3 -1
- package/src/stories/alerts.story.tsx +1 -1
- package/src/stories/dropdown.story.tsx +2 -2
- package/src/stories/index.story.tsx +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
|
-
import
|
|
3
|
+
import coreUtils from "@opentripplanner/core-utils";
|
|
4
|
+
var getMostReadableTextColor = coreUtils.route.getMostReadableTextColor;
|
|
4
5
|
var ColorBlock = styled.div.withConfig({
|
|
5
6
|
displayName: "ColorPalette__ColorBlock",
|
|
6
7
|
componentId: "sc-fil65c-0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPalette.js","names":["React","styled","getMostReadableTextColor","ColorBlock","div","withConfig","displayName","componentId","props","hex","ColorPalette","_ref","color","colorArray","Object","entries","createElement","Fragment","map","hue","key"],"sources":["../../src/stories/ColorPalette.tsx"],"sourcesContent":["import React from \"react\";\n\nimport styled from \"styled-components\";\nimport
|
|
1
|
+
{"version":3,"file":"ColorPalette.js","names":["React","styled","coreUtils","getMostReadableTextColor","route","ColorBlock","div","withConfig","displayName","componentId","props","hex","ColorPalette","_ref","color","colorArray","Object","entries","createElement","Fragment","map","hue","key"],"sources":["../../src/stories/ColorPalette.tsx"],"sourcesContent":["import React from \"react\";\n\nimport styled from \"styled-components\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\nconst { getMostReadableTextColor } = coreUtils.route;\n\nexport interface Hue {\n [key: number]: string;\n}\n\ninterface Props {\n color: Hue;\n}\n\nconst ColorBlock = styled.div<{ hex: string }>`\n align-items: center;\n background-color: ${props => props.hex};\n color: ${props => getMostReadableTextColor(props.hex, \"#ffffff\")};\n text-shadow: ${props =>\n getMostReadableTextColor(props.hex, \"#ffffff\") === \"#ffffff\"\n ? \"1px 1px 2px black\"\n : \"\"};\n display: flex;\n font-family: Arial, Helvetica, sans-serif;\n height: 40px;\n justify-content: space-between;\n margin: 0;\n padding: 10px;\n width: 300px;\n\n &:first-of-type {\n border-radius: 8px 8px 0 0;\n }\n &:last-of-type {\n border-radius: 0 0 8px 8px;\n }\n`;\n\nconst ColorPalette = ({ color }: Props): JSX.Element => {\n const colorArray: Array<Hue> = Object.entries(color);\n\n return (\n <>\n {colorArray.map(\n (hue: Hue): JSX.Element => {\n return (\n <ColorBlock key={hue[0]} hex={hue[1]}>\n <p>{hue[0]}</p>\n <p>{hue[1]}</p>\n </ColorBlock>\n );\n }\n )}\n </>\n );\n};\nexport default ColorPalette;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,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ding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
6
17
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
31
|
+
const react_animate_height_1 = __importDefault(require("react-animate-height"));
|
|
32
|
+
const ChevronUp_1 = require("@styled-icons/bootstrap/ChevronUp");
|
|
33
|
+
const Bell_1 = require("@styled-icons/bootstrap/Bell");
|
|
34
|
+
const react_intl_1 = require("react-intl");
|
|
35
|
+
const blue_1 = __importDefault(require("../colors/blue"));
|
|
36
|
+
const AlertContainer = styled_components_1.default.div `
|
|
37
|
+
background-color: ${props => props.backgroundColor ? props.backgroundColor : blue_1.default[50]};
|
|
38
|
+
display: grid;
|
|
39
|
+
grid-template-columns: 50px auto auto;
|
|
40
|
+
grid-template-rows: minmax(25px, auto) auto;
|
|
41
|
+
max-width: 715px;
|
|
42
|
+
padding: 1.5em 2em;
|
|
43
|
+
|
|
44
|
+
svg {
|
|
45
|
+
align-self: center;
|
|
46
|
+
grid-column: 1;
|
|
47
|
+
grid-row: 1 / span 2;
|
|
48
|
+
justify-self: start;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
button {
|
|
52
|
+
background: transparent;
|
|
53
|
+
border: none;
|
|
54
|
+
width: 40px;
|
|
55
|
+
|
|
56
|
+
svg {
|
|
57
|
+
transform: ${props => !props.expandAlert && "rotate(180deg)"};
|
|
58
|
+
transition: all 0.2s ease-in;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@media (max-width: 550px) {
|
|
63
|
+
grid-template-columns: 40px auto auto;
|
|
64
|
+
padding: 1.25em 1.25em;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
const ButtonContainer = styled_components_1.default.span `
|
|
68
|
+
align-items: center;
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
justify-self: right;
|
|
72
|
+
`;
|
|
73
|
+
const AlertHeader = styled_components_1.default.span `
|
|
74
|
+
align-self: center;
|
|
75
|
+
font-weight: 700;
|
|
76
|
+
grid-column: 2;
|
|
77
|
+
`;
|
|
78
|
+
const AlertSubheader = (0, styled_components_1.default)(AlertHeader) `
|
|
79
|
+
font-weight: 400;
|
|
80
|
+
margin-top: 0.3em;
|
|
81
|
+
`;
|
|
82
|
+
const AlertContent = styled_components_1.default.div `
|
|
83
|
+
grid-column: 2;
|
|
84
|
+
grid-row: 3;
|
|
85
|
+
`;
|
|
86
|
+
const ContentPadding = styled_components_1.default.div `
|
|
87
|
+
margin-top: ${props => (props.collapsible ? "1em" : ".5em")};
|
|
88
|
+
`;
|
|
89
|
+
const Alert = ({ alertHeader, alertSubheader, backgroundColor, children, collapsible, Icon = Bell_1.Bell }) => {
|
|
90
|
+
const [expandAlert, setExpandAlert] = (0, react_1.useState)(false);
|
|
91
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
92
|
+
const label = intl.formatMessage({
|
|
93
|
+
id: "otpUi.buildingBlocks.alert.expand",
|
|
94
|
+
defaultMessage: "Expand"
|
|
95
|
+
});
|
|
96
|
+
return (react_1.default.createElement(AlertContainer, { backgroundColor: backgroundColor, expandAlert: expandAlert, collapsible: collapsible },
|
|
97
|
+
react_1.default.createElement(Icon, { size: 24 }),
|
|
98
|
+
react_1.default.createElement(AlertHeader, null, alertHeader),
|
|
99
|
+
react_1.default.createElement(ButtonContainer, null, collapsible && (react_1.default.createElement("button", { type: "button", onClick: () => setExpandAlert(!expandAlert), "aria-label": label, title: label },
|
|
100
|
+
react_1.default.createElement(ChevronUp_1.ChevronUp, { size: 16 })))),
|
|
101
|
+
alertSubheader && react_1.default.createElement(AlertSubheader, null, alertSubheader),
|
|
102
|
+
children && (react_1.default.createElement(AlertContent, null,
|
|
103
|
+
react_1.default.createElement(react_animate_height_1.default, { duration: 500, height: collapsible ? (expandAlert ? "auto" : 0) : "auto" },
|
|
104
|
+
react_1.default.createElement(ContentPadding, { collapsible: collapsible }, children))))));
|
|
74
105
|
};
|
|
75
|
-
|
|
106
|
+
exports.default = Alert;
|
|
76
107
|
//# sourceMappingURL=Alert.js.map
|
package/lib/alert/Alert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/alert/Alert.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,0EAAuC;AACvC,gFAAiD;AACjD,iEAA8D;AAC9D,uDAAoD;AAEpD,2CAAqC;AACrC,0DAAkC;AAWlC,MAAM,cAAc,GAAG,2BAAM,CAAC,GAAG,CAI/B;sBACoB,KAAK,CAAC,EAAE,CAC1B,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,cAAI,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;mBAoBzC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,gBAAgB;;;;;;;;;CASjE,CAAC;AAEF,MAAM,eAAe,GAAG,2BAAM,CAAC,IAAI,CAAA;;;;;CAKlC,CAAC;AAEF,MAAM,WAAW,GAAG,2BAAM,CAAC,IAAI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X,8BAAC,8BAAa,IACZ,QAAQ,EAAE,GAAG,EACb,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;gBAEzD,8BAAC,cAAc,IAAC,WAAW,EAAE,WAAW,IACrC,QAAQ,CACM,CACH,CACH,CAChB,CACc,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC"}
|
package/lib/colors/blue.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
const blue = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
50: "#E5ECF3",
|
|
5
|
+
100: "#CCDAE7",
|
|
6
|
+
200: "#B2C7DB",
|
|
7
|
+
300: "#99B5CF",
|
|
8
|
+
400: "#7FA2C2",
|
|
9
|
+
500: "#6690B7",
|
|
10
|
+
600: "#4D7EAB",
|
|
11
|
+
// 700 and above text is WCAG AA accessible on white backgrounds.
|
|
12
|
+
700: "#336B9E",
|
|
13
|
+
// 800 and above text is WCAG AAA accessible on white backgrounds.
|
|
14
|
+
800: "#1A5992",
|
|
15
|
+
900: "#004686"
|
|
20
16
|
};
|
|
21
|
-
|
|
17
|
+
exports.default = blue;
|
|
22
18
|
//# sourceMappingURL=blue.js.map
|
package/lib/colors/blue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blue.js","
|
|
1
|
+
{"version":3,"file":"blue.js","sourceRoot":"","sources":["../../src/colors/blue.ts"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG;IACX,EAAE,EAAE,SAAS;IACb,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,iEAAiE;IACjE,GAAG,EAAE,SAAS;IACd,kEAAkE;IAClE,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;CACf,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
package/lib/colors/grey.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
const grey = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
50: "#ECECEC",
|
|
5
|
+
100: "#D9D9D9",
|
|
6
|
+
200: "#C5C5C5",
|
|
7
|
+
300: "#B3B3B3",
|
|
8
|
+
400: "#9F9F9F",
|
|
9
|
+
500: "#8C8C8C",
|
|
10
|
+
600: "#797979",
|
|
11
|
+
// 700 and above text is WCAG AA accessible on white backgrounds.
|
|
12
|
+
700: "#666666",
|
|
13
|
+
// 800 and above text is WCAG AAA accessible on white backgrounds.
|
|
14
|
+
800: "#535353",
|
|
15
|
+
900: "#404040"
|
|
20
16
|
};
|
|
21
|
-
|
|
17
|
+
exports.default = grey;
|
|
22
18
|
//# sourceMappingURL=grey.js.map
|
package/lib/colors/grey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grey.js","
|
|
1
|
+
{"version":3,"file":"grey.js","sourceRoot":"","sources":["../../src/colors/grey.ts"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG;IACX,EAAE,EAAE,SAAS;IACb,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,iEAAiE;IACjE,GAAG,EAAE,SAAS;IACd,kEAAkE;IAClE,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;CACf,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
package/lib/colors/red.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
const red = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
50: "#F7E7E6",
|
|
5
|
+
100: "#EFCFCE",
|
|
6
|
+
200: "#E7B6B4",
|
|
7
|
+
300: "#DF9E9C",
|
|
8
|
+
400: "#D78683",
|
|
9
|
+
500: "#CF6E6B",
|
|
10
|
+
600: "#C75652",
|
|
11
|
+
// 700 and above text is WCAG AA accessible on white backgrounds.
|
|
12
|
+
700: "#BF3E3A",
|
|
13
|
+
800: "#B72620",
|
|
14
|
+
// 900 text is WCAG AAA accessible on white backgrounds.
|
|
15
|
+
900: "#AF0E08"
|
|
20
16
|
};
|
|
21
|
-
|
|
17
|
+
exports.default = red;
|
|
22
18
|
//# sourceMappingURL=red.js.map
|
package/lib/colors/red.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"red.js","
|
|
1
|
+
{"version":3,"file":"red.js","sourceRoot":"","sources":["../../src/colors/red.ts"],"names":[],"mappings":";;AAAA,MAAM,GAAG,GAAG;IACV,EAAE,EAAE,SAAS;IACb,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,iEAAiE;IACjE,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,wDAAwD;IACxD,GAAG,EAAE,SAAS;CACf,CAAC;AAEF,kBAAe,GAAG,CAAC"}
|
package/lib/dropdown/index.js
CHANGED
|
@@ -1,112 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const dom_query_1 = require("../focus-trap-wrapper/dom-query");
|
|
28
|
+
const styled_1 = require("./styled");
|
|
12
29
|
/**
|
|
13
30
|
* Renders a dropdown menu. By default, only a passed "text" is rendered. If clicked,
|
|
14
31
|
* a floating div is rendered below the "text" with list contents inside. Clicking anywhere
|
|
15
32
|
* outside the floating div will close the dropdown.
|
|
16
33
|
*/
|
|
17
|
-
const Dropdown = ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
case " ":
|
|
69
|
-
case "Enter":
|
|
70
|
-
e.preventDefault();
|
|
71
|
-
element.click();
|
|
72
|
-
if (element.id === `${id}-label` || element.id === `${id}-wrapper`) {
|
|
73
|
-
toggleOpen();
|
|
34
|
+
const Dropdown = ({ alignMenuLeft, children, className, id, label, listLabel, text, buttonStyle }) => {
|
|
35
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
36
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
37
|
+
const toggleOpen = (0, react_1.useCallback)(() => setOpen(!open), [open, setOpen]);
|
|
38
|
+
// Argument for document.querySelectorAll to target focusable elements.
|
|
39
|
+
const queryId = `#${id} button, #${id}-label`;
|
|
40
|
+
const isList = Array.isArray(children)
|
|
41
|
+
? children.every(child => react_1.default.isValidElement(child) && child.type === "li")
|
|
42
|
+
: react_1.default.isValidElement(children) && children.type === "li";
|
|
43
|
+
// Adding document event listeners allows us to close the dropdown
|
|
44
|
+
// when the user interacts with any part of the page that isn't the dropdown
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
const handleExternalAction = (e) => {
|
|
47
|
+
var _a;
|
|
48
|
+
if (!((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
49
|
+
setOpen(false);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
document.addEventListener("mousedown", handleExternalAction);
|
|
53
|
+
document.addEventListener("focusin", handleExternalAction);
|
|
54
|
+
document.addEventListener("keydown", handleExternalAction);
|
|
55
|
+
return () => {
|
|
56
|
+
document.removeEventListener("mousedown", handleExternalAction);
|
|
57
|
+
document.removeEventListener("focusin", handleExternalAction);
|
|
58
|
+
document.removeEventListener("keydown", handleExternalAction);
|
|
59
|
+
};
|
|
60
|
+
}, [containerRef]);
|
|
61
|
+
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const element = e.target;
|
|
64
|
+
switch (e.key) {
|
|
65
|
+
case "ArrowUp":
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
(_a = (0, dom_query_1.getPreviousSibling)(queryId, element)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
68
|
+
break;
|
|
69
|
+
case "ArrowDown":
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
(_b = (0, dom_query_1.getNextSibling)(queryId, element)) === null || _b === void 0 ? void 0 : _b.focus();
|
|
72
|
+
break;
|
|
73
|
+
case "Escape":
|
|
74
|
+
setOpen(false);
|
|
75
|
+
break;
|
|
76
|
+
case " ":
|
|
77
|
+
case "Enter":
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
element.click();
|
|
80
|
+
if (element.id === `${id}-label` || element.id === `${id}-wrapper`) {
|
|
81
|
+
toggleOpen();
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
74
85
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, /*#__PURE__*/_react.default.createElement(_styled.DropdownButton
|
|
85
|
-
// Only set aria-controls when the dropdown is open
|
|
86
|
-
// (otherwise, assistive technologies may not announce the dropdown correctly).
|
|
87
|
-
, {
|
|
88
|
-
"aria-controls": open ? id : undefined,
|
|
89
|
-
"aria-expanded": open,
|
|
90
|
-
"aria-haspopup": "listbox",
|
|
91
|
-
"aria-label": label,
|
|
92
|
-
id: `${id}-label`,
|
|
93
|
-
onClick: toggleOpen,
|
|
94
|
-
style: buttonStyle,
|
|
95
|
-
title: label,
|
|
96
|
-
type: "button"
|
|
97
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, text), /*#__PURE__*/_react.default.createElement("span", {
|
|
98
|
-
className: "caret",
|
|
99
|
-
role: "presentation"
|
|
100
|
-
})), open && /*#__PURE__*/_react.default.createElement(_styled.DropdownMenu, {
|
|
101
|
-
as: isList && "ul",
|
|
102
|
-
"aria-label": listLabel,
|
|
103
|
-
"aria-labelledby": listLabel ? undefined : `${id}-label`,
|
|
104
|
-
id: id,
|
|
105
|
-
onClick: toggleOpen,
|
|
106
|
-
alignLeft: alignMenuLeft,
|
|
107
|
-
role: isList && "listbox",
|
|
108
|
-
tabIndex: -1
|
|
109
|
-
}, children));
|
|
86
|
+
}, [id, toggleOpen]);
|
|
87
|
+
return (react_1.default.createElement(styled_1.DropdownWrapper, { className: className, id: `${id}-wrapper`, onKeyDown: handleKeyDown, ref: containerRef },
|
|
88
|
+
react_1.default.createElement(styled_1.DropdownButton
|
|
89
|
+
// Only set aria-controls when the dropdown is open
|
|
90
|
+
// (otherwise, assistive technologies may not announce the dropdown correctly).
|
|
91
|
+
, { "aria-controls": open ? id : undefined, "aria-expanded": open, "aria-haspopup": "listbox", "aria-label": label, id: `${id}-label`, onClick: toggleOpen, style: buttonStyle, title: label, type: "button" },
|
|
92
|
+
react_1.default.createElement("span", null, text),
|
|
93
|
+
react_1.default.createElement("span", { className: "caret", role: "presentation" })),
|
|
94
|
+
open && (react_1.default.createElement(styled_1.DropdownMenu, { as: isList && "ul", "aria-label": listLabel, "aria-labelledby": listLabel ? undefined : `${id}-label`, id: id, onClick: toggleOpen, alignLeft: alignMenuLeft, role: isList && "listbox", tabIndex: -1 }, children))));
|
|
110
95
|
};
|
|
111
|
-
|
|
96
|
+
exports.default = Dropdown;
|
|
112
97
|
//# sourceMappingURL=index.js.map
|