@tiny-codes/react-easy 1.3.0 → 1.4.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/es/components/ConfirmAction/withConfirmAction.js +23 -1
  3. package/es/components/ConfirmAction/withConfirmAction.js.map +1 -1
  4. package/es/components/Lexical/helpers/index.d.ts +58 -0
  5. package/es/components/Lexical/helpers/index.js +249 -0
  6. package/es/components/Lexical/helpers/index.js.map +1 -0
  7. package/es/components/Lexical/index.d.ts +5 -0
  8. package/es/components/Lexical/index.js +6 -0
  9. package/es/components/Lexical/index.js.map +1 -0
  10. package/es/components/Lexical/nodes/DivNode.d.ts +25 -0
  11. package/es/components/Lexical/nodes/DivNode.js +163 -0
  12. package/es/components/Lexical/nodes/DivNode.js.map +1 -0
  13. package/es/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
  14. package/es/components/Lexical/nodes/ExtendTextNode.js +102 -0
  15. package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -0
  16. package/es/components/Lexical/nodes/SelectNode.d.ts +44 -0
  17. package/es/components/Lexical/nodes/SelectNode.js +204 -0
  18. package/es/components/Lexical/nodes/SelectNode.js.map +1 -0
  19. package/es/components/Lexical/nodes/base.d.ts +51 -0
  20. package/es/components/Lexical/nodes/base.js +168 -0
  21. package/es/components/Lexical/nodes/base.js.map +1 -0
  22. package/es/hooks/useRefValue.d.ts +2 -2
  23. package/es/hooks/useRefValue.js.map +1 -1
  24. package/lib/components/ConfirmAction/withConfirmAction.js +5 -1
  25. package/lib/components/ConfirmAction/withConfirmAction.js.map +2 -2
  26. package/lib/components/Lexical/helpers/index.d.ts +58 -0
  27. package/lib/components/Lexical/helpers/index.js +198 -0
  28. package/lib/components/Lexical/helpers/index.js.map +7 -0
  29. package/lib/components/Lexical/index.d.ts +5 -0
  30. package/lib/components/Lexical/index.js +32 -0
  31. package/lib/components/Lexical/index.js.map +7 -0
  32. package/lib/components/Lexical/nodes/DivNode.d.ts +25 -0
  33. package/lib/components/Lexical/nodes/DivNode.js +139 -0
  34. package/lib/components/Lexical/nodes/DivNode.js.map +7 -0
  35. package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
  36. package/lib/components/Lexical/nodes/ExtendTextNode.js +87 -0
  37. package/lib/components/Lexical/nodes/ExtendTextNode.js.map +7 -0
  38. package/lib/components/Lexical/nodes/SelectNode.d.ts +44 -0
  39. package/lib/components/Lexical/nodes/SelectNode.js +157 -0
  40. package/lib/components/Lexical/nodes/SelectNode.js.map +7 -0
  41. package/lib/components/Lexical/nodes/base.d.ts +51 -0
  42. package/lib/components/Lexical/nodes/base.js +116 -0
  43. package/lib/components/Lexical/nodes/base.js.map +7 -0
  44. package/lib/hooks/useRefValue.d.ts +2 -2
  45. package/lib/hooks/useRefValue.js.map +2 -2
  46. package/package.json +20 -1
