@opentripplanner/building-blocks 3.0.2-alpha.1 → 3.1.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.
Files changed (42) hide show
  1. package/README.md +0 -4
  2. package/esm/alert/Alert.js +2 -1
  3. package/esm/alert/Alert.js.map +1 -1
  4. package/esm/index.js +2 -1
  5. package/esm/index.js.map +1 -1
  6. package/lib/alert/Alert.d.ts +3 -4
  7. package/lib/alert/Alert.d.ts.map +1 -1
  8. package/lib/alert/Alert.js +72 -103
  9. package/lib/alert/Alert.js.map +1 -1
  10. package/lib/colors/blue.js +18 -14
  11. package/lib/colors/blue.js.map +1 -1
  12. package/lib/colors/grey.js +18 -14
  13. package/lib/colors/grey.js.map +1 -1
  14. package/lib/colors/red.js +18 -14
  15. package/lib/colors/red.js.map +1 -1
  16. package/lib/dropdown/index.d.ts.map +1 -1
  17. package/lib/dropdown/index.js +101 -87
  18. package/lib/dropdown/index.js.map +1 -1
  19. package/lib/dropdown/styled.js +19 -72
  20. package/lib/dropdown/styled.js.map +1 -1
  21. package/lib/focus-trap-wrapper/dom-query.js +36 -20
  22. package/lib/focus-trap-wrapper/dom-query.js.map +1 -1
  23. package/lib/focus-trap-wrapper/index.d.ts.map +1 -1
  24. package/lib/focus-trap-wrapper/index.js +50 -52
  25. package/lib/focus-trap-wrapper/index.js.map +1 -1
  26. package/lib/index.d.ts +2 -1
  27. package/lib/index.d.ts.map +1 -1
  28. package/lib/index.js +47 -36
  29. package/lib/index.js.map +1 -1
  30. package/lib/stories/ColorPalette.d.ts +0 -1
  31. package/lib/stories/ColorPalette.d.ts.map +1 -1
  32. package/lib/stories/ColorPalette.js +26 -37
  33. package/lib/stories/ColorPalette.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/alert/Alert.tsx +11 -8
  36. package/src/index.ts +8 -1
  37. package/src/stories/__snapshots__/alerts.story.tsx.snap +88 -83
  38. package/src/stories/__snapshots__/dropdown.story.tsx.snap +1 -1
  39. package/src/stories/__snapshots__/focusTrapStory.story.tsx.snap +1 -1
  40. package/src/stories/__snapshots__/index.story.tsx.snap +1 -1
  41. package/src/stories/alerts.story.tsx +23 -14
  42. package/tsconfig.tsbuildinfo +1 -1
