@tiny-codes/react-easy 1.4.0 → 1.4.2

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 (61) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/es/components/FormItemControl/index.d.ts +7 -7
  3. package/es/components/FormItemControl/index.js +6 -6
  4. package/es/components/FormItemControl/index.js.map +1 -1
  5. package/es/components/Lexical/helpers/index.d.ts +39 -24
  6. package/es/components/Lexical/helpers/index.js +63 -24
  7. package/es/components/Lexical/helpers/index.js.map +1 -1
  8. package/es/components/Lexical/index.d.ts +1 -0
  9. package/es/components/Lexical/index.js +1 -0
  10. package/es/components/Lexical/index.js.map +1 -1
  11. package/es/components/Lexical/nodes/CloseIcon.d.ts +71 -0
  12. package/es/components/Lexical/nodes/CloseIcon.js +176 -0
  13. package/es/components/Lexical/nodes/CloseIcon.js.map +1 -0
  14. package/es/components/Lexical/nodes/DivNode.d.ts +20 -0
  15. package/es/components/Lexical/nodes/DivNode.js +32 -4
  16. package/es/components/Lexical/nodes/DivNode.js.map +1 -1
  17. package/es/components/Lexical/nodes/ExtendTextNode.d.ts +23 -1
  18. package/es/components/Lexical/nodes/ExtendTextNode.js +38 -6
  19. package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -1
  20. package/es/components/Lexical/nodes/SelectNode.d.ts +39 -9
  21. package/es/components/Lexical/nodes/SelectNode.js +42 -7
  22. package/es/components/Lexical/nodes/SelectNode.js.map +1 -1
  23. package/es/components/Lexical/nodes/base.d.ts +59 -8
  24. package/es/components/Lexical/nodes/base.js +50 -1
  25. package/es/components/Lexical/nodes/base.js.map +1 -1
  26. package/es/utils/index.d.ts +1 -0
  27. package/es/utils/index.js +1 -0
  28. package/es/utils/index.js.map +1 -1
  29. package/es/utils/string.d.ts +7 -0
  30. package/es/utils/string.js +15 -0
  31. package/es/utils/string.js.map +1 -0
  32. package/lib/components/FormItemControl/index.d.ts +7 -7
  33. package/lib/components/FormItemControl/index.js.map +1 -1
  34. package/lib/components/Lexical/helpers/index.d.ts +39 -24
  35. package/lib/components/Lexical/helpers/index.js +26 -0
  36. package/lib/components/Lexical/helpers/index.js.map +2 -2
  37. package/lib/components/Lexical/index.d.ts +1 -0
  38. package/lib/components/Lexical/index.js +3 -1
  39. package/lib/components/Lexical/index.js.map +2 -2
  40. package/lib/components/Lexical/nodes/CloseIcon.d.ts +71 -0
  41. package/lib/components/Lexical/nodes/CloseIcon.js +149 -0
  42. package/lib/components/Lexical/nodes/CloseIcon.js.map +7 -0
  43. package/lib/components/Lexical/nodes/DivNode.d.ts +20 -0
  44. package/lib/components/Lexical/nodes/DivNode.js +1 -1
  45. package/lib/components/Lexical/nodes/DivNode.js.map +2 -2
  46. package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +23 -1
  47. package/lib/components/Lexical/nodes/ExtendTextNode.js +9 -1
  48. package/lib/components/Lexical/nodes/ExtendTextNode.js.map +2 -2
  49. package/lib/components/Lexical/nodes/SelectNode.d.ts +39 -9
  50. package/lib/components/Lexical/nodes/SelectNode.js +2 -2
  51. package/lib/components/Lexical/nodes/SelectNode.js.map +2 -2
  52. package/lib/components/Lexical/nodes/base.d.ts +59 -8
  53. package/lib/components/Lexical/nodes/base.js +18 -0
  54. package/lib/components/Lexical/nodes/base.js.map +2 -2
  55. package/lib/utils/index.d.ts +1 -0
  56. package/lib/utils/index.js +3 -1
  57. package/lib/utils/index.js.map +2 -2
  58. package/lib/utils/string.d.ts +7 -0
  59. package/lib/utils/string.js +37 -0
  60. package/lib/utils/string.js.map +7 -0
  61. package/package.json +1 -1
