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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/es/acl/ACLProvider.js +7 -8
  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 +18 -9
  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.d.ts +4 -0
  33. package/es/collection-manager/action-hooks.js +26 -12
  34. package/es/collection-manager/context.d.ts +4 -0
  35. package/es/collection-manager/context.js +5 -1
  36. package/es/collection-manager/hooks/useCollectionManager.d.ts +7 -0
  37. package/es/collection-manager/hooks/useCollectionManager.js +52 -7
  38. package/es/collection-manager/interfaces/m2m.js +2 -2
  39. package/es/collection-manager/interfaces/properties/index.d.ts +0 -56
  40. package/es/collection-manager/interfaces/properties/index.js +1 -2
  41. package/es/collection-manager/templates/calendar.js +1 -1
  42. package/es/collection-manager/templates/general.js +1 -1
  43. package/es/collection-manager/templates/properties/index.d.ts +12 -1
  44. package/es/collection-manager/templates/properties/index.js +11 -0
  45. package/es/i18n/i18n.js +3 -1
  46. package/es/locale/en_US.d.ts +23 -0
  47. package/es/locale/en_US.js +23 -0
  48. package/es/locale/ja_JP.d.ts +23 -0
  49. package/es/locale/ja_JP.js +24 -1
  50. package/es/locale/ru_RU.d.ts +1 -0
  51. package/es/locale/ru_RU.js +1 -0
  52. package/es/locale/zh_CN.d.ts +43 -4
  53. package/es/locale/zh_CN.js +44 -5
  54. package/es/route-switch/antd/admin-layout/index.js +13 -33
  55. package/es/schema-component/antd/action/Action.Designer.js +28 -15
  56. package/es/schema-component/antd/action/Action.js +28 -5
  57. package/es/schema-component/antd/action/utils.d.ts +1 -0
  58. package/es/schema-component/antd/action/utils.js +49 -0
  59. package/es/schema-component/antd/association-filter/AssociationFilter.js +4 -4
  60. package/es/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
  61. package/es/schema-component/antd/association-select/useServiceOptions.js +47 -6
  62. package/es/schema-component/antd/calendar/Calendar.Designer.js +17 -36
  63. package/es/schema-component/antd/checkbox/Checkbox.js +9 -8
  64. package/es/schema-component/antd/date-picker/util.d.ts +1 -1
  65. package/es/schema-component/antd/date-picker/util.js +1 -1
  66. package/es/schema-component/antd/filter/DynamicComponent.js +3 -1
  67. package/es/schema-component/antd/filter/Filter.js +2 -1
  68. package/es/schema-component/antd/filter/FilterGroup.js +7 -4
  69. package/es/schema-component/antd/filter/FilterItem.js +3 -2
  70. package/es/schema-component/antd/filter/context.d.ts +1 -0
  71. package/es/schema-component/antd/filter/useValues.js +14 -11
  72. package/es/schema-component/antd/form/Form.js +11 -5
  73. package/es/schema-component/antd/form-item/FormItem.js +17 -8
  74. package/es/schema-component/antd/form-v2/Form.Designer.js +2 -0
  75. package/es/schema-component/antd/form-v2/Form.js +94 -7
  76. package/es/schema-component/antd/form-v2/utils.d.ts +5 -0
  77. package/es/schema-component/antd/form-v2/utils.js +161 -0
  78. package/es/schema-component/antd/g2plot/G2Plot.js +3 -1
  79. package/es/schema-component/antd/grid/Grid.js +10 -5
  80. package/es/schema-component/antd/icon-picker/IconPicker.js +1 -0
  81. package/es/schema-component/antd/index.d.ts +1 -0
  82. package/es/schema-component/antd/index.js +1 -0
  83. package/es/schema-component/antd/input/Input.d.ts +2 -1
  84. package/es/schema-component/antd/input/Json.d.ts +5 -3
  85. package/es/schema-component/antd/input/Json.js +3 -2
  86. package/es/schema-component/antd/input/ReadPretty.js +1 -1
  87. package/es/schema-component/antd/input-number/InputNumber.js +3 -1
  88. package/es/schema-component/antd/page/FixedBlock.js +3 -1
  89. package/es/schema-component/antd/page/Page.js +11 -5
  90. package/es/schema-component/antd/page/PageTabDesigner.js +3 -3
  91. package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  92. package/es/schema-component/antd/record-picker/RecordPicker.js +1 -2
  93. package/es/schema-component/antd/record-picker/util.js +7 -0
  94. package/es/schema-component/antd/remote-select/RemoteSelect.d.ts +2 -0
  95. package/es/schema-component/antd/remote-select/RemoteSelect.js +78 -36
  96. package/es/schema-component/antd/rich-text/RichText.js +4 -2
  97. package/es/schema-component/antd/select/Select.js +14 -4
  98. package/es/schema-component/antd/table/Table.Array.js +10 -3
  99. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
  100. package/es/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
  101. package/es/schema-component/antd/tabs/Tabs.Designer.js +1 -0
  102. package/es/schema-component/antd/tabs/Tabs.js +1 -0
  103. package/es/schema-component/antd/time-picker/TimePicker.js +1 -1
  104. package/es/schema-component/antd/variable/Input.d.ts +2 -0
  105. package/es/schema-component/antd/variable/Input.js +244 -0
  106. package/es/schema-component/antd/variable/JSONInput.d.ts +2 -0
  107. package/es/schema-component/antd/variable/JSONInput.js +82 -0
  108. package/es/schema-component/antd/variable/TextArea.d.ts +2 -0
  109. package/es/schema-component/antd/variable/TextArea.js +322 -0
  110. package/es/schema-component/antd/variable/Variable.d.ts +8 -0
  111. package/es/schema-component/antd/variable/Variable.js +11 -0
  112. package/es/schema-component/antd/variable/index.d.ts +1 -0
  113. package/es/schema-component/antd/variable/index.js +1 -0
  114. package/es/schema-component/common/sortable-item/SortableItem.js +36 -6
  115. package/es/schema-component/common/utils/logic.js +523 -0
  116. package/es/schema-component/common/utils/uitls.d.ts +1 -0
  117. package/es/schema-component/common/utils/uitls.js +89 -0
  118. package/es/schema-initializer/SchemaInitializer.js +9 -4
  119. package/es/schema-initializer/buttons/BlockInitializers.d.ts +2 -184
  120. package/es/schema-initializer/buttons/BlockInitializers.js +1 -102
  121. package/es/schema-initializer/buttons/RecordBlockInitializers.js +72 -16
  122. package/es/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
  123. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -3
  124. package/es/schema-initializer/components/CreateRecordAction.d.ts +3 -0
  125. package/es/schema-initializer/components/CreateRecordAction.js +174 -0
  126. package/es/schema-initializer/components/index.d.ts +1 -0
  127. package/es/schema-initializer/components/index.js +2 -1
  128. package/es/schema-initializer/index.d.ts +2 -1
  129. package/es/schema-initializer/index.js +2 -1
  130. package/es/schema-initializer/items/CalendarBlockInitializer.js +24 -41
  131. package/es/schema-initializer/items/CreateActionInitializer.js +3 -3
  132. package/es/schema-initializer/items/RecordFormBlockInitializer.js +9 -9
  133. package/es/schema-initializer/items/index.d.ts +4 -4
  134. package/es/schema-initializer/items/index.js +6 -6
  135. package/es/schema-initializer/utils.js +22 -7
  136. package/es/schema-settings/EnableChildCollections/index.d.ts +2 -0
  137. package/es/schema-settings/EnableChildCollections/index.js +141 -0
  138. package/es/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
  139. package/es/schema-settings/LinkageRules/DynamicComponent.js +113 -0
  140. package/es/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
  141. package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +15 -0
  142. package/es/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
  143. package/es/schema-settings/LinkageRules/LinkageRuleAction.js +162 -0
  144. package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
  145. package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.js +71 -0
  146. package/es/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
  147. package/es/schema-settings/LinkageRules/ValueDynamicComponent.js +82 -0
  148. package/es/schema-settings/LinkageRules/Variables.d.ts +7 -0
  149. package/es/schema-settings/LinkageRules/Variables.js +115 -0
  150. package/es/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
  151. package/es/schema-settings/LinkageRules/action-hooks.js +115 -0
  152. package/es/schema-settings/LinkageRules/context.d.ts +13 -0
  153. package/es/schema-settings/LinkageRules/context.js +4 -0
  154. package/es/schema-settings/LinkageRules/index.d.ts +2 -0
  155. package/es/schema-settings/LinkageRules/index.js +132 -0
  156. package/es/schema-settings/LinkageRules/type.d.ts +13 -0
  157. package/es/schema-settings/LinkageRules/type.js +15 -0
  158. package/es/schema-settings/LinkageRules/useValues.d.ts +1 -0
  159. package/es/schema-settings/LinkageRules/useValues.js +84 -0
  160. package/es/schema-settings/SchemaSettings.d.ts +4 -1
  161. package/es/schema-settings/SchemaSettings.js +219 -26
  162. package/es/schema-templates/BlockTemplate.js +9 -1
  163. package/es/system-settings/SystemSettingsShortcut.js +1 -1
  164. package/lib/acl/ACLProvider.js +7 -8
  165. package/lib/api-client/APIClient.js +6 -0
  166. package/lib/block-provider/BlockProvider.js +9 -6
  167. package/lib/block-provider/FormBlockProvider.js +17 -8
  168. package/lib/block-provider/KanbanBlockProvider.js +1 -1
  169. package/lib/block-provider/SharedFilterProvider.js +9 -3
  170. package/lib/block-provider/TableBlockProvider.js +1 -1
  171. package/lib/block-provider/TableSelectorProvider.js +2 -2
  172. package/lib/block-provider/hooks/index.js +23 -7
  173. package/lib/collection-manager/CollectionManagerProvider.d.ts +1 -0
  174. package/lib/collection-manager/CollectionManagerProvider.js +81 -16
  175. package/lib/collection-manager/CollectionManagerShortcut.js +36 -23
  176. package/lib/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
  177. package/lib/collection-manager/Configuration/AddCategoryAction.js +145 -0
  178. package/lib/collection-manager/Configuration/AddCollectionAction.js +8 -3
  179. package/lib/collection-manager/Configuration/AddFieldAction.js +1 -0
  180. package/lib/collection-manager/Configuration/ConfigurationTable.js +34 -4
  181. package/lib/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
  182. package/lib/collection-manager/Configuration/ConfigurationTabs.js +407 -0
  183. package/lib/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
  184. package/lib/collection-manager/Configuration/EditCategoryAction.js +178 -0
  185. package/lib/collection-manager/Configuration/EditCollectionAction.js +6 -2
  186. package/lib/collection-manager/Configuration/OverridingCollectionField.js +17 -8
  187. package/lib/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
  188. package/lib/collection-manager/Configuration/components/CollectionCategory.js +27 -0
  189. package/lib/collection-manager/Configuration/index.d.ts +3 -0
  190. package/lib/collection-manager/Configuration/index.js +39 -0
  191. package/lib/collection-manager/Configuration/schemas/collections.d.ts +3 -0
  192. package/lib/collection-manager/Configuration/schemas/collections.js +316 -178
  193. package/lib/collection-manager/Configuration/templates.d.ts +1 -0
  194. package/lib/collection-manager/Configuration/templates.js +2 -0
  195. package/lib/collection-manager/action-hooks.d.ts +4 -0
  196. package/lib/collection-manager/action-hooks.js +30 -13
  197. package/lib/collection-manager/context.d.ts +4 -0
  198. package/lib/collection-manager/context.js +7 -2
  199. package/lib/collection-manager/hooks/useCollectionManager.d.ts +7 -0
  200. package/lib/collection-manager/hooks/useCollectionManager.js +52 -6
  201. package/lib/collection-manager/interfaces/m2m.js +2 -2
  202. package/lib/collection-manager/interfaces/properties/index.d.ts +0 -56
  203. package/lib/collection-manager/interfaces/properties/index.js +1 -2
  204. package/lib/collection-manager/templates/calendar.js +1 -1
  205. package/lib/collection-manager/templates/general.js +1 -1
  206. package/lib/collection-manager/templates/properties/index.d.ts +12 -1
  207. package/lib/collection-manager/templates/properties/index.js +11 -0
  208. package/lib/i18n/i18n.js +3 -1
  209. package/lib/locale/en_US.d.ts +23 -0
  210. package/lib/locale/en_US.js +23 -0
  211. package/lib/locale/ja_JP.d.ts +23 -0
  212. package/lib/locale/ja_JP.js +24 -1
  213. package/lib/locale/ru_RU.d.ts +1 -0
  214. package/lib/locale/ru_RU.js +1 -0
  215. package/lib/locale/zh_CN.d.ts +43 -4
  216. package/lib/locale/zh_CN.js +44 -5
  217. package/lib/route-switch/antd/admin-layout/index.js +13 -33
  218. package/lib/schema-component/antd/action/Action.Designer.js +30 -14
  219. package/lib/schema-component/antd/action/Action.js +29 -3
  220. package/lib/schema-component/antd/action/utils.d.ts +1 -0
  221. package/lib/schema-component/antd/action/utils.js +58 -2
  222. package/lib/schema-component/antd/association-filter/AssociationFilter.js +3 -3
  223. package/lib/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
  224. package/lib/schema-component/antd/association-select/useServiceOptions.js +47 -4
  225. package/lib/schema-component/antd/calendar/Calendar.Designer.js +15 -33
  226. package/lib/schema-component/antd/checkbox/Checkbox.js +8 -7
  227. package/lib/schema-component/antd/date-picker/util.d.ts +1 -1
  228. package/lib/schema-component/antd/date-picker/util.js +1 -1
  229. package/lib/schema-component/antd/filter/DynamicComponent.js +3 -1
  230. package/lib/schema-component/antd/filter/Filter.js +2 -1
  231. package/lib/schema-component/antd/filter/FilterGroup.js +7 -4
  232. package/lib/schema-component/antd/filter/FilterItem.js +3 -2
  233. package/lib/schema-component/antd/filter/context.d.ts +1 -0
  234. package/lib/schema-component/antd/filter/useValues.js +15 -11
  235. package/lib/schema-component/antd/form/Form.js +9 -3
  236. package/lib/schema-component/antd/form-item/FormItem.js +21 -7
  237. package/lib/schema-component/antd/form-v2/Form.Designer.js +2 -0
  238. package/lib/schema-component/antd/form-v2/Form.js +93 -5
  239. package/lib/schema-component/antd/form-v2/utils.d.ts +5 -0
  240. package/lib/schema-component/antd/form-v2/utils.js +181 -0
  241. package/lib/schema-component/antd/g2plot/G2Plot.js +3 -1
  242. package/lib/schema-component/antd/grid/Grid.js +10 -5
  243. package/lib/schema-component/antd/icon-picker/IconPicker.js +1 -0
  244. package/lib/schema-component/antd/index.d.ts +1 -0
  245. package/lib/schema-component/antd/index.js +13 -0
  246. package/lib/schema-component/antd/input/Input.d.ts +2 -1
  247. package/lib/schema-component/antd/input/Json.d.ts +5 -3
  248. package/lib/schema-component/antd/input/Json.js +6 -3
  249. package/lib/schema-component/antd/input/ReadPretty.js +1 -1
  250. package/lib/schema-component/antd/input-number/InputNumber.js +2 -0
  251. package/lib/schema-component/antd/page/FixedBlock.js +3 -1
  252. package/lib/schema-component/antd/page/Page.js +14 -5
  253. package/lib/schema-component/antd/page/PageTabDesigner.js +1 -1
  254. package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  255. package/lib/schema-component/antd/record-picker/RecordPicker.js +1 -2
  256. package/lib/schema-component/antd/record-picker/util.js +7 -0
  257. package/lib/schema-component/antd/remote-select/RemoteSelect.d.ts +2 -0
  258. package/lib/schema-component/antd/remote-select/RemoteSelect.js +78 -37
  259. package/lib/schema-component/antd/rich-text/RichText.js +4 -2
  260. package/lib/schema-component/antd/select/Select.js +14 -4
  261. package/lib/schema-component/antd/table/Table.Array.js +8 -1
  262. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
  263. package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
  264. package/lib/schema-component/antd/tabs/Tabs.Designer.js +1 -0
  265. package/lib/schema-component/antd/tabs/Tabs.js +1 -0
  266. package/lib/schema-component/antd/time-picker/TimePicker.js +1 -1
  267. package/lib/schema-component/antd/variable/Input.d.ts +2 -0
  268. package/lib/schema-component/antd/variable/Input.js +262 -0
  269. package/lib/schema-component/antd/variable/JSONInput.d.ts +2 -0
  270. package/lib/schema-component/antd/variable/JSONInput.js +100 -0
  271. package/lib/schema-component/antd/variable/TextArea.d.ts +2 -0
  272. package/lib/schema-component/antd/variable/TextArea.js +341 -0
  273. package/lib/schema-component/antd/variable/Variable.d.ts +8 -0
  274. package/lib/schema-component/antd/variable/Variable.js +25 -0
  275. package/lib/schema-component/antd/variable/index.d.ts +1 -0
  276. package/lib/schema-component/antd/variable/index.js +18 -0
  277. package/lib/schema-component/common/sortable-item/SortableItem.js +36 -6
  278. package/lib/schema-component/common/utils/logic.js +525 -0
  279. package/lib/schema-component/common/utils/uitls.d.ts +1 -0
  280. package/lib/schema-component/common/utils/uitls.js +103 -0
  281. package/lib/schema-initializer/SchemaInitializer.js +9 -4
  282. package/lib/schema-initializer/buttons/BlockInitializers.d.ts +2 -184
  283. package/lib/schema-initializer/buttons/BlockInitializers.js +0 -108
  284. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +72 -16
  285. package/lib/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
  286. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +3 -1
  287. package/lib/schema-initializer/components/CreateRecordAction.d.ts +3 -0
  288. package/lib/schema-initializer/components/CreateRecordAction.js +199 -0
  289. package/lib/schema-initializer/components/index.d.ts +1 -0
  290. package/lib/schema-initializer/components/index.js +13 -0
  291. package/lib/schema-initializer/index.d.ts +2 -1
  292. package/lib/schema-initializer/index.js +51 -2
  293. package/lib/schema-initializer/items/CalendarBlockInitializer.js +16 -33
  294. package/lib/schema-initializer/items/CreateActionInitializer.js +3 -3
  295. package/lib/schema-initializer/items/RecordFormBlockInitializer.js +3 -3
  296. package/lib/schema-initializer/items/index.d.ts +4 -4
  297. package/lib/schema-initializer/items/index.js +52 -52
  298. package/lib/schema-initializer/utils.js +22 -6
  299. package/lib/schema-settings/EnableChildCollections/index.d.ts +2 -0
  300. package/lib/schema-settings/EnableChildCollections/index.js +156 -0
  301. package/lib/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
  302. package/lib/schema-settings/LinkageRules/DynamicComponent.js +139 -0
  303. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
  304. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +27 -0
  305. package/lib/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
  306. package/lib/schema-settings/LinkageRules/LinkageRuleAction.js +190 -0
  307. package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
  308. package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.js +90 -0
  309. package/lib/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
  310. package/lib/schema-settings/LinkageRules/ValueDynamicComponent.js +104 -0
  311. package/lib/schema-settings/LinkageRules/Variables.d.ts +7 -0
  312. package/lib/schema-settings/LinkageRules/Variables.js +124 -0
  313. package/lib/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
  314. package/lib/schema-settings/LinkageRules/action-hooks.js +127 -0
  315. package/lib/schema-settings/LinkageRules/context.d.ts +13 -0
  316. package/lib/schema-settings/LinkageRules/context.js +15 -0
  317. package/lib/schema-settings/LinkageRules/index.d.ts +2 -0
  318. package/lib/schema-settings/LinkageRules/index.js +149 -0
  319. package/lib/schema-settings/LinkageRules/type.d.ts +13 -0
  320. package/lib/schema-settings/LinkageRules/type.js +22 -0
  321. package/lib/schema-settings/LinkageRules/useValues.d.ts +1 -0
  322. package/lib/schema-settings/LinkageRules/useValues.js +95 -0
  323. package/lib/schema-settings/SchemaSettings.d.ts +4 -1
  324. package/lib/schema-settings/SchemaSettings.js +243 -48
  325. package/lib/schema-templates/BlockTemplate.js +9 -1
  326. package/lib/system-settings/SystemSettingsShortcut.js +1 -1
  327. package/package.json +4 -4