@@ -1,97 +1,111 @@
1
1
  "use strict";
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;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
17
5
  });
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");
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _domQuery = require("../focus-trap-wrapper/dom-query");
9
+ var _styled = require("./styled");
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
29
11
  /**
30
12
  * Renders a dropdown menu. By default, only a passed "text" is rendered. If clicked,
31
13
  * a floating div is rendered below the "text" with list contents inside. Clicking anywhere
32
14
  * outside the floating div will close the dropdown.
33
15
  */
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:
16
+ const Dropdown = ({
17
+ alignMenuLeft,
18
+ children,
19
+ className,
20
+ id,
21
+ label,
22
+ listLabel,
23
+ text,
24
+ buttonStyle
25
+ }) => {
26
+ const [open, setOpen] = (0, _react.useState)(false);
27
+ const containerRef = (0, _react.useRef)(null);
28
+ const toggleOpen = (0, _react.useCallback)(() => setOpen(!open), [open, setOpen]);
29
+
30
+ // Argument for document.querySelectorAll to target focusable elements.
31
+ const queryId = `#${id} button, #${id}-label`;
32
+ const isList = Array.isArray(children) ? children.every(child => /*#__PURE__*/_react.default.isValidElement(child) && child.type === "li") : /*#__PURE__*/_react.default.isValidElement(children) && children.type === "li";
33
+
34
+ // Adding document event listeners allows us to close the dropdown
35
+ // when the user interacts with any part of the page that isn't the dropdown
36
+ (0, _react.useEffect)(() => {
37
+ const handleExternalAction = e => {
38
+ var _containerRef$current;
39
+ if (!(containerRef !== null && containerRef !== void 0 && (_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(e.target))) {
40
+ setOpen(false);
41
+ }
42
+ };
43
+ document.addEventListener("mousedown", handleExternalAction);
44
+ document.addEventListener("focusin", handleExternalAction);
45
+ document.addEventListener("keydown", handleExternalAction);
46
+ return () => {
47
+ document.removeEventListener("mousedown", handleExternalAction);
48
+ document.removeEventListener("focusin", handleExternalAction);
49
+ document.removeEventListener("keydown", handleExternalAction);
50
+ };
51
+ }, [containerRef]);
52
+ const handleKeyDown = (0, _react.useCallback)(e => {
53
+ var _getPreviousSibling, _getNextSibling;
54
+ const element = e.target;
55
+ switch (e.key) {
56
+ case "ArrowUp":
57
+ e.preventDefault();
58
+ (_getPreviousSibling = (0, _domQuery.getPreviousSibling)(queryId, element)) === null || _getPreviousSibling === void 0 || _getPreviousSibling.focus();
59
+ break;
60
+ case "ArrowDown":
61
+ e.preventDefault();
62
+ (_getNextSibling = (0, _domQuery.getNextSibling)(queryId, element)) === null || _getNextSibling === void 0 || _getNextSibling.focus();
63
+ break;
64
+ case "Escape":
65
+ setOpen(false);
66
+ break;
67
+ case " ":
68
+ case "Enter":
69
+ e.preventDefault();
70
+ element.click();
71
+ if (element.id === `${id}-label` || element.id === `${id}-wrapper`) {
72
+ toggleOpen();
85
73
  }
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))));
74
+ break;
75
+ default:
76
+ }
77
+ }, [id, toggleOpen]);
78
+ return /*#__PURE__*/_react.default.createElement(_styled.DropdownWrapper, {
79
+ className: className,
80
+ id: `${id}-wrapper`,
81
+ onKeyDown: handleKeyDown,
82
+ ref: containerRef
83
+ }, /*#__PURE__*/_react.default.createElement(_styled.DropdownButton
84
+ // Only set aria-controls when the dropdown is open
85
+ // (otherwise, assistive technologies may not announce the dropdown correctly).
86
+ , {
87
+ "aria-controls": open ? id : undefined,
88
+ "aria-expanded": open,
89
+ "aria-haspopup": "listbox",
90
+ "aria-label": label,
91
+ id: `${id}-label`,
92
+ onClick: toggleOpen,
93
+ style: buttonStyle,
94
+ title: label,
95
+ type: "button"
96
+ }, /*#__PURE__*/_react.default.createElement("span", null, text), /*#__PURE__*/_react.default.createElement("span", {
97
+ className: "caret",
98
+ role: "presentation"
99
+ })), open && /*#__PURE__*/_react.default.createElement(_styled.DropdownMenu, {
100
+ as: isList && "ul",
101
+ "aria-label": listLabel,
102
+ "aria-labelledby": listLabel ? undefined : `${id}-label`,
103
+ id: id,
104
+ onClick: toggleOpen,
105
+ alignLeft: alignMenuLeft,
106
+ role: isList && "listbox",
107
+ tabIndex: -1
108
+ }, children));
95
109
  };
