@powerhousedao/builder-tools 0.2.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/dist/connect-studio/helpers.d.ts +5 -0
- package/dist/connect-studio/helpers.d.ts.map +1 -0
- package/dist/connect-studio/helpers.js +43 -0
- package/dist/connect-studio/hmr.d.ts +12 -0
- package/dist/connect-studio/hmr.d.ts.map +1 -0
- package/dist/connect-studio/hmr.js +8 -0
- package/dist/connect-studio/index.d.ts +9 -0
- package/dist/connect-studio/index.d.ts.map +1 -0
- package/dist/connect-studio/index.js +7 -0
- package/dist/connect-studio/server.d.ts +3 -0
- package/dist/connect-studio/server.d.ts.map +1 -0
- package/dist/connect-studio/server.js +175 -0
- package/dist/connect-studio/studio.d.ts +3 -0
- package/dist/connect-studio/studio.d.ts.map +1 -0
- package/dist/connect-studio/studio.js +65 -0
- package/dist/connect-studio/types.d.ts +25 -0
- package/dist/connect-studio/types.d.ts.map +1 -0
- package/dist/connect-studio/types.js +1 -0
- package/dist/connect-studio/vite-plugins/base.d.ts +19 -0
- package/dist/connect-studio/vite-plugins/base.d.ts.map +1 -0
- package/dist/connect-studio/vite-plugins/base.js +162 -0
- package/dist/connect-studio/vite-plugins/external-packages.d.ts +6 -0
- package/dist/connect-studio/vite-plugins/external-packages.d.ts.map +1 -0
- package/dist/connect-studio/vite-plugins/external-packages.js +74 -0
- package/dist/connect-studio/vite-plugins/hmr.d.ts +3 -0
- package/dist/connect-studio/vite-plugins/hmr.d.ts.map +1 -0
- package/dist/connect-studio/vite-plugins/hmr.js +57 -0
- package/dist/connect-studio/vite-plugins/importmap.d.ts +20 -0
- package/dist/connect-studio/vite-plugins/importmap.d.ts.map +1 -0
- package/dist/connect-studio/vite-plugins/importmap.js +174 -0
- package/dist/connect-studio/vite-plugins/studio.d.ts +4 -0
- package/dist/connect-studio/vite-plugins/studio.d.ts.map +1 -0
- package/dist/connect-studio/vite-plugins/studio.js +112 -0
- package/dist/document-model-editor/components/button.d.ts +4 -0
- package/dist/document-model-editor/components/button.d.ts.map +1 -0
- package/dist/document-model-editor/components/button.js +7 -0
- package/dist/document-model-editor/components/code-editors/graphql-editor.d.ts +10 -0
- package/dist/document-model-editor/components/code-editors/graphql-editor.d.ts.map +1 -0
- package/dist/document-model-editor/components/code-editors/graphql-editor.js +75 -0
- package/dist/document-model-editor/components/code-editors/json-editor.d.ts +8 -0
- package/dist/document-model-editor/components/code-editors/json-editor.d.ts.map +1 -0
- package/dist/document-model-editor/components/code-editors/json-editor.js +43 -0
- package/dist/document-model-editor/components/code-editors/utils.d.ts +32 -0
- package/dist/document-model-editor/components/code-editors/utils.d.ts.map +1 -0
- package/dist/document-model-editor/components/code-editors/utils.js +191 -0
- package/dist/document-model-editor/components/divider.d.ts +8 -0
- package/dist/document-model-editor/components/divider.d.ts.map +1 -0
- package/dist/document-model-editor/components/divider.js +21 -0
- package/dist/document-model-editor/components/errors.d.ts +6 -0
- package/dist/document-model-editor/components/errors.d.ts.map +1 -0
- package/dist/document-model-editor/components/errors.js +4 -0
- package/dist/document-model-editor/components/form.d.ts +12 -0
- package/dist/document-model-editor/components/form.d.ts.map +1 -0
- package/dist/document-model-editor/components/form.js +42 -0
- package/dist/document-model-editor/components/input.d.ts +6 -0
- package/dist/document-model-editor/components/input.d.ts.map +1 -0
- package/dist/document-model-editor/components/input.js +8 -0
- package/dist/document-model-editor/components/label.d.ts +6 -0
- package/dist/document-model-editor/components/label.d.ts.map +1 -0
- package/dist/document-model-editor/components/label.js +9 -0
- package/dist/document-model-editor/components/model-metadata-form.d.ts +45 -0
- package/dist/document-model-editor/components/model-metadata-form.d.ts.map +1 -0
- package/dist/document-model-editor/components/model-metadata-form.js +69 -0
- package/dist/document-model-editor/components/module-form.d.ts +10 -0
- package/dist/document-model-editor/components/module-form.d.ts.map +1 -0
- package/dist/document-model-editor/components/module-form.js +21 -0
- package/dist/document-model-editor/components/module.d.ts +21 -0
- package/dist/document-model-editor/components/module.d.ts.map +1 -0
- package/dist/document-model-editor/components/module.js +9 -0
- package/dist/document-model-editor/components/modules.d.ts +19 -0
- package/dist/document-model-editor/components/modules.d.ts.map +1 -0
- package/dist/document-model-editor/components/modules.js +16 -0
- package/dist/document-model-editor/components/operation-description-form.d.ts +9 -0
- package/dist/document-model-editor/components/operation-description-form.d.ts.map +1 -0
- package/dist/document-model-editor/components/operation-description-form.js +12 -0
- package/dist/document-model-editor/components/operation-error-form.d.ts +13 -0
- package/dist/document-model-editor/components/operation-error-form.d.ts.map +1 -0
- package/dist/document-model-editor/components/operation-error-form.js +39 -0
- package/dist/document-model-editor/components/operation-errors.d.ts +10 -0
- package/dist/document-model-editor/components/operation-errors.d.ts.map +1 -0
- package/dist/document-model-editor/components/operation-errors.js +16 -0
- package/dist/document-model-editor/components/operation-form.d.ts +13 -0
- package/dist/document-model-editor/components/operation-form.d.ts.map +1 -0
- package/dist/document-model-editor/components/operation-form.js +36 -0
- package/dist/document-model-editor/components/operation.d.ts +22 -0
- package/dist/document-model-editor/components/operation.d.ts.map +1 -0
- package/dist/document-model-editor/components/operation.js +21 -0
- package/dist/document-model-editor/components/operations.d.ts +17 -0
- package/dist/document-model-editor/components/operations.d.ts.map +1 -0
- package/dist/document-model-editor/components/operations.js +19 -0
- package/dist/document-model-editor/components/state-schemas.d.ts +13 -0
- package/dist/document-model-editor/components/state-schemas.d.ts.map +1 -0
- package/dist/document-model-editor/components/state-schemas.js +34 -0
- package/dist/document-model-editor/components/tabs.d.ts +8 -0
- package/dist/document-model-editor/components/tabs.d.ts.map +1 -0
- package/dist/document-model-editor/components/tabs.js +12 -0
- package/dist/document-model-editor/components/text-area.d.ts +9 -0
- package/dist/document-model-editor/components/text-area.d.ts.map +1 -0
- package/dist/document-model-editor/components/text-area.js +26 -0
- package/dist/document-model-editor/components/text-field.d.ts +21 -0
- package/dist/document-model-editor/components/text-field.d.ts.map +1 -0
- package/dist/document-model-editor/components/text-field.js +78 -0
- package/dist/document-model-editor/constants/documents.d.ts +12 -0
- package/dist/document-model-editor/constants/documents.d.ts.map +1 -0
- package/dist/document-model-editor/constants/documents.js +16 -0
- package/dist/document-model-editor/context/form-context.d.ts +11 -0
- package/dist/document-model-editor/context/form-context.d.ts.map +1 -0
- package/dist/document-model-editor/context/form-context.js +3 -0
- package/dist/document-model-editor/context/schema-context.d.ts +11 -0
- package/dist/document-model-editor/context/schema-context.d.ts.map +1 -0
- package/dist/document-model-editor/context/schema-context.js +116 -0
- package/dist/document-model-editor/document-model-editor.stories.d.ts +48 -0
- package/dist/document-model-editor/document-model-editor.stories.d.ts.map +1 -0
- package/dist/document-model-editor/document-model-editor.stories.js +252 -0
- package/dist/document-model-editor/editor.d.ts +3 -0
- package/dist/document-model-editor/editor.d.ts.map +1 -0
- package/dist/document-model-editor/editor.js +186 -0
- package/dist/document-model-editor/hooks/useFormField.d.ts +13 -0
- package/dist/document-model-editor/hooks/useFormField.d.ts.map +1 -0
- package/dist/document-model-editor/hooks/useFormField.js +21 -0
- package/dist/document-model-editor/index.d.ts +3 -0
- package/dist/document-model-editor/index.d.ts.map +1 -0
- package/dist/document-model-editor/index.js +2 -0
- package/dist/document-model-editor/module.d.ts +4 -0
- package/dist/document-model-editor/module.d.ts.map +1 -0
- package/dist/document-model-editor/module.js +10 -0
- package/dist/document-model-editor/schemas/inputs.d.ts +31 -0
- package/dist/document-model-editor/schemas/inputs.d.ts.map +1 -0
- package/dist/document-model-editor/schemas/inputs.js +70 -0
- package/dist/document-model-editor/schemas/utils.d.ts +3 -0
- package/dist/document-model-editor/schemas/utils.d.ts.map +1 -0
- package/dist/document-model-editor/schemas/utils.js +2 -0
- package/dist/document-model-editor/types/documents.d.ts +27 -0
- package/dist/document-model-editor/types/documents.d.ts.map +1 -0
- package/dist/document-model-editor/types/documents.js +1 -0
- package/dist/document-model-editor/utils/helpers.d.ts +39 -0
- package/dist/document-model-editor/utils/helpers.d.ts.map +1 -0
- package/dist/document-model-editor/utils/helpers.js +293 -0
- package/dist/document-model-editor/utils/linting.d.ts +7 -0
- package/dist/document-model-editor/utils/linting.d.ts.map +1 -0
- package/dist/document-model-editor/utils/linting.js +47 -0
- package/dist/document-model-editor/utils/style.d.ts +3 -0
- package/dist/document-model-editor/utils/style.d.ts.map +1 -0
- package/dist/document-model-editor/utils/style.js +5 -0
- package/dist/editor-utils/components/documentEditor.d.ts +7 -0
- package/dist/editor-utils/components/documentEditor.d.ts.map +1 -0
- package/dist/editor-utils/components/documentEditor.js +5 -0
- package/dist/editor-utils/components/editorToolbar.d.ts +11 -0
- package/dist/editor-utils/components/editorToolbar.d.ts.map +1 -0
- package/dist/editor-utils/components/editorToolbar.js +5 -0
- package/dist/editor-utils/components/editorWorksheet.d.ts +7 -0
- package/dist/editor-utils/components/editorWorksheet.d.ts.map +1 -0
- package/dist/editor-utils/components/editorWorksheet.js +4 -0
- package/dist/editor-utils/components/index.d.ts +9 -0
- package/dist/editor-utils/components/index.d.ts.map +1 -0
- package/dist/editor-utils/components/index.js +9 -0
- package/dist/editor-utils/components/styles.d.ts +40 -0
- package/dist/editor-utils/components/styles.d.ts.map +1 -0
- package/dist/editor-utils/components/styles.js +78 -0
- package/dist/editor-utils/components/stylesVariant.d.ts +40 -0
- package/dist/editor-utils/components/stylesVariant.d.ts.map +1 -0
- package/dist/editor-utils/components/stylesVariant.js +88 -0
- package/dist/editor-utils/components/textInput.d.ts +20 -0
- package/dist/editor-utils/components/textInput.d.ts.map +1 -0
- package/dist/editor-utils/components/textInput.js +83 -0
- package/dist/editor-utils/components/textInputVariant.d.ts +21 -0
- package/dist/editor-utils/components/textInputVariant.d.ts.map +1 -0
- package/dist/editor-utils/components/textInputVariant.js +92 -0
- package/dist/editor-utils/components/toolbarButton.d.ts +7 -0
- package/dist/editor-utils/components/toolbarButton.d.ts.map +1 -0
- package/dist/editor-utils/components/toolbarButton.js +8 -0
- package/dist/editor-utils/hooks/index.d.ts +2 -0
- package/dist/editor-utils/hooks/index.d.ts.map +1 -0
- package/dist/editor-utils/hooks/index.js +1 -0
- package/dist/editor-utils/hooks/useEnsInfo.d.ts +15 -0
- package/dist/editor-utils/hooks/useEnsInfo.d.ts.map +1 -0
- package/dist/editor-utils/hooks/useEnsInfo.js +63 -0
- package/dist/editor-utils/index.d.ts +5 -0
- package/dist/editor-utils/index.d.ts.map +1 -0
- package/dist/editor-utils/index.js +4 -0
- package/dist/editor-utils/reducer.d.ts +3 -0
- package/dist/editor-utils/reducer.d.ts.map +1 -0
- package/dist/editor-utils/reducer.js +24 -0
- package/dist/editor-utils/storybook.d.ts +25 -0
- package/dist/editor-utils/storybook.d.ts.map +1 -0
- package/dist/editor-utils/storybook.js +118 -0
- package/dist/styles.css +786 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorWorksheet.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/editorWorksheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,2CAO/C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DocumentEditor } from "./documentEditor.js";
|
|
2
|
+
export { EditorToolbar } from "./editorToolbar.js";
|
|
3
|
+
export { EditorWorksheet } from "./editorWorksheet.js";
|
|
4
|
+
export * as styles from "./styles.js";
|
|
5
|
+
export * as stylesVariant from "./stylesVariant.js";
|
|
6
|
+
export { TextInput } from "./textInput.js";
|
|
7
|
+
export { TextInputVariant } from "./textInputVariant.js";
|
|
8
|
+
export { ToolbarButton } from "./toolbarButton.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DocumentEditor } from "./documentEditor.js";
|
|
2
|
+
export { EditorToolbar } from "./editorToolbar.js";
|
|
3
|
+
export { EditorWorksheet } from "./editorWorksheet.js";
|
|
4
|
+
export * as styles from "./styles.js";
|
|
5
|
+
export * as stylesVariant from "./stylesVariant.js";
|
|
6
|
+
export { TextInput } from "./textInput.js";
|
|
7
|
+
export { TextInputVariant } from "./textInputVariant.js";
|
|
8
|
+
export { ToolbarButton } from "./toolbarButton.js";
|
|
9
|
+
// import "./styles.css";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
type ColorTheme = "light" | "dark";
|
|
3
|
+
declare const colorScheme: {
|
|
4
|
+
light: {
|
|
5
|
+
color: string;
|
|
6
|
+
bgColor: string;
|
|
7
|
+
border: string;
|
|
8
|
+
shadow: string;
|
|
9
|
+
inputColor: string;
|
|
10
|
+
inputBg: string;
|
|
11
|
+
};
|
|
12
|
+
dark: {
|
|
13
|
+
color: string;
|
|
14
|
+
bgColor: string;
|
|
15
|
+
border: string;
|
|
16
|
+
shadow: string;
|
|
17
|
+
inputColor: string;
|
|
18
|
+
inputBg: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type TypographySize = "huge" | "larger" | "large" | "medium" | "small" | "smaller" | "tiny";
|
|
22
|
+
type TypographyScheme = {
|
|
23
|
+
[K in TypographySize]: CSSProperties;
|
|
24
|
+
};
|
|
25
|
+
declare const typographySizes: TypographyScheme;
|
|
26
|
+
declare const inputStyle: (mode?: keyof typeof colorScheme, focus?: boolean) => {
|
|
27
|
+
width: string;
|
|
28
|
+
border: string;
|
|
29
|
+
boxSizing: "border-box";
|
|
30
|
+
backgroundColor: string;
|
|
31
|
+
outline: string;
|
|
32
|
+
color: string;
|
|
33
|
+
resize: "none";
|
|
34
|
+
fontFamily: "Roboto, sans-serif";
|
|
35
|
+
overflow: "hidden";
|
|
36
|
+
lineHeight: string;
|
|
37
|
+
};
|
|
38
|
+
export type { ColorTheme, TypographyScheme, TypographySize };
|
|
39
|
+
export { colorScheme, inputStyle, typographySizes };
|
|
40
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,KAAK,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnC,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAEF,KAAK,cAAc,GACf,MAAM,GACN,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AACX,KAAK,gBAAgB,GAAG;KAAG,CAAC,IAAI,cAAc,GAAG,aAAa;CAAE,CAAC;AAEjE,QAAA,MAAM,eAAe,EAAE,gBA2CtB,CAAC;AAEF,QAAA,MAAM,UAAU,UACR,MAAM,OAAO,WAAW;;;;;;;;;;;CAiB/B,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const colorScheme = {
|
|
2
|
+
light: {
|
|
3
|
+
color: "#222222",
|
|
4
|
+
bgColor: "#FFFFFF",
|
|
5
|
+
border: "#EEEEEE",
|
|
6
|
+
shadow: "rgba(128,128,128,0.65)",
|
|
7
|
+
inputColor: "#222222",
|
|
8
|
+
inputBg: "#F6F6F6",
|
|
9
|
+
},
|
|
10
|
+
dark: {
|
|
11
|
+
color: "#E6E6E6",
|
|
12
|
+
bgColor: "#181818",
|
|
13
|
+
border: "#181818",
|
|
14
|
+
shadow: "rgba(0, 0, 0, 0.25)",
|
|
15
|
+
inputColor: "#E6E6E6",
|
|
16
|
+
inputBg: "#222222",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
const typographySizes = {
|
|
20
|
+
huge: {
|
|
21
|
+
fontSize: "36pt",
|
|
22
|
+
fontWeight: "bold",
|
|
23
|
+
padding: "6pt",
|
|
24
|
+
margin: "30pt 0 0 0",
|
|
25
|
+
},
|
|
26
|
+
larger: {
|
|
27
|
+
fontSize: "24pt",
|
|
28
|
+
fontWeight: "bold",
|
|
29
|
+
padding: "6pt",
|
|
30
|
+
margin: "18pt 0 0 0",
|
|
31
|
+
},
|
|
32
|
+
large: {
|
|
33
|
+
fontSize: "18pt",
|
|
34
|
+
fontWeight: "bold",
|
|
35
|
+
padding: "6pt",
|
|
36
|
+
margin: "12pt 0 0 0",
|
|
37
|
+
},
|
|
38
|
+
medium: {
|
|
39
|
+
fontSize: "11pt",
|
|
40
|
+
fontWeight: "bold",
|
|
41
|
+
padding: "6pt",
|
|
42
|
+
margin: "5pt 0 0 0",
|
|
43
|
+
},
|
|
44
|
+
small: {
|
|
45
|
+
fontSize: "10pt",
|
|
46
|
+
fontWeight: "normal",
|
|
47
|
+
padding: "6pt",
|
|
48
|
+
margin: "0",
|
|
49
|
+
},
|
|
50
|
+
smaller: {
|
|
51
|
+
fontSize: "9pt",
|
|
52
|
+
fontWeight: "normal",
|
|
53
|
+
padding: "6pt",
|
|
54
|
+
margin: "0",
|
|
55
|
+
},
|
|
56
|
+
tiny: {
|
|
57
|
+
fontSize: "8pt",
|
|
58
|
+
fontWeight: "normal",
|
|
59
|
+
padding: "6pt",
|
|
60
|
+
margin: "0",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const inputStyle = (mode = "light", focus = false) => {
|
|
64
|
+
const scheme = colorScheme[mode];
|
|
65
|
+
return {
|
|
66
|
+
width: "100%",
|
|
67
|
+
border: "none",
|
|
68
|
+
boxSizing: "border-box",
|
|
69
|
+
backgroundColor: focus ? scheme.inputBg : scheme.bgColor,
|
|
70
|
+
outline: "none",
|
|
71
|
+
color: scheme.inputColor,
|
|
72
|
+
resize: "none",
|
|
73
|
+
fontFamily: "Roboto, sans-serif",
|
|
74
|
+
overflow: "hidden",
|
|
75
|
+
lineHeight: "1.5",
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export { colorScheme, inputStyle, typographySizes };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
type ColorTheme = "light" | "dark";
|
|
3
|
+
declare const colorScheme: {
|
|
4
|
+
light: {
|
|
5
|
+
color: string;
|
|
6
|
+
bgColor: string;
|
|
7
|
+
border: string;
|
|
8
|
+
shadow: string;
|
|
9
|
+
inputColor: string;
|
|
10
|
+
inputBg: string;
|
|
11
|
+
};
|
|
12
|
+
dark: {
|
|
13
|
+
color: string;
|
|
14
|
+
bgColor: string;
|
|
15
|
+
border: string;
|
|
16
|
+
shadow: string;
|
|
17
|
+
inputColor: string;
|
|
18
|
+
inputBg: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type TypographySize = "chapter" | "huge" | "larger" | "large" | "medium" | "small" | "smaller" | "tiny";
|
|
22
|
+
type TypographyScheme = {
|
|
23
|
+
[K in TypographySize]: CSSProperties;
|
|
24
|
+
};
|
|
25
|
+
declare const typographySizes: TypographyScheme;
|
|
26
|
+
declare const inputStyle: (mode?: keyof typeof colorScheme, focus?: boolean) => {
|
|
27
|
+
width: string;
|
|
28
|
+
border: string;
|
|
29
|
+
boxSizing: "border-box";
|
|
30
|
+
backgroundColor: string;
|
|
31
|
+
outline: string;
|
|
32
|
+
color: string;
|
|
33
|
+
resize: "none";
|
|
34
|
+
fontFamily: "Roboto, sans-serif";
|
|
35
|
+
overflow: "hidden";
|
|
36
|
+
lineHeight: string;
|
|
37
|
+
};
|
|
38
|
+
export type { ColorTheme, TypographyScheme, TypographySize };
|
|
39
|
+
export { colorScheme, inputStyle, typographySizes };
|
|
40
|
+
//# sourceMappingURL=stylesVariant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesVariant.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/stylesVariant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,KAAK,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnC,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAEF,KAAK,cAAc,GACf,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AACX,KAAK,gBAAgB,GAAG;KAAG,CAAC,IAAI,cAAc,GAAG,aAAa;CAAE,CAAC;AAEjE,QAAA,MAAM,eAAe,EAAE,gBAqDtB,CAAC;AAEF,QAAA,MAAM,UAAU,UACR,MAAM,OAAO,WAAW;;;;;;;;;;;CAiB/B,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const colorScheme = {
|
|
2
|
+
light: {
|
|
3
|
+
color: "#222222",
|
|
4
|
+
bgColor: "#FFFFFF",
|
|
5
|
+
border: "#EEEEEE",
|
|
6
|
+
shadow: "rgba(128,128,128,0.65)",
|
|
7
|
+
inputColor: "#222222",
|
|
8
|
+
inputBg: "#F6F6F6",
|
|
9
|
+
},
|
|
10
|
+
dark: {
|
|
11
|
+
color: "#CCCCCC",
|
|
12
|
+
bgColor: "#0A0A0A",
|
|
13
|
+
border: "#181818",
|
|
14
|
+
shadow: "rgba(255, 255, 255, 0.25)",
|
|
15
|
+
inputColor: "#CCCCCC",
|
|
16
|
+
inputBg: "#1A1D1F",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
const typographySizes = {
|
|
20
|
+
chapter: {
|
|
21
|
+
fontSize: "64pt",
|
|
22
|
+
fontWeight: "bold",
|
|
23
|
+
padding: "6pt 24pt",
|
|
24
|
+
margin: "0",
|
|
25
|
+
lineHeight: 1,
|
|
26
|
+
textAlign: "right",
|
|
27
|
+
borderLeft: "4px solid",
|
|
28
|
+
},
|
|
29
|
+
huge: {
|
|
30
|
+
fontSize: "32pt",
|
|
31
|
+
fontWeight: "normal",
|
|
32
|
+
padding: "6pt",
|
|
33
|
+
margin: "0 0 0 -6pt",
|
|
34
|
+
lineHeight: 1,
|
|
35
|
+
},
|
|
36
|
+
larger: {
|
|
37
|
+
fontSize: "24pt",
|
|
38
|
+
fontWeight: "bold",
|
|
39
|
+
padding: "6pt",
|
|
40
|
+
margin: "-12pt 0 0 0",
|
|
41
|
+
},
|
|
42
|
+
large: {
|
|
43
|
+
fontSize: "18pt",
|
|
44
|
+
fontWeight: "bold",
|
|
45
|
+
padding: "6pt",
|
|
46
|
+
margin: "-10.5pt 0 0 0",
|
|
47
|
+
},
|
|
48
|
+
medium: {
|
|
49
|
+
fontSize: "11pt",
|
|
50
|
+
fontWeight: "bold",
|
|
51
|
+
padding: "6pt",
|
|
52
|
+
margin: "-8pt 0 0 0",
|
|
53
|
+
},
|
|
54
|
+
small: {
|
|
55
|
+
fontSize: "10pt",
|
|
56
|
+
fontWeight: "normal",
|
|
57
|
+
padding: "6pt",
|
|
58
|
+
margin: "-6pt 0 0 0",
|
|
59
|
+
},
|
|
60
|
+
smaller: {
|
|
61
|
+
fontSize: "9pt",
|
|
62
|
+
fontWeight: "normal",
|
|
63
|
+
padding: "6pt",
|
|
64
|
+
margin: "-5pt 0 0 0",
|
|
65
|
+
},
|
|
66
|
+
tiny: {
|
|
67
|
+
fontSize: "8pt",
|
|
68
|
+
fontWeight: "normal",
|
|
69
|
+
padding: "6pt",
|
|
70
|
+
margin: "-8pt 0 0 0",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const inputStyle = (mode = "light", focus = false) => {
|
|
74
|
+
const scheme = colorScheme[mode];
|
|
75
|
+
return {
|
|
76
|
+
width: "100%",
|
|
77
|
+
border: "none",
|
|
78
|
+
boxSizing: "border-box",
|
|
79
|
+
backgroundColor: focus ? scheme.inputBg : scheme.bgColor,
|
|
80
|
+
outline: "none",
|
|
81
|
+
color: scheme.inputColor,
|
|
82
|
+
resize: "none",
|
|
83
|
+
fontFamily: "Roboto, sans-serif",
|
|
84
|
+
overflow: "hidden",
|
|
85
|
+
lineHeight: "1.5",
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export { colorScheme, inputStyle, typographySizes };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TypographySize } from "./styles.js";
|
|
2
|
+
interface TextInputProps {
|
|
3
|
+
readonly theme: "light" | "dark";
|
|
4
|
+
readonly size?: TypographySize;
|
|
5
|
+
readonly horizontalLine?: boolean;
|
|
6
|
+
readonly id?: string;
|
|
7
|
+
readonly value?: string;
|
|
8
|
+
readonly placeholder?: string;
|
|
9
|
+
readonly autoFocus?: boolean;
|
|
10
|
+
readonly clearOnSubmit?: boolean;
|
|
11
|
+
readonly onSubmit?: {
|
|
12
|
+
(value: string): void;
|
|
13
|
+
};
|
|
14
|
+
readonly onEmpty?: {
|
|
15
|
+
(id: string): void;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare function TextInput(props: TextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=textInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textInput.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/textInput.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAmB,MAAM,aAAa,CAAC;AAE1E,UAAU,cAAc;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC3C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,2CAuH9C"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { inputStyle, typographySizes } from "./styles.js";
|
|
4
|
+
export function TextInput(props) {
|
|
5
|
+
const [state, setState] = useState({
|
|
6
|
+
value: props.value || "",
|
|
7
|
+
hasFocus: false,
|
|
8
|
+
pressingEnter: false,
|
|
9
|
+
});
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setState((state) => state.value !== props.value
|
|
12
|
+
? { ...state, value: props.value || "" }
|
|
13
|
+
: state);
|
|
14
|
+
}, [props.value]);
|
|
15
|
+
const onKeyDown = (e) => {
|
|
16
|
+
if (e.key === "Enter") {
|
|
17
|
+
setState({ ...state, pressingEnter: true });
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const onKeyUp = (e) => {
|
|
22
|
+
if (e.key === "Enter") {
|
|
23
|
+
if (e.target && props.onSubmit) {
|
|
24
|
+
props.onSubmit(e.target.value);
|
|
25
|
+
}
|
|
26
|
+
if (props.clearOnSubmit) {
|
|
27
|
+
setState({ ...state, value: "", pressingEnter: false });
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
setState({ ...state, pressingEnter: false });
|
|
31
|
+
}
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
}
|
|
34
|
+
if (e.key === "Backspace" || e.key === "Delete") {
|
|
35
|
+
if (props.onEmpty && e.target.value.length < 1) {
|
|
36
|
+
props.onEmpty(props.id || "");
|
|
37
|
+
}
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const onInput = (e) => {
|
|
42
|
+
if (!state.pressingEnter) {
|
|
43
|
+
const target = e.target;
|
|
44
|
+
setState({ ...state, value: target.value });
|
|
45
|
+
target.style.height = "1px";
|
|
46
|
+
target.style.height = target.scrollHeight + "px";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const setFocus = (f) => {
|
|
50
|
+
setState((state) => ({ ...state, hasFocus: f }));
|
|
51
|
+
if (!f) {
|
|
52
|
+
const newValue = ref.current?.value || "";
|
|
53
|
+
const origValue = props.value || "";
|
|
54
|
+
if (newValue != origValue && props.onSubmit) {
|
|
55
|
+
props.onSubmit(newValue);
|
|
56
|
+
if (props.clearOnSubmit) {
|
|
57
|
+
setState((state) => ({ ...state, value: "" }));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const ref = useRef(null);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const resizeTextArea = () => {
|
|
65
|
+
if (ref.current) {
|
|
66
|
+
ref.current.style.height = "1px";
|
|
67
|
+
ref.current.style.height = ref.current.scrollHeight + "px";
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
window.addEventListener("resize", resizeTextArea);
|
|
71
|
+
resizeTextArea();
|
|
72
|
+
return () => {
|
|
73
|
+
window.removeEventListener("resize", resizeTextArea);
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
const style = {
|
|
77
|
+
...inputStyle(props.theme, state.hasFocus),
|
|
78
|
+
...typographySizes[props.size || "small"],
|
|
79
|
+
};
|
|
80
|
+
return (_jsxs("div", { children: [props.horizontalLine ? (_jsx("hr", { style: {
|
|
81
|
+
borderColor: inputStyle(props.theme, false).backgroundColor,
|
|
82
|
+
} }, "line")) : (""), _jsx("textarea", { autoFocus: props.autoFocus || false, onBlur: (e) => setFocus(false), onFocus: (e) => setFocus(true), onInput: onInput, onKeyDown: onKeyDown, onKeyUp: onKeyUp, placeholder: props.placeholder || "", ref: ref, style: style, value: state.value }, "text")] }));
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TypographySize } from "./stylesVariant.js";
|
|
2
|
+
interface TextInputProps {
|
|
3
|
+
readonly theme: "light" | "dark";
|
|
4
|
+
readonly size?: TypographySize;
|
|
5
|
+
readonly horizontalLine?: boolean;
|
|
6
|
+
readonly id?: string;
|
|
7
|
+
readonly value?: string;
|
|
8
|
+
readonly placeholder?: string;
|
|
9
|
+
readonly autoFocus?: boolean;
|
|
10
|
+
readonly clearOnSubmit?: boolean;
|
|
11
|
+
readonly onSubmit?: {
|
|
12
|
+
(value: string): void;
|
|
13
|
+
};
|
|
14
|
+
readonly onEmpty?: {
|
|
15
|
+
(id: string): void;
|
|
16
|
+
};
|
|
17
|
+
readonly labelStyle?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function TextInputVariant(props: TextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=textInputVariant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textInputVariant.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/textInputVariant.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EAEf,MAAM,oBAAoB,CAAC;AAE5B,UAAU,cAAc;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,2CAiIrD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { inputStyle, typographySizes, } from "./stylesVariant.js";
|
|
4
|
+
export function TextInputVariant(props) {
|
|
5
|
+
const [state, setState] = useState({
|
|
6
|
+
value: props.value || "",
|
|
7
|
+
hasFocus: false,
|
|
8
|
+
pressingEnter: false,
|
|
9
|
+
});
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setState({ ...state, value: props.value || "" });
|
|
12
|
+
}, [props.value]);
|
|
13
|
+
const onKeyDown = (e) => {
|
|
14
|
+
if (e.key === "Enter") {
|
|
15
|
+
setState({ ...state, pressingEnter: true });
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const onKeyUp = (e) => {
|
|
20
|
+
if (e.key === "Enter") {
|
|
21
|
+
if (e.target && props.onSubmit) {
|
|
22
|
+
props.onSubmit(e.target.value);
|
|
23
|
+
}
|
|
24
|
+
if (props.clearOnSubmit) {
|
|
25
|
+
setState({ ...state, value: "", pressingEnter: false });
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
setState({ ...state, pressingEnter: false });
|
|
29
|
+
}
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
if (e.key === "Backspace" || e.key === "Delete") {
|
|
33
|
+
if (props.onEmpty && e.target.value.length < 1) {
|
|
34
|
+
props.onEmpty(props.id || "");
|
|
35
|
+
}
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const onInput = (e) => {
|
|
40
|
+
if (!state.pressingEnter) {
|
|
41
|
+
const target = e.target;
|
|
42
|
+
setState({ ...state, value: target.value });
|
|
43
|
+
target.style.height = "1px";
|
|
44
|
+
target.style.height = target.scrollHeight + "px";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const setFocus = (f) => {
|
|
48
|
+
setState({ ...state, hasFocus: f });
|
|
49
|
+
if (!f) {
|
|
50
|
+
const newValue = ref.current?.value || "";
|
|
51
|
+
const origValue = props.value || "";
|
|
52
|
+
if (newValue != origValue && props.onSubmit) {
|
|
53
|
+
props.onSubmit(newValue);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const ref = useRef(null);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const resizeTextArea = () => {
|
|
60
|
+
if (ref.current) {
|
|
61
|
+
ref.current.style.height = "1px";
|
|
62
|
+
ref.current.style.height = ref.current.scrollHeight + "px";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
window.addEventListener("resize", resizeTextArea);
|
|
66
|
+
resizeTextArea();
|
|
67
|
+
return () => {
|
|
68
|
+
window.removeEventListener("resize", resizeTextArea);
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
const style = {
|
|
72
|
+
...inputStyle(props.theme, state.hasFocus),
|
|
73
|
+
...typographySizes[props.size || "small"],
|
|
74
|
+
};
|
|
75
|
+
if (props.labelStyle) {
|
|
76
|
+
style.textAlign = "center";
|
|
77
|
+
style.textTransform = "uppercase";
|
|
78
|
+
style.backgroundColor = "rgba(0, 0, 255, 0.05)";
|
|
79
|
+
style.borderRadius = "8px";
|
|
80
|
+
style.padding = "1px 0 4px 0";
|
|
81
|
+
style.margin = "0";
|
|
82
|
+
style.fontWeight = "bold";
|
|
83
|
+
style.fontSize = "8pt";
|
|
84
|
+
style.color = "#518EBE";
|
|
85
|
+
style.border = "2px solid #518EBE";
|
|
86
|
+
style.cursor = "pointer";
|
|
87
|
+
style.lineHeight = "1.5";
|
|
88
|
+
}
|
|
89
|
+
return (_jsxs("div", { children: [props.horizontalLine ? (_jsx("hr", { style: {
|
|
90
|
+
borderColor: inputStyle(props.theme, false).backgroundColor,
|
|
91
|
+
} }, "line")) : (""), _jsx("textarea", { autoFocus: props.autoFocus || false, onBlur: (e) => setFocus(false), onFocus: (e) => setFocus(true), onInput: onInput, onKeyDown: onKeyDown, onKeyUp: onKeyUp, placeholder: props.placeholder || "", ref: ref, spellCheck: state.hasFocus, style: style, tabIndex: props.labelStyle ? -1 : 1, value: state.value }, "text")] }));
|
|
92
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
interface ToolbarButtonProps {
|
|
3
|
+
readonly onClick?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare function ToolbarButton(props: PropsWithChildren<ToolbarButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=toolbarButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbarButton.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/toolbarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,2CAgBzE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function ToolbarButton(props) {
|
|
3
|
+
const handleClick = props.onClick ||
|
|
4
|
+
(() => {
|
|
5
|
+
console.log("No onClick handler attached to button.");
|
|
6
|
+
});
|
|
7
|
+
return (_jsx("div", { className: "toolbar-button", onClick: handleClick, style: { userSelect: "none" }, children: props.children }));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editor-utils/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useEnsInfo } from "./useEnsInfo.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import * as chains from "viem/chains";
|
|
3
|
+
export type { Address } from "viem";
|
|
4
|
+
export type Chain = chains.Chain;
|
|
5
|
+
export declare function getChain(id: number): Chain | undefined;
|
|
6
|
+
export type ENSInfo = {
|
|
7
|
+
name?: string;
|
|
8
|
+
avatarUrl?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const getEnsInfo: (address: Address, chainId: number) => Promise<ENSInfo>;
|
|
11
|
+
export declare function useEnsInfo(address?: `0x${string}`, chainId?: number): {
|
|
12
|
+
info: ENSInfo | undefined;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useEnsInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEnsInfo.d.ts","sourceRoot":"","sources":["../../../editor-utils/hooks/useEnsInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA0C,MAAM,MAAM,CAAC;AAEvE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,YAAY,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAEjC,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAItD;AA6BD,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,UAAU,YACZ,OAAO,WACP,MAAM,KACd,OAAO,CAAC,OAAO,CAiBjB,CAAC;AAEF,wBAAgB,UAAU,CACxB,OAAO,CAAC,EAAE,KAAK,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,GACf;IAAE,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAgBjD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { createPublicClient, http } from "viem";
|
|
3
|
+
import { getEnsAvatar, getEnsName } from "viem/actions";
|
|
4
|
+
import * as chains from "viem/chains";
|
|
5
|
+
export function getChain(id) {
|
|
6
|
+
return Object.values(chains).find((x) => "id" in x && x.id === id);
|
|
7
|
+
}
|
|
8
|
+
let client = createPublicClient({
|
|
9
|
+
chain: chains.mainnet,
|
|
10
|
+
batch: {
|
|
11
|
+
multicall: true,
|
|
12
|
+
},
|
|
13
|
+
transport: http(),
|
|
14
|
+
});
|
|
15
|
+
function updateChain(chainId) {
|
|
16
|
+
if (client.chain?.id === chainId) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const chain = getChain(chainId);
|
|
20
|
+
if (!chain) {
|
|
21
|
+
throw new Error(`Invalid chain id: ${chainId}`);
|
|
22
|
+
}
|
|
23
|
+
client = createPublicClient({
|
|
24
|
+
chain,
|
|
25
|
+
batch: {
|
|
26
|
+
multicall: true,
|
|
27
|
+
},
|
|
28
|
+
transport: http(),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export const getEnsInfo = async (address, chainId) => {
|
|
32
|
+
const result = {};
|
|
33
|
+
try {
|
|
34
|
+
updateChain(chainId);
|
|
35
|
+
const name = await getEnsName(client, { address });
|
|
36
|
+
if (name) {
|
|
37
|
+
result.name = name;
|
|
38
|
+
const avatarUrl = await getEnsAvatar(client, { name });
|
|
39
|
+
if (avatarUrl) {
|
|
40
|
+
result.avatarUrl = avatarUrl;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
console.error(e);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
export function useEnsInfo(address, chainId) {
|
|
50
|
+
const [info, setInfo] = useState(undefined);
|
|
51
|
+
const [loading, setLoading] = useState(false);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!address || !chainId) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
setLoading(true);
|
|
57
|
+
getEnsInfo(address, chainId)
|
|
58
|
+
.then((info) => setInfo(info))
|
|
59
|
+
.catch(console.error)
|
|
60
|
+
.finally(() => setLoading(false));
|
|
61
|
+
}, [address, chainId]);
|
|
62
|
+
return useMemo(() => ({ info, loading }), [info, loading]);
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../editor-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ActionFromDocument, PHDocument, Reducer } from "document-model";
|
|
2
|
+
export declare function useDocumentReducer<TDocument extends PHDocument>(reducer: Reducer<TDocument>, initialState: TDocument, onError?: (error: unknown) => void): readonly [TDocument, (action: ActionFromDocument<TDocument>) => void];
|
|
3
|
+
//# sourceMappingURL=reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../editor-utils/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAElB,UAAU,EACV,OAAO,EACR,MAAM,gBAAgB,CAAC;AAGxB,wBAAgB,kBAAkB,CAAC,SAAS,SAAS,UAAU,EAC7D,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,EAC3B,YAAY,EAAE,SAAS,EACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,CA6BvE"}
|