@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,262 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Input = Input;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _react2 = require("@formily/react");
11
+
12
+ var _antd = require("antd");
13
+
14
+ var _icons = require("@ant-design/icons");
15
+
16
+ var _css = require("@emotion/css");
17
+
18
+ var _reactI18next = require("react-i18next");
19
+
20
+ var _moment = _interopRequireDefault(require("moment"));
21
+
22
+ var _ = require("../..");
23
+
24
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
29
+
30
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
31
+
32
+ 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."); }
33
+
34
+ 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); }
35
+
36
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
37
+
38
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
39
+
40
+ 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; }
41
+
42
+ 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); }
43
+
44
+ var JT_VALUE_RE = /^\s*{{\s*([^{}]+)\s*}}\s*$/;
45
+
46
+ function parseValue(value) {
47
+ if (value == null) {
48
+ return 'null';
49
+ }
50
+
51
+ var type = _typeof(value);
52
+
53
+ if (type === 'string') {
54
+ var matched = value.match(JT_VALUE_RE);
55
+
56
+ if (matched) {
57
+ return matched[1].split('.');
58
+ } // const ts = Date.parse(value);
59
+ // if (value.match(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d{0,3})Z$/) && !Number.isNaN(Date.parse(value))) {
60
+ // return {
61
+ // type: 'date',
62
+ // };
63
+ // }
64
+
65
+ }
66
+
67
+ return type === 'object' && value instanceof Date ? 'date' : type;
68
+ }
69
+
70
+ var ConstantTypes = {
71
+ string: {
72
+ label: "{{t(\"String\")}}",
73
+ value: 'string',
74
+ component: function component(_ref) {
75
+ var _onChange = _ref.onChange,
76
+ value = _ref.value;
77
+ return /*#__PURE__*/_react.default.createElement(_antd.Input, {
78
+ value: value,
79
+ onChange: function onChange(ev) {
80
+ return _onChange(ev.target.value);
81
+ }
82
+ });
83
+ },
84
+ default: ''
85
+ },
86
+ number: {
87
+ label: '{{t("Number")}}',
88
+ value: 'number',
89
+ component: function component(_ref2) {
90
+ var onChange = _ref2.onChange,
91
+ value = _ref2.value;
92
+ return /*#__PURE__*/_react.default.createElement(_antd.InputNumber, {
93
+ value: value,
94
+ onChange: onChange
95
+ });
96
+ },
97
+ default: 0
98
+ },
99
+ boolean: {
100
+ label: "{{t(\"Boolean\")}}",
101
+ value: 'boolean',
102
+ component: function component(_ref3) {
103
+ var onChange = _ref3.onChange,
104
+ value = _ref3.value;
105
+
106
+ var _useTranslation = (0, _reactI18next.useTranslation)(),
107
+ t = _useTranslation.t;
108
+
109
+ return /*#__PURE__*/_react.default.createElement(_antd.Select, {
110
+ value: value,
111
+ onChange: onChange,
112
+ placeholder: t('Select'),
113
+ options: [{
114
+ value: true,
115
+ label: t('True')
116
+ }, {
117
+ value: false,
118
+ label: t('False')
119
+ }]
120
+ });
121
+ },
122
+ default: false
123
+ },
124
+ date: {
125
+ label: '{{t("Date")}}',
126
+ value: 'date',
127
+ component: function component(_ref4) {
128
+ var _onChange2 = _ref4.onChange,
129
+ value = _ref4.value;
130
+ return /*#__PURE__*/_react.default.createElement(_antd.DatePicker, {
131
+ value: (0, _moment.default)(value),
132
+ onChange: function onChange(d) {
133
+ return d ? _onChange2(d.toDate()) : null;
134
+ },
135
+ allowClear: false,
136
+ showTime: true
137
+ });
138
+ },
139
+ default: function () {
140
+ var now = new Date();
141
+ return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);
142
+ }()
143
+ },
144
+ null: {
145
+ label: "{{t(\"Null\")}}",
146
+ value: 'null',
147
+ component: function component() {
148
+ var _useTranslation2 = (0, _reactI18next.useTranslation)(),
149
+ t = _useTranslation2.t;
150
+
151
+ return /*#__PURE__*/_react.default.createElement(_antd.Input, {
152
+ readOnly: true,
153
+ placeholder: t('Null'),
154
+ className: "null-value"
155
+ });
156
+ },
157
+ default: null
158
+ }
159
+ };
160
+
161
+ function Input(props) {
162
+ var _ConstantTypes$type;
163
+
164
+ var _props$value = props.value,
165
+ value = _props$value === void 0 ? '' : _props$value,
166
+ scope = props.scope,
167
+ onChange = props.onChange,
168
+ children = props.children,
169
+ button = props.button;
170
+ var parsed = parseValue(value);
171
+ var isConstant = typeof parsed === 'string';
172
+ var type = isConstant ? parsed : '';
173
+ var variable = isConstant ? null : parsed;
174
+ var ConstantComponent = (_ConstantTypes$type = ConstantTypes[type]) === null || _ConstantTypes$type === void 0 ? void 0 : _ConstantTypes$type.component;
175
+ var constantOptions = Object.values(ConstantTypes);
176
+ var compile = (0, _.useCompile)();
177
+
178
+ var _useTranslation3 = (0, _reactI18next.useTranslation)(),
179
+ t = _useTranslation3.t;
180
+
181
+ var options = compile([{
182
+ value: '',
183
+ label: t('Constant'),
184
+ children: children ? null : constantOptions
185
+ }].concat(_toConsumableArray(typeof scope === 'function' ? scope() : scope !== null && scope !== void 0 ? scope : [])));
186
+ var form = (0, _react2.useForm)();
187
+
188
+ function onSwitch(next) {
189
+ if (next[0] === '') {
190
+ if (next[1]) {
191
+ if (next[1] !== type) {
192
+ var _ConstantTypes$next$, _ConstantTypes$next$2;
193
+
194
+ 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);
195
+ }
196
+ } else {
197
+ if (variable) {
198
+ onChange(null);
199
+ }
200
+ }
201
+
202
+ return;
203
+ }
204
+
205
+ onChange("{{".concat(next.join('.'), "}}"));
206
+ }
207
+
208
+ var variableText = variable === null || variable === void 0 ? void 0 : variable.reduce(function (opts, key, i) {
209
+ var _ref5;
210
+
211
+ var option = (_ref5 = i ? opts[i - 1].children : options) === null || _ref5 === void 0 ? void 0 : _ref5.find(function (item) {
212
+ return item.value === key;
213
+ });
214
+ return option ? opts.concat(option) : opts;
215
+ }, []).map(function (item) {
216
+ return item.label;
217
+ }).join(' / ');
218
+ var disabled = props.disabled || form.disabled;
219
+ return /*#__PURE__*/_react.default.createElement(_antd.Input.Group, {
220
+ compact: true,
221
+ className: (0, _css.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 "])))
222
+ }, variable ? /*#__PURE__*/_react.default.createElement("div", {
223
+ className: (0, _css.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;')
224
+ }, /*#__PURE__*/_react.default.createElement("div", {
225
+ onInput: function onInput(e) {
226
+ return e.preventDefault();
227
+ },
228
+ onKeyDown: function onKeyDown(e) {
229
+ if (e.key !== 'Backspace') {
230
+ e.preventDefault();
231
+ return;
232
+ }
233
+
234
+ onChange(null);
235
+ },
236
+ className: (0, _css.cx)('ant-input', {
237
+ 'ant-input-disabled': disabled
238
+ }),
239
+ contentEditable: !disabled,
240
+ suppressContentEditableWarning: true
241
+ }, /*#__PURE__*/_react.default.createElement(_antd.Tag, {
242
+ contentEditable: false,
243
+ color: "blue"
244
+ }, variableText)), !disabled ? /*#__PURE__*/_react.default.createElement("span", {
245
+ className: (0, _css.cx)('ant-select-clear', (0, _css.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n user-select: 'none';\n "])))),
246
+ unselectable: "on",
247
+ "aria-hidden": true,
248
+ onClick: function onClick() {
249
+ return onChange(null);
250
+ }
251
+ }, /*#__PURE__*/_react.default.createElement(_icons.CloseCircleFilled, null)) : null) : children !== null && children !== void 0 ? children : /*#__PURE__*/_react.default.createElement(ConstantComponent, {
252
+ value: value,
253
+ onChange: onChange
254
+ }), options.length > 1 ? /*#__PURE__*/_react.default.createElement(_antd.Cascader, {
255
+ value: variable !== null && variable !== void 0 ? variable : [''].concat(_toConsumableArray(children ? [] : [type])),
256
+ options: options,
257
+ onChange: onSwitch
258
+ }, button !== null && button !== void 0 ? button : /*#__PURE__*/_react.default.createElement(_antd.Button, {
259
+ type: variable ? 'primary' : 'default',
260
+ className: (0, _css.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-style: italic;\n font-family: 'New York', 'Times New Roman', Times, serif;\n "])))
261
+ }, "x")) : null);
262
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function JSONInput(props: any): JSX.Element;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.JSONInput = JSONInput;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _antd = require("antd");
13
+
14
+ var _css = require("@emotion/css");
15
+
16
+ var _input = require("../input");
17
+
18
+ var _reactI18next = require("react-i18next");
19
+
20
+ var _templateObject, _templateObject2, _templateObject3;
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ 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; }
27
+
28
+ 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; }
29
+
30
+ 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; }
31
+
32
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
33
+
34
+ // NOTE: https://stackoverflow.com/questions/23892547/what-is-the-best-way-to-trigger-onchange-event-in-react-js/46012210#46012210
35
+ function setNativeInputValue(input, value) {
36
+ var nativeInputValueSetter = Object.getOwnPropertyDescriptor(input.constructor.prototype, 'value').set;
37
+ nativeInputValueSetter.call(input, value);
38
+ input.dispatchEvent(new Event('input', {
39
+ bubbles: true
40
+ }));
41
+ }
42
+
43
+ function JSONInput(props) {
44
+ var inputRef = (0, _react.useRef)(null);
45
+ var value = props.value,
46
+ _props$space = props.space,
47
+ space = _props$space === void 0 ? 2 : _props$space,
48
+ scope = props.scope;
49
+
50
+ var _useTranslation = (0, _reactI18next.useTranslation)(),
51
+ t = _useTranslation.t;
52
+
53
+ var options = typeof scope === 'function' ? scope() : scope !== null && scope !== void 0 ? scope : [];
54
+
55
+ function onFormat() {
56
+ if (!inputRef.current) {
57
+ return;
58
+ }
59
+
60
+ if (!value) {
61
+ return;
62
+ }
63
+
64
+ var textArea = inputRef.current.resizableTextArea.textArea;
65
+ var nextValue = JSON.stringify(value, null, space);
66
+ setNativeInputValue(textArea, nextValue);
67
+ textArea.setSelectionRange(nextValue.length, nextValue.length);
68
+ textArea.focus();
69
+ }
70
+
71
+ function onInsert(selected) {
72
+ if (!inputRef.current) {
73
+ return;
74
+ }
75
+
76
+ var variable = "{{".concat(selected.join('.'), "}}");
77
+ var textArea = inputRef.current.resizableTextArea.textArea;
78
+ var nextValue = textArea.value.slice(0, textArea.selectionStart) + variable + textArea.value.slice(textArea.selectionEnd);
79
+ var nextPos = [textArea.selectionStart, textArea.selectionStart + variable.length];
80
+ setNativeInputValue(textArea, nextValue);
81
+ textArea.setSelectionRange.apply(textArea, nextPos);
82
+ textArea.focus();
83
+ }
84
+
85
+ return /*#__PURE__*/_react.default.createElement("div", {
86
+ className: (0, _css.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n .ant-input{\n width: 100%;\n }\n "])))
87
+ }, /*#__PURE__*/_react.default.createElement(_input.Input.JSON, _objectSpread(_objectSpread({}, props), {}, {
88
+ ref: inputRef
89
+ })), /*#__PURE__*/_react.default.createElement(_antd.Button.Group, {
90
+ className: (0, _css.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n right: 0;\n top: 0;\n .ant-btn-sm{\n font-size: 85%;\n }\n "])))
91
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
92
+ onClick: onFormat
93
+ }, t('Prettify')), /*#__PURE__*/_react.default.createElement(_antd.Cascader, {
94
+ value: [],
95
+ options: options,
96
+ onChange: onInsert
97
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
98
+ className: (0, _css.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-style: italic;\n font-family: \"New York\", \"Times New Roman\", Times, serif;\n "])))
99
+ }, "x"))));
100
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function TextArea(props: any): JSX.Element;