@ic-pay/icpay-widget 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.d.ts +12 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import '../amount-input-B399OwiA.js';
|
|
2
2
|
import 'lit';
|
|
3
3
|
|
|
4
|
+
type IcpaySuccess = {
|
|
5
|
+
amount?: number;
|
|
6
|
+
tx: unknown;
|
|
7
|
+
};
|
|
8
|
+
type IcpayCoffeeSuccess = {
|
|
9
|
+
item: {
|
|
10
|
+
name: string;
|
|
11
|
+
priceUsd: number;
|
|
12
|
+
};
|
|
13
|
+
tx: unknown;
|
|
14
|
+
};
|
|
4
15
|
declare const IcpayPayButton: any;
|
|
5
16
|
declare const IcpayAmountInput: any;
|
|
6
17
|
declare const IcpayPremiumContent: any;
|
|
@@ -10,4 +21,4 @@ declare const IcpayCoffeeShop: any;
|
|
|
10
21
|
declare const IcpayDonationThermometer: any;
|
|
11
22
|
declare const IcpayProgressBar: any;
|
|
12
23
|
|
|
13
|
-
export { IcpayAmountInput, IcpayArticlePaywall, IcpayCoffeeShop, IcpayDonationThermometer, IcpayPayButton, IcpayPremiumContent, IcpayProgressBar, IcpayTipJar };
|
|
24
|
+
export { IcpayAmountInput, IcpayArticlePaywall, IcpayCoffeeShop, type IcpayCoffeeSuccess, IcpayDonationThermometer, IcpayPayButton, IcpayPremiumContent, IcpayProgressBar, type IcpaySuccess, IcpayTipJar };
|
package/dist/react/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunk-PK6L5TPW.js";import
|
|
1
|
+
import"../chunk-PK6L5TPW.js";import I,{forwardRef as M,useEffect as d,useRef as b}from"react";function n(m,i){let f=M((o,t)=>{let s=b(null);d(()=>{let e=s.current;if(!e)return;let{children:p,className:r,style:y,id:c,role:l,tabIndex:u,title:a,ref:h,...C}=o;for(let[S,T]of Object.entries(C))try{e[S]=T}catch{}},[o]),d(()=>{let e=s.current;if(!e||!i?.eventMap)return;let p=[];for(let[r,y]of Object.entries(i.eventMap)){let c=o[r];if(typeof c=="function"){let l=u=>{let a=u;a&&"detail"in a?c(a.detail):c(u)};e.addEventListener(y,l),p.push(()=>e.removeEventListener(y,l))}}return()=>{p.forEach(r=>r())}},[o,i?.eventMap]);let g=e=>{s.current=e,typeof t=="function"?t(e):t&&typeof t=="object"&&(t.current=e)},{children:E,...v}=o;return I.createElement(m,{ref:g,...v},E)});return f.displayName=`ICPay(${m})`,f}var R=n("icpay-pay-button",{eventMap:{onSuccess:"icpay-pay",onError:"icpay-error"}}),A=n("icpay-amount-input",{eventMap:{onSuccess:"icpay-amount-pay",onError:"icpay-error"}}),H=n("icpay-premium-content",{eventMap:{onSuccess:"icpay-unlock",onError:"icpay-error"}}),w=n("icpay-tip-jar",{eventMap:{onSuccess:"icpay-tip",onError:"icpay-error"}}),k=n("icpay-article-paywall",{eventMap:{onSuccess:"icpay-unlock",onError:"icpay-error"}}),j=n("icpay-coffee-shop",{eventMap:{onSuccess:"icpay-coffee",onError:"icpay-error"}}),B=n("icpay-donation-thermometer",{eventMap:{onSuccess:"icpay-donation",onError:"icpay-error"}}),N=n("icpay-progress-bar");export{A as IcpayAmountInput,k as IcpayArticlePaywall,j as IcpayCoffeeShop,B as IcpayDonationThermometer,R as IcpayPayButton,H as IcpayPremiumContent,N as IcpayProgressBar,w as IcpayTipJar};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/createWrapper.tsx","../../src/react/widgets.tsx"],"sourcesContent":["import React, { forwardRef, useEffect, useRef } from 'react';\n\ntype AnyProps = Record<string, unknown> & { children?: React.ReactNode };\n\n// Generic React wrapper for ICPay custom elements.\n// - Assigns all non-React props as properties on the underlying element\n// - Leaves events to be handled via config callbacks (recommended)\nexport function createWebComponent<TElement extends HTMLElement, TProps extends AnyProps>(\n tagName: string\n) {\n const Component = forwardRef<TElement, TProps>((props, ref) => {\n const innerRef = useRef<TElement | null>(null);\n\n useEffect(() => {\n const el = innerRef.current as any;\n if (!el) return;\n\n // Assign props as element properties (exclude standard React DOM props)\n const {\n children,\n className,\n style,\n id,\n role,\n tabIndex,\n title,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ref: _ignoredRef,\n ...rest\n } = props as any;\n\n for (const [key, value] of Object.entries(rest)) {\n try {\n (el as any)[key] = value;\n } catch {\n // no-op if property assignment fails\n }\n }\n }, [props]);\n\n // Merge forwarded ref\n const setRef = (node: TElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref && typeof ref === 'object') {\n (ref as React.MutableRefObject<TElement | null>).current = node;\n }\n };\n\n const { children, ...rest } = props as any;\n return React.createElement(tagName, { ref: setRef, ...rest }, children);\n });\n\n Component.displayName = `ICPay(${tagName})`;\n return Component;\n}\n\n\n","import { createWebComponent } from './createWrapper';\nimport type {\n PayButtonConfig,\n AmountInputConfig,\n PremiumContentConfig,\n TipJarConfig,\n ArticlePaywallConfig,\n CoffeeShopConfig,\n DonationThermometerConfig,\n ThemeConfig\n} from '../types';\n\n// Public React components\nexport const IcpayPayButton = createWebComponent<HTMLElement, { config?: PayButtonConfig }>('icpay-pay-button');\nexport const IcpayAmountInput = createWebComponent<HTMLElement, { config?: AmountInputConfig }>('icpay-amount-input');\nexport const IcpayPremiumContent = createWebComponent<HTMLElement, { config?: PremiumContentConfig }>('icpay-premium-content');\nexport const IcpayTipJar = createWebComponent<HTMLElement, { config?: TipJarConfig }>('icpay-tip-jar');\nexport const IcpayArticlePaywall = createWebComponent<HTMLElement, { config?: ArticlePaywallConfig }>('icpay-article-paywall');\nexport const IcpayCoffeeShop = createWebComponent<HTMLElement, { config?: CoffeeShopConfig }>('icpay-coffee-shop');\nexport const IcpayDonationThermometer = createWebComponent<HTMLElement, { config?: DonationThermometerConfig }>('icpay-donation-thermometer');\nexport const IcpayProgressBar = createWebComponent<HTMLElement, {\n open?: boolean;\n steps?: Array<{ key: string; label: string; tooltip: string; status: string }>;\n amount?: number;\n currency?: string;\n ledgerSymbol?: string;\n debug?: boolean;\n theme?: ThemeConfig;\n}>('icpay-progress-bar');\n\n// Internal helpers (not exported): wallet selector is not a standalone element.\n\n\n"],"mappings":"6BAAA,OAAOA,GAAS,cAAAC,EAAY,aAAAC,EAAW,UAAAC,MAAc,QAO9C,SAASC,EACdC,EACA,CACA,IAAMC,
|
|
1
|
+
{"version":3,"sources":["../../src/react/createWrapper.tsx","../../src/react/widgets.tsx"],"sourcesContent":["import React, { forwardRef, useEffect, useRef } from 'react';\n\ntype AnyProps = Record<string, unknown> & { children?: React.ReactNode };\n\n// Generic React wrapper for ICPay custom elements.\n// - Assigns all non-React props as properties on the underlying element\n// - Leaves events to be handled via config callbacks (recommended)\nexport function createWebComponent<TElement extends HTMLElement, TProps extends AnyProps>(\n tagName: string,\n options?: { eventMap?: Record<string, string> }\n) {\n const Component = forwardRef<TElement, TProps>((props, ref) => {\n const innerRef = useRef<TElement | null>(null);\n\n useEffect(() => {\n const el = innerRef.current as any;\n if (!el) return;\n\n // Assign props as element properties (exclude standard React DOM props)\n const {\n children,\n className,\n style,\n id,\n role,\n tabIndex,\n title,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ref: _ignoredRef,\n ...rest\n } = props as any;\n\n for (const [key, value] of Object.entries(rest)) {\n try {\n (el as any)[key] = value;\n } catch {\n // no-op if property assignment fails\n }\n }\n }, [props]);\n\n // Wire custom-element events from props via eventMap\n useEffect(() => {\n const el = innerRef.current as unknown as HTMLElement | null;\n if (!el || !options?.eventMap) return;\n const cleanup: Array<() => void> = [];\n for (const [propName, eventName] of Object.entries(options.eventMap)) {\n const handler = (props as any)[propName];\n if (typeof handler === 'function') {\n const listener = (e: Event) => {\n const ce = e as CustomEvent;\n if (ce && 'detail' in ce) handler(ce.detail);\n else handler(e);\n };\n el.addEventListener(eventName, listener as EventListener);\n cleanup.push(() => el.removeEventListener(eventName, listener as EventListener));\n }\n }\n return () => { cleanup.forEach(fn => fn()); };\n }, [props, options?.eventMap]);\n\n // Merge forwarded ref\n const setRef = (node: TElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref && typeof ref === 'object') {\n (ref as React.MutableRefObject<TElement | null>).current = node;\n }\n };\n\n const { children, ...rest } = props as any;\n return React.createElement(tagName, { ref: setRef, ...rest }, children);\n });\n\n Component.displayName = `ICPay(${tagName})`;\n return Component;\n}\n\n\n","import { createWebComponent } from './createWrapper';\nimport type {\n PayButtonConfig,\n AmountInputConfig,\n PremiumContentConfig,\n TipJarConfig,\n ArticlePaywallConfig,\n CoffeeShopConfig,\n DonationThermometerConfig,\n ThemeConfig\n} from '../types';\n\n// Public success detail types\nexport type IcpaySuccess = { amount?: number; tx: unknown };\nexport type IcpayCoffeeSuccess = { item: { name: string; priceUsd: number }; tx: unknown };\n\n// Public React components\nexport const IcpayPayButton = createWebComponent<HTMLElement, { config?: PayButtonConfig; onSuccess?: (detail: IcpaySuccess) => void; onError?: (detail: any) => void }>('icpay-pay-button', { eventMap: { onSuccess: 'icpay-pay', onError: 'icpay-error' } });\nexport const IcpayAmountInput = createWebComponent<HTMLElement, { config?: AmountInputConfig; onSuccess?: (detail: IcpaySuccess) => void; onError?: (detail: any) => void }>('icpay-amount-input', { eventMap: { onSuccess: 'icpay-amount-pay', onError: 'icpay-error' } });\nexport const IcpayPremiumContent = createWebComponent<HTMLElement, { config?: PremiumContentConfig; onSuccess?: (detail: IcpaySuccess) => void; onError?: (detail: any) => void }>('icpay-premium-content', { eventMap: { onSuccess: 'icpay-unlock', onError: 'icpay-error' } });\nexport const IcpayTipJar = createWebComponent<HTMLElement, { config?: TipJarConfig; onSuccess?: (detail: IcpaySuccess) => void; onError?: (detail: any) => void }>('icpay-tip-jar', { eventMap: { onSuccess: 'icpay-tip', onError: 'icpay-error' } });\nexport const IcpayArticlePaywall = createWebComponent<HTMLElement, { config?: ArticlePaywallConfig; onSuccess?: (detail: IcpaySuccess) => void; onError?: (detail: any) => void }>('icpay-article-paywall', { eventMap: { onSuccess: 'icpay-unlock', onError: 'icpay-error' } });\nexport const IcpayCoffeeShop = createWebComponent<HTMLElement, { config?: CoffeeShopConfig; onSuccess?: (detail: IcpayCoffeeSuccess) => void; onError?: (detail: any) => void }>('icpay-coffee-shop', { eventMap: { onSuccess: 'icpay-coffee', onError: 'icpay-error' } });\nexport const IcpayDonationThermometer = createWebComponent<HTMLElement, { config?: DonationThermometerConfig; onSuccess?: (detail: IcpaySuccess) => void; onError?: (detail: any) => void }>('icpay-donation-thermometer', { eventMap: { onSuccess: 'icpay-donation', onError: 'icpay-error' } });\nexport const IcpayProgressBar = createWebComponent<HTMLElement, {\n open?: boolean;\n steps?: Array<{ key: string; label: string; tooltip: string; status: string }>;\n amount?: number;\n currency?: string;\n ledgerSymbol?: string;\n debug?: boolean;\n theme?: ThemeConfig;\n}>('icpay-progress-bar');\n\n// Internal helpers (not exported): wallet selector is not a standalone element.\n\n\n"],"mappings":"6BAAA,OAAOA,GAAS,cAAAC,EAAY,aAAAC,EAAW,UAAAC,MAAc,QAO9C,SAASC,EACdC,EACAC,EACA,CACA,IAAMC,EAAYN,EAA6B,CAACO,EAAOC,IAAQ,CAC7D,IAAMC,EAAWP,EAAwB,IAAI,EAE7CD,EAAU,IAAM,CACd,IAAMS,EAAKD,EAAS,QACpB,GAAI,CAACC,EAAI,OAGT,GAAM,CACJ,SAAAC,EACA,UAAAC,EACA,MAAAC,EACA,GAAAC,EACA,KAAAC,EACA,SAAAC,EACA,MAAAC,EAEA,IAAKC,EACL,GAAGC,CACL,EAAIZ,EAEJ,OAAW,CAACa,EAAKC,CAAK,IAAK,OAAO,QAAQF,CAAI,EAC5C,GAAI,CACDT,EAAWU,CAAG,EAA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AE,UAAW,eAAgB,QAAS,aAAc,CAAE,CAAC,EAClQG,EAAcH,EAAwI,gBAAiB,CAAE,SAAU,CAAE,UAAW,YAAa,QAAS,aAAc,CAAE,CAAC,EACvOI,EAAsBJ,EAAgJ,wBAAyB,CAAE,SAAU,CAAE,UAAW,eAAgB,QAAS,aAAc,CAAE,CAAC,EAClQK,EAAkBL,EAAkJ,oBAAqB,CAAE,SAAU,CAAE,UAAW,eAAgB,QAAS,aAAc,CAAE,CAAC,EAC5PM,EAA2BN,EAAqJ,6BAA8B,CAAE,SAAU,CAAE,UAAW,iBAAkB,QAAS,aAAc,CAAE,CAAC,EACnRO,EAAmBP,EAQ7B,oBAAoB","names":["React","forwardRef","useEffect","useRef","createWebComponent","tagName","options","Component","props","ref","innerRef","el","children","className","style","id","role","tabIndex","title","_ignoredRef","rest","key","value","cleanup","propName","eventName","handler","listener","e","ce","fn","setRef","node","IcpayPayButton","createWebComponent","IcpayAmountInput","IcpayPremiumContent","IcpayTipJar","IcpayArticlePaywall","IcpayCoffeeShop","IcpayDonationThermometer","IcpayProgressBar"]}
|
package/package.json
CHANGED