@@ -0,0 +1,116 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/Lexical/nodes/base.ts
20
+ var base_exports = {};
21
+ __export(base_exports, {
22
+ BaseDecoratorNode: () => BaseDecoratorNode,
23
+ BaseElementNode: () => BaseElementNode,
24
+ BaseNodeHelper: () => BaseNodeHelper
25
+ });
26
+ module.exports = __toCommonJS(base_exports);
27
+ var import_lexical = require("lexical");
28
+ var BaseNodeHelper = class {
29
+ constructor(props, superMethods) {
30
+ this.hooks = {
31
+ remove: (preserveEmptyParent) => {
32
+ var _a;
33
+ if (((_a = this.__props) == null ? void 0 : _a.canBeRemoved) === false) {
34
+ return;
35
+ }
36
+ this.__superMethods.remove(preserveEmptyParent);
37
+ },
38
+ replace: (replaceWith, includeChildren) => {
39
+ var _a;
40
+ if (((_a = this.__props) == null ? void 0 : _a.canBeReplaced) === false) {
41
+ return this;
42
+ }
43
+ return this.__superMethods.replace(replaceWith, includeChildren);
44
+ }
45
+ };
46
+ this.__props = props;
47
+ this.__superMethods = superMethods;
48
+ }
49
+ getUnderlyingProps(props) {
50
+ const { canBeRemoved, canBeReplaced, ...restProps } = props;
51
+ return restProps;
52
+ }
53
+ };
54
+ var BaseElementNode = class extends import_lexical.ElementNode {
55
+ constructor(props) {
56
+ const { key, ...restProps } = props || {};
57
+ super(key);
58
+ this.__props = restProps;
59
+ this.__base = new BaseNodeHelper(this.__props, {
60
+ remove: () => super.remove(),
61
+ replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren)
62
+ });
63
+ Object.keys(this.__base.hooks).forEach((key2) => {
64
+ const method = this.__base.hooks[key2];
65
+ if (typeof method === "function") {
66
+ this[key2] = method.bind(this.__base);
67
+ }
68
+ });
69
+ }
70
+ canBeEmpty() {
71
+ var _a;
72
+ return ((_a = this.__props) == null ? void 0 : _a.canBeEmpty) ?? false;
73
+ }
74
+ canInsertTextBefore() {
75
+ var _a;
76
+ return ((_a = this.__props) == null ? void 0 : _a.canInsertTextBefore) ?? true;
77
+ }
78
+ canInsertTextAfter() {
79
+ var _a;
80
+ return ((_a = this.__props) == null ? void 0 : _a.canInsertTextAfter) ?? true;
81
+ }
82
+ getUnderlyingProps(props) {
83
+ const baseProps = this.__base.getUnderlyingProps(props ?? {});
84
+ const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;
85
+ return restProps;
86
+ }
87
+ };
88
+ var BaseDecoratorNode = class extends import_lexical.DecoratorNode {
89
+ constructor(props) {
90
+ const { key, ...restProps } = props || {};
91
+ super(key);
92
+ this.__props = restProps;
93
+ this.__base = new BaseNodeHelper(this.__props, {
94
+ remove: () => super.remove(),
95
+ replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren)
96
+ });
97
+ Object.keys(this.__base.hooks).forEach((key2) => {
98
+ const method = this.__base.hooks[key2];
99
+ if (typeof method === "function") {
100
+ this[key2] = method.bind(this.__base);
101
+ }
102
+ });
103
+ }
104
+ getUnderlyingProps(props) {
105
+ const baseProps = this.__base.getUnderlyingProps(props ?? {});
106
+ const { ...restProps } = baseProps;
107
+ return restProps;
108
+ }
109
+ };
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ BaseDecoratorNode,
113
+ BaseElementNode,
114
+ BaseNodeHelper
115
+ });
116
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/Lexical/nodes/base.ts"],
4
+ "sourcesContent": ["import type { LexicalNode } from 'lexical';\nimport { DecoratorNode, ElementNode } from 'lexical';\n\nexport interface BaseNodeProps {\n /** 是否可被删除,默认 `true` */\n canBeRemoved?: boolean;\n /** 是否可被替换,默认 `true` */\n canBeReplaced?: boolean;\n}\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * 是否允许节点为空,默认 `false`\n *\n * - `true` - 允许节点为空\n * - `false` - 不允许节点为空,当最后一个子节点被删除后,节点也会被删除\n */\n canBeEmpty?: boolean;\n /** 是否允许在节点内的起始位置插入文本,默认 `true` */\n canInsertTextBefore?: boolean;\n /** 是否允许在节点内的结束位置插入文本,默认 `true` */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\n\nexport class BaseNodeHelper<P extends BaseNodeProps> {\n __props: (P & BaseNodeProps) | undefined;\n __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;\n\n constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>) {\n this.__props = props as P & BaseNodeProps;\n this.__superMethods = superMethods;\n }\n\n hooks = {\n remove: (preserveEmptyParent?: boolean): void => {\n if (this.__props?.canBeRemoved === false) {\n return;\n }\n this.__superMethods.remove(preserveEmptyParent);\n },\n\n replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N => {\n if (this.__props?.canBeReplaced === false) {\n return this as unknown as N;\n }\n return this.__superMethods.replace(replaceWith, includeChildren);\n },\n };\n getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps> {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeRemoved, canBeReplaced, ...restProps } = props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\nexport class BaseElementNode<P extends BaseElementProps> extends ElementNode {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n canBeEmpty(): boolean {\n return this.__props?.canBeEmpty ?? false;\n }\n\n canInsertTextBefore(): boolean {\n return this.__props?.canInsertTextBefore ?? true;\n }\n\n canInsertTextAfter(): boolean {\n return this.__props?.canInsertTextAfter ?? true;\n }\n\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\nexport class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA2C;AAwBpC,IAAM,iBAAN,MAA8C;AAAA,EAInD,YAAY,OAAsB,cAAuD;AAKzF,iBAAQ;AAAA,MACN,QAAQ,CAAC,wBAAwC;AAnCrD;AAoCM,cAAI,UAAK,YAAL,mBAAc,kBAAiB,OAAO;AACxC;AAAA,QACF;AACA,aAAK,eAAe,OAAO,mBAAmB;AAAA,MAChD;AAAA,MAEA,SAAS,CAAwB,aAAgB,oBAAiC;AA1CtF;AA2CM,cAAI,UAAK,YAAL,mBAAc,mBAAkB,OAAO;AACzC,iBAAO;AAAA,QACT;AACA,eAAO,KAAK,eAAe,QAAQ,aAAa,eAAe;AAAA,MACjE;AAAA,IACF;AAlBE,SAAK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AAG;AACT,SAAK,UAAU;AAEf,SAAK,SAAS,IAAI,eAAkB,KAAK,SAAS;AAAA,MAChD,QAAQ,MAAM,MAAM,OAAO;AAAA,MAC3B,SAAS,CAAC,aAAa,oBAAoB,MAAM,QAAQ,aAAa,eAAe;AAAA,IACvF,CAAC;AACD,WAAO,KAAK,KAAK,OAAO,KAAK,EAAE,QAAQ,CAACA,SAAQ;AAC9C,YAAM,SAAS,KAAK,OAAO,MAAMA,IAAqC;AACtE,UAAI,OAAO,WAAW,YAAY;AAEhC,aAAKA,IAAiB,IAAI,OAAO,KAAK,KAAK,MAAM;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,mBAAmB,OAA6D;AAC9E,UAAM,YAAY,KAAK,OAAO,mBAAmB,SAAU,CAAC,CAAO;AAEnE,UAAM,EAAE,GAAG,UAAU,IAAI;AAEzB,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["key"]
7
+ }
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import type { RefObject } from 'react';
2
2
  /**
3
3
  * - **EN:** Get a mutable ref object and automatically update the value change
4
4
  * - **CN:** 获取一个可变的ref对象,并自动更新值变化
@@ -7,5 +7,5 @@
7
7
  *
8
8
  * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变
9
9
  */