96
- exports.default = Dropdown;
110
+ var _default = exports.default = Dropdown;
97
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dropdown/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AAEf,+DAGyC;AACzC,qCAAyE;AAWzE;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,EAChB,aAAa,EACb,QAAQ,EACR,SAAS,EACT,EAAE,EACF,KAAK,EACL,SAAS,EACT,IAAI,EACJ,WAAW,EACL,EAAe,EAAE;IACvB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAExC,MAAM,YAAY,GAAG,IAAA,cAAM,EAAkB,IAAI,CAAC,CAAC;IAEnD,MAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtE,uEAAuE;IACvE,MAAM,OAAO,GAAG,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC;IAE9C,MAAM,MAAM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Ac,GAAG,CAC/B;QAChB,IAAI,IAAI,CACP,8BAAC,qBAAY,IACX,EAAE,EAAE,MAAM,IAAI,IAAI,gBACN,SAAS,qBACJ,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,EACtD,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,MAAM,IAAI,SAAS,EACzB,QAAQ,EAAE,CAAC,CAAC,IAEX,QAAQ,CACI,CAChB,CACe,CACnB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_domQuery","_styled","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Dropdown","alignMenuLeft","children","className","id","label","listLabel","text","buttonStyle","open","setOpen","useState","containerRef","useRef","toggleOpen","useCallback","queryId","isList","Array","isArray","every","child","React","isValidElement","type","useEffect","handleExternalAction","_containerRef$current","current","contains","target","document","addEventListener","removeEventListener","handleKeyDown","_getPreviousSibling","_getNextSibling","element","key","preventDefault","getPreviousSibling","focus","getNextSibling","click","createElement","DropdownWrapper","onKeyDown","ref","DropdownButton","undefined","onClick","style","title","role","DropdownMenu","as","alignLeft","tabIndex","_default","exports"],"sources":["../../src/dropdown/index.tsx"],"sourcesContent":["import React, {\n HTMLAttributes,\n KeyboardEvent,\n useCallback,\n useEffect,\n useRef,\n useState\n} from \"react\";\n\nimport {\n getNextSibling,\n getPreviousSibling\n} from \"../focus-trap-wrapper/dom-query\";\nimport { DropdownButton, DropdownMenu, DropdownWrapper } from \"./styled\";\n\nexport interface Props extends HTMLAttributes<HTMLElement> {\n alignMenuLeft?: boolean;\n buttonStyle?: React.CSSProperties;\n label?: string;\n listLabel?: string;\n text?: JSX.Element | string;\n nav?: boolean;\n}\n\n/**\n * Renders a dropdown menu. By default, only a passed \"text\" is rendered. If clicked,\n * a floating div is rendered below the \"text\" with list contents inside. Clicking anywhere\n * outside the floating div will close the dropdown.\n */\nconst Dropdown = ({\n alignMenuLeft,\n children,\n className,\n id,\n label,\n listLabel,\n text,\n buttonStyle\n}: Props): JSX.Element => {\n const [open, setOpen] = useState(false);\n\n const containerRef = useRef<HTMLSpanElement>(null);\n\n const toggleOpen = useCallback(() => setOpen(!open), [open, setOpen]);\n\n // Argument for document.querySelectorAll to target focusable elements.\n const queryId = `#${id} button, #${id}-label`;\n\n const isList = Array.isArray(children)\n ? children.every(\n child => React.isValidElement(child) && child.type === \"li\"\n )\n : React.isValidElement(children) && children.type === \"li\";\n\n // Adding document event listeners allows us to close the dropdown\n // when the user interacts with any part of the page that isn't the dropdown\n useEffect(() => {\n const handleExternalAction = (e: Event): void => {\n if (!containerRef?.current?.contains(e.target as HTMLElement)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", handleExternalAction);\n document.addEventListener(\"focusin\", handleExternalAction);\n document.addEventListener(\"keydown\", handleExternalAction);\n return () => {\n document.removeEventListener(\"mousedown\", handleExternalAction);\n document.removeEventListener(\"focusin\", handleExternalAction);\n document.removeEventListener(\"keydown\", handleExternalAction);\n };\n }, [containerRef]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent): void => {\n const element = e.target as HTMLElement;\n switch (e.key) {\n case \"ArrowUp\":\n e.preventDefault();\n getPreviousSibling(queryId, element)?.focus();\n break;\n case \"ArrowDown\":\n e.preventDefault();\n getNextSibling(queryId, element)?.focus();\n break;\n case \"Escape\":\n setOpen(false);\n break;\n case \" \":\n case \"Enter\":\n e.preventDefault();\n element.click();\n if (element.id === `${id}-label` || element.id === `${id}-wrapper`) {\n toggleOpen();\n }\n break;\n default:\n }\n },\n [id, toggleOpen]\n );\n\n return (\n <DropdownWrapper\n className={className}\n id={`${id}-wrapper`}\n onKeyDown={handleKeyDown}\n ref={containerRef}\n >\n <DropdownButton\n // Only set aria-controls when the dropdown is open\n // (otherwise, assistive technologies may not announce the dropdown correctly).\n aria-controls={open ? id : undefined}\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-label={label}\n id={`${id}-label`}\n onClick={toggleOpen}\n style={buttonStyle}\n title={label}\n type=\"button\"\n >\n <span>{text}</span>\n <span className=\"caret\" role=\"presentation\" />\n </DropdownButton>\n {open && (\n <DropdownMenu\n as={isList && \"ul\"}\n aria-label={listLabel}\n aria-labelledby={listLabel ? undefined : `${id}-label`}\n id={id}\n onClick={toggleOpen}\n alignLeft={alignMenuLeft}\n role={isList && \"listbox\"}\n tabIndex={-1}\n >\n {children}\n </DropdownMenu>\n )}\n </DropdownWrapper>\n );\n};\n\nexport default Dropdown;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AAIA,IAAAE,OAAA,GAAAF,OAAA;AAAyE,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAA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G,GAAG7C,EAAE,QAAS;IACvDA,EAAE,EAAEA,EAAG;IACP8C,OAAO,EAAEpC,UAAW;IACpB0C,SAAS,EAAEvD,aAAc;IACzBoD,IAAI,EAAEpC,MAAM,IAAI,SAAU;IAC1BwC,QAAQ,EAAE,CAAC;EAAE,GAEZvD,QACW,CAED,CAAC;AAEtB,CAAC;AAAC,IAAAwD,QAAA,GAAAC,OAAA,CAAApE,OAAA,GAEaS,QAAQ","ignoreList":[]}
@@ -1,75 +1,22 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DropdownWrapper = exports.DropdownMenu = exports.DropdownButton = void 0;
7
- const styled_components_1 = __importDefault(require("styled-components"));
8
- const grey_1 = __importDefault(require("../colors/grey"));
9
- exports.DropdownButton = styled_components_1.default.button `
10
- background: #fff;
11
- border: 1px solid black;
12
- border-radius: 5px;
13
- color: inherit;
14
- padding: 5px 7px;
15
- transition: all 0.1s ease-in-out;
16
-
17
- span.caret {
18
- border-left: 4px solid transparent;
19
- border-right: 4px solid transparent;
20
- border-top: 4px solid;
21
- color: inherit;
22
- display: inline-block;
23
- height: 0;
24
- margin-left: 5px;
25
- vertical-align: middle;
26
- width: 0;
27
- }
28
-
29
- &:hover,
30
- &[aria-expanded="true"] {
31
- background: ${grey_1.default[50]};
32
- color: black;
33
- cursor: pointer;
34
- }
35
- `;
36
- exports.DropdownMenu = styled_components_1.default.div `
37
- background-clip: padding-box;
38
- background-color: #fff;
39
- border-radius: 4px;
40
- border: 1px solid rgba(0, 0, 0, 0.15);
41
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
42
- color: #333;
43
- list-style: none;
44
- margin: 2px 0 0;
45
- min-width: 160px;
46
- padding: 5px 0;
47
- position: absolute;
48
- ${props => (props.alignLeft ? "left: 0;" : "right: 0;")}
49
- top: 100%;
50
- width: 100%;
51
- z-index: 1000;
52
2
 
53
- hr {
54
- margin: 0;
55
- padding: 0;
56
- }
57
- a,
58
- button {
59
- background: transparent;
60
- border: none;
61
- cursor: pointer;
62
- padding: 5px 15px;
63
- text-align: start;
64
- width: 100%;
65
-
66
- &:hover {
67
- background: ${grey_1.default[50]};
68
- }
69
- }
70
- `;
71
- exports.DropdownWrapper = styled_components_1.default.span `
72
- float: ${props => (props.pullRight ? "right" : "left")};
73
- position: relative;
74
- `;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DropdownWrapper = exports.DropdownMenu = exports.DropdownButton = void 0;
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+ var _grey = _interopRequireDefault(require("../colors/grey"));
10
+ const DropdownButton = exports.DropdownButton = _styledComponents.default.button.withConfig({
11
+ displayName: "styled__DropdownButton",
12
+ componentId: "sc-kes9ha-0"
13
+ })(["background:#fff;border:1px solid black;border-radius:5px;color:inherit;padding:5px 7px;transition:all 0.1s ease-in-out;span.caret{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid;color:inherit;display:inline-block;height:0;margin-left:5px;vertical-align:middle;width:0;}&:hover,&[aria-expanded=\"true\"]{background:", ";color:black;cursor:pointer;}"], _grey.default[50]);
14
+ const DropdownMenu = exports.DropdownMenu = _styledComponents.default.div.withConfig({
15
+ displayName: "styled__DropdownMenu",
16
+ componentId: "sc-kes9ha-1"
17
+ })(["background-clip:padding-box;background-color:#fff;border-radius:4px;border:1px solid rgba(0,0,0,0.15);box-shadow:0 6px 12px rgba(0,0,0,0.175);color:#333;list-style:none;margin:2px 0 0;min-width:160px;padding:5px 0;position:absolute;", " top:100%;width:100%;z-index:1000;hr{margin:0;padding:0;}a,button{background:transparent;border:none;cursor:pointer;padding:5px 15px;text-align:start;width:100%;&:hover{background:", ";}}"], props => props.alignLeft ? "left: 0;" : "right: 0;", _grey.default[50]);
18
+ const DropdownWrapper = exports.DropdownWrapper = _styledComponents.default.span.withConfig({
19
+ displayName: "styled__DropdownWrapper",
20
+ componentId: "sc-kes9ha-2"
21
+ })(["float:", ";position:relative;"], props => props.pullRight ? "right" : "left");
75
22
  //# sourceMappingURL=styled.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.js","sourceRoot":"","sources":["../../src/dropdown/styled.tsx"],"names":[],"mappings":";;;;;;AAAA,0EAAuC;AACvC,0DAAkC;AAErB,QAAA,cAAc,GAAG,2BAAM,CAAC,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;kBAsBzB,cAAI,CAAC,EAAE,CAAC;;;;CAIzB,CAAC;AAEW,QAAA,YAAY,GAAG,2BAAM,CAAC,GAAG,CAAyB;;;;;;;;;;;;IAY3D,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;oBAmBrC,cAAI,CAAC,EAAE,CAAC;;;CAG3B,CAAC;AAEW,QAAA,eAAe,GAAG,2BAAM,CAAC,IAAI,CAAyB;WACxD,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;;CAEvD,CAAC"}
