@bigbinary/neeto-molecules 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +60 -0
  2. package/dist/BrowserSupport.cjs.js +1727 -0
  3. package/dist/BrowserSupport.cjs.js.map +1 -0
  4. package/dist/BrowserSupport.js +1721 -0
  5. package/dist/BrowserSupport.js.map +1 -0
  6. package/dist/Columns.cjs.js +191 -0
  7. package/dist/Columns.cjs.js.map +1 -0
  8. package/dist/Columns.js +184 -0
  9. package/dist/Columns.js.map +1 -0
  10. package/dist/Container.cjs.js +1277 -0
  11. package/dist/Container.cjs.js.map +1 -0
  12. package/dist/Container.js +1271 -0
  13. package/dist/Container.js.map +1 -0
  14. package/dist/CopyToClipboardButton.cjs.js +78 -0
  15. package/dist/CopyToClipboardButton.cjs.js.map +1 -0
  16. package/dist/CopyToClipboardButton.js +72 -0
  17. package/dist/CopyToClipboardButton.js.map +1 -0
  18. package/dist/CustomDomain.cjs.js +680 -0
  19. package/dist/CustomDomain.cjs.js.map +1 -0
  20. package/dist/CustomDomain.js +654 -0
  21. package/dist/CustomDomain.js.map +1 -0
  22. package/dist/CustomDomainDashboard.cjs.js +2306 -0
  23. package/dist/CustomDomainDashboard.cjs.js.map +1 -0
  24. package/dist/CustomDomainDashboard.js +2279 -0
  25. package/dist/CustomDomainDashboard.js.map +1 -0
  26. package/dist/DateFormat.cjs.js +51 -0
  27. package/dist/DateFormat.cjs.js.map +1 -0
  28. package/dist/DateFormat.js +45 -0
  29. package/dist/DateFormat.js.map +1 -0
  30. package/dist/DateRangeFilter.cjs.js +236 -0
  31. package/dist/DateRangeFilter.cjs.js.map +1 -0
  32. package/dist/DateRangeFilter.js +229 -0
  33. package/dist/DateRangeFilter.js.map +1 -0
  34. package/dist/DynamicVariables.cjs.js +112 -0
  35. package/dist/DynamicVariables.cjs.js.map +1 -0
  36. package/dist/DynamicVariables.js +106 -0
  37. package/dist/DynamicVariables.js.map +1 -0
  38. package/dist/EmailPreview.cjs.js +102 -0
  39. package/dist/EmailPreview.cjs.js.map +1 -0
  40. package/dist/EmailPreview.js +96 -0
  41. package/dist/EmailPreview.js.map +1 -0
  42. package/dist/ErrorPage.cjs.js +208 -0
  43. package/dist/ErrorPage.cjs.js.map +1 -0
  44. package/dist/ErrorPage.js +184 -0
  45. package/dist/ErrorPage.js.map +1 -0
  46. package/dist/Header.cjs.js +219 -0
  47. package/dist/Header.cjs.js.map +1 -0
  48. package/dist/Header.js +213 -0
  49. package/dist/Header.js.map +1 -0
  50. package/dist/IconPicker.cjs.js +1307 -0
  51. package/dist/IconPicker.cjs.js.map +1 -0
  52. package/dist/IconPicker.js +1301 -0
  53. package/dist/IconPicker.js.map +1 -0
  54. package/dist/IntegrationCard.cjs.js +75 -0
  55. package/dist/IntegrationCard.cjs.js.map +1 -0
  56. package/dist/IntegrationCard.js +69 -0
  57. package/dist/IntegrationCard.js.map +1 -0
  58. package/dist/IntegrationDisconnectAlert.cjs.js +81 -0
  59. package/dist/IntegrationDisconnectAlert.cjs.js.map +1 -0
  60. package/dist/IntegrationDisconnectAlert.js +75 -0
  61. package/dist/IntegrationDisconnectAlert.js.map +1 -0
  62. package/dist/IntegrationWalkthroughModal.cjs.js +42 -0
  63. package/dist/IntegrationWalkthroughModal.cjs.js.map +1 -0
  64. package/dist/IntegrationWalkthroughModal.js +36 -0
  65. package/dist/IntegrationWalkthroughModal.js.map +1 -0
  66. package/dist/IpRestriction.cjs.js +3764 -0
  67. package/dist/IpRestriction.cjs.js.map +1 -0
  68. package/dist/IpRestriction.js +3738 -0
  69. package/dist/IpRestriction.js.map +1 -0
  70. package/dist/KeyboardShortcuts.cjs.js +2242 -0
  71. package/dist/KeyboardShortcuts.cjs.js.map +1 -0
  72. package/dist/KeyboardShortcuts.js +2235 -0
  73. package/dist/KeyboardShortcuts.js.map +1 -0
  74. package/dist/LoginPage.cjs.js +618 -0
  75. package/dist/LoginPage.cjs.js.map +1 -0
  76. package/dist/LoginPage.js +593 -0
  77. package/dist/LoginPage.js.map +1 -0
  78. package/dist/MenuBar.cjs.js +31044 -0
  79. package/dist/MenuBar.cjs.js.map +1 -0
  80. package/dist/MenuBar.js +31038 -0
  81. package/dist/MenuBar.js.map +1 -0
  82. package/dist/NeetoWidget.cjs.js +3369 -0
  83. package/dist/NeetoWidget.cjs.js.map +1 -0
  84. package/dist/NeetoWidget.js +3343 -0
  85. package/dist/NeetoWidget.js.map +1 -0
  86. package/dist/PageLoader.cjs.js +158 -0
  87. package/dist/PageLoader.cjs.js.map +1 -0
  88. package/dist/PageLoader.js +134 -0
  89. package/dist/PageLoader.js.map +1 -0
  90. package/dist/PhoneNumber.cjs.js +7021 -0
  91. package/dist/PhoneNumber.cjs.js.map +1 -0
  92. package/dist/PhoneNumber.js +6989 -0
  93. package/dist/PhoneNumber.js.map +1 -0
  94. package/dist/PublishBlock.cjs.js +189 -0
  95. package/dist/PublishBlock.cjs.js.map +1 -0
  96. package/dist/PublishBlock.js +183 -0
  97. package/dist/PublishBlock.js.map +1 -0
  98. package/dist/Rename.cjs.js +306 -0
  99. package/dist/Rename.cjs.js.map +1 -0
  100. package/dist/Rename.js +300 -0
  101. package/dist/Rename.js.map +1 -0
  102. package/dist/ResponsiveDevicePicker.cjs.js +260 -0
  103. package/dist/ResponsiveDevicePicker.cjs.js.map +1 -0
  104. package/dist/ResponsiveDevicePicker.js +254 -0
  105. package/dist/ResponsiveDevicePicker.js.map +1 -0
  106. package/dist/Schedule.cjs.js +952 -0
  107. package/dist/Schedule.cjs.js.map +1 -0
  108. package/dist/Schedule.js +921 -0
  109. package/dist/Schedule.js.map +1 -0
  110. package/dist/Scrollable.cjs.js +184 -0
  111. package/dist/Scrollable.cjs.js.map +1 -0
  112. package/dist/Scrollable.js +178 -0
  113. package/dist/Scrollable.js.map +1 -0
  114. package/dist/ShareViaEmail.cjs.js +2992 -0
  115. package/dist/ShareViaEmail.cjs.js.map +1 -0
  116. package/dist/ShareViaEmail.js +2966 -0
  117. package/dist/ShareViaEmail.js.map +1 -0
  118. package/dist/ShareViaLink.cjs.js +1385 -0
  119. package/dist/ShareViaLink.cjs.js.map +1 -0
  120. package/dist/ShareViaLink.js +1360 -0
  121. package/dist/ShareViaLink.js.map +1 -0
  122. package/dist/Sidebar.cjs.js +32222 -0
  123. package/dist/Sidebar.cjs.js.map +1 -0
  124. package/dist/Sidebar.js +32196 -0
  125. package/dist/Sidebar.js.map +1 -0
  126. package/dist/SubHeader.cjs.js +272 -0
  127. package/dist/SubHeader.cjs.js.map +1 -0
  128. package/dist/SubHeader.js +265 -0
  129. package/dist/SubHeader.js.map +1 -0
  130. package/dist/TableWrapper.cjs.js +87 -0
  131. package/dist/TableWrapper.cjs.js.map +1 -0
  132. package/dist/TableWrapper.js +81 -0
  133. package/dist/TableWrapper.js.map +1 -0
  134. package/dist/ThemeSidebar.cjs.js +13618 -0
  135. package/dist/ThemeSidebar.cjs.js.map +1 -0
  136. package/dist/ThemeSidebar.js +13593 -0
  137. package/dist/ThemeSidebar.js.map +1 -0
  138. package/dist/TimeFormat.cjs.js +53 -0
  139. package/dist/TimeFormat.cjs.js.map +1 -0
  140. package/dist/TimeFormat.js +47 -0
  141. package/dist/TimeFormat.js.map +1 -0
  142. package/dist/TimezoneMismatchModal.cjs.js +176 -0
  143. package/dist/TimezoneMismatchModal.cjs.js.map +1 -0
  144. package/dist/TimezoneMismatchModal.js +168 -0
  145. package/dist/TimezoneMismatchModal.js.map +1 -0
  146. package/package.json +185 -0
  147. package/src/translations/en.json +449 -0
  148. package/types/BrowserSupport.d.ts +86 -0
  149. package/types/Columns.d.ts +53 -0
  150. package/types/Container.d.ts +35 -0
  151. package/types/CopyToClipboardButton.d.ts +21 -0
  152. package/types/CustomDomain.d.ts +19 -0
  153. package/types/CustomDomainDashboard.d.ts +33 -0
  154. package/types/DateFormat.d.ts +18 -0
  155. package/types/DateRangeFilter.d.ts +52 -0
  156. package/types/DynamicVariables.d.ts +45 -0
  157. package/types/EmailPreview.d.ts +41 -0
  158. package/types/ErrorPage.d.ts +15 -0
  159. package/types/Header.d.ts +30 -0
  160. package/types/IconPicker.d.ts +43 -0
  161. package/types/IntegrationCard.d.ts +45 -0
  162. package/types/IntegrationDisconnectAlert.d.ts +37 -0
  163. package/types/IntegrationWalkthroughModal.d.ts +31 -0
  164. package/types/IpRestriction.d.ts +23 -0
  165. package/types/KeyboardShortcuts.d.ts +147 -0
  166. package/types/LoginPage.d.ts +43 -0
  167. package/types/MenuBar.d.ts +125 -0
  168. package/types/NeetoWidget.d.ts +41 -0
  169. package/types/PageLoader.d.ts +38 -0
  170. package/types/PhoneNumber.d.ts +106 -0
  171. package/types/PublishBlock.d.ts +84 -0
  172. package/types/Rename.d.ts +60 -0
  173. package/types/ResponsiveDevicePicker.d.ts +30 -0
  174. package/types/Schedule.d.ts +132 -0
  175. package/types/Scrollable.d.ts +28 -0
  176. package/types/ShareViaEmail.d.ts +99 -0
  177. package/types/ShareViaLink.d.ts +117 -0
  178. package/types/Sidebar.d.ts +63 -0
  179. package/types/SubHeader.d.ts +97 -0
  180. package/types/TableWrapper.d.ts +38 -0
  181. package/types/TimeFormat.d.ts +17 -0
  182. package/types/TimezoneMismatchModal.d.ts +39 -0
  183. package/types/themeSidebar.d.ts +80 -0