10
- declare const useRefValue: <T>(value: T) => import("react").RefObject<T>;
10
+ declare const useRefValue: <T>(value: T) => RefObject<T>;
11
11
  export default useRefValue;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/useRefValue.ts"],
4
- "sourcesContent": ["import { useRef } from 'react';\n\n/**\n * - **EN:** Get a mutable ref object and automatically update the value change\n * - **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T) => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAUvB,IAAM,cAAc,CAAI,UAAa;AACnC,QAAM,UAAM,qBAAU,KAAK;AAC3B,MAAI,UAAU;AACd,SAAO;AACT;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["import type { RefObject } from 'react';\nimport { useRef } from 'react';\n\n/**\n * - **EN:** Get a mutable ref object and automatically update the value change\n * - **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T): RefObject<T> => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAuB;AAUvB,IAAM,cAAc,CAAI,UAA2B;AACjD,QAAM,UAAM,qBAAU,KAAK;AAC3B,MAAI,UAAU;AACd,SAAO;AACT;AAEA,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",
@@ -20,6 +20,23 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "author": "李凤宝(Leo) <shijistar@gmail.com>",
23
+ "exports": {
24
+ ".": {
25
+ "import": "./es/index.js",
26
+ "require": "./lib/index.js",
27
+ "default": "./lib/index.js",
28
+ "node": "./lib/index.js",
29
+ "types": "./lib/index.d.ts"
30
+ },
31
+ "./lexical": {
32
+ "import": "./es/components/Lexical/index.js",
33
+ "require": "./lib/components/Lexical/index.js",
34
+ "default": "./lib/components/Lexical/index.js",
35
+ "node": "./lib/components/Lexical/index.js",
36
+ "types": "./lib/components/Lexical/index.d.ts"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
23
40
  "main": "lib/index.js",
24
41
  "module": "es/index.js",
25
42
  "types": "lib/index.d.ts",
@@ -36,7 +53,9 @@
36
53
  "prepublishOnly": "npm run build"
37
54
  },
38
55
  "dependencies": {
56
+ "@lexical/react": "^0.33.1",
39
57
  "i18next": "^24.2.3",
58
+ "lexical": "^0.33.1",
40
59
  "react-contexify": "^6.0.0"
41
60
  },
42
61
  "devDependencies": {