@opentripplanner/from-to-location-picker 1.2.2-alpha.1 → 2.0.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/index.js CHANGED
@@ -1,148 +1,78 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
-
7
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
- import coreUtils from "@opentripplanner/core-utils";
1
+ import flatten from "flat";
12
2
  import LocationIcon from "@opentripplanner/location-icon";
13
- import PropTypes from "prop-types";
14
- import React, { Component } from "react";
15
- import { LocationPickerSpan, Button, FromToPickerSpan } from "./styled";
16
- var iconSize = "0.9em";
17
-
18
- var FromToLocationPicker = /*#__PURE__*/function (_Component) {
19
- _inherits(FromToLocationPicker, _Component);
20
-
21
- var _super = _createSuper(FromToLocationPicker);
22
-
23
- function FromToLocationPicker() {
24
- var _this;
25
-
26
- _classCallCheck(this, FromToLocationPicker);
27
-
28
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
- args[_key] = arguments[_key];
3
+ import { FormattedMessage } from "react-intl";
4
+ import React from "react";
5
+ import * as S from "./styled"; // eslint-disable-next-line prettier/prettier
6
+
7
+ // Load the default messages.
8
+ import defaultEnglishMessages from "../i18n/en-US.yml";
9
+ var iconSize = "0.9em"; // HACK: We should flatten the messages loaded above because
10
+ // the YAML loaders behave differently between webpack and our version of jest:
11
+ // - the yaml loader for webpack returns a nested object,
12
+ // - the yaml loader for jest returns messages with flattened ids.
13
+
14
+ var defaultMessages = flatten(defaultEnglishMessages);
15
+
16
+ var FromToLocationPicker = function FromToLocationPicker(_ref) {
17
+ var _ref$location = _ref.location,
18
+ location = _ref$location === void 0 ? null : _ref$location,
19
+ _ref$onFromClick = _ref.onFromClick,
20
+ onFromClick = _ref$onFromClick === void 0 ? null : _ref$onFromClick,
21
+ _ref$onToClick = _ref.onToClick,
22
+ onToClick = _ref$onToClick === void 0 ? null : _ref$onToClick,
23
+ _ref$setLocation = _ref.setLocation,
24
+ setLocation = _ref$setLocation === void 0 ? null : _ref$setLocation,
25
+ _ref$showIcons = _ref.showIcons,
26
+ showIcons = _ref$showIcons === void 0 ? true : _ref$showIcons;
27
+
28
+ var handleFromClick = function handleFromClick() {
29
+ if (onFromClick) {
30
+ onFromClick();
31
+ return;
30
32
  }
31
33
 
32
- _this = _super.call.apply(_super, [this].concat(args));
33
-
34
- _this.onFromClick = function () {
35
- var _this$props = _this.props,
36
- location = _this$props.location,
37
- onFromClick = _this$props.onFromClick,
38
- setLocation = _this$props.setLocation;
39
-
40
- if (onFromClick) {
41
- onFromClick();
42
- return;
43
- }
44
-
45
- setLocation({
46
- location: location,
47
- locationType: "from",
48
- reverseGeocode: false
49
- });
50
- };
51
-
52
- _this.onToClick = function () {
53
- var _this$props2 = _this.props,
54
- location = _this$props2.location,
55
- onToClick = _this$props2.onToClick,
56
- setLocation = _this$props2.setLocation;
57
-
58
- if (onToClick) {
59
- onToClick();
60
- return;
61
- }
62
-
63
- setLocation({
64
- location: location,
65
- locationType: "to",
66
- reverseGeocode: false
67
- });
68
- };
69
-
70
- return _this;
71
- }
72
-
73
- _createClass(FromToLocationPicker, [{
74
- key: "render",
75
- value: function render() {
76
- var _this$props3 = this.props,
77
- fromText = _this$props3.fromText,
78
- showIcons = _this$props3.showIcons,
79
- toText = _this$props3.toText;
80
- return /*#__PURE__*/React.createElement(FromToPickerSpan, null, /*#__PURE__*/React.createElement(LocationPickerSpan, null, showIcons && /*#__PURE__*/React.createElement(LocationIcon, {
81
- type: "from",
82
- size: iconSize
83
- }), /*#__PURE__*/React.createElement(Button, {
84
- onClick: this.onFromClick
85
- }, fromText)), /*#__PURE__*/React.createElement(LocationPickerSpan, null, showIcons && /*#__PURE__*/React.createElement(LocationIcon, {
86
- type: "to",
87
- size: iconSize
88
- }), /*#__PURE__*/React.createElement(Button, {
89
- onClick: this.onToClick
90
- }, toText)));
34
+ setLocation({
35
+ location: location,
36
+ locationType: "from",
37
+ reverseGeocode: false
38
+ });
39
+ };
40
+
41
+ var handleToClick = function handleToClick() {
42
+ if (onToClick) {
43
+ onToClick();
44
+ return;
91
45
  }
92
- }]);
93
-
94
- return FromToLocationPicker;
95
- }(Component);
96
-
97
- FromToLocationPicker.propTypes = {
98
- /**
99
- * The text to display on the "from" button for setting the origin of a trip.
100
- */
101
- fromText: PropTypes.string,
102
46
 
103
- /**
104
- * A specific location to associate with this. This is only used when combined
105
- * with the setLocation prop.
106
- */
107
- location: coreUtils.types.locationType,
108
-
109
- /**
110
- * Triggered when the user clicks on the "from" button.
111
- */
112
- onFromClick: PropTypes.func,
113
-
114
- /**
115
- * Triggered when the user clicks on the "to" button.
116
- */
117
- onToClick: PropTypes.func,
118
-
119
- /**
120
- * The text to display on the "to" button for setting the destination of a trip.
121
- */
122
- toText: PropTypes.string,
47
+ setLocation({
48
+ location: location,
49
+ locationType: "to",
50
+ reverseGeocode: false
51
+ });
52
+ };
53
+
54
+ return /*#__PURE__*/React.createElement(S.FromToPickerSpan, null, /*#__PURE__*/React.createElement(S.LocationPickerSpan, null, showIcons && /*#__PURE__*/React.createElement(LocationIcon, {
55
+ type: "from",
56
+ size: iconSize
57
+ }), /*#__PURE__*/React.createElement(S.Button, {
58
+ onClick: handleFromClick
59
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
60
+ defaultMessage: defaultMessages["otpUi.FromToLocationPicker.from"],
61
+ description: "Text for the 'from' button of the picker",
62
+ id: "otpUi.FromToLocationPicker.from"
63
+ }))), /*#__PURE__*/React.createElement(S.LocationPickerSpan, null, showIcons && /*#__PURE__*/React.createElement(LocationIcon, {
64
+ type: "to",
65
+ size: iconSize
66
+ }), /*#__PURE__*/React.createElement(S.Button, {
67
+ onClick: handleToClick
68
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
69
+ defaultMessage: defaultMessages["otpUi.FromToLocationPicker.to"],
70
+ description: "Text for the 'to' button of the picker",
71
+ id: "otpUi.FromToLocationPicker.to"
72
+ }))));
73
+ };
123
74
 
