@opentripplanner/building-blocks 1.1.0 → 1.2.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 (40) hide show
  1. package/esm/dropdown/index.js +1 -1
  2. package/esm/dropdown/index.js.map +1 -1
  3. package/esm/focus-trap-wrapper/dom-query.js.map +1 -0
  4. package/esm/focus-trap-wrapper/index.js +48 -0
  5. package/esm/focus-trap-wrapper/index.js.map +1 -0
  6. package/lib/dropdown/index.d.ts.map +1 -1
  7. package/lib/dropdown/index.js +1 -1
  8. package/lib/dropdown/index.js.map +1 -1
  9. package/lib/focus-trap-wrapper/dom-query.d.ts.map +1 -0
  10. package/lib/focus-trap-wrapper/dom-query.js.map +1 -0
  11. package/lib/focus-trap-wrapper/index.d.ts +9 -0
  12. package/lib/focus-trap-wrapper/index.d.ts.map +1 -0
  13. package/lib/focus-trap-wrapper/index.js +58 -0
  14. package/lib/focus-trap-wrapper/index.js.map +1 -0
  15. package/lib/stories/ColorPalette.d.ts +1 -0
  16. package/lib/stories/ColorPalette.d.ts.map +1 -1
  17. package/package.json +4 -4
  18. package/src/dropdown/index.tsx +4 -1
  19. package/src/focus-trap-wrapper/index.tsx +46 -0
  20. package/src/stories/__snapshots__/dropdown.story.tsx.snap +91 -0
  21. package/src/stories/__snapshots__/focusTrapStory.story.tsx.snap +64 -0
  22. package/src/stories/__snapshots__/index.story.tsx.snap +250 -0
  23. package/src/stories/focusTrapStory.story.tsx +46 -0
  24. package/tsconfig.json +1 -2
  25. package/tsconfig.tsbuildinfo +1 -1
  26. package/esm/utils/dom-query.js.map +0 -1
  27. package/lib/stories/dropdown.story.d.ts +0 -9
  28. package/lib/stories/dropdown.story.d.ts.map +0 -1
  29. package/lib/stories/dropdown.story.js +0 -59
  30. package/lib/stories/dropdown.story.js.map +0 -1
  31. package/lib/stories/index.story.d.ts +0 -9
  32. package/lib/stories/index.story.d.ts.map +0 -1
  33. package/lib/stories/index.story.js +0 -29
  34. package/lib/stories/index.story.js.map +0 -1
  35. package/lib/utils/dom-query.d.ts.map +0 -1
  36. package/lib/utils/dom-query.js.map +0 -1
  37. /package/esm/{utils → focus-trap-wrapper}/dom-query.js +0 -0
  38. /package/lib/{utils → focus-trap-wrapper}/dom-query.d.ts +0 -0
  39. /package/lib/{utils → focus-trap-wrapper}/dom-query.js +0 -0
  40. /package/src/{utils → focus-trap-wrapper}/dom-query.ts +0 -0
