@openreceive/svelte 0.1.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.
- package/LICENSE +21 -0
- package/dist/Checkout.svelte +62 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +58 -0
- package/dist/styles.css +1 -0
- package/package.json +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenReceive contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
createOpenReceiveSvelteCheckoutShellBinding,
|
|
4
|
+
defineOpenReceiveElements,
|
|
5
|
+
type CheckoutElementListeners,
|
|
6
|
+
type CheckoutShellOptions,
|
|
7
|
+
type CheckoutSnapshot
|
|
8
|
+
} from "./index.js";
|
|
9
|
+
|
|
10
|
+
export let snapshot: CheckoutSnapshot;
|
|
11
|
+
export let options: CheckoutShellOptions = {};
|
|
12
|
+
|
|
13
|
+
$: shell = createOpenReceiveSvelteCheckoutShellBinding(snapshot, options);
|
|
14
|
+
|
|
15
|
+
if (typeof window !== "undefined") {
|
|
16
|
+
defineOpenReceiveElements();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function checkoutListeners(node: HTMLElement, listeners: CheckoutElementListeners) {
|
|
20
|
+
let activeListeners = listeners;
|
|
21
|
+
|
|
22
|
+
const attach = () => {
|
|
23
|
+
for (const [name, listener] of Object.entries(activeListeners)) {
|
|
24
|
+
if (listener !== undefined) {
|
|
25
|
+
node.addEventListener(name, listener);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const detach = () => {
|
|
30
|
+
for (const [name, listener] of Object.entries(activeListeners)) {
|
|
31
|
+
if (listener !== undefined) {
|
|
32
|
+
node.removeEventListener(name, listener);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
attach();
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
update(nextListeners: CheckoutElementListeners) {
|
|
41
|
+
detach();
|
|
42
|
+
activeListeners = nextListeners;
|
|
43
|
+
attach();
|
|
44
|
+
},
|
|
45
|
+
destroy() {
|
|
46
|
+
detach();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<section {...shell.rootProps}>
|
|
53
|
+
<svelte:element
|
|
54
|
+
this={shell.themeToggle.tagName}
|
|
55
|
+
{...shell.themeToggle.props}
|
|
56
|
+
/>
|
|
57
|
+
<svelte:element
|
|
58
|
+
this={shell.checkout.tagName}
|
|
59
|
+
{...shell.checkout.props}
|
|
60
|
+
use:checkoutListeners={shell.checkout.events}
|
|
61
|
+
/>
|
|
62
|
+
</section>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME, OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME, type CreateCheckoutShellOptions, type CheckoutElementAttributeOptions, type CheckoutElementAttributes, type CheckoutElementEventHandlers, type CheckoutElementListeners, type CheckoutController, type CheckoutControllerOptions, type CheckoutShellElements, type CheckoutShellOptions, type CheckoutSnapshot, type OpenReceiveStoredThemeModelOptions, type OpenReceiveThemeModel, type OpenReceiveThemeModelOptions, type OpenReceiveThemePreference, type OpenReceiveThemeToggleElementAttributeOptions, type OpenReceiveThemeToggleElementAttributes } from "@openreceive/browser/internal";
|
|
2
|
+
import { defineOpenReceiveElements, type DefineOpenReceiveElementsOptions } from "@openreceive/elements";
|
|
3
|
+
export { OPENRECEIVE_CHECKOUT_ELEMENT_EVENTS, OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME, OPENRECEIVE_THEME_STORAGE_KEY, OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME, applyCheckoutThemeAttributes, applyOpenReceiveThemeAttributes, createCheckoutController, createCheckoutElement, createCheckoutElementAttributes, createCheckoutElementListeners, createCheckoutShell, createCheckoutShellModel, createOpenReceiveStoredThemeModel, createOpenReceiveThemeModel, createOpenReceiveThemeToggleElement, createOpenReceiveThemeToggleElementAttributes, readOpenReceiveThemePreference, syncOpenReceiveStoredThemeControls, toggleOpenReceiveStoredThemeControls, toggleOpenReceiveStoredThemePreference, writeOpenReceiveThemePreference } from "@openreceive/browser/internal";
|
|
4
|
+
export type { CreateCheckoutElementOptions, CreateCheckoutShellOptions, CreateOpenReceiveThemeToggleElementOptions, CheckoutElementAttributeOptions, CheckoutElementAttributes, CheckoutElementDocument, CheckoutElementEventHandlers, CheckoutElementListeners, CheckoutController, CheckoutControllerOptions, CheckoutShellElements, CheckoutShellCheckoutBinding, CheckoutShellModel, CheckoutShellOptions, CheckoutShellThemeToggleBinding, CheckoutElementTarget, CheckoutSnapshot, OpenReceiveReadThemePreferenceOptions, OpenReceiveStoredThemeModelOptions, OpenReceiveThemeAttributeTarget, OpenReceiveThemeControlTargets, OpenReceiveThemeLabelTarget, OpenReceiveThemeModel, OpenReceiveThemeModelOptions, OpenReceiveThemePreference, OpenReceiveThemeStorageOptions, OpenReceiveThemeToggleElementAttributeOptions, OpenReceiveThemeToggleElementAttributes } from "@openreceive/browser/internal";
|
|
5
|
+
export { defineOpenReceiveElements } from "@openreceive/elements";
|
|
6
|
+
export type { DefineOpenReceiveElementsOptions } from "@openreceive/elements";
|
|
7
|
+
export interface OpenReceiveSvelteCheckoutPropsOptions extends CheckoutElementAttributeOptions {
|
|
8
|
+
}
|
|
9
|
+
export interface OpenReceiveSvelteCheckoutBindingOptions extends OpenReceiveSvelteCheckoutPropsOptions, CheckoutElementEventHandlers {
|
|
10
|
+
}
|
|
11
|
+
export interface OpenReceiveSvelteCheckoutBinding {
|
|
12
|
+
readonly tagName: typeof OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME;
|
|
13
|
+
readonly props: CheckoutElementAttributes;
|
|
14
|
+
readonly events: CheckoutElementListeners;
|
|
15
|
+
}
|
|
16
|
+
export interface OpenReceiveSvelteThemeToggleBinding {
|
|
17
|
+
readonly tagName: typeof OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME;
|
|
18
|
+
readonly props: OpenReceiveThemeToggleElementAttributes;
|
|
19
|
+
}
|
|
20
|
+
export interface OpenReceiveSvelteCheckoutShellBinding {
|
|
21
|
+
readonly theme: OpenReceiveThemeModel;
|
|
22
|
+
readonly rootProps: OpenReceiveThemeModel["attributes"];
|
|
23
|
+
readonly checkout: OpenReceiveSvelteCheckoutBinding;
|
|
24
|
+
readonly themeToggle: OpenReceiveSvelteThemeToggleBinding;
|
|
25
|
+
}
|
|
26
|
+
export interface OpenReceiveSvelteCheckoutComponentOptions extends CheckoutShellOptions {
|
|
27
|
+
readonly defineElementsOptions?: DefineOpenReceiveElementsOptions;
|
|
28
|
+
}
|
|
29
|
+
export interface OpenReceiveSvelteCheckoutComponentModel extends OpenReceiveSvelteCheckoutShellBinding {
|
|
30
|
+
readonly componentName: "Checkout";
|
|
31
|
+
readonly defineElements: typeof defineOpenReceiveElements;
|
|
32
|
+
readonly defineElementsOptions?: DefineOpenReceiveElementsOptions;
|
|
33
|
+
}
|
|
34
|
+
export declare function createOpenReceiveSvelteCheckoutProps(snapshot: CheckoutSnapshot, options?: OpenReceiveSvelteCheckoutPropsOptions): CheckoutElementAttributes;
|
|
35
|
+
export declare function createOpenReceiveSvelteCheckoutBinding(snapshot: CheckoutSnapshot, options?: OpenReceiveSvelteCheckoutBindingOptions): OpenReceiveSvelteCheckoutBinding;
|
|
36
|
+
export declare function createOpenReceiveSvelteThemeBinding(theme: OpenReceiveThemePreference, options?: OpenReceiveThemeModelOptions): OpenReceiveThemeModel;
|
|
37
|
+
export declare function createOpenReceiveSvelteStoredThemeBinding(options?: OpenReceiveStoredThemeModelOptions): OpenReceiveThemeModel;
|
|
38
|
+
export declare function createOpenReceiveSvelteThemeToggleBinding(options?: OpenReceiveThemeToggleElementAttributeOptions): OpenReceiveSvelteThemeToggleBinding;
|
|
39
|
+
export declare function createOpenReceiveSvelteCheckoutShellBinding(snapshot: CheckoutSnapshot, options?: CheckoutShellOptions): OpenReceiveSvelteCheckoutShellBinding;
|
|
40
|
+
export declare function createOpenReceiveSvelteCheckoutComponentModel(snapshot: CheckoutSnapshot, options?: OpenReceiveSvelteCheckoutComponentOptions): OpenReceiveSvelteCheckoutComponentModel;
|
|
41
|
+
export declare function createOpenReceiveSvelteCheckoutController(options: CheckoutControllerOptions): CheckoutController;
|
|
42
|
+
export declare function createOpenReceiveSvelteCheckoutShell(snapshot: CheckoutSnapshot, options?: CreateCheckoutShellOptions): CheckoutShellElements;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME, OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME, createCheckoutController, createCheckoutShell, createCheckoutShellModel, createCheckoutElementAttributes, createCheckoutElementListeners, createOpenReceiveStoredThemeModel, createOpenReceiveThemeModel, createOpenReceiveThemeToggleElementAttributes } from "@openreceive/browser/internal";
|
|
2
|
+
import { defineOpenReceiveElements } from "@openreceive/elements";
|
|
3
|
+
export { OPENRECEIVE_CHECKOUT_ELEMENT_EVENTS, OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME, OPENRECEIVE_THEME_STORAGE_KEY, OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME, applyCheckoutThemeAttributes, applyOpenReceiveThemeAttributes, createCheckoutController, createCheckoutElement, createCheckoutElementAttributes, createCheckoutElementListeners, createCheckoutShell, createCheckoutShellModel, createOpenReceiveStoredThemeModel, createOpenReceiveThemeModel, createOpenReceiveThemeToggleElement, createOpenReceiveThemeToggleElementAttributes, readOpenReceiveThemePreference, syncOpenReceiveStoredThemeControls, toggleOpenReceiveStoredThemeControls, toggleOpenReceiveStoredThemePreference, writeOpenReceiveThemePreference } from "@openreceive/browser/internal";
|
|
4
|
+
export { defineOpenReceiveElements } from "@openreceive/elements";
|
|
5
|
+
export function createOpenReceiveSvelteCheckoutProps(snapshot, options = {}) {
|
|
6
|
+
return createCheckoutElementAttributes(snapshot, options);
|
|
7
|
+
}
|
|
8
|
+
export function createOpenReceiveSvelteCheckoutBinding(snapshot, options = {}) {
|
|
9
|
+
return {
|
|
10
|
+
tagName: OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME,
|
|
11
|
+
props: createOpenReceiveSvelteCheckoutProps(snapshot, options),
|
|
12
|
+
events: createCheckoutElementListeners(options)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function createOpenReceiveSvelteThemeBinding(theme, options = {}) {
|
|
16
|
+
return createOpenReceiveThemeModel(theme, options);
|
|
17
|
+
}
|
|
18
|
+
export function createOpenReceiveSvelteStoredThemeBinding(options = {}) {
|
|
19
|
+
return createOpenReceiveStoredThemeModel(options);
|
|
20
|
+
}
|
|
21
|
+
export function createOpenReceiveSvelteThemeToggleBinding(options = {}) {
|
|
22
|
+
return {
|
|
23
|
+
tagName: OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME,
|
|
24
|
+
props: createOpenReceiveThemeToggleElementAttributes(options)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function createOpenReceiveSvelteCheckoutShellBinding(snapshot, options = {}) {
|
|
28
|
+
const shell = createCheckoutShellModel(snapshot, options);
|
|
29
|
+
return {
|
|
30
|
+
theme: shell.theme,
|
|
31
|
+
rootProps: shell.rootAttributes,
|
|
32
|
+
checkout: {
|
|
33
|
+
tagName: shell.checkout.tagName,
|
|
34
|
+
props: shell.checkout.attributes,
|
|
35
|
+
events: shell.checkout.listeners
|
|
36
|
+
},
|
|
37
|
+
themeToggle: {
|
|
38
|
+
tagName: shell.themeToggle.tagName,
|
|
39
|
+
props: shell.themeToggle.attributes
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function createOpenReceiveSvelteCheckoutComponentModel(snapshot, options = {}) {
|
|
44
|
+
const { defineElementsOptions, ...shellOptions } = options;
|
|
45
|
+
const shell = createOpenReceiveSvelteCheckoutShellBinding(snapshot, shellOptions);
|
|
46
|
+
return {
|
|
47
|
+
componentName: "Checkout",
|
|
48
|
+
defineElements: defineOpenReceiveElements,
|
|
49
|
+
defineElementsOptions,
|
|
50
|
+
...shell
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function createOpenReceiveSvelteCheckoutController(options) {
|
|
54
|
+
return createCheckoutController(options);
|
|
55
|
+
}
|
|
56
|
+
export function createOpenReceiveSvelteCheckoutShell(snapshot, options = {}) {
|
|
57
|
+
return createCheckoutShell(snapshot, options);
|
|
58
|
+
}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "@openreceive/browser/styles.css";
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openreceive/svelte",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@openreceive/browser": "0.1.1",
|
|
7
|
+
"@openreceive/elements": "0.1.1"
|
|
8
|
+
},
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"svelte": ">=4.0.0 || >=5.0.0"
|
|
11
|
+
},
|
|
12
|
+
"peerDependenciesMeta": {
|
|
13
|
+
"svelte": {
|
|
14
|
+
"optional": true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.js",
|
|
19
|
+
"./checkout.svelte": "./dist/Checkout.svelte",
|
|
20
|
+
"./styles.css": "./dist/styles.css"
|
|
21
|
+
},
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
]
|
|
28
|
+
}
|