@@ -19,12 +19,14 @@ export var RichText = connect(function (props) {
19
19
  };
20
20
  var formats = ['header', 'bold', 'italic', 'underline', 'strike', 'blockquote', 'list', 'bullet', 'indent', 'link', 'image'];
21
21
  var value = props.value,
22
- onChange = props.onChange;
22
+ onChange = props.onChange,
23
+ disabled = props.disabled;
23
24
  return /*#__PURE__*/React.createElement(ReactQuill, {
24
25
  modules: modules,
25
26
  formats: formats,
26
27
  value: typeof value === 'string' ? value : '',
27
- onChange: onChange
28
+ onChange: onChange,
29
+ readOnly: disabled
28
30
  });
29
31
  }, mapReadPretty(function (props) {
30
32
  return /*#__PURE__*/React.createElement(InputReadPretty.Html, _objectSpread({}, props));
@@ -1,5 +1,5 @@
1
1
  var _excluded = ["value", "options", "onChange", "fieldNames", "mode"],
2
- _excluded2 = ["objectValue"];
2
+ _excluded2 = ["objectValue", "value"];
3
3
 
4
4
  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; }
5
5
 
@@ -99,12 +99,22 @@ var filterOption = function filterOption(input, option) {
99
99
 
100
100
  var InternalSelect = connect(function (props) {
101
101
  var objectValue = props.objectValue,
102
+ value = props.value,
102
103
  others = _objectWithoutProperties(props, _excluded2);
103
104
 
104
105
  var mode = props.mode || props.multiple ? 'multiple' : undefined;
105
106
 
107
+ var toValue = function toValue(v) {
108
+ if (['multiple', 'tags'].includes(mode)) {
109
+ return v || [];
110
+ }
111
+
112
+ return v;
113
+ };
114
+
106
115
  if (objectValue) {
107
116
  return /*#__PURE__*/React.createElement(ObjectSelect, _objectSpread(_objectSpread({}, others), {}, {
117
+ value: toValue(value),
108
118
  mode: mode
109
119
  }));
110
120
  }
@@ -112,7 +122,8 @@ var InternalSelect = connect(function (props) {
112
122
  return /*#__PURE__*/React.createElement(AntdSelect, _objectSpread(_objectSpread({
113
123
  showSearch: true,
114
124
  filterOption: filterOption,
115
- allowClear: true
125
+ allowClear: true,
126
+ value: toValue(value)
116
127
  }, others), {}, {
117
128
  onChange: function onChange(changed) {
118
129
  var _props$onChange;
@@ -122,8 +133,7 @@ var InternalSelect = connect(function (props) {
122
133
  mode: mode
123
134
  }));
124
135
  }, mapProps({
125
- dataSource: 'options',
126
- loading: true
136
+ dataSource: 'options'
127
137
  }, function (props, field) {
128
138
  return _objectSpread(_objectSpread({}, props), {}, {
129
139
  fieldNames: _objectSpread(_objectSpread({}, defaultFieldNames), props.fieldNames),
@@ -32,10 +32,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
32
32
 
33
33
  import { MenuOutlined } from '@ant-design/icons';
34
34
  import { css } from '@emotion/css';
35
- import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
35
+ import { observer, RecursionField, useField, useFieldSchema, SchemaExpressionScopeContext } from '@formily/react';
36
36
  import { Table } from 'antd';
37
37
  import { default as classNames, default as cls } from 'classnames';
38
- import React, { useState } from 'react';
38
+ import React, { useState, useContext } from 'react';
39
39
  import ReactDragListView from 'react-drag-listview';
40
40
  import { DndContext } from '../..';
41
41
  import { RecordIndexProvider, RecordProvider, useRequest, useSchemaInitializer } from '../../../';
@@ -46,6 +46,11 @@ var isColumnComponent = function isColumnComponent(schema) {
46
46
  return ((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : _schema$xComponent.endsWith('.Column')) > -1;
47
47
  };
48
48
 
49
+ var useScope = function useScope(key) {
50
+ var scope = useContext(SchemaExpressionScopeContext);
51
+ return scope[key] !== false;
52
+ };
53
+
49
54
  var useTableColumns = function useTableColumns() {
50
55
  var start = Date.now();
51
56
  var field = useField();
@@ -56,9 +61,11 @@ var useTableColumns = function useTableColumns() {
56
61
  render = _useSchemaInitializer.render;
57
62
 
58
63
  var columns = schema.reduceProperties(function (buf, s) {
59
- if (isColumnComponent(s)) {
64
+ if (isColumnComponent(s) && useScope(s['x-visible'])) {
60
65
  return buf.concat([s]);
61
66
  }
67
+
68
+ return buf;
62
69
  }, []).map(function (s) {
63
70
  return {
64
71
  title: /*#__PURE__*/React.createElement(RecursionField, {
@@ -37,7 +37,7 @@ var useLabelFields = function useLabelFields(collectionName) {
37
37
  };
38
38
 
39
39
  export var TableColumnDesigner = function TableColumnDesigner(props) {
40
- var _fieldSchema$xCompon, _uiSchema$xComponent, _collectionField$uiSc, _columnSchema$xCompo;
40
+ var _fieldSchema$xCompon, _uiSchema$xComponent, _collectionField$targ, _collectionField$uiSc, _columnSchema$xCompo;
41
41
 
42
42
  var uiSchema = props.uiSchema,
43
43
  fieldSchema = props.fieldSchema,
@@ -57,7 +57,7 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
57
57
  dn = _useDesignable.dn;
58
58
 
59
59
  var fieldNames = (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon['fieldNames']) || (uiSchema === null || uiSchema === void 0 ? void 0 : (_uiSchema$xComponent = uiSchema['x-component-props']) === null || _uiSchema$xComponent === void 0 ? void 0 : _uiSchema$xComponent['fieldNames']);
60
- var options = useLabelFields(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
60
+ var options = useLabelFields((_collectionField$targ = collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) !== null && _collectionField$targ !== void 0 ? _collectionField$targ : collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetCollection);
61
61
  var intefaceCfg = getInterface(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
62
62
  return /*#__PURE__*/React.createElement(GeneralSchemaDesigner, {
63
63
  disableInitializer: true
@@ -29,7 +29,7 @@ import { useSchemaTemplate } from '../../../schema-templates';
29
29
  import { useDesignable } from '../../hooks';
30
30
  import { useFixedBlockDesignerSetting } from '../page';
31
31
  export var TableBlockDesigner = function TableBlockDesigner() {
32
- var _fieldSchema$xDecora, _fieldSchema$xDecora$, _fieldSchema$xDecora2, _fieldSchema$xDecora3, _fieldSchema$xDecora4, _field$decoratorProps, _field$decoratorProps2;
32
+ var _fieldSchema$xDecora, _fieldSchema$xDecora$, _fieldSchema$xDecora2, _fieldSchema$xDecora3, _fieldSchema$xDecora4, _fieldSchema$xDecora5, _field$decoratorProps, _field$decoratorProps2;
33
33
 
34
34
  var _useCollection = useCollection(),
35
35
  name = _useCollection.name,
@@ -54,6 +54,7 @@ export var TableBlockDesigner = function TableBlockDesigner() {
54
54
  var defaultFilter = (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xDecora = fieldSchema['x-decorator-props']) === null || _fieldSchema$xDecora === void 0 ? void 0 : (_fieldSchema$xDecora$ = _fieldSchema$xDecora.params) === null || _fieldSchema$xDecora$ === void 0 ? void 0 : _fieldSchema$xDecora$.filter) || {};
55
55
  var defaultSort = (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xDecora2 = fieldSchema['x-decorator-props']) === null || _fieldSchema$xDecora2 === void 0 ? void 0 : (_fieldSchema$xDecora3 = _fieldSchema$xDecora2.params) === null || _fieldSchema$xDecora3 === void 0 ? void 0 : _fieldSchema$xDecora3.sort) || [];
56
56
  var defaultResource = fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xDecora4 = fieldSchema['x-decorator-props']) === null || _fieldSchema$xDecora4 === void 0 ? void 0 : _fieldSchema$xDecora4.resource;
57
+ var supportTemplate = !(fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xDecora5 = fieldSchema['x-decorator-props']) === null || _fieldSchema$xDecora5 === void 0 ? void 0 : _fieldSchema$xDecora5.disableTemplate);
57
58
  var sort = defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort.map(function (item) {
58
59
  return item.startsWith('-') ? {
59
60
  field: item.substring(1),
@@ -241,7 +242,7 @@ export var TableBlockDesigner = function TableBlockDesigner() {
241
242
  schema: (_schema4 = {}, _defineProperty(_schema4, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema4, 'x-decorator-props', fieldSchema['x-decorator-props']), _schema4)
242
243
  });
243
244
  }
244
- }), /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Template, {
245
+ }), supportTemplate && /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), supportTemplate && /*#__PURE__*/React.createElement(SchemaSettings.Template, {
245
246
  componentName: 'Table',
246
247
  collectionName: name,
247
248
  resourceName: defaultResource
@@ -18,6 +18,7 @@ export var TabsDesigner = function TabsDesigner() {
18
18
  return /*#__PURE__*/React.createElement(GeneralSchemaDesigner, {
19
19
  disableInitializer: true
20
20
  }, /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
21
+ key: "edit",
21
22
  title: t('Edit'),
22
23
  schema: {
23
24
  type: 'object',
@@ -19,6 +19,7 @@ export var Tabs = observer(function (props) {
19
19
  render = _useSchemaInitializer.render;
20
20
 
21
21
  return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement(AntdTabs, {
22
+ style: props.style,
22
23
  tabBarExtraContent: {
23
24
  right: render()
24
25
  }
@@ -10,7 +10,7 @@ import { TimePicker as AntdTimePicker } from 'antd';
10
10
  import { ReadPretty } from './ReadPretty';
11
11
 
12
12
  var mapTimeFormat = function mapTimeFormat() {
13
- return function (props) {
13
+ return function (props, field) {
14
14
  var format = props['format'] || 'HH:mm:ss';
15
15
  var _onChange = props.onChange;
16
16
  return _objectSpread(_objectSpread({}, props), {}, {
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function Input(props: any): JSX.Element;
@@ -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;