1
+ {"version":3,"file":"styled.js","names":["_styledComponents","_interopRequireDefault","require","_grey","DropdownButton","exports","styled","button","withConfig","displayName","componentId","grey","DropdownMenu","div","props","alignLeft","DropdownWrapper","span","pullRight"],"sources":["../../src/dropdown/styled.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport grey from \"../colors/grey\";\n\nexport const DropdownButton = styled.button`\n background: #fff;\n border: 1px solid black;\n border-radius: 5px;\n color: inherit;\n padding: 5px 7px;\n transition: all 0.1s ease-in-out;\n\n span.caret {\n border-left: 4px solid transparent;\n border-right: 4px solid transparent;\n border-top: 4px solid;\n color: inherit;\n display: inline-block;\n height: 0;\n margin-left: 5px;\n vertical-align: middle;\n width: 0;\n }\n\n &:hover,\n &[aria-expanded=\"true\"] {\n background: ${grey[50]};\n color: black;\n cursor: pointer;\n }\n`;\n\nexport const DropdownMenu = styled.div<{ alignLeft?: boolean }>`\n background-clip: padding-box;\n background-color: #fff;\n border-radius: 4px;\n border: 1px solid rgba(0, 0, 0, 0.15);\n box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);\n color: #333;\n list-style: none;\n margin: 2px 0 0;\n min-width: 160px;\n padding: 5px 0;\n position: absolute;\n ${props => (props.alignLeft ? \"left: 0;\" : \"right: 0;\")}\n top: 100%;\n width: 100%;\n z-index: 1000;\n\n hr {\n margin: 0;\n padding: 0;\n }\n a,\n button {\n background: transparent;\n border: none;\n cursor: pointer;\n padding: 5px 15px;\n text-align: start;\n width: 100%;\n\n &:hover {\n background: ${grey[50]};\n }\n }\n`;\n\nexport const DropdownWrapper = styled.span<{ pullRight?: boolean }>`\n float: ${props => (props.pullRight ? \"right\" : \"left\")};\n position: relative;\n`;\n"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEO,MAAME,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,MAAM,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,8YAsBzBC,aAAI,CAAC,EAAE,CAAC,CAIzB;AAEM,MAAMC,YAAY,GAAAP,OAAA,CAAAO,YAAA,GAAGN,yBAAM,CAACO,GAAG,CAAAL,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gbAYlCI,KAAK,IAAKA,KAAK,CAACC,SAAS,GAAG,UAAU,GAAG,WAAY,EAmBrCJ,aAAI,CAAC,EAAE,CAAC,CAG3B;AAEM,MAAMK,eAAe,GAAAX,OAAA,CAAAW,eAAA,GAAGV,yBAAM,CAACW,IAAI,CAAAT,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,sCAC/BI,KAAK,IAAKA,KAAK,CAACI,SAAS,GAAG,OAAO,GAAG,MAAO,CAEvD","ignoreList":[]}
@@ -1,12 +1,21 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPreviousSibling = exports.getNextSibling = void 0;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNextSibling = getNextSibling;
7
+ exports.getPreviousSibling = getPreviousSibling;
4
8
  function getEntries(query) {
5
- const entries = Array.from(document.querySelectorAll(query));
6
- const firstElement = entries[0];
7
- const lastElement = entries[entries.length - 1];
8
- return { entries, firstElement, lastElement };
9
+ const entries = Array.from(document.querySelectorAll(query));
10
+ const firstElement = entries[0];
11
+ const lastElement = entries[entries.length - 1];
12
+ return {
13
+ entries,
14
+ firstElement,
15
+ lastElement
16
+ };
9
17
  }
18
+
10
19
  /**
11
20
  * Helper method to find the next focusable sibling element relative to the
12
21
  * specified element.
@@ -16,14 +25,18 @@ function getEntries(query) {
16
25
  * @returns {HTMLElement} - element to be focused
17
26
  */
18
27
  function getNextSibling(query, element) {
19
- const { entries, firstElement, lastElement } = getEntries(query);
20
- if (element === lastElement) {
21
- return firstElement;
22
- }
23
- const elementIndex = entries.indexOf(element);
24
- return entries[elementIndex + 1];
28
+ const {
29
+ entries,
30
+ firstElement,
31
+ lastElement
32
+ } = getEntries(query);
33
+ if (element === lastElement) {
34
+ return firstElement;
35
+ }
36
+ const elementIndex = entries.indexOf(element);
37
+ return entries[elementIndex + 1];
25
38
  }
26
- exports.getNextSibling = getNextSibling;
39
+
27
40
  /**
28
41
  * Helper method to find the previous focusable sibling element relative to the
29
42
  * specified element.
@@ -33,12 +46,15 @@ exports.getNextSibling = getNextSibling;
33
46
  * @returns {HTMLElement} - element to be focused
34
47
  */
35
48
  function getPreviousSibling(query, element) {
36
- const { entries, firstElement, lastElement } = getEntries(query);
37
- if (element === firstElement) {
38
- return lastElement;
39
- }
40
- const elementIndex = entries.indexOf(element);
41
- return entries[elementIndex - 1];
49
+ const {
50
+ entries,
51
+ firstElement,
52
+ lastElement
53
+ } = getEntries(query);
54
+ if (element === firstElement) {
55
+ return lastElement;
56
+ }
57
+ const elementIndex = entries.indexOf(element);
58
+ return entries[elementIndex - 1];
42
59
  }
43
- exports.getPreviousSibling = getPreviousSibling;
44
60
  //# sourceMappingURL=dom-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom-query.js","sourceRoot":"","sources":["../../src/focus-trap-wrapper/dom-query.ts"],"names":[],"mappings":";;;AAAA,SAAS,UAAU,CAAC,KAAa;IAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEhD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AAChD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC5B,KAAa,EACb,OAAoB;IAEpB,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAEjE,IAAI,OAAO,KAAK,WAAW,EAAE;QAC3B,OAAO,YAA2B,CAAC;KACpC;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,OAAsB,CAAC,CAAC;IAC7D,OAAO,OAAO,CAAC,YAAY,GAAG,CAAC,CAAgB,CAAC;AAClD,CAAC;AAXD,wCAWC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,KAAa,EACb,OAAoB;IAEpB,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAEjE,IAAI,OAAO,KAAK,YAAY,EAAE;QAC5B,OAAO,WAA0B,CAAC;KACnC;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,OAA4B,CAAC,CAAC;IACnE,OAAO,OAAO,CAAC,YAAY,GAAG,CAAC,CAAgB,CAAC;AAClD,CAAC;AAXD,gDAWC"}
1
+ {"version":3,"file":"dom-query.js","names":["getEntries","query","entries","Array","from","document","querySelectorAll","firstElement","lastElement","length","getNextSibling","element","elementIndex","indexOf","getPreviousSibling"],"sources":["../../src/focus-trap-wrapper/dom-query.ts"],"sourcesContent":["function getEntries(query: string) {\n const entries = Array.from(document.querySelectorAll(query));\n const firstElement = entries[0];\n const lastElement = entries[entries.length - 1];\n\n return { entries, firstElement, lastElement };\n}\n\n/**\n * Helper method to find the next focusable sibling element relative to the\n * specified element.\n *\n * @param {string} query - Argument that gets passed to document.querySelectorAll\n * @param {HTMLElement} element - Specified element (e.target)\n * @returns {HTMLElement} - element to be focused\n */\nexport function getNextSibling(\n query: string,\n element: EventTarget\n): HTMLElement {\n const { entries, firstElement, lastElement } = getEntries(query);\n\n if (element === lastElement) {\n return firstElement as HTMLElement;\n }\n const elementIndex = entries.indexOf(element as HTMLElement);\n return entries[elementIndex + 1] as HTMLElement;\n}\n\n/**\n * Helper method to find the previous focusable sibling element relative to the\n * specified element.\n *\n * @param {string} query - Argument that gets passed to document.querySelectorAll\n * @param {HTMLElement} element - Specified element (e.target)\n * @returns {HTMLElement} - element to be focused\n */\nexport function getPreviousSibling(\n query: string,\n element: EventTarget\n): HTMLElement {\n const { entries, firstElement, lastElement } = getEntries(query);\n\n if (element === firstElement) {\n return lastElement as HTMLElement;\n }\n const elementIndex = entries.indexOf(element as HTMLButtonElement);\n return entries[elementIndex - 1] as HTMLElement;\n}\n"],"mappings":";;;;;;;AAAA,SAASA,UAAUA,CAACC,KAAa,EAAE;EACjC,MAAMC,OAAO,GAAGC,KAAK,CAACC,IAAI,CAACC,QAAQ,CAACC,gBAAgB,CAACL,KAAK,CAAC,CAAC;EAC5D,MAAMM,YAAY,GAAGL,OAAO,CAAC,CAAC,CAAC;EAC/B,MAAMM,WAAW,GAAGN,OAAO,CAACA,OAAO,CAACO,MAAM,GAAG,CAAC,CAAC;EAE/C,OAAO;IAAEP,OAAO;IAAEK,YAAY;IAAEC;EAAY,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,cAAcA,CAC5BT,KAAa,EACbU,OAAoB,EACP;EACb,MAAM;IAAET,OAAO;IAAEK,YAAY;IAAEC;EAAY,CAAC,GAAGR,UAAU,CAACC,KAAK,CAAC;EAEhE,IAAIU,OAAO,KAAKH,WAAW,EAAE;IAC3B,OAAOD,YAAY;EACrB;EACA,MAAMK,YAAY,GAAGV,OAAO,CAACW,OAAO,CAACF,OAAsB,CAAC;EAC5D,OAAOT,OAAO,CAACU,YAAY,GAAG,CAAC,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,kBAAkBA,CAChCb,KAAa,EACbU,OAAoB,EACP;EACb,MAAM;IAAET,OAAO;IAAEK,YAAY;IAAEC;EAAY,CAAC,GAAGR,UAAU,CAACC,KAAK,CAAC;EAEhE,IAAIU,OAAO,KAAKJ,YAAY,EAAE;IAC5B,OAAOC,WAAW;EACpB;EACA,MAAMI,YAAY,GAAGV,OAAO,CAACW,OAAO,CAACF,OAA4B,CAAC;EAClE,OAAOT,OAAO,CAACU,YAAY,GAAG,CAAC,CAAC;AAClC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/focus-trap-wrapper/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjE,QAAA,MAAM,gBAAgB;cAMV,SAAS,GAAG,SAAS,EAAE;wBACb,OAAO,KAAK,IAAI;QAChC,MAAM;oBACM,MAAM,EAAE;MACtB,WA8BH,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;AAE9C,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/focus-trap-wrapper/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjE,QAAA,MAAM,gBAAgB,GAAI,6CAKvB;IACD,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAClC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,KAAG,GAAG,CAAC,OA8BP,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;AAE9C,eAAe,gBAAgB,CAAC"}
@@ -1,57 +1,55 @@
1
1
  "use strict";
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;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
17
5
  });
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
- exports.getPreviousSibling = exports.getNextSibling = void 0;
27
- const react_1 = __importStar(require("react"));
28
- const dom_query_1 = require("./dom-query");
29
- Object.defineProperty(exports, "getNextSibling", { enumerable: true, get: function () { return dom_query_1.getNextSibling; } });
30
- Object.defineProperty(exports, "getPreviousSibling", { enumerable: true, get: function () { return dom_query_1.getPreviousSibling; } });
31
- const FocusTrapWrapper = ({ children, closePopup = null, focusElements = ["button", "a", "input", "select"], id }) => {
32
- const queryId = focusElements
33
- .map(el => `#${id}-focus-trap ${el}:not([disabled])`)
34
- .join(", ");
35
- const handleKeyDown = (0, react_1.useCallback)(e => {
36
- var _a, _b;
37
- const element = e.target;
38
- switch (e.key) {
39
- case "Escape":
40
- closePopup();
41
- break;
42
- case "Tab":
43
- e.preventDefault();
44
- if (e.shiftKey) {
45
- (_a = (0, dom_query_1.getPreviousSibling)(queryId, element)) === null || _a === void 0 ? void 0 : _a.focus();
46
- }
47
- else {
48
- (_b = (0, dom_query_1.getNextSibling)(queryId, element)) === null || _b === void 0 ? void 0 : _b.focus();
49
- }
50
- break;
51
- default:
6
+ exports.default = void 0;
7
+ Object.defineProperty(exports, "getNextSibling", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _domQuery.getNextSibling;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "getPreviousSibling", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _domQuery.getPreviousSibling;
17
+ }
18
+ });
19
+ var _react = _interopRequireWildcard(require("react"));
20
+ var _domQuery = require("./dom-query");
21
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
22
+ const FocusTrapWrapper = ({
23
+ children,
24
+ closePopup = null,
25
+ focusElements = ["button", "a", "input", "select"],
26
+ id
27
+ }) => {
28
+ const queryId = focusElements.map(el => `#${id}-focus-trap ${el}:not([disabled])`).join(", ");
29
+ const handleKeyDown = (0, _react.useCallback)(e => {
30
+ const element = e.target;
31
+ switch (e.key) {
32
+ case "Escape":
33
+ closePopup();
34
+ break;
35
+ case "Tab":
36
+ e.preventDefault();
37
+ if (e.shiftKey) {
38
+ var _getPreviousSibling;
39
+ (_getPreviousSibling = (0, _domQuery.getPreviousSibling)(queryId, element)) === null || _getPreviousSibling === void 0 || _getPreviousSibling.focus();
40
+ } else {
41
+ var _getNextSibling;
42
+ (_getNextSibling = (0, _domQuery.getNextSibling)(queryId, element)) === null || _getNextSibling === void 0 || _getNextSibling.focus();
52
43
  }
53
- }, [closePopup]);
54
- return (react_1.default.createElement("div", { id: `${id}-focus-trap`, onKeyDown: handleKeyDown, role: "presentation" }, children));
44
+ break;
45
+ default:
46
+ }
47
+ }, [closePopup]);
48
+ return /*#__PURE__*/_react.default.createElement("div", {
49
+ id: `${id}-focus-trap`,
50
+ onKeyDown: handleKeyDown,
51
+ role: "presentation"
52
+ }, children);
55
53
  };