@@ -1,59 +0,0 @@
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.DropdownAsOtprrNavItem = exports.DropdownWithListAlignMenuLeft = exports.DropdownWithList = exports.DropdownWithLabel = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const styled_components_1 = __importDefault(require("styled-components"));
9
- const dropdown_1 = __importDefault(require("../dropdown"));
10
- const blue_1 = __importDefault(require("../colors/blue"));
11
- const options = [
12
- { value: "1", label: "One" },
13
- { value: "2", label: "Two" },
14
- { value: "3", label: "Three" }
15
- ];
16
- const NavItemWrapper = styled_components_1.default.div `
17
- align-items: center;
18
- background: ${blue_1.default[900]};
19
- display: flex;
20
- min-height: 50px;
21
- padding: 0 10px;
22
- position: relative;
23
- width: 100%;
24
-
25
- .navBarItem {
26
- position: static;
27
- & > button {
28
- background: transparent;
29
- border: none;
30
- color: white;
31
- padding: 15px;
32
-
33
- @media (max-width: 768px) {
34
- padding: 10px;
35
- }
36
-
37
- &:hover {
38
- background: rgba(0, 0, 0, 0.05);
39
- color: #ececec;
40
- }
41
- }
42
- }
43
- `;
44
- exports.default = {
45
- title: "Building-Blocks/Dropdown",
46
- component: dropdown_1.default
47
- };
48
- const DropdownWithLabel = () => (react_1.default.createElement(dropdown_1.default, { id: "dropdown-with-label", label: "Dropdown with label", listLabel: "Dropdown menu", text: "Dropdown with label" }, "More content here"));
49
- exports.DropdownWithLabel = DropdownWithLabel;
50
- const DropdownWithList = () => (react_1.default.createElement(dropdown_1.default, { id: "dropdown-with-ul", label: "Dropdown with ul", listLabel: "Dropdown menu", text: "Dropdown with ul" }, options.map(option => (react_1.default.createElement("li", { key: option.value, value: option.value },
51
- react_1.default.createElement("button", { type: "button" }, option.label))))));
52
- exports.DropdownWithList = DropdownWithList;
53
- const DropdownWithListAlignMenuLeft = () => (react_1.default.createElement(dropdown_1.default, { alignMenuLeft: true, id: "dropdown-with-ul", label: "Dropdown with ul", listLabel: "Dropdown menu", text: "Dropdown with ul" }, options.map(option => (react_1.default.createElement("li", { key: option.value, value: option.value },
54
- react_1.default.createElement("button", { type: "button" }, option.label))))));
55
- exports.DropdownWithListAlignMenuLeft = DropdownWithListAlignMenuLeft;
56
- const DropdownAsOtprrNavItem = () => (react_1.default.createElement(NavItemWrapper, null,
57
- react_1.default.createElement(dropdown_1.default, { className: "navBarItem", id: "dropdown-navbar", label: "Dropdown navbar", listLabel: "Dropdown within navbar", text: "Icon" }, options.map(option => (react_1.default.createElement("button", { key: option.value, type: "button" }, option.label))))));
58
- exports.DropdownAsOtprrNavItem = DropdownAsOtprrNavItem;
59
- //# sourceMappingURL=dropdown.story.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dropdown.story.js","sourceRoot":"","sources":["../../src/stories/dropdown.story.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,0EAAuC;AACvC,2DAAmC;AACnC,0DAAkC;AAElC,MAAM,OAAO,GAAG;IACd,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;IAC5B,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;IAC5B,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;CAC/B,CAAC;AAEF,MAAM,cAAc,GAAG,2BAAM,CAAC,GAAG,CAAA;;gBAEjB,cAAI,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;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AC9D,8BAAC,cAAc;IACb,8BAAC,kBAAQ,IACP,SAAS,EAAC,YAAY,EACtB,EAAE,EAAC,iBAAiB,EACpB,KAAK,EAAC,iBAAiB,EACvB,SAAS,EAAC,wBAAwB,EAClC,IAAI,EAAC,MAAM,IAEV,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CACrB,0CAAQ,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAC,QAAQ,IACrC,MAAM,CAAC,KAAK,CACN,CACV,CAAC,CACO,CACI,CAClB,CAAC;AAhBW,QAAA,sBAAsB,0BAgBjC"}
@@ -1,9 +0,0 @@
1
- import { ReactElement } from "react";
2
- import { Meta } from "@storybook/react";
3
- import ColorPalette from "./ColorPalette";
4
- declare const meta: Meta<typeof ColorPalette>;
5
- export default meta;
6
- export declare const Grey: () => ReactElement;
7
- export declare const Blue: () => ReactElement;
8
- export declare const Red: () => ReactElement;
9
- //# sourceMappingURL=index.story.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAM1C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,YAAY,CAGnC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,IAAI,QAAO,YAEvB,CAAC;AAEF,eAAO,MAAM,IAAI,QAAO,YAEvB,CAAC;AAEF,eAAO,MAAM,GAAG,QAAO,YAEtB,CAAC"}
@@ -1,29 +0,0 @@
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.Red = exports.Blue = exports.Grey = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const ColorPalette_1 = __importDefault(require("./ColorPalette"));
9
- const grey_1 = __importDefault(require("../colors/grey"));
10
- const blue_1 = __importDefault(require("../colors/blue"));
11
- const red_1 = __importDefault(require("../colors/red"));
12
- const meta = {
13
- title: "Building-Blocks/Colors",
14
- component: ColorPalette_1.default
15
- };
16
- exports.default = meta;
17
- const Grey = () => {
18
- return react_1.default.createElement(ColorPalette_1.default, { color: grey_1.default });
19
- };
20
- exports.Grey = Grey;
21
- const Blue = () => {
22
- return react_1.default.createElement(ColorPalette_1.default, { color: blue_1.default });
23
- };
24
- exports.Blue = Blue;
25
- const Red = () => {
26
- return react_1.default.createElement(ColorPalette_1.default, { color: red_1.default });
27
- };
28
- exports.Red = Red;
29
- //# sourceMappingURL=index.story.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.story.js","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA4C;AAE5C,kEAA0C;AAE1C,0DAAkC;AAClC,0DAAkC;AAClC,wDAAgC;AAEhC,MAAM,IAAI,GAA8B;IACtC,KAAK,EAAE,wBAAwB;IAC/B,SAAS,EAAE,sBAAY;CACxB,CAAC;AAEF,kBAAe,IAAI,CAAC;AAEb,MAAM,IAAI,GAAG,GAAiB,EAAE;IACrC,OAAO,8BAAC,sBAAY,IAAC,KAAK,EAAE,cAAI,GAAI,CAAC;AACvC,CAAC,CAAC;AAFW,QAAA,IAAI,QAEf;AAEK,MAAM,IAAI,GAAG,GAAiB,EAAE;IACrC,OAAO,8BAAC,sBAAY,IAAC,KAAK,EAAE,cAAI,GAAI,CAAC;AACvC,CAAC,CAAC;AAFW,QAAA,IAAI,QAEf;AAEK,MAAM,GAAG,GAAG,GAAiB,EAAE;IACpC,OAAO,8BAAC,sBAAY,IAAC,KAAK,EAAE,aAAG,GAAI,CAAC;AACtC,CAAC,CAAC;AAFW,QAAA,GAAG,OAEd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dom-query.d.ts","sourceRoot":"","sources":["../../src/utils/dom-query.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,WAAW,GACnB,WAAW,CAQb;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,WAAW,GACnB,WAAW,CAQb"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/dom-query.ts"],"names":["getEntries","query","entries","Array","from","document","querySelectorAll","firstElement","lastElement","length","getNextSibling","element","elementIndex","indexOf","getPreviousSibling"],"mappings":";;;;;;;;AAAA,SAASA,UAAT,CAAoBC,KAApB,EAAmC;AACjC,QAAMC,OAAO,GAAGC,KAAK,CAACC,IAAN,CAAWC,QAAQ,CAACC,gBAAT,CAA0BL,KAA1B,CAAX,CAAhB;AACA,QAAMM,YAAY,GAAGL,OAAO,CAAC,CAAD,CAA5B;AACA,QAAMM,WAAW,GAAGN,OAAO,CAACA,OAAO,CAACO,MAAR,GAAiB,CAAlB,CAA3B;AAEA,SAAO;AAAEP,IAAAA,OAAF;AAAWK,IAAAA,YAAX;AAAyBC,IAAAA;AAAzB,GAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,cAAT,CACLT,KADK,EAELU,OAFK,EAGQ;AACb,QAAM;AAAET,IAAAA,OAAF;AAAWK,IAAAA,YAAX;AAAyBC,IAAAA;AAAzB,MAAyCR,UAAU,CAACC,KAAD,CAAzD;;AAEA,MAAIU,OAAO,KAAKH,WAAhB,EAA6B;AAC3B,WAAOD,YAAP;AACD;;AACD,QAAMK,YAAY,GAAGV,OAAO,CAACW,OAAR,CAAgBF,OAAhB,CAArB;AACA,SAAOT,OAAO,CAACU,YAAY,GAAG,CAAhB,CAAd;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,kBAAT,CACLb,KADK,EAELU,OAFK,EAGQ;AACb,QAAM;AAAET,IAAAA,OAAF;AAAWK,IAAAA,YAAX;AAAyBC,IAAAA;AAAzB,MAAyCR,UAAU,CAACC,KAAD,CAAzD;;AAEA,MAAIU,OAAO,KAAKJ,YAAhB,EAA8B;AAC5B,WAAOC,WAAP;AACD;;AACD,QAAMI,YAAY,GAAGV,OAAO,CAACW,OAAR,CAAgBF,OAAhB,CAArB;AACA,SAAOT,OAAO,CAACU,YAAY,GAAG,CAAhB,CAAd;AACD","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"],"file":"dom-query.js"}
File without changes
File without changes
File without changes