@nocobase/client 0.9.0-alpha.2 → 0.9.1-alpha.1

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 (291) hide show
  1. package/es/acl/ACLProvider.js +4 -7
  2. package/es/api-client/APIClient.js +6 -0
  3. package/es/block-provider/BlockProvider.js +9 -6
  4. package/es/block-provider/FormBlockProvider.js +3 -1
  5. package/es/block-provider/KanbanBlockProvider.js +1 -1
  6. package/es/block-provider/SharedFilterProvider.js +9 -1
  7. package/es/block-provider/TableBlockProvider.js +1 -1
  8. package/es/block-provider/TableSelectorProvider.js +2 -2
  9. package/es/block-provider/hooks/index.js +22 -7
  10. package/es/collection-manager/CollectionManagerProvider.d.ts +1 -0
  11. package/es/collection-manager/CollectionManagerProvider.js +71 -9
  12. package/es/collection-manager/CollectionManagerShortcut.js +36 -23
  13. package/es/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
  14. package/es/collection-manager/Configuration/AddCategoryAction.js +117 -0
  15. package/es/collection-manager/Configuration/AddCollectionAction.js +8 -3
  16. package/es/collection-manager/Configuration/AddFieldAction.js +1 -0
  17. package/es/collection-manager/Configuration/ConfigurationTable.js +33 -4
  18. package/es/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
  19. package/es/collection-manager/Configuration/ConfigurationTabs.js +381 -0
  20. package/es/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
  21. package/es/collection-manager/Configuration/EditCategoryAction.js +150 -0
  22. package/es/collection-manager/Configuration/EditCollectionAction.js +6 -2
  23. package/es/collection-manager/Configuration/OverridingCollectionField.js +17 -8
  24. package/es/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
  25. package/es/collection-manager/Configuration/components/CollectionCategory.js +13 -0
  26. package/es/collection-manager/Configuration/index.d.ts +3 -0
  27. package/es/collection-manager/Configuration/index.js +3 -0
  28. package/es/collection-manager/Configuration/schemas/collections.d.ts +3 -0
  29. package/es/collection-manager/Configuration/schemas/collections.js +309 -176
  30. package/es/collection-manager/Configuration/templates.d.ts +1 -0
  31. package/es/collection-manager/Configuration/templates.js +1 -1
  32. package/es/collection-manager/action-hooks.js +3 -1
  33. package/es/collection-manager/context.d.ts +4 -0
  34. package/es/collection-manager/context.js +5 -1
  35. package/es/collection-manager/hooks/useCollectionManager.d.ts +7 -0
  36. package/es/collection-manager/hooks/useCollectionManager.js +51 -6
  37. package/es/collection-manager/interfaces/m2m.js +2 -2
  38. package/es/collection-manager/interfaces/properties/index.d.ts +0 -56
  39. package/es/collection-manager/interfaces/properties/index.js +1 -2
  40. package/es/collection-manager/templates/calendar.js +1 -1
  41. package/es/collection-manager/templates/general.js +1 -1
  42. package/es/collection-manager/templates/properties/index.d.ts +12 -1
  43. package/es/collection-manager/templates/properties/index.js +11 -0
  44. package/es/i18n/i18n.js +3 -1
  45. package/es/locale/en_US.d.ts +23 -0
  46. package/es/locale/en_US.js +23 -0
  47. package/es/locale/ja_JP.d.ts +23 -0
  48. package/es/locale/ja_JP.js +24 -1
  49. package/es/locale/ru_RU.d.ts +1 -0
  50. package/es/locale/ru_RU.js +1 -0
  51. package/es/locale/zh_CN.d.ts +43 -4
  52. package/es/locale/zh_CN.js +44 -5
  53. package/es/route-switch/antd/admin-layout/index.js +13 -33
  54. package/es/schema-component/antd/action/Action.Designer.js +22 -15
  55. package/es/schema-component/antd/action/Action.js +25 -3
  56. package/es/schema-component/antd/action/utils.d.ts +1 -0
  57. package/es/schema-component/antd/action/utils.js +49 -0
  58. package/es/schema-component/antd/association-filter/AssociationFilter.js +4 -4
  59. package/es/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
  60. package/es/schema-component/antd/association-select/useServiceOptions.js +47 -6
  61. package/es/schema-component/antd/calendar/Calendar.Designer.js +17 -36
  62. package/es/schema-component/antd/checkbox/Checkbox.js +9 -8
  63. package/es/schema-component/antd/date-picker/util.d.ts +1 -1
  64. package/es/schema-component/antd/date-picker/util.js +1 -1
  65. package/es/schema-component/antd/filter/DynamicComponent.js +3 -1
  66. package/es/schema-component/antd/filter/Filter.js +2 -1
  67. package/es/schema-component/antd/filter/FilterGroup.js +7 -4
  68. package/es/schema-component/antd/filter/FilterItem.js +3 -2
  69. package/es/schema-component/antd/filter/context.d.ts +1 -0
  70. package/es/schema-component/antd/filter/useValues.js +14 -11
  71. package/es/schema-component/antd/form/Form.js +11 -5
  72. package/es/schema-component/antd/form-item/FormItem.js +17 -8
  73. package/es/schema-component/antd/form-v2/Form.Designer.js +2 -0
  74. package/es/schema-component/antd/form-v2/Form.js +90 -7
  75. package/es/schema-component/antd/form-v2/utils.d.ts +5 -0
  76. package/es/schema-component/antd/form-v2/utils.js +161 -0
  77. package/es/schema-component/antd/grid/Grid.js +10 -5
  78. package/es/schema-component/antd/icon-picker/IconPicker.js +1 -0
  79. package/es/schema-component/antd/index.d.ts +1 -0
  80. package/es/schema-component/antd/index.js +1 -0
  81. package/es/schema-component/antd/input/Input.d.ts +2 -1
  82. package/es/schema-component/antd/input/Json.d.ts +5 -3
  83. package/es/schema-component/antd/input/Json.js +3 -2
  84. package/es/schema-component/antd/input-number/InputNumber.js +3 -1
  85. package/es/schema-component/antd/page/FixedBlock.js +3 -1
  86. package/es/schema-component/antd/page/Page.js +11 -5
  87. package/es/schema-component/antd/page/PageTabDesigner.js +3 -3
  88. package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  89. package/es/schema-component/antd/record-picker/RecordPicker.js +1 -2
  90. package/es/schema-component/antd/record-picker/util.js +7 -0
  91. package/es/schema-component/antd/remote-select/RemoteSelect.js +76 -36
  92. package/es/schema-component/antd/rich-text/RichText.js +4 -2
  93. package/es/schema-component/antd/select/Select.js +14 -4
  94. package/es/schema-component/antd/table/Table.Array.js +10 -3
  95. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
  96. package/es/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
  97. package/es/schema-component/antd/tabs/Tabs.Designer.js +1 -0
  98. package/es/schema-component/antd/time-picker/TimePicker.js +1 -1
  99. package/es/schema-component/antd/variable/Input.d.ts +2 -0
  100. package/es/schema-component/antd/variable/Input.js +244 -0
  101. package/es/schema-component/antd/variable/JSONInput.d.ts +2 -0
  102. package/es/schema-component/antd/variable/JSONInput.js +82 -0
  103. package/es/schema-component/antd/variable/TextArea.d.ts +2 -0
  104. package/es/schema-component/antd/variable/TextArea.js +322 -0
  105. package/es/schema-component/antd/variable/Variable.d.ts +8 -0
  106. package/es/schema-component/antd/variable/Variable.js +11 -0
  107. package/es/schema-component/antd/variable/index.d.ts +1 -0
  108. package/es/schema-component/antd/variable/index.js +1 -0
  109. package/es/schema-component/common/sortable-item/SortableItem.js +36 -6
  110. package/es/schema-component/common/utils/logic.js +523 -0
  111. package/es/schema-component/common/utils/uitls.d.ts +1 -0
  112. package/es/schema-component/common/utils/uitls.js +89 -0
  113. package/es/schema-initializer/SchemaInitializer.js +0 -1
  114. package/es/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
  115. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -3
  116. package/es/schema-initializer/index.d.ts +2 -1
  117. package/es/schema-initializer/index.js +2 -1
  118. package/es/schema-initializer/items/CalendarBlockInitializer.js +24 -41
  119. package/es/schema-initializer/utils.js +22 -7
  120. package/es/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
  121. package/es/schema-settings/LinkageRules/DynamicComponent.js +113 -0
  122. package/es/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
  123. package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +15 -0
  124. package/es/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
  125. package/es/schema-settings/LinkageRules/LinkageRuleAction.js +162 -0
  126. package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
  127. package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.js +71 -0
  128. package/es/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
  129. package/es/schema-settings/LinkageRules/ValueDynamicComponent.js +82 -0
  130. package/es/schema-settings/LinkageRules/Variables.d.ts +7 -0
  131. package/es/schema-settings/LinkageRules/Variables.js +115 -0
  132. package/es/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
  133. package/es/schema-settings/LinkageRules/action-hooks.js +115 -0
  134. package/es/schema-settings/LinkageRules/context.d.ts +13 -0
  135. package/es/schema-settings/LinkageRules/context.js +4 -0
  136. package/es/schema-settings/LinkageRules/index.d.ts +2 -0
  137. package/es/schema-settings/LinkageRules/index.js +132 -0
  138. package/es/schema-settings/LinkageRules/type.d.ts +13 -0
  139. package/es/schema-settings/LinkageRules/type.js +15 -0
  140. package/es/schema-settings/LinkageRules/useValues.d.ts +1 -0
  141. package/es/schema-settings/LinkageRules/useValues.js +84 -0
  142. package/es/schema-settings/SchemaSettings.d.ts +4 -1
  143. package/es/schema-settings/SchemaSettings.js +153 -26
  144. package/es/schema-templates/BlockTemplate.js +9 -1
  145. package/es/system-settings/SystemSettingsShortcut.js +1 -1
  146. package/lib/acl/ACLProvider.js +4 -7
  147. package/lib/api-client/APIClient.js +6 -0
  148. package/lib/block-provider/BlockProvider.js +9 -6
  149. package/lib/block-provider/FormBlockProvider.js +3 -1
  150. package/lib/block-provider/KanbanBlockProvider.js +1 -1
  151. package/lib/block-provider/SharedFilterProvider.js +9 -3
  152. package/lib/block-provider/TableBlockProvider.js +1 -1
  153. package/lib/block-provider/TableSelectorProvider.js +2 -2
  154. package/lib/block-provider/hooks/index.js +23 -7
  155. package/lib/collection-manager/CollectionManagerProvider.d.ts +1 -0
  156. package/lib/collection-manager/CollectionManagerProvider.js +81 -16
  157. package/lib/collection-manager/CollectionManagerShortcut.js +36 -23
  158. package/lib/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
  159. package/lib/collection-manager/Configuration/AddCategoryAction.js +145 -0
  160. package/lib/collection-manager/Configuration/AddCollectionAction.js +8 -3
  161. package/lib/collection-manager/Configuration/AddFieldAction.js +1 -0
  162. package/lib/collection-manager/Configuration/ConfigurationTable.js +34 -4
  163. package/lib/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
  164. package/lib/collection-manager/Configuration/ConfigurationTabs.js +407 -0
  165. package/lib/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
  166. package/lib/collection-manager/Configuration/EditCategoryAction.js +178 -0
  167. package/lib/collection-manager/Configuration/EditCollectionAction.js +6 -2
  168. package/lib/collection-manager/Configuration/OverridingCollectionField.js +17 -8
  169. package/lib/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
  170. package/lib/collection-manager/Configuration/components/CollectionCategory.js +27 -0
  171. package/lib/collection-manager/Configuration/index.d.ts +3 -0
  172. package/lib/collection-manager/Configuration/index.js +39 -0
  173. package/lib/collection-manager/Configuration/schemas/collections.d.ts +3 -0
  174. package/lib/collection-manager/Configuration/schemas/collections.js +316 -178
  175. package/lib/collection-manager/Configuration/templates.d.ts +1 -0
  176. package/lib/collection-manager/Configuration/templates.js +2 -0
  177. package/lib/collection-manager/action-hooks.js +3 -1
  178. package/lib/collection-manager/context.d.ts +4 -0
  179. package/lib/collection-manager/context.js +7 -2
  180. package/lib/collection-manager/hooks/useCollectionManager.d.ts +7 -0
  181. package/lib/collection-manager/hooks/useCollectionManager.js +52 -6
  182. package/lib/collection-manager/interfaces/m2m.js +2 -2
  183. package/lib/collection-manager/interfaces/properties/index.d.ts +0 -56
  184. package/lib/collection-manager/interfaces/properties/index.js +1 -2
  185. package/lib/collection-manager/templates/calendar.js +1 -1
  186. package/lib/collection-manager/templates/general.js +1 -1
  187. package/lib/collection-manager/templates/properties/index.d.ts +12 -1
  188. package/lib/collection-manager/templates/properties/index.js +11 -0
  189. package/lib/i18n/i18n.js +3 -1
  190. package/lib/locale/en_US.d.ts +23 -0
  191. package/lib/locale/en_US.js +23 -0
  192. package/lib/locale/ja_JP.d.ts +23 -0
  193. package/lib/locale/ja_JP.js +24 -1
  194. package/lib/locale/ru_RU.d.ts +1 -0
  195. package/lib/locale/ru_RU.js +1 -0
  196. package/lib/locale/zh_CN.d.ts +43 -4
  197. package/lib/locale/zh_CN.js +44 -5
  198. package/lib/route-switch/antd/admin-layout/index.js +13 -33
  199. package/lib/schema-component/antd/action/Action.Designer.js +24 -14
  200. package/lib/schema-component/antd/action/Action.js +27 -2
  201. package/lib/schema-component/antd/action/utils.d.ts +1 -0
  202. package/lib/schema-component/antd/action/utils.js +58 -2
  203. package/lib/schema-component/antd/association-filter/AssociationFilter.js +3 -3
  204. package/lib/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
  205. package/lib/schema-component/antd/association-select/useServiceOptions.js +47 -4
  206. package/lib/schema-component/antd/calendar/Calendar.Designer.js +15 -33
  207. package/lib/schema-component/antd/checkbox/Checkbox.js +8 -7
  208. package/lib/schema-component/antd/date-picker/util.d.ts +1 -1
  209. package/lib/schema-component/antd/date-picker/util.js +1 -1
  210. package/lib/schema-component/antd/filter/DynamicComponent.js +3 -1
  211. package/lib/schema-component/antd/filter/Filter.js +2 -1
  212. package/lib/schema-component/antd/filter/FilterGroup.js +7 -4
  213. package/lib/schema-component/antd/filter/FilterItem.js +3 -2
  214. package/lib/schema-component/antd/filter/context.d.ts +1 -0
  215. package/lib/schema-component/antd/filter/useValues.js +15 -11
  216. package/lib/schema-component/antd/form/Form.js +9 -3
  217. package/lib/schema-component/antd/form-item/FormItem.js +21 -7
  218. package/lib/schema-component/antd/form-v2/Form.Designer.js +2 -0
  219. package/lib/schema-component/antd/form-v2/Form.js +89 -5
  220. package/lib/schema-component/antd/form-v2/utils.d.ts +5 -0
  221. package/lib/schema-component/antd/form-v2/utils.js +181 -0
  222. package/lib/schema-component/antd/grid/Grid.js +10 -5
  223. package/lib/schema-component/antd/icon-picker/IconPicker.js +1 -0
  224. package/lib/schema-component/antd/index.d.ts +1 -0
  225. package/lib/schema-component/antd/index.js +13 -0
  226. package/lib/schema-component/antd/input/Input.d.ts +2 -1
  227. package/lib/schema-component/antd/input/Json.d.ts +5 -3
  228. package/lib/schema-component/antd/input/Json.js +6 -3
  229. package/lib/schema-component/antd/input-number/InputNumber.js +2 -0
  230. package/lib/schema-component/antd/page/FixedBlock.js +3 -1
  231. package/lib/schema-component/antd/page/Page.js +14 -5
  232. package/lib/schema-component/antd/page/PageTabDesigner.js +1 -1
  233. package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  234. package/lib/schema-component/antd/record-picker/RecordPicker.js +1 -2
  235. package/lib/schema-component/antd/record-picker/util.js +7 -0
  236. package/lib/schema-component/antd/remote-select/RemoteSelect.js +76 -37
  237. package/lib/schema-component/antd/rich-text/RichText.js +4 -2
  238. package/lib/schema-component/antd/select/Select.js +14 -4
  239. package/lib/schema-component/antd/table/Table.Array.js +8 -1
  240. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
  241. package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
  242. package/lib/schema-component/antd/tabs/Tabs.Designer.js +1 -0
  243. package/lib/schema-component/antd/time-picker/TimePicker.js +1 -1
  244. package/lib/schema-component/antd/variable/Input.d.ts +2 -0
  245. package/lib/schema-component/antd/variable/Input.js +262 -0
  246. package/lib/schema-component/antd/variable/JSONInput.d.ts +2 -0
  247. package/lib/schema-component/antd/variable/JSONInput.js +100 -0
  248. package/lib/schema-component/antd/variable/TextArea.d.ts +2 -0
  249. package/lib/schema-component/antd/variable/TextArea.js +341 -0
  250. package/lib/schema-component/antd/variable/Variable.d.ts +8 -0
  251. package/lib/schema-component/antd/variable/Variable.js +25 -0
  252. package/lib/schema-component/antd/variable/index.d.ts +1 -0
  253. package/lib/schema-component/antd/variable/index.js +18 -0
  254. package/lib/schema-component/common/sortable-item/SortableItem.js +36 -6
  255. package/lib/schema-component/common/utils/logic.js +525 -0
  256. package/lib/schema-component/common/utils/uitls.d.ts +1 -0
  257. package/lib/schema-component/common/utils/uitls.js +103 -0
  258. package/lib/schema-initializer/SchemaInitializer.js +0 -1
  259. package/lib/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
  260. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +3 -1
  261. package/lib/schema-initializer/index.d.ts +2 -1
  262. package/lib/schema-initializer/index.js +51 -2
  263. package/lib/schema-initializer/items/CalendarBlockInitializer.js +16 -33
  264. package/lib/schema-initializer/utils.js +22 -6
  265. package/lib/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
  266. package/lib/schema-settings/LinkageRules/DynamicComponent.js +139 -0
  267. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
  268. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +27 -0
  269. package/lib/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
  270. package/lib/schema-settings/LinkageRules/LinkageRuleAction.js +190 -0
  271. package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
  272. package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.js +90 -0
  273. package/lib/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
  274. package/lib/schema-settings/LinkageRules/ValueDynamicComponent.js +104 -0
  275. package/lib/schema-settings/LinkageRules/Variables.d.ts +7 -0
  276. package/lib/schema-settings/LinkageRules/Variables.js +124 -0
  277. package/lib/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
  278. package/lib/schema-settings/LinkageRules/action-hooks.js +127 -0
  279. package/lib/schema-settings/LinkageRules/context.d.ts +13 -0
  280. package/lib/schema-settings/LinkageRules/context.js +15 -0
  281. package/lib/schema-settings/LinkageRules/index.d.ts +2 -0
  282. package/lib/schema-settings/LinkageRules/index.js +149 -0
  283. package/lib/schema-settings/LinkageRules/type.d.ts +13 -0
  284. package/lib/schema-settings/LinkageRules/type.js +22 -0
  285. package/lib/schema-settings/LinkageRules/useValues.d.ts +1 -0
  286. package/lib/schema-settings/LinkageRules/useValues.js +95 -0
  287. package/lib/schema-settings/SchemaSettings.d.ts +4 -1
  288. package/lib/schema-settings/SchemaSettings.js +176 -48
  289. package/lib/schema-templates/BlockTemplate.js +9 -1
  290. package/lib/system-settings/SystemSettingsShortcut.js +1 -1
  291. package/package.json +4 -4
