@opentripplanner/building-blocks 2.1.0 → 2.1.1-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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/esm/alert/Alert.js +9 -13
  4. package/esm/alert/Alert.js.map +1 -1
  5. package/esm/colors/blue.js.map +1 -1
  6. package/esm/colors/grey.js.map +1 -1
  7. package/esm/colors/red.js.map +1 -1
  8. package/esm/dropdown/index.js +19 -30
  9. package/esm/dropdown/index.js.map +1 -1
  10. package/esm/dropdown/styled.js.map +1 -1
  11. package/esm/focus-trap-wrapper/dom-query.js +8 -13
  12. package/esm/focus-trap-wrapper/dom-query.js.map +1 -1
  13. package/esm/focus-trap-wrapper/index.js +7 -16
  14. package/esm/focus-trap-wrapper/index.js.map +1 -1
  15. package/esm/index.js +2 -1
  16. package/esm/index.js.map +1 -1
  17. package/esm/stories/ColorPalette.js +0 -2
  18. package/esm/stories/ColorPalette.js.map +1 -1
  19. package/lib/alert/Alert.js +3 -22
  20. package/lib/alert/Alert.js.map +1 -1
  21. package/lib/colors/blue.js +1 -2
  22. package/lib/colors/blue.js.map +1 -1
  23. package/lib/colors/grey.js +1 -2
  24. package/lib/colors/grey.js.map +1 -1
  25. package/lib/colors/red.js +1 -2
  26. package/lib/colors/red.js.map +1 -1
  27. package/lib/dropdown/index.js +13 -30
  28. package/lib/dropdown/index.js.map +1 -1
  29. package/lib/dropdown/styled.js +3 -15
  30. package/lib/dropdown/styled.js.map +1 -1
  31. package/lib/focus-trap-wrapper/dom-query.js +2 -9
  32. package/lib/focus-trap-wrapper/dom-query.js.map +1 -1
  33. package/lib/focus-trap-wrapper/index.js +6 -22
  34. package/lib/focus-trap-wrapper/index.js.map +1 -1
  35. package/lib/index.js +4 -14
  36. package/lib/index.js.map +1 -1
  37. package/lib/stories/ColorPalette.js +1 -9
  38. package/lib/stories/ColorPalette.js.map +1 -1
  39. package/package.json +8 -8
  40. package/src/stories/__snapshots__/alerts.story.tsx.snap +14 -14
  41. package/src/stories/__snapshots__/dropdown.story.tsx.snap +9 -9
  42. package/src/stories/__snapshots__/index.story.tsx.snap +30 -30
  43. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/alert/Alert.tsx"],"names":["AlertContainer","styled","div","props","backgroundColor","blue","expandAlert","ButtonContainer","span","AlertHeader","AlertSubheader","AlertContent","ContentPadding","collapsible","Alert","alertHeader","alertSubheader","children","Icon","Bell","setExpandAlert","intl","label","formatMessage","id","defaultMessage"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAWA,MAAMA,cAAc,GAAGC,0BAAOC,GAAV;AAAA;AAAA;AAAA,oaAKEC,KAAK,IACvBA,KAAK,CAACC,eAAN,GAAwBD,KAAK,CAACC,eAA9B,GAAgDC,cAAK,EAAL,CANhC,EA0BDF,KAAK,IAAI,CAACA,KAAK,CAACG,WAAP,IAAsB,gBA1B9B,CAApB;;AAqCA,MAAMC,eAAe,GAAGN,0BAAOO,IAAV;AAAA;AAAA;AAAA,kFAArB;;AAOA,MAAMC,WAAW,GAAGR,0BAAOO,IAAV;AAAA;AAAA;AAAA,wDAAjB;;AAMA,MAAME,cAAc,GAAG,+BAAOD,WAAP,CAAH;AAAA;AAAA;AAAA,yCAApB;;AAKA,MAAME,YAAY,GAAGV,0BAAOC,GAAV;AAAA;AAAA;AAAA,iCAAlB;;AAKA,MAAMU,cAAc,GAAGX,0BAAOC,GAAV;AAAA;AAAA;AAAA,yBAGJC,KAAK,IAAKA,KAAK,CAACU,WAAN,GAAoB,KAApB,GAA4B,MAHlC,CAApB;;AAMA,MAAMC,KAAK,GAAG,CAAC;AACbC,EAAAA,WADa;AAEbC,EAAAA,cAFa;AAGbZ,EAAAA,eAHa;AAIba,EAAAA,QAJa;AAKbJ,EAAAA,WALa;AAMbK,EAAAA,IAAI,GAAGC;AANM,CAAD,KAOY;AACxB,QAAM,CAACb,WAAD,EAAcc,cAAd,IAAgC,qBAAS,KAAT,CAAtC;AACA,QAAMC,IAAI,GAAG,yBAAb;AACA,QAAMC,KAAK,GAAGD,IAAI,CAACE,aAAL,CAAmB;AAC/BC,IAAAA,EAAE,EAAE,mCAD2B;AAE/BC,IAAAA,cAAc,EAAE;AAFe,GAAnB,CAAd;AAIA,sBACE,6BAAC,cAAD;AACE,IAAA,eAAe,EAAErB,eADnB;AAEE,IAAA,WAAW,EAAEE,WAFf;AAGE,IAAA,WAAW,EAAEO;AAHf,kBAKE,6BAAC,IAAD;AAAM,IAAA,IAAI,EAAE;AAAZ,IALF,eAME,6BAAC,WAAD,QAAcE,WAAd,CANF,eAOE,6BAAC,eAAD,QACGF,WAAW,iBACV;AACE,IAAA,IAAI,EAAC,QADP;AAEE,IAAA,OAAO,EAAE,MAAMO,cAAc,CAAC,CAACd,WAAF,CAF/B;AAGE,kBAAYgB,KAHd;AAIE,IAAA,KAAK,EAAEA;AAJT,kBAME,6BAAC,oBAAD;AAAW,IAAA,IAAI,EAAE;AAAjB,IANF,CAFJ,CAPF,EAmBGN,cAAc,iBAAI,6BAAC,cAAD,QAAiBA,cAAjB,CAnBrB,EAoBGC,QAAQ,iBACP,6BAAC,YAAD,qBACE,6BAAC,2BAAD;AACE,IAAA,QAAQ,EAAE,GADZ;AAEE,IAAA,MAAM,EAAEJ,WAAW,GAAIP,WAAW,GAAG,MAAH,GAAY,CAA3B,GAAgC;AAFrD,kBAIE,6BAAC,cAAD;AAAgB,IAAA,WAAW,EAAEO;AAA7B,KACGI,QADH,CAJF,CADF,CArBJ,CADF;AAmCD,CAjDD;;eAmDeH,K","sourcesContent":["import React, { ReactChild, useState } from \"react\";\nimport styled from \"styled-components\";\nimport AnimateHeight from \"react-animate-height\";\nimport { ChevronUp } from \"@styled-icons/bootstrap/ChevronUp\";\nimport { Bell } from \"@styled-icons/bootstrap/Bell\";\nimport { StyledIcon } from \"@styled-icons/styled-icon\";\nimport { useIntl } from \"react-intl\";\nimport blue from \"../colors/blue\";\n\ninterface Props {\n alertHeader: string;\n alertSubheader?: string;\n backgroundColor?: string;\n collapsible?: boolean;\n children?: ReactChild;\n Icon?: StyledIcon;\n}\n\nconst AlertContainer = styled.div<{\n backgroundColor: string;\n collapsible: boolean;\n expandAlert: boolean;\n}>`\n background-color: ${props =>\n props.backgroundColor ? props.backgroundColor : blue[50]};\n display: grid;\n grid-template-columns: 50px auto auto;\n grid-template-rows: minmax(25px, auto) auto;\n max-width: 715px;\n padding: 1.5em 2em;\n\n svg {\n align-self: center;\n grid-column: 1;\n grid-row: 1 / span 2;\n justify-self: start;\n }\n\n button {\n background: transparent;\n border: none;\n width: 40px;\n\n svg {\n transform: ${props => !props.expandAlert && \"rotate(180deg)\"};\n transition: all 0.2s ease-in;\n }\n }\n\n @media (max-width: 550px) {\n grid-template-columns: 40px auto auto;\n padding: 1.25em 1.25em;\n }\n`;\n\nconst ButtonContainer = styled.span`\n align-items: center;\n display: flex;\n justify-content: center;\n justify-self: right;\n`;\n\nconst AlertHeader = styled.span`\n align-self: center;\n font-weight: 700;\n grid-column: 2;\n`;\n\nconst AlertSubheader = styled(AlertHeader)`\n font-weight: 400;\n margin-top: 0.3em;\n`;\n\nconst AlertContent = styled.div`\n grid-column: 2;\n grid-row: 3;\n`;\n\nconst ContentPadding = styled.div<{\n collapsible: boolean;\n}>`\n margin-top: ${props => (props.collapsible ? \"1em\" : \".5em\")};\n`;\n\nconst Alert = ({\n alertHeader,\n alertSubheader,\n backgroundColor,\n children,\n collapsible,\n Icon = Bell\n}: Props): JSX.Element => {\n const [expandAlert, setExpandAlert] = useState(false);\n const intl = useIntl();\n const label = intl.formatMessage({\n id: \"otpUi.buildingBlocks.alert.expand\",\n defaultMessage: \"Expand\"\n });\n return (\n <AlertContainer\n backgroundColor={backgroundColor}\n expandAlert={expandAlert}\n collapsible={collapsible}\n >\n <Icon size={24} />\n <AlertHeader>{alertHeader}</AlertHeader>\n <ButtonContainer>\n {collapsible && (\n <button\n type=\"button\"\n onClick={() => setExpandAlert(!expandAlert)}\n aria-label={label}\n title={label}\n >\n <ChevronUp size={16} />\n </button>\n )}\n </ButtonContainer>\n {alertSubheader && <AlertSubheader>{alertSubheader}</AlertSubheader>}\n {children && (\n <AlertContent>\n <AnimateHeight\n duration={500}\n height={collapsible ? (expandAlert ? \"auto\" : 0) : \"auto\"}\n >\n <ContentPadding collapsible={collapsible}>\n {children}\n </ContentPadding>\n </AnimateHeight>\n </AlertContent>\n )}\n </AlertContainer>\n );\n};\n\nexport default Alert;\n"],"file":"Alert.js"}
