@blocklet/payment-react 1.13.211 → 1.13.212

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.
@@ -0,0 +1,3 @@
1
+ export default function SafeGuard({ children }: {
2
+ children: any;
3
+ }): any;
@@ -0,0 +1,4 @@
1
+ import { isPaymentKitMounted } from "../util.js";
2
+ export default function SafeGuard({ children }) {
3
+ return isPaymentKitMounted() ? children : null;
4
+ }
package/es/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import ConfirmDialog from './components/confirm';
7
7
  import FormInput from './components/input';
8
8
  import Livemode from './components/livemode';
9
9
  import PricingTable from './components/pricing-table';
10
+ import SafeGuard from './components/safe-guard';
10
11
  import Status from './components/status';
11
12
  import Switch from './components/switch-button';
12
13
  import dayjs from './dayjs';
@@ -24,4 +25,4 @@ import PaymentSummary from './payment/summary';
24
25
  export * from './util';
25
26
  export * from './contexts/payment';
26
27
  export { translations, createTranslator } from './locales';
27
- export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
28
+ export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, SafeGuard, };
package/es/index.js CHANGED
@@ -7,6 +7,7 @@ import ConfirmDialog from "./components/confirm.js";
7
7
  import FormInput from "./components/input.js";
8
8
  import Livemode from "./components/livemode.js";
9
9
  import PricingTable from "./components/pricing-table.js";
10
+ import SafeGuard from "./components/safe-guard.js";
10
11
  import Status from "./components/status.js";
11
12
  import Switch from "./components/switch-button.js";
12
13
  import dayjs from "./dayjs.js";
@@ -47,5 +48,6 @@ export {
47
48
  CustomerInvoiceList,
48
49
  CustomerPaymentList,
49
50
  MiniInvoiceList,
50
- TxLink
51
+ TxLink,
52
+ SafeGuard
51
53
  };
package/es/util.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
3
3
  export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
4
+ export declare const isPaymentKitMounted: () => any;
4
5
  export declare const getPrefix: () => any;
5
6
  export declare function formatToDate(date: Date | string | number, locale?: string): any;
6
7
  export declare function formatToDatetime(date: Date | string | number, locale?: string): any;
package/es/util.js CHANGED
@@ -6,6 +6,9 @@ import { joinURL } from "ufo";
6
6
  import dayjs from "./dayjs.js";
7
7
  import { t } from "./locales/index.js";
8
8
  export const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