124
- /**
125
- * Triggered when the user clicks either the "from" or "to" button and there
126
- * are no from/to specific handler functions defined as props.
127
- *
128
- * Passes an argument as follows:
129
- * { locationType: "from/to", location, reverseGeocode: false }
130
- */
131
- setLocation: PropTypes.func,
75
+ export default FromToLocationPicker; // Rename styled components for export
132
76
 
133
- /**
134
- * Determines whether icons are shown on the "from" and "to" buttons.
135
- */
136
- showIcons: PropTypes.bool
137
- };
138
- FromToLocationPicker.defaultProps = {
139
- fromText: "From here",
140
- location: null,
141
- onFromClick: null,
142
- onToClick: null,
143
- setLocation: null,
144
- showIcons: true,
145
- toText: "To here"
146
- };
147
- export default FromToLocationPicker;
77
+ export { S as Styled };
148
78
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["coreUtils","LocationIcon","PropTypes","React","Component","LocationPickerSpan","Button","FromToPickerSpan","iconSize","FromToLocationPicker","onFromClick","props","location","setLocation","locationType","reverseGeocode","onToClick","fromText","showIcons","toText","propTypes","string","types","func","bool","defaultProps"],"mappings":";;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,6B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@opentripplanner/core-utils\";\nimport LocationIcon from \"@opentripplanner/location-icon\";\nimport PropTypes from \"prop-types\";\nimport React, { Component } from \"react\";\n\nimport { LocationPickerSpan, Button, FromToPickerSpan } from \"./styled\";\n\nconst iconSize = \"0.9em\";\n\nclass FromToLocationPicker extends Component {\n onFromClick = () => {\n const { location, onFromClick, setLocation } = this.props;\n if (onFromClick) {\n onFromClick();\n return;\n }\n setLocation({\n location,\n locationType: \"from\",\n reverseGeocode: false\n });\n };\n\n onToClick = () => {\n const { location, onToClick, setLocation } = this.props;\n if (onToClick) {\n onToClick();\n return;\n }\n setLocation({\n location,\n locationType: \"to\",\n reverseGeocode: false\n });\n };\n\n render() {\n const { fromText, showIcons, toText } = this.props;\n return (\n <FromToPickerSpan>\n <LocationPickerSpan>\n {showIcons && <LocationIcon type=\"from\" size={iconSize} />}\n <Button onClick={this.onFromClick}>{fromText}</Button>\n </LocationPickerSpan>\n <LocationPickerSpan>\n {showIcons && <LocationIcon type=\"to\" size={iconSize} />}\n <Button onClick={this.onToClick}>{toText}</Button>\n </LocationPickerSpan>\n </FromToPickerSpan>\n );\n }\n}\n\nFromToLocationPicker.propTypes = {\n /**\n * The text to display on the \"from\" button for setting the origin of a trip.\n */\n fromText: PropTypes.string,\n /**\n * A specific location to associate with this. This is only used when combined\n * with the setLocation prop.\n */\n location: coreUtils.types.locationType,\n /**\n * Triggered when the user clicks on the \"from\" button.\n */\n onFromClick: PropTypes.func,\n /**\n * Triggered when the user clicks on the \"to\" button.\n */\n onToClick: PropTypes.func,\n /**\n * The text to display on the \"to\" button for setting the destination of a trip.\n */\n toText: PropTypes.string,\n /**\n * Triggered when the user clicks either the \"from\" or \"to\" button and there\n * are no from/to specific handler functions defined as props.\n *\n * Passes an argument as follows:\n * { locationType: \"from/to\", location, reverseGeocode: false }\n */\n setLocation: PropTypes.func,\n /**\n * Determines whether icons are shown on the \"from\" and \"to\" buttons.\n */\n showIcons: PropTypes.bool\n};\n\nFromToLocationPicker.defaultProps = {\n fromText: \"From here\",\n location: null,\n onFromClick: null,\n onToClick: null,\n setLocation: null,\n showIcons: true,\n toText: \"To here\"\n};\n\nexport default FromToLocationPicker;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["flatten","LocationIcon","FormattedMessage","React","S","defaultEnglishMessages","iconSize","defaultMessages","FromToLocationPicker","location","onFromClick","onToClick","setLocation","showIcons","handleFromClick","locationType","reverseGeocode","handleToClick","Styled"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,MAApB;AACA,OAAOC,YAAP,MAAyB,gCAAzB;AACA,SAASC,gBAAT,QAAiC,YAAjC;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB,C,CAEA;;AAGA;AACA,OAAOC,sBAAP,MAAmC,mBAAnC;AAEA,IAAMC,QAAQ,GAAG,OAAjB,C,CAEA;AACA;AACA;AACA;;AACA,IAAMC,eAAuC,GAAGP,OAAO,CAACK,sBAAD,CAAvD;;AAEA,IAAMG,oBAAoB,GAAG,SAAvBA,oBAAuB,OAMgB;AAAA,2BAL3CC,QAK2C;AAAA,MAL3CA,QAK2C,8BALhC,IAKgC;AAAA,8BAJ3CC,WAI2C;AAAA,MAJ3CA,WAI2C,iCAJ7B,IAI6B;AAAA,4BAH3CC,SAG2C;AAAA,MAH3CA,SAG2C,+BAH/B,IAG+B;AAAA,8BAF3CC,WAE2C;AAAA,MAF3CA,WAE2C,iCAF7B,IAE6B;AAAA,4BAD3CC,SAC2C;AAAA,MAD3CA,SAC2C,+BAD/B,IAC+B;;AAC3C,MAAMC,eAAe,GAAG,SAAlBA,eAAkB,GAAM;AAC5B,QAAIJ,WAAJ,EAAiB;AACfA,MAAAA,WAAW;AACX;AACD;;AACDE,IAAAA,WAAW,CAAC;AACVH,MAAAA,QAAQ,EAARA,QADU;AAEVM,MAAAA,YAAY,EAAE,MAFJ;AAGVC,MAAAA,cAAc,EAAE;AAHN,KAAD,CAAX;AAKD,GAVD;;AAYA,MAAMC,aAAa,GAAG,SAAhBA,aAAgB,GAAM;AAC1B,QAAIN,SAAJ,EAAe;AACbA,MAAAA,SAAS;AACT;AACD;;AACDC,IAAAA,WAAW,CAAC;AACVH,MAAAA,QAAQ,EAARA,QADU;AAEVM,MAAAA,YAAY,EAAE,IAFJ;AAGVC,MAAAA,cAAc,EAAE;AAHN,KAAD,CAAX;AAKD,GAVD;;AAYA,sBACE,oBAAC,CAAD,CAAG,gBAAH,qBACE,oBAAC,CAAD,CAAG,kBAAH,QACGH,SAAS,iBAAI,oBAAC,YAAD;AAAc,IAAA,IAAI,EAAC,MAAnB;AAA0B,IAAA,IAAI,EAAEP;AAAhC,IADhB,eAEE,oBAAC,CAAD,CAAG,MAAH;AAAU,IAAA,OAAO,EAAEQ;AAAnB,kBACE,oBAAC,gBAAD;AACE,IAAA,cAAc,EAAEP,eAAe,CAAC,iCAAD,CADjC;AAEE,IAAA,WAAW,EAAC,0CAFd;AAGE,IAAA,EAAE,EAAC;AAHL,IADF,CAFF,CADF,eAWE,oBAAC,CAAD,CAAG,kBAAH,QACGM,SAAS,iBAAI,oBAAC,YAAD;AAAc,IAAA,IAAI,EAAC,IAAnB;AAAwB,IAAA,IAAI,EAAEP;AAA9B,IADhB,eAEE,oBAAC,CAAD,CAAG,MAAH;AAAU,IAAA,OAAO,EAAEW;AAAnB,kBACE,oBAAC,gBAAD;AACE,IAAA,cAAc,EAAEV,eAAe,CAAC,+BAAD,CADjC;AAEE,IAAA,WAAW,EAAC,wCAFd;AAGE,IAAA,EAAE,EAAC;AAHL,IADF,CAFF,CAXF,CADF;AAwBD,CAvDD;;AAyDA,eAAeC,oBAAf,C,CAEA;;AACA,SAASJ,CAAC,IAAIc,MAAd","sourcesContent":["import flatten from \"flat\";\nimport LocationIcon from \"@opentripplanner/location-icon\";\nimport { FormattedMessage } from \"react-intl\";\nimport React from \"react\";\n\nimport * as S from \"./styled\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { FromToPickerProps } from \"./types\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\n\nconst iconSize = \"0.9em\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nconst defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);\n\nconst FromToLocationPicker = ({\n location = null,\n onFromClick = null,\n onToClick = null,\n setLocation = null,\n showIcons = true\n}: FromToPickerProps): React.ReactElement => {\n const handleFromClick = () => {\n if (onFromClick) {\n onFromClick();\n return;\n }\n setLocation({\n location,\n locationType: \"from\",\n reverseGeocode: false\n });\n };\n\n const handleToClick = () => {\n if (onToClick) {\n onToClick();\n return;\n }\n setLocation({\n location,\n locationType: \"to\",\n reverseGeocode: false\n });\n };\n\n return (\n <S.FromToPickerSpan>\n <S.LocationPickerSpan>\n {showIcons && <LocationIcon type=\"from\" size={iconSize} />}\n <S.Button onClick={handleFromClick}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.FromToLocationPicker.from\"]}\n description=\"Text for the 'from' button of the picker\"\n id=\"otpUi.FromToLocationPicker.from\"\n />\n </S.Button>\n </S.LocationPickerSpan>\n <S.LocationPickerSpan>\n {showIcons && <LocationIcon type=\"to\" size={iconSize} />}\n <S.Button onClick={handleToClick}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.FromToLocationPicker.to\"]}\n description=\"Text for the 'to' button of the picker\"\n id=\"otpUi.FromToLocationPicker.to\"\n />\n </S.Button>\n </S.LocationPickerSpan>\n </S.FromToPickerSpan>\n );\n};\n\nexport default FromToLocationPicker;\n\n// Rename styled components for export\nexport { S as Styled };\n"],"file":"index.js"}
package/esm/styled.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import styled from "styled-components";
2
2
  export var LocationPickerSpan = styled.span.withConfig({
3
3
  displayName: "styled__LocationPickerSpan",
4
- componentId: "p56b41-0"
4
+ componentId: "vb4790-0"
5
5
  })([":first-of-type{border-left:none;}"]);
