@thienvu18/designable-formily-setters 2.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 (91) hide show
  1. package/LICENSE.md +20 -0
  2. package/README.md +7 -0
  3. package/esm/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
  4. package/esm/components/DataSourceSetter/DataSettingPanel.js +54 -0
  5. package/esm/components/DataSourceSetter/Header.d.ts +7 -0
  6. package/esm/components/DataSourceSetter/Header.js +8 -0
  7. package/esm/components/DataSourceSetter/Title.d.ts +7 -0
  8. package/esm/components/DataSourceSetter/Title.js +46 -0
  9. package/esm/components/DataSourceSetter/TreePanel.d.ts +12 -0
  10. package/esm/components/DataSourceSetter/TreePanel.js +94 -0
  11. package/esm/components/DataSourceSetter/index.d.ts +18 -0
  12. package/esm/components/DataSourceSetter/index.js +27 -0
  13. package/esm/components/DataSourceSetter/shared.d.ts +9 -0
  14. package/esm/components/DataSourceSetter/shared.js +45 -0
  15. package/esm/components/DataSourceSetter/styles.less +81 -0
  16. package/esm/components/DataSourceSetter/types.d.ts +18 -0
  17. package/esm/components/DataSourceSetter/types.js +1 -0
  18. package/esm/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
  19. package/esm/components/ReactionsSetter/FieldPropertySetter.js +65 -0
  20. package/esm/components/ReactionsSetter/PathSelector.d.ts +10 -0
  21. package/esm/components/ReactionsSetter/PathSelector.js +103 -0
  22. package/esm/components/ReactionsSetter/declarations.d.ts +5 -0
  23. package/esm/components/ReactionsSetter/declarations.js +51 -0
  24. package/esm/components/ReactionsSetter/helpers.d.ts +10 -0
  25. package/esm/components/ReactionsSetter/helpers.js +384 -0
  26. package/esm/components/ReactionsSetter/index.d.ts +8 -0
  27. package/esm/components/ReactionsSetter/index.js +251 -0
  28. package/esm/components/ReactionsSetter/properties.d.ts +11 -0
  29. package/esm/components/ReactionsSetter/properties.js +41 -0
  30. package/esm/components/ReactionsSetter/styles.less +105 -0
  31. package/esm/components/ReactionsSetter/types.d.ts +13 -0
  32. package/esm/components/ReactionsSetter/types.js +1 -0
  33. package/esm/components/ValidatorSetter/index.d.ts +6 -0
  34. package/esm/components/ValidatorSetter/index.js +135 -0
  35. package/esm/components/index.d.ts +3 -0
  36. package/esm/components/index.js +3 -0
  37. package/esm/index.d.ts +2 -0
  38. package/esm/index.js +2 -0
  39. package/esm/locales/en-US.d.ts +93 -0
  40. package/esm/locales/en-US.js +98 -0
  41. package/esm/locales/index.d.ts +1 -0
  42. package/esm/locales/index.js +5 -0
  43. package/esm/locales/ko-KR.d.ts +93 -0
  44. package/esm/locales/ko-KR.js +98 -0
  45. package/esm/locales/zh-CN.d.ts +93 -0
  46. package/esm/locales/zh-CN.js +98 -0
  47. package/lib/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
  48. package/lib/components/DataSourceSetter/DataSettingPanel.js +57 -0
  49. package/lib/components/DataSourceSetter/Header.d.ts +7 -0
  50. package/lib/components/DataSourceSetter/Header.js +11 -0
  51. package/lib/components/DataSourceSetter/Title.d.ts +7 -0
  52. package/lib/components/DataSourceSetter/Title.js +49 -0
  53. package/lib/components/DataSourceSetter/TreePanel.d.ts +12 -0
  54. package/lib/components/DataSourceSetter/TreePanel.js +97 -0
  55. package/lib/components/DataSourceSetter/index.d.ts +18 -0
  56. package/lib/components/DataSourceSetter/index.js +33 -0
  57. package/lib/components/DataSourceSetter/shared.d.ts +9 -0
  58. package/lib/components/DataSourceSetter/shared.js +51 -0
  59. package/lib/components/DataSourceSetter/styles.less +81 -0
  60. package/lib/components/DataSourceSetter/types.d.ts +18 -0
  61. package/lib/components/DataSourceSetter/types.js +2 -0
  62. package/lib/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
  63. package/lib/components/ReactionsSetter/FieldPropertySetter.js +69 -0
  64. package/lib/components/ReactionsSetter/PathSelector.d.ts +10 -0
  65. package/lib/components/ReactionsSetter/PathSelector.js +107 -0
  66. package/lib/components/ReactionsSetter/declarations.d.ts +5 -0
  67. package/lib/components/ReactionsSetter/declarations.js +55 -0
  68. package/lib/components/ReactionsSetter/helpers.d.ts +10 -0
  69. package/lib/components/ReactionsSetter/helpers.js +387 -0
  70. package/lib/components/ReactionsSetter/index.d.ts +8 -0
  71. package/lib/components/ReactionsSetter/index.js +255 -0
  72. package/lib/components/ReactionsSetter/properties.d.ts +11 -0
  73. package/lib/components/ReactionsSetter/properties.js +44 -0
  74. package/lib/components/ReactionsSetter/styles.less +105 -0
  75. package/lib/components/ReactionsSetter/types.d.ts +13 -0
  76. package/lib/components/ReactionsSetter/types.js +2 -0
  77. package/lib/components/ValidatorSetter/index.d.ts +6 -0
  78. package/lib/components/ValidatorSetter/index.js +138 -0
  79. package/lib/components/index.d.ts +3 -0
  80. package/lib/components/index.js +19 -0
  81. package/lib/index.d.ts +2 -0
  82. package/lib/index.js +18 -0
  83. package/lib/locales/en-US.d.ts +93 -0
  84. package/lib/locales/en-US.js +100 -0
  85. package/lib/locales/index.d.ts +1 -0
  86. package/lib/locales/index.js +10 -0
  87. package/lib/locales/ko-KR.d.ts +93 -0
  88. package/lib/locales/ko-KR.js +100 -0
  89. package/lib/locales/zh-CN.d.ts +93 -0
  90. package/lib/locales/zh-CN.js +100 -0
  91. package/package.json +64 -0