@@ -0,0 +1,654 @@
1
+ import React, { useRef, useState } from 'react';
2
+ import { snakeToCamelCase, isNotEmpty, noop } from '@bigbinary/neeto-commons-frontend/pure';
3
+ import { Info, Copy, Check, MenuHorizontal, CustomDomain as CustomDomain$1 } from '@bigbinary/neeto-icons';
4
+ import { Alert, Tag, Button, Dropdown, Callout, Input, Pane, Typography, Label, Spinner } from '@bigbinary/neetoui';
5
+ import { useTranslation, Trans } from 'react-i18next';
6
+ import { Formik, Form } from 'formik';
7
+ import { Input as Input$1 } from '@bigbinary/neetoui/formik';
8
+ import { joinHyphenCase, copyToClipboard, timeFormat } from '@bigbinary/neeto-commons-frontend/utils';
9
+ import { t } from 'i18next';
10
+ import * as Yup from 'yup';
11
+ import { useQueryClient, useMutation, useQuery } from 'react-query';
12
+ import axios from 'axios';
13
+
14
+ function _arrayWithHoles(arr) {
15
+ if (Array.isArray(arr)) return arr;
16
+ }
17
+
18
+ function _iterableToArrayLimit(arr, i) {
19
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
20
+ if (null != _i) {
21
+ var _s,
22
+ _e,
23
+ _x,
24
+ _r,
25
+ _arr = [],
26
+ _n = !0,
27
+ _d = !1;
28
+ try {
29
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
30
+ if (Object(_i) !== _i) return;
31
+ _n = !1;
32
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
33
+ } catch (err) {
34
+ _d = !0, _e = err;
35
+ } finally {
36
+ try {
37
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
38
+ } finally {
39
+ if (_d) throw _e;
40
+ }
41
+ }
42
+ return _arr;
43
+ }
44
+ }
45
+
46
+ function _arrayLikeToArray(arr, len) {
47
+ if (len == null || len > arr.length) len = arr.length;
48
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
49
+ return arr2;
50
+ }
51
+
52
+ function _unsupportedIterableToArray(o, minLen) {
53
+ if (!o) return;
54
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
55
+ var n = Object.prototype.toString.call(o).slice(8, -1);
56
+ if (n === "Object" && o.constructor) n = o.constructor.name;
57
+ if (n === "Map" || n === "Set") return Array.from(o);
58
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
59
+ }
60
+
61
+ function _nonIterableRest() {
62
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
63
+ }
64
+
65
+ function _slicedToArray(arr, i) {
66
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
67
+ }
68
+
69
+ var DEFAULT_STALE_TIME = 60 * 60 * 1000;
70
+ var DOMAIN_QUERY_KEY = "custom-domain";
71
+ var SINGULAR = {
72
+ count: 1
73
+ };
74
+
75
+ var DeleteAlert = function DeleteAlert(_ref) {
76
+ var onClose = _ref.onClose,
77
+ onSubmit = _ref.onSubmit,
78
+ isOpen = _ref.isOpen,
79
+ isSubmitting = _ref.isSubmitting,
80
+ hostname = _ref.hostname;
81
+ var _useTranslation = useTranslation(),
82
+ t = _useTranslation.t;
83
+ return /*#__PURE__*/React.createElement(Alert, {
84
+ cancelButtonLabel: t("neetoMolecules.common.actions.cancel"),
85
+ isOpen: isOpen,
86
+ isSubmitting: isSubmitting,
87
+ submitButtonLabel: t("neetoMolecules.common.actions.delete"),
88
+ title: t("neetoMolecules.customDomain.delete"),
89
+ message: /*#__PURE__*/React.createElement(Trans, {
90
+ i18nKey: "neetoMolecules.customDomain.alertMessage",
91
+ values: {
92
+ hostname: hostname
93
+ }
94
+ }),
95
+ onClose: onClose,
96
+ onSubmit: onSubmit
97
+ });
98
+ };
99
+
100
+ var HOSTNAME_REGEX = /^(?!-)[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+/;
101
+ var INITIAL_VALUES = {
102
+ hostname: ""
103
+ };
104
+
105
+ var classnames$1 = {exports: {}};
106
+
107
+ /*!
108
+ Copyright (c) 2018 Jed Watson.
109
+ Licensed under the MIT License (MIT), see
110
+ http://jedwatson.github.io/classnames
111
+ */
112
+
113
+ (function (module) {
114
+ /* global define */
115
+
116
+ (function () {
117
+
118
+ var hasOwn = {}.hasOwnProperty;
119
+
120
+ function classNames() {
121
+ var classes = [];
122
+
123
+ for (var i = 0; i < arguments.length; i++) {
124
+ var arg = arguments[i];
125
+ if (!arg) continue;
126
+
127
+ var argType = typeof arg;
128
+
129
+ if (argType === 'string' || argType === 'number') {
130
+ classes.push(arg);
131
+ } else if (Array.isArray(arg)) {
132
+ if (arg.length) {
133
+ var inner = classNames.apply(null, arg);
134
+ if (inner) {
135
+ classes.push(inner);
136
+ }
137
+ }
138
+ } else if (argType === 'object') {
139
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
140
+ classes.push(arg.toString());
141
+ continue;
142
+ }
143
+
144
+ for (var key in arg) {
145
+ if (hasOwn.call(arg, key) && arg[key]) {
146
+ classes.push(key);
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ return classes.join(' ');
153
+ }
154
+
155
+ if (module.exports) {
156
+ classNames.default = classNames;
157
+ module.exports = classNames;
158
+ } else {
159
+ window.classNames = classNames;
160
+ }
161
+ }());
162
+ } (classnames$1));
163
+
164
+ var classnames = classnames$1.exports;
165
+
166
+ var TagBlock = function TagBlock(_ref) {
167
+ var status = _ref.status,
168
+ isCnameRecordsAdded = _ref.isCnameRecordsAdded,
169
+ _ref$stacked = _ref.stacked,
170
+ stacked = _ref$stacked === void 0 ? false : _ref$stacked,
171
+ handleValidateCname = _ref.handleValidateCname;
172
+ var _useTranslation = useTranslation(),
173
+ t = _useTranslation.t;
174
+ var isDomainValidated = status === "active" || status === "pending_cname_validation";
175
+ var camelCasedStatus = snakeToCamelCase(status || "");
176
+ return /*#__PURE__*/React.createElement("div", {
177
+ className: classnames("flex gap-2", {
178
+ "flex-col items-start": stacked
179
+ })
180
+ }, status === "failed" ? /*#__PURE__*/React.createElement(Tag, {
181
+ indicatorStyle: "danger",
182
+ label: t("neetoMolecules.customDomain.status.".concat(camelCasedStatus)),
183
+ style: "secondary"
184
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tag, {
185
+ indicatorStyle: isDomainValidated ? "success" : "warning",
186
+ style: "secondary",
187
+ label: t("neetoMolecules.customDomain.status.domain.".concat(camelCasedStatus))
188
+ }), isDomainValidated && /*#__PURE__*/React.createElement("div", {
189
+ className: classnames("flex items-center justify-between gap-2", {
190
+ "w-full": stacked
191
+ })
192
+ }, /*#__PURE__*/React.createElement(Tag, {
193
+ indicatorStyle: status === "active" ? "success" : "warning",
194
+ style: "secondary",
195
+ label: t("neetoMolecules.customDomain.status.cname.".concat(camelCasedStatus))
196
+ }), isCnameRecordsAdded && status === "pending_cname_validation" && /*#__PURE__*/React.createElement(Button, {
197
+ className: "text-xs",
198
+ style: "link",
199
+ label: t("neetoMolecules.customDomain.validation.buttonLabel.cnameCheck"),
200
+ onClick: handleValidateCname
201
+ }))));
202
+ };
203
+ var TagBlock$1 = /*#__PURE__*/React.memo(TagBlock);
204
+
205
+ Dropdown.Menu;
206
+ Dropdown.MenuItem;
207
+ var recordData = function recordData(customDomain) {
208
+ var status = customDomain.status,
209
+ hostname = customDomain.hostname,
210
+ dnsTarget = customDomain.dnsTarget,
211
+ cnameValidationParams = customDomain.cnameValidationParams;
212
+ var isDomainValidated = status === "active" || status === "pending_cname_validation";
213
+ var recordName = isDomainValidated ? hostname : cnameValidationParams === null || cnameValidationParams === void 0 ? void 0 : cnameValidationParams.name;
214
+ var recordValue = isDomainValidated ? dnsTarget : cnameValidationParams === null || cnameValidationParams === void 0 ? void 0 : cnameValidationParams.value;
215
+ var recordType = isDomainValidated ? t("neetoMolecules.customDomain.cname") : t("neetoMolecules.customDomain.domainValidationCname");
216
+ var recordDescription = t("neetoMolecules.customDomain.validation.desc", {
217
+ record: recordType
218
+ });
219
+ var recordNameLabel = t("neetoMolecules.customDomain.validation.record", {
220
+ record: recordType,
221
+ type: t("neetoMolecules.common.name")
222
+ });
223
+ var recordValueLabel = t("neetoMolecules.customDomain.validation.record", {
224
+ record: recordType,
225
+ type: t("neetoMolecules.common.value")
226
+ });
227
+ return {
228
+ recordName: recordName,
229
+ recordValue: recordValue,
230
+ recordDescription: recordDescription,
231
+ recordNameLabel: recordNameLabel,
232
+ recordValueLabel: recordValueLabel
233
+ };
234
+ };
235
+
236
+ var Record = function Record(_ref) {
237
+ var customDomain = _ref.customDomain;
238
+ var _recordData = recordData(customDomain),
239
+ recordName = _recordData.recordName,
240
+ recordValue = _recordData.recordValue,
241
+ recordDescription = _recordData.recordDescription,
242
+ recordNameLabel = _recordData.recordNameLabel,
243
+ recordValueLabel = _recordData.recordValueLabel;
244
+ return /*#__PURE__*/React.createElement("div", {
245
+ className: "mt-6 grid gap-4"
246
+ }, customDomain.status !== "active" && /*#__PURE__*/React.createElement(Callout, {
247
+ icon: Info,
248
+ style: "info"
249
+ }, recordDescription), /*#__PURE__*/React.createElement(Input, {
250
+ disabled: true,
251
+ "data-cy": joinHyphenCase(recordNameLabel),
252
+ label: recordNameLabel,
253
+ value: recordName,
254
+ suffix: /*#__PURE__*/React.createElement(Button, {
255
+ icon: Copy,
256
+ style: "text",
257
+ onClick: function onClick() {
258
+ return copyToClipboard(recordName);
259
+ }
260
+ })
261
+ }), /*#__PURE__*/React.createElement(Input, {
262
+ disabled: true,
263
+ "data-cy": joinHyphenCase(recordValueLabel),
264
+ label: recordValueLabel,
265
+ value: recordValue,
266
+ suffix: /*#__PURE__*/React.createElement(Button, {
267
+ icon: Copy,
268
+ style: "text",
269
+ onClick: function onClick() {
270
+ return copyToClipboard(recordValue);
271
+ }
272
+ })
273
+ }));
274
+ };
275
+ var Record$1 = /*#__PURE__*/React.memo(Record);
276
+
277
+ var CustomDomainInfo = function CustomDomainInfo(_ref) {
278
+ var time = _ref.time;
279
+ var _useTranslation = useTranslation(),
280
+ t = _useTranslation.t;
281
+ return /*#__PURE__*/React.createElement("div", {
282
+ className: "space-y-6"
283
+ }, /*#__PURE__*/React.createElement("div", {
284
+ className: "neeto-ui-rounded neeto-ui-bg-gray-100 neeto-ui-text-gray-700 space-y-3 p-4"
285
+ }, /*#__PURE__*/React.createElement(Trans, {
286
+ i18nKey: "neetoMolecules.customDomain.messageBlock.dnsStatus"
287
+ }), /*#__PURE__*/React.createElement(Button, {
288
+ href: "mailto:support@neeto.com",
289
+ label: "support@neeto.com",
290
+ style: "link"
291
+ })), /*#__PURE__*/React.createElement(Callout, {
292
+ icon: Info,
293
+ style: "info"
294
+ }, t("neetoMolecules.customDomain.messageBlock.cnameAddedTime", {
295
+ time: timeFormat.fromNow(time)
296
+ })));
297
+ };
298
+ var StatusInfo = /*#__PURE__*/React.memo(CustomDomainInfo);
299
+
300
+ var getCustomDomainValidationSchema = function getCustomDomainValidationSchema() {
301
+ return Yup.object().shape({
302
+ hostname: Yup.string().required(t("neetoMolecules.customDomain.formikValidation.required")).matches(HOSTNAME_REGEX, t("neetoMolecules.customDomain.formikValidation.valid"))
303
+ });
304
+ };
305
+
306
+ function _typeof(obj) {
307
+ "@babel/helpers - typeof";
308
+
309
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
310
+ return typeof obj;
311
+ } : function (obj) {
312
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
313
+ }, _typeof(obj);
314
+ }
315
+
316
+ function _toPrimitive(input, hint) {
317
+ if (_typeof(input) !== "object" || input === null) return input;
318
+ var prim = input[Symbol.toPrimitive];
319
+ if (prim !== undefined) {
320
+ var res = prim.call(input, hint || "default");
321
+ if (_typeof(res) !== "object") return res;
322
+ throw new TypeError("@@toPrimitive must return a primitive value.");
323
+ }
324
+ return (hint === "string" ? String : Number)(input);
325
+ }
326
+
327
+ function _toPropertyKey(arg) {
328
+ var key = _toPrimitive(arg, "string");
329
+ return _typeof(key) === "symbol" ? key : String(key);
330
+ }
331
+
332
+ function _defineProperty(obj, key, value) {
333
+ key = _toPropertyKey(key);
334
+ if (key in obj) {
335
+ Object.defineProperty(obj, key, {
336
+ value: value,
337
+ enumerable: true,
338
+ configurable: true,
339
+ writable: true
340
+ });
341
+ } else {
342
+ obj[key] = value;
343
+ }
344
+ return obj;
345
+ }
346
+
347
+ var getUrlwithId = function getUrlwithId(url, id) {
348
+ return id ? "".concat(url, "/").concat(id) : url;
349
+ };
350
+ var fetchCustomDomains = function fetchCustomDomains(_ref) {
351
+ var url = _ref.url,
352
+ params = _ref.params;
353
+ return axios.get(url, {
354
+ params: params
355
+ });
356
+ };
357
+ var updateCustomDomain = function updateCustomDomain(url, id) {
358
+ return axios.patch(getUrlwithId(url, id));
359
+ };
360
+ var createCustomDomain = function createCustomDomain(url, payload) {
361
+ return axios.post(url, payload);
362
+ };
363
+ var deleteCustomDomain = function deleteCustomDomain(url, id) {
364
+ return axios["delete"](getUrlwithId(url, id));
365
+ };
366
+ var validateDomain = function validateDomain(url, id) {
367
+ return axios.patch("".concat(getUrlwithId(url, id), "/validate_domain"));
368
+ };
369
+ var validateCname = function validateCname(url, id) {
370
+ return axios.patch("".concat(getUrlwithId(url, id), "/validate_cname"));
371
+ };
372
+ var customDomainApi = {
373
+ createCustomDomain: createCustomDomain,
374
+ deleteCustomDomain: deleteCustomDomain,
375
+ validateDomain: validateDomain,
376
+ fetchCustomDomains: fetchCustomDomains,
377
+ validateCname: validateCname,
378
+ updateCustomDomain: updateCustomDomain
379
+ };
380
+
381
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
382
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
383
+ var useCreateCustomDomain = function useCreateCustomDomain(url) {
384
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
385
+ var queryClient = useQueryClient();
386
+ return useMutation(function (payload) {
387
+ return customDomainApi.createCustomDomain(url, payload);
388
+ }, _objectSpread(_objectSpread({}, options), {}, {
389
+ onSuccess: function onSuccess() {
390
+ return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
391
+ }
392
+ }));
393
+ };
394
+ var useDeleteCustomDomain = function useDeleteCustomDomain(url) {
395
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
396
+ var queryClient = useQueryClient();
397
+ return useMutation(function (id) {
398
+ return customDomainApi.deleteCustomDomain(url, id);
399
+ }, _objectSpread(_objectSpread({}, options), {}, {
400
+ onSuccess: function onSuccess(result) {
401
+ var _options$onSuccess;
402
+ (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, result);
403
+ queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
404
+ }
405
+ }));
406
+ };
407
+ var useFetchCustomDomains = function useFetchCustomDomains(params) {
408
+ return useQuery([DOMAIN_QUERY_KEY, _objectSpread({}, params)], function () {
409
+ return customDomainApi.fetchCustomDomains(params);
410
+ }, {
411
+ staleTime: DEFAULT_STALE_TIME
412
+ });
413
+ };
414
+ var useValidateDomain = function useValidateDomain(url) {
415
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
416
+ var queryClient = useQueryClient();
417
+ return useMutation(function (id) {
418
+ return customDomainApi.validateDomain(url, id);
419
+ }, _objectSpread(_objectSpread({}, options), {}, {
420
+ onSuccess: function onSuccess() {
421
+ return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
422
+ }
423
+ }));
424
+ };
425
+ var useValidateCname = function useValidateCname(url) {
426
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
427
+ var queryClient = useQueryClient();
428
+ return useMutation(function (id) {
429
+ return customDomainApi.validateCname(url, id);
430
+ }, _objectSpread(_objectSpread({}, options), {}, {
431
+ onSuccess: function onSuccess() {
432
+ return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
433
+ }
434
+ }));
435
+ };
436
+ var useUpdateCustomDomain = function useUpdateCustomDomain(url) {
437
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
438
+ var queryClient = useQueryClient();
439
+ return useMutation(function (id) {
440
+ return customDomainApi.updateCustomDomain(url, id);
441
+ }, _objectSpread(_objectSpread({}, options), {}, {
442
+ onSuccess: function onSuccess() {
443
+ return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
444
+ }
445
+ }));
446
+ };
447
+
448
+ var Manage = function Manage(_ref) {
449
+ var isOpen = _ref.isOpen,
450
+ onClose = _ref.onClose,
451
+ customDomain = _ref.customDomain,
452
+ setCustomDomain = _ref.setCustomDomain,
453
+ url = _ref.url,
454
+ hasOne = _ref.hasOne;
455
+ var _useTranslation = useTranslation(),
456
+ t = _useTranslation.t;
457
+ var initialFocusRef = useRef(null);
458
+ var customDomainId = hasOne ? null : customDomain === null || customDomain === void 0 ? void 0 : customDomain.id;
459
+ var _useCreateCustomDomai = useCreateCustomDomain(url),
460
+ createCustomDomain = _useCreateCustomDomai.mutate,
461
+ isCreating = _useCreateCustomDomai.isLoading;
462
+ var _useValidateDomain = useValidateDomain(url),
463
+ validateDomain = _useValidateDomain.mutate,
464
+ isValidating = _useValidateDomain.isLoading;
465
+ var _useValidateCname = useValidateCname(url),
466
+ validateCname = _useValidateCname.mutate,
467
+ isCnameValidating = _useValidateCname.isLoading;
468
+ var _useUpdateCustomDomai = useUpdateCustomDomain(url),
469
+ updateCustomDomain = _useUpdateCustomDomai.mutate,
470
+ isUpdating = _useUpdateCustomDomai.isLoading;
471
+ var handleSubmit = function handleSubmit(values) {
472
+ return createCustomDomain(values, {
473
+ onSuccess: function onSuccess(values) {
474
+ return setCustomDomain(values);
475
+ }
476
+ });
477
+ };
478
+ var handleValidateDomain = function handleValidateDomain() {
479
+ return validateDomain(customDomainId, {
480
+ onSuccess: function onSuccess(values) {
481
+ return setCustomDomain(values);
482
+ }
483
+ });
484
+ };
485
+ var handleValidateCname = function handleValidateCname() {
486
+ validateCname(customDomainId, {
487
+ onSuccess: function onSuccess(data) {
488
+ return setCustomDomain(data);
489
+ }
490
+ });
491
+ };
492
+ var handleUpdateCname = function handleUpdateCname() {
493
+ updateCustomDomain(customDomainId, {
494
+ onSuccess: function onSuccess(data) {
495
+ return setCustomDomain(data);
496
+ }
497
+ });
498
+ };
499
+ return /*#__PURE__*/React.createElement(Pane, {
500
+ initialFocusRef: initialFocusRef,
501
+ isOpen: isOpen,
502
+ onClose: onClose
503
+ }, /*#__PURE__*/React.createElement(Formik, {
504
+ enableReinitialize: true,
505
+ initialValues: customDomain || INITIAL_VALUES,
506
+ validationSchema: getCustomDomainValidationSchema(),
507
+ onSubmit: handleSubmit
508
+ }, function (_ref2) {
509
+ var dirty = _ref2.dirty;
510
+ return /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
511
+ "data-cy": "add-custom-domain-pane-heading",
512
+ style: "h2",
513
+ weight: "semibold"
514
+ }, isNotEmpty(customDomain) ? t("neetoMolecules.customDomain.edit") : t("neetoMolecules.customDomain.addNew"))), /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
515
+ className: "w-full space-y-6"
516
+ }, isNotEmpty(customDomain) && /*#__PURE__*/React.createElement(TagBlock$1, {
517
+ stacked: true,
518
+ handleValidateCname: handleValidateCname,
519
+ isCnameRecordsAdded: customDomain.addedCnameAt,
520
+ status: customDomain.status
521
+ }), /*#__PURE__*/React.createElement("div", {
522
+ className: "space-y-2"
523
+ }, /*#__PURE__*/React.createElement(Label, {
524
+ htmlFor: "hostname"
525
+ }, isNotEmpty(customDomain) ? t("neetoMolecules.customDomain.customDomain", SINGULAR) : t("neetoMolecules.customDomain.label")), /*#__PURE__*/React.createElement("div", {
526
+ className: "flex items-start gap-2"
527
+ }, /*#__PURE__*/React.createElement(Input$1, {
528
+ "data-cy": "custom-domain-input-field",
529
+ disabled: isNotEmpty(customDomain),
530
+ name: "hostname",
531
+ placeholder: t("neetoMolecules.customDomain.placeholder"),
532
+ ref: initialFocusRef
533
+ }), !isNotEmpty(customDomain) && /*#__PURE__*/React.createElement(Button, {
534
+ "data-cy": "submit-custom-domain-button",
535
+ disabled: !dirty || isCreating,
536
+ icon: Check,
537
+ loading: isCreating,
538
+ style: "primary",
539
+ type: "submit"
540
+ }))), isNotEmpty(customDomain) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Record$1, {
541
+ customDomain: customDomain
542
+ }), customDomain.status === "pending_domain_validation" && /*#__PURE__*/React.createElement(Button, {
543
+ "data-cy": "validate-domain-button",
544
+ disabled: isValidating,
545
+ loading: isValidating,
546
+ label: t("neetoMolecules.customDomain.validation.buttonLabel.domain"),
547
+ onClick: handleValidateDomain
548
+ }), customDomain.status === "pending_cname_validation" && !customDomain.addedCnameAt && /*#__PURE__*/React.createElement(Button, {
549
+ "data-cy": "validate-cname-record-button",
550
+ loading: isCnameValidating || isUpdating,
551
+ label: t("neetoMolecules.customDomain.validation.buttonLabel.cnameAdded"),
552
+ onClick: handleUpdateCname
553
+ }), customDomain.status === "pending_cname_validation" && customDomain.addedCnameAt && /*#__PURE__*/React.createElement(StatusInfo, {
554
+ time: customDomain.addedCnameAt
555
+ })))));
556
+ }));
557
+ };
558
+
559
+ var CustomDomain = function CustomDomain(_ref) {
560
+ var url = _ref.url,
561
+ iconOnly = _ref.iconOnly;
562
+ var Menu = Dropdown.Menu,
563
+ MenuItem = Dropdown.MenuItem;
564
+ var _useState = useState(false),
565
+ _useState2 = _slicedToArray(_useState, 2),
566
+ isPaneOpen = _useState2[0],
567
+ setIsPaneOpen = _useState2[1];
568
+ var _useState3 = useState(false),
569
+ _useState4 = _slicedToArray(_useState3, 2),
570
+ isAlertOpen = _useState4[0],
571
+ setIsAlertOpen = _useState4[1];
572
+ var _useTranslation = useTranslation(),
573
+ t = _useTranslation.t;
574
+ var _useFetchCustomDomain = useFetchCustomDomains({
575
+ url: url
576
+ }),
577
+ customDomain = _useFetchCustomDomain.data,
578
+ isLoading = _useFetchCustomDomain.isLoading;
579
+ var _useDeleteCustomDomai = useDeleteCustomDomain(url, {
580
+ onSettled: function onSettled() {
581
+ return setIsAlertOpen(false);
582
+ }
583
+ }),
584
+ deleteCustomDomain = _useDeleteCustomDomai.mutate,
585
+ isDeleting = _useDeleteCustomDomai.isLoading;
586
+ var actions = [{
587
+ key: "edit",
588
+ label: t("neetoMolecules.common.actions.edit"),
589
+ onClick: function onClick() {
590
+ return setIsPaneOpen(true);
591
+ }
592
+ }, {
593
+ key: "delete",
594
+ label: t("neetoMolecules.common.actions.delete"),
595
+ onClick: function onClick() {
596
+ return setIsAlertOpen(true);
597
+ }
598
+ }];
599
+ if (isLoading) return /*#__PURE__*/React.createElement(Spinner, null);
600
+ return /*#__PURE__*/React.createElement("div", null, isNotEmpty(customDomain) ? /*#__PURE__*/React.createElement("div", {
601
+ className: "flex flex-row items-center"
602
+ }, /*#__PURE__*/React.createElement(Tag, {
603
+ label: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname,
604
+ style: customDomain.status === "active" ? "success" : "warning"
605
+ }), /*#__PURE__*/React.createElement(Dropdown, {
606
+ autoWidth: true,
607
+ buttonStyle: "text",
608
+ icon: MenuHorizontal
609
+ }, /*#__PURE__*/React.createElement(Menu, null, actions.map(function (_ref2) {
610
+ var key = _ref2.key,
611
+ label = _ref2.label,
612
+ onClick = _ref2.onClick,
613
+ style = _ref2.style;
614
+ return /*#__PURE__*/React.createElement(MenuItem.Button, {
615
+ key: key,
616
+ style: style,
617
+ onClick: onClick
618
+ }, label);
619
+ })))) : /*#__PURE__*/React.createElement(Button, {
620
+ icon: iconOnly && CustomDomain$1,
621
+ style: "text",
622
+ label: iconOnly ? "" : t("neetoMolecules.common.actions.add", {
623
+ entity: t("neetoMolecules.customDomain.customDomain", SINGULAR).toLowerCase()
624
+ }),
625
+ tooltipProps: iconOnly && {
626
+ content: t("neetoMolecules.customDomain.customDomain", SINGULAR)
627
+ },
628
+ onClick: function onClick() {
629
+ return setIsPaneOpen(true);
630
+ }
631
+ }), /*#__PURE__*/React.createElement(Manage, {
632
+ hasOne: true,
633
+ customDomain: customDomain,
634
+ isOpen: isPaneOpen,
635
+ setCustomDomain: noop,
636
+ url: url,
637
+ onClose: function onClose() {
638
+ return setIsPaneOpen(false);
639
+ }
640
+ }), /*#__PURE__*/React.createElement(DeleteAlert, {
641
+ hostname: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname,
642
+ isOpen: isAlertOpen,
643
+ isSubmitting: isDeleting,
644
+ onClose: function onClose() {
645
+ return setIsAlertOpen(false);
646
+ },
647
+ onSubmit: function onSubmit() {
648
+ return deleteCustomDomain();
649
+ }
650
+ }));
651
+ };
652
+
653
+ export { CustomDomain as default };
654
+ //# sourceMappingURL=CustomDomain.js.map