diff --git a/examples/with-html/index.html b/examples/with-html/index.html index 29b790b8..fc9088bf 100644 --- a/examples/with-html/index.html +++ b/examples/with-html/index.html @@ -53,6 +53,7 @@
Verifying
Please continue in app
diff --git a/packages/standalone/src/index.tsx b/packages/standalone/src/index.tsx index bd1d7ad9..603c718a 100644 --- a/packages/standalone/src/index.tsx +++ b/packages/standalone/src/index.tsx @@ -54,6 +54,13 @@ const open = () => { }) } +const close = () => { + return new Promise((_, reject) => { + if (!isInitialized) return reject(__('IDKitWidget is not initialized')) + useIDKitStore.setState({ open: false }) + }) +} + /** * Reset internal state. Useful for unit-testing */ @@ -65,7 +72,16 @@ const reset = () => { useIDKitStore.destroy() } -const IDKit = { init, update, open, reset } +const IDKit = { + init, + update, + open, + close, + reset, + get isInitialized() { + return isInitialized + }, +} window.IDKit = IDKit declare global { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9df9cbc8..9838df39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -141,6 +141,9 @@ importers: autoprefixer: specifier: ^10.4.19 version: 10.4.19(postcss@8.4.39) + clsx: + specifier: ^2.1.1 + version: 2.1.1 eslint: specifier: 8.54.0 version: 8.54.0 @@ -1506,6 +1509,10 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} + clsx@2.1.1: + resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} + engines: {node: '>=6'} + color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -5007,6 +5014,8 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + clsx@2.1.1: {} + color-convert@1.9.3: dependencies: color-name: 1.1.3