@@ -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,387 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FulfillRunHelper = exports.DecoratorPropsHelper = exports.ComponentPropsHelper = exports.DataSourceHelper = exports.AnyHelper = exports.StringHelper = exports.PatternHelper = exports.DisplayHelper = exports.BooleanHelper = exports.GlobalHelper = void 0;
4
+ exports.GlobalHelper = `
5
+ /**
6
+ * You can use the built-in context variables
7
+ *
8
+ * 1. \`$self\` is the current Field Model
9
+ *
10
+ * 2. \`$form\` is the current Form Model
11
+ *
12
+ * 3. \`$deps\` is the dependencies value
13
+ *
14
+ * 4. \`$observable\` function is used to create an persistent observable state object
15
+ *
16
+ * 5. \`$memo\` function is is used to create a persistent data
17
+ *
18
+ * 6. \`$effect\` function is used to handle side-effect logic
19
+ *
20
+ * 7. \`$props\` function is used to set component props to current field
21
+ *
22
+ * Document Links
23
+ *
24
+ * 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
25
+ **/
26
+ `;
27
+ exports.BooleanHelper = `
28
+ /**
29
+ * Example 1
30
+ * Static Boolean
31
+ **/
32
+
33
+ false
34
+
35
+ /**
36
+ * Example 2
37
+ * Equal Calculation
38
+ **/
39
+
40
+ $deps.VariableName === 'TARGET_VALUE'
41
+
42
+ /**
43
+ * Example 3
44
+ * Not Equal Calculation
45
+ **/
46
+
47
+ $deps.VariableName !== 'TARGET_VALUE'
48
+
49
+ /**
50
+ * Example 4
51
+ * And Logic Calculation
52
+ **/
53
+
54
+ $deps.VariableName1 && $deps.VariableName2
55
+
56
+ /**
57
+ * Example 5
58
+ * Grater Logic Calculation
59
+ **/
60
+
61
+ $deps.VariableName > 100
62
+
63
+ /**
64
+ * Example 6
65
+ * Not Logic Calculation
66
+ **/
67
+
68
+ !$deps.VariableName
69
+
70
+ ${exports.GlobalHelper}
71
+ `;
72
+ exports.DisplayHelper = `
73
+ /**
74
+ * Example 1
75
+ * Static Mode
76
+ **/
77
+
78
+ 'none'
79
+
80
+ /**
81
+ * Example 2
82
+ * Equal Condition Associated
83
+ **/
84
+
85
+ $deps.VariableName === 'TARGET_VALUE' ? 'visible' : 'none'
86
+
87
+ /**
88
+ * Example 3
89
+ * Not Equal Condition Associated
90
+ **/
91
+
92
+ $deps.VariableName !== 'TARGET_VALUE' ? 'visible' : 'hidden'
93
+
94
+ /**
95
+ * Example 4
96
+ * And Logic Condition Associated
97
+ **/
98
+
99
+ $deps.VariableName1 && $deps.VariableName2 ? 'visible' : 'none'
100
+
101
+ /**
102
+ * Example 5
103
+ * Grater Logic Condition Associated
104
+ **/
105
+
106
+ $deps.VariableName > 100 ? 'visible' : 'hidden'
107
+
108
+ /**
109
+ * Example 6
110
+ * Not Logic Condition Associated
111
+ **/
112
+
113
+ !$deps.VariableName ? 'visible' : 'none'
114
+
115
+ ${exports.GlobalHelper}
116
+ `;
117
+ exports.PatternHelper = `
118
+ /**
119
+ * Example 1
120
+ * Static Mode
121
+ **/
122
+
123
+ 'readPretty'
124
+
125
+ /**
126
+ * Example 2
127
+ * Equal Condition Associated
128
+ **/
129
+
130
+ $deps.VariableName === 'TARGET_VALUE' ? 'editable' : 'disabled'
131
+
132
+ /**
133
+ * Example 3
134
+ * Not Equal Condition Associated
135
+ **/
136
+
137
+ $deps.VariableName !== 'TARGET_VALUE' ? 'editable' : 'readOnly'
138
+
139
+ /**
140
+ * Example 4
141
+ * And Logic Condition Associated
142
+ **/
143
+
144
+ $deps.VariableName1 && $deps.VariableName2 ? 'editable' : 'readPretty'
145
+
146
+ /**
147
+ * Example 5
148
+ * Grater Logic Condition Associated
149
+ **/
150
+
151
+ $deps.VariableName > 100 ? 'editable' : 'readOnly'
152
+
153
+ /**
154
+ * Example 6
155
+ * Not Logic Condition Associated
156
+ **/
157
+
158
+ !$deps.VariableName ? 'editable' : 'disabled'
159
+
160
+ ${exports.GlobalHelper}
161
+ `;
162
+ exports.StringHelper = `
163
+ /**
164
+ * Example 1
165
+ * Static String
166
+ **/
167
+
168
+ 'Normal String Text'
169
+
170
+ /**
171
+ * Example 2
172
+ * Associated String
173
+ **/
174
+
175
+ $deps.VariableName === 'TARGET_VALUE' ? 'Associated String Text' : ''
176
+
177
+ ${exports.GlobalHelper}
178
+ `;
179
+ exports.AnyHelper = `
180
+ /**
181
+ * Example 1
182
+ * String Type
183
+ **/
184
+
185
+ 'String'
186
+
187
+ /**
188
+ * Example 2
189
+ * String Array
190
+ **/
191
+
192
+ ['StringArray']
193
+
194
+ /**
195
+ * Example 3
196
+ * Object Array
197
+ **/
198
+
199
+ [{ key: 'ObjectArray' }]
200
+
201
+ /**
202
+ * Example 4
203
+ * Boolean
204
+ **/
205
+
206
+ true
207
+
208
+ /**
209
+ * Example 5
210
+ * RegExp
211
+ **/
212
+
213
+ /\d+/
214
+
215
+ /**
216
+ * Example 1
217
+ * Associated String Value
218
+ **/
219
+
220
+ $deps.VariableName + 'Compose String'
221
+
222
+ /**
223
+ * Example 2
224
+ * Associated Array Value
225
+ **/
226
+
227
+ [ $deps.VariableName ]
228
+
229
+ /**
230
+ * Example 3
231
+ * Associated Object Value
232
+ **/
233
+
234
+ {
235
+ key : $deps.VariableName
236
+ }
237
+
238
+ /**
239
+ * Example 4
240
+ * Associated Boolean Value
241
+ **/
242
+
243
+ !$deps.VariableName
244
+
245
+ ${exports.GlobalHelper}
246
+ `;
247
+ exports.DataSourceHelper = `
248
+ /**
249
+ * Example 1
250
+ * Static DataSource
251
+ **/
252
+
253
+ [
254
+ { label : "item1", value: "1" },
255
+ { label : "item2", value: "2" }
256
+ ]
257
+
258
+ /**
259
+ * Example 2
260
+ * Associated DataSource
261
+ **/
262
+
263
+ [
264
+ { label : "item1", value: "1" },
265
+ { label : "item2", value: "2" },
266
+ ...$deps.VariableName
267
+ ]
268
+
269
+ ${exports.GlobalHelper}
270
+ `;
271
+ exports.ComponentPropsHelper = `
272
+ /**
273
+ * Example 1
274
+ * Static Props
275
+ **/
276
+
277
+ {
278
+ placeholder: "This is placeholder"
279
+ }
280
+
281
+ /**
282
+ * Example 2
283
+ * Associated Props
284
+ **/
285
+
286
+ {
287
+ placeholder: $deps.VariableName
288
+ }
289
+
290
+ ${exports.GlobalHelper}
291
+ `;
292
+ exports.DecoratorPropsHelper = `
293
+ /**
294
+ * Example 1
295
+ * Static Props
296
+ **/
297
+
298
+ {
299
+ labelCol:6
300
+ }
301
+
302
+ /**
303
+ * Example 2
304
+ * Associated Props
305
+ **/
306
+
307
+ {
308
+ labelCol: $deps.VariableName
309
+ }
310
+
311
+ ${exports.GlobalHelper}
312
+ `;
313
+ exports.FulfillRunHelper = `
314
+ /**
315
+ * Example 1
316
+ * Async Select
317
+ **/
318
+
319
+ $effect(()=>{
320
+ $self.loading = true
321
+ fetch('//some.domain/getSomething')
322
+ .then(response=>response.json())
323
+ .then(({ data })=>{
324
+ $self.loading = false
325
+ $self.dataSource = data
326
+ },()=>{
327
+ $self.loading = false
328
+ })
329
+ },[])
330
+
331
+
332
+ /**
333
+ * Example 2
334
+ * Async Search Select
335
+ **/
336
+
337
+ const state = $observable({
338
+ keyword:''
339
+ })
340
+
341
+ $props({
342
+ onSearch(keyword){
343
+ state.keyword = keyword
344
+ }
345
+ })
346
+
347
+ $effect(()=>{
348
+ $self.loading = true
349
+ fetch(\`//some.domain/getSomething?q=\${state.keyword}\`)
350
+ .then(response=>response.json())
351
+ .then(({ data })=>{
352
+ $self.loading = false
353
+ $self.dataSource = data
354
+ },()=>{
355
+ $self.loading = false
356
+ })
357
+ },[ state.keyword ])
358
+
359
+ /**
360
+ * Example 3
361
+ * Async Associated Select
362
+ **/
363
+
364
+ const state = $observable({
365
+ keyword:''
366
+ })
367
+
368
+ $props({
369
+ onSearch(keyword){
370
+ state.keyword = keyword
371
+ }
372
+ })
373
+
374
+ $effect(()=>{
375
+ $self.loading = true
376
+ fetch(\`//some.domain/getSomething?q=\${state.keyword}&other=\${$deps.VariableName}\`)
377
+ .then(response=>response.json())
378
+ .then(({ data })=>{
379
+ $self.loading = false
380
+ $self.dataSource = data
381
+ },()=>{
382
+ $self.loading = false
383
+ })
384
+ },[ state.keyword, $deps.VariableName ])
385
+
386
+ ${exports.GlobalHelper}
387
+ `;
@@ -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>;
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReactionsSetter = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const shared_1 = require("@formily/shared");
7
+ const core_1 = require("@formily/core");
8
+ const react_2 = require("@formily/react");
9
+ const designable_core_1 = require("@thienvu18/designable-core");
10
+ const designable_shared_1 = require("@thienvu18/designable-shared");
11
+ const designable_react_1 = require("@thienvu18/designable-react");
12
+ const designable_react_settings_form_1 = require("@thienvu18/designable-react-settings-form");
13
+ const formily_antd_v6_1 = require("@thienvu18/formily-antd-v6");
14
+ const antd_1 = require("antd");
15
+ const PathSelector_1 = require("./PathSelector");
16
+ const FieldPropertySetter_1 = require("./FieldPropertySetter");
17
+ const helpers_1 = require("./helpers");
18
+ const declarations_1 = require("./declarations");
19
+ require("./styles.less");
20
+ const TypeView = ({ value }) => {
21
+ const text = String(value);
22
+ if (text.length <= 26)
23
+ return (0, jsx_runtime_1.jsx)(antd_1.Tag, { children: text });
24
+ return ((0, jsx_runtime_1.jsx)(antd_1.Tag, { children: (0, jsx_runtime_1.jsxs)(antd_1.Tooltip, { title: (0, jsx_runtime_1.jsx)("div", { style: { fontSize: 12 }, children: (0, jsx_runtime_1.jsx)("code", { children: (0, jsx_runtime_1.jsx)("pre", { style: { whiteSpace: 'pre-wrap', padding: 0, margin: 0 }, children: text }) }) }), children: [text.substring(0, 24), "..."] }) }));
25
+ };
26
+ const SchemaField = (0, react_2.createSchemaField)({
27
+ components: {
28
+ Card: antd_1.Card,
29
+ FormCollapse: formily_antd_v6_1.FormCollapse,
30
+ Input: formily_antd_v6_1.Input,
31
+ TypeView,
32
+ Select: formily_antd_v6_1.Select,
33
+ FormItem: formily_antd_v6_1.FormItem,
34
+ PathSelector: PathSelector_1.PathSelector,
35
+ FieldPropertySetter: FieldPropertySetter_1.FieldPropertySetter,
36
+ ArrayTable: formily_antd_v6_1.ArrayTable,
37
+ MonacoInput: designable_react_settings_form_1.MonacoInput,
38
+ },
39
+ });
40
+ const FieldStateProperties = [
41
+ 'value',
42
+ 'initialValue',
43
+ 'inputValue',
44
+ 'inputValues',
45
+ 'modified',
46
+ 'initialized',
47
+ 'title',
48
+ 'description',
49
+ 'mounted',
50
+ 'unmounted',
51
+ 'active',
52
+ 'visited',
53
+ 'loading',
54
+ 'errors',
55
+ 'warnings',
56
+ 'successes',
57
+ 'feedbacks',
58
+ 'valid',
59
+ 'invalid',
60
+ 'pattern',
61
+ 'display',
62
+ 'disabled',
63
+ 'readOnly',
64
+ 'readPretty',
65
+ 'visible',
66
+ 'hidden',
67
+ 'editable',
68
+ 'validateStatus',
69
+ 'validating',
70
+ ];
71
+ const FieldStateValueTypes = {
72
+ modified: 'boolean',
73
+ initialized: 'boolean',
74
+ title: 'string',
75
+ description: 'string',
76
+ mounted: 'boolean',
77
+ unmounted: 'boolean',
78
+ active: 'boolean',
79
+ visited: 'boolean',
80
+ loading: 'boolean',
81
+ errors: 'string[]',
82
+ warnings: 'string[]',
83
+ successes: 'string[]',
84
+ feedbacks: `Array<
85
+ triggerType?: 'onInput' | 'onFocus' | 'onBlur'
86
+ type?: 'error' | 'success' | 'warning'
87
+ code?:
88
+ | 'ValidateError'
89
+ | 'ValidateSuccess'
90
+ | 'ValidateWarning'
91
+ | 'EffectError'
92
+ | 'EffectSuccess'
93
+ | 'EffectWarning'
94
+ messages?: string[]
95
+ >
96
+ `,
97
+ valid: 'boolean',
98
+ invalid: 'boolean',
99
+ pattern: "'editable' | 'disabled' | 'readOnly' | 'readPretty'",
100
+ display: "'visible' | 'hidden' | 'none'",
101
+ disabled: 'boolean',
102
+ readOnly: 'boolean',
103
+ readPretty: 'boolean',
104
+ visible: 'boolean',
105
+ hidden: 'boolean',
106
+ editable: 'boolean',
107
+ validateStatus: "'error' | 'warning' | 'success' | 'validating'",
108
+ validating: 'boolean',
109
+ };
110
+ const ReactionsSetter = (props) => {
111
+ const [modalVisible, setModalVisible] = (0, react_1.useState)(false);
112
+ const [innerVisible, setInnerVisible] = (0, react_1.useState)(false);
113
+ const prefix = (0, designable_react_1.usePrefix)('reactions-setter');
114
+ const form = (0, react_1.useMemo)(() => {
115
+ return (0, core_1.createForm)({
116
+ values: (0, shared_1.clone)(props.value),
117
+ });
118
+ }, [modalVisible, props.value]);
119
+ const formCollapse = (0, react_1.useMemo)(() => formily_antd_v6_1.FormCollapse.createFormCollapse(['deps', 'state']), [modalVisible]);
120
+ const openModal = () => setModalVisible(true);
121
+ const closeModal = () => setModalVisible(false);
122
+ (0, react_1.useEffect)(() => {
123
+ if (modalVisible) {
124
+ (0, designable_shared_1.requestIdle)(() => {
125
+ (0, declarations_1.initDeclaration)().then(() => {
126
+ setInnerVisible(true);
127
+ });
128
+ }, {
129
+ timeout: 400,
130
+ });
131
+ }
132
+ else {
133
+ setInnerVisible(false);
134
+ }
135
+ }, [modalVisible]);
136
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { block: true, onClick: openModal, children: (0, jsx_runtime_1.jsx)(designable_react_1.TextWidget, { token: "SettingComponents.ReactionsSetter.configureReactions" }) }), (0, jsx_runtime_1.jsx)(antd_1.Modal, { title: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.configureReactions'), width: "70%", centered: true, styles: { body: { padding: 10 } }, transitionName: "", maskTransitionName: "", open: modalVisible, onCancel: closeModal, destroyOnHidden: true, onOk: () => {
137
+ form.submit((values) => {
138
+ props.onChange?.(values);
139
+ });
140
+ closeModal();
141
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: prefix, children: innerVisible && ((0, jsx_runtime_1.jsx)(formily_antd_v6_1.Form, { form: form, children: (0, jsx_runtime_1.jsx)(SchemaField, { children: (0, jsx_runtime_1.jsxs)(SchemaField.Void, { "x-component": "FormCollapse", "x-component-props": {
142
+ formCollapse,
143
+ defaultActiveKey: ['deps', 'state'],
144
+ style: { marginBottom: 10 },
145
+ }, children: [(0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "FormCollapse.CollapsePanel", "x-component-props": {
146
+ key: 'deps',
147
+ header: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.relationsFields'),
148
+ }, children: (0, jsx_runtime_1.jsxs)(SchemaField.Array, { name: "dependencies", default: [{}], "x-component": "ArrayTable", children: [(0, jsx_runtime_1.jsxs)(SchemaField.Object, { children: [(0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
149
+ title: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.sourceField'),
150
+ width: 240,
151
+ }, children: (0, jsx_runtime_1.jsx)(SchemaField.String, { name: "source", "x-decorator": "FormItem", "x-component": "PathSelector", "x-component-props": {
152
+ placeholder: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.pleaseSelect'),
153
+ } }) }), (0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
154
+ title: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.sourceProperty'),
155
+ width: 200,
156
+ }, children: (0, jsx_runtime_1.jsx)(SchemaField.String, { name: "property", default: "value", "x-decorator": "FormItem", "x-component": "Select", "x-component-props": { showSearch: true }, enum: FieldStateProperties }) }), (0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
157
+ title: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.variableName'),
158
+ width: 200,
159
+ }, children: (0, jsx_runtime_1.jsx)(SchemaField.String, { name: "name", "x-decorator": "FormItem", "x-validator": {
160
+ pattern: /^[$_a-zA-Z]+[$_a-zA-Z0-9]*$/,
161
+ message: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.variableNameValidateMessage'),
162
+ }, "x-component": "Input", "x-component-props": {
163
+ addonBefore: '$deps.',
164
+ placeholder: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.pleaseInput'),
165
+ }, "x-reactions": (field) => {
166
+ if ((0, core_1.isVoidField)(field))
167
+ return;
168
+ field.query('.source').take((source) => {
169
+ if ((0, core_1.isVoidField)(source))
170
+ return;
171
+ if (source.value &&
172
+ !field.value &&
173
+ !field.modified) {
174
+ field.value =
175
+ source.inputValues[1]?.props?.name ||
176
+ `v_${(0, shared_1.uid)()}`;
177
+ }
178
+ });
179
+ } }) }), (0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
180
+ title: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.variableType'),
181
+ ellipsis: {
182
+ showTitle: false,
183
+ },
184
+ width: 200,
185
+ align: 'center',
186
+ }, children: (0, jsx_runtime_1.jsx)(SchemaField.String, { name: "type", default: "any", "x-decorator": "FormItem", "x-component": "TypeView", "x-reactions": (field) => {
187
+ if ((0, core_1.isVoidField)(field))
188
+ return;
189
+ const property = field
190
+ .query('.property')
191
+ .get('inputValues');
192
+ if (!property)
193
+ return;
194
+ property[0] = property[0] || 'value';
195
+ field.query('.source').take((source) => {
196
+ if ((0, core_1.isVoidField)(source))
197
+ return;
198
+ if (source.value) {
199
+ if (property[0] === 'value' ||
200
+ property[0] === 'initialValue' ||
201
+ property[0] === 'inputValue') {
202
+ field.value =
203
+ source.inputValues[1]?.props?.type ||
204
+ 'any';
205
+ }
206
+ else if (property[0] === 'inputValues') {
207
+ field.value = `any[]`;
208
+ }
209
+ else if (property[0]) {
210
+ field.value =
211
+ FieldStateValueTypes[property[0]];
212
+ }
213
+ else {
214
+ field.value = 'any';
215
+ }
216
+ }
217
+ });
218
+ } }) }), (0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
219
+ title: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.operations'),
220
+ align: 'center',
221
+ width: 80,
222
+ }, children: (0, jsx_runtime_1.jsx)(SchemaField.Markup, { type: "void", "x-component": "ArrayTable.Remove" }) })] }), (0, jsx_runtime_1.jsx)(SchemaField.Void, { title: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.addRelationField'), "x-component": "ArrayTable.Addition", "x-component-props": { style: { marginTop: 8 } } })] }) }), (0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "FormCollapse.CollapsePanel", "x-component-props": {
223
+ header: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.propertyReactions'),
224
+ key: 'state',
225
+ className: 'reaction-state',
226
+ }, children: (0, jsx_runtime_1.jsx)(SchemaField.Markup, { name: "fulfill.state", "x-component": "FieldPropertySetter" }) }), (0, jsx_runtime_1.jsx)(SchemaField.Void, { "x-component": "FormCollapse.CollapsePanel", "x-component-props": {
227
+ key: 'run',
228
+ header: designable_core_1.GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.actionReactions'),
229
+ className: 'reaction-runner',
230
+ }, children: (0, jsx_runtime_1.jsx)(SchemaField.String, { name: "fulfill.run", "x-component": "MonacoInput", "x-component-props": {
231
+ width: '100%',
232
+ height: 400,
233
+ language: 'typescript',
234
+ helpCode: helpers_1.FulfillRunHelper,
235
+ options: {
236
+ minimap: {
237
+ enabled: false,
238
+ },
239
+ },
240
+ }, "x-reactions": (field) => {
241
+ const deps = field.query('dependencies').value();
242
+ if (Array.isArray(deps)) {
243
+ field.componentProps.extraLib = `
244
+ declare var $deps : {
245
+ ${deps.map(({ name, type }) => {
246
+ if (!name)
247
+ return '';
248
+ return `${name}?:${type || 'any'},`;
249
+ })}
250
+ }
251
+ `;
252
+ }
253
+ } }) })] }) }) })) }) })] }));
254
+ };
255
+ exports.ReactionsSetter = ReactionsSetter;