@formily-design/formily-setters 1.0.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 (108) hide show
  1. package/.umirc.js +44 -0
  2. package/LICENSE.md +20 -0
  3. package/README.md +7 -0
  4. package/copy.ts +6 -0
  5. package/esm/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
  6. package/esm/components/DataSourceSetter/DataSettingPanel.js +66 -0
  7. package/esm/components/DataSourceSetter/Header.d.ts +7 -0
  8. package/esm/components/DataSourceSetter/Header.js +10 -0
  9. package/esm/components/DataSourceSetter/Title.d.ts +7 -0
  10. package/esm/components/DataSourceSetter/Title.js +50 -0
  11. package/esm/components/DataSourceSetter/TreePanel.d.ts +12 -0
  12. package/esm/components/DataSourceSetter/TreePanel.js +98 -0
  13. package/esm/components/DataSourceSetter/index.d.ts +18 -0
  14. package/esm/components/DataSourceSetter/index.js +34 -0
  15. package/esm/components/DataSourceSetter/shared.d.ts +9 -0
  16. package/esm/components/DataSourceSetter/shared.js +47 -0
  17. package/esm/components/DataSourceSetter/styles.less +80 -0
  18. package/esm/components/DataSourceSetter/types.d.ts +18 -0
  19. package/esm/components/DataSourceSetter/types.js +1 -0
  20. package/esm/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
  21. package/esm/components/ReactionsSetter/FieldPropertySetter.js +83 -0
  22. package/esm/components/ReactionsSetter/PathSelector.d.ts +10 -0
  23. package/esm/components/ReactionsSetter/PathSelector.js +107 -0
  24. package/esm/components/ReactionsSetter/declarations.d.ts +5 -0
  25. package/esm/components/ReactionsSetter/declarations.js +51 -0
  26. package/esm/components/ReactionsSetter/helpers.d.ts +10 -0
  27. package/esm/components/ReactionsSetter/helpers.js +384 -0
  28. package/esm/components/ReactionsSetter/index.d.ts +8 -0
  29. package/esm/components/ReactionsSetter/index.js +282 -0
  30. package/esm/components/ReactionsSetter/properties.d.ts +11 -0
  31. package/esm/components/ReactionsSetter/properties.js +41 -0
  32. package/esm/components/ReactionsSetter/styles.less +103 -0
  33. package/esm/components/ReactionsSetter/types.d.ts +13 -0
  34. package/esm/components/ReactionsSetter/types.js +1 -0
  35. package/esm/components/RemoteDataSourceSetter/RemoteDataSourcePanel.d.ts +8 -0
  36. package/esm/components/RemoteDataSourceSetter/RemoteDataSourcePanel.js +103 -0
  37. package/esm/components/RemoteDataSourceSetter/index.d.ts +17 -0
  38. package/esm/components/RemoteDataSourceSetter/index.js +25 -0
  39. package/esm/components/RemoteDataSourceSetter/styles.less +33 -0
  40. package/esm/components/RemoteDataSourceSetter/types.d.ts +8 -0
  41. package/esm/components/RemoteDataSourceSetter/types.js +1 -0
  42. package/esm/components/ValidatorSetter/index.d.ts +6 -0
  43. package/esm/components/ValidatorSetter/index.js +140 -0
  44. package/esm/components/index.d.ts +4 -0
  45. package/esm/components/index.js +4 -0
  46. package/esm/index.d.ts +2 -0
  47. package/esm/index.js +2 -0
  48. package/esm/locales/en-US.d.ts +110 -0
  49. package/esm/locales/en-US.js +115 -0
  50. package/esm/locales/index.d.ts +1 -0
  51. package/esm/locales/index.js +5 -0
  52. package/esm/locales/ko-KR.d.ts +110 -0
  53. package/esm/locales/ko-KR.js +115 -0
  54. package/esm/locales/zh-CN.d.ts +110 -0
  55. package/esm/locales/zh-CN.js +115 -0
  56. package/lib/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
  57. package/lib/components/DataSourceSetter/DataSettingPanel.js +102 -0
  58. package/lib/components/DataSourceSetter/Header.d.ts +7 -0
  59. package/lib/components/DataSourceSetter/Header.js +16 -0
  60. package/lib/components/DataSourceSetter/Title.d.ts +7 -0
  61. package/lib/components/DataSourceSetter/Title.js +56 -0
  62. package/lib/components/DataSourceSetter/TreePanel.d.ts +12 -0
  63. package/lib/components/DataSourceSetter/TreePanel.js +134 -0
  64. package/lib/components/DataSourceSetter/index.d.ts +18 -0
  65. package/lib/components/DataSourceSetter/index.js +73 -0
  66. package/lib/components/DataSourceSetter/shared.d.ts +9 -0
  67. package/lib/components/DataSourceSetter/shared.js +53 -0
  68. package/lib/components/DataSourceSetter/styles.less +80 -0
  69. package/lib/components/DataSourceSetter/types.d.ts +18 -0
  70. package/lib/components/DataSourceSetter/types.js +2 -0
  71. package/lib/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
  72. package/lib/components/ReactionsSetter/FieldPropertySetter.js +120 -0
  73. package/lib/components/ReactionsSetter/PathSelector.d.ts +10 -0
  74. package/lib/components/ReactionsSetter/PathSelector.js +114 -0
  75. package/lib/components/ReactionsSetter/declarations.d.ts +5 -0
  76. package/lib/components/ReactionsSetter/declarations.js +55 -0
  77. package/lib/components/ReactionsSetter/helpers.d.ts +10 -0
  78. package/lib/components/ReactionsSetter/helpers.js +387 -0
  79. package/lib/components/ReactionsSetter/index.d.ts +8 -0
  80. package/lib/components/ReactionsSetter/index.js +319 -0
  81. package/lib/components/ReactionsSetter/properties.d.ts +11 -0
  82. package/lib/components/ReactionsSetter/properties.js +44 -0
  83. package/lib/components/ReactionsSetter/styles.less +103 -0
  84. package/lib/components/ReactionsSetter/types.d.ts +13 -0
  85. package/lib/components/ReactionsSetter/types.js +2 -0
  86. package/lib/components/RemoteDataSourceSetter/RemoteDataSourcePanel.d.ts +8 -0
  87. package/lib/components/RemoteDataSourceSetter/RemoteDataSourcePanel.js +140 -0
  88. package/lib/components/RemoteDataSourceSetter/index.d.ts +17 -0
  89. package/lib/components/RemoteDataSourceSetter/index.js +64 -0
  90. package/lib/components/RemoteDataSourceSetter/styles.less +33 -0
  91. package/lib/components/RemoteDataSourceSetter/types.d.ts +8 -0
  92. package/lib/components/RemoteDataSourceSetter/types.js +2 -0
  93. package/lib/components/ValidatorSetter/index.d.ts +6 -0
  94. package/lib/components/ValidatorSetter/index.js +146 -0
  95. package/lib/components/index.d.ts +4 -0
  96. package/lib/components/index.js +20 -0
  97. package/lib/index.d.ts +2 -0
  98. package/lib/index.js +18 -0
  99. package/lib/locales/en-US.d.ts +110 -0
  100. package/lib/locales/en-US.js +117 -0
  101. package/lib/locales/index.d.ts +1 -0
  102. package/lib/locales/index.js +10 -0
  103. package/lib/locales/ko-KR.d.ts +110 -0
  104. package/lib/locales/ko-KR.js +117 -0
  105. package/lib/locales/zh-CN.d.ts +110 -0
  106. package/lib/locales/zh-CN.js +117 -0
  107. package/package.json +53 -0
  108. package/tsconfig.build.json +10 -0
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { TreeNode } from '@formily-design/core';
3
+ import { TreeSelectProps } from 'antd';
4
+ export interface IPathSelectorProps extends Omit<TreeSelectProps<any>, 'onChange'> {
5
+ value?: string;
6
+ onChange?: (value: string, node: TreeNode) => void;
7
+ style?: React.CSSProperties;
8
+ className?: string;
9
+ }
10
+ export declare const PathSelector: React.FC<IPathSelectorProps>;
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import { useSelectedNode } from '@formily-design/react';
3
+ import { TreeSelect } from 'antd';
4
+ const transformDataSource = (node) => {
5
+ const currentNode = node;
6
+ const dots = (count) => {
7
+ let dots = '';
8
+ for (let i = 0; i < count; i++) {
9
+ dots += '.';
10
+ }
11
+ return dots;
12
+ };
13
+ const targetPath = (parentNode, targetNode) => {
14
+ const path = [];
15
+ const transform = (node) => {
16
+ if (node && node !== parentNode) {
17
+ path.push(node.props.name || node.id);
18
+ }
19
+ else {
20
+ transform(node.parent);
21
+ }
22
+ };
23
+ transform(targetNode);
24
+ return path.reverse().join('.');
25
+ };
26
+ const hasNoVoidChildren = (node) => {
27
+ var _a;
28
+ return (_a = node.children) === null || _a === void 0 ? void 0 : _a.some((node) => {
29
+ if (node.props.type !== 'void' && node !== currentNode)
30
+ return true;
31
+ return hasNoVoidChildren(node);
32
+ });
33
+ };
34
+ const findRoot = (node) => {
35
+ var _a;
36
+ if (!(node === null || node === void 0 ? void 0 : node.parent))
37
+ return node;
38
+ if (((_a = node === null || node === void 0 ? void 0 : node.parent) === null || _a === void 0 ? void 0 : _a.componentName) !== node.componentName)
39
+ return node.parent;
40
+ return findRoot(node.parent);
41
+ };
42
+ const findArrayParent = (node) => {
43
+ if (!(node === null || node === void 0 ? void 0 : node.parent))
44
+ return;
45
+ if (node.parent.props.type === 'array')
46
+ return node.parent;
47
+ if (node.parent === root)
48
+ return;
49
+ return findArrayParent(node.parent);
50
+ };
51
+ const transformRelativePath = (arrayNode, targetNode) => {
52
+ if (targetNode.depth === currentNode.depth)
53
+ return `.${targetNode.props.name || targetNode.id}`;
54
+ return `${dots(currentNode.depth - arrayNode.depth)}[].${targetPath(arrayNode, targetNode)}`;
55
+ };
56
+ const transformChildren = (children, path = []) => {
57
+ return children.reduce((buf, node) => {
58
+ var _a;
59
+ if (node === currentNode)
60
+ return buf;
61
+ if (node.props.type === 'array' && !node.contains(currentNode))
62
+ return buf;
63
+ if (node.props.type === 'void' && !hasNoVoidChildren(node))
64
+ return buf;
65
+ const currentPath = path.concat(node.props.name || node.id);
66
+ const arrayNode = findArrayParent(node);
67
+ const label = node.props.title ||
68
+ ((_a = node.props['x-component-props']) === null || _a === void 0 ? void 0 : _a.title) ||
69
+ node.props.name ||
70
+ node.designerProps.title;
71
+ const value = arrayNode
72
+ ? transformRelativePath(arrayNode, node)
73
+ : currentPath.join('.');
74
+ return buf.concat({
75
+ label,
76
+ value,
77
+ node,
78
+ children: transformChildren(node.children, currentPath),
79
+ });
80
+ }, []);
81
+ };
82
+ const root = findRoot(node);
83
+ if (root) {
84
+ return transformChildren(root.children);
85
+ }
86
+ return [];
87
+ };
88
+ export const PathSelector = (props) => {
89
+ const baseNode = useSelectedNode();
90
+ const dataSource = transformDataSource(baseNode);
91
+ const findNode = (dataSource, value) => {
92
+ var _a;
93
+ for (let i = 0; i < dataSource.length; i++) {
94
+ const item = dataSource[i];
95
+ if (item.value === value)
96
+ return item.node;
97
+ if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
98
+ const fondedChild = findNode(item.children, value);
99
+ if (fondedChild)
100
+ return fondedChild;
101
+ }
102
+ }
103
+ };
104
+ return (React.createElement(TreeSelect, { ...props, onChange: (value) => {
105
+ props.onChange(value, findNode(dataSource, value));
106
+ }, treeDefaultExpandAll: true, treeData: dataSource }));
107
+ };
@@ -0,0 +1,5 @@
1
+ export interface IDependency {
2
+ name: string;
3
+ path: string;
4
+ }
5
+ export declare const initDeclaration: () => Promise<void>;
@@ -0,0 +1,51 @@
1
+ import { MonacoInput, getNpmCDNRegistry, } from '@formily-design/react-settings-form';
2
+ const loadDependencies = async (deps) => {
3
+ return Promise.all(deps.map(async ({ name, path }) => ({
4
+ name,
5
+ path,
6
+ library: await fetch(`${getNpmCDNRegistry()}/${name}/${path}`).then((res) => res.text()),
7
+ })));
8
+ };
9
+ export const initDeclaration = async () => {
10
+ return MonacoInput.loader.init().then(async (monaco) => {
11
+ const deps = await loadDependencies([
12
+ { name: '@formily/core', path: 'dist/formily.core.all.d.ts' },
13
+ ]);
14
+ deps === null || deps === void 0 ? void 0 : deps.forEach(({ name, library }) => {
15
+ monaco.languages.typescript.typescriptDefaults.addExtraLib(`declare module '${name}'{ ${library} }`, `file:///node_modules/${name}/index.d.ts`);
16
+ });
17
+ monaco.languages.typescript.typescriptDefaults.addExtraLib(`
18
+ import { Form, Field } from '@formily/core'
19
+ declare global {
20
+ /*
21
+ * Form Model
22
+ **/
23
+ declare var $form: Form
24
+ /*
25
+ * Form Values
26
+ **/
27
+ declare var $values: any
28
+ /*
29
+ * Field Model
30
+ **/
31
+ declare var $self: Field
32
+ /*
33
+ * create an persistent observable state object
34
+ **/
35
+ declare var $observable: <T>(target: T, deps?: any[]) => T
36
+ /*
37
+ * create a persistent data
38
+ **/
39
+ declare var $memo: <T>(callback: () => T, deps?: any[]) => T
40
+ /*
41
+ * handle side-effect logic
42
+ **/
43
+ declare var $effect: (callback: () => void | (() => void), deps?: any[]) => void
44
+ /*
45
+ * set initial component props to current field
46
+ **/
47
+ declare var $props: (props: any) => void
48
+ }
49
+ `, `file:///node_modules/formily_global.d.ts`);
50
+ });
51
+ };
@@ -0,0 +1,10 @@
1
+ export declare const GlobalHelper = "\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n";
2
+ export declare const BooleanHelper = "\n/** \n * Example 1\n * Static Boolean\n **/\n\nfalse\n\n/** \n * Example 2\n * Equal Calculation\n **/\n\n$deps.VariableName === 'TARGET_VALUE'\n\n/** \n * Example 3\n * Not Equal Calculation\n **/\n\n$deps.VariableName !== 'TARGET_VALUE'\n\n/** \n * Example 4\n * And Logic Calculation\n **/\n\n$deps.VariableName1 && $deps.VariableName2\n\n/** \n * Example 5\n * Grater Logic Calculation\n **/\n\n$deps.VariableName > 100\n\n/** \n * Example 6\n * Not Logic Calculation\n **/\n\n!$deps.VariableName\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
3
+ export declare const DisplayHelper = "\n/** \n * Example 1\n * Static Mode\n **/\n\n'none'\n\n/** \n * Example 2\n * Equal Condition Associated\n **/\n\n$deps.VariableName === 'TARGET_VALUE' ? 'visible' : 'none'\n\n/** \n * Example 3\n * Not Equal Condition Associated\n **/\n\n$deps.VariableName !== 'TARGET_VALUE' ? 'visible' : 'hidden'\n\n/** \n * Example 4\n * And Logic Condition Associated\n **/\n\n$deps.VariableName1 && $deps.VariableName2 ? 'visible' : 'none'\n\n/** \n * Example 5\n * Grater Logic Condition Associated\n **/\n\n$deps.VariableName > 100 ? 'visible' : 'hidden'\n\n/** \n * Example 6\n * Not Logic Condition Associated\n **/\n\n!$deps.VariableName ? 'visible' : 'none'\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
4
+ export declare const PatternHelper = "\n/** \n * Example 1\n * Static Mode\n **/\n\n'readPretty'\n\n/** \n * Example 2\n * Equal Condition Associated\n **/\n\n$deps.VariableName === 'TARGET_VALUE' ? 'editable' : 'disabled'\n\n/** \n * Example 3\n * Not Equal Condition Associated\n **/\n\n$deps.VariableName !== 'TARGET_VALUE' ? 'editable' : 'readOnly'\n\n/** \n * Example 4\n * And Logic Condition Associated\n **/\n\n$deps.VariableName1 && $deps.VariableName2 ? 'editable' : 'readPretty'\n\n/** \n * Example 5\n * Grater Logic Condition Associated\n **/\n\n$deps.VariableName > 100 ? 'editable' : 'readOnly'\n\n/** \n * Example 6\n * Not Logic Condition Associated\n **/\n\n!$deps.VariableName ? 'editable' : 'disabled'\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
5
+ export declare const StringHelper = "\n/** \n * Example 1\n * Static String\n **/\n\n'Normal String Text'\n\n/** \n * Example 2\n * Associated String\n **/\n\n$deps.VariableName === 'TARGET_VALUE' ? 'Associated String Text' : ''\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
6
+ export declare const AnyHelper = "\n/** \n * Example 1\n * String Type\n **/\n\n'String'\n\n/** \n * Example 2\n * String Array\n **/\n\n['StringArray']\n\n/** \n * Example 3\n * Object Array\n **/\n\n[{ key: 'ObjectArray' }]\n\n/** \n * Example 4\n * Boolean\n **/\n\ntrue\n\n/** \n * Example 5\n * RegExp\n **/\n\n/d+/\n\n/** \n * Example 1\n * Associated String Value\n **/\n\n$deps.VariableName + 'Compose String'\n\n/** \n * Example 2\n * Associated Array Value\n **/\n\n[ $deps.VariableName ]\n\n/** \n * Example 3\n * Associated Object Value\n **/\n\n{\n key : $deps.VariableName\n}\n\n/** \n * Example 4\n * Associated Boolean Value\n **/\n\n!$deps.VariableName\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
7
+ export declare const DataSourceHelper = "\n/** \n * Example 1\n * Static DataSource\n **/\n\n[\n { label : \"item1\", value: \"1\" },\n { label : \"item2\", value: \"2\" }\n]\n\n/** \n * Example 2\n * Associated DataSource\n **/\n\n[\n { label : \"item1\", value: \"1\" },\n { label : \"item2\", value: \"2\" },\n ...$deps.VariableName\n]\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
8
+ export declare const ComponentPropsHelper = "\n/** \n * Example 1\n * Static Props\n **/\n\n{\n placeholder: \"This is placeholder\"\n}\n\n/** \n * Example 2\n * Associated Props\n **/\n\n{\n placeholder: $deps.VariableName\n}\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
9
+ export declare const DecoratorPropsHelper = "\n/** \n * Example 1\n * Static Props\n **/\n\n{\n labelCol:6\n}\n\n/** \n * Example 2\n * Associated Props\n **/\n\n{\n labelCol: $deps.VariableName\n}\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
10
+ export declare const FulfillRunHelper = "\n/** \n * Example 1\n * Async Select\n **/\n\n$effect(()=>{\n $self.loading = true\n fetch('//some.domain/getSomething')\n .then(response=>response.json())\n .then(({ data })=>{\n $self.loading = false\n $self.dataSource = data\n },()=>{\n $self.loading = false\n })\n},[])\n \n\n/** \n * Example 2\n * Async Search Select\n **/\n\nconst state = $observable({\n keyword:''\n})\n\n$props({\n onSearch(keyword){\n state.keyword = keyword\n }\n})\n\n$effect(()=>{\n $self.loading = true\n fetch(`//some.domain/getSomething?q=${state.keyword}`)\n .then(response=>response.json())\n .then(({ data })=>{\n $self.loading = false\n $self.dataSource = data\n },()=>{\n $self.loading = false\n })\n},[ state.keyword ])\n\n/** \n * Example 3\n * Async Associated Select\n **/\n\nconst state = $observable({\n keyword:''\n})\n\n$props({\n onSearch(keyword){\n state.keyword = keyword\n }\n})\n\n$effect(()=>{\n $self.loading = true\n fetch(`//some.domain/getSomething?q=${state.keyword}&other=${$deps.VariableName}`)\n .then(response=>response.json())\n .then(({ data })=>{\n $self.loading = false\n $self.dataSource = data\n },()=>{\n $self.loading = false\n })\n},[ state.keyword, $deps.VariableName ])\n\n\n/** \n * You can use the built-in context variables\n * \n * 1. `$self` is the current Field Model \n * \n * 2. `$form` is the current Form Model \n * \n * 3. `$deps` is the dependencies value\n * \n * 4. `$observable` function is used to create an persistent observable state object\n *\n * 5. `$memo` function is is used to create a persistent data\n * \n * 6. `$effect` function is used to handle side-effect logic\n * \n * 7. `$props` function is used to set component props to current field\n * \n * Document Links\n * \n * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F\n **/\n\n";
@@ -0,0 +1,384 @@
1
+ export const GlobalHelper = `
2
+ /**
3
+ * You can use the built-in context variables
4
+ *
5
+ * 1. \`$self\` is the current Field Model
6
+ *
7
+ * 2. \`$form\` is the current Form Model
8
+ *
9
+ * 3. \`$deps\` is the dependencies value
10
+ *
11
+ * 4. \`$observable\` function is used to create an persistent observable state object
12
+ *
13
+ * 5. \`$memo\` function is is used to create a persistent data
14
+ *
15
+ * 6. \`$effect\` function is used to handle side-effect logic
16
+ *
17
+ * 7. \`$props\` function is used to set component props to current field
18
+ *
19
+ * Document Links
20
+ *
21
+ * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F
22
+ **/
23
+ `;
24
+ export const BooleanHelper = `
25
+ /**
26
+ * Example 1
27
+ * Static Boolean
28
+ **/
29
+
30
+ false
31
+
32
+ /**
33
+ * Example 2
34
+ * Equal Calculation
35
+ **/
36
+
37
+ $deps.VariableName === 'TARGET_VALUE'
38
+
39
+ /**
40
+ * Example 3
41
+ * Not Equal Calculation
42
+ **/
43
+
44
+ $deps.VariableName !== 'TARGET_VALUE'
45
+
46
+ /**
47
+ * Example 4
48
+ * And Logic Calculation
49
+ **/
50
+
51
+ $deps.VariableName1 && $deps.VariableName2
52
+
53
+ /**
54
+ * Example 5
55
+ * Grater Logic Calculation
56
+ **/
57
+
58
+ $deps.VariableName > 100
59
+
60
+ /**
61
+ * Example 6
62
+ * Not Logic Calculation
63
+ **/
64
+
65
+ !$deps.VariableName
66
+
67
+ ${GlobalHelper}
68
+ `;
69
+ export const DisplayHelper = `
70
+ /**
71
+ * Example 1
72
+ * Static Mode
73
+ **/
74
+
75
+ 'none'
76
+
77
+ /**
78
+ * Example 2
79
+ * Equal Condition Associated
80
+ **/
81
+
82
+ $deps.VariableName === 'TARGET_VALUE' ? 'visible' : 'none'
83
+
84
+ /**
85
+ * Example 3
86
+ * Not Equal Condition Associated
87
+ **/
88
+
89
+ $deps.VariableName !== 'TARGET_VALUE' ? 'visible' : 'hidden'
90
+
91
+ /**
92
+ * Example 4
93
+ * And Logic Condition Associated
94
+ **/
95
+
96
+ $deps.VariableName1 && $deps.VariableName2 ? 'visible' : 'none'
97
+
98
+ /**
99
+ * Example 5
100
+ * Grater Logic Condition Associated
101
+ **/
102
+
103
+ $deps.VariableName > 100 ? 'visible' : 'hidden'
104
+
105
+ /**
106
+ * Example 6
107
+ * Not Logic Condition Associated
108
+ **/
109
+
110
+ !$deps.VariableName ? 'visible' : 'none'
111
+
112
+ ${GlobalHelper}
113
+ `;
114
+ export const PatternHelper = `
115
+ /**
116
+ * Example 1
117
+ * Static Mode
118
+ **/
119
+
120
+ 'readPretty'
121
+
122
+ /**
123
+ * Example 2
124
+ * Equal Condition Associated
125
+ **/
126
+
127
+ $deps.VariableName === 'TARGET_VALUE' ? 'editable' : 'disabled'
128
+
129
+ /**
130
+ * Example 3
131
+ * Not Equal Condition Associated
132
+ **/
133
+
134
+ $deps.VariableName !== 'TARGET_VALUE' ? 'editable' : 'readOnly'
135
+
136
+ /**
137
+ * Example 4
138
+ * And Logic Condition Associated
139
+ **/
140
+
141
+ $deps.VariableName1 && $deps.VariableName2 ? 'editable' : 'readPretty'
142
+
143
+ /**
144
+ * Example 5
145
+ * Grater Logic Condition Associated
146
+ **/
147
+
148
+ $deps.VariableName > 100 ? 'editable' : 'readOnly'
149
+
150
+ /**
151
+ * Example 6
152
+ * Not Logic Condition Associated
153
+ **/
154
+
155
+ !$deps.VariableName ? 'editable' : 'disabled'
156
+
157
+ ${GlobalHelper}
158
+ `;
159
+ export const StringHelper = `
160
+ /**
161
+ * Example 1
162
+ * Static String
163
+ **/
164
+
165
+ 'Normal String Text'
166
+
167
+ /**
168
+ * Example 2
169
+ * Associated String
170
+ **/
171
+
172
+ $deps.VariableName === 'TARGET_VALUE' ? 'Associated String Text' : ''
173
+
174
+ ${GlobalHelper}
175
+ `;
176
+ export const AnyHelper = `
177
+ /**
178
+ * Example 1
179
+ * String Type
180
+ **/
181
+
182
+ 'String'
183
+
184
+ /**
185
+ * Example 2
186
+ * String Array
187
+ **/
188
+
189
+ ['StringArray']
190
+
191
+ /**
192
+ * Example 3
193
+ * Object Array
194
+ **/
195
+
196
+ [{ key: 'ObjectArray' }]
197
+
198
+ /**
199
+ * Example 4
200
+ * Boolean
201
+ **/
202
+
203
+ true
204
+
205
+ /**
206
+ * Example 5
207
+ * RegExp
208
+ **/
209
+
210
+ /\d+/
211
+
212
+ /**
213
+ * Example 1
214
+ * Associated String Value
215
+ **/
216
+
217
+ $deps.VariableName + 'Compose String'
218
+
219
+ /**
220
+ * Example 2
221
+ * Associated Array Value
222
+ **/
223
+
224
+ [ $deps.VariableName ]
225
+
226
+ /**
227
+ * Example 3
228
+ * Associated Object Value
229
+ **/
230
+
231
+ {
232
+ key : $deps.VariableName
233
+ }
234
+
235
+ /**
236
+ * Example 4
237
+ * Associated Boolean Value
238
+ **/
239
+
240
+ !$deps.VariableName
241
+
242
+ ${GlobalHelper}
243
+ `;
244
+ export const DataSourceHelper = `
245
+ /**
246
+ * Example 1
247
+ * Static DataSource
248
+ **/
249
+
250
+ [
251
+ { label : "item1", value: "1" },
252
+ { label : "item2", value: "2" }
253
+ ]
254
+
255
+ /**
256
+ * Example 2
257
+ * Associated DataSource
258
+ **/
259
+
260
+ [
261
+ { label : "item1", value: "1" },
262
+ { label : "item2", value: "2" },
263
+ ...$deps.VariableName
264
+ ]
265
+
266
+ ${GlobalHelper}
267
+ `;
268
+ export const ComponentPropsHelper = `
269
+ /**
270
+ * Example 1
271
+ * Static Props
272
+ **/
273
+
274
+ {
275
+ placeholder: "This is placeholder"
276
+ }
277
+
278
+ /**
279
+ * Example 2
280
+ * Associated Props
281
+ **/
282
+
283
+ {
284
+ placeholder: $deps.VariableName
285
+ }
286
+
287
+ ${GlobalHelper}
288
+ `;
289
+ export const DecoratorPropsHelper = `
290
+ /**
291
+ * Example 1
292
+ * Static Props
293
+ **/
294
+
295
+ {
296
+ labelCol:6
297
+ }
298
+
299
+ /**
300
+ * Example 2
301
+ * Associated Props
302
+ **/
303
+
304
+ {
305
+ labelCol: $deps.VariableName
306
+ }
307
+
308
+ ${GlobalHelper}
309
+ `;
310
+ export const FulfillRunHelper = `
311
+ /**
312
+ * Example 1
313
+ * Async Select
314
+ **/
315
+
316
+ $effect(()=>{
317
+ $self.loading = true
318
+ fetch('//some.domain/getSomething')
319
+ .then(response=>response.json())
320
+ .then(({ data })=>{
321
+ $self.loading = false
322
+ $self.dataSource = data
323
+ },()=>{
324
+ $self.loading = false
325
+ })
326
+ },[])
327
+
328
+
329
+ /**
330
+ * Example 2
331
+ * Async Search Select
332
+ **/
333
+
334
+ const state = $observable({
335
+ keyword:''
336
+ })
337
+
338
+ $props({
339
+ onSearch(keyword){
340
+ state.keyword = keyword
341
+ }
342
+ })
343
+
344
+ $effect(()=>{
345
+ $self.loading = true
346
+ fetch(\`//some.domain/getSomething?q=\${state.keyword}\`)
347
+ .then(response=>response.json())
348
+ .then(({ data })=>{
349
+ $self.loading = false
350
+ $self.dataSource = data
351
+ },()=>{
352
+ $self.loading = false
353
+ })
354
+ },[ state.keyword ])
355
+
356
+ /**
357
+ * Example 3
358
+ * Async Associated Select
359
+ **/
360
+
361
+ const state = $observable({
362
+ keyword:''
363
+ })
364
+
365
+ $props({
366
+ onSearch(keyword){
367
+ state.keyword = keyword
368
+ }
369
+ })
370
+
371
+ $effect(()=>{
372
+ $self.loading = true
373
+ fetch(\`//some.domain/getSomething?q=\${state.keyword}&other=\${$deps.VariableName}\`)
374
+ .then(response=>response.json())
375
+ .then(({ data })=>{
376
+ $self.loading = false
377
+ $self.dataSource = data
378
+ },()=>{
379
+ $self.loading = false
380
+ })
381
+ },[ state.keyword, $deps.VariableName ])
382
+
383
+ ${GlobalHelper}
384
+ `;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { IReaction } from './types';
3
+ import './styles.less';
4
+ export interface IReactionsSetterProps {
5
+ value?: IReaction;
6
+ onChange?: (value: IReaction) => void;
7
+ }
8
+ export declare const ReactionsSetter: React.FC<IReactionsSetterProps>;