9
+ export const isPaymentKitMounted = () => {
10
+ return (window.blocklet?.componentMountPoints || []).some((x) => x.did === PAYMENT_KIT_DID);
11
+ };
9
12
  export const getPrefix = () => {
10
13
  const componentId = (window?.blocklet?.componentId || "").split("/").pop();
11
14
  if (componentId === PAYMENT_KIT_DID) {
@@ -0,0 +1,3 @@
1
+ export default function SafeGuard({ children }: {
2
+ children: any;
3
+ }): any;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = SafeGuard;
7
+ var _util = require("../util");
8
+ function SafeGuard({
9
+ children
10
+ }) {
11
+ return (0, _util.isPaymentKitMounted)() ? children : null;
12
+ }
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import ConfirmDialog from './components/confirm';
7
7
  import FormInput from './components/input';
8
8
  import Livemode from './components/livemode';
9
9
  import PricingTable from './components/pricing-table';
10
+ import SafeGuard from './components/safe-guard';
10
11
  import Status from './components/status';
11
12
  import Switch from './components/switch-button';
12
13
  import dayjs from './dayjs';
@@ -24,4 +25,4 @@ import PaymentSummary from './payment/summary';
24
25
  export * from './util';
25
26
  export * from './contexts/payment';
26
27
  export { translations, createTranslator } from './locales';
27
- export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
28
+ export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, SafeGuard, };
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ var _exportNames = {
13
13
  FormInput: true,
14
14
  Livemode: true,
15
15
  PricingTable: true,
16
+ SafeGuard: true,
16
17
  Status: true,
17
18
  Switch: true,
18
19
  dayjs: true,
@@ -132,6 +133,12 @@ Object.defineProperty(exports, "ProductSkeleton", {
132
133
  return _productSkeleton.default;
133
134
  }
134
135
  });
136
+ Object.defineProperty(exports, "SafeGuard", {
137
+ enumerable: true,
138
+ get: function () {
139
+ return _safeGuard.default;
140
+ }
141
+ });
135
142
  Object.defineProperty(exports, "Status", {
136
143
  enumerable: true,
137
144
  get: function () {
@@ -189,6 +196,7 @@ var _confirm = _interopRequireDefault(require("./components/confirm"));
189
196
  var _input = _interopRequireDefault(require("./components/input"));
190
197
  var _livemode = _interopRequireDefault(require("./components/livemode"));
191
198
  var _pricingTable = _interopRequireDefault(require("./components/pricing-table"));
199
+ var _safeGuard = _interopRequireDefault(require("./components/safe-guard"));
192
200
  var _status = _interopRequireDefault(require("./components/status"));
193
201
  var _switchButton = _interopRequireDefault(require("./components/switch-button"));
194
202
  var _dayjs = _interopRequireDefault(require("./dayjs"));
package/lib/util.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
3
3
  export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
4
+ export declare const isPaymentKitMounted: () => any;
4
5
  export declare const getPrefix: () => any;
5
6
  export declare function formatToDate(date: Date | string | number, locale?: string): any;
6
7
  export declare function formatToDatetime(date: Date | string | number, locale?: string): any;
package/lib/util.js CHANGED
@@ -35,6 +35,7 @@ exports.getSubscriptionAction = void 0;
35
35
  exports.getSubscriptionStatusColor = getSubscriptionStatusColor;
36
36
  exports.getTxLink = exports.getSubscriptionTimeSummary = void 0;
37
37
  exports.getWebhookStatusColor = getWebhookStatusColor;
38
+ exports.isPaymentKitMounted = void 0;
38
39
  exports.isValidCountry = isValidCountry;
39
40
  exports.mergeExtraParams = void 0;
40
41
  exports.sleep = sleep;
@@ -48,6 +49,10 @@ var _dayjs = _interopRequireDefault(require("./dayjs"));
48
49
  var _locales = require("./locales");
49
50
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
51
  const PAYMENT_KIT_DID = exports.PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
52
+ const isPaymentKitMounted = () => {
53
+ return (window.blocklet?.componentMountPoints || []).some(x => x.did === PAYMENT_KIT_DID);
54
+ };
55
+ exports.isPaymentKitMounted = isPaymentKitMounted;
51
56
  const getPrefix = () => {
52
57
  const componentId = (window?.blocklet?.componentId || "").split("/").pop();
53
58
  if (componentId === PAYMENT_KIT_DID) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.13.211",
3
+ "version": "1.13.212",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -90,7 +90,7 @@
90
90
  "@babel/core": "^7.23.9",
91
91
  "@babel/preset-env": "^7.23.9",
92
92
  "@babel/preset-react": "^7.23.3",
93
- "@blocklet/payment-types": "1.13.211",
93
+ "@blocklet/payment-types": "1.13.212",
94
94
  "@storybook/addon-essentials": "^7.6.13",
95
95
  "@storybook/addon-interactions": "^7.6.13",
96
96
  "@storybook/addon-links": "^7.6.13",
@@ -119,5 +119,5 @@
119
119
  "vite-plugin-babel": "^1.2.0",
120
120
  "vite-plugin-node-polyfills": "^0.21.0"
121
121
  },
122
- "gitHead": "2fe03028e2284261a1a62260d82a2e79ec45ce4a"
122
+ "gitHead": "942de3b017723af85a6c271a7e4ddd35443bc84d"
123
123
  }
@@ -0,0 +1,5 @@
1
+ import { isPaymentKitMounted } from '../util';
2
+
3
+ export default function SafeGuard({ children }: { children: any }) {
4
+ return isPaymentKitMounted() ? children : null;
5
+ }
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import ConfirmDialog from './components/confirm';
7
7
  import FormInput from './components/input';
8
8
  import Livemode from './components/livemode';
9
9
  import PricingTable from './components/pricing-table';
10
+ import SafeGuard from './components/safe-guard';
10
11
  import Status from './components/status';
11
12
  import Switch from './components/switch-button';
12
13
  import dayjs from './dayjs';
@@ -51,4 +52,5 @@ export {
51
52
  CustomerPaymentList,
52
53
  MiniInvoiceList,
53
54
  TxLink,
55
+ SafeGuard,
54
56
  };
package/src/util.ts CHANGED
@@ -23,6 +23,10 @@ import { t } from './locales';
23
23
 
24
24
  export const PAYMENT_KIT_DID = 'z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk';
25
25
 
26
+ export const isPaymentKitMounted = () => {
27
+ return (window.blocklet?.componentMountPoints || []).some((x: any) => x.did === PAYMENT_KIT_DID);
28
+ };
29
+
26
30
  export const getPrefix = () => {
27
31
  const componentId = (window?.blocklet?.componentId || '').split('/').pop();
28
32
  if (componentId === PAYMENT_KIT_DID) {