@ckb-ccc/connector-react 0.0.13-alpha.8 → 0.0.14-alpha.0

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,33 @@
1
1
  # @ckb-ccc/connector-react
2
2
 
3
+ ## 0.0.14-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @ckb-ccc/connector@0.0.14-alpha.0
9
+
10
+ ## 0.0.13
11
+
12
+ ### Patch Changes
13
+
14
+ - [`9e6b9fd`](https://github.com/ckb-ecofund/ccc/commit/9e6b9fd40274015a0964dec8e0ee58dcbc06c786) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector-react): if the filter is undefined, accept all
15
+
16
+ - [`6d62032`](https://github.com/ckb-ecofund/ccc/commit/6d620326f42f8c48eff9deb95578cf28d7bf5c97) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): recordCells should not add usableCells
17
+
18
+ - [`3658797`](https://github.com/ckb-ecofund/ccc/commit/3658797e67c42c56b20fa66481d0455ed019e69f) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): node.js websocket
19
+
20
+ - [#25](https://github.com/ckb-ecofund/ccc/pull/25) [`69c10fd`](https://github.com/ckb-ecofund/ccc/commit/69c10fdfcd507433c13b15d17015dca4687afb97) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(utxo-global): switchNetwork
21
+
22
+ - [`44c7fee`](https://github.com/ckb-ecofund/ccc/commit/44c7feed37369836268fba21884418682f15254b) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): completeInputs
23
+
24
+ - [`079e20e`](https://github.com/ckb-ecofund/ccc/commit/079e20ef14cf9a7c06bbaddf3e92cbfbb005da11) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): more APIs. Since parsing.
25
+
26
+ - [`ed154d1`](https://github.com/ckb-ecofund/ccc/commit/ed154d189e239907ad686ec51ac8133b6d5eb895) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Signer.findCells
27
+
28
+ - Updated dependencies [[`6d62032`](https://github.com/ckb-ecofund/ccc/commit/6d620326f42f8c48eff9deb95578cf28d7bf5c97), [`3658797`](https://github.com/ckb-ecofund/ccc/commit/3658797e67c42c56b20fa66481d0455ed019e69f), [`69c10fd`](https://github.com/ckb-ecofund/ccc/commit/69c10fdfcd507433c13b15d17015dca4687afb97), [`44c7fee`](https://github.com/ckb-ecofund/ccc/commit/44c7feed37369836268fba21884418682f15254b), [`079e20e`](https://github.com/ckb-ecofund/ccc/commit/079e20ef14cf9a7c06bbaddf3e92cbfbb005da11), [`ed154d1`](https://github.com/ckb-ecofund/ccc/commit/ed154d189e239907ad686ec51ac8133b6d5eb895)]:
29
+ - @ckb-ccc/connector@0.0.13
30
+
3
31
  ## 0.0.13-alpha.8
4
32
 
5
33
  ### Patch Changes
package/README.md CHANGED
@@ -43,6 +43,18 @@
43
43
 
44
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.
45
45
 
46
+ ## Use the Connector UI
47
+
48
+ Before using the Connector, wrap your UI with the CCC Provider:
49
+
50
+ ```tsx
51
+ <ccc.Provider>
52
+ {/* Your application */}
53
+ </ccc.Provider>
54
+ ```
55
+
56
+ Check [the document for @ckb-ccc/connector-react](https://docs.ckbccc.com/modules/_ckb_ccc_connector_react.index.ccc.html) for more information.
57
+
46
58
  <h3 align="center">
47
59
  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>.
48
60
  </h3>
@@ -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-alpha.8",
3
+ "version": "0.0.14-alpha.0",
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-alpha.8"
38
+ "@ckb-ccc/connector": "0.0.14-alpha.0"
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.",