56
- exports.default = FocusTrapWrapper;
54
+ var _default = exports.default = FocusTrapWrapper;
57
55
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/focus-trap-wrapper/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,2CAAiE;AA4CxD,+FA5CA,0BAAc,OA4CA;AAAE,mGA5CA,8BAAkB,OA4CA;AA1C3C,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,IAAI,EACjB,aAAa,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,EAClD,EAAE,EAMH,EAAe,EAAE;IAChB,MAAM,OAAO,GAAG,aAAa;SAC1B,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,kBAAkB,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,CAAC,CAAC,EAAE;;QACF,MAAM,OAAO,GAAG,CAAC,CAAC,MAAqB,CAAC;QACxC,QAAQ,CAAC,CAAC,GAAG,EAAE;YACb,KAAK,QAAQ;gBACX,UAAU,EAAE,CAAC;gBACb,MAAM;YACR,KAAK,KAAK;gBACR,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,CAAC,QAAQ,EAAE;oBACd,MAAA,IAAA,8BAAkB,EAAC,OAAO,EAAE,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAC;iBAC/C;qBAAM;oBACL,MAAA,IAAA,0BAAc,EAAC,OAAO,EAAE,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAC;iBAC3C;gBACD,MAAM;YACR,QAAQ;SACT;IACH,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,OAAO,CACL,uCAAK,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAC,cAAc,IACvE,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CAAC;AAIF,kBAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_domQuery","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FocusTrapWrapper","children","closePopup","focusElements","id","queryId","map","el","join","handleKeyDown","useCallback","element","target","key","preventDefault","shiftKey","_getPreviousSibling","getPreviousSibling","focus","_getNextSibling","getNextSibling","createElement","onKeyDown","role","_default","exports"],"sources":["../../src/focus-trap-wrapper/index.tsx"],"sourcesContent":["import React, { ReactNode, useCallback } from \"react\";\nimport { getNextSibling, getPreviousSibling } from \"./dom-query\";\n\nconst FocusTrapWrapper = ({\n children,\n closePopup = null,\n focusElements = [\"button\", \"a\", \"input\", \"select\"],\n id\n}: {\n children: ReactNode | ReactNode[];\n closePopup?: (arg?: boolean) => void;\n id: string;\n focusElements?: string[];\n}): JSX.Element => {\n const queryId = focusElements\n .map(el => `#${id}-focus-trap ${el}:not([disabled])`)\n .join(\", \");\n const handleKeyDown = useCallback(\n e => {\n const element = e.target as HTMLElement;\n switch (e.key) {\n case \"Escape\":\n closePopup();\n break;\n case \"Tab\":\n e.preventDefault();\n if (e.shiftKey) {\n getPreviousSibling(queryId, element)?.focus();\n } else {\n getNextSibling(queryId, element)?.focus();\n }\n break;\n default:\n }\n },\n [closePopup]\n );\n\n return (\n <div id={`${id}-focus-trap`} onKeyDown={handleKeyDown} role=\"presentation\">\n {children}\n </div>\n );\n};\n\nexport { getNextSibling, getPreviousSibling };\n\nexport default FocusTrapWrapper;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAAiE,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAA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,CAAC,CAACkC,QAAQ,EAAE;UAAA,IAAAC,mBAAA;UACd,CAAAA,mBAAA,OAAAC,4BAAkB,EAACZ,OAAO,EAAEM,OAAO,CAAC,cAAAK,mBAAA,eAApCA,mBAAA,CAAsCE,KAAK,CAAC,CAAC;QAC/C,CAAC,MAAM;UAAA,IAAAC,eAAA;UACL,CAAAA,eAAA,OAAAC,wBAAc,EAACf,OAAO,EAAEM,OAAO,CAAC,cAAAQ,eAAA,eAAhCA,eAAA,CAAkCD,KAAK,CAAC,CAAC;QAC3C;QACA;MACF;IACF;EACF,CAAC,EACD,CAAChB,UAAU,CACb,CAAC;EAED,oBACEzB,MAAA,CAAAc,OAAA,CAAA8B,aAAA;IAAKjB,EAAE,EAAE,GAAGA,EAAE,aAAc;IAACkB,SAAS,EAAEb,aAAc;IAACc,IAAI,EAAC;EAAc,GACvEtB,QACE,CAAC;AAEV,CAAC;AAAC,IAAAuB,QAAA,GAAAC,OAAA,CAAAlC,OAAA,GAIaS,gBAAgB","ignoreList":[]}
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import Dropdown from "./dropdown";
2
2
  import FocusTrapWrapper, { getNextSibling, getPreviousSibling } from "./focus-trap-wrapper";
3
- export { Dropdown, FocusTrapWrapper, getNextSibling, getPreviousSibling };
3
+ import Alert from "./alert/Alert";
4
+ export { Alert, Dropdown, FocusTrapWrapper, getNextSibling, getPreviousSibling };
4
5
  declare const _default: {
5
6
  blue: {
6
7
  50: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,gBAAgB,EAAE,EACvB,cAAc,EACd,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAC1E,wBAAmC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,gBAAgB,EAAE,EACvB,cAAc,EACd,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,MAAM,eAAe,CAAC;AAGlC,OAAO,EACL,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EACnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACF,wBAAmC"}