1
+ {"version":3,"file":"Alert.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_interopRequireDefault","_reactAnimateHeight","_ChevronUp","_Bell","_reactIntl","_blue","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AlertContainer","styled","div","withConfig","displayName","componentId","props","backgroundColor","blue","expandAlert","ButtonContainer","span","AlertHeader","AlertSubheader","AlertContent","ContentPadding","collapsible","Alert","alertHeader","alertSubheader","children","Icon","Bell","setExpandAlert","useState","intl","useIntl","label","formatMessage","id","defaultMessage","createElement","size","type","onClick","title","ChevronUp","duration","height","_default","exports"],"sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import React, { ReactChild, useState } from \"react\";\nimport styled from \"styled-components\";\nimport AnimateHeight from \"react-animate-height\";\nimport { ChevronUp } from \"@styled-icons/bootstrap/ChevronUp\";\nimport { Bell } from \"@styled-icons/bootstrap/Bell\";\nimport { StyledIcon } from \"@styled-icons/styled-icon\";\nimport { useIntl } from \"react-intl\";\nimport blue from \"../colors/blue\";\n\ninterface Props {\n alertHeader: string;\n alertSubheader?: string;\n backgroundColor?: string;\n collapsible?: boolean;\n children?: ReactChild;\n Icon?: StyledIcon;\n}\n\nconst AlertContainer = styled.div<{\n backgroundColor: string;\n collapsible: boolean;\n expandAlert: boolean;\n}>`\n background-color: ${props =>\n props.backgroundColor ? props.backgroundColor : blue[50]};\n display: grid;\n grid-template-columns: 50px auto auto;\n grid-template-rows: minmax(25px, auto) auto;\n max-width: 715px;\n padding: 1.5em 2em;\n\n svg {\n align-self: center;\n grid-column: 1;\n grid-row: 1 / span 2;\n justify-self: start;\n }\n\n button {\n background: transparent;\n border: none;\n width: 40px;\n\n svg {\n transform: ${props => !props.expandAlert && \"rotate(180deg)\"};\n transition: all 0.2s ease-in;\n }\n }\n\n @media (max-width: 550px) {\n grid-template-columns: 40px auto auto;\n padding: 1.25em 1.25em;\n }\n`;\n\nconst ButtonContainer = styled.span`\n align-items: center;\n display: flex;\n justify-content: center;\n justify-self: right;\n`;\n\nconst AlertHeader = styled.span`\n align-self: center;\n font-weight: 700;\n grid-column: 2;\n`;\n\nconst AlertSubheader = styled(AlertHeader)`\n font-weight: 400;\n margin-top: 0.3em;\n`;\n\nconst AlertContent = styled.div`\n grid-column: 2;\n grid-row: 3;\n`;\n\nconst ContentPadding = styled.div<{\n collapsible: boolean;\n}>`\n margin-top: ${props => (props.collapsible ? \"1em\" : \".5em\")};\n`;\n\nconst Alert = ({\n alertHeader,\n alertSubheader,\n backgroundColor,\n children,\n collapsible,\n Icon = Bell\n}: Props): JSX.Element => {\n const [expandAlert, setExpandAlert] = useState(false);\n const intl = useIntl();\n const label = intl.formatMessage({\n id: \"otpUi.buildingBlocks.alert.expand\",\n defaultMessage: \"Expand\"\n });\n return (\n <AlertContainer\n backgroundColor={backgroundColor}\n expandAlert={expandAlert}\n collapsible={collapsible}\n >\n <Icon size={24} />\n <AlertHeader>{alertHeader}</AlertHeader>\n <ButtonContainer>\n {collapsible && (\n <button\n type=\"button\"\n onClick={() => setExpandAlert(!expandAlert)}\n aria-label={label}\n title={label}\n >\n <ChevronUp size={16} />\n </button>\n )}\n </ButtonContainer>\n {alertSubheader && <AlertSubheader>{alertSubheader}</AlertSubheader>}\n {children && (\n <AlertContent>\n <AnimateHeight\n duration={500}\n height={collapsible ? (expandAlert ? \"auto\" : 0) : \"auto\"}\n >\n <ContentPadding collapsible={collapsible}>\n {children}\n </ContentPadding>\n </AnimateHeight>\n </AlertContent>\n )}\n </AlertContainer>\n );\n};\n\nexport default Alert;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAL,sBAAA,CAAAF,OAAA;AAAkC,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,U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AAM,EAAEtB,WAAW,GAAIP,WAAW,GAAG,MAAM,GAAG,CAAC,GAAI;EAAO,gBAE1DvC,MAAA,CAAAgB,OAAA,CAAA6C,aAAA,CAAChB,cAAc;IAACC,WAAW,EAAEA;EAAY,GACtCI,QACa,CACH,CACH,CAEF,CAAC;AAErB,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAtD,OAAA,GAEa+B,KAAK","ignoreList":[]}
@@ -18,6 +18,5 @@ const blue = {
18
18
  800: "#1A5992",
19
19
  900: "#004686"
20
20
  };
