@bigbinary/neeto-molecules 1.1.50 → 1.1.51

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/README.md CHANGED
@@ -19,6 +19,7 @@ https://neeto-molecules.neeto.com/
19
19
  - [CalendarView](./docs/components.md#calendarview)
20
20
  - [DateFormat/TimeFormat](./docs/components.md#dateformattimeformat)
21
21
  - [DateRangeFilter](./docs/components.md#daterangefilter)
22
+ - [DownloadMobileAppCallout](./docs/components.md#downloadmobileappcallout)
22
23
  - [DynamicVariables](./docs/components.md#dynamicvariables)
23
24
  - [EmailForm](./docs/components.md#emailform)
24
25
  - [EmailPreview](./docs/components.md#emailpreview)
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
3
+ import { Callout } from '@bigbinary/neetoui';
4
+ import platform from 'platform';
5
+ import { Trans } from 'react-i18next';
6
+ import { useLocation } from 'react-router-dom';
7
+
8
+ var MOBILE_PLATFORMS = ["Android", "iOS", "Windows Phone"];
9
+
10
+ var DownloadMobileAppCallout = function DownloadMobileAppCallout(_ref) {
11
+ var _platform$os, _globalProps$appName;
12
+ var excludePathRegex = _ref.excludePathRegex;
13
+ var _useLocation = useLocation(),
14
+ pathname = _useLocation.pathname;
15
+ var isMobilePlatform = MOBILE_PLATFORMS.includes((_platform$os = platform.os) === null || _platform$os === void 0 ? void 0 : _platform$os.family);
16
+ if (!isMobilePlatform) return null;
17
+ var shouldExcludePath = excludePathRegex && excludePathRegex.test(pathname);
18
+ if (shouldExcludePath) return null;
19
+ var appName = (_globalProps$appName = globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.toLowerCase();
20
+ var mobileAppDownloadUrl = "https://www.neeto.com/".concat(appName, "/mobile");
21
+ return /*#__PURE__*/React.createElement(Callout, {
22
+ className: "m-4 block",
23
+ style: "warning"
24
+ }, /*#__PURE__*/React.createElement(Trans, {
25
+ i18nKey: "neetoMolecules.downloadMobileAppCallout.message",
26
+ components: {
27
+ a: /*#__PURE__*/React.createElement("a", {
28
+ className: "neeto-ui-btn--style-link",
29
+ href: mobileAppDownloadUrl,
30
+ rel: "noreferrer",
31
+ target: "_blank"
32
+ })
33
+ }
34
+ }));
35
+ };
36
+
37
+ export { DownloadMobileAppCallout as default };
38
+ //# sourceMappingURL=DownloadMobileAppCallout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DownloadMobileAppCallout.js","sources":["../src/components/DownloadMobileAppCallout/constants.js","../src/components/DownloadMobileAppCallout/index.jsx"],"sourcesContent":["export const MOBILE_PLATFORMS = [\"Android\", \"iOS\", \"Windows Phone\"];\n","import React from \"react\";\n\nimport { globalProps } from \"neetocommons/initializers\";\nimport { Callout } from \"neetoui\";\nimport platform from \"platform\";\nimport PropTypes from \"prop-types\";\nimport { Trans } from \"react-i18next\";\nimport { useLocation } from \"react-router-dom\";\n\nimport { MOBILE_PLATFORMS } from \"./constants\";\n\nconst DownloadMobileAppCallout = ({ excludePathRegex }) => {\n const { pathname } = useLocation();\n\n const isMobilePlatform = MOBILE_PLATFORMS.includes(platform.os?.family);\n if (!isMobilePlatform) return null;\n\n const shouldExcludePath = excludePathRegex && excludePathRegex.test(pathname);\n if (shouldExcludePath) return null;\n\n const appName = globalProps.appName?.toLowerCase();\n const mobileAppDownloadUrl = `https://www.neeto.com/${appName}/mobile`;\n\n return (\n <Callout className=\"m-4 block\" style=\"warning\">\n <Trans\n i18nKey=\"neetoMolecules.downloadMobileAppCallout.message\"\n components={{\n a: (\n <a\n className=\"neeto-ui-btn--style-link\"\n href={mobileAppDownloadUrl}\n rel=\"noreferrer\"\n target=\"_blank\"\n />\n ),\n }}\n />\n </Callout>\n );\n};\n\nDownloadMobileAppCallout.propTypes = {\n /**\n * To exclude specific paths where download mobile app callout should be hidden.\n */\n excludePathRegex: PropTypes.instanceOf(RegExp),\n};\n\nexport default DownloadMobileAppCallout;\n"],"names":["MOBILE_PLATFORMS","DownloadMobileAppCallout","_ref","_platform$os","_globalProps$appName","excludePathRegex","_useLocation","useLocation","pathname","isMobilePlatform","includes","platform","os","family","shouldExcludePath","test","appName","globalProps","toLowerCase","mobileAppDownloadUrl","concat","React","createElement","Callout","className","style","Trans","i18nKey","components","a","href","rel","target"],"mappings":";;;;;;;AAAO,IAAMA,gBAAgB,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,eAAe,CAAC;;ACWnE,IAAMC,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAAC,IAAA,EAA6B;EAAA,IAAAC,YAAA,EAAAC,oBAAA,CAAA;AAAA,EAAA,IAAvBC,gBAAgB,GAAAH,IAAA,CAAhBG,gBAAgB,CAAA;EAClD,IAAAC,YAAA,GAAqBC,WAAW,EAAE;IAA1BC,QAAQ,GAAAF,YAAA,CAARE,QAAQ,CAAA;AAEhB,EAAA,IAAMC,gBAAgB,GAAGT,gBAAgB,CAACU,QAAQ,EAAAP,YAAA,GAACQ,QAAQ,CAACC,EAAE,MAAAT,IAAAA,IAAAA,YAAA,uBAAXA,YAAA,CAAaU,MAAM,CAAC,CAAA;AACvE,EAAA,IAAI,CAACJ,gBAAgB,EAAE,OAAO,IAAI,CAAA;EAElC,IAAMK,iBAAiB,GAAGT,gBAAgB,IAAIA,gBAAgB,CAACU,IAAI,CAACP,QAAQ,CAAC,CAAA;EAC7E,IAAIM,iBAAiB,EAAE,OAAO,IAAI,CAAA;AAElC,EAAA,IAAME,OAAO,GAAA,CAAAZ,oBAAA,GAAGa,WAAW,CAACD,OAAO,MAAA,IAAA,IAAAZ,oBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAnBA,oBAAA,CAAqBc,WAAW,EAAE,CAAA;AAClD,EAAA,IAAMC,oBAAoB,GAAA,wBAAA,CAAAC,MAAA,CAA4BJ,OAAO,EAAS,SAAA,CAAA,CAAA;AAEtE,EAAA,oBACEK,KAAA,CAAAC,aAAA,CAACC,OAAO,EAAA;AAACC,IAAAA,SAAS,EAAC,WAAW;AAACC,IAAAA,KAAK,EAAC,SAAA;AAAS,GAAA,eAC5CJ,KAAA,CAAAC,aAAA,CAACI,KAAK,EAAA;AACJC,IAAAA,OAAO,EAAC,iDAAiD;AACzDC,IAAAA,UAAU,EAAE;MACVC,CAAC,eACCR,KAAA,CAAAC,aAAA,CAAA,GAAA,EAAA;AACEE,QAAAA,SAAS,EAAC,0BAA0B;AACpCM,QAAAA,IAAI,EAAEX,oBAAqB;AAC3BY,QAAAA,GAAG,EAAC,YAAY;AAChBC,QAAAA,MAAM,EAAC,QAAA;AAAQ,OAAA,CAAA;AAGrB,KAAA;AAAE,GAAA,CACF,CACM,CAAA;AAEd;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-molecules",
3
- "version": "1.1.50",
3
+ "version": "1.1.51",
4
4
  "description": "A package of reusable molecular components for neeto products.",
5
5
  "repository": "git@github.com:bigbinary/neeto-molecules.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -200,6 +200,9 @@
200
200
  "valid": "Please add valid custom domain"
201
201
  }
202
202
  },
203
+ "downloadMobileAppCallout": {
204
+ "message": "Noticed that you're on a mobile device. For the best experience, <a>download our mobile app</a>."
205
+ },
203
206
  "schedule": {
204
207
  "changeAvailability": "Change availability",
205
208
  "unavailable": "Unavailable",
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ /**
3
+ *
4
+ * A component to render warning callout when the application is accessed from a
5
+ *
6
+ * mobile browser.
7
+ *
8
+ * @example
9
+ *
10
+ * import DownloadMobileAppCallout from "@bigbinary/neeto-molecules/DownloadMobileAppCallout";
11
+ *
12
+ * const App = () => (
13
+ * <DownloadMobileAppCallout />
14
+ * <Main />
15
+ * )
16
+ * @endexample
17
+ * The excludePathRegex can be specified like this:
18
+ *
19
+ * @example
20
+ *
21
+ * const PUBLIC_ROUTE_REGEX = new RegExp(/^\/public/)
22
+ *
23
+ * <DownloadMobileAppCallout excludePathRegex={PUBLIC_ROUTE_REGEX} />
24
+ * @endexample
25
+ * With this change, the DownloadMobileAppCallout component won't display callout for any path that
26
+ *
27
+ * starts with "/public".
28
+ *
29
+ */
30
+ const DownloadMobileAppCallout: React.FC<{
31
+ excludePathRegex?: RegExp;
32
+ }>;
33
+ export default DownloadMobileAppCallout;