@bigbinary/neeto-molecules 5.1.23 → 5.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/PhoneNumber.js +2 -2
  2. package/dist/SessionEnvironment.js +1 -1
  3. package/dist/arrow-left-B-s28MD1.js +18 -0
  4. package/dist/arrow-left-B-s28MD1.js.map +1 -0
  5. package/dist/cjs/PhoneNumber.js +1 -1
  6. package/dist/cjs/SessionEnvironment.js +1 -1
  7. package/dist/cjs/arrow-left-gtCwH31u.js +20 -0
  8. package/dist/cjs/arrow-left-gtCwH31u.js.map +1 -0
  9. package/dist/cjs/{phone-number-DIIlhFGA.js → phone-number-D8DlSqHJ.js} +6 -5
  10. package/dist/cjs/phone-number-D8DlSqHJ.js.map +1 -0
  11. package/dist/cjs/{phone-number-Bza7WGZm.js → phone-number-DMH57syY.js} +6 -5
  12. package/dist/cjs/phone-number-DMH57syY.js.map +1 -0
  13. package/dist/cjs/v2/ImageWithFallback.js +51 -0
  14. package/dist/cjs/v2/ImageWithFallback.js.map +1 -0
  15. package/dist/cjs/v2/PhoneNumber.js +1 -1
  16. package/dist/cjs/v2/ProductEmbed.js +4 -17
  17. package/dist/cjs/v2/ProductEmbed.js.map +1 -1
  18. package/dist/cjs/v2/SessionEnvironment.js +1 -1
  19. package/dist/cjs/v2/ShareRecordingPane.js +305 -0
  20. package/dist/cjs/v2/ShareRecordingPane.js.map +1 -0
  21. package/dist/cjs/v2/ShareViaEmail.js +387 -0
  22. package/dist/cjs/v2/ShareViaEmail.js.map +1 -0
  23. package/dist/cjs/v2/StatusDropdown.js +161 -0
  24. package/dist/cjs/v2/StatusDropdown.js.map +1 -0
  25. package/dist/cjs/v2/SubscriptionNotificationsContainer.js +72 -0
  26. package/dist/cjs/v2/SubscriptionNotificationsContainer.js.map +1 -0
  27. package/dist/cjs/v2/SubscriptionUpgradeRequestModal.js +90 -0
  28. package/dist/cjs/v2/SubscriptionUpgradeRequestModal.js.map +1 -0
  29. package/dist/cjs/v2/SuffixedInput.js +130 -0
  30. package/dist/cjs/v2/SuffixedInput.js.map +1 -0
  31. package/dist/cjs/v2/TimezoneMismatchModal.js +136 -0
  32. package/dist/cjs/v2/TimezoneMismatchModal.js.map +1 -0
  33. package/dist/cjs/v2/VersionHistory.js +210 -0
  34. package/dist/cjs/v2/VersionHistory.js.map +1 -0
  35. package/dist/{phone-number-B3OcwVZM.js → phone-number-CJj2wD9_.js} +6 -5
  36. package/dist/phone-number-CJj2wD9_.js.map +1 -0
  37. package/dist/{phone-number-CGZtDB_n.js → phone-number-D9soCpCv.js} +6 -5
  38. package/dist/phone-number-D9soCpCv.js.map +1 -0
  39. package/dist/v2/ImageWithFallback.js +49 -0
  40. package/dist/v2/ImageWithFallback.js.map +1 -0
  41. package/dist/v2/PhoneNumber.js +2 -2
  42. package/dist/v2/ProductEmbed.js +2 -15
  43. package/dist/v2/ProductEmbed.js.map +1 -1
  44. package/dist/v2/SessionEnvironment.js +1 -1
  45. package/dist/v2/ShareRecordingPane.js +303 -0
  46. package/dist/v2/ShareRecordingPane.js.map +1 -0
  47. package/dist/v2/ShareViaEmail.js +366 -0
  48. package/dist/v2/ShareViaEmail.js.map +1 -0
  49. package/dist/v2/StatusDropdown.js +159 -0
  50. package/dist/v2/StatusDropdown.js.map +1 -0
  51. package/dist/v2/SubscriptionNotificationsContainer.js +70 -0
  52. package/dist/v2/SubscriptionNotificationsContainer.js.map +1 -0
  53. package/dist/v2/SubscriptionUpgradeRequestModal.js +88 -0
  54. package/dist/v2/SubscriptionUpgradeRequestModal.js.map +1 -0
  55. package/dist/v2/SuffixedInput.js +128 -0
  56. package/dist/v2/SuffixedInput.js.map +1 -0
  57. package/dist/v2/TimezoneMismatchModal.js +134 -0
  58. package/dist/v2/TimezoneMismatchModal.js.map +1 -0
  59. package/dist/v2/VersionHistory.js +208 -0
  60. package/dist/v2/VersionHistory.js.map +1 -0
  61. package/package.json +1 -1
  62. package/types/v2/ImageWithFallback.d.ts +9 -0
  63. package/types/v2/ShareRecordingPane.d.ts +16 -0
  64. package/types/v2/ShareViaEmail.d.ts +34 -0
  65. package/types/v2/StatusDropdown.d.ts +16 -0
  66. package/types/v2/SubscriptionNotificationsContainer.d.ts +5 -0
  67. package/types/v2/SubscriptionUpgradeRequestModal.d.ts +8 -0
  68. package/types/v2/SuffixedInput.d.ts +16 -0
  69. package/types/v2/TimezoneMismatchModal.d.ts +8 -0
  70. package/types/v2/VersionHistory.d.ts +44 -0
  71. package/dist/cjs/phone-number-Bza7WGZm.js.map +0 -1
  72. package/dist/cjs/phone-number-DIIlhFGA.js.map +0 -1
  73. package/dist/phone-number-B3OcwVZM.js.map +0 -1
  74. package/dist/phone-number-CGZtDB_n.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusDropdown.js","sources":["../../../src/v2/components/StatusDropdown/Menu.jsx","../../../src/v2/components/StatusDropdown/constants.js","../../../src/v2/components/StatusDropdown/Target.jsx","../../../src/v2/components/StatusDropdown/index.jsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { DropdownMenu } from \"@bigbinary/neeto-atoms\";\nimport { hyphenate } from \"neetocist\";\n\nconst Menu = ({\n onItemClick,\n options,\n shouldShowAllOptions = false,\n hiddenStatuses = [],\n}) => {\n const allowedOptions = shouldShowAllOptions\n ? options\n : options.filter(status => !hiddenStatuses.includes(status.value));\n\n return (\n <>\n {allowedOptions?.map(option => (\n <DropdownMenu.MenuItem\n className={`status-dropdown-item--${option.color}`}\n data-testid={`status-dropdown-item-${hyphenate(option.value)}`}\n key={option.value}\n onClick={() => onItemClick(option)}\n >\n {option.label}\n </DropdownMenu.MenuItem>\n ))}\n </>\n );\n};\n\nexport default memo(Menu);\n","export const ICON_SIZE = 16;\n","import { forwardRef } from \"react\";\n\nimport { Typography } from \"@bigbinary/neeto-atoms\";\nimport { ChevronDown, X } from \"lucide-react\";\nimport { isPresent } from \"neetocist\";\nimport { isNil } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { ICON_SIZE } from \"./constants.js\";\n\nconst Target = forwardRef(\n (\n {\n color,\n value,\n label,\n dataTestid,\n isClearable,\n onClear,\n placeholder,\n ...otherProps\n },\n ref\n ) => {\n const { t } = useTranslation();\n const targetClassName = `rounded-sm inline-flex items-center gap-2 cursor-pointer py-0.5 px-2 status-dropdown-target--${\n color || \"waiting\"\n }`;\n const isOptionSelected = !isNil(value);\n\n const handleClearClick = event => {\n onClear();\n event.stopPropagation();\n };\n\n const handleClearKeyDown = event => {\n if (!(event.key === \"Enter\" || event.key === \" \")) return;\n event.preventDefault();\n handleClearClick(event);\n };\n\n return (\n <button\n {...{ ref, ...otherProps }}\n aria-haspopup=\"listbox\"\n className={targetClassName}\n data-testid={isPresent(dataTestid) ? dataTestid : \"status-dropdown\"}\n type=\"button\"\n aria-label={\n isOptionSelected\n ? `Selected: ${label}`\n : placeholder || t(\"neetoMolecules.statusDropdown.placeholder\")\n }\n >\n {isOptionSelected ? (\n <Typography className=\"inline\" variant=\"body2\">\n {label}\n </Typography>\n ) : (\n <Typography className=\"text-muted-foreground inline\" variant=\"body2\">\n {placeholder || t(\"neetoMolecules.statusDropdown.placeholder\")}\n </Typography>\n )}\n <span className=\"inline-flex items-center gap-1\">\n {isClearable && isOptionSelected && (\n <span\n aria-label={t(\"neetoMolecules.statusDropdown.clear\")}\n className=\"cursor-pointer\"\n data-testid=\"status-dropdown-clear-button\"\n role=\"button\"\n tabIndex={0}\n onClick={handleClearClick}\n onKeyDown={handleClearKeyDown}\n >\n <X size={ICON_SIZE} />\n </span>\n )}\n <ChevronDown aria-hidden=\"true\" size={ICON_SIZE} />\n </span>\n </button>\n );\n }\n);\n\nTarget.displayName = \"Target\";\n\nexport default Target;\n","import { DropdownMenu, Spinner } from \"@bigbinary/neeto-atoms\";\nimport { _findBy, noop } from \"neetocist\";\nimport PropTypes from \"prop-types\";\n\nimport Menu from \"./Menu\";\nimport \"./status-dropdown.css\";\nimport Target from \"./Target\";\n\nconst StatusDropdown = ({\n disabled = false,\n hiddenStatuses = [],\n isLoading = false,\n onItemClick,\n options,\n placeholder = null,\n selectedValue,\n shouldShowAllOptions = false,\n isClearable = false,\n onClear = noop,\n dataTestid = \"status-dropdown\",\n}) => {\n const selectedOption = _findBy({ value: selectedValue }, options);\n\n return (\n <DropdownMenu\n {...{ disabled }}\n dropdownProps={{ \"data-testid\": \"status-dropdown-menu\" }}\n customTarget={\n <Target\n label={selectedValue}\n {...{\n ...selectedOption,\n dataTestid,\n isClearable,\n onClear,\n placeholder,\n }}\n />\n }\n >\n {isLoading ? (\n <div className=\"flex w-full items-center justify-center py-8\">\n <Spinner />\n </div>\n ) : (\n <Menu\n {...{ hiddenStatuses, onItemClick, options, shouldShowAllOptions }}\n />\n )}\n </DropdownMenu>\n );\n};\n\nStatusDropdown.Menu = Menu;\n\nStatusDropdown.propTypes = {\n /**\n * This prop will decide whether the dropdown is disabled or not.\n */\n disabled: PropTypes.bool,\n /**\n * Statuses to be hidden when shouldShowAllOptions is false.\n */\n hiddenStatuses: PropTypes.array,\n /**\n * This prop will decide whether the dropdown is in loading state or not.\n */\n isLoading: PropTypes.bool,\n /**\n * Function to be called when a menu item is clicked.\n */\n onItemClick: PropTypes.func,\n /**\n * The items that should be shown in the dropdown.\n */\n options: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n value: PropTypes.string,\n color: PropTypes.string,\n })\n ),\n /**\n * Placeholder for the dropdown.\n */\n placeholder: PropTypes.string,\n /**\n * The selected value.\n */\n selectedValue: PropTypes.string,\n /**\n * This prop will decide whether all options should be shown or not. If set to false, the items in hiddenStatuses will not be shown.\n */\n shouldShowAllOptions: PropTypes.bool,\n /**\n * This prop will decide whether the dropdown is clearable or not.\n */\n isClearable: PropTypes.bool,\n /**\n * Function to be called when the clear button is clicked.\n */\n onClear: PropTypes.func,\n};\n\nexport default StatusDropdown;\n"],"names":["Menu","_ref","onItemClick","options","_ref$shouldShowAllOpt","shouldShowAllOptions","_ref$hiddenStatuses","hiddenStatuses","allowedOptions","filter","status","includes","value","_jsx","_Fragment","children","map","option","DropdownMenu","MenuItem","className","concat","color","hyphenate","onClick","label","memo","ICON_SIZE","Target","forwardRef","ref","dataTestid","isClearable","onClear","placeholder","otherProps","_objectWithoutProperties","_excluded","_useTranslation","useTranslation","t","targetClassName","isOptionSelected","isNil","handleClearClick","event","stopPropagation","handleClearKeyDown","key","preventDefault","_jsxs","_objectSpread","isPresent","type","Typography","variant","role","tabIndex","onKeyDown","X","size","ChevronDown","displayName","StatusDropdown","_ref$disabled","disabled","_ref$isLoading","isLoading","_ref$placeholder","selectedValue","_ref$isClearable","_ref$onClear","noop","_ref$dataTestid","selectedOption","_findBy","dropdownProps","customTarget","Spinner"],"mappings":";;;;;;;;;;;;;;;AAKA,IAAMA,MAAI,GAAG,SAAPA,IAAIA,CAAAC,IAAA,EAKJ;AAAA,EAAA,IAJJC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IACXC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IAAAC,qBAAA,GAAAH,IAAA,CACPI,oBAAoB;AAApBA,IAAAA,oBAAoB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IAAAE,mBAAA,GAAAL,IAAA,CAC5BM,cAAc;AAAdA,IAAAA,cAAc,GAAAD,mBAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,mBAAA;EAEnB,IAAME,cAAc,GAAGH,oBAAoB,GACvCF,OAAO,GACPA,OAAO,CAACM,MAAM,CAAC,UAAAC,MAAM,EAAA;IAAA,OAAI,CAACH,cAAc,CAACI,QAAQ,CAACD,MAAM,CAACE,KAAK,CAAC;EAAA,CAAA,CAAC;EAEpE,oBACEC,cAAA,CAAAC,mBAAA,EAAA;IAAAC,QAAA,EACGP,cAAc,KAAA,IAAA,IAAdA,cAAc,KAAA,MAAA,GAAA,MAAA,GAAdA,cAAc,CAAEQ,GAAG,CAAC,UAAAC,MAAM,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8C;AAAAL,MAAAA,QAAA,eAC3DF,cAAA,CAACiE,kBAAO,EAAA,EAAE;AAAC,KACR,CAAC,gBAENjE,cAAA,CAACb,IAAI,EAAA;AACGO,MAAAA,cAAc,EAAdA,cAAc;AAAEL,MAAAA,WAAW,EAAXA,WAAW;AAAEC,MAAAA,OAAO,EAAPA,OAAO;AAAEE,MAAAA,oBAAoB,EAApBA;KAC7C;AACF,GACW,CAAC;AAEnB;AAEA0D,cAAc,CAAC/D,IAAI,GAAGA,IAAI;;;;"}
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ var neetoAtoms = require('@bigbinary/neeto-atoms');
4
+ var neetoCist = require('@bigbinary/neeto-cist');
5
+ var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
6
+ var reactI18next = require('react-i18next');
7
+ var reactQuery = require('@tanstack/react-query');
8
+ var axios = require('axios');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+
11
+ var QUERY_KEYS = {
12
+ SUBSCRIPTIONS_LIST: "SUBSCRIPTIONS_LIST"
13
+ };
14
+ var SUBSCRIPTION_STATUS = {
15
+ past_due: "past_due"
16
+ };
17
+
18
+ var fetchSubscriptions = function fetchSubscriptions() {
19
+ return axios.get("neeto_sso/api/v1/server/subscriptions");
20
+ };
21
+ var subscriptionsApi = {
22
+ fetchSubscriptions: fetchSubscriptions
23
+ };
24
+
25
+ var SUBSCRIPTIONS_LIST = QUERY_KEYS.SUBSCRIPTIONS_LIST;
26
+ var useFetchSubscriptions = function useFetchSubscriptions() {
27
+ return reactQuery.useQuery({
28
+ queryKey: [SUBSCRIPTIONS_LIST],
29
+ queryFn: subscriptionsApi.fetchSubscriptions
30
+ });
31
+ };
32
+
33
+ var SubscriptionNotificationsContainer = function SubscriptionNotificationsContainer() {
34
+ var _data$clientAppSubscr;
35
+ var _useFetchSubscription = useFetchSubscriptions(),
36
+ data = _useFetchSubscription.data;
37
+ var clientAppSubscriptions = (_data$clientAppSubscr = data === null || data === void 0 ? void 0 : data.clientAppSubscriptions) !== null && _data$clientAppSubscr !== void 0 ? _data$clientAppSubscr : [];
38
+ var visibleNotifications = neetoCist.filterBy({
39
+ status: SUBSCRIPTION_STATUS.past_due
40
+ }, clientAppSubscriptions);
41
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
42
+ children: visibleNotifications.map(function (_ref, index) {
43
+ var downgradeScheduledAt = _ref.downgradeScheduledAt,
44
+ customerPortalUrl = _ref.customerPortalUrl;
45
+ return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Callout, {
46
+ className: "w-full rounded-none p-2.5",
47
+ "data-testid": "subscription-notifications",
48
+ variant: "warning",
49
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
50
+ variant: "body2",
51
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
52
+ i18nKey: "neetoMolecules.subscription.paymentFailedNotification",
53
+ components: {
54
+ a: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
55
+ href: customerPortalUrl,
56
+ rel: "noreferrer",
57
+ target: "_blank",
58
+ variant: "link"
59
+ })
60
+ },
61
+ values: {
62
+ downgradeScheduledAt: utils.dateFormat.date(downgradeScheduledAt)
63
+ }
64
+ })
65
+ })
66
+ }, index);
67
+ })
68
+ });
69
+ };
70
+
71
+ module.exports = SubscriptionNotificationsContainer;
72
+ //# sourceMappingURL=SubscriptionNotificationsContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionNotificationsContainer.js","sources":["../../../src/v2/components/SubscriptionNotificationsContainer/constants.js","../../../src/v2/components/SubscriptionNotificationsContainer/api.js","../../../src/v2/components/SubscriptionNotificationsContainer/useSubscriptionsApi.js","../../../src/v2/components/SubscriptionNotificationsContainer/index.jsx"],"sourcesContent":["export const QUERY_KEYS = {\n SUBSCRIPTIONS_LIST: \"SUBSCRIPTIONS_LIST\",\n};\n\nexport const SUBSCRIPTION_STATUS = { past_due: \"past_due\" };\n","import axios from \"axios\";\n\nconst fetchSubscriptions = () =>\n axios.get(\"neeto_sso/api/v1/server/subscriptions\");\n\nconst subscriptionsApi = { fetchSubscriptions };\n\nexport default subscriptionsApi;\n","import { useQuery } from \"@tanstack/react-query\";\n\nimport subscriptionsApi from \"./api\";\nimport { QUERY_KEYS } from \"./constants\";\n\nconst { SUBSCRIPTIONS_LIST } = QUERY_KEYS;\n\nconst useFetchSubscriptions = () =>\n useQuery({\n queryKey: [SUBSCRIPTIONS_LIST],\n queryFn: subscriptionsApi.fetchSubscriptions,\n });\n\nexport { useFetchSubscriptions };\n","import { Callout, Typography, Button } from \"@bigbinary/neeto-atoms\";\nimport { filterBy } from \"neetocist\";\nimport { dateFormat } from \"neetocommons/v2/utils\";\nimport { Trans } from \"react-i18next\";\n\nimport { SUBSCRIPTION_STATUS } from \"./constants\";\nimport { useFetchSubscriptions } from \"./useSubscriptionsApi\";\n\nconst SubscriptionNotificationsContainer = () => {\n const { data } = useFetchSubscriptions();\n const clientAppSubscriptions = data?.clientAppSubscriptions ?? [];\n\n const visibleNotifications = filterBy(\n { status: SUBSCRIPTION_STATUS.past_due },\n clientAppSubscriptions\n );\n\n return (\n <>\n {visibleNotifications.map(\n ({ downgradeScheduledAt, customerPortalUrl }, index) => (\n <Callout\n className=\"w-full rounded-none p-2.5\"\n data-testid=\"subscription-notifications\"\n key={index}\n variant=\"warning\"\n >\n <Typography variant=\"body2\">\n <Trans\n i18nKey=\"neetoMolecules.subscription.paymentFailedNotification\"\n components={{\n a: (\n <Button\n href={customerPortalUrl}\n rel=\"noreferrer\"\n target=\"_blank\"\n variant=\"link\"\n />\n ),\n }}\n values={{\n downgradeScheduledAt: dateFormat.date(downgradeScheduledAt),\n }}\n />\n </Typography>\n </Callout>\n )\n )}\n </>\n );\n};\n\nexport default SubscriptionNotificationsContainer;\n"],"names":["QUERY_KEYS","SUBSCRIPTIONS_LIST","SUBSCRIPTION_STATUS","past_due","fetchSubscriptions","axios","get","subscriptionsApi","useFetchSubscriptions","useQuery","queryKey","queryFn","SubscriptionNotificationsContainer","_data$clientAppSubscr","_useFetchSubscription","data","clientAppSubscriptions","visibleNotifications","filterBy","status","_jsx","_Fragment","children","map","_ref","index","downgradeScheduledAt","customerPortalUrl","Callout","className","variant","Typography","Trans","i18nKey","components","a","Button","href","rel","target","values","dateFormat","date"],"mappings":";;;;;;;;;;AAAO,IAAMA,UAAU,GAAG;AACxBC,EAAAA,kBAAkB,EAAE;AACtB,CAAC;AAEM,IAAMC,mBAAmB,GAAG;AAAEC,EAAAA,QAAQ,EAAE;AAAW,CAAC;;ACF3D,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,GAAA;AAAA,EAAA,OACtBC,KAAK,CAACC,GAAG,CAAC,uCAAuC,CAAC;AAAA,CAAA;AAEpD,IAAMC,gBAAgB,GAAG;AAAEH,EAAAA,kBAAkB,EAAlBA;AAAmB,CAAC;;ACA/C,IAAQH,kBAAkB,GAAKD,UAAU,CAAjCC,kBAAkB;AAE1B,IAAMO,qBAAqB,GAAG,SAAxBA,qBAAqBA,GAAA;AAAA,EAAA,OACzBC,mBAAQ,CAAC;IACPC,QAAQ,EAAE,CAACT,kBAAkB,CAAC;IAC9BU,OAAO,EAAEJ,gBAAgB,CAACH;AAC5B,GAAC,CAAC;AAAA,CAAA;;ACHJ,IAAMQ,kCAAkC,GAAG,SAArCA,kCAAkCA,GAAS;AAAA,EAAA,IAAAC,qBAAA;AAC/C,EAAA,IAAAC,qBAAA,GAAiBN,qBAAqB,EAAE;IAAhCO,IAAI,GAAAD,qBAAA,CAAJC,IAAI;AACZ,EAAA,IAAMC,sBAAsB,GAAA,CAAAH,qBAAA,GAAGE,IAAI,aAAJA,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJA,IAAI,CAAEC,sBAAsB,MAAA,IAAA,IAAAH,qBAAA,KAAA,MAAA,GAAAA,qBAAA,GAAI,EAAE;EAEjE,IAAMI,oBAAoB,GAAGC,kBAAQ,CACnC;IAAEC,MAAM,EAAEjB,mBAAmB,CAACC;GAAU,EACxCa,sBACF,CAAC;EAED,oBACEI,cAAA,CAAAC,mBAAA,EAAA;IAAAC,QAAA,EACGL,oBAAoB,CAACM,GAAG,CACvB,UAAAC,IAAA,EAA8CC,KAAK,EAAA;AAAA,MAAA,IAAhDC,oBAAoB,GAAAF,IAAA,CAApBE,oBAAoB;QAAEC,iBAAiB,GAAAH,IAAA,CAAjBG,iBAAiB;MAAA,oBACxCP,cAAA,CAACQ,kBAAO,EAAA;AACNC,QAAAA,SAAS,EAAC,2BAA2B;AACrC,QAAA,aAAA,EAAY,4BAA4B;AAExCC,QAAAA,OAAO,EAAC,SAAS;QAAAR,QAAA,eAEjBF,cAAA,CAACW,qBAAU,EAAA;AAACD,UAAAA,OAAO,EAAC,OAAO;UAAAR,QAAA,eACzBF,cAAA,CAACY,kBAAK,EAAA;AACJC,YAAAA,OAAO,EAAC,uDAAuD;AAC/DC,YAAAA,UAAU,EAAE;cACVC,CAAC,eACCf,cAAA,CAACgB,iBAAM,EAAA;AACLC,gBAAAA,IAAI,EAAEV,iBAAkB;AACxBW,gBAAAA,GAAG,EAAC,YAAY;AAChBC,gBAAAA,MAAM,EAAC,QAAQ;AACfT,gBAAAA,OAAO,EAAC;eACT;aAEH;AACFU,YAAAA,MAAM,EAAE;AACNd,cAAAA,oBAAoB,EAAEe,gBAAU,CAACC,IAAI,CAAChB,oBAAoB;AAC5D;WACD;SACS;AAAC,OAAA,EApBRD,KAqBE,CAAC;IAAA,CAEd;AAAC,GACD,CAAC;AAEP;;;;"}
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var neetoAtoms = require('@bigbinary/neeto-atoms');
4
+ var initializers = require('@bigbinary/neeto-commons-frontend/v2/initializers');
5
+ var reactI18next = require('react-i18next');
6
+ var reactQuery = require('@tanstack/react-query');
7
+ var axios = require('axios');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+
10
+ var create = function create() {
11
+ return axios.post("/neeto_sso/api/v1/subscription_request");
12
+ };
13
+ var subscriptionRequestApi = {
14
+ create: create
15
+ };
16
+
17
+ var useCreateSubscriptionRequest = function useCreateSubscriptionRequest() {
18
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
19
+ onSuccess = _ref.onSuccess;
20
+ return reactQuery.useMutation({
21
+ mutationFn: subscriptionRequestApi.create,
22
+ onSuccess: onSuccess
23
+ });
24
+ };
25
+
26
+ var SubscriptionUpgradeRequestModal = function SubscriptionUpgradeRequestModal(_ref) {
27
+ var _globalProps$appName;
28
+ var isOpen = _ref.isOpen,
29
+ onClose = _ref.onClose;
30
+ var _useTranslation = reactI18next.useTranslation(),
31
+ t = _useTranslation.t;
32
+ var pricingPageUrl = "https://neeto.com/".concat((_globalProps$appName = initializers.globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.toLowerCase(), "/pricing");
33
+ var _useCreateSubscriptio = useCreateSubscriptionRequest({
34
+ onSuccess: onClose
35
+ }),
36
+ sendRequest = _useCreateSubscriptio.mutate,
37
+ isPending = _useCreateSubscriptio.isPending;
38
+ return /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Dialog, {
39
+ isOpen: isOpen,
40
+ onClose: onClose,
41
+ "aria-describedby": undefined,
42
+ closeOnEsc: !isPending,
43
+ closeOnOutsideClick: !isPending,
44
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Dialog.Header, {
45
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Dialog.Title, {
46
+ children: t("neetoMolecules.subscriptionRequest.title")
47
+ })
48
+ }), /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Dialog.Body, {
49
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
50
+ variant: "body2",
51
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
52
+ components: {
53
+ strong: /*#__PURE__*/jsxRuntime.jsx("strong", {})
54
+ },
55
+ i18nKey: "neetoMolecules.subscriptionRequest.description"
56
+ })
57
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
58
+ className: "mt-3",
59
+ variant: "body2",
60
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
61
+ i18nKey: "neetoMolecules.subscriptionRequest.pricingInfo",
62
+ components: {
63
+ pricingLink: /*#__PURE__*/jsxRuntime.jsx("a", {
64
+ className: "text-primary",
65
+ href: pricingPageUrl,
66
+ rel: "noopener noreferrer",
67
+ target: "_blank"
68
+ })
69
+ }
70
+ })
71
+ })]
72
+ }), /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Dialog.Footer, {
73
+ className: "flex gap-x-2",
74
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
75
+ disabled: isPending,
76
+ label: t("neetoMolecules.subscriptionRequest.cancel"),
77
+ variant: "secondary",
78
+ onClick: onClose
79
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
80
+ disabled: isPending,
81
+ label: t("neetoMolecules.subscriptionRequest.sendRequest"),
82
+ loading: isPending,
83
+ onClick: sendRequest
84
+ })]
85
+ })]
86
+ });
87
+ };
88
+
89
+ module.exports = SubscriptionUpgradeRequestModal;
90
+ //# sourceMappingURL=SubscriptionUpgradeRequestModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionUpgradeRequestModal.js","sources":["../../../src/v2/components/SubscriptionUpgradeRequestModal/apis/subscription_request.js","../../../src/v2/components/SubscriptionUpgradeRequestModal/useSubscriptionRequestApi.js","../../../src/v2/components/SubscriptionUpgradeRequestModal/index.jsx"],"sourcesContent":["import axios from \"axios\";\n\nconst create = () => axios.post(\"/neeto_sso/api/v1/subscription_request\");\n\nconst subscriptionRequestApi = { create };\n\nexport default subscriptionRequestApi;\n","import { useMutation } from \"@tanstack/react-query\";\n\nimport subscriptionRequestApi from \"./apis/subscription_request\";\n\nconst useCreateSubscriptionRequest = ({ onSuccess } = {}) =>\n useMutation({\n mutationFn: subscriptionRequestApi.create,\n onSuccess,\n });\n\nexport { useCreateSubscriptionRequest };\n","import { Button, Dialog, Typography } from \"@bigbinary/neeto-atoms\";\nimport { globalProps } from \"neetocommons/v2/initializers\";\nimport { Trans, useTranslation } from \"react-i18next\";\n\nimport { useCreateSubscriptionRequest } from \"./useSubscriptionRequestApi\";\n\nconst SubscriptionUpgradeRequestModal = ({ isOpen, onClose }) => {\n const { t } = useTranslation();\n\n const pricingPageUrl = `https://neeto.com/${globalProps.appName?.toLowerCase()}/pricing`;\n\n const { mutate: sendRequest, isPending } = useCreateSubscriptionRequest({\n onSuccess: onClose,\n });\n\n return (\n <Dialog\n {...{ isOpen, onClose }}\n aria-describedby={undefined}\n closeOnEsc={!isPending}\n closeOnOutsideClick={!isPending}\n >\n <Dialog.Header>\n <Dialog.Title>\n {t(\"neetoMolecules.subscriptionRequest.title\")}\n </Dialog.Title>\n </Dialog.Header>\n <Dialog.Body>\n <Typography variant=\"body2\">\n <Trans\n components={{ strong: <strong /> }}\n i18nKey=\"neetoMolecules.subscriptionRequest.description\"\n />\n </Typography>\n <Typography className=\"mt-3\" variant=\"body2\">\n <Trans\n i18nKey=\"neetoMolecules.subscriptionRequest.pricingInfo\"\n components={{\n pricingLink: (\n <a\n className=\"text-primary\"\n href={pricingPageUrl}\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n />\n ),\n }}\n />\n </Typography>\n </Dialog.Body>\n <Dialog.Footer className=\"flex gap-x-2\">\n <Button\n disabled={isPending}\n label={t(\"neetoMolecules.subscriptionRequest.cancel\")}\n variant=\"secondary\"\n onClick={onClose}\n />\n <Button\n disabled={isPending}\n label={t(\"neetoMolecules.subscriptionRequest.sendRequest\")}\n loading={isPending}\n onClick={sendRequest}\n />\n </Dialog.Footer>\n </Dialog>\n );\n};\n\nexport default SubscriptionUpgradeRequestModal;\n"],"names":["create","axios","post","subscriptionRequestApi","useCreateSubscriptionRequest","_ref","arguments","length","undefined","onSuccess","useMutation","mutationFn","SubscriptionUpgradeRequestModal","_globalProps$appName","isOpen","onClose","_useTranslation","useTranslation","t","pricingPageUrl","concat","globalProps","appName","toLowerCase","_useCreateSubscriptio","sendRequest","mutate","isPending","_jsxs","Dialog","closeOnEsc","closeOnOutsideClick","children","_jsx","Header","Title","Body","Typography","variant","Trans","components","strong","i18nKey","className","pricingLink","href","rel","target","Footer","Button","disabled","label","onClick","loading"],"mappings":";;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAMA,GAAA;AAAA,EAAA,OAASC,KAAK,CAACC,IAAI,CAAC,wCAAwC,CAAC;AAAA,CAAA;AAEzE,IAAMC,sBAAsB,GAAG;AAAEH,EAAAA,MAAM,EAANA;AAAO,CAAC;;ACAzC,IAAMI,4BAA4B,GAAG,SAA/BA,4BAA4BA,GAAA;AAAA,EAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAoB,EAAE;IAAhBG,SAAS,GAAAJ,IAAA,CAATI,SAAS;AAAA,EAAA,OAC/CC,sBAAW,CAAC;IACVC,UAAU,EAAER,sBAAsB,CAACH,MAAM;AACzCS,IAAAA,SAAS,EAATA;AACF,GAAC,CAAC;AAAA,CAAA;;ACFJ,IAAMG,+BAA+B,GAAG,SAAlCA,+BAA+BA,CAAAP,IAAA,EAA4B;AAAA,EAAA,IAAAQ,oBAAA;AAAA,EAAA,IAAtBC,MAAM,GAAAT,IAAA,CAANS,MAAM;IAAEC,OAAO,GAAAV,IAAA,CAAPU,OAAO;AACxD,EAAA,IAAAC,eAAA,GAAcC,2BAAc,EAAE;IAAtBC,CAAC,GAAAF,eAAA,CAADE,CAAC;AAET,EAAA,IAAMC,cAAc,GAAA,oBAAA,CAAAC,MAAA,CAAA,CAAAP,oBAAA,GAAwBQ,wBAAW,CAACC,OAAO,MAAA,IAAA,IAAAT,oBAAA,KAAA,MAAA,GA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,cAAAA,IAAI,EAAE1B,cAAe;AACrB2B,cAAAA,GAAG,EAAC,qBAAqB;AACzBC,cAAAA,MAAM,EAAC;aACR;AAEL;SACD;AAAC,OACQ,CAAC;AAAA,KACF,CAAC,eACdnB,eAAA,CAACC,iBAAM,CAACmB,MAAM,EAAA;AAACL,MAAAA,SAAS,EAAC,cAAc;MAAAX,QAAA,EAAA,cACrCC,cAAA,CAACgB,iBAAM,EAAA;AACLC,QAAAA,QAAQ,EAAEvB,SAAU;AACpBwB,QAAAA,KAAK,EAAEjC,CAAC,CAAC,2CAA2C,CAAE;AACtDoB,QAAAA,OAAO,EAAC,WAAW;AACnBc,QAAAA,OAAO,EAAErC;AAAQ,OAClB,CAAC,eACFkB,cAAA,CAACgB,iBAAM,EAAA;AACLC,QAAAA,QAAQ,EAAEvB,SAAU;AACpBwB,QAAAA,KAAK,EAAEjC,CAAC,CAAC,gDAAgD,CAAE;AAC3DmC,QAAAA,OAAO,EAAE1B,SAAU;AACnByB,QAAAA,OAAO,EAAE3B;AAAY,OACtB,CAAC;AAAA,KACW,CAAC;AAAA,GACV,CAAC;AAEb;;;;"}
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
+ var React = require('react');
6
+ var neetoAtoms = require('@bigbinary/neeto-atoms');
7
+ var formik = require('@bigbinary/neeto-atoms/formik');
8
+ var neetoCist = require('@bigbinary/neeto-cist');
9
+ var ramda = require('ramda');
10
+ var v2_CopyToClipboardButton = require('./CopyToClipboardButton.js');
11
+ var jsxRuntime = require('react/jsx-runtime');
12
+ var createLucideIcon = require('../createLucideIcon-DBDhE7kE.js');
13
+ require('@babel/runtime/helpers/objectWithoutProperties');
14
+ require('classnames');
15
+ require('@bigbinary/neeto-commons-frontend/v2/utils/general');
16
+ require('react-i18next');
17
+ require('../check-VgZf0qTr.js');
18
+ require('../copy-CerjTcLL.js');
19
+
20
+ /**
21
+ * @license lucide-react v1.7.0 - ISC
22
+ *
23
+ * This source code is licensed under the ISC license.
24
+ * See the LICENSE file in the root directory of this source tree.
25
+ */
26
+
27
+
28
+ const __iconNode = [
29
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30
+ ["path", { d: "M12 16v-4", key: "1dtifu" }],
31
+ ["path", { d: "M12 8h.01", key: "e9boi3" }]
32
+ ];
33
+ const Info = createLucideIcon.createLucideIcon("info", __iconNode);
34
+
35
+ var INPUT_FIELD_MIN_WIDTH = 60;
36
+
37
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
38
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
39
+ var SuffixedInput = function SuffixedInput(_ref) {
40
+ var _placeholderRef$curre2, _placeholderRef$curre3;
41
+ var placeholder = _ref.placeholder,
42
+ helpUrl = _ref.helpUrl,
43
+ helpIconTooltipContent = _ref.helpIconTooltipContent,
44
+ label = _ref.label,
45
+ value = _ref.value,
46
+ getInputRef = _ref.getInputRef,
47
+ suffix = _ref.suffix,
48
+ _ref$isCopyToClipboar = _ref.isCopyToClipboardEnabled,
49
+ isCopyToClipboardEnabled = _ref$isCopyToClipboar === void 0 ? false : _ref$isCopyToClipboar,
50
+ _ref$name = _ref.name,
51
+ name = _ref$name === void 0 ? "email" : _ref$name,
52
+ _ref$inputProps = _ref.inputProps,
53
+ inputProps = _ref$inputProps === void 0 ? {} : _ref$inputProps;
54
+ var _useState = React.useState(INPUT_FIELD_MIN_WIDTH),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ initialInputWidth = _useState2[0],
57
+ setInitialInputWidth = _useState2[1];
58
+ var inputRef = React.useRef(null);
59
+ var placeholderRef = React.useRef(null);
60
+ var setInputRef = function setInputRef(ref) {
61
+ inputRef.current = ref;
62
+ getInputRef === null || getInputRef === void 0 || getInputRef(ref);
63
+ };
64
+ React.useEffect(function () {
65
+ var _placeholderRef$curre;
66
+ //To handle the input width on initial render.
67
+ var placeholderSpanWidth = (_placeholderRef$curre = placeholderRef.current) === null || _placeholderRef$curre === void 0 ? void 0 : _placeholderRef$curre.offsetWidth;
68
+ setInitialInputWidth(placeholderSpanWidth);
69
+ }, []);
70
+ var labelNode = neetoCist.isPresent(helpUrl) ? /*#__PURE__*/jsxRuntime.jsxs("span", {
71
+ className: "inline-flex items-center gap-1",
72
+ children: [label, /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
73
+ content: helpIconTooltipContent,
74
+ disabled: neetoCist.isNotPresent(helpUrl),
75
+ position: "right",
76
+ children: /*#__PURE__*/jsxRuntime.jsx("button", {
77
+ className: "cursor-pointer opacity-75 transition-opacity duration-300 ease-in-out hover:opacity-100",
78
+ type: "button",
79
+ onClick: function onClick() {
80
+ return window.open(helpUrl, "_blank");
81
+ },
82
+ children: /*#__PURE__*/jsxRuntime.jsx(Info, {
83
+ size: 16
84
+ })
85
+ })
86
+ })]
87
+ }) : label;
88
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
89
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
90
+ // Dummy element to calculate the width to be set for the input. Do not remove.
91
+ className: "pointer-events-none invisible absolute ps-2",
92
+ ref: placeholderRef,
93
+ children: value || placeholder
94
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
95
+ className: "inline-flex max-w-full items-end gap-2",
96
+ children: [/*#__PURE__*/jsxRuntime.jsx(formik.Input, _objectSpread(_objectSpread({}, _objectSpread({
97
+ name: name,
98
+ placeholder: placeholder
99
+ }, inputProps)), {}, {
100
+ className: "w-max max-w-full min-w-0",
101
+ label: labelNode,
102
+ ref: setInputRef,
103
+ type: "text",
104
+ style: {
105
+ minWidth: ramda.isEmpty(value) ? INPUT_FIELD_MIN_WIDTH : 0,
106
+ width: (_placeholderRef$curre2 = (_placeholderRef$curre3 = placeholderRef.current) === null || _placeholderRef$curre3 === void 0 ? void 0 : _placeholderRef$curre3.offsetWidth) !== null && _placeholderRef$curre2 !== void 0 ? _placeholderRef$curre2 : initialInputWidth
107
+ },
108
+ suffix:
109
+ /*#__PURE__*/
110
+ // Added onClick to focus the input even when the suffix part is clicked.
111
+ // `size-auto` overrides the icon-size class atoms injects into addons.
112
+ jsxRuntime.jsx("span", {
113
+ className: "bg-muted text-muted-foreground -me-1.5 flex size-auto cursor-not-allowed items-center self-stretch px-2 whitespace-nowrap",
114
+ onClick: function onClick() {
115
+ var _inputRef$current;
116
+ return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
117
+ },
118
+ children: suffix
119
+ })
120
+ })), isCopyToClipboardEnabled && /*#__PURE__*/jsxRuntime.jsx(v2_CopyToClipboardButton, {
121
+ disabled: ramda.isEmpty(value),
122
+ value: "".concat(value).concat(suffix),
123
+ variant: "ghost"
124
+ })]
125
+ })]
126
+ });
127
+ };
128
+
129
+ module.exports = SuffixedInput;
130
+ //# sourceMappingURL=SuffixedInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SuffixedInput.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/info.js","../../../src/v2/components/SuffixedInput/constants.js","../../../src/v2/components/SuffixedInput/index.jsx"],"sourcesContent":["/**\n * @license lucide-react v1.7.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"path\", { d: \"M12 16v-4\", key: \"1dtifu\" }],\n [\"path\", { d: \"M12 8h.01\", key: \"e9boi3\" }]\n];\nconst Info = createLucideIcon(\"info\", __iconNode);\n\nexport { __iconNode, Info as default };\n//# sourceMappingURL=info.js.map\n","export const INPUT_FIELD_MIN_WIDTH = 60;\n","import { useEffect, useRef, useState } from \"react\";\n\nimport { Tooltip } from \"@bigbinary/neeto-atoms\";\nimport { Input } from \"@bigbinary/neeto-atoms/formik\";\nimport { Info } from \"lucide-react\";\nimport { isPresent, isNotPresent } from \"neetocist\";\nimport PropTypes from \"prop-types\";\nimport { isEmpty } from \"ramda\";\n\nimport { INPUT_FIELD_MIN_WIDTH } from \"./constants\";\n\nimport CopyToClipboardButton from \"../CopyToClipboardButton\";\n\nconst SuffixedInput = ({\n placeholder,\n helpUrl,\n helpIconTooltipContent,\n label,\n value,\n getInputRef,\n suffix,\n isCopyToClipboardEnabled = false,\n name = \"email\",\n inputProps = {},\n}) => {\n const [initialInputWidth, setInitialInputWidth] = useState(\n INPUT_FIELD_MIN_WIDTH\n );\n const inputRef = useRef(null);\n const placeholderRef = useRef(null);\n\n const setInputRef = ref => {\n inputRef.current = ref;\n getInputRef?.(ref);\n };\n\n useEffect(() => {\n //To handle the input width on initial render.\n const placeholderSpanWidth = placeholderRef.current?.offsetWidth;\n setInitialInputWidth(placeholderSpanWidth);\n }, []);\n\n const labelNode = isPresent(helpUrl) ? (\n <span className=\"inline-flex items-center gap-1\">\n {label}\n <Tooltip\n content={helpIconTooltipContent}\n disabled={isNotPresent(helpUrl)}\n position=\"right\"\n >\n <button\n className=\"cursor-pointer opacity-75 transition-opacity duration-300 ease-in-out hover:opacity-100\"\n type=\"button\"\n onClick={() => window.open(helpUrl, \"_blank\")}\n >\n <Info size={16} />\n </button>\n </Tooltip>\n </span>\n ) : (\n label\n );\n\n return (\n <>\n <span // Dummy element to calculate the width to be set for the input. Do not remove.\n className=\"pointer-events-none invisible absolute ps-2\"\n ref={placeholderRef}\n >\n {value || placeholder}\n </span>\n <div className=\"inline-flex max-w-full items-end gap-2\">\n <Input\n {...{ name, placeholder, ...inputProps }}\n className=\"w-max max-w-full min-w-0\"\n label={labelNode}\n ref={setInputRef}\n type=\"text\"\n style={{\n minWidth: isEmpty(value) ? INPUT_FIELD_MIN_WIDTH : 0,\n width: placeholderRef.current?.offsetWidth ?? initialInputWidth,\n }}\n suffix={\n // Added onClick to focus the input even when the suffix part is clicked.\n // `size-auto` overrides the icon-size class atoms injects into addons.\n <span\n className=\"bg-muted text-muted-foreground -me-1.5 flex size-auto cursor-not-allowed items-center self-stretch px-2 whitespace-nowrap\"\n onClick={() => inputRef.current?.focus()}\n >\n {suffix}\n </span>\n }\n />\n {isCopyToClipboardEnabled && (\n <CopyToClipboardButton\n disabled={isEmpty(value)}\n value={`${value}${suffix}`}\n variant=\"ghost\"\n />\n )}\n </div>\n </>\n );\n};\n\nSuffixedInput.propTypes = {\n /**\n * Placeholder of the input field.\n */\n placeholder: PropTypes.string,\n /**\n * A help icon will be displayed next to the label if helpUrl is present. On clicking the icon will take the user to the URL.\n */\n helpUrl: PropTypes.string,\n /**\n * Text to be displayed inside the tooltip of the help icon.\n */\n helpIconTooltipContent: PropTypes.string,\n /**\n * Label of the input field.\n */\n label: PropTypes.string,\n /**\n * The value entered by the user, eg: email.\n */\n value: PropTypes.string,\n /**\n * A method to get the ref of the input field.\n */\n getInputRef: PropTypes.func,\n /**\n * Domain name to be rendered next to the input field.\n */\n suffix: PropTypes.string,\n /**\n * Whether to show the copy to clipboard button.\n */\n isCopyToClipboardEnabled: PropTypes.bool,\n /**\n * Formik field name of the input field.\n */\n name: PropTypes.string,\n /**\n * This will be passed down to the `Input` component.\n */\n inputProps: PropTypes.object,\n};\n\nexport default SuffixedInput;\n"],"names":["createLucideIcon","INPUT_FIELD_MIN_WIDTH","SuffixedInput","_ref","_placeholderRef$curre2","_placeholderRef$curre3","placeholder","helpUrl","helpIconTooltipContent","label","value","getInputRef","suffix","_ref$isCopyToClipboar","isCopyToClipboardEnabled","_ref$name","name","_ref$inputProps","inputProps","_useState","useState","_useState2","_slicedToArray","initialInputWidth","setInitialInputWidth","inputRef","useRef","placeholderRef","setInputRef","ref","current","useEffect","_placeholderRef$curre","placeholderSpanWidth","offsetWidth","labelNode","isPresent","_jsxs","className","children","_jsx","Tooltip","content","disabled","isNotPresent","position","type","onClick","window","open","Info","size","_Fragment","Input","_objectSpread","style","minWidth","isEmpty","width","_inputRef$current","focus","CopyToClipboardButton","concat","variant"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAIA,MAAM,UAAU,GAAG;AACnB,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AAC5D,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AAC7C,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE;AAC5C,CAAC;AACD,MAAM,IAAI,GAAGA,iCAAgB,CAAC,MAAM,EAAE,UAAU,CAAC;;ACd1C,IAAMC,qBAAqB,GAAG,EAAE;;;;ACavC,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA,EAWb;EAAA,IAAAC,sBAAA,EAAAC,sBAAA;AAAA,EAAA,IAVJC,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,sBAAsB,GAAAL,IAAA,CAAtBK,sBAAsB;IACtBC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,WAAW,GAAAR,IAAA,CAAXQ,WAAW;IACXC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AACjBN,QAAAA,GAAG,EAAED,WAAY;AACjBkB,QAAAA,IAAI,EAAC,MAAM;AACXS,QAAAA,KAAK,EAAE;UACLC,QAAQ,EAAEC,aAAO,CAAC/C,KAAK,CAAC,GAAGT,qBAAqB,GAAG,CAAC;AACpDyD,UAAAA,KAAK,GAAAtD,sBAAA,GAAA,CAAAC,sBAAA,GAAEsB,cAAc,CAACG,OAAO,MAAA,IAAA,IAAAzB,sBAAA,KAAA,MAAA,GAAA,MAAA,GAAtBA,sBAAA,CAAwB6B,WAAW,cAAA9B,sBAAA,KAAA,MAAA,GAAAA,sBAAA,GAAImB;SAC9C;QACFX,MAAM;AAAA;AACJ;AACA;QACA4B,cAAA,CAAA,MAAA,EAAA;AACEF,UAAAA,SAAS,EAAC,2HAA2H;UACrIS,OAAO,EAAE,SAATA,OAAOA,GAAA;AAAA,YAAA,IAAAY,iBAAA;AAAA,YAAA,OAAA,CAAAA,iBAAA,GAAQlC,QAAQ,CAACK,OAAO,MAAA,IAAA,IAAA6B,iBAAA,KAAA,MAAA,GAAA,MAAA,GAAhBA,iBAAA,CAAkBC,KAAK,EAAE;UAAA,CAAC;AAAArB,UAAAA,QAAA,EAExC3B;SACG;AACP,OAAA,CACF,CAAC,EACDE,wBAAwB,iBACvB0B,cAAA,CAACqB,wBAAqB,EAAA;AACpBlB,QAAAA,QAAQ,EAAEc,aAAO,CAAC/C,KAAK,CAAE;QACzBA,KAAK,EAAA,EAAA,CAAAoD,MAAA,CAAKpD,KAAK,EAAAoD,MAAA,CAAGlD,MAAM,CAAG;AAC3BmD,QAAAA,OAAO,EAAC;AAAO,OAChB,CACF;AAAA,KACE,CAAC;AAAA,GACN,CAAC;AAEP;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var React = require('react');
5
+ var neetoAtoms = require('@bigbinary/neeto-atoms');
6
+ var neetoCist = require('@bigbinary/neeto-cist');
7
+ var initializers = require('@bigbinary/neeto-commons-frontend/v2/initializers');
8
+ var reactI18next = require('react-i18next');
9
+ var reactQuery = require('@tanstack/react-query');
10
+ var axios = require('axios');
11
+ var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
12
+ var jsxRuntime = require('react/jsx-runtime');
13
+
14
+ var timeZoneUrl = "api/v1/time_zone";
15
+ var updateTimeZone = function updateTimeZone(payload) {
16
+ return axios.patch(timeZoneUrl, payload);
17
+ };
18
+ var timeZoneApi = {
19
+ updateTimeZone: updateTimeZone
20
+ };
21
+
22
+ var useUpdateTimeZone = function useUpdateTimeZone() {
23
+ return reactQuery.useMutation({
24
+ mutationFn: timeZoneApi.updateTimeZone,
25
+ onSuccess: function onSuccess() {
26
+ return window.location.reload();
27
+ }
28
+ });
29
+ };
30
+
31
+ var getBrowserTimeZone = function getBrowserTimeZone() {
32
+ return utils.dayjs.tz.guess();
33
+ };
34
+ var getUserTimeZone = function getUserTimeZone() {
35
+ var _globalProps$user;
36
+ return (_globalProps$user = initializers.globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.timeZone;
37
+ };
38
+ var checkIfTwoTimeZonesAreSame = function checkIfTwoTimeZonesAreSame(timeZone1, timeZone2) {
39
+ return (
40
+ // eslint-disable-next-line @bigbinary/neeto/use-standard-date-time-formats
41
+ utils.dayjs().tz(timeZone1).format("Z") === utils.dayjs().tz(timeZone2).format("Z")
42
+ );
43
+ };
44
+
45
+ var TimezoneMismatchModal = function TimezoneMismatchModal(_ref) {
46
+ var _ref$isOpen = _ref.isOpen,
47
+ isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
48
+ _ref$onClose = _ref.onClose,
49
+ onClose = _ref$onClose === void 0 ? neetoCist.noop : _ref$onClose;
50
+ var _useTranslation = reactI18next.useTranslation(),
51
+ t = _useTranslation.t;
52
+ var _useState = React.useState(false),
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ isTimezoneModalOpen = _useState2[0],
55
+ setIsTimezoneModalOpen = _useState2[1];
56
+ var _useUpdateTimeZone = useUpdateTimeZone(),
57
+ isPending = _useUpdateTimeZone.isPending,
58
+ updateTimeZone = _useUpdateTimeZone.mutate;
59
+ var isUserAndBrowserTimeZoneSame = checkIfTwoTimeZonesAreSame(getUserTimeZone(), getBrowserTimeZone());
60
+ var handleUpdateTimeZone = function handleUpdateTimeZone() {
61
+ var payload = {
62
+ timeZone: getBrowserTimeZone()
63
+ };
64
+ updateTimeZone(payload, {
65
+ onSuccess: function onSuccess() {
66
+ setIsTimezoneModalOpen(false);
67
+ onClose();
68
+ }
69
+ });
70
+ };
71
+ var handleCancel = function handleCancel() {
72
+ setIsTimezoneModalOpen(false);
73
+ onClose();
74
+ };
75
+ React.useEffect(function () {
76
+ if (!(process.env.RAILS_ENV !== "heroku")) return;
77
+ setIsTimezoneModalOpen(!isUserAndBrowserTimeZoneSame);
78
+ }, []);
79
+ return /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Dialog, {
80
+ "aria-describedby": undefined,
81
+ closeOnOutsideClick: false,
82
+ isOpen: isTimezoneModalOpen || isOpen,
83
+ size: "large",
84
+ onClose: handleCancel,
85
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Dialog.Header, {
86
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Dialog.Title, {
87
+ children: t("neetoMolecules.alert.timezone.title")
88
+ })
89
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Dialog.Body, {
90
+ children: /*#__PURE__*/jsxRuntime.jsxs("span", {
91
+ className: "flex flex-col gap-y-4",
92
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
93
+ as: "span",
94
+ variant: "body2",
95
+ children: t("neetoMolecules.alert.timezone.message", {
96
+ entity: initializers.globalProps.appName
97
+ })
98
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
99
+ as: "span",
100
+ variant: "h4",
101
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
102
+ i18nKey: "neetoMolecules.alert.timezone.userTimezone",
103
+ values: {
104
+ entity: getUserTimeZone()
105
+ }
106
+ })
107
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
108
+ as: "span",
109
+ variant: "h4",
110
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
111
+ i18nKey: "neetoMolecules.alert.timezone.browserTimezone",
112
+ values: {
113
+ entity: getBrowserTimeZone()
114
+ }
115
+ })
116
+ })]
117
+ })
118
+ }), /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Dialog.Footer, {
119
+ className: "flex items-center gap-x-2",
120
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
121
+ "data-testid": "update-timezone-button",
122
+ disabled: isPending,
123
+ label: t("neetoMolecules.alert.timezone.updateProfile"),
124
+ loading: isPending,
125
+ onClick: handleUpdateTimeZone
126
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
127
+ label: t("neetoMolecules.common.actions.cancel"),
128
+ variant: "ghost",
129
+ onClick: handleCancel
130
+ })]
131
+ })]
132
+ });
133
+ };
134
+
135
+ module.exports = TimezoneMismatchModal;
136
+ //# sourceMappingURL=TimezoneMismatchModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimezoneMismatchModal.js","sources":["../../../src/v2/components/TimezoneMismatchModal/apis/time_zone.js","../../../src/v2/components/TimezoneMismatchModal/useTimeZoneApi.js","../../../src/v2/components/TimezoneMismatchModal/utils.js","../../../src/v2/components/TimezoneMismatchModal/index.jsx"],"sourcesContent":["import axios from \"axios\";\n\nconst timeZoneUrl = \"api/v1/time_zone\";\n\nconst updateTimeZone = payload => axios.patch(timeZoneUrl, payload);\n\nconst timeZoneApi = { updateTimeZone };\n\nexport default timeZoneApi;\n","import { useMutation } from \"@tanstack/react-query\";\n\nimport timeZoneApi from \"./apis/time_zone\";\n\nconst useUpdateTimeZone = () =>\n useMutation({\n mutationFn: timeZoneApi.updateTimeZone,\n onSuccess: () => window.location.reload(),\n });\n\nexport { useUpdateTimeZone };\n","import { globalProps } from \"neetocommons/v2/initializers\";\nimport { dayjs } from \"neetocommons/v2/utils\";\n\nexport const getBrowserTimeZone = () => dayjs.tz.guess();\n\nexport const getUserTimeZone = () => globalProps.user?.timeZone;\n\nexport const checkIfTwoTimeZonesAreSame = (timeZone1, timeZone2) =>\n // eslint-disable-next-line @bigbinary/neeto/use-standard-date-time-formats\n dayjs().tz(timeZone1).format(\"Z\") === dayjs().tz(timeZone2).format(\"Z\");\n","import { useEffect, useState } from \"react\";\n\nimport { Button, Dialog, Typography } from \"@bigbinary/neeto-atoms\";\nimport { noop } from \"neetocist\";\nimport { globalProps } from \"neetocommons/v2/initializers\";\nimport PropTypes from \"prop-types\";\nimport { Trans, useTranslation } from \"react-i18next\";\n\nimport { useUpdateTimeZone } from \"./useTimeZoneApi\";\nimport {\n checkIfTwoTimeZonesAreSame,\n getBrowserTimeZone,\n getUserTimeZone,\n} from \"./utils\";\n\nconst TimezoneMismatchModal = ({ isOpen = false, onClose = noop }) => {\n const { t } = useTranslation();\n const [isTimezoneModalOpen, setIsTimezoneModalOpen] = useState(false);\n const { isPending, mutate: updateTimeZone } = useUpdateTimeZone();\n const isUserAndBrowserTimeZoneSame = checkIfTwoTimeZonesAreSame(\n getUserTimeZone(),\n getBrowserTimeZone()\n );\n\n const handleUpdateTimeZone = () => {\n const payload = { timeZone: getBrowserTimeZone() };\n\n updateTimeZone(payload, {\n onSuccess: () => {\n setIsTimezoneModalOpen(false);\n onClose();\n },\n });\n };\n\n const handleCancel = () => {\n setIsTimezoneModalOpen(false);\n onClose();\n };\n\n useEffect(() => {\n if (!(process.env.RAILS_ENV !== \"heroku\")) return;\n setIsTimezoneModalOpen(!isUserAndBrowserTimeZoneSame);\n }, []);\n\n return (\n <Dialog\n aria-describedby={undefined}\n closeOnOutsideClick={false}\n isOpen={isTimezoneModalOpen || isOpen}\n size=\"large\"\n onClose={handleCancel}\n >\n <Dialog.Header>\n <Dialog.Title>{t(\"neetoMolecules.alert.timezone.title\")}</Dialog.Title>\n </Dialog.Header>\n <Dialog.Body>\n <span className=\"flex flex-col gap-y-4\">\n <Typography as=\"span\" variant=\"body2\">\n {t(\"neetoMolecules.alert.timezone.message\", {\n entity: globalProps.appName,\n })}\n </Typography>\n <Typography as=\"span\" variant=\"h4\">\n <Trans\n i18nKey=\"neetoMolecules.alert.timezone.userTimezone\"\n values={{ entity: getUserTimeZone() }}\n />\n </Typography>\n <Typography as=\"span\" variant=\"h4\">\n <Trans\n i18nKey=\"neetoMolecules.alert.timezone.browserTimezone\"\n values={{ entity: getBrowserTimeZone() }}\n />\n </Typography>\n </span>\n </Dialog.Body>\n <Dialog.Footer className=\"flex items-center gap-x-2\">\n <Button\n data-testid=\"update-timezone-button\"\n disabled={isPending}\n label={t(\"neetoMolecules.alert.timezone.updateProfile\")}\n loading={isPending}\n onClick={handleUpdateTimeZone}\n />\n <Button\n label={t(\"neetoMolecules.common.actions.cancel\")}\n variant=\"ghost\"\n onClick={handleCancel}\n />\n </Dialog.Footer>\n </Dialog>\n );\n};\n\nTimezoneMismatchModal.propTypes = {\n /**\n * Boolean value to toggle the modal.\n */\n isOpen: PropTypes.bool,\n /**\n * The function that's called after the modal is closed.\n */\n onClose: PropTypes.func,\n};\n\nexport default TimezoneMismatchModal;\n"],"names":["timeZoneUrl","updateTimeZone","payload","axios","patch","timeZoneApi","useUpdateTimeZone","useMutation","mutationFn","onSuccess","window","location","reload","getBrowserTimeZone","dayjs","tz","guess","getUserTimeZone","_globalProps$user","globalProps","user","timeZone","checkIfTwoTimeZonesAreSame","timeZone1","timeZone2","format","TimezoneMismatchModal","_ref","_ref$isOpen","isOpen","_ref$onClose","onClose","noop","_useTranslation","useTranslation","t","_useState","useState","_useState2","_slicedToArray","isTimezoneModalOpen","setIsTimezoneModalOpen","_useUpdateTimeZone","isPending","mutate","isUserAndBrowserTimeZoneSame","handleUpdateTimeZone","handleCancel","useEffect","process","env","RAILS_ENV","_jsxs","Dialog","undefined","closeOnOutsideClick","size","children","_jsx","Header","Title","Body","className","Typography","as","variant","entity","appName","Trans","i18nKey","values","Footer","Button","disabled","label","loading","onClick"],"mappings":";;;;;;;;;;;;;AAEA,IAAMA,WAAW,GAAG,kBAAkB;AAEtC,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,OAAO,EAAA;AAAA,EAAA,OAAIC,KAAK,CAACC,KAAK,CAACJ,WAAW,EAAEE,OAAO,CAAC;AAAA,CAAA;AAEnE,IAAMG,WAAW,GAAG;AAAEJ,EAAAA,cAAc,EAAdA;AAAe,CAAC;;ACFtC,IAAMK,iBAAiB,GAAG,SAApBA,iBAAiBA,GAAA;AAAA,EAAA,OACrBC,sBAAW,CAAC;IACVC,UAAU,EAAEH,WAAW,CAACJ,cAAc;IACtCQ,SAAS,EAAE,SAAXA,SAASA,GAAA;AAAA,MAAA,OAAQC,MAAM,CAACC,QAAQ,CAACC,MAAM,EAAE;AAAA,IAAA;AAC3C,GAAC,CAAC;AAAA,CAAA;;ACLG,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,GAAA;AAAA,EAAA,OAASC,WAAK,CAACC,EAAE,CAACC,KAAK,EAAE;AAAA,CAAA;AAEjD,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,GAAA;AAAA,EAAA,IAAAC,iBAAA;EAAA,OAAA,CAAAA,iBAAA,GAASC,wBAAW,CAACC,IAAI,cAAAF,iBAAA,KAAA,MAAA,GAAA,MAAA,GAAhBA,iBAAA,CAAkBG,QAAQ;AAAA,CAAA;AAExD,IAAMC,0BAA0B,GAAG,SAA7BA,0BAA0BA,CAAIC,SAAS,EAAEC,SAAS,EAAA;AAAA,EAAA;AAC7D;IACAV,WAAK,EAAE,CAACC,EAAE,CAACQ,SAAS,CAAC,CAACE,MAAM,CAAC,GAAG,CAAC,KAAKX,WAAK,EAAE,CAACC,EAAE,CAACS,SAAS,CAAC,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