6
6
  export var FromToPickerSpan = styled.span.withConfig({
7
7
  displayName: "styled__FromToPickerSpan",
8
- componentId: "p56b41-1"
8
+ componentId: "vb4790-1"
9
9
  })(["> *{padding-left:0.4em;border-left:1px solid black;}"]);
10
10
  export var Button = styled.button.withConfig({
11
11
  displayName: "styled__Button",
12
- componentId: "p56b41-2"
12
+ componentId: "vb4790-2"
13
13
  })(["background:none;border:none;color:navy;font-family:inherit;font-size:inherit;line-height:inherit;padding-left:0.2em;:hover{text-decoration:underline;cursor:pointer;}"]);
14
14
  //# sourceMappingURL=styled.js.map
package/esm/styled.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styled.js"],"names":["styled","LocationPickerSpan","span","FromToPickerSpan","Button","button"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,mBAAnB;AAEA,OAAO,IAAMC,kBAAkB,GAAGD,MAAM,CAACE,IAAV;AAAA;AAAA;AAAA,yCAAxB;AAMP,OAAO,IAAMC,gBAAgB,GAAGH,MAAM,CAACE,IAAV;AAAA;AAAA;AAAA,4DAAtB;AAOP,OAAO,IAAME,MAAM,GAAGJ,MAAM,CAACK,MAAV;AAAA;AAAA;AAAA,6KAAZ","sourcesContent":["import styled from \"styled-components\";\n\nexport const LocationPickerSpan = styled.span`\n :first-of-type {\n border-left: none;\n }\n`;\n\nexport const FromToPickerSpan = styled.span`\n > * {\n padding-left: 0.4em;\n border-left: 1px solid black;\n }\n`;\n\nexport const Button = styled.button`\n background: none;\n border: none;\n color: navy;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n padding-left: 0.2em;\n\n :hover {\n text-decoration: underline;\n cursor: pointer;\n }\n`;\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../src/styled.ts"],"names":["styled","LocationPickerSpan","span","FromToPickerSpan","Button","button"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,mBAAnB;AAEA,OAAO,IAAMC,kBAAkB,GAAGD,MAAM,CAACE,IAAV;AAAA;AAAA;AAAA,yCAAxB;AAMP,OAAO,IAAMC,gBAAgB,GAAGH,MAAM,CAACE,IAAV;AAAA;AAAA;AAAA,4DAAtB;AAOP,OAAO,IAAME,MAAM,GAAGJ,MAAM,CAACK,MAAV;AAAA;AAAA;AAAA,6KAAZ","sourcesContent":["import styled from \"styled-components\";\n\nexport const LocationPickerSpan = styled.span`\n :first-of-type {\n border-left: none;\n }\n`;\n\nexport const FromToPickerSpan = styled.span`\n > * {\n padding-left: 0.4em;\n border-left: 1px solid black;\n }\n`;\n\nexport const Button = styled.button`\n background: none;\n border: none;\n color: navy;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n padding-left: 0.2em;\n\n :hover {\n text-decoration: underline;\n cursor: pointer;\n }\n`;\n"],"file":"styled.js"}
package/esm/types.js ADDED
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"}
package/i18n/en-US.yml ADDED
@@ -0,0 +1,14 @@
1
+ # Default messages for the FromToLocationPicker component.
2
+ # To use from a react-intl application:
3
+ # - merge the content of this file into the messages object
4
+ # that has your other localized strings,
5
+ # - flatten the ids, i.e. convert a structure such as
6
+ # otpUi > FromToLocationPicker > from
7
+ # into "otpUi.FromToLocationPicker.from" (see FromToLocationPicker story for an example),
8
+ # - pass the resulting object to the messages prop of IntlProvider.
9
+ #
10
+
11
+ otpUi:
12
+ FromToLocationPicker:
13
+ from: From here
14
+ to: To here
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import * as S from "./styled";
3
+ import type { FromToPickerProps } from "./types";
4
+ declare const FromToLocationPicker: ({ location, onFromClick, onToClick, setLocation, showIcons }: FromToPickerProps) => React.ReactElement;
5
+ export default FromToLocationPicker;
6
+ export { S as Styled };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAajD,QAAA,MAAM,oBAAoB,iEAMvB,iBAAiB,KAAG,MAAM,YAiD5B,CAAC;AAEF,eAAe,oBAAoB,CAAC;AAGpC,OAAO,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -5,138 +5,89 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.Styled = exports.default = void 0;
9
9
 