@@ -4,17 +4,27 @@ import type { BaseOptionType, DefaultOptionType } from 'antd/es/select';
4
4
  import type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';
5
5
  import type { BaseDecoratorNodeProps } from './base';
6
6
  import { BaseDecoratorNode } from './base';
7
+ /**
8
+ * - EN: Props for SelectNode, extending antd Select props plus behavior flags.
9
+ * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。
10
+ */
7
11
  export interface SelectNodeProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends SelectProps<ValueType, OptionType>, BaseDecoratorNodeProps {
8
12
  /**
9
- * 在获取editortextContent时,是否将选项的label作为文本内容插入到编辑器中,默认 `value`
10
- *
11
- * - `label` - 将选项的label作为文本内容
12
- * - `value` - 将选项的value作为文本内容
13
+ * - EN: When reading editor textContent, whether to use option label or value. Default `value`.
14
+ * - CN: 在获取 editor 的 textContent 时,使用选项的 label 还是 value。默认 `value`。
15
+ * - label: use option label as text
16
+ * - value: use option value as text
13
17
  */
14
18
  textContentMode?: 'label' | 'value';
15
- /** 是否在`textContext`两边添加一个空格,默认`true` */
19
+ /**
20
+ * - EN: Add a space around textContent. Default `true`.
21
+ * - CN: 是否在 textContent 两边添加一个空格,默认 `true`。
22
+ */
16
23
  spaceAround?: boolean;
17
- /** 容器样式 */
24
+ /**
25
+ * - EN: Container DOM style.
26
+ * - CN: 容器样式。
27
+ */
18
28
  containerStyle?: CSSProperties;
19
29
  }
20
30
  export declare class SelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {
@@ -33,12 +43,32 @@ export declare class SelectNode<ValueType = any, OptionType extends BaseOptionTy
33
43
  getTextContent(): string;
34
44
  getValue(): ValueType | undefined;
35
45
  setValue(value: ValueType | undefined): void;
36
- getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): any;
37
- setProps(props: SelectNodeProps<ValueType, OptionType>): void;
46
+ getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): SelectNodeProps<ValueType, OptionType>[typeof propName];
47
+ setProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void;
38
48
  }
49
+ /**
50
+ * - EN: Factory to create a SelectNode.
51
+ * - CN: 创建 SelectNode 的工厂函数。
52
+ *
53
+ * @param props Props for the Select node | Select 节点的属性
54
+ */
39
55
  export declare function $createSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
56
+ /**
57
+ * - EN: Type guard to check whether a node is SelectNode.
58
+ * - CN: 判断节点是否为 SelectNode 的类型守卫。
59
+ *
60
+ * @param node Node to test | 要检测的节点
61
+ */
40
62
  export declare function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any>;
63
+ /**
64
+ * - EN: Insert a SelectNode at the current cursor position.
65
+ * - CN: 在当前光标位置插入一个 SelectNode。
66
+ *
67
+ * @param editor LexicalEditor instance | LexicalEditor 实例
68
+ * @param props Props for the Select node | Select 节点的属性
69
+ */
41
70
  export declare function $insertSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void;