21
- var _default = blue;
22
- exports.default = _default;
21
+ var _default = exports.default = blue;
23
22
  //# sourceMappingURL=blue.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/colors/blue.ts"],"names":["blue"],"mappings":";;;;;;AAAA,MAAMA,IAAI,GAAG;AACX,MAAI,SADO;AAEX,OAAK,SAFM;AAGX,OAAK,SAHM;AAIX,OAAK,SAJM;AAKX,OAAK,SALM;AAMX,OAAK,SANM;AAOX,OAAK,SAPM;AAQX;AACA,OAAK,SATM;AAUX;AACA,OAAK,SAXM;AAYX,OAAK;AAZM,CAAb;eAeeA,I","sourcesContent":["const blue = {\n 50: \"#E5ECF3\",\n 100: \"#CCDAE7\",\n 200: \"#B2C7DB\",\n 300: \"#99B5CF\",\n 400: \"#7FA2C2\",\n 500: \"#6690B7\",\n 600: \"#4D7EAB\",\n // 700 and above text is WCAG AA accessible on white backgrounds.\n 700: \"#336B9E\",\n // 800 and above text is WCAG AAA accessible on white backgrounds.\n 800: \"#1A5992\",\n 900: \"#004686\"\n};\n\nexport default blue;\n"],"file":"blue.js"}
1
+ {"version":3,"file":"blue.js","names":["blue","_default","exports","default"],"sources":["../../src/colors/blue.ts"],"sourcesContent":["const blue = {\n 50: \"#E5ECF3\",\n 100: \"#CCDAE7\",\n 200: \"#B2C7DB\",\n 300: \"#99B5CF\",\n 400: \"#7FA2C2\",\n 500: \"#6690B7\",\n 600: \"#4D7EAB\",\n // 700 and above text is WCAG AA accessible on white backgrounds.\n 700: \"#336B9E\",\n // 800 and above text is WCAG AAA accessible on white backgrounds.\n 800: \"#1A5992\",\n 900: \"#004686\"\n};\n\nexport default blue;\n"],"mappings":";;;;;;AAAA,MAAMA,IAAI,GAAG;EACX,EAAE,EAAE,SAAS;EACb,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd;EACA,GAAG,EAAE,SAAS;EACd;EACA,GAAG,EAAE,SAAS;EACd,GAAG,EAAE;AACP,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaH,IAAI","ignoreList":[]}
@@ -18,6 +18,5 @@ const grey = {
18
18
  800: "#535353",
19
19
  900: "#404040"
20
20
  };
