xendit-components-web 0.0.7 → 0.0.8

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/README.md CHANGED
@@ -37,13 +37,13 @@ Two types of sessions are available:
37
37
  First, initialize the SDK either with either:
38
38
 
39
39
  - `XenditComponentsTest` for frontend development or unit tests
40
- - `XenditComponents`, for production, which requires a `sessionClientKey`, which comes from the Session object, which you need to create on your server. Make an endpoint that creates a session for the user's current transaction, return the `components_sdk_key` to the client, and pass it into the constructor.
40
+ - `XenditComponents`, for production, which requires a `componentsSdkKey`. That key comes from the session object you create on your server. Make an endpoint that creates a session for the user's current transaction, return the `components_sdk_key` to the client, and pass it into the constructor.
41
41
 
42
42
  ```typescript
43
43
  // For frontend development, use XenditComponentsTest
44
44
  const components: XenditComponents = new XenditComponentsTest({});
45
45
  // For production or e2e testing, use XenditComponents, passing in the components_sdk_key from the Session object
46
- // const components: XenditComponents = new XenditComponents({ sessionClientKey });
46
+ const components: XenditComponents = new XenditComponents({ componentsSdkKey });
47
47
 
48
48
  // Create a channel picker component
49
49
  const channelPicker: HTMLElement = components.createChannelPickerComponent();
@@ -71,7 +71,7 @@ components.addEventListener("session-expired-or-canceled", () => {
71
71
 
72
72
  The constructor.
73
73
 
74
- For production and e2e testing, you need to pass the `sessionClientKey`, which you can get when you create a Session on your server.
74
+ For production and e2e testing, you need to pass the `componentsSdkKey`, which you can get when you create a Session on your server.
75
75
 
76
76
  For development and unit testing, use `XenditComponentsTest`, which uses mock data and doesn't connect to Xendit servers.
77
77
 
@@ -110,9 +110,7 @@ your own channel selection UI. Each channel has a `uiGroup` property which match
110
110
  ### `createChannelComponent`
111
111
 
112
112
  ```typescript
113
- const channel = components
114
- .getActiveChannels()
115
- .find((channel) => channel.channelCode === "CARDS");
113
+ const channel = components.getActiveChannels({ filter: "CARDS" })[0];
116
114
  if (channel) {
117
115
  const htmlElement = components.createChannelPickerComponent(channel);
118
116
  myContainer.replaceChildren(htmlElement);
@@ -220,9 +218,7 @@ The current channel:
220
218
  ### `setCurrentChannel`
221
219
 
222
220
  ```typescript
223
- const channel = components
224
- .getActiveChannels()
225
- .find((channel) => channel.channelCode === "CARDS");
221
+ const channel = components.getActiveChannels({ filter: "CARDS" })[0];
226
222
  if (channel) {
227
223
  components.setCurrentChannel(channel);
228
224
  }
@@ -283,10 +279,8 @@ The following variables are available:
283
279
  | --xendit-color-text-placeholder | Placeholder color |
284
280
  | --xendit-color-disabled | Background color of disabled elements |
285
281
  | --xendit-color-danger | Border color of elements with validation errors and text color of validation errors |
286
- | --xendit-color-border | TODO: remove this |
287
- | --xendit-color-border-subtle | TODO: rename this |
288
- | --xendit-color-border-default | TODO: rename this |
289
- | --xendit-color-background | Background color of elements |
282
+ | --xendit-color-border | Border color used on accordions, input fields, and logos |
283
+ | --xendit-color-background | Background color of input fields |
290
284
  | --xendit-focus-shadow | Box-shadow applied to elements with focus |
291
285
  | --xendit-animation-duration | Duration of animations (affects the channel picker accordion) |
292
286
  | --xendit-animation-ease | Ease function of animations |
@@ -297,13 +291,25 @@ The following variables are available:
297
291
 
298
292
  Some form fields (credit card inputs) are implemented inside iframes to protect the user's information.
299
293
 
300
- Regular CSS doesn't apply inside iframes. The SDK instead provides overrides in the constructor which
301
- it applies to the iframe fields.
294
+ You can't override the CSS inside the iframe fields. Instead, you can pass some limited styles to the constructor
295
+ which we'll pass along to the iframes.
302
296
 
303
297
  ```typescript
304
298
  const sdk = new XenditComponents({
305
- appearance: {
306
- // TODO
299
+ iframeFieldAppearance: {
300
+ inputStyles: {
301
+ // apply styles to inputs within iframe fields
302
+ color: "#000",
303
+ },
304
+ placeholderStyles: {
305
+ // apply styles to input placeholders in iframe fields
306
+ color: "#ccc",
307
+ },
308
+ fontFace: {
309
+ // insert a @font-face rule inside iframe fields
310
+ source: "url(https://example.com/my-font-file) format(woff2)",
311
+ descriptors: { display: "swap" },
312
+ },
307
313
  },
308
314
  });
309
315
  ```
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "xendit-components-web",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Xendit frontend payment components SDK",
5
5
  "type": "module",
6
6
  "author": "Xendit",
7
- "license": "UNLICENSED",
7
+ "license": "MIT",
8
+ "keywords": [
9
+ "xendit",
10
+ "payment",
11
+ "payments",
12
+ "payment processing",
13
+ "credit cards",
14
+ "checkout",
15
+ "components"
16
+ ],
8
17
  "files": [
9
18
  "./sdk/dist/index.umd.js",
10
19
  "./sdk/dist/index.umd.js.map",
@@ -23,19 +32,6 @@
23
32
  "default": "./sdk/dist/index.umd.js"
24
33
  }
25
34
  },
26
- "scripts": {
27
- "dev": "./build.ts dev",
28
- "build": "./build.ts prod",
29
- "test": "vitest run",
30
- "test:watch": "vitest",
31
- "test:run": "vitest run",
32
- "test:debug": "vitest run --printConsoleTrace=true --silent=false",
33
- "lint": "eslint . --ext .ts,.tsx",
34
- "lint:fix": "eslint . --fix --ext .ts,.tsx",
35
- "prettier": "prettier . --check",
36
- "prettier:fix": "prettier . --check --write",
37
- "prepare": "husky"
38
- },
39
35
  "dependencies": {
40
36
  "card-validator": "^10.0.3",
41
37
  "classnames": "^2.5.1",
@@ -76,5 +72,16 @@
76
72
  "typescript-eslint": "^8.48.0",
77
73
  "vitest": "^4.0.14"
78
74
  },
79
- "packageManager": "pnpm@10.15.1"
80
- }
75
+ "scripts": {
76
+ "dev": "./build.ts dev",
77
+ "build": "./build.ts prod",
78
+ "test": "vitest run",
79
+ "test:watch": "vitest",
80
+ "test:run": "vitest run",
81
+ "test:debug": "vitest run --printConsoleTrace=true --silent=false",
82
+ "lint": "eslint . --ext .ts,.tsx",
83
+ "lint:fix": "eslint . --fix --ext .ts,.tsx",
84
+ "prettier": "prettier . --check",
85
+ "prettier:fix": "prettier . --check --write"
86
+ }
87
+ }