@@ -0,0 +1,244 @@
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
2
+
3
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
4
+
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
+
17
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
18
+
19
+ import React from 'react';
20
+ import { useForm } from '@formily/react';
21
+ import { Cascader, Input as AntInput, Button, Tag, InputNumber, Select, DatePicker } from 'antd';
22
+ import { CloseCircleFilled } from '@ant-design/icons';
23
+ import { cx, css } from '@emotion/css';
24
+ import { useTranslation } from 'react-i18next';
25
+ import moment from 'moment';
26
+ import { useCompile } from '../..';
27
+ var JT_VALUE_RE = /^\s*{{\s*([^{}]+)\s*}}\s*$/;
28
+
29
+ function parseValue(value) {
30
+ if (value == null) {
31
+ return 'null';
32
+ }
33
+
34
+ var type = _typeof(value);
35
+
36
+ if (type === 'string') {
37
+ var matched = value.match(JT_VALUE_RE);
38
+
39
+ if (matched) {
40
+ return matched[1].split('.');
41
+ } // const ts = Date.parse(value);
42
+ // if (value.match(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d{0,3})Z$/) && !Number.isNaN(Date.parse(value))) {
43
+ // return {
44
+ // type: 'date',
45
+ // };
46
+ // }
47
+
48
+ }
49
+
50
+ return type === 'object' && value instanceof Date ? 'date' : type;
51
+ }
52
+
53
+ var ConstantTypes = {
54
+ string: {
55
+ label: "{{t(\"String\")}}",
56
+ value: 'string',
57
+ component: function component(_ref) {
58
+ var _onChange = _ref.onChange,
59
+ value = _ref.value;
60
+ return /*#__PURE__*/React.createElement(AntInput, {
61
+ value: value,
62
+ onChange: function onChange(ev) {
63
+ return _onChange(ev.target.value);
64
+ }
65
+ });
66
+ },
67
+ default: ''
68
+ },
69
+ number: {
70
+ label: '{{t("Number")}}',
71
+ value: 'number',
72
+ component: function component(_ref2) {
73
+ var onChange = _ref2.onChange,
74
+ value = _ref2.value;
75
+ return /*#__PURE__*/React.createElement(InputNumber, {
76
+ value: value,
77
+ onChange: onChange
78
+ });
79
+ },
80
+ default: 0
81
+ },
82
+ boolean: {
83
+ label: "{{t(\"Boolean\")}}",
84
+ value: 'boolean',
85
+ component: function component(_ref3) {
86
+ var onChange = _ref3.onChange,
87
+ value = _ref3.value;
88
+
89
+ var _useTranslation = useTranslation(),
90
+ t = _useTranslation.t;
91
+
92
+ return /*#__PURE__*/React.createElement(Select, {
93
+ value: value,
94
+ onChange: onChange,
95
+ placeholder: t('Select'),
96
+ options: [{
97
+ value: true,
98
+ label: t('True')
99
+ }, {
100
+ value: false,
101
+ label: t('False')
102
+ }]
103
+ });
104
+ },
105
+ default: false
106
+ },
107
+ date: {
108
+ label: '{{t("Date")}}',
109
+ value: 'date',
110
+ component: function component(_ref4) {
111
+ var _onChange2 = _ref4.onChange,
112
+ value = _ref4.value;
113
+ return /*#__PURE__*/React.createElement(DatePicker, {
114
+ value: moment(value),
115
+ onChange: function onChange(d) {
116
+ return d ? _onChange2(d.toDate()) : null;
117
+ },
118
+ allowClear: false,
119
+ showTime: true
120
+ });
121
+ },
122
+ default: function () {
123
+ var now = new Date();
124
+ return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);
125
+ }()
126
+ },
127
+ null: {
128
+ label: "{{t(\"Null\")}}",
129
+ value: 'null',
130
+ component: function component() {
131
+ var _useTranslation2 = useTranslation(),
132
+ t = _useTranslation2.t;
133
+
134
+ return /*#__PURE__*/React.createElement(AntInput, {
135
+ readOnly: true,
136
+ placeholder: t('Null'),
137
+ className: "null-value"
138
+ });
139
+ },
140
+ default: null
141
+ }
142
+ };
143
+ export function Input(props) {
144
+ var _ConstantTypes$type;
145
+
146
+ var _props$value = props.value,
147
+ value = _props$value === void 0 ? '' : _props$value,
148
+ scope = props.scope,
149
+ onChange = props.onChange,
150
+ children = props.children,
151
+ button = props.button;
152
+ var parsed = parseValue(value);
153
+ var isConstant = typeof parsed === 'string';
154
+ var type = isConstant ? parsed : '';
155
+ var variable = isConstant ? null : parsed;
156
+ var ConstantComponent = (_ConstantTypes$type = ConstantTypes[type]) === null || _ConstantTypes$type === void 0 ? void 0 : _ConstantTypes$type.component;
157
+ var constantOptions = Object.values(ConstantTypes);
158
+ var compile = useCompile();
159
+
160
+ var _useTranslation3 = useTranslation(),
161
+ t = _useTranslation3.t;
162
+
163
+ var options = compile([{
164
+ value: '',
165
+ label: t('Constant'),
166
+ children: children ? null : constantOptions
167
+ }].concat(_toConsumableArray(typeof scope === 'function' ? scope() : scope !== null && scope !== void 0 ? scope : [])));
168
+ var form = useForm();
169
+
170
+ function onSwitch(next) {
171
+ if (next[0] === '') {
172
+ if (next[1]) {
173
+ if (next[1] !== type) {
174
+ var _ConstantTypes$next$, _ConstantTypes$next$2;
175
+
176
+ onChange((_ConstantTypes$next$ = (_ConstantTypes$next$2 = ConstantTypes[next[1]]) === null || _ConstantTypes$next$2 === void 0 ? void 0 : _ConstantTypes$next$2.default) !== null && _ConstantTypes$next$ !== void 0 ? _ConstantTypes$next$ : null);
177
+ }
178
+ } else {
179
+ if (variable) {
180
+ onChange(null);
181
+ }
182
+ }
183
+
184
+ return;
185
+ }
186
+
187
+ onChange("{{".concat(next.join('.'), "}}"));
188
+ }
189
+
190
+ var variableText = variable === null || variable === void 0 ? void 0 : variable.reduce(function (opts, key, i) {
191
+ var _ref5;
192
+
193
+ var option = (_ref5 = i ? opts[i - 1].children : options) === null || _ref5 === void 0 ? void 0 : _ref5.find(function (item) {
194
+ return item.value === key;
195
+ });
196
+ return option ? opts.concat(option) : opts;
197
+ }, []).map(function (item) {
198
+ return item.label;
199
+ }).join(' / ');
200
+ var disabled = props.disabled || form.disabled;
201
+ return /*#__PURE__*/React.createElement(AntInput.Group, {
202
+ compact: true,
203
+ className: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: auto;\n display: flex !important;\n .ant-input-disabled {\n .ant-tag {\n color: #bfbfbf;\n border-color: #d9d9d9;\n }\n }\n .ant-input.null-value {\n width: 4em;\n min-width: 4em;\n }\n "])))
204
+ }, variable ? /*#__PURE__*/React.createElement("div", {
205
+ className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n line-height: 0;\n\n &:hover {\n .ant-select-clear {\n opacity: 0.8;\n }\n }\n\n .ant-input {\n overflow: auto;\n white-space: nowrap;\n ", "\n\n .ant-tag {\n display: inline;\n line-height: 19px;\n margin: 0;\n padding: 2px 7px;\n border-radius: 10px;\n }\n }\n "])), disabled ? '' : 'padding-right: 28px;')
206
+ }, /*#__PURE__*/React.createElement("div", {
207
+ onInput: function onInput(e) {
208
+ return e.preventDefault();
209
+ },
210
+ onKeyDown: function onKeyDown(e) {
211
+ if (e.key !== 'Backspace') {
212
+ e.preventDefault();
213
+ return;
214
+ }
215
+
216
+ onChange(null);
217
+ },
218
+ className: cx('ant-input', {
219
+ 'ant-input-disabled': disabled
220
+ }),
221
+ contentEditable: !disabled,
222
+ suppressContentEditableWarning: true
223
+ }, /*#__PURE__*/React.createElement(Tag, {
224
+ contentEditable: false,
225
+ color: "blue"
226
+ }, variableText)), !disabled ? /*#__PURE__*/React.createElement("span", {
227
+ className: cx('ant-select-clear', css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n user-select: 'none';\n "])))),
228
+ unselectable: "on",
229
+ "aria-hidden": true,
230
+ onClick: function onClick() {
231
+ return onChange(null);
232
+ }
233
+ }, /*#__PURE__*/React.createElement(CloseCircleFilled, null)) : null) : children !== null && children !== void 0 ? children : /*#__PURE__*/React.createElement(ConstantComponent, {
234
+ value: value,
235
+ onChange: onChange
236
+ }), options.length > 1 ? /*#__PURE__*/React.createElement(Cascader, {
237
+ value: variable !== null && variable !== void 0 ? variable : [''].concat(_toConsumableArray(children ? [] : [type])),
238
+ options: options,
239
+ onChange: onSwitch
240
+ }, button !== null && button !== void 0 ? button : /*#__PURE__*/React.createElement(Button, {
241
+ type: variable ? 'primary' : 'default',
242
+ className: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-style: italic;\n font-family: 'New York', 'Times New Roman', Times, serif;\n "])))
243
+ }, "x")) : null);
244
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function JSONInput(props: any): JSX.Element;
@@ -0,0 +1,82 @@
1
+ var _templateObject, _templateObject2, _templateObject3;
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+
9
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
10
+
11
+ import React, { useRef } from 'react';
12
+ import { Button, Cascader } from 'antd';
13
+ import { css } from "@emotion/css";
14
+ import { Input } from "../input";
15
+ import { useTranslation } from 'react-i18next'; // NOTE: https://stackoverflow.com/questions/23892547/what-is-the-best-way-to-trigger-onchange-event-in-react-js/46012210#46012210
16
+
17
+ function setNativeInputValue(input, value) {
18
+ var nativeInputValueSetter = Object.getOwnPropertyDescriptor(input.constructor.prototype, 'value').set;
19
+ nativeInputValueSetter.call(input, value);
20
+ input.dispatchEvent(new Event('input', {
21
+ bubbles: true
22
+ }));
23
+ }
24
+
25
+ export function JSONInput(props) {
26
+ var inputRef = useRef(null);
27
+ var value = props.value,
28
+ _props$space = props.space,
29
+ space = _props$space === void 0 ? 2 : _props$space,
30
+ scope = props.scope;
31
+
32
+ var _useTranslation = useTranslation(),
33
+ t = _useTranslation.t;
34
+
35
+ var options = typeof scope === 'function' ? scope() : scope !== null && scope !== void 0 ? scope : [];
36
+
37
+ function onFormat() {
38
+ if (!inputRef.current) {
39
+ return;
40
+ }
41
+
42
+ if (!value) {
43
+ return;
44
+ }
45
+
46
+ var textArea = inputRef.current.resizableTextArea.textArea;
47
+ var nextValue = JSON.stringify(value, null, space);
48
+ setNativeInputValue(textArea, nextValue);
49
+ textArea.setSelectionRange(nextValue.length, nextValue.length);
50
+ textArea.focus();
51
+ }
52
+
53
+ function onInsert(selected) {
54
+ if (!inputRef.current) {
55
+ return;
56
+ }
57
+
58
+ var variable = "{{".concat(selected.join('.'), "}}");
59
+ var textArea = inputRef.current.resizableTextArea.textArea;
60
+ var nextValue = textArea.value.slice(0, textArea.selectionStart) + variable + textArea.value.slice(textArea.selectionEnd);
61
+ var nextPos = [textArea.selectionStart, textArea.selectionStart + variable.length];
62
+ setNativeInputValue(textArea, nextValue);
63
+ textArea.setSelectionRange.apply(textArea, nextPos);
64
+ textArea.focus();
65
+ }
66
+
67
+ return /*#__PURE__*/React.createElement("div", {
68
+ className: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n .ant-input{\n width: 100%;\n }\n "])))
69
+ }, /*#__PURE__*/React.createElement(Input.JSON, _objectSpread(_objectSpread({}, props), {}, {
70
+ ref: inputRef
71
+ })), /*#__PURE__*/React.createElement(Button.Group, {
72
+ className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n right: 0;\n top: 0;\n .ant-btn-sm{\n font-size: 85%;\n }\n "])))
73
+ }, /*#__PURE__*/React.createElement(Button, {
74
+ onClick: onFormat
75
+ }, t('Prettify')), /*#__PURE__*/React.createElement(Cascader, {
76
+ value: [],
77
+ options: options,
78
+ onChange: onInsert
79
+ }, /*#__PURE__*/React.createElement(Button, {
80
+ className: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-style: italic;\n font-family: \"New York\", \"Times New Roman\", Times, serif;\n "])))
81
+ }, "x"))));
82
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function TextArea(props: any): JSX.Element;
@@ -0,0 +1,322 @@
1
+ var _templateObject, _templateObject2, _templateObject3;
2
+
3
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
4
+
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+
15
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+
17
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
18
+
19
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
+
21
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
22
+
23
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
24
+
25
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
26
+
27
+ import React, { useState, useEffect, useRef, useMemo } from 'react';
28
+ import { Input, Cascader, Tooltip, Button } from 'antd';
29
+ import { useForm } from '@formily/react';
30
+ import { cx, css } from '@emotion/css';
31
+ import { useTranslation } from 'react-i18next';
32
+ import { useCompile } from '../..';
33
+ var VARIABLE_RE = /{{\s*([^{}]+)\s*}}/g;
34
+
35
+ function pasteHtml(container, html, _ref) {
36
+ var _window$getSelection, _window;
37
+
38
+ var _ref$selectPastedCont = _ref.selectPastedContent,
39
+ selectPastedContent = _ref$selectPastedCont === void 0 ? false : _ref$selectPastedCont,
40
+ indexes = _ref.range;
41
+ // IE9 and non-IE
42
+ var sel = (_window$getSelection = (_window = window).getSelection) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.call(_window);
43
+
44
+ if (!(sel === null || sel === void 0 ? void 0 : sel.getRangeAt) || !sel.rangeCount) {
45
+ return;
46
+ }
47
+
48
+ var range = sel.getRangeAt(0);
49
+
50
+ if (!range) {
51
+ return;
52
+ }
53
+
54
+ var children = Array.from(container.childNodes);
55
+
56
+ if (indexes[0] === -1) {
57
+ if (indexes[1]) {
58
+ range.setStartAfter(children[indexes[1] - 1]);
59
+ }
60
+ } else {
61
+ range.setStart(children[indexes[0]], indexes[1]);
62
+ }
63
+
64
+ if (indexes[2] === -1) {
65
+ if (indexes[3]) {
66
+ range.setEndAfter(children[indexes[3] - 1]);
67
+ }
68
+ } else {
69
+ range.setEnd(children[indexes[2]], indexes[3]);
70
+ }
71
+
72
+ range.deleteContents(); // Range.createContextualFragment() would be useful here but is
73
+ // only relatively recently standardized and is not supported in
74
+ // some browsers (IE9, for one)
75
+
76
+ var el = document.createElement('div');
77
+ el.innerHTML = html;
78
+ var frag = document.createDocumentFragment();
79
+ var lastNode;
80
+
81
+ while (el.firstChild) {
82
+ lastNode = frag.appendChild(el.firstChild);
83
+ }
84
+
85
+ var firstChild = frag.firstChild;
86
+ range.insertNode(frag); // Preserve the selection
87
+
88
+ if (lastNode) {
89
+ var next = range.cloneRange();
90
+ next.setStartAfter(lastNode);
91
+
92
+ if (selectPastedContent) {
93
+ if (firstChild) {
94
+ next.setStartBefore(firstChild);
95
+ }
96
+ } else {
97
+ next.collapse(true);
98
+ }
99
+
100
+ sel.removeAllRanges();
101
+ sel.addRange(next);
102
+ }
103
+ }
104
+
105
+ function getValue(el) {
106
+ var values = [];
107
+
108
+ var _iterator = _createForOfIteratorHelper(el.childNodes),
109
+ _step;
110
+
111
+ try {
112
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
113
+ var node = _step.value;
114
+
115
+ if (node.nodeName === 'SPAN') {
116
+ values.push("{{".concat(node['dataset']['key'], "}}"));
117
+ } else {
118
+ var _node$textContent, _node$textContent$tri;
119
+
120
+ values.push((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : (_node$textContent$tri = _node$textContent.trim) === null || _node$textContent$tri === void 0 ? void 0 : _node$textContent$tri.call(_node$textContent));
121
+ }
122
+ }
123
+ } catch (err) {
124
+ _iterator.e(err);
125
+ } finally {
126
+ _iterator.f();
127
+ }
128
+
129
+ return values.join(' ').replace(/\s+/g, ' ').trim();
130
+ }
131
+
132
+ function renderHTML(exp, keyLabelMap) {
133
+ return exp.replace(VARIABLE_RE, function (_, i) {
134
+ var _createVariableTagHTM;
135
+
136
+ var key = i.trim();
137
+ return (_createVariableTagHTM = createVariableTagHTML(key, keyLabelMap)) !== null && _createVariableTagHTM !== void 0 ? _createVariableTagHTM : '';
138
+ });
139
+ }
140
+
141
+ function createOptionsValueLabelMap(options) {
142
+ var map = new Map();
143
+
144
+ var _iterator2 = _createForOfIteratorHelper(options),
145
+ _step2;
146
+
147
+ try {
148
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
149
+ var option = _step2.value;
150
+ map.set(option.value, [option.label]);
151
+
152
+ if (option.children) {
153
+ var _iterator3 = _createForOfIteratorHelper(createOptionsValueLabelMap(option.children)),
154
+ _step3;
155
+
156
+ try {
157
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
158
+ var _step3$value = _slicedToArray(_step3.value, 2),
159
+ value = _step3$value[0],
160
+ labels = _step3$value[1];
161
+
162
+ map.set("".concat(option.value, ".").concat(value), [option.label].concat(_toConsumableArray(labels)));
163
+ }
164
+ } catch (err) {
165
+ _iterator3.e(err);
166
+ } finally {
167
+ _iterator3.f();
168
+ }
169
+ }
170
+ }
171
+ } catch (err) {
172
+ _iterator2.e(err);
173
+ } finally {
174
+ _iterator2.f();
175
+ }
176
+
177
+ return map;
178
+ }
179
+
180
+ function createVariableTagHTML(variable, keyLabelMap) {
181
+ var labels = keyLabelMap.get(variable);
182
+ return "<span class=\"ant-tag ant-tag-blue\" contentEditable=\"false\" data-key=\"".concat(variable, "\">").concat(labels === null || labels === void 0 ? void 0 : labels.join(' / '), "</span>");
183
+ }
184
+
185
+ export function TextArea(props) {
186
+ var _ref2;
187
+
188
+ var _props$value = props.value,
189
+ value = _props$value === void 0 ? '' : _props$value,
190
+ scope = props.scope,
191
+ onChange = props.onChange,
192
+ _props$multiline = props.multiline,
193
+ multiline = _props$multiline === void 0 ? true : _props$multiline,
194
+ button = props.button;
195
+ var compile = useCompile();
196
+
197
+ var _useTranslation = useTranslation(),
198
+ t = _useTranslation.t;
199
+
200
+ var inputRef = useRef(null);
201
+ var options = compile((_ref2 = typeof scope === 'function' ? scope() : scope) !== null && _ref2 !== void 0 ? _ref2 : []);
202
+ var form = useForm();
203
+ var keyLabelMap = useMemo(function () {
204
+ return createOptionsValueLabelMap(options);
205
+ }, [scope]);
206
+
207
+ var _useState = useState(false),
208
+ _useState2 = _slicedToArray(_useState, 2),
209
+ changed = _useState2[0],
210
+ setChanged = _useState2[1];
211
+
212
+ var _useState3 = useState(function () {
213
+ return renderHTML(value !== null && value !== void 0 ? value : '', keyLabelMap);
214
+ }),
215
+ _useState4 = _slicedToArray(_useState3, 2),
216
+ html = _useState4[0],
217
+ setHtml = _useState4[1]; // [startElementIndex, startOffset, endElementIndex, endOffset]
218
+
219
+
220
+ var _useState5 = useState([-1, 0, -1, 0]),
221
+ _useState6 = _slicedToArray(_useState5, 2),
222
+ range = _useState6[0],
223
+ setRange = _useState6[1];
224
+
225
+ useEffect(function () {
226
+ if (changed) {
227
+ return;
228
+ }
229
+
230
+ setHtml(renderHTML(value !== null && value !== void 0 ? value : '', keyLabelMap));
231
+ }, [value]);
232
+ useEffect(function () {
233
+ var current = inputRef.current;
234
+
235
+ if (!current || changed) {
236
+ return;
237
+ }
238
+
239
+ var nextRange = new Range();
240
+ var lastChild = current.lastChild;
241
+
242
+ if (lastChild) {
243
+ nextRange.setStartAfter(lastChild);
244
+ nextRange.setEndAfter(lastChild);
245
+ var nodes = Array.from(current.childNodes);
246
+ var startElementIndex = nextRange.startContainer === current ? -1 : nodes.indexOf(lastChild);
247
+ var endElementIndex = nextRange.startContainer === current ? -1 : nodes.indexOf(lastChild);
248
+ setRange([startElementIndex, nextRange.startOffset, endElementIndex, nextRange.endOffset]);
249
+ }
250
+ }, [html]);
251
+
252
+ function onInsert(keyPath) {
253
+ var variable = keyPath.filter(function (key) {
254
+ return Boolean(key.trim());
255
+ });
256
+ var current = inputRef.current;
257
+
258
+ if (!current || !variable) {
259
+ return;
260
+ }
261
+
262
+ current.focus();
263
+ pasteHtml(current, createVariableTagHTML(variable.join('.'), keyLabelMap), {
264
+ range: range
265
+ });
266
+ setChanged(true);
267
+ onChange(getValue(current));
268
+ }
269
+
270
+ function onInput(_ref3) {
271
+ var currentTarget = _ref3.currentTarget;
272
+ setChanged(true);
273
+ onChange(getValue(currentTarget));
274
+ }
275
+
276
+ function onBlur(_ref4) {
277
+ var _window$getSelection2, _window2;
278
+
279
+ var currentTarget = _ref4.currentTarget;
280
+ var sel = (_window$getSelection2 = (_window2 = window).getSelection) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.call(_window2);
281
+
282
+ if (!(sel === null || sel === void 0 ? void 0 : sel.getRangeAt) || !sel.rangeCount) {
283
+ return;
284
+ }
285
+
286
+ var r = sel.getRangeAt(0);
287
+ var nodes = Array.from(currentTarget.childNodes);
288
+ var startElementIndex = nodes.indexOf(r.startContainer);
289
+ var endElementIndex = nodes.indexOf(r.endContainer);
290
+ setRange([startElementIndex, r.startOffset, endElementIndex, r.endOffset]);
291
+ }
292
+
293
+ var disabled = props.disabled || form.disabled;
294
+ return /*#__PURE__*/React.createElement(Input.Group, {
295
+ compact: true,
296
+ className: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.ant-input-group.ant-input-group-compact {\n display: flex;\n .ant-input {\n flex-grow: 1;\n min-width: 200px;\n }\n .ant-input-disabled {\n .ant-tag {\n color: #bfbfbf;\n border-color: #d9d9d9;\n }\n }\n }\n "])))
297
+ }, /*#__PURE__*/React.createElement("div", {
298
+ onInput: onInput,
299
+ onBlur: onBlur,
300
+ onKeyDown: function onKeyDown(e) {
301
+ if (e.key === 'Enter') {
302
+ e.preventDefault();
303
+ }
304
+ },
305
+ className: cx('ant-input', {
306
+ 'ant-input-disabled': disabled
307
+ }, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow: auto;\n white-space: ", ";\n\n .ant-tag {\n display: inline;\n line-height: 19px;\n margin: 0 0.5em;\n padding: 2px 7px;\n border-radius: 10px;\n }\n "])), multiline ? 'normal' : 'nowrap')),
308
+ ref: inputRef,
309
+ contentEditable: !disabled,
310
+ dangerouslySetInnerHTML: {
311
+ __html: html
312
+ }
313
+ }), /*#__PURE__*/React.createElement(Tooltip, {
314
+ title: t('Use variable')
315
+ }, /*#__PURE__*/React.createElement(Cascader, {
316
+ value: [],
317
+ options: options,
318
+ onChange: onInsert
319
+ }, button !== null && button !== void 0 ? button : /*#__PURE__*/React.createElement(Button, {
320
+ className: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-style: italic;\n font-family: 'New York', 'Times New Roman', Times, serif;\n "])))
321
+ }, "x"))));
322
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare function Variable(): any;
3
+ export declare namespace Variable {
4
+ var Input: import("react").ForwardRefExoticComponent<Pick<Partial<any>, string | number | symbol> & import("react").RefAttributes<unknown>>;
5
+ var TextArea: import("react").ForwardRefExoticComponent<Pick<Partial<any>, string | number | symbol> & import("react").RefAttributes<unknown>>;
6
+ var JSON: import("react").ForwardRefExoticComponent<Pick<Partial<any>, string | number | symbol> & import("react").RefAttributes<unknown>>;
7
+ }
8
+ export default Variable;
@@ -0,0 +1,11 @@
1
+ import { connect } from '@formily/react';
2
+ import { Input } from "./Input";
3
+ import { TextArea } from "./TextArea";
4
+ import { JSONInput } from "./JSONInput";
5
+ export function Variable() {
6
+ return null;
7
+ }
8
+ Variable.Input = connect(Input);
9
+ Variable.TextArea = connect(TextArea);
10
+ Variable.JSON = connect(JSONInput);
11
+ export default Variable;
@@ -0,0 +1 @@
1
+ export * from './Variable';