@opentripplanner/building-blocks 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/alert/Alert.js +2 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -1
- package/esm/stories/ColorPalette.js +2 -1
- package/esm/stories/ColorPalette.js.map +1 -1
- package/lib/alert/Alert.d.ts +3 -4
- package/lib/alert/Alert.d.ts.map +1 -1
- package/lib/alert/Alert.js +3 -3
- package/lib/alert/Alert.js.map +1 -1
- package/lib/dropdown/index.d.ts.map +1 -1
- package/lib/dropdown/index.js +1 -2
- package/lib/dropdown/index.js.map +1 -1
- package/lib/focus-trap-wrapper/index.d.ts.map +1 -1
- package/lib/focus-trap-wrapper/index.js +1 -2
- package/lib/focus-trap-wrapper/index.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/stories/ColorPalette.d.ts +0 -1
- package/lib/stories/ColorPalette.d.ts.map +1 -1
- package/lib/stories/ColorPalette.js +5 -2
- package/lib/stories/ColorPalette.js.map +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.tsx +11 -8
- package/src/index.ts +8 -1
- package/src/stories/ColorPalette.tsx +3 -1
- package/src/stories/__snapshots__/alerts.story.tsx.snap +88 -83
- package/src/stories/__snapshots__/dropdown.story.tsx.snap +1 -1
- package/src/stories/__snapshots__/focusTrapStory.story.tsx.snap +1 -1
- package/src/stories/__snapshots__/index.story.tsx.snap +1 -1
- package/src/stories/alerts.story.tsx +24 -15
- package/src/stories/dropdown.story.tsx +2 -2
- package/src/stories/index.story.tsx +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/esm/alert/Alert.js
CHANGED
|
@@ -9,7 +9,7 @@ import blue from "../colors/blue";
|
|
|
9
9
|
var AlertContainer = styled.div.withConfig({
|
|
10
10
|
displayName: "Alert__AlertContainer",
|
|
11
11
|
componentId: "sc-2vlo3n-0"
|
|
12
|
-
})(["background-color:", ";display:grid;grid-template-columns:50px auto auto;grid-template-rows:minmax(25px,auto) auto;
|
|
12
|
+
})(["background-color:", ";display:grid;grid-template-columns:50px auto auto;grid-template-rows:minmax(25px,auto) auto;column-gap:1em;padding:1.5em;svg{align-self:center;grid-column:1;grid-row:1 / span 2;justify-self:center;}button.toggle-btn{background:transparent;border:none;width:40px;svg{transform:", ";transition:all 0.2s ease-in;}}@media (max-width:550px){grid-template-columns:40px auto auto;padding:1.25em 1.25em;}"], function (props) {
|
|
13
13
|
return props.backgroundColor ? props.backgroundColor : blue[50];
|
|
14
14
|
}, function (props) {
|
|
15
15
|
return !props.expandAlert && "rotate(180deg)";
|
|
@@ -61,6 +61,7 @@ var Alert = function Alert(_ref) {
|
|
|
61
61
|
size: 24
|
|
62
62
|
}), /*#__PURE__*/React.createElement(AlertHeader, null, alertHeader), /*#__PURE__*/React.createElement(ButtonContainer, null, collapsible && /*#__PURE__*/React.createElement("button", {
|
|
63
63
|
type: "button",
|
|
64
|
+
className: "toggle-btn",
|
|
64
65
|
onClick: function onClick() {
|
|
65
66
|
return setExpandAlert(!expandAlert);
|
|
66
67
|
},
|
package/esm/alert/Alert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","names":["React","useState","styled","AnimateHeight","ChevronUp","Bell","useIntl","blue","AlertContainer","div","withConfig","displayName","componentId","props","backgroundColor","expandAlert","ButtonContainer","span","AlertHeader","AlertSubheader","AlertContent","ContentPadding","collapsible","Alert","_ref","alertHeader","alertSubheader","children","_ref$Icon","Icon","_useState","_useState2","_slicedToArray","setExpandAlert","intl","label","formatMessage","id","defaultMessage","createElement","size","type","onClick","title","duration","height"],"sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"Alert.js","names":["React","useState","styled","AnimateHeight","ChevronUp","Bell","useIntl","blue","AlertContainer","div","withConfig","displayName","componentId","props","backgroundColor","expandAlert","ButtonContainer","span","AlertHeader","AlertSubheader","AlertContent","ContentPadding","collapsible","Alert","_ref","alertHeader","alertSubheader","children","_ref$Icon","Icon","_useState","_useState2","_slicedToArray","setExpandAlert","intl","label","formatMessage","id","defaultMessage","createElement","size","type","className","onClick","title","duration","height"],"sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import React, { 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: JSX.Element | string;\n alertSubheader?: JSX.Element | string;\n backgroundColor?: string;\n /* If true, adds a toggle that expands/collapses the alert content */\n collapsible?: boolean;\n children?: JSX.Element | string;\n /* Icon displayed on Alert - default is Bell */\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 column-gap: 1em;\n padding: 1.5em;\n\n svg {\n align-self: center;\n grid-column: 1;\n grid-row: 1 / span 2;\n justify-self: center;\n }\n\n button.toggle-btn {\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 className=\"toggle-btn\"\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,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,aAAa,MAAM,sBAAsB;AAChD,SAASC,SAAS,QAAQ,mCAAmC;AAC7D,SAASC,IAAI,QAAQ,8BAA8B;AAEnD,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,IAAI,MAAM,gBAAgB;AAajC,IAAMC,cAAc,GAAGN,MAAM,CAACO,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAA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CACH,CAEF,CAAC;AAErB,CAAC;AAED,eAAeJ,KAAK","ignoreList":[]}
|
package/esm/index.js
CHANGED
|
@@ -3,9 +3,10 @@ import red from "./colors/red";
|
|
|
3
3
|
import grey from "./colors/grey";
|
|
4
4
|
import Dropdown from "./dropdown";
|
|
5
5
|
import FocusTrapWrapper, { getNextSibling, getPreviousSibling } from "./focus-trap-wrapper";
|
|
6
|
+
import Alert from "./alert/Alert";
|
|
6
7
|
|
|
7
8
|
// TODO: Fix exports
|
|
8
|
-
export { Dropdown, FocusTrapWrapper, getNextSibling, getPreviousSibling };
|
|
9
|
+
export { Alert, Dropdown, FocusTrapWrapper, getNextSibling, getPreviousSibling };
|
|
9
10
|
export default {
|
|
10
11
|
blue: blue,
|
|
11
12
|
red: red,
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["blue","red","grey","Dropdown","FocusTrapWrapper","getNextSibling","getPreviousSibling"],"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 {
|
|
1
|
+
{"version":3,"file":"index.js","names":["blue","red","grey","Dropdown","FocusTrapWrapper","getNextSibling","getPreviousSibling","Alert"],"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\";\nimport Alert from \"./alert/Alert\";\n\n// TODO: Fix exports\nexport {\n Alert,\n Dropdown,\n FocusTrapWrapper,\n getNextSibling,\n getPreviousSibling\n};\nexport default { blue, red, grey };\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,eAAe;AAChC,OAAOC,GAAG,MAAM,cAAc;AAC9B,OAAOC,IAAI,MAAM,eAAe;AAChC,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,gBAAgB,IACrBC,cAAc,EACdC,kBAAkB,QACb,sBAAsB;AAC7B,OAAOC,KAAK,MAAM,eAAe;;AAEjC;AACA,SACEA,KAAK,EACLJ,QAAQ,EACRC,gBAAgB,EAChBC,cAAc,EACdC,kBAAkB;AAEpB,eAAe;EAAEN,IAAI,EAAJA,IAAI;EAAEC,GAAG,EAAHA,GAAG;EAAEC,IAAI,EAAJA;AAAK,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
|
-
import
|
|
3
|
+
import coreUtils from "@opentripplanner/core-utils";
|
|
4
|
+
var getMostReadableTextColor = coreUtils.route.getMostReadableTextColor;
|
|
4
5
|
var ColorBlock = styled.div.withConfig({
|
|
5
6
|
displayName: "ColorPalette__ColorBlock",
|
|
6
7
|
componentId: "sc-fil65c-0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPalette.js","names":["React","styled","getMostReadableTextColor","ColorBlock","div","withConfig","displayName","componentId","props","hex","ColorPalette","_ref","color","colorArray","Object","entries","createElement","Fragment","map","hue","key"],"sources":["../../src/stories/ColorPalette.tsx"],"sourcesContent":["import React from \"react\";\n\nimport styled from \"styled-components\";\nimport
|
|
1
|
+
{"version":3,"file":"ColorPalette.js","names":["React","styled","coreUtils","getMostReadableTextColor","route","ColorBlock","div","withConfig","displayName","componentId","props","hex","ColorPalette","_ref","color","colorArray","Object","entries","createElement","Fragment","map","hue","key"],"sources":["../../src/stories/ColorPalette.tsx"],"sourcesContent":["import React from \"react\";\n\nimport styled from \"styled-components\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\nconst { getMostReadableTextColor } = coreUtils.route;\n\nexport interface Hue {\n [key: number]: string;\n}\n\ninterface Props {\n color: Hue;\n}\n\nconst ColorBlock = styled.div<{ hex: string }>`\n align-items: center;\n background-color: ${props => props.hex};\n color: ${props => getMostReadableTextColor(props.hex, \"#ffffff\")};\n text-shadow: ${props =>\n getMostReadableTextColor(props.hex, \"#ffffff\") === \"#ffffff\"\n ? \"1px 1px 2px black\"\n : \"\"};\n display: flex;\n font-family: Arial, Helvetica, sans-serif;\n height: 40px;\n justify-content: space-between;\n margin: 0;\n padding: 10px;\n width: 300px;\n\n &:first-of-type {\n border-radius: 8px 8px 0 0;\n }\n &:last-of-type {\n border-radius: 0 0 8px 8px;\n }\n`;\n\nconst ColorPalette = ({ color }: Props): JSX.Element => {\n const colorArray: Array<Hue> = Object.entries(color);\n\n return (\n <>\n {colorArray.map(\n (hue: Hue): JSX.Element => {\n return (\n <ColorBlock key={hue[0]} hex={hue[1]}>\n <p>{hue[0]}</p>\n <p>{hue[1]}</p>\n </ColorBlock>\n );\n }\n )}\n </>\n );\n};\nexport default ColorPalette;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,SAAS,MAAM,6BAA6B;AAEnD,IAAQC,wBAAwB,GAAKD,SAAS,CAACE,KAAK,CAA5CD,wBAAwB;AAUhC,IAAME,UAAU,GAAGJ,MAAM,CAACK,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,mSAEP,UAAAC,KAAK;EAAA,OAAIA,KAAK,CAACC,GAAG;AAAA,GAC7B,UAAAD,KAAK;EAAA,OAAIP,wBAAwB,CAACO,KAAK,CAACC,GAAG,EAAE,SAAS,CAAC;AAAA,GACjD,UAAAD,KAAK;EAAA,OAClBP,wBAAwB,CAACO,KAAK,CAACC,GAAG,EAAE,SAAS,CAAC,KAAK,SAAS,GACxD,mBAAmB,GACnB,EAAE;AAAA,EAeT;AAED,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAAsC;EAAA,IAAhCC,KAAK,GAAAD,IAAA,CAALC,KAAK;EAC3B,IAAMC,UAAsB,GAAGC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC;EAEpD,oBACEd,KAAA,CAAAkB,aAAA,CAAAlB,KAAA,CAAAmB,QAAA,QACGJ,UAAU,CAACK,GAAG,CACb,UAACC,GAAQ,EAAkB;IACzB,oBACErB,KAAA,CAAAkB,aAAA,CAACb,UAAU;MAACiB,GAAG,EAAED,GAAG,CAAC,CAAC,CAAE;MAACV,GAAG,EAAEU,GAAG,CAAC,CAAC;IAAE,gBACnCrB,KAAA,CAAAkB,aAAA,YAAIG,GAAG,CAAC,CAAC,CAAK,CAAC,eACfrB,KAAA,CAAAkB,aAAA,YAAIG,GAAG,CAAC,CAAC,CAAK,CACJ,CAAC;EAEjB,CACF,CACA,CAAC;AAEP,CAAC;AACD,eAAeT,YAAY","ignoreList":[]}
|
package/lib/alert/Alert.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { ReactChild } from "react";
|
|
2
1
|
import { StyledIcon } from "@styled-icons/styled-icon";
|
|
3
2
|
interface Props {
|
|
4
|
-
alertHeader: string;
|
|
5
|
-
alertSubheader?: string;
|
|
3
|
+
alertHeader: JSX.Element | string;
|
|
4
|
+
alertSubheader?: JSX.Element | string;
|
|
6
5
|
backgroundColor?: string;
|
|
7
6
|
collapsible?: boolean;
|
|
8
|
-
children?:
|
|
7
|
+
children?: JSX.Element | string;
|
|
9
8
|
Icon?: StyledIcon;
|
|
10
9
|
}
|
|
11
10
|
declare const Alert: ({ alertHeader, alertSubheader, backgroundColor, children, collapsible, Icon }: Props) => JSX.Element;
|
package/lib/alert/Alert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/alert/Alert.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/alert/Alert.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,UAAU,KAAK;IACb,WAAW,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAEhC,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAoED,QAAA,MAAM,KAAK,GAAI,+EAOZ,KAAK,KAAG,GAAG,CAAC,OA2Cd,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/lib/alert/Alert.js
CHANGED
|
@@ -12,12 +12,11 @@ var _ChevronUp = require("@styled-icons/bootstrap/ChevronUp");
|
|
|
12
12
|
var _Bell = require("@styled-icons/bootstrap/Bell");
|
|
13
13
|
var _reactIntl = require("react-intl");
|
|
14
14
|
var _blue = _interopRequireDefault(require("../colors/blue"));
|
|
15
|
-
function
|
|
16
|
-
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; }
|
|
15
|
+
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); }
|
|
17
16
|
const AlertContainer = _styledComponents.default.div.withConfig({
|
|
18
17
|
displayName: "Alert__AlertContainer",
|
|
19
18
|
componentId: "sc-2vlo3n-0"
|
|
20
|
-
})(["background-color:", ";display:grid;grid-template-columns:50px auto auto;grid-template-rows:minmax(25px,auto) auto;
|
|
19
|
+
})(["background-color:", ";display:grid;grid-template-columns:50px auto auto;grid-template-rows:minmax(25px,auto) auto;column-gap:1em;padding:1.5em;svg{align-self:center;grid-column:1;grid-row:1 / span 2;justify-self:center;}button.toggle-btn{background:transparent;border:none;width:40px;svg{transform:", ";transition:all 0.2s ease-in;}}@media (max-width:550px){grid-template-columns:40px auto auto;padding:1.25em 1.25em;}"], props => props.backgroundColor ? props.backgroundColor : _blue.default[50], props => !props.expandAlert && "rotate(180deg)");
|
|
21
20
|
const ButtonContainer = _styledComponents.default.span.withConfig({
|
|
22
21
|
displayName: "Alert__ButtonContainer",
|
|
23
22
|
componentId: "sc-2vlo3n-1"
|
|
@@ -60,6 +59,7 @@ const Alert = ({
|
|
|
60
59
|
size: 24
|
|
61
60
|
}), /*#__PURE__*/_react.default.createElement(AlertHeader, null, alertHeader), /*#__PURE__*/_react.default.createElement(ButtonContainer, null, collapsible && /*#__PURE__*/_react.default.createElement("button", {
|
|
62
61
|
type: "button",
|
|
62
|
+
className: "toggle-btn",
|
|
63
63
|
onClick: () => setExpandAlert(!expandAlert),
|
|
64
64
|
"aria-label": label,
|
|
65
65
|
title: label
|
package/lib/alert/Alert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_interopRequireDefault","_reactAnimateHeight","_ChevronUp","_Bell","_reactIntl","_blue","
|
|
1
|
+
{"version":3,"file":"Alert.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_interopRequireDefault","_reactAnimateHeight","_ChevronUp","_Bell","_reactIntl","_blue","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","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","className","onClick","title","ChevronUp","duration","height","_default","exports"],"sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import React, { 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: JSX.Element | string;\n alertSubheader?: JSX.Element | string;\n backgroundColor?: string;\n /* If true, adds a toggle that expands/collapses the alert content */\n collapsible?: boolean;\n children?: JSX.Element | string;\n /* Icon displayed on Alert - default is Bell */\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 column-gap: 1em;\n padding: 1.5em;\n\n svg {\n align-self: center;\n grid-column: 1;\n grid-row: 1 / span 2;\n justify-self: center;\n }\n\n button.toggle-btn {\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 className=\"toggle-btn\"\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,UAA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AAQf,MAAM,WAAW,KAAM,SAAQ,cAAc,CAAC,WAAW,CAAC;IACxD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;GAIG;AACH,QAAA,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dropdown/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,cAAc,EAMf,MAAM,OAAO,CAAC;AAQf,MAAM,WAAW,KAAM,SAAQ,cAAc,CAAC,WAAW,CAAC;IACxD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;GAIG;AACH,QAAA,MAAM,QAAQ,GAAI,iFASf,KAAK,KAAG,GAAG,CAAC,OAsGd,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/lib/dropdown/index.js
CHANGED
|
@@ -7,8 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _domQuery = require("../focus-trap-wrapper/dom-query");
|
|
9
9
|
var _styled = require("./styled");
|
|
10
|
-
function
|
|
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; }
|
|
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); }
|
|
12
11
|
/**
|
|
13
12
|
* Renders a dropdown menu. By default, only a passed "text" is rendered. If clicked,
|
|
14
13
|
* a floating div is rendered below the "text" with list contents inside. Clicking anywhere
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_domQuery","_styled","
|
|
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,QAA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I,EAAC;EAAQ,gBAEbhD,MAAA,CAAAe,OAAA,CAAAqD,aAAA,eAAOrC,IAAW,CAAC,eACnB/B,MAAA,CAAAe,OAAA,CAAAqD,aAAA;IAAMzC,SAAS,EAAC,OAAO;IAACkD,IAAI,EAAC;EAAc,CAAE,CAC/B,CAAC,EAChB5C,IAAI,iBACHjC,MAAA,CAAAe,OAAA,CAAAqD,aAAA,CAAChE,OAAA,CAAA0E,YAAY;IACXC,EAAE,EAAEtC,MAAM,IAAI,IAAK;IACnB,cAAYX,SAAU;IACtB,mBAAiBA,SAAS,GAAG2C,SAAS,GAAG,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 +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;
|
|
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"}
|
|
@@ -18,8 +18,7 @@ Object.defineProperty(exports, "getPreviousSibling", {
|
|
|
18
18
|
});
|
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
|
20
20
|
var _domQuery = require("./dom-query");
|
|
21
|
-
function
|
|
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; }
|
|
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); }
|
|
23
22
|
const FocusTrapWrapper = ({
|
|
24
23
|
children,
|
|
25
24
|
closePopup = null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_domQuery","
|
|
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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,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;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
|
-
|
|
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;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "Alert", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _Alert.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
Object.defineProperty(exports, "Dropdown", {
|
|
8
14
|
enumerable: true,
|
|
9
15
|
get: function () {
|
|
@@ -34,8 +40,8 @@ var _red = _interopRequireDefault(require("./colors/red"));
|
|
|
34
40
|
var _grey = _interopRequireDefault(require("./colors/grey"));
|
|
35
41
|
var _dropdown = _interopRequireDefault(require("./dropdown"));
|
|
36
42
|
var _focusTrapWrapper = _interopRequireWildcard(require("./focus-trap-wrapper"));
|
|
37
|
-
|
|
38
|
-
function _interopRequireWildcard(e, r) { if (!
|
|
43
|
+
var _Alert = _interopRequireDefault(require("./alert/Alert"));
|
|
44
|
+
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); }
|
|
39
45
|
// TODO: Fix exports
|
|
40
46
|
var _default = exports.default = {
|
|
41
47
|
blue: _blue.default,
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_blue","_interopRequireDefault","require","_red","_grey","_dropdown","_focusTrapWrapper","_interopRequireWildcard","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_blue","_interopRequireDefault","require","_red","_grey","_dropdown","_focusTrapWrapper","_interopRequireWildcard","_Alert","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_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\";\nimport Alert from \"./alert/Alert\";\n\n// TODO: Fix exports\nexport {\n Alert,\n Dropdown,\n FocusTrapWrapper,\n getNextSibling,\n getPreviousSibling\n};\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,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAC,uBAAA,CAAAL,OAAA;AAIA,IAA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orPalette.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColorPalette.d.ts","sourceRoot":"","sources":["../../src/stories/ColorPalette.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,UAAU,KAAK;IACb,KAAK,EAAE,GAAG,CAAC;CACZ;AA0BD,QAAA,MAAM,YAAY,GAAI,WAAW,KAAK,KAAG,GAAG,CAAC,OAiB5C,CAAC;AACF,eAAe,YAAY,CAAC"}
|
|
@@ -7,11 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
-
var
|
|
10
|
+
var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
|
|
11
|
+
const {
|
|
12
|
+
getMostReadableTextColor
|
|
13
|
+
} = _coreUtils.default.route;
|
|
11
14
|
const ColorBlock = _styledComponents.default.div.withConfig({
|
|
12
15
|
displayName: "ColorPalette__ColorBlock",
|
|
13
16
|
componentId: "sc-fil65c-0"
|
|
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 =>
|
|
17
|
+
})(["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 => getMostReadableTextColor(props.hex, "#ffffff"), props => getMostReadableTextColor(props.hex, "#ffffff") === "#ffffff" ? "1px 1px 2px black" : "");
|
|
15
18
|
const ColorPalette = ({
|
|
16
19
|
color
|
|
17
20
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPalette.js","names":["_react","_interopRequireDefault","require","_styledComponents","
|
|
1
|
+
{"version":3,"file":"ColorPalette.js","names":["_react","_interopRequireDefault","require","_styledComponents","_coreUtils","getMostReadableTextColor","coreUtils","route","ColorBlock","styled","div","withConfig","displayName","componentId","props","hex","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 coreUtils from \"@opentripplanner/core-utils\";\n\nconst { getMostReadableTextColor } = coreUtils.route;\n\nexport interface Hue {\n [key: number]: string;\n}\n\ninterface Props {\n color: Hue;\n}\n\nconst ColorBlock = styled.div<{ hex: string }>`\n align-items: center;\n background-color: ${props => props.hex};\n color: ${props => getMostReadableTextColor(props.hex, \"#ffffff\")};\n text-shadow: ${props =>\n getMostReadableTextColor(props.hex, \"#ffffff\") === \"#ffffff\"\n ? \"1px 1px 2px black\"\n : \"\"};\n display: flex;\n font-family: Arial, Helvetica, sans-serif;\n height: 40px;\n justify-content: space-between;\n margin: 0;\n padding: 10px;\n width: 300px;\n\n &:first-of-type {\n border-radius: 8px 8px 0 0;\n }\n &:last-of-type {\n border-radius: 0 0 8px 8px;\n }\n`;\n\nconst ColorPalette = ({ color }: Props): JSX.Element => {\n const colorArray: Array<Hue> = Object.entries(color);\n\n return (\n <>\n {colorArray.map(\n (hue: Hue): JSX.Element => {\n return (\n <ColorBlock key={hue[0]} hex={hue[1]}>\n <p>{hue[0]}</p>\n <p>{hue[1]}</p>\n </ColorBlock>\n );\n }\n )}\n </>\n );\n};\nexport default ColorPalette;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,MAAM;EAAEG;AAAyB,CAAC,GAAGC,kBAAS,CAACC,KAAK;AAUpD,MAAMC,UAAU,GAAGC,yBAAM,CAACC,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,mSAEPC,KAAK,IAAIA,KAAK,CAACC,GAAG,EAC7BD,KAAK,IAAIT,wBAAwB,CAACS,KAAK,CAACC,GAAG,EAAE,SAAS,CAAC,EACjDD,KAAK,IAClBT,wBAAwB,CAACS,KAAK,CAACC,GAAG,EAAE,SAAS,CAAC,KAAK,SAAS,GACxD,mBAAmB,GACnB,EAAE,CAeT;AAED,MAAMC,YAAY,GAAGA,CAAC;EAAEC;AAAa,CAAC,KAAkB;EACtD,MAAMC,UAAsB,GAAGC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC;EAEpD,oBACEjB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,CAAAtB,MAAA,CAAAqB,OAAA,CAAAE,QAAA,QACGL,UAAU,CAACM,GAAG,CACZC,GAAQ,IAAkB;IACzB,oBACEzB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,CAACd,UAAU;MAACkB,GAAG,EAAED,GAAG,CAAC,CAAC,CAAE;MAACV,GAAG,EAAEU,GAAG,CAAC,CAAC;IAAE,gBACnCzB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,YAAIG,GAAG,CAAC,CAAC,CAAK,CAAC,eACfzB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,YAAIG,GAAG,CAAC,CAAC,CAAK,CACJ,CAAC;EAEjB,CACF,CACA,CAAC;AAEP,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAP,OAAA,GACaL,YAAY","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentripplanner/building-blocks",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Styling and UI Component Library",
|
|
5
5
|
"author": "@binh-dam-ibigroup",
|
|
6
6
|
"homepage": "https://github.com/opentripplanner/otp-ui/#readme",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"module": "esm/index.js",
|
|
10
10
|
"private": false,
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@opentripplanner/types": "
|
|
13
|
-
"@opentripplanner/core-utils": "
|
|
12
|
+
"@opentripplanner/types": "8.3.1",
|
|
13
|
+
"@opentripplanner/core-utils": "15.0.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": "^18.2.0",
|
package/src/alert/Alert.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import AnimateHeight from "react-animate-height";
|
|
4
4
|
import { ChevronUp } from "@styled-icons/bootstrap/ChevronUp";
|
|
@@ -8,11 +8,13 @@ import { useIntl } from "react-intl";
|
|
|
8
8
|
import blue from "../colors/blue";
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
|
-
alertHeader: string;
|
|
12
|
-
alertSubheader?: string;
|
|
11
|
+
alertHeader: JSX.Element | string;
|
|
12
|
+
alertSubheader?: JSX.Element | string;
|
|
13
13
|
backgroundColor?: string;
|
|
14
|
+
/* If true, adds a toggle that expands/collapses the alert content */
|
|
14
15
|
collapsible?: boolean;
|
|
15
|
-
children?:
|
|
16
|
+
children?: JSX.Element | string;
|
|
17
|
+
/* Icon displayed on Alert - default is Bell */
|
|
16
18
|
Icon?: StyledIcon;
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -26,17 +28,17 @@ const AlertContainer = styled.div<{
|
|
|
26
28
|
display: grid;
|
|
27
29
|
grid-template-columns: 50px auto auto;
|
|
28
30
|
grid-template-rows: minmax(25px, auto) auto;
|
|
29
|
-
|
|
30
|
-
padding: 1.5em
|
|
31
|
+
column-gap: 1em;
|
|
32
|
+
padding: 1.5em;
|
|
31
33
|
|
|
32
34
|
svg {
|
|
33
35
|
align-self: center;
|
|
34
36
|
grid-column: 1;
|
|
35
37
|
grid-row: 1 / span 2;
|
|
36
|
-
justify-self:
|
|
38
|
+
justify-self: center;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
button {
|
|
41
|
+
button.toggle-btn {
|
|
40
42
|
background: transparent;
|
|
41
43
|
border: none;
|
|
42
44
|
width: 40px;
|
|
@@ -108,6 +110,7 @@ const Alert = ({
|
|
|
108
110
|
{collapsible && (
|
|
109
111
|
<button
|
|
110
112
|
type="button"
|
|
113
|
+
className="toggle-btn"
|
|
111
114
|
onClick={() => setExpandAlert(!expandAlert)}
|
|
112
115
|
aria-label={label}
|
|
113
116
|
title={label}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,14 @@ import FocusTrapWrapper, {
|
|
|
6
6
|
getNextSibling,
|
|
7
7
|
getPreviousSibling
|
|
8
8
|
} from "./focus-trap-wrapper";
|
|
9
|
+
import Alert from "./alert/Alert";
|
|
9
10
|
|
|
10
11
|
// TODO: Fix exports
|
|
11
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
Alert,
|
|
14
|
+
Dropdown,
|
|
15
|
+
FocusTrapWrapper,
|
|
16
|
+
getNextSibling,
|
|
17
|
+
getPreviousSibling
|
|
18
|
+
};
|
|
12
19
|
export default { blue, red, grey };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import styled from "styled-components";
|
|
4
|
-
import
|
|
4
|
+
import coreUtils from "@opentripplanner/core-utils";
|
|
5
|
+
|
|
6
|
+
const { getMostReadableTextColor } = coreUtils.route;
|
|
5
7
|
|
|
6
8
|
export interface Hue {
|
|
7
9
|
[key: number]: string;
|