@ckb-ccc/connector-react 0.0.13 → 0.0.14-alpha.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @ckb-ccc/connector-react
2
2
 
3
+ ## 0.0.14-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#48](https://github.com/ckb-ecofund/ccc/pull/48) [`4fb114b`](https://github.com/ckb-ecofund/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(okx): make okx wallet happy
8
+
9
+ - Updated dependencies [[`4fb114b`](https://github.com/ckb-ecofund/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6)]:
10
+ - @ckb-ccc/connector@0.0.14-alpha.1
11
+
12
+ ## 0.0.14-alpha.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies []:
17
+ - @ckb-ccc/connector@0.0.14-alpha.0
18
+
3
19
  ## 0.0.13
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -15,6 +15,9 @@
15
15
  <img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-ecofund/ccc" />
16
16
  <img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-ecofund/ccc/master" />
17
17
  <img alt="GitHub branch check runs" src="https://img.shields.io/github/check-runs/ckb-ecofund/ccc/master" />
18
+ <a href="https://live.ckbccc.com/"><img
19
+ alt="Playground" src="https://img.shields.io/website?url=https%3A%2F%2Flive.ckbccc.com%2F&label=Playground"
20
+ /></a>
18
21
  <a href="https://app.ckbccc.com/"><img
19
22
  alt="App" src="https://img.shields.io/website?url=https%3A%2F%2Fapp.ckbccc.com%2F&label=App"
20
23
  /></a>
@@ -33,15 +36,37 @@
33
36
  Fully enabling CKB's Turing completeness and cryptographic freedom power.
34
37
  </p>
35
38
 
36
- ## Preview
39
+ ## Playground
40
+
41
+ <p align="center">
42
+ <a href="https://live.ckbccc.com/">
43
+ <img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="90%" />
44
+ </a>
45
+ </p>
46
+
47
+ This project is still under active development, and we are looking forward to your feedback. You can [experiment instantly in the playground](https://live.ckbccc.com/). If you are new to the CKB, we recommend checking [Nervos CKB Docs](https://docs.nervos.org/) for basic knowledge.
48
+
49
+ ## App
37
50
 
38
51
  <p align="center">
39
52
  <a href="https://app.ckbccc.com/">
40
- <img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="30%" />
53
+ <img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/appPreview.png" width="50%" />
41
54
  </a>
42
55
  </p>
43
56
 
44
- This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://app.ckbccc.com/). It showcases how to use CCC for some basic scenarios in CKB.
57
+ For non-developers, you can also [try CCC's app now here](https://app.ckbccc.com/). It showcases how to use CCC for some basic scenarios in CKB.
58
+
59
+ ## Use the Connector UI
60
+
61
+ Before using the Connector, wrap your UI with the CCC Provider:
62
+
63
+ ```tsx
64
+ <ccc.Provider>
65
+ {/* Your application */}
66
+ </ccc.Provider>
67
+ ```
68
+
69
+ Check [the document for @ckb-ccc/connector-react](https://docs.ckbccc.com/modules/_ckb_ccc_connector_react.index.ccc.html) for more information.
45
70
 
46
71
  <h3 align="center">
47
72
  Read more about CCC on <a href="https://docs.ckbccc.com">our website</a> or <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
@@ -1,8 +1,8 @@
1
1
  import { ccc } from "@ckb-ccc/connector";
2
- import React from "react";
2
+ import React, { HTMLAttributes, ReactNode } from "react";
3
3
  export declare function Provider({ children, connectorProps, name, icon, signerFilter, signersController, defaultClient, preferredNetworks, }: {
4
- children: React.ReactNode;
5
- connectorProps?: React.HTMLAttributes<{}>;
4
+ children: ReactNode;
5
+ connectorProps?: HTMLAttributes<{}>;
6
6
  name?: string;
7
7
  icon?: string;
8
8
  signerFilter?: (signerInfo: ccc.SignerInfo, wallet: ccc.Wallet) => Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"useCcc.d.ts","sourceRoot":"","sources":["../../src/hooks/useCcc.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAON,MAAM,OAAO,CAAC;AA0Cf,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,GAAG,CAAC,UAAU,EAC1B,MAAM,EAAE,GAAG,CAAC,MAAM,KACf,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAC1C,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC;CAC7C,qBAoFA;AAED,wBAAgB,MAAM;;;;;;;EAQrB"}
1
+ {"version":3,"file":"useCcc.d.ts","sourceRoot":"","sources":["../../src/hooks/useCcc.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAAK,EAAE,EAEZ,cAAc,EACd,SAAS,EAQV,MAAM,OAAO,CAAC;AA0Cf,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,GAAG,CAAC,UAAU,EAC1B,MAAM,EAAE,GAAG,CAAC,MAAM,KACf,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAC1C,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC;CAC7C,qBAoFA;AAED,wBAAgB,MAAM;;;;;;;EAQrB"}
@@ -1,5 +1,5 @@
1
1
  import { ccc } from "@ckb-ccc/connector";
2
- import React, { createContext, useCallback, useEffect, useMemo, useRef, useState, } from "react";
2
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
3
3
  import { Connector } from "../components/index.js";
4
4
  const CCC_CONTEXT = createContext(undefined);
5
5
  class SignersControllerWithFilter extends ccc.SignersController {
@@ -50,8 +50,7 @@ export function Provider({ children, connectorProps, name, icon, signerFilter, s
50
50
  } },
51
51
  React.createElement(Connector, { name: name, icon: icon, signersController: signersController ?? defautlSignersController.current, ref: setRef, onWillUpdate: () => setFlag((f) => f + 1), onClose: () => setIsOpen(false), preferredNetworks: preferredNetworks, ...connectorProps,
52
52
  style: {
53
- ...connectorProps?.style,
54
- zIndex: connectorProps?.style?.zIndex ?? 999,
53
+ zIndex: 999,
55
54
  ...(isOpen ? {} : { display: "none" }),
56
55
  ...{
57
56
  "--background": "#fff",
@@ -63,11 +62,12 @@ export function Provider({ children, connectorProps, name, icon, signerFilter, s
63
62
  color: "#1e1e1e",
64
63
  "--tip-color": "#666",
65
64
  },
65
+ ...connectorProps?.style,
66
66
  } }),
67
67
  children));
68
68
  }
69
69
  export function useCcc() {
70
- const context = React.useContext(CCC_CONTEXT);
70
+ const context = useContext(CCC_CONTEXT);
71
71
  if (!context) {
72
72
  throw Error("The component which invokes the useCcc hook should be placed in a ccc.Provider.");
73
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/connector-react",
3
- "version": "0.0.13",
3
+ "version": "0.0.14-alpha.1",
4
4
  "description": "CCC - CKBer's Codebase. Common Chains Connector UI Component for React",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -35,8 +35,10 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@lit/react": "^1.0.5",
38
- "react": "^18",
39
- "@ckb-ccc/connector": "0.0.13"
38
+ "@ckb-ccc/connector": "0.0.14-alpha.1"
39
+ },
40
+ "peerDependencies": {
41
+ "react": ">=16"
40
42
  },
41
43
  "scripts": {
42
44
  "build": "rimraf ./dist && tsc",
@@ -1,7 +1,11 @@
1
1
  import { ccc } from "@ckb-ccc/connector";
2
2
  import React, {
3
+ CSSProperties,
4
+ HTMLAttributes,
5
+ ReactNode,
3
6
  createContext,
4
7
  useCallback,
8
+ useContext,
5
9
  useEffect,
6
10
  useMemo,
7
11
  useRef,
@@ -58,8 +62,8 @@ export function Provider({
58
62
  defaultClient,
59
63
  preferredNetworks,
60
64
  }: {
61
- children: React.ReactNode;
62
- connectorProps?: React.HTMLAttributes<{}>;
65
+ children: ReactNode;
66
+ connectorProps?: HTMLAttributes<{}>;
63
67
  name?: string;
64
68
  icon?: string;
65
69
  signerFilter?: (
@@ -134,8 +138,7 @@ export function Provider({
134
138
  {...{
135
139
  ...connectorProps,
136
140
  style: {
137
- ...connectorProps?.style,
138
- zIndex: connectorProps?.style?.zIndex ?? 999,
141
+ zIndex: 999,
139
142
  ...(isOpen ? {} : { display: "none" }),
140
143
  ...({
141
144
  "--background": "#fff",
@@ -146,7 +149,8 @@ export function Provider({
146
149
  "--btn-secondary-hover": "#ccc",
147
150
  color: "#1e1e1e",
148
151
  "--tip-color": "#666",
149
- } as React.CSSProperties),
152
+ } as CSSProperties),
153
+ ...connectorProps?.style,
150
154
  },
151
155
  }}
152
156
  />
@@ -156,7 +160,7 @@ export function Provider({
156
160
  }
157
161
 
158
162
  export function useCcc() {
159
- const context = React.useContext(CCC_CONTEXT);
163
+ const context = useContext(CCC_CONTEXT);
160
164
  if (!context) {
161
165
  throw Error(
162
166
  "The component which invokes the useCcc hook should be placed in a ccc.Provider.",