10
- var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
10
+ var _flat = _interopRequireDefault(require("flat"));
11
11
 
12
12
  var _locationIcon = _interopRequireDefault(require("@opentripplanner/location-icon"));
13
13
 
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _reactIntl = require("react-intl");
15
15
 
16
- var _react = _interopRequireWildcard(require("react"));
16
+ var _react = _interopRequireDefault(require("react"));
17
17
 
18
- var _styled = require("./styled");
18
+ var S = _interopRequireWildcard(require("./styled"));
19
+
20
+ exports.Styled = S;
21
+
22
+ var _enUS = _interopRequireDefault(require("../i18n/en-US.yml"));
19
23
 
20
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); }
21
25
 
22
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; }
23
27
 
24
- const iconSize = "0.9em";
25
-
26
- class FromToLocationPicker extends _react.Component {
27
- constructor(...args) {
28
- super(...args);
29
-
30
- this.onFromClick = () => {
31
- const {
32
- location,
33
- onFromClick,
34
- setLocation
35
- } = this.props;
36
-
37
- if (onFromClick) {
38
- onFromClick();
39
- return;
40
- }
41
-
42
- setLocation({
43
- location,
44
- locationType: "from",
45
- reverseGeocode: false
46
- });
47
- };
48
-
49
- this.onToClick = () => {
50
- const {
51
- location,
52
- onToClick,
53
- setLocation
54
- } = this.props;
55
-
56
- if (onToClick) {
57
- onToClick();
58
- return;
59
- }
60
-
61
- setLocation({
62
- location,
63
- locationType: "to",
64
- reverseGeocode: false
65
- });
66
- };
67
- }
68
-
69
- render() {
70
- const {
71
- fromText,
72
- showIcons,
73
- toText
74
- } = this.props;
75
- return /*#__PURE__*/_react.default.createElement(_styled.FromToPickerSpan, null, /*#__PURE__*/_react.default.createElement(_styled.LocationPickerSpan, null, showIcons && /*#__PURE__*/_react.default.createElement(_locationIcon.default, {
76
- type: "from",
77
- size: iconSize
78
- }), /*#__PURE__*/_react.default.createElement(_styled.Button, {
79
- onClick: this.onFromClick
80
- }, fromText)), /*#__PURE__*/_react.default.createElement(_styled.LocationPickerSpan, null, showIcons && /*#__PURE__*/_react.default.createElement(_locationIcon.default, {
81
- type: "to",
82
- size: iconSize
83
- }), /*#__PURE__*/_react.default.createElement(_styled.Button, {
84
- onClick: this.onToClick
85
- }, toText)));
86
- }
87
-
88
- }
89
-
90
- FromToLocationPicker.propTypes = {
91
- /**
92
- * The text to display on the "from" button for setting the origin of a trip.
93
- */
94
- fromText: _propTypes.default.string,
95
-
96
- /**
97
- * A specific location to associate with this. This is only used when combined
98
- * with the setLocation prop.
99
- */
100
- location: _coreUtils.default.types.locationType,
101
-
102
- /**
103
- * Triggered when the user clicks on the "from" button.
104
- */
105
- onFromClick: _propTypes.default.func,
106
-
107
- /**
108
- * Triggered when the user clicks on the "to" button.
109
- */
110
- onToClick: _propTypes.default.func,
111
-
112
- /**
113
- * The text to display on the "to" button for setting the destination of a trip.
114
- */
115
- toText: _propTypes.default.string,
116
-
117
- /**
118
- * Triggered when the user clicks either the "from" or "to" button and there
119
- * are no from/to specific handler functions defined as props.
120
- *
121
- * Passes an argument as follows:
122
- * { locationType: "from/to", location, reverseGeocode: false }
123
- */
124
- setLocation: _propTypes.default.func,
125
-
126
- /**
127
- * Determines whether icons are shown on the "from" and "to" buttons.
128
- */
129
- showIcons: _propTypes.default.bool
130
- };
131
- FromToLocationPicker.defaultProps = {
132
- fromText: "From here",
133
- location: null,
134
- onFromClick: null,
135
- onToClick: null,
136
- setLocation: null,
137
- showIcons: true,
138
- toText: "To here"
28
+ // Load the default messages.
29
+ const iconSize = "0.9em"; // HACK: We should flatten the messages loaded above because
30
+ // the YAML loaders behave differently between webpack and our version of jest:
31
+ // - the yaml loader for webpack returns a nested object,
32
+ // - the yaml loader for jest returns messages with flattened ids.
33
+
34
+ const defaultMessages = (0, _flat.default)(_enUS.default);
35
+
36
+ const FromToLocationPicker = ({
37
+ location = null,
38
+ onFromClick = null,
39
+ onToClick = null,
40
+ setLocation = null,
41
+ showIcons = true
42
+ }) => {
43
+ const handleFromClick = () => {
44
+ if (onFromClick) {
45
+ onFromClick();
46
+ return;
47
+ }
48
+
49
+ setLocation({
50
+ location,
51
+ locationType: "from",
52
+ reverseGeocode: false
53
+ });
54
+ };
55
+
56
+ const handleToClick = () => {
57
+ if (onToClick) {
58
+ onToClick();
59
+ return;
60
+ }
61
+
62
+ setLocation({
63
+ location,
64
+ locationType: "to",
65
+ reverseGeocode: false
66
+ });
67
+ };
68
+
69
+ return /*#__PURE__*/_react.default.createElement(S.FromToPickerSpan, null, /*#__PURE__*/_react.default.createElement(S.LocationPickerSpan, null, showIcons && /*#__PURE__*/_react.default.createElement(_locationIcon.default, {
70
+ type: "from",
71
+ size: iconSize
72
+ }), /*#__PURE__*/_react.default.createElement(S.Button, {
73
+ onClick: handleFromClick
74
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
75
+ defaultMessage: defaultMessages["otpUi.FromToLocationPicker.from"],
76
+ description: "Text for the 'from' button of the picker",
77
+ id: "otpUi.FromToLocationPicker.from"
78
+ }))), /*#__PURE__*/_react.default.createElement(S.LocationPickerSpan, null, showIcons && /*#__PURE__*/_react.default.createElement(_locationIcon.default, {
79
+ type: "to",
80
+ size: iconSize
81
+ }), /*#__PURE__*/_react.default.createElement(S.Button, {
82
+ onClick: handleToClick
83
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
84
+ defaultMessage: defaultMessages["otpUi.FromToLocationPicker.to"],
85
+ description: "Text for the 'to' button of the picker",
86
+ id: "otpUi.FromToLocationPicker.to"
87
+ }))));
139
88
  };