42
- export type SerializedSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> = Spread<{
71
+ type SerializedSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> = Spread<{
43
72
  props?: SelectNodeProps<ValueType, OptionType>;
44
73
  }, SerializedLexicalNode>;
74
+ export {};
@@ -91,7 +91,6 @@ var SelectNode = class extends import_base.BaseDecoratorNode {
91
91
  const writable = this.getWritable();
92
92
  writable.__value = value;
93
93
  }
94
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
94
  getPropValue(propName) {
96
95
  var _a;
97
96
  return (_a = this.__props) == null ? void 0 : _a[propName];
@@ -107,7 +106,8 @@ var SelectNode = class extends import_base.BaseDecoratorNode {
107
106
  function SelectComponent({
108
107
  node
109
108
  }) {
110
- const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};
109
+ const underlyingProps = node.getUnderlyingProps(node.__props);
110
+ const { textContentMode, spaceAround, containerStyle, ...selectProps } = underlyingProps;
111
111
  const [editor] = (0, import_LexicalComposerContext.useLexicalComposerContext)();
112
112
  const handleChange = (0, import_react.useCallback)(
113
113
  (value, options) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/Lexical/nodes/SelectNode.tsx"],
4
- "sourcesContent": ["import { type CSSProperties, type ReactNode, useCallback } from 'react';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { Select } from 'antd';\nimport type { SelectProps } from 'antd';\nimport type { BaseOptionType, DefaultOptionType } from 'antd/es/select';\nimport type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { insertNodeAtCursor, updateDomStyle } from '../helpers';\nimport type { BaseDecoratorNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\nexport interface SelectNodeProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends SelectProps<ValueType, OptionType>,\n BaseDecoratorNodeProps {\n /**\n * 在获取editortextContent时,是否将选项的label作为文本内容插入到编辑器中,默认 `value`\n *\n * - `label` - 将选项的label作为文本内容\n * - `value` - 将选项的value作为文本内容\n */\n textContentMode?: 'label' | 'value';\n /** 是否在`textContext`两边添加一个空格,默认`true` */\n spaceAround?: boolean;\n /** 容器样式 */\n containerStyle?: CSSProperties;\n}\n\nexport class SelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {\n __value: ValueType | undefined;\n\n constructor(props?: SelectNodeProps<ValueType, OptionType> & { key?: string }) {\n super(props);\n this.__value = props?.defaultValue ?? undefined;\n }\n static getType(): string {\n return 'antd.Select';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n node: SelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>({ ...node.__props, key: node.getKey() });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n serializedNode: SerializedSelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return $createSelectNode(serializedNode.props);\n }\n\n exportJSON(): SerializedSelectNode<ValueType, OptionType> {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n updateDomStyle(span, this.__props?.containerStyle);\n return span;\n }\n\n updateDOM(): false {\n return false;\n }\n\n decorate(): ReactNode {\n return <SelectComponent node={this} />;\n }\n\n isInline(): boolean {\n return true;\n }\n\n getTextContent(): string {\n let content: string;\n const valueContent = this.__value ? String(this.__value) : '';\n if (this.__props?.textContentMode === 'label') {\n const option = this.__props?.options?.find((opt) => opt.value === this.__value);\n content = option?.label ? String(option.label) : valueContent;\n } else {\n content = valueContent;\n }\n if (this.__props?.spaceAround !== false) {\n return ` ${content} `;\n }\n return content;\n }\n\n getValue(): ValueType | undefined {\n return this.__value;\n }\n\n setValue(value: ValueType | undefined): void {\n const writable = this.getWritable();\n writable.__value = value;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): any {\n return this.__props?.[propName];\n }\n\n setProps(props: SelectNodeProps<ValueType, OptionType>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n };\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction SelectComponent<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>({\n node,\n}: SelectComponentProps<ValueType, OptionType>): ReactNode {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};\n /* eslint-enable @typescript-eslint/no-unused-vars */\n const [editor] = useLexicalComposerContext();\n\n const handleChange = useCallback<NonNullable<SelectNodeProps<ValueType, OptionType>['onChange']>>(\n (value, options) => {\n editor.update(() => {\n node.setValue(value);\n node.__props?.onChange?.(value, options);\n });\n },\n [editor, node]\n );\n\n const handleClear = useCallback(() => {\n editor.update(() => {\n node.setValue(undefined);\n node.__props?.onClear?.();\n });\n }, [editor, node]);\n\n return <Select {...selectProps} value={node.getValue()} onChange={handleChange} onClear={handleClear} />;\n}\n\nexport function $createSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>(props);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any> {\n return node instanceof SelectNode;\n}\n\nexport function $insertSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void {\n editor.update(() => {\n const selectNode = $createSelectNode<ValueType, OptionType>({\n ...props,\n containerStyle: {\n paddingLeft: '8px',\n paddingRight: '8px',\n ...props.containerStyle,\n },\n });\n insertNodeAtCursor(editor, selectNode);\n });\n}\n\ninterface SelectComponentProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> {\n node: SelectNode<ValueType, OptionType>;\n}\nexport type SerializedSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> = Spread<\n {\n props?: SelectNodeProps<ValueType, OptionType>;\n },\n Serialized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BAId,OAAmF;AACnF,SAAO,IAAI,WAAkC,KAAK;AACpD;AAGO,SAAS,cAAc,MAAoE;AAChG,SAAO,gBAAgB;AACzB;AAEO,SAAS,kBAId,QAAuB,OAAqD;AAC5E,SAAO,OAAO,MAAM;AAClB,UAAM,aAAa,kBAAyC;AAAA,MAC1D,GAAG;AAAA,MACH,gBAAgB;AAAA,QACd,aAAa;AAAA,QACb,cAAc;AAAA,QACd,GAAG,MAAM;AAAA,MACX;AAAA,IACF,CAAC;AACD,2CAAmB,QAAQ,UAAU;AAAA,EACvC,CAAC;AACH;",
4
+ "sourcesContent": ["import { type CSSProperties, type ReactNode, useCallback } from 'react';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { Select } from 'antd';\nimport type { SelectProps } from 'antd';\nimport type { BaseOptionType, DefaultOptionType } from 'antd/es/select';\nimport type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { insertNodeAtCursor, updateDomStyle } from '../helpers';\nimport type { BaseDecoratorNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\n/**\n * - EN: Props for SelectNode, extending antd Select props plus behavior flags.\n * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。\n */\nexport interface SelectNodeProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends SelectProps<ValueType, OptionType>,\n BaseDecoratorNodeProps {\n /**\n * - EN: When reading editor textContent, whether to use option label or value. Default `value`.\n * - CN: 在获取 editor 的 textContent 时,使用选项的 label 还是 value。默认 `value`。\n * - label: use option label as text\n * - value: use option value as text\n */\n textContentMode?: 'label' | 'value';\n /**\n * - EN: Add a space around textContent. Default `true`.\n * - CN: 是否在 textContent 两边添加一个空格,默认 `true`。\n */\n spaceAround?: boolean;\n /**\n * - EN: Container DOM style.\n * - CN: 容器样式。\n */\n containerStyle?: CSSProperties;\n}\n\nexport class SelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {\n __value: ValueType | undefined;\n\n constructor(props?: SelectNodeProps<ValueType, OptionType> & { key?: string }) {\n super(props);\n this.__value = props?.defaultValue ?? undefined;\n }\n static getType(): string {\n return 'antd.Select';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n node: SelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>({ ...node.__props, key: node.getKey() });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n serializedNode: SerializedSelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return $createSelectNode(serializedNode.props);\n }\n\n exportJSON(): SerializedSelectNode<ValueType, OptionType> {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n updateDomStyle(span, this.__props?.containerStyle);\n return span;\n }\n\n updateDOM(): false {\n return false;\n }\n\n decorate(): ReactNode {\n return <SelectComponent node={this} />;\n }\n\n isInline(): boolean {\n return true;\n }\n\n getTextContent(): string {\n let content: string;\n const valueContent = this.__value ? String(this.__value) : '';\n if (this.__props?.textContentMode === 'label') {\n const option = this.__props?.options?.find((opt) => opt.value === this.__value);\n content = option?.label ? String(option.label) : valueContent;\n } else {\n content = valueContent;\n }\n if (this.__props?.spaceAround !== false) {\n return ` ${content} `;\n }\n return content;\n }\n\n getValue(): ValueType | undefined {\n return this.__value;\n }\n\n setValue(value: ValueType | undefined): void {\n const writable = this.getWritable();\n writable.__value = value;\n }\n\n getPropValue(\n propName: keyof SelectNodeProps<ValueType, OptionType>\n ): SelectNodeProps<ValueType, OptionType>[typeof propName] {\n return this.__props?.[propName];\n }\n\n setProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n };\n }\n}\n\n/**\n * - EN: React decorator component rendered for SelectNode.\n * - CN: SelectNode 对应的 React 装饰组件。\n *\n * @param node The bound SelectNode instance | 关联的 SelectNode 实例\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction SelectComponent<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>({\n node,\n}: SelectComponentProps<ValueType, OptionType>): ReactNode {\n const underlyingProps = node.getUnderlyingProps(node.__props);\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { textContentMode, spaceAround, containerStyle, ...selectProps } = underlyingProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n const [editor] = useLexicalComposerContext();\n\n const handleChange = useCallback<NonNullable<SelectNodeProps<ValueType, OptionType>['onChange']>>(\n (value, options) => {\n editor.update(() => {\n node.setValue(value);\n node.__props?.onChange?.(value, options);\n });\n },\n [editor, node]\n );\n\n const handleClear = useCallback(() => {\n editor.update(() => {\n node.setValue(undefined);\n node.__props?.onClear?.();\n });\n }, [editor, node]);\n\n return <Select {...selectProps} value={node.getValue()} onChange={handleChange} onClear={handleClear} />;\n}\n\n/**\n * - EN: Factory to create a SelectNode.\n * - CN: 创建 SelectNode 的工厂函数。\n *\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $createSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is SelectNode.\n * - CN: 判断节点是否为 SelectNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any> {\n return node instanceof SelectNode;\n}\n\n/**\n * - EN: Insert a SelectNode at the current cursor position.\n * - CN: 在当前光标位置插入一个 SelectNode。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $insertSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void {\n editor.update(() => {\n const selectNode = $createSelectNode<ValueType, OptionType>({\n ...props,\n containerStyle: {\n paddingLeft: '8px',\n paddingRight: '8px',\n ...props.containerStyle,\n },\n });\n insertNodeAtCursor(editor, selectNode);\n });\n}\n\n/**\n * - EN: Props passed to the Select decorator component.\n * - CN: 传递给 Select 装饰组件的属性。\n */\ninterface SelectComponentProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> {\n node: SelectNode<ValueType, OptionType>;\n}\ntype SerializedSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> = Spread<\n {\n props?: SelectNodeProps<ValueType, OptionType>;\n },\n SerializedLexicalNode\n>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAChE,oCAA0C;AAC1C,kBAAuB;AAIvB,qBAAmD;AAEnD,kBAAkC;AA+B3B,IAAM,aAAN,cAIG,8BAAqE;AAAA,EAG7E,YAAY,OAAmE;AAC7E,UAAM,KAAK;AACX,SAAK,WAAU,+BAAO,iBAAgB;AAAA,EACxC;AAAA,EACA,OAAO,UAAkB;AACvB,WAAO;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B,QAAQ,UAAU;AAAA,EACvC,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,25 +1,50 @@
1
1
  import type { LexicalNode } from 'lexical';
2
2
  import { DecoratorNode, ElementNode } from 'lexical';
3
+ /**
4
+ * - EN: Common behavior flags for custom nodes.
5
+ * - CN: 自定义节点的通用行为标记。
6
+ */
3
7
  export interface BaseNodeProps {
4
- /** 是否可被删除,默认 `true` */
8
+ /**
9
+ * - EN: Whether the node can be removed. Default `true`.
10
+ * - CN: 是否可被删除,默认 `true`。
11
+ */
5
12
  canBeRemoved?: boolean;
6
- /** 是否可被替换,默认 `true` */
13
+ /**
14
+ * - EN: Whether the node can be replaced. Default `true`.
15
+ * - CN: 是否可被替换,默认 `true`。
16
+ */
7
17
  canBeReplaced?: boolean;
8
18
  }
19
+ /**
20
+ * - EN: Extra behavior flags for element nodes.
21
+ * - CN: 元素节点的附加行为标记。
22
+ */
9
23
  export interface BaseElementProps extends BaseNodeProps {
10
24
  /**
11
- * 是否允许节点为空,默认 `false`
12
- *
13
- * - `true` - 允许节点为空
14
- * - `false` - 不允许节点为空,当最后一个子节点被删除后,节点也会被删除
25
+ * - EN: Whether an element is allowed to be empty. Default `false`.
26
+ * - CN: 是否允许节点为空,默认 `false`。
15
27
  */
16
28
  canBeEmpty?: boolean;
17
- /** 是否允许在节点内的起始位置插入文本,默认 `true` */
29
+ /**
30
+ * - EN: Allow inserting text at the start of the element. Default `true`.
31
+ * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。
32
+ */
18
33
  canInsertTextBefore?: boolean;
19
- /** 是否允许在节点内的结束位置插入文本,默认 `true` */
34
+ /**
35
+ * - EN: Allow inserting text at the end of the element. Default `true`.
36
+ * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。
37
+ */
20
38
  canInsertTextAfter?: boolean;
21
39
  }
22
40
  export type BaseDecoratorNodeProps = BaseNodeProps;
41
+ /**
42
+ * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.
43
+ * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。
44
+ *
45
+ * @param props Node behavior flags | 节点行为标记
46
+ * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法
47
+ */
23
48
  export declare class BaseNodeHelper<P extends BaseNodeProps> {
24
49
  __props: (P & BaseNodeProps) | undefined;
25
50
  __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;
@@ -28,8 +53,18 @@ export declare class BaseNodeHelper<P extends BaseNodeProps> {
28
53
  remove: (preserveEmptyParent?: boolean) => void;
29
54
  replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean) => N;
30
55
  };
56
+ /**
57
+ * - EN: Strip helper-only flags from props for DOM usage.
58
+ * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。
59
+ *
60
+ * @param props Props including helper flags | 含帮助标记的属性
61
+ */
31
62
  getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps>;
32
63
  }
64
+ /**
65
+ * - EN: Base element node with behavior flags.
66
+ * - CN: 带行为标记的基础元素节点。
67
+ */
33
68
  export declare class BaseElementNode<P extends BaseElementProps> extends ElementNode {
34
69
  __props: P | undefined;
35
70
  __base: BaseNodeHelper<P>;
@@ -39,13 +74,29 @@ export declare class BaseElementNode<P extends BaseElementProps> extends Element
39
74
  canBeEmpty(): boolean;
40
75
  canInsertTextBefore(): boolean;
41
76
  canInsertTextAfter(): boolean;
77
+ /**
78
+ * - EN: Strip element-specific flags and return DOM props.
79
+ * - CN: 去除元素特有的标记并返回 DOM 属性。
80
+ *
81
+ * @param props Element props including flags | 含标记的元素属性
82
+ */
42
83
  getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps>;
43
84
  }
85
+ /**
86
+ * - EN: Base decorator node with behavior flags.
87
+ * - CN: 带行为标记的基础装饰器节点。
88
+ */
44
89
  export declare class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {
45
90
  __props: P | undefined;
46
91
  __base: BaseNodeHelper<P>;
47
92
  constructor(props?: P & {
48
93
  key?: string;
49
94
  });
95
+ /**
96
+ * - EN: Strip decorator-specific flags and return DOM props.
97
+ * - CN: 去除装饰器特有的标记并返回 DOM 属性。
98
+ *
99
+ * @param props Decorator props including flags | 含标记的装饰器属性
100
+ */
50
101
  getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps>;
51
102
  }
@@ -46,6 +46,12 @@ var BaseNodeHelper = class {
46
46
  this.__props = props;
47
47
  this.__superMethods = superMethods;
48
48
  }
49
+ /**
50
+ * - EN: Strip helper-only flags from props for DOM usage.
51
+ * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。
52
+ *
53
+ * @param props Props including helper flags | 含帮助标记的属性
54
+ */
49
55
  getUnderlyingProps(props) {
50
56
  const { canBeRemoved, canBeReplaced, ...restProps } = props;
51
57
  return restProps;
@@ -79,6 +85,12 @@ var BaseElementNode = class extends import_lexical.ElementNode {
79
85
  var _a;
80
86
  return ((_a = this.__props) == null ? void 0 : _a.canInsertTextAfter) ?? true;
81
87
  }
88
+ /**
89
+ * - EN: Strip element-specific flags and return DOM props.
90
+ * - CN: 去除元素特有的标记并返回 DOM 属性。
91
+ *
92
+ * @param props Element props including flags | 含标记的元素属性
93
+ */
82
94
  getUnderlyingProps(props) {
83
95
  const baseProps = this.__base.getUnderlyingProps(props ?? {});
84
96
  const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;
@@ -101,6 +113,12 @@ var BaseDecoratorNode = class extends import_lexical.DecoratorNode {
101
113
  }
102
114
  });
103
115
  }
116
+ /**
117
+ * - EN: Strip decorator-specific flags and return DOM props.
118
+ * - CN: 去除装饰器特有的标记并返回 DOM 属性。
119
+ *
120
+ * @param props Decorator props including flags | 含标记的装饰器属性
121
+ */
104
122
  getUnderlyingProps(props) {
105
123
  const baseProps = this.__base.getUnderlyingProps(props ?? {});
106
124
  const { ...restProps } = baseProps;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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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n/**\n * - EN: Common behavior flags for custom nodes.\n * - CN: 自定义节点的通用行为标记。\n */\nexport interface BaseNodeProps {\n /**\n * - EN: Whether the node can be removed. Default `true`.\n * - CN: 是否可被删除,默认 `true`。\n */\n canBeRemoved?: boolean;\n /**\n * - EN: Whether the node can be replaced. Default `true`.\n * - CN: 是否可被替换,默认 `true`。\n */\n canBeReplaced?: boolean;\n}\n/**\n * - EN: Extra behavior flags for element nodes.\n * - CN: 元素节点的附加行为标记。\n */\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * - EN: Whether an element is allowed to be empty. Default `false`.\n * - CN: 是否允许节点为空,默认 `false`。\n */\n canBeEmpty?: boolean;\n /**\n * - EN: Allow inserting text at the start of the element. Default `true`.\n * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。\n */\n canInsertTextBefore?: boolean;\n /**\n * - EN: Allow inserting text at the end of the element. Default `true`.\n * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。\n */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\n\n/**\n * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.\n * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。\n *\n * @param props Node behavior flags | 节点行为标记\n * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法\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 /**\n * - EN: Strip helper-only flags from props for DOM usage.\n * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。\n *\n * @param props Props including helper flags | 含帮助标记的属性\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\n/**\n * - EN: Base element node with behavior flags.\n * - CN: 带行为标记的基础元素节点。\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 /**\n * - EN: Strip element-specific flags and return DOM props.\n * - CN: 去除元素特有的标记并返回 DOM 属性。\n *\n * @param props Element props including flags | 含标记的元素属性\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\n/**\n * - EN: Base decorator node with behavior flags.\n * - CN: 带行为标记的基础装饰器节点。\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 /**\n * - EN: Strip decorator-specific flags and return DOM props.\n * - CN: 去除装饰器特有的标记并返回 DOM 属性。\n *\n * @param props Decorator props including flags | 含标记的装饰器属性\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;AAiDpC,IAAM,iBAAN,MAA8C;AAAA,EAInD,YAAY,OAAsB,cAAuD;AAKzF,iBAAQ;AAAA,MACN,QAAQ,CAAC,wBAAwC;AA5DrD;AA6DM,cAAI,UAAK,YAAL,mBAAc,kBAAiB,OAAO;AACxC;AAAA,QACF;AACA,aAAK,eAAe,OAAO,mBAAmB;AAAA,MAChD;AAAA,MAEA,SAAS,CAAwB,aAAgB,oBAAiC;AAnEtF;AAoEM,cAAI,UAAK,YAAL,mBAAc,mBAAkB,OAAO;AACzC,iBAAO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I;AAE9E,WAAO;AAAA,EACT;AACF;AAMO,IAAM,oBAAN,cAAqE,6BAAiB;AAAA,EAI3F,YAAY,OAA8B;AACxC,UAAM,EAAE,KAAK,GAAG,UAAU,IAAI,SAAS,CAAC;AACxC,UAAM,GAAG;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,OAA6D;AAC9E,UAAM,YAAY,KAAK,OAAO,mBAAmB,SAAU,CAAC,CAAO;AAEnE,UAAM,EAAE,GAAG,UAAU,IAAI;AAEzB,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["key"]
7
7
  }
@@ -1,2 +1,3 @@
1
1
  export * from './color';
2
2
  export * from './math';
3
+ export * from './string';
@@ -18,9 +18,11 @@ var utils_exports = {};
18
18
  module.exports = __toCommonJS(utils_exports);
19
19
  __reExport(utils_exports, require("./color"), module.exports);
20
20
  __reExport(utils_exports, require("./math"), module.exports);
21
+ __reExport(utils_exports, require("./string"), module.exports);
21
22
  // Annotate the CommonJS export names for ESM import in node:
22
23
  0 && (module.exports = {
23
24
  ...require("./color"),
24
- ...require("./math")
25
+ ...require("./math"),
26
+ ...require("./string")
25
27
  });
26
28
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/index.ts"],
4
- "sourcesContent": ["export * from './color';\nexport * from './math';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,oBAAd;AACA,0BAAc,mBADd;",
4
+ "sourcesContent": ["export * from './color';\nexport * from './math';\nexport * from './string';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,oBAAd;AACA,0BAAc,mBADd;AAEA,0BAAc,qBAFd;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * - EN: Generate a random string of alphanumeric characters.
3
+ * - CN: 生成一个随机的字母数字字符串。
4
+ *
5
+ * @param length Length of the random string | 随机字符串的长度
6
+ */
7
+ export declare function randomChars(length: number): string;
@@ -0,0 +1,37 @@
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/utils/string.ts
20
+ var string_exports = {};
21
+ __export(string_exports, {
22
+ randomChars: () => randomChars
23
+ });
24
+ module.exports = __toCommonJS(string_exports);
25
+ function randomChars(length) {
26
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
27
+ let result = "";
28
+ for (let i = 0; i < length; i++) {
29
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
30
+ }
31
+ return result;
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ randomChars
36
+ });
37
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/string.ts"],
4
+ "sourcesContent": ["/**\n * - EN: Generate a random string of alphanumeric characters.\n * - CN: 生成一个随机的字母数字字符串。\n *\n * @param length Length of the random string | 随机字符串的长度\n */\nexport function randomChars(length: number): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,YAAY,QAAwB;AAClD,QAAM,QAAQ;AACd,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,cAAU,MAAM,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,MAAM,MAAM,CAAC;AAAA,EACjE;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",