21
- var _default = grey;
22
- exports.default = _default;
21
+ var _default = exports.default = grey;
23
22
  //# sourceMappingURL=grey.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/colors/grey.ts"],"names":["grey"],"mappings":";;;;;;AAAA,MAAMA,IAAI,GAAG;AACX,MAAI,SADO;AAEX,OAAK,SAFM;AAGX,OAAK,SAHM;AAIX,OAAK,SAJM;AAKX,OAAK,SALM;AAMX,OAAK,SANM;AAOX,OAAK,SAPM;AAQX;AACA,OAAK,SATM;AAUX;AACA,OAAK,SAXM;AAYX,OAAK;AAZM,CAAb;eAeeA,I","sourcesContent":["const grey = {\n 50: \"#ECECEC\",\n 100: \"#D9D9D9\",\n 200: \"#C5C5C5\",\n 300: \"#B3B3B3\",\n 400: \"#9F9F9F\",\n 500: \"#8C8C8C\",\n 600: \"#797979\",\n // 700 and above text is WCAG AA accessible on white backgrounds.\n 700: \"#666666\",\n // 800 and above text is WCAG AAA accessible on white backgrounds.\n 800: \"#535353\",\n 900: \"#404040\"\n};\n\nexport default grey;\n"],"file":"grey.js"}
1
+ {"version":3,"file":"grey.js","names":["grey","_default","exports","default"],"sources":["../../src/colors/grey.ts"],"sourcesContent":["const grey = {\n 50: \"#ECECEC\",\n 100: \"#D9D9D9\",\n 200: \"#C5C5C5\",\n 300: \"#B3B3B3\",\n 400: \"#9F9F9F\",\n 500: \"#8C8C8C\",\n 600: \"#797979\",\n // 700 and above text is WCAG AA accessible on white backgrounds.\n 700: \"#666666\",\n // 800 and above text is WCAG AAA accessible on white backgrounds.\n 800: \"#535353\",\n 900: \"#404040\"\n};\n\nexport default grey;\n"],"mappings":";;;;;;AAAA,MAAMA,IAAI,GAAG;EACX,EAAE,EAAE,SAAS;EACb,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd;EACA,GAAG,EAAE,SAAS;EACd;EACA,GAAG,EAAE,SAAS;EACd,GAAG,EAAE;AACP,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaH,IAAI","ignoreList":[]}
package/lib/colors/red.js CHANGED
@@ -18,6 +18,5 @@ const red = {
18
18
  // 900 text is WCAG AAA accessible on white backgrounds.
19
19
  900: "#AF0E08"
20
20
  };
21
- var _default = red;
22
- exports.default = _default;
21
+ var _default = exports.default = red;
23
22
  //# sourceMappingURL=red.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/colors/red.ts"],"names":["red"],"mappings":";;;;;;AAAA,MAAMA,GAAG,GAAG;AACV,MAAI,SADM;AAEV,OAAK,SAFK;AAGV,OAAK,SAHK;AAIV,OAAK,SAJK;AAKV,OAAK,SALK;AAMV,OAAK,SANK;AAOV,OAAK,SAPK;AAQV;AACA,OAAK,SATK;AAUV,OAAK,SAVK;AAWV;AACA,OAAK;AAZK,CAAZ;eAeeA,G","sourcesContent":["const red = {\n 50: \"#F7E7E6\",\n 100: \"#EFCFCE\",\n 200: \"#E7B6B4\",\n 300: \"#DF9E9C\",\n 400: \"#D78683\",\n 500: \"#CF6E6B\",\n 600: \"#C75652\",\n // 700 and above text is WCAG AA accessible on white backgrounds.\n 700: \"#BF3E3A\",\n 800: \"#B72620\",\n // 900 text is WCAG AAA accessible on white backgrounds.\n 900: \"#AF0E08\"\n};\n\nexport default red;\n"],"file":"red.js"}
1
+ {"version":3,"file":"red.js","names":["red","_default","exports","default"],"sources":["../../src/colors/red.ts"],"sourcesContent":["const red = {\n 50: \"#F7E7E6\",\n 100: \"#EFCFCE\",\n 200: \"#E7B6B4\",\n 300: \"#DF9E9C\",\n 400: \"#D78683\",\n 500: \"#CF6E6B\",\n 600: \"#C75652\",\n // 700 and above text is WCAG AA accessible on white backgrounds.\n 700: \"#BF3E3A\",\n 800: \"#B72620\",\n // 900 text is WCAG AAA accessible on white backgrounds.\n 900: \"#AF0E08\"\n};\n\nexport default red;\n"],"mappings":";;;;;;AAAA,MAAMA,GAAG,GAAG;EACV,EAAE,EAAE,SAAS;EACb,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd;EACA,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd;EACA,GAAG,EAAE;AACP,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaH,GAAG","ignoreList":[]}
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _domQuery = require("../focus-trap-wrapper/dom-query");
11
-
12
9
  var _styled = require("./styled");
13
-
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
12
  /**
19
13
  * Renders a dropdown menu. By default, only a passed "text" is rendered. If clicked,
20
14
  * a floating div is rendered below the "text" with list contents inside. Clicking anywhere
@@ -32,21 +26,20 @@ const Dropdown = ({
32
26
  }) => {
33
27
  const [open, setOpen] = (0, _react.useState)(false);
34
28
  const containerRef = (0, _react.useRef)(null);
35
- const toggleOpen = (0, _react.useCallback)(() => setOpen(!open), [open, setOpen]); // Argument for document.querySelectorAll to target focusable elements.
29
+ const toggleOpen = (0, _react.useCallback)(() => setOpen(!open), [open, setOpen]);
36
30
 
31
+ // Argument for document.querySelectorAll to target focusable elements.
37
32
  const queryId = `#${id} button, #${id}-label`;
38
- const isList = Array.isArray(children) ? children.every(child => /*#__PURE__*/_react.default.isValidElement(child) && child.type === "li") : /*#__PURE__*/_react.default.isValidElement(children) && children.type === "li"; // Adding document event listeners allows us to close the dropdown
39
- // when the user interacts with any part of the page that isn't the dropdown
33
+ const isList = Array.isArray(children) ? children.every(child => /*#__PURE__*/_react.default.isValidElement(child) && child.type === "li") : /*#__PURE__*/_react.default.isValidElement(children) && children.type === "li";
40
34
 
35
+ // Adding document event listeners allows us to close the dropdown
36
+ // when the user interacts with any part of the page that isn't the dropdown
41
37
  (0, _react.useEffect)(() => {
42
38
  const handleExternalAction = e => {
43
- var _containerRef$current;
44
-
45
- if (!(containerRef !== null && containerRef !== void 0 && (_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(e.target))) {
39
+ if (!containerRef?.current?.contains(e.target)) {
46
40
  setOpen(false);
47
41
  }
48
42
  };
49
-
50
43
  document.addEventListener("mousedown", handleExternalAction);
51
44
  document.addEventListener("focusin", handleExternalAction);
52
45
  document.addEventListener("keydown", handleExternalAction);
@@ -57,36 +50,27 @@ const Dropdown = ({
57
50
  };
58
51
  }, [containerRef]);
59
52
  const handleKeyDown = (0, _react.useCallback)(e => {
60
- var _getPreviousSibling, _getNextSibling;
61
-
62
53
  const element = e.target;
63
-
64
54
  switch (e.key) {
65
55
  case "ArrowUp":
66
56
  e.preventDefault();
67
- (_getPreviousSibling = (0, _domQuery.getPreviousSibling)(queryId, element)) === null || _getPreviousSibling === void 0 ? void 0 : _getPreviousSibling.focus();
57
+ (0, _domQuery.getPreviousSibling)(queryId, element)?.focus();
68
58
  break;
69
-
70
59
  case "ArrowDown":
71
60
  e.preventDefault();
72
- (_getNextSibling = (0, _domQuery.getNextSibling)(queryId, element)) === null || _getNextSibling === void 0 ? void 0 : _getNextSibling.focus();
61
+ (0, _domQuery.getNextSibling)(queryId, element)?.focus();
73
62
  break;
74
-
75
63
  case "Escape":
76
64
  setOpen(false);
77
65
  break;
78
-
79
66
  case " ":
80
67
  case "Enter":
81
68
  e.preventDefault();
82
69
  element.click();
83
-
84
70
  if (element.id === `${id}-label` || element.id === `${id}-wrapper`) {
85
71
  toggleOpen();
86
72
  }
87
-
88
73
  break;
89
-
90
74
  default:
91
75
  }
92
76
  }, [id, toggleOpen]);
@@ -95,7 +79,8 @@ const Dropdown = ({
95
79
  id: `${id}-wrapper`,
96
80
  onKeyDown: handleKeyDown,
97
81
  ref: containerRef
98
- }, /*#__PURE__*/_react.default.createElement(_styled.DropdownButton // Only set aria-controls when the dropdown is open
82
+ }, /*#__PURE__*/_react.default.createElement(_styled.DropdownButton
83
+ // Only set aria-controls when the dropdown is open
99
84
  // (otherwise, assistive technologies may not announce the dropdown correctly).
100
85
  , {
101
86
  "aria-controls": open ? id : undefined,
@@ -120,7 +105,5 @@ const Dropdown = ({
120
105
  tabIndex: -1
121
106
  }, children));
122
107
  };
123
-
124
- var _default = Dropdown;
125
- exports.default = _default;
108
+ var _default = exports.default = Dropdown;
126
109
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/dropdown/index.tsx"],"names":["Dropdown","alignMenuLeft","children","className","id","label","listLabel","text","buttonStyle","open","setOpen","containerRef","toggleOpen","queryId","isList","Array","isArray","every","child","isValidElement","type","handleExternalAction","e","current","contains","target","document","addEventListener","removeEventListener","handleKeyDown","element","key","preventDefault","focus","click","undefined"],"mappings":";;;;;;;AAAA;;AASA;;AAIA;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GAAG,CAAC;AAChBC,EAAAA,aADgB;AAEhBC,EAAAA,QAFgB;AAGhBC,EAAAA,SAHgB;AAIhBC,EAAAA,EAJgB;AAKhBC,EAAAA,KALgB;AAMhBC,EAAAA,SANgB;AAOhBC,EAAAA,IAPgB;AAQhBC,EAAAA;AARgB,CAAD,KASS;AACxB,Q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AAEH;AAVT,kBAYE,2CAAOE,IAAP,CAZF,eAaE;AAAM,IAAA,SAAS,EAAC,OAAhB;AAAwB,IAAA,IAAI,EAAC;AAA7B,IAbF,CANF,EAqBGE,IAAI,iBACH,6BAAC,oBAAD;AACE,IAAA,EAAE,EAAEK,MAAM,IAAI,IADhB;AAEE,kBAAYR,SAFd;AAGE,uBAAiBA,SAAS,GAAG6B,SAAH,GAAgB,GAAE/B,EAAG,QAHjD;AAIE,IAAA,EAAE,EAAEA,EAJN;AAKE,IAAA,OAAO,EAAEQ,UALX;AAME,IAAA,SAAS,EAAEX,aANb;AAOE,IAAA,IAAI,EAAEa,MAAM,IAAI,MAPlB;AAQE,IAAA,QAAQ,EAAE,CAAC;AARb,KAUGZ,QAVH,CAtBJ,CADF;AAsCD,CA9GD;;eAgHeF,Q","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 >\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 && \"list\"}\n tabIndex={-1}\n >\n {children}\n </DropdownMenu>\n )}\n </DropdownWrapper>\n );\n};\n\nexport default Dropdown;\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_domQuery","_styled","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","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","current","contains","target","document","addEventListener","removeEventListener","handleKeyDown","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 >\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 && \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AE,GAAGA,EAAE,UAAW;IACpBuC,SAAS,EAAEV,aAAc;IACzBW,GAAG,EAAEhC;EAAa,gBAElBrC,MAAA,CAAAW,OAAA,CAAAuD,aAAA,CAAC9D,OAAA,CAAAkE;EACC;EACA;EAAA;IACA,iBAAepC,IAAI,GAAGL,EAAE,GAAG0C,SAAU;IACrC,iBAAerC,IAAK;IACpB,iBAAc,SAAS;IACvB,cAAYJ,KAAM;IAClBD,EAAE,EAAE,GAAGA,EAAE,QAAS;IAClB2C,OAAO,EAAEjC,UAAW;IACpBkC,KAAK,EAAExC,WAAY;IACnByC,KAAK,EAAE5C;EAAM,gBAEb9B,MAAA,CAAAW,OAAA,CAAAuD,aAAA,eAAOlC,IAAW,CAAC,eACnBhC,MAAA,CAAAW,OAAA,CAAAuD,aAAA;IAAMtC,SAAS,EAAC,OAAO;IAAC+C,IAAI,EAAC;EAAc,CAAE,CAC/B,CAAC,EAChBzC,IAAI,iBACHlC,MAAA,CAAAW,OAAA,CAAAuD,aAAA,CAAC9D,OAAA,CAAAwE,YAAY;IACXC,EAAE,EAAEnC,MAAM,IAAI,IAAK;IACnB,cAAYX,SAAU;IACtB,mBAAiBA,SAAS,GAAGwC,SAAS,GAAG,GAAG1C,EAAE,QAAS;IACvDA,EAAE,EAAEA,EAAG;IACP2C,OAAO,EAAEjC,UAAW;IACpBuC,SAAS,EAAEpD,aAAc;IACzBiD,IAAI,EAAEjC,MAAM,IAAI,MAAO;IACvBqC,QAAQ,EAAE,CAAC;EAAE,GAEZpD,QACW,CAED,CAAC;AAEtB,CAAC;AAAC,IAAAqD,QAAA,GAAAC,OAAA,CAAAtE,OAAA,GAEac,QAAQ","ignoreList":[]}
@@ -1,34 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.DropdownWrapper = exports.DropdownMenu = exports.DropdownButton = void 0;
9
-
10
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
9
  var _grey = _interopRequireDefault(require("../colors/grey"));
13
-
14
- const DropdownButton = _styledComponents.default.button.withConfig({
10
+ const DropdownButton = exports.DropdownButton = _styledComponents.default.button.withConfig({
15
11
  displayName: "styled__DropdownButton",
16
12
  componentId: "sc-kes9ha-0"
17
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]);
18
-
19
- exports.DropdownButton = DropdownButton;
20
-
21
- const DropdownMenu = _styledComponents.default.div.withConfig({
14
+ const DropdownMenu = exports.DropdownMenu = _styledComponents.default.div.withConfig({
22
15
  displayName: "styled__DropdownMenu",
23
16
  componentId: "sc-kes9ha-1"
24
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]);
25
-
26
- exports.DropdownMenu = DropdownMenu;
27
-
28
- const DropdownWrapper = _styledComponents.default.span.withConfig({
18
+ const DropdownWrapper = exports.DropdownWrapper = _styledComponents.default.span.withConfig({
29
19
  displayName: "styled__DropdownWrapper",
30
20
  componentId: "sc-kes9ha-2"
31
21
  })(["float:", ";position:relative;"], props => props.pullRight ? "right" : "left");
32
-
33
- exports.DropdownWrapper = DropdownWrapper;
34
22
  //# sourceMappingURL=styled.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/dropdown/styled.tsx"],"names":["DropdownButton","styled","button","grey","DropdownMenu","div","props","alignLeft","DropdownWrapper","span","pullRight"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,MAAMA,cAAc,GAAGC,0BAAOC,MAAV;AAAA;AAAA;AAAA,8YAsBTC,cAAK,EAAL,CAtBS,CAApB;;;;AA4BA,MAAMC,YAAY,GAAGH,0BAAOI,GAAV;AAAA;AAAA;AAAA,gbAYrBC,KAAK,IAAKA,KAAK,CAACC,SAAN,GAAkB,UAAlB,GAA+B,WAZpB,EA+BLJ,cAAK,EAAL,CA/BK,CAAlB;;;;AAoCA,MAAMK,eAAe,GAAGP,0BAAOQ,IAAV;AAAA;AAAA;AAAA,sCACjBH,KAAK,IAAKA,KAAK,CAACI,SAAN,GAAkB,OAAlB,GAA4B,MADrB,CAArB","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"],"file":"styled.js"}
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":[]}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getNextSibling = getNextSibling;
7
7
  exports.getPreviousSibling = getPreviousSibling;
8
-
9
8
  function getEntries(query) {
10
9
  const entries = Array.from(document.querySelectorAll(query));
11
10
  const firstElement = entries[0];
@@ -16,6 +15,7 @@ function getEntries(query) {
16
15
  lastElement
17
16
  };
18
17
  }
18
+
19
19
  /**
20
20
  * Helper method to find the next focusable sibling element relative to the
21
21
  * specified element.
@@ -24,22 +24,19 @@ function getEntries(query) {
24
24
  * @param {HTMLElement} element - Specified element (e.target)
25
25
  * @returns {HTMLElement} - element to be focused
26
26
  */
27
-
28
-
29
27
  function getNextSibling(query, element) {
30
28
  const {
31
29
  entries,
32
30
  firstElement,
33
31
  lastElement
34
32
  } = getEntries(query);
35
-
36
33
  if (element === lastElement) {
37
34
  return firstElement;
38
35
  }
39
-
40
36
  const elementIndex = entries.indexOf(element);
41
37
  return entries[elementIndex + 1];
42
38
  }
39
+
43
40
  /**
44
41
  * Helper method to find the previous focusable sibling element relative to the
45
42
  * specified element.
@@ -48,19 +45,15 @@ function getNextSibling(query, element) {
48
45
  * @param {HTMLElement} element - Specified element (e.target)
49
46
  * @returns {HTMLElement} - element to be focused
50
47
  */
51
-
52
-
53
48
  function getPreviousSibling(query, element) {
54
49
  const {
55
50
  entries,
56
51
  firstElement,
57
52
  lastElement
58
53
  } = getEntries(query);
59
-
60
54
  if (element === firstElement) {
61
55
  return lastElement;
62
56
  }
63
-
64
57
  const elementIndex = entries.indexOf(element);
65
58
  return entries[elementIndex - 1];
66
59
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/focus-trap-wrapper/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"}
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":[]}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
  Object.defineProperty(exports, "getNextSibling", {
7
8
  enumerable: true,
8
9
  get: function () {
@@ -15,16 +16,10 @@ Object.defineProperty(exports, "getPreviousSibling", {
15
16
  return _domQuery.getPreviousSibling;
16
17
  }
17
18
  });
18
- exports.default = void 0;
19
-
20
19
  var _react = _interopRequireWildcard(require("react"));
21
-
22
20
  var _domQuery = require("./dom-query");
23
-
24
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
-
26
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
-
21
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
22
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
28
23
  const FocusTrapWrapper = ({
29
24
  children,
30
25
  closePopup = null,
@@ -34,27 +29,18 @@ const FocusTrapWrapper = ({
34
29
  const queryId = focusElements.map(el => `#${id}-focus-trap ${el}:not([disabled])`).join(", ");
35
30
  const handleKeyDown = (0, _react.useCallback)(e => {
36
31
  const element = e.target;
37
-
38
32
  switch (e.key) {
39
33
  case "Escape":
40
34
  closePopup();
41
35
  break;
42
-
43
36
  case "Tab":
44
37
  e.preventDefault();
45
-
46
38
  if (e.shiftKey) {
47
- var _getPreviousSibling;
48
-
49
- (_getPreviousSibling = (0, _domQuery.getPreviousSibling)(queryId, element)) === null || _getPreviousSibling === void 0 ? void 0 : _getPreviousSibling.focus();
39
+ (0, _domQuery.getPreviousSibling)(queryId, element)?.focus();
50
40
  } else {
51
- var _getNextSibling;
52
-
53
- (_getNextSibling = (0, _domQuery.getNextSibling)(queryId, element)) === null || _getNextSibling === void 0 ? void 0 : _getNextSibling.focus();
41
+ (0, _domQuery.getNextSibling)(queryId, element)?.focus();
54
42
  }
55
-
56
43
  break;
57
-
58
44
  default:
59
45
  }
60
46
  }, [closePopup]);
@@ -64,7 +50,5 @@ const FocusTrapWrapper = ({
64
50
  role: "presentation"
65
51
  }, children);
66
52
  };
67
-
68
- var _default = FocusTrapWrapper;
69
- exports.default = _default;
53
+ var _default = exports.default = FocusTrapWrapper;
70
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/focus-trap-wrapper/index.tsx"],"names":["FocusTrapWrapper","children","closePopup","focusElements","id","queryId","map","el","join","handleKeyDown","e","element","target","key","preventDefault","shiftKey","focus"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA,MAAMA,gBAAgB,GAAG,CAAC;AACxBC,EAAAA,QADwB;AAExBC,EAAAA,UAAU,GAAG,IAFW;AAGxBC,EAAAA,aAAa,GAAG,CAAC,QAAD,EAAW,GAAX,EAAgB,OAAhB,EAAyB,QAAzB,CAHQ;AAIxBC,EAAAA;AAJwB,CAAD,KAUN;AACjB,QAAMC,OAAO,GAAGF,aAAa,CAC1BG,GADa,CACTC,EAAE,IAAK,IAAGH,EAAG,eAAcG,EAAG,kBADrB,EAEbC,IAFa,CAER,IAFQ,CAAhB;AAGA,QAAMC,aAAa,GAAG,wBACpBC,CAAC,IAAI;AACH,UAAMC,OAAO,GAAGD,CAAC,CAACE,MAAlB;;AACA,YAAQF,CAAC,CAACG,GAAV;AACE,WAAK,QAAL;AACEX,QAAAA,UAAU;AACV;;AACF,WAAK,KAAL;AACEQ,QAAAA,CAAC,CAACI,cAAF;;AACA,YAAIJ,CAAC,CAACK,QAAN,EAAgB;AAAA;;AACd,mEAAmBV,OAAnB,EAA4BM,OAA5B,6EAAsCK,KAAtC;AACD,SAFD,MAEO;AAAA;;AACL,2DAAeX,OAAf,EAAwBM,OAAxB,qEAAkCK,KAAlC;AACD;;AACD;;AACF;AAZF;AAcD,GAjBmB,EAkBpB,CAACd,UAAD,CAlBoB,CAAtB;AAqBA,sBACE;AAAK,IAAA,EAAE,EAAG,GAAEE,EAAG,aAAf;AAA6B,IAAA,SAAS,EAAEK,aAAxC;AAAuD,IAAA,IAAI,EAAC;AAA5D,KACGR,QADH,CADF;AAKD,CAxCD;;eA4CeD,gB","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"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_domQuery","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","FocusTrapWrapper","children","closePopup","focusElements","id","queryId","map","el","join","handleKeyDown","useCallback","element","target","key","preventDefault","shiftKey","getPreviousSibling","focus","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,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,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AAC+B,MAAqB;IACvC,QAAQ/B,CAAC,CAACgC,GAAG;MACX,KAAK,QAAQ;QACXX,UAAU,CAAC,CAAC;QACZ;MACF,KAAK,KAAK;QACRrB,CAAC,CAACiC,cAAc,CAAC,CAAC;QAClB,IAAIjC,CAAC,CAACkC,QAAQ,EAAE;UACd,IAAAC,4BAAkB,EAACX,OAAO,EAAEM,OAAO,CAAC,EAAEM,KAAK,CAAC,CAAC;QAC/C,CAAC,MAAM;UACL,IAAAC,wBAAc,EAACb,OAAO,EAAEM,OAAO,CAAC,EAAEM,KAAK,CAAC,CAAC;QAC3C;QACA;MACF;IACF;EACF,CAAC,EACD,CAACf,UAAU,CACb,CAAC;EAED,oBACE1B,MAAA,CAAAU,OAAA,CAAAiC,aAAA;IAAKf,EAAE,EAAE,GAAGA,EAAE,aAAc;IAACgB,SAAS,EAAEX,aAAc;IAACY,IAAI,EAAC;EAAc,GACvEpB,QACE,CAAC;AAEV,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAArC,OAAA,GAIac,gBAAgB","ignoreList":[]}
package/lib/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -17,6 +16,7 @@ Object.defineProperty(exports, "FocusTrapWrapper", {
17
16
  return _focusTrapWrapper.default;
18
17
  }
19
18
  });
19
+ exports.default = void 0;
20
20
  Object.defineProperty(exports, "getNextSibling", {
21
21
  enumerable: true,
22
22
  get: function () {
@@ -29,27 +29,17 @@ Object.defineProperty(exports, "getPreviousSibling", {
29
29
  return _focusTrapWrapper.getPreviousSibling;
30
30
  }
31
31
  });
32
- exports.default = void 0;
33
-
34
32
  var _blue = _interopRequireDefault(require("./colors/blue"));
35
-
36
33
  var _red = _interopRequireDefault(require("./colors/red"));
37
-
38
34
  var _grey = _interopRequireDefault(require("./colors/grey"));
39
-
40
35
  var _dropdown = _interopRequireDefault(require("./dropdown"));
41
-
42
36
  var _focusTrapWrapper = _interopRequireWildcard(require("./focus-trap-wrapper"));
43
-
44
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
-
46
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
-
37
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
38
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
48
39
  // TODO: Fix exports
49
- var _default = {
40
+ var _default = exports.default = {
50
41
  blue: _blue.default,
51
42
  red: _red.default,
52
43
  grey: _grey.default
53
44
  };
54
- exports.default = _default;
55
45
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["blue","red","grey"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAKA;eAEe;AAAEA,EAAAA,IAAI,EAAJA,aAAF;AAAQC,EAAAA,GAAG,EAAHA,YAAR;AAAaC,EAAAA,IAAI,EAAJA;AAAb,C","sourcesContent":["import blue from \"./colors/blue\";\nimport red from \"./colors/red\";\nimport grey from \"./colors/grey\";\nimport Dropdown from \"./dropdown\";\nimport FocusTrapWrapper, {\n getNextSibling,\n getPreviousSibling\n} from \"./focus-trap-wrapper\";\n\n// TODO: Fix exports\nexport { Dropdown, FocusTrapWrapper, getNextSibling, getPreviousSibling };\nexport default { blue, red, grey };\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_blue","_interopRequireDefault","require","_red","_grey","_dropdown","_focusTrapWrapper","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_default","exports","blue","red","grey"],"sources":["../src/index.ts"],"sourcesContent":["import blue from \"./colors/blue\";\nimport red from \"./colors/red\";\nimport grey from \"./colors/grey\";\nimport Dropdown from \"./dropdown\";\nimport FocusTrapWrapper, {\n getNextSibling,\n getPreviousSibling\n} from \"./focus-trap-wrapper\";\n\n// TODO: Fix exports\nexport { Dropdown, FocusTrapWrapper, getNextSibling, getPreviousSibling };\nexport default { blue, red, grey };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAA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GAEe;EAAEgB,IAAI,EAAJA,aAAI;EAAEC,GAAG,EAAHA,YAAG;EAAEC,IAAI,EAAJA;AAAK,CAAC","ignoreList":[]}
@@ -1,23 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
10
  var _route = require("@opentripplanner/core-utils/lib/route");
15
-
16
11
  const ColorBlock = _styledComponents.default.div.withConfig({
17
12
  displayName: "ColorPalette__ColorBlock",
18
13
  componentId: "sc-fil65c-0"
19
14
  })(["align-items:center;background-color:", ";color:", ";text-shadow:", ";display:flex;font-family:Arial,Helvetica,sans-serif;height:40px;justify-content:space-between;margin:0;padding:10px;width:300px;&:first-of-type{border-radius:8px 8px 0 0;}&:last-of-type{border-radius:0 0 8px 8px;}"], props => props.hex, props => (0, _route.getMostReadableTextColor)(props.hex, "#ffffff"), props => (0, _route.getMostReadableTextColor)(props.hex, "#ffffff") === "#ffffff" ? "1px 1px 2px black" : "");
20
-
21
15
  const ColorPalette = ({
22
16
  color
23
17
  }) => {
@@ -29,7 +23,5 @@ const ColorPalette = ({
29
23
  }, /*#__PURE__*/_react.default.createElement("p", null, hue[0]), /*#__PURE__*/_react.default.createElement("p", null, hue[1]));
30
24
  }));
31
25
  };
32
-
33
- var _default = ColorPalette;
34
- exports.default = _default;
26
+ var _default = exports.default = ColorPalette;
35
27
  //# sourceMappingURL=ColorPalette.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stories/ColorPalette.tsx"],"names":["ColorBlock","styled","div","props","hex","ColorPalette","color","colorArray","Object","entries","map","hue"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AAUA,MAAMA,UAAU,GAAGC,0BAAOC,GAAV;AAAA;AAAA;AAAA,mSAEMC,KAAK,IAAIA,KAAK,CAACC,GAFrB,EAGLD,KAAK,IAAI,qCAAyBA,KAAK,CAACC,GAA/B,EAAoC,SAApC,CAHJ,EAICD,KAAK,IAClB,qCAAyBA,KAAK,CAACC,GAA/B,EAAoC,SAApC,MAAmD,SAAnD,GACI,mBADJ,GAEI,EAPQ,CAAhB;;AAwBA,MAAMC,YAAY,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAmC;AACtD,QAAMC,UAAsB,GAAGC,MAAM,CAACC,OAAP,CAAeH,KAAf,CAA/B;AAEA,sBACE,4DACGC,UAAU,CAACG,GAAX,CACEC,GAAD,IAA2B;AACzB,wBACE,6BAAC,UAAD;AAAY,MAAA,GAAG,EAAEA,GAAG,CAAC,CAAD,CAApB;AAAyB,MAAA,GAAG,EAAEA,GAAG,CAAC,CAAD;AAAjC,oBACE,wCAAIA,GAAG,CAAC,CAAD,CAAP,CADF,eAEE,wCAAIA,GAAG,CAAC,CAAD,CAAP,CAFF,CADF;AAMD,GARF,CADH,CADF;AAcD,CAjBD;;eAkBeN,Y","sourcesContent":["import React from \"react\";\n\nimport styled from \"styled-components\";\nimport { getMostReadableTextColor } from \"@opentripplanner/core-utils/lib/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"],"file":"ColorPalette.js"}
1
+ {"version":3,"file":"ColorPalette.js","names":["_react","_interopRequireDefault","require","_styledComponents","_route","ColorBlock","styled","div","withConfig","displayName","componentId","props","hex","getMostReadableTextColor","ColorPalette","color","colorArray","Object","entries","default","createElement","Fragment","map","hue","key","_default","exports"],"sources":["../../src/stories/ColorPalette.tsx"],"sourcesContent":["import React from \"react\";\n\nimport styled from \"styled-components\";\nimport { getMostReadableTextColor } from \"@opentripplanner/core-utils/lib/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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAA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