140
- var _default = FromToLocationPicker;
89
+
90
+ var _default = FromToLocationPicker; // Rename styled components for export
91
+
141
92
  exports.default = _default;
142
93
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["iconSize","FromToLocationPicker","Component","onFromClick","location","setLocation","props","locationType","reverseGeocode","onToClick","render","fromText","showIcons","toText","propTypes","PropTypes","string","coreUtils","types","func","bool","defaultProps"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,MAAMA,QAAQ,GAAG,OAAjB;;AAEA,MAAMC,oBAAN,SAAmCC,gBAAnC,CAA6C;AAAA;AAAA;;AAAA,S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ADF;AAYD;;AAzC0C;;AA4C7CZ,oBAAoB,CAACa,SAArB,GAAiC;AAC/B;AACF;AACA;AACEH,EAAAA,QAAQ,EAAEI,mBAAUC,MAJW;;AAK/B;AACF;AACA;AACA;AACEZ,EAAAA,QAAQ,EAAEa,mBAAUC,KAAV,CAAgBX,YATK;;AAU/B;AACF;AACA;AACEJ,EAAAA,WAAW,EAAEY,mBAAUI,IAbQ;;AAc/B;AACF;AACA;AACEV,EAAAA,SAAS,EAAEM,mBAAUI,IAjBU;;AAkB/B;AACF;AACA;AACEN,EAAAA,MAAM,EAAEE,mBAAUC,MArBa;;AAsB/B;AACF;AACA;AACA;AACA;AACA;AACA;AACEX,EAAAA,WAAW,EAAEU,mBAAUI,IA7BQ;;AA8B/B;AACF;AACA;AACEP,EAAAA,SAAS,EAAEG,mBAAUK;AAjCU,CAAjC;AAoCAnB,oBAAoB,CAACoB,YAArB,GAAoC;AAClCV,EAAAA,QAAQ,EAAE,WADwB;AAElCP,EAAAA,QAAQ,EAAE,IAFwB;AAGlCD,EAAAA,WAAW,EAAE,IAHqB;AAIlCM,EAAAA,SAAS,EAAE,IAJuB;AAKlCJ,EAAAA,WAAW,EAAE,IALqB;AAMlCO,EAAAA,SAAS,EAAE,IANuB;AAOlCC,EAAAA,MAAM,EAAE;AAP0B,CAApC;eAUeZ,oB","sourcesContent":["import coreUtils from \"@opentripplanner/core-utils\";\nimport LocationIcon from \"@opentripplanner/location-icon\";\nimport PropTypes from \"prop-types\";\nimport React, { Component } from \"react\";\n\nimport { LocationPickerSpan, Button, FromToPickerSpan } from \"./styled\";\n\nconst iconSize = \"0.9em\";\n\nclass FromToLocationPicker extends Component {\n onFromClick = () => {\n const { location, onFromClick, setLocation } = this.props;\n if (onFromClick) {\n onFromClick();\n return;\n }\n setLocation({\n location,\n locationType: \"from\",\n reverseGeocode: false\n });\n };\n\n onToClick = () => {\n const { location, onToClick, setLocation } = this.props;\n if (onToClick) {\n onToClick();\n return;\n }\n setLocation({\n location,\n locationType: \"to\",\n reverseGeocode: false\n });\n };\n\n render() {\n const { fromText, showIcons, toText } = this.props;\n return (\n <FromToPickerSpan>\n <LocationPickerSpan>\n {showIcons && <LocationIcon type=\"from\" size={iconSize} />}\n <Button onClick={this.onFromClick}>{fromText}</Button>\n </LocationPickerSpan>\n <LocationPickerSpan>\n {showIcons && <LocationIcon type=\"to\" size={iconSize} />}\n <Button onClick={this.onToClick}>{toText}</Button>\n </LocationPickerSpan>\n </FromToPickerSpan>\n );\n }\n}\n\nFromToLocationPicker.propTypes = {\n /**\n * The text to display on the \"from\" button for setting the origin of a trip.\n */\n fromText: PropTypes.string,\n /**\n * A specific location to associate with this. This is only used when combined\n * with the setLocation prop.\n */\n location: coreUtils.types.locationType,\n /**\n * Triggered when the user clicks on the \"from\" button.\n */\n onFromClick: PropTypes.func,\n /**\n * Triggered when the user clicks on the \"to\" button.\n */\n onToClick: PropTypes.func,\n /**\n * The text to display on the \"to\" button for setting the destination of a trip.\n */\n toText: PropTypes.string,\n /**\n * Triggered when the user clicks either the \"from\" or \"to\" button and there\n * are no from/to specific handler functions defined as props.\n *\n * Passes an argument as follows:\n * { locationType: \"from/to\", location, reverseGeocode: false }\n */\n setLocation: PropTypes.func,\n /**\n * Determines whether icons are shown on the \"from\" and \"to\" buttons.\n */\n showIcons: PropTypes.bool\n};\n\nFromToLocationPicker.defaultProps = {\n fromText: \"From here\",\n location: null,\n onFromClick: null,\n onToClick: null,\n setLocation: null,\n showIcons: true,\n toText: \"To here\"\n};\n\nexport default FromToLocationPicker;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["iconSize","defaultMessages","defaultEnglishMessages","FromToLocationPicker","location","onFromClick","onToClick","setLocation","showIcons","handleFromClick","locationType","reverseGeocode","handleToClick"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;AAMA;;;;;;AADA;AAGA,MAAMA,QAAQ,GAAG,OAAjB,C,CAEA;AACA;AACA;AACA;;AAC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,eAEE,6BAAC,CAAD,CAAG,MAAH;AAAU,IAAA,OAAO,EAAEY;AAAnB,kBACE,6BAAC,2BAAD;AACE,IAAA,cAAc,EAAEX,eAAe,CAAC,+BAAD,CADjC;AAEE,IAAA,WAAW,EAAC,wCAFd;AAGE,IAAA,EAAE,EAAC;AAHL,IADF,CAFF,CAXF,CADF;AAwBD,CAvDD;;eAyDeE,oB,EAEf","sourcesContent":["import flatten from \"flat\";\nimport LocationIcon from \"@opentripplanner/location-icon\";\nimport { FormattedMessage } from \"react-intl\";\nimport React from \"react\";\n\nimport * as S from \"./styled\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { FromToPickerProps } from \"./types\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\n\nconst iconSize = \"0.9em\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nconst defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);\n\nconst FromToLocationPicker = ({\n location = null,\n onFromClick = null,\n onToClick = null,\n setLocation = null,\n showIcons = true\n}: FromToPickerProps): React.ReactElement => {\n const handleFromClick = () => {\n if (onFromClick) {\n onFromClick();\n return;\n }\n setLocation({\n location,\n locationType: \"from\",\n reverseGeocode: false\n });\n };\n\n const handleToClick = () => {\n if (onToClick) {\n onToClick();\n return;\n }\n setLocation({\n location,\n locationType: \"to\",\n reverseGeocode: false\n });\n };\n\n return (\n <S.FromToPickerSpan>\n <S.LocationPickerSpan>\n {showIcons && <LocationIcon type=\"from\" size={iconSize} />}\n <S.Button onClick={handleFromClick}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.FromToLocationPicker.from\"]}\n description=\"Text for the 'from' button of the picker\"\n id=\"otpUi.FromToLocationPicker.from\"\n />\n </S.Button>\n </S.LocationPickerSpan>\n <S.LocationPickerSpan>\n {showIcons && <LocationIcon type=\"to\" size={iconSize} />}\n <S.Button onClick={handleToClick}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.FromToLocationPicker.to\"]}\n description=\"Text for the 'to' button of the picker\"\n id=\"otpUi.FromToLocationPicker.to\"\n />\n </S.Button>\n </S.LocationPickerSpan>\n </S.FromToPickerSpan>\n );\n};\n\nexport default FromToLocationPicker;\n\n// Rename styled components for export\nexport { S as Styled };\n"],"file":"index.js"}
@@ -0,0 +1,4 @@
1
+ export declare const LocationPickerSpan: import("styled-components").StyledComponent<"span", any, {}, never>;
2
+ export declare const FromToPickerSpan: import("styled-components").StyledComponent<"span", any, {}, never>;
3
+ export declare const Button: import("styled-components").StyledComponent<"button", any, {}, never>;
4
+ //# sourceMappingURL=styled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,qEAI9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,qEAK5B,CAAC;AAEF,eAAO,MAAM,MAAM,uEAalB,CAAC"}
package/lib/styled.js CHANGED
@@ -11,21 +11,21 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
 
12
12
  const LocationPickerSpan = _styledComponents.default.span.withConfig({
13
13
  displayName: "styled__LocationPickerSpan",
14
- componentId: "p56b41-0"
14
+ componentId: "vb4790-0"
15
15
  })([":first-of-type{border-left:none;}"]);
16
16
 
17
17
  exports.LocationPickerSpan = LocationPickerSpan;
18
18
 
19
19
  const FromToPickerSpan = _styledComponents.default.span.withConfig({
20
20
  displayName: "styled__FromToPickerSpan",
21
- componentId: "p56b41-1"
21
+ componentId: "vb4790-1"
22
22
  })(["> *{padding-left:0.4em;border-left:1px solid black;}"]);
23
23
 
24
24
  exports.FromToPickerSpan = FromToPickerSpan;
25
25
 
26
26
  const Button = _styledComponents.default.button.withConfig({
27
27
  displayName: "styled__Button",
28
- componentId: "p56b41-2"
28
+ componentId: "vb4790-2"
29
29
  })(["background:none;border:none;color:navy;font-family:inherit;font-size:inherit;line-height:inherit;padding-left:0.2em;:hover{text-decoration:underline;cursor:pointer;}"]);
30
30
 
31
31
  exports.Button = Button;
package/lib/styled.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styled.js"],"names":["LocationPickerSpan","styled","span","FromToPickerSpan","Button","button"],"mappings":";;;;;;;;;AAAA;;AAEO,MAAMA,kBAAkB,GAAGC,0BAAOC,IAAV;AAAA;AAAA;AAAA,yCAAxB;;;;AAMA,MAAMC,gBAAgB,GAAGF,0BAAOC,IAAV;AAAA;AAAA;AAAA,4DAAtB;;;;AAOA,MAAME,MAAM,GAAGH,0BAAOI,MAAV;AAAA;AAAA;AAAA,6KAAZ","sourcesContent":["import styled from \"styled-components\";\n\nexport const LocationPickerSpan = styled.span`\n :first-of-type {\n border-left: none;\n }\n`;\n\nexport const FromToPickerSpan = styled.span`\n > * {\n padding-left: 0.4em;\n border-left: 1px solid black;\n }\n`;\n\nexport const Button = styled.button`\n background: none;\n border: none;\n color: navy;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n padding-left: 0.2em;\n\n :hover {\n text-decoration: underline;\n cursor: pointer;\n }\n`;\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../src/styled.ts"],"names":["LocationPickerSpan","styled","span","FromToPickerSpan","Button","button"],"mappings":";;;;;;;;;AAAA;;AAEO,MAAMA,kBAAkB,GAAGC,0BAAOC,IAAV;AAAA;AAAA;AAAA,yCAAxB;;;;AAMA,MAAMC,gBAAgB,GAAGF,0BAAOC,IAAV;AAAA;AAAA;AAAA,4DAAtB;;;;AAOA,MAAME,MAAM,GAAGH,0BAAOI,MAAV;AAAA;AAAA;AAAA,6KAAZ","sourcesContent":["import styled from \"styled-components\";\n\nexport const LocationPickerSpan = styled.span`\n :first-of-type {\n border-left: none;\n }\n`;\n\nexport const FromToPickerSpan = styled.span`\n > * {\n padding-left: 0.4em;\n border-left: 1px solid black;\n }\n`;\n\nexport const Button = styled.button`\n background: none;\n border: none;\n color: navy;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n padding-left: 0.2em;\n\n :hover {\n text-decoration: underline;\n cursor: pointer;\n }\n`;\n"],"file":"styled.js"}