amis 1.4.2-beta.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. package/lib/Schema.d.ts +11 -3
  2. package/lib/Schema.js.map +1 -1
  3. package/lib/components/Alert2.d.ts +26 -21
  4. package/lib/components/Alert2.js +11 -4
  5. package/lib/components/Alert2.js.map +2 -2
  6. package/lib/components/AnchorNav.d.ts +22 -21
  7. package/lib/components/AnchorNav.js +7 -3
  8. package/lib/components/AnchorNav.js.map +2 -2
  9. package/lib/components/ArrayInput.d.ts +84 -84
  10. package/lib/components/AssociatedSelection.d.ts +930 -0
  11. package/lib/components/AssociatedSelection.js +89 -0
  12. package/lib/components/AssociatedSelection.js.map +13 -0
  13. package/lib/components/Badge.js +2 -2
  14. package/lib/components/Badge.js.map +2 -2
  15. package/lib/components/Button.js +1 -1
  16. package/lib/components/Button.js.map +2 -2
  17. package/lib/components/{ChainedCheckboxes.d.ts → ChainedSelection.d.ts} +267 -98
  18. package/lib/components/{ChainedCheckboxes.js → ChainedSelection.js} +30 -24
  19. package/lib/components/ChainedSelection.js.map +13 -0
  20. package/lib/components/Checkbox.d.ts +20 -20
  21. package/lib/components/Collapse.d.ts +51 -23
  22. package/lib/components/Collapse.js +70 -11
  23. package/lib/components/Collapse.js.map +2 -2
  24. package/lib/components/CollapseGroup.d.ts +88 -0
  25. package/lib/components/CollapseGroup.js +81 -0
  26. package/lib/components/CollapseGroup.js.map +13 -0
  27. package/lib/components/ColorPicker.d.ts +89 -85
  28. package/lib/components/ColorPicker.js +17 -4
  29. package/lib/components/ColorPicker.js.map +2 -2
  30. package/lib/components/DatePicker.d.ts +84 -84
  31. package/lib/components/DateRangePicker.d.ts +84 -84
  32. package/lib/components/Drawer.js +2 -2
  33. package/lib/components/Drawer.js.map +2 -2
  34. package/lib/components/Editor.d.ts +84 -84
  35. package/lib/components/GridNav.d.ts +52 -0
  36. package/lib/components/GridNav.js +123 -0
  37. package/lib/components/GridNav.js.map +13 -0
  38. package/lib/components/GroupedSelection.d.ts +907 -0
  39. package/lib/components/GroupedSelection.js +48 -0
  40. package/lib/components/GroupedSelection.js.map +13 -0
  41. package/lib/components/InputBox.d.ts +22 -21
  42. package/lib/components/InputBox.js +10 -2
  43. package/lib/components/InputBox.js.map +2 -2
  44. package/lib/components/Link.d.ts +29 -36
  45. package/lib/components/Link.js +14 -15
  46. package/lib/components/Link.js.map +2 -2
  47. package/lib/components/ListGroup.d.ts +21 -21
  48. package/lib/components/ModalManager.js +1 -1
  49. package/lib/components/ModalManager.js.map +2 -2
  50. package/lib/components/MonthRangePicker.d.ts +84 -84
  51. package/lib/components/NumberInput.d.ts +20 -20
  52. package/lib/components/Overlay.js +5 -0
  53. package/lib/components/Overlay.js.map +2 -2
  54. package/lib/components/PickerColumn.d.ts +514 -0
  55. package/lib/components/PickerColumn.js +279 -0
  56. package/lib/components/PickerColumn.js.map +13 -0
  57. package/lib/components/PickerContainer.d.ts +513 -0
  58. package/lib/components/PickerContainer.js +96 -0
  59. package/lib/components/PickerContainer.js.map +13 -0
  60. package/lib/components/PopOver.d.ts +1 -0
  61. package/lib/components/PopOver.js +12 -1
  62. package/lib/components/PopOver.js.map +2 -2
  63. package/lib/components/Progress.d.ts +85 -0
  64. package/lib/components/Progress.js +81 -0
  65. package/lib/components/Progress.js.map +13 -0
  66. package/lib/components/Radios.d.ts +22 -21
  67. package/lib/components/Radios.js +1 -0
  68. package/lib/components/Radios.js.map +2 -2
  69. package/lib/components/Rating.d.ts +21 -21
  70. package/lib/components/ResultBox.d.ts +84 -84
  71. package/lib/components/ResultBox.js +10 -2
  72. package/lib/components/ResultBox.js.map +2 -2
  73. package/lib/components/SearchBox.d.ts +84 -84
  74. package/lib/components/Select.d.ts +245 -237
  75. package/lib/components/Select.js +25 -4
  76. package/lib/components/Select.js.map +2 -2
  77. package/lib/components/{Checkboxes.d.ts → Selection.d.ts} +273 -98
  78. package/lib/components/Selection.js +134 -0
  79. package/lib/components/Selection.js.map +13 -0
  80. package/lib/components/{TableCheckboxes.d.ts → TableSelection.d.ts} +266 -96
  81. package/lib/components/{TableCheckboxes.js → TableSelection.js} +30 -30
  82. package/lib/components/TableSelection.js.map +13 -0
  83. package/lib/components/Tabs.d.ts +20 -20
  84. package/lib/components/TabsTransfer.d.ts +84 -84
  85. package/lib/components/TabsTransfer.js +9 -9
  86. package/lib/components/TabsTransfer.js.map +2 -2
  87. package/lib/components/TabsTransferPicker.d.ts +489 -0
  88. package/lib/components/TabsTransferPicker.js +60 -0
  89. package/lib/components/TabsTransferPicker.js.map +13 -0
  90. package/lib/components/Toast.d.ts +90 -87
  91. package/lib/components/Toast.js +15 -5
  92. package/lib/components/Toast.js.map +2 -2
  93. package/lib/components/Transfer.d.ts +908 -274
  94. package/lib/components/Transfer.js +31 -24
  95. package/lib/components/Transfer.js.map +2 -2
  96. package/lib/components/TransferDropDown.d.ts +488 -0
  97. package/lib/components/TransferDropDown.js +59 -0
  98. package/lib/components/TransferDropDown.js.map +13 -0
  99. package/lib/components/TransferPicker.d.ts +493 -0
  100. package/lib/components/TransferPicker.js +60 -0
  101. package/lib/components/TransferPicker.js.map +13 -0
  102. package/lib/components/Tree.d.ts +115 -84
  103. package/lib/components/Tree.js +183 -30
  104. package/lib/components/Tree.js.map +2 -2
  105. package/lib/components/{TreeCheckboxes.d.ts → TreeSelection.d.ts} +269 -99
  106. package/lib/components/{TreeCheckboxes.js → TreeSelection.js} +36 -32
  107. package/lib/components/TreeSelection.js.map +13 -0
  108. package/lib/components/condition-builder/Field.js +4 -2
  109. package/lib/components/condition-builder/Field.js.map +2 -2
  110. package/lib/components/condition-builder/Func.js +2 -2
  111. package/lib/components/condition-builder/Func.js.map +2 -2
  112. package/lib/components/condition-builder/InputSwitch.js +2 -2
  113. package/lib/components/condition-builder/InputSwitch.js.map +2 -2
  114. package/lib/components/condition-builder/Item.js +3 -3
  115. package/lib/components/condition-builder/Item.js.map +2 -2
  116. package/lib/components/icons.js +10 -0
  117. package/lib/components/icons.js.map +2 -2
  118. package/lib/components/index.d.ts +8 -8
  119. package/lib/components/index.js +16 -16
  120. package/lib/components/index.js.map +2 -2
  121. package/lib/envOverwrite.d.ts +1 -1
  122. package/lib/envOverwrite.js +24 -9
  123. package/lib/envOverwrite.js.map +2 -2
  124. package/lib/factory.d.ts +15 -1
  125. package/lib/factory.js +35 -6
  126. package/lib/factory.js.map +2 -2
  127. package/lib/helper.css.map +1 -1
  128. package/lib/hooks/index.d.ts +5 -0
  129. package/lib/hooks/index.js +14 -0
  130. package/lib/hooks/index.js.map +13 -0
  131. package/lib/hooks/use-set-state.d.ts +2 -0
  132. package/lib/hooks/use-set-state.js +15 -0
  133. package/lib/hooks/use-set-state.js.map +13 -0
  134. package/lib/hooks/use-touch.d.ts +16 -0
  135. package/lib/hooks/use-touch.js +73 -0
  136. package/lib/hooks/use-touch.js.map +13 -0
  137. package/lib/hooks/use-update-effect.d.ts +3 -0
  138. package/lib/hooks/use-update-effect.js +17 -0
  139. package/lib/hooks/use-update-effect.js.map +13 -0
  140. package/lib/icons/alert-danger.js +7 -0
  141. package/lib/icons/alert-info.js +7 -0
  142. package/lib/icons/alert-success.js +7 -0
  143. package/lib/icons/alert-warning.js +7 -0
  144. package/lib/icons/download.js +7 -0
  145. package/lib/icons/drag-bar.js +10 -3
  146. package/lib/index.d.ts +5 -0
  147. package/lib/index.js +6 -1
  148. package/lib/index.js.map +2 -2
  149. package/lib/locale/de-DE.js +2 -0
  150. package/lib/locale/de-DE.js.map +2 -2
  151. package/lib/locale/en-US.js +3 -0
  152. package/lib/locale/en-US.js.map +2 -2
  153. package/lib/locale/zh-CN.js +5 -2
  154. package/lib/locale/zh-CN.js.map +2 -2
  155. package/lib/renderers/Action.d.ts +10 -5
  156. package/lib/renderers/Action.js +23 -5
  157. package/lib/renderers/Action.js.map +2 -2
  158. package/lib/renderers/Alert.d.ts +21 -1
  159. package/lib/renderers/Alert.js.map +2 -2
  160. package/lib/renderers/AnchorNav.d.ts +1 -0
  161. package/lib/renderers/AnchorNav.js +2 -2
  162. package/lib/renderers/AnchorNav.js.map +2 -2
  163. package/lib/renderers/Avatar.js +3 -3
  164. package/lib/renderers/Avatar.js.map +2 -2
  165. package/lib/renderers/Breadcrumb.js +1 -1
  166. package/lib/renderers/Breadcrumb.js.map +2 -2
  167. package/lib/renderers/CRUD.d.ts +5 -0
  168. package/lib/renderers/CRUD.js +25 -4
  169. package/lib/renderers/CRUD.js.map +2 -2
  170. package/lib/renderers/Card.d.ts +5 -0
  171. package/lib/renderers/Card.js +34 -23
  172. package/lib/renderers/Card.js.map +2 -2
  173. package/lib/renderers/Collapse.d.ts +25 -20
  174. package/lib/renderers/Collapse.js +10 -72
  175. package/lib/renderers/Collapse.js.map +2 -2
  176. package/lib/renderers/CollapseGroup.d.ts +42 -0
  177. package/lib/renderers/CollapseGroup.js +33 -0
  178. package/lib/renderers/CollapseGroup.js.map +13 -0
  179. package/lib/renderers/Form/ConditionBuilder.js +2 -2
  180. package/lib/renderers/Form/ConditionBuilder.js.map +2 -2
  181. package/lib/renderers/Form/DiffEditor.d.ts +4 -3
  182. package/lib/renderers/Form/Editor.d.ts +3 -2
  183. package/lib/renderers/Form/InputCity.d.ts +84 -84
  184. package/lib/renderers/Form/InputCity.js +7 -6
  185. package/lib/renderers/Form/InputCity.js.map +2 -2
  186. package/lib/renderers/Form/InputColor.d.ts +86 -85
  187. package/lib/renderers/Form/InputColor.js +1 -1
  188. package/lib/renderers/Form/InputColor.js.map +2 -2
  189. package/lib/renderers/Form/InputFile.d.ts +6 -0
  190. package/lib/renderers/Form/InputFile.js +28 -8
  191. package/lib/renderers/Form/InputFile.js.map +2 -2
  192. package/lib/renderers/Form/InputImage.js +11 -4
  193. package/lib/renderers/Form/InputImage.js.map +2 -2
  194. package/lib/renderers/Form/Item.d.ts +1 -1
  195. package/lib/renderers/Form/Item.js +2 -1
  196. package/lib/renderers/Form/Item.js.map +2 -2
  197. package/lib/renderers/Form/Options.js +25 -4
  198. package/lib/renderers/Form/Options.js.map +2 -2
  199. package/lib/renderers/Form/Select.d.ts +42 -4
  200. package/lib/renderers/Form/Select.js +37 -3
  201. package/lib/renderers/Form/Select.js.map +2 -2
  202. package/lib/renderers/Form/TabsTransferPicker.d.ts +48 -0
  203. package/lib/renderers/Form/TabsTransferPicker.js +29 -0
  204. package/lib/renderers/Form/TabsTransferPicker.js.map +13 -0
  205. package/lib/renderers/Form/Transfer.js +18 -3
  206. package/lib/renderers/Form/Transfer.js.map +2 -2
  207. package/lib/renderers/Form/TransferPicker.d.ts +52 -0
  208. package/lib/renderers/Form/TransferPicker.js +43 -0
  209. package/lib/renderers/Form/TransferPicker.js.map +13 -0
  210. package/lib/renderers/Form/TreeSelect.js +2 -2
  211. package/lib/renderers/Form/TreeSelect.js.map +2 -2
  212. package/lib/renderers/Form/index.d.ts +5 -0
  213. package/lib/renderers/Form/index.js +5 -3
  214. package/lib/renderers/Form/index.js.map +2 -2
  215. package/lib/renderers/Form/wrapControl.js +13 -1
  216. package/lib/renderers/Form/wrapControl.js.map +2 -2
  217. package/lib/renderers/GridNav.d.ts +99 -0
  218. package/lib/renderers/GridNav.js +82 -0
  219. package/lib/renderers/GridNav.js.map +13 -0
  220. package/lib/renderers/IFrame.js +1 -3
  221. package/lib/renderers/IFrame.js.map +2 -2
  222. package/lib/renderers/Image.js +7 -5
  223. package/lib/renderers/Image.js.map +2 -2
  224. package/lib/renderers/Json.d.ts +4 -0
  225. package/lib/renderers/Json.js +4 -13
  226. package/lib/renderers/Json.js.map +2 -2
  227. package/lib/renderers/Link.d.ts +4 -2
  228. package/lib/renderers/Link.js +15 -8
  229. package/lib/renderers/Link.js.map +2 -2
  230. package/lib/renderers/List.js +1 -1
  231. package/lib/renderers/List.js.map +2 -2
  232. package/lib/renderers/Nav.d.ts +21 -21
  233. package/lib/renderers/Nav.js +37 -19
  234. package/lib/renderers/Nav.js.map +2 -2
  235. package/lib/renderers/Page.d.ts +18 -0
  236. package/lib/renderers/Page.js +53 -9
  237. package/lib/renderers/Page.js.map +2 -2
  238. package/lib/renderers/Portlet.d.ts +125 -0
  239. package/lib/renderers/Portlet.js +156 -0
  240. package/lib/renderers/Portlet.js.map +13 -0
  241. package/lib/renderers/Progress.d.ts +23 -3
  242. package/lib/renderers/Progress.js +15 -19
  243. package/lib/renderers/Progress.js.map +2 -2
  244. package/lib/renderers/Property.js +1 -1
  245. package/lib/renderers/Property.js.map +2 -2
  246. package/lib/renderers/Table/ColumnToggler.js +1 -1
  247. package/lib/renderers/Table/ColumnToggler.js.map +2 -2
  248. package/lib/renderers/Table/TableContent.d.ts +4 -1
  249. package/lib/renderers/Table/TableContent.js +21 -1
  250. package/lib/renderers/Table/TableContent.js.map +2 -2
  251. package/lib/renderers/Table/index.d.ts +5 -1
  252. package/lib/renderers/Table/index.js +65 -30
  253. package/lib/renderers/Table/index.js.map +2 -2
  254. package/lib/renderers/Tabs.js +9 -1
  255. package/lib/renderers/Tabs.js.map +2 -2
  256. package/lib/renderers/WebComponent.js +1 -1
  257. package/lib/renderers/WebComponent.js.map +2 -2
  258. package/lib/store/combo.d.ts +2 -2
  259. package/lib/store/form.d.ts +1 -1
  260. package/lib/store/form.js +3 -5
  261. package/lib/store/form.js.map +2 -2
  262. package/lib/store/formItem.js +44 -4
  263. package/lib/store/formItem.js.map +2 -2
  264. package/lib/store/table.d.ts +3 -2
  265. package/lib/store/table.js +35 -12
  266. package/lib/store/table.js.map +2 -2
  267. package/lib/themes/ang-ie11.css +934 -222
  268. package/lib/themes/ang.css +934 -222
  269. package/lib/themes/ang.css.map +1 -1
  270. package/lib/themes/antd-ie11.css +934 -222
  271. package/lib/themes/antd.css +934 -222
  272. package/lib/themes/antd.css.map +1 -1
  273. package/lib/themes/cxd-ie11.css +970 -260
  274. package/lib/themes/cxd.css +970 -260
  275. package/lib/themes/cxd.css.map +1 -1
  276. package/lib/themes/dark-ie11.css +934 -222
  277. package/lib/themes/dark.css +934 -222
  278. package/lib/themes/dark.css.map +1 -1
  279. package/lib/themes/default.css +970 -260
  280. package/lib/themes/default.css.map +1 -1
  281. package/lib/types.d.ts +38 -1
  282. package/lib/types.js +0 -5
  283. package/lib/types.js.map +2 -2
  284. package/lib/utils/api.d.ts +3 -2
  285. package/lib/utils/api.js +90 -17
  286. package/lib/utils/api.js.map +2 -2
  287. package/lib/utils/dom.d.ts +4 -0
  288. package/lib/utils/dom.js +11 -1
  289. package/lib/utils/dom.js.map +2 -2
  290. package/lib/utils/helper.d.ts +12 -23
  291. package/lib/utils/helper.js +62 -166
  292. package/lib/utils/helper.js.map +2 -2
  293. package/lib/utils/tpl-builtin.d.ts +2 -20
  294. package/lib/utils/tpl-builtin.js +25 -743
  295. package/lib/utils/tpl-builtin.js.map +2 -2
  296. package/lib/utils/tpl.js +24 -0
  297. package/lib/utils/tpl.js.map +2 -2
  298. package/package.json +5 -2
  299. package/schema.json +3966 -1263
  300. package/scss/_mixins.scss +1 -3
  301. package/scss/_properties.scss +42 -13
  302. package/scss/base/_common.scss +3 -0
  303. package/scss/base/_normalize.scss +2 -0
  304. package/scss/components/_alert.scss +28 -5
  305. package/scss/components/_anchor-nav.scss +89 -29
  306. package/scss/components/_button.scss +12 -0
  307. package/scss/components/_card.scss +9 -15
  308. package/scss/components/_collapse-group.scss +15 -0
  309. package/scss/components/_collapse.scss +48 -23
  310. package/scss/components/_grid-nav.scss +128 -0
  311. package/scss/components/_images.scss +1 -0
  312. package/scss/components/_input-box.scss +1 -0
  313. package/scss/components/_nav.scss +2 -7
  314. package/scss/components/_page.scss +35 -2
  315. package/scss/components/_picker-columns.scss +124 -0
  316. package/scss/components/_popover.scss +13 -0
  317. package/scss/components/_portlet.scss +51 -0
  318. package/scss/components/_progress.scss +141 -33
  319. package/scss/components/_result-box.scss +1 -0
  320. package/scss/components/_spinner.scss +5 -4
  321. package/scss/components/_status.scss +1 -1
  322. package/scss/components/_table.scss +32 -0
  323. package/scss/components/_toast.scss +41 -11
  324. package/scss/components/form/_checks.scss +0 -351
  325. package/scss/components/form/_color.scss +32 -3
  326. package/scss/components/form/_combo.scss +4 -0
  327. package/scss/components/form/_fieldset.scss +6 -1
  328. package/scss/components/form/_file.scss +11 -0
  329. package/scss/components/form/_form.scss +48 -0
  330. package/scss/components/form/_selection.scss +354 -0
  331. package/scss/components/form/_transfer.scss +76 -18
  332. package/scss/components/form/_tree.scss +42 -0
  333. package/scss/themes/_common.scss +6 -0
  334. package/scss/themes/_cxd-variables.scss +13 -6
  335. package/scss/themes/cxd.scss +19 -20
  336. package/sdk/ang-ie11.css +1065 -246
  337. package/sdk/ang.css +1069 -230
  338. package/sdk/antd-ie11.css +1068 -249
  339. package/sdk/antd.css +1069 -230
  340. package/sdk/charts.js +17 -17
  341. package/sdk/color-picker.js +65 -69
  342. package/sdk/cropperjs.js +3 -3
  343. package/sdk/cxd-ie11.css +1081 -268
  344. package/sdk/cxd.css +1116 -279
  345. package/sdk/dark-ie11.css +1069 -250
  346. package/sdk/dark.css +1069 -230
  347. package/sdk/exceljs.js +1 -1
  348. package/sdk/helper.css.map +1 -1
  349. package/sdk/iconfont.svg +2513 -0
  350. package/sdk/iconfont.ttf +0 -0
  351. package/sdk/iconfont.woff +0 -0
  352. package/sdk/locale/de-DE.js +2 -0
  353. package/sdk/markdown.js +69 -69
  354. package/sdk/papaparse.js +1 -1
  355. package/sdk/renderers/Form/CityDB.js +1 -1
  356. package/sdk/rest.js +20 -28
  357. package/sdk/rich-text.js +62 -62
  358. package/sdk/sdk-ie11.css +1081 -268
  359. package/sdk/sdk.css +1116 -279
  360. package/sdk/sdk.js +1371 -1189
  361. package/sdk/thirds/hls.js/hls.js +18 -18
  362. package/sdk/thirds/mpegts.js/mpegts.js +2 -2
  363. package/sdk/tinymce.js +57 -57
  364. package/src/Schema.ts +19 -1
  365. package/src/components/Alert2.tsx +32 -4
  366. package/src/components/AnchorNav.tsx +15 -4
  367. package/src/components/{AssociatedCheckboxes.tsx → AssociatedSelection.tsx} +43 -37
  368. package/src/components/Badge.tsx +3 -3
  369. package/src/components/Button.tsx +1 -0
  370. package/src/components/{ChainedCheckboxes.tsx → ChainedSelection.tsx} +57 -40
  371. package/src/components/Collapse.tsx +139 -20
  372. package/src/components/CollapseGroup.tsx +130 -0
  373. package/src/components/ColorPicker.tsx +32 -10
  374. package/src/components/Drawer.tsx +8 -6
  375. package/src/components/GridNav.tsx +233 -0
  376. package/src/components/{ListCheckboxes.tsx → GroupedSelection.tsx} +26 -21
  377. package/src/components/InputBox.tsx +10 -9
  378. package/src/components/Link.tsx +28 -37
  379. package/src/components/ModalManager.ts +1 -1
  380. package/src/components/Overlay.tsx +6 -0
  381. package/src/components/PickerColumn.tsx +429 -0
  382. package/src/components/PickerContainer.tsx +128 -0
  383. package/src/components/PopOver.tsx +15 -1
  384. package/src/components/Progress.tsx +140 -0
  385. package/src/components/Radios.tsx +3 -8
  386. package/src/components/ResultBox.tsx +9 -9
  387. package/src/components/Select.tsx +57 -5
  388. package/src/components/{Checkboxes.tsx → Selection.tsx} +75 -21
  389. package/src/components/{TableCheckboxes.tsx → TableSelection.tsx} +46 -25
  390. package/src/components/TabsTransfer.tsx +13 -7
  391. package/src/components/TabsTransferPicker.tsx +85 -0
  392. package/src/components/Toast.tsx +48 -21
  393. package/src/components/Transfer.tsx +71 -50
  394. package/src/components/TransferDropDown.tsx +120 -0
  395. package/src/components/TransferPicker.tsx +91 -0
  396. package/src/components/Tree.tsx +194 -8
  397. package/src/components/{TreeCheckboxes.tsx → TreeSelection.tsx} +33 -26
  398. package/src/components/condition-builder/Field.tsx +7 -5
  399. package/src/components/condition-builder/Func.tsx +3 -3
  400. package/src/components/condition-builder/InputSwitch.tsx +3 -3
  401. package/src/components/condition-builder/Item.tsx +5 -12
  402. package/src/components/icons.tsx +10 -0
  403. package/src/components/index.tsx +13 -13
  404. package/src/envOverwrite.ts +20 -8
  405. package/src/factory.tsx +70 -9
  406. package/src/hooks/index.ts +5 -0
  407. package/src/hooks/use-set-state.ts +19 -0
  408. package/src/hooks/use-touch.ts +100 -0
  409. package/src/hooks/use-update-effect.ts +16 -0
  410. package/src/icons/alert-danger.svg +1 -0
  411. package/src/icons/alert-info.svg +1 -0
  412. package/src/icons/alert-success.svg +1 -0
  413. package/src/icons/alert-warning.svg +1 -0
  414. package/src/icons/download.svg +4 -0
  415. package/src/icons/drag-bar.svg +12 -6
  416. package/src/index.tsx +5 -0
  417. package/src/locale/de-DE.ts +2 -0
  418. package/src/locale/en-US.ts +3 -0
  419. package/src/locale/zh-CN.ts +5 -2
  420. package/src/renderers/Action.tsx +58 -3
  421. package/src/renderers/Alert.tsx +31 -1
  422. package/src/renderers/AnchorNav.tsx +4 -0
  423. package/src/renderers/Avatar.tsx +8 -4
  424. package/src/renderers/Breadcrumb.tsx +5 -1
  425. package/src/renderers/CRUD.tsx +29 -3
  426. package/src/renderers/Card.tsx +76 -36
  427. package/src/renderers/Collapse.tsx +70 -115
  428. package/src/renderers/CollapseGroup.tsx +80 -0
  429. package/src/renderers/Form/ConditionBuilder.tsx +2 -2
  430. package/src/renderers/Form/InputCity.tsx +4 -8
  431. package/src/renderers/Form/InputColor.tsx +4 -2
  432. package/src/renderers/Form/InputFile.tsx +65 -24
  433. package/src/renderers/Form/InputImage.tsx +11 -3
  434. package/src/renderers/Form/Item.tsx +3 -2
  435. package/src/renderers/Form/Options.tsx +29 -3
  436. package/src/renderers/Form/Select.tsx +162 -21
  437. package/src/renderers/Form/TabsTransferPicker.tsx +123 -0
  438. package/src/renderers/Form/Transfer.tsx +19 -4
  439. package/src/renderers/Form/TransferPicker.tsx +145 -0
  440. package/src/renderers/Form/TreeSelect.tsx +25 -0
  441. package/src/renderers/Form/index.tsx +15 -2
  442. package/src/renderers/Form/wrapControl.tsx +26 -1
  443. package/src/renderers/GridNav.tsx +204 -0
  444. package/src/renderers/IFrame.tsx +2 -4
  445. package/src/renderers/Image.tsx +19 -15
  446. package/src/renderers/Json.tsx +9 -9
  447. package/src/renderers/Link.tsx +29 -16
  448. package/src/renderers/List.tsx +1 -1
  449. package/src/renderers/Nav.tsx +105 -56
  450. package/src/renderers/Page.tsx +62 -1
  451. package/src/renderers/Portlet.tsx +423 -0
  452. package/src/renderers/Progress.tsx +56 -38
  453. package/src/renderers/Property.tsx +6 -4
  454. package/src/renderers/Table/ColumnToggler.tsx +1 -1
  455. package/src/renderers/Table/TableContent.tsx +40 -2
  456. package/src/renderers/Table/index.tsx +88 -43
  457. package/src/renderers/Tabs.tsx +9 -1
  458. package/src/renderers/WebComponent.tsx +2 -2
  459. package/src/store/form.ts +3 -9
  460. package/src/store/formItem.ts +94 -2
  461. package/src/store/table.ts +55 -14
  462. package/src/types.ts +58 -1
  463. package/src/utils/api.ts +120 -26
  464. package/src/utils/dom.tsx +12 -0
  465. package/src/utils/helper.ts +55 -185
  466. package/src/utils/tpl-builtin.ts +40 -866
  467. package/src/utils/tpl.ts +33 -0
  468. package/tsconfig-for-declaration.json +1 -1
  469. package/dump.rdb +0 -0
  470. package/lib/components/AssociatedCheckboxes.d.ts +0 -762
  471. package/lib/components/AssociatedCheckboxes.js +0 -90
  472. package/lib/components/AssociatedCheckboxes.js.map +0 -13
  473. package/lib/components/ChainedCheckboxes.js.map +0 -13
  474. package/lib/components/Checkboxes.js +0 -101
  475. package/lib/components/Checkboxes.js.map +0 -13
  476. package/lib/components/ListCheckboxes.d.ts +0 -739
  477. package/lib/components/ListCheckboxes.js +0 -48
  478. package/lib/components/ListCheckboxes.js.map +0 -13
  479. package/lib/components/ListRadios.d.ts +0 -763
  480. package/lib/components/ListRadios.js +0 -86
  481. package/lib/components/ListRadios.js.map +0 -13
  482. package/lib/components/TableCheckboxes.js.map +0 -13
  483. package/lib/components/TreeCheckboxes.js.map +0 -13
  484. package/lib/components/TreeRadios.d.ts +0 -838
  485. package/lib/components/TreeRadios.js +0 -116
  486. package/lib/components/TreeRadios.js.map +0 -13
  487. package/src/components/ListRadios.tsx +0 -159
  488. package/src/components/TreeRadios.tsx +0 -202
@@ -1,753 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = exports.dataMapping = exports.resolveMapping = exports.tokenize = exports.resolveVariableAndFilter = exports.isPureVariable = exports.resolveVariable = exports.pickValues = exports.getFilters = exports.registerFilter = exports.filters = exports.stripNumber = exports.parseDuration = exports.filterDate = exports.relativeValueRe = exports.formatDuration = exports.escapeHtml = exports.prettyBytes = void 0;
3
+ exports.register = exports.dataMapping = exports.resolveMapping = exports.stripNumber = exports.tokenize = exports.resolveVariableAndFilter = exports.isPureVariable = exports.resolveVariable = exports.pickValues = exports.registerFilter = exports.getFilters = exports.parseDuration = exports.relativeValueRe = exports.filterDate = exports.formatDuration = exports.escapeHtml = exports.prettyBytes = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var moment_1 = (0, tslib_1.__importDefault)(require("moment"));
6
5
  var isPlainObject_1 = (0, tslib_1.__importDefault)(require("lodash/isPlainObject"));
7
- var groupBy_1 = (0, tslib_1.__importDefault)(require("lodash/groupBy"));
8
6
  var helper_1 = require("./helper");
9
- var uniqBy_1 = (0, tslib_1.__importDefault)(require("lodash/uniqBy"));
10
- var uniq_1 = (0, tslib_1.__importDefault)(require("lodash/uniq"));
11
- var transform_1 = (0, tslib_1.__importDefault)(require("lodash/transform"));
12
- var UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
13
- var prettyBytes = function (num) {
14
- if (!Number.isFinite(num)) {
15
- throw new TypeError("Expected a finite number, got " + typeof num + ": " + num);
16
- }
17
- var neg = num < 0;
18
- if (neg) {
19
- num = -num;
20
- }
21
- if (num < 1) {
22
- return (neg ? '-' : '') + num + ' B';
23
- }
24
- var exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), UNITS.length - 1);
25
- var numStr = Number((num / Math.pow(1000, exponent)).toPrecision(3));
26
- var unit = UNITS[exponent];
27
- return (neg ? '-' : '') + numStr + ' ' + unit;
28
- };
29
- exports.prettyBytes = prettyBytes;
30
- var entityMap = {
31
- '&': '&amp;',
32
- '<': '&lt;',
33
- '>': '&gt;',
34
- '"': '&quot;',
35
- "'": '&#39;',
36
- '/': '&#x2F;'
37
- };
38
- var escapeHtml = function (str) {
39
- return String(str).replace(/[&<>"'\/]/g, function (s) {
40
- return entityMap[s];
41
- });
42
- };
43
- exports.escapeHtml = escapeHtml;
44
- function formatDuration(value) {
45
- var unit = ['秒', '分', '时', '天', '月', '季', '年'];
46
- var steps = [1, 60, 3600, 86400, 2592000, 7776000, 31104000];
47
- var len = steps.length;
48
- var parts = [];
49
- while (len--) {
50
- if (steps[len] && value >= steps[len]) {
51
- parts.push(Math.floor(value / steps[len]) + unit[len]);
52
- value %= steps[len];
53
- }
54
- else if (len === 0 && value) {
55
- parts.push((value.toFixed ? value.toFixed(2) : '0') + unit[0]);
56
- }
57
- }
58
- return parts.join('');
59
- }
60
- exports.formatDuration = formatDuration;
61
- function makeSorter(key, method, order) {
62
- return function (a, b) {
63
- if (!a || !b) {
64
- return 0;
65
- }
66
- var va = (0, exports.resolveVariable)(key, a);
67
- var vb = (0, exports.resolveVariable)(key, b);
68
- var result = 0;
69
- if (method === 'numerical') {
70
- result = (parseFloat(va) || 0) - (parseFloat(vb) || 0);
71
- }
72
- else {
73
- result = String(va).localeCompare(String(vb));
74
- }
75
- return result * (order === 'desc' ? -1 : 1);
76
- };
77
- }
78
- var timeUnitMap = {
79
- year: 'Y',
80
- month: 'M',
81
- week: 'w',
82
- weekday: 'W',
83
- day: 'd',
84
- hour: 'h',
85
- minute: 'm',
86
- min: 'm',
87
- second: 's',
88
- millisecond: 'ms'
89
- };
90
- exports.relativeValueRe = /^(.+)?(\+|-)(\d+)(minute|min|hour|day|week|month|year|weekday|second|millisecond)s?$/i;
91
- var filterDate = function (value, data, format, utc) {
92
- if (data === void 0) { data = {}; }
93
- if (format === void 0) { format = 'X'; }
94
- if (utc === void 0) { utc = false; }
95
- var m, mm = utc ? moment_1.default.utc : moment_1.default;
96
- if (typeof value === 'string') {
97
- value = value.trim();
98
- }
99
- value = (0, exports.tokenize)(value, data);
100
- if (value && typeof value === 'string' && (m = exports.relativeValueRe.exec(value))) {
101
- var date = new Date();
102
- var step = parseInt(m[3], 10);
103
- var from = m[1]
104
- ? (0, exports.filterDate)(m[1], data, format, utc)
105
- : mm(/(minute|min|hour|second)s?/.test(m[4])
106
- ? [
107
- date.getFullYear(),
108
- date.getMonth(),
109
- date.getDate(),
110
- date.getHours(),
111
- date.getMinutes(),
112
- date.getSeconds()
113
- ]
114
- : [date.getFullYear(), date.getMonth(), date.getDate()]);
115
- return m[2] === '-'
116
- ? from.subtract(step, timeUnitMap[m[4]])
117
- : from.add(step, timeUnitMap[m[4]]);
118
- // return from[m[2] === '-' ? 'subtract' : 'add'](step, mapping[m[4]] || m[4]);
119
- }
120
- else if (value === 'now') {
121
- return mm();
122
- }
123
- else if (value === 'today') {
124
- var date = new Date();
125
- return mm([date.getFullYear(), date.getMonth(), date.getDate()]);
126
- }
127
- else {
128
- return mm(value, format);
129
- }
130
- };
131
- exports.filterDate = filterDate;
132
- function parseDuration(str) {
133
- var matches = /^((?:\-|\+)?(?:\d*\.)?\d+)(minute|min|hour|day|week|month|quarter|year|weekday|second|millisecond)s?$/.exec(str);
134
- if (matches) {
135
- var duration = moment_1.default.duration(parseFloat(matches[1]), matches[2]);
136
- if (moment_1.default.isDuration(duration)) {
137
- return duration;
138
- }
139
- }
140
- return;
141
- }
142
- exports.parseDuration = parseDuration;
143
- // 主要用于解决 0.1+0.2 结果的精度问题导致太长
144
- function stripNumber(number) {
145
- if (typeof number === 'number') {
146
- return parseFloat(number.toPrecision(12));
147
- }
148
- else {
149
- return number;
150
- }
151
- }
152
- exports.stripNumber = stripNumber;
153
- exports.filters = {
154
- map: function (input, fn) {
155
- var arg = [];
156
- for (var _i = 2; _i < arguments.length; _i++) {
157
- arg[_i - 2] = arguments[_i];
158
- }
159
- return Array.isArray(input) && exports.filters[fn]
160
- ? input.map(function (item) { return exports.filters[fn].apply(exports.filters, (0, tslib_1.__spreadArray)([item], arg, false)); })
161
- : input;
162
- },
163
- html: function (input) { return (0, exports.escapeHtml)(input); },
164
- json: function (input, tabSize) {
165
- if (tabSize === void 0) { tabSize = 2; }
166
- return tabSize
167
- ? JSON.stringify(input, null, parseInt(tabSize, 10))
168
- : JSON.stringify(input);
169
- },
170
- toJson: function (input) {
171
- var ret;
172
- try {
173
- ret = JSON.parse(input);
174
- }
175
- catch (e) {
176
- ret = null;
177
- }
178
- return ret;
179
- },
180
- toInt: function (input) { return (typeof input === 'string' ? parseInt(input, 10) : input); },
181
- toFloat: function (input) { return (typeof input === 'string' ? parseFloat(input) : input); },
182
- raw: function (input) { return input; },
183
- now: function () { return new Date(); },
184
- toDate: function (input, inputFormat) {
185
- if (inputFormat === void 0) { inputFormat = ''; }
186
- var data = (0, moment_1.default)(input, inputFormat);
187
- data.add();
188
- return data.isValid() ? data.toDate() : undefined;
189
- },
190
- fromNow: function (input, inputFormat) {
191
- if (inputFormat === void 0) { inputFormat = ''; }
192
- return (0, moment_1.default)(input, inputFormat).fromNow();
193
- },
194
- dateModify: function (input, modifier, amount, unit) {
195
- if (modifier === void 0) { modifier = 'add'; }
196
- if (amount === void 0) { amount = 0; }
197
- if (unit === void 0) { unit = 'days'; }
198
- if (!(input instanceof Date)) {
199
- input = new Date();
200
- }
201
- if (modifier === 'endOf' || modifier === 'startOf') {
202
- return (0, moment_1.default)(input)[modifier === 'endOf' ? 'endOf' : 'startOf'](amount || 'day')
203
- .toDate();
204
- }
205
- return (0, moment_1.default)(input)[modifier === 'add' ? 'add' : 'subtract'](parseInt(amount, 10) || 0, unit)
206
- .toDate();
207
- },
208
- date: function (input, format, inputFormat) {
209
- if (format === void 0) { format = 'LLL'; }
210
- if (inputFormat === void 0) { inputFormat = 'X'; }
211
- return (0, moment_1.default)(input, inputFormat).format(format);
212
- },
213
- number: function (input) {
214
- var parts = String(input).split('.');
215
- parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
216
- return parts.join('.');
217
- },
218
- trim: function (input) { return (typeof input === 'string' ? input.trim() : input); },
219
- percent: function (input, decimals) {
220
- if (decimals === void 0) { decimals = 0; }
221
- input = parseFloat(input) || 0;
222
- decimals = parseInt(decimals, 10) || 0;
223
- var whole = input * 100;
224
- var multiplier = Math.pow(10, decimals);
225
- return ((Math.round(whole * multiplier) / multiplier).toFixed(decimals) + '%');
226
- },
227
- duration: function (input) { return (input ? formatDuration(input) : input); },
228
- bytes: function (input) { return (input ? (0, exports.prettyBytes)(parseFloat(input)) : input); },
229
- round: function (input, decimals) {
230
- var _a;
231
- if (decimals === void 0) { decimals = 2; }
232
- if (isNaN(input)) {
233
- return 0;
234
- }
235
- decimals = (_a = parseInt(decimals, 10)) !== null && _a !== void 0 ? _a : 2;
236
- var multiplier = Math.pow(10, decimals);
237
- return (Math.round(input * multiplier) / multiplier).toFixed(decimals);
238
- },
239
- truncate: function (input, length, end) {
240
- if (typeof input !== 'string') {
241
- return input;
242
- }
243
- end = end || '...';
244
- if (length == null) {
245
- return input;
246
- }
247
- length = parseInt(length, 10) || 200;
248
- return input.substring(0, length) + (input.length > length ? end : '');
249
- },
250
- url_encode: function (input) { return encodeURIComponent(input); },
251
- url_decode: function (input) { return decodeURIComponent(input); },
252
- default: function (input, defaultValue, strict) {
253
- var _a;
254
- if (strict === void 0) { strict = false; }
255
- return (_a = (strict ? input : input ? input : undefined)) !== null && _a !== void 0 ? _a : (function () {
256
- try {
257
- if (defaultValue === 'undefined') {
258
- return undefined;
259
- }
260
- return JSON.parse(defaultValue);
261
- }
262
- catch (e) {
263
- return defaultValue;
264
- }
265
- })();
266
- },
267
- join: function (input, glue) { return (input && input.join ? input.join(glue) : input); },
268
- split: function (input, delimiter) {
269
- if (delimiter === void 0) { delimiter = ','; }
270
- return typeof input === 'string' ? input.split(delimiter) : input;
271
- },
272
- sortBy: function (input, key, method, order) {
273
- if (method === void 0) { method = 'alpha'; }
274
- return Array.isArray(input) ? input.sort(makeSorter(key, method, order)) : input;
275
- },
276
- objectToArray: function (input, label, value) {
277
- if (label === void 0) { label = 'label'; }
278
- if (value === void 0) { value = 'value'; }
279
- return (0, transform_1.default)(input, function (result, v, k) {
280
- var _a;
281
- (result || (result = [])).push((_a = {},
282
- _a[label] = v,
283
- _a[value] = k,
284
- _a));
285
- }, []);
286
- },
287
- unique: function (input, key) {
288
- return Array.isArray(input) ? (key ? (0, uniqBy_1.default)(input, key) : (0, uniq_1.default)(input)) : input;
289
- },
290
- topAndOther: function (input, len, labelField, restLabel) {
291
- if (len === void 0) { len = 10; }
292
- if (labelField === void 0) { labelField = 'name'; }
293
- if (restLabel === void 0) { restLabel = '其他'; }
294
- if (Array.isArray(input) && len) {
295
- var grouped_1 = (0, groupBy_1.default)(input, function (item) {
296
- var index = input.indexOf(item) + 1;
297
- return index >= len ? len : index;
298
- });
299
- return Object.keys(grouped_1).map(function (key, index) {
300
- var group = grouped_1[key];
301
- var obj = group.reduce(function (obj, item) {
302
- Object.keys(item).forEach(function (key) {
303
- if (!obj.hasOwnProperty(key) || key === 'labelField') {
304
- obj[key] = item[key];
305
- }
306
- else if (typeof item[key] === 'number' &&
307
- typeof obj[key] === 'number') {
308
- obj[key] += item[key];
309
- }
310
- else if (typeof item[key] === 'string' &&
311
- /^(?:\-|\.)\d/.test(item[key]) &&
312
- typeof obj[key] === 'number') {
313
- obj[key] += parseFloat(item[key]) || 0;
314
- }
315
- else if (typeof item[key] === 'string' &&
316
- typeof obj[key] === 'string') {
317
- obj[key] += ", " + item[key];
318
- }
319
- else {
320
- obj[key] = item[key];
321
- }
322
- });
323
- return obj;
324
- }, {});
325
- if (index === len - 1) {
326
- obj[labelField] = restLabel || '其他';
327
- }
328
- return obj;
329
- });
330
- }
331
- return input;
332
- },
333
- first: function (input) { return input && input[0]; },
334
- nth: function (input, nth) {
335
- if (nth === void 0) { nth = 0; }
336
- return input && input[nth];
337
- },
338
- last: function (input) { return input && (input.length ? input[input.length - 1] : null); },
339
- minus: function (input, step) {
340
- if (step === void 0) { step = 1; }
341
- return stripNumber((Number(input) || 0) - Number(getStrOrVariable(step, this)));
342
- },
343
- plus: function (input, step) {
344
- if (step === void 0) { step = 1; }
345
- return stripNumber((Number(input) || 0) + Number(getStrOrVariable(step, this)));
346
- },
347
- times: function (input, step) {
348
- if (step === void 0) { step = 1; }
349
- return stripNumber((Number(input) || 0) * Number(getStrOrVariable(step, this)));
350
- },
351
- division: function (input, step) {
352
- if (step === void 0) { step = 1; }
353
- return stripNumber((Number(input) || 0) / Number(getStrOrVariable(step, this)));
354
- },
355
- count: function (input) {
356
- return Array.isArray(input) || typeof input === 'string' ? input.length : 0;
357
- },
358
- sum: function (input, field) {
359
- if (!Array.isArray(input)) {
360
- return input;
361
- }
362
- var restult = input.reduce(function (sum, item) {
363
- return sum + (parseFloat(field ? pickValues(field, item) : item) || 0);
364
- }, 0);
365
- return stripNumber(restult);
366
- },
367
- abs: function (input) { return (typeof input === 'number' ? Math.abs(input) : input); },
368
- pick: function (input, path) {
369
- if (path === void 0) { path = '&'; }
370
- return Array.isArray(input) && !/^\d+$/.test(path)
371
- ? input.map(function (item, index) {
372
- return pickValues(path, (0, helper_1.createObject)({ index: index }, item));
373
- })
374
- : pickValues(path, input);
375
- },
376
- pick_if_exist: function (input, path) {
377
- if (path === void 0) { path = '&'; }
378
- return Array.isArray(input)
379
- ? input.map(function (item) { return (0, exports.resolveVariable)(path, item) || item; })
380
- : (0, exports.resolveVariable)(path, input) || input;
381
- },
382
- str2date: function (input, inputFormat, outputFormat) {
383
- if (inputFormat === void 0) { inputFormat = 'X'; }
384
- if (outputFormat === void 0) { outputFormat = 'X'; }
385
- return input
386
- ? (0, exports.filterDate)(input, this, inputFormat).format(outputFormat)
387
- : '';
388
- },
389
- asArray: function (input) { return (Array.isArray(input) ? input : input ? [input] : input); },
390
- concat: function (input) {
391
- var _this = this;
392
- var args = [];
393
- for (var _i = 1; _i < arguments.length; _i++) {
394
- args[_i - 1] = arguments[_i];
395
- }
396
- return Array.isArray(input)
397
- ? input.concat.apply(input, args.map(function (arg) { return getStrOrVariable(arg, _this); })) : input;
398
- },
399
- filter: function (input, keys, expOrDirective, arg1) {
400
- if (!Array.isArray(input) || !keys || !expOrDirective) {
401
- return input;
402
- }
403
- var directive = expOrDirective;
404
- var fn = function () { return true; };
405
- if (directive === 'isTrue') {
406
- fn = function (value) { return !!value; };
407
- }
408
- else if (directive === 'isFalse') {
409
- fn = function (value) { return !value; };
410
- }
411
- else if (directive === 'isExists') {
412
- fn = function (value) { return typeof value !== 'undefined'; };
413
- }
414
- else if (directive === 'equals' || directive === 'equal') {
415
- arg1 = arg1 ? getStrOrVariable(arg1, this) : '';
416
- fn = function (value) { return arg1 == value; };
417
- }
418
- else if (directive === 'isIn') {
419
- var list_1 = arg1 ? getStrOrVariable(arg1, this) : [];
420
- list_1 = str2array(list_1);
421
- list_1 = Array.isArray(list_1) ? list_1 : list_1 ? [list_1] : [];
422
- fn = function (value) { return (list_1.length ? !!~list_1.indexOf(value) : true); };
423
- }
424
- else if (directive === 'notIn') {
425
- var list_2 = arg1 ? getStrOrVariable(arg1, this) : [];
426
- list_2 = str2array(list_2);
427
- list_2 = Array.isArray(list_2) ? list_2 : list_2 ? [list_2] : [];
428
- fn = function (value) { return !~list_2.indexOf(value); };
429
- }
430
- else {
431
- if (directive !== 'match') {
432
- directive = 'match';
433
- arg1 = expOrDirective;
434
- }
435
- arg1 = arg1 ? getStrOrVariable(arg1, this) : '';
436
- // 比对的值是空时直接返回。
437
- if (!arg1) {
438
- return input;
439
- }
440
- var reg_1 = (0, helper_1.string2regExp)("" + arg1, false);
441
- fn = function (value) { return reg_1.test(String(value)); };
442
- }
443
- // 判断keys是否为*
444
- var isAsterisk = /\s*\*\s*/.test(keys);
445
- keys = keys.split(/\s*,\s*/);
446
- return input.filter(function (item) {
447
- // 当keys为*时从item中获取key
448
- return (isAsterisk ? Object.keys(item) : keys).some(function (key) {
449
- return fn((0, exports.resolveVariable)(key, item), key, item);
450
- });
451
- });
452
- },
453
- base64Encode: function (str) {
454
- return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
455
- return String.fromCharCode(('0x' + p1));
456
- }));
457
- },
458
- base64Decode: function (str) {
459
- return decodeURIComponent(atob(str)
460
- .split('')
461
- .map(function (c) {
462
- return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
463
- })
464
- .join(''));
465
- },
466
- lowerCase: function (input) {
467
- return input && typeof input === 'string' ? input.toLowerCase() : input;
468
- },
469
- upperCase: function (input) {
470
- return input && typeof input === 'string' ? input.toUpperCase() : input;
471
- },
472
- isTrue: function (input, trueValue, falseValue) {
473
- return getConditionValue(input, !!input, trueValue, falseValue, this);
474
- },
475
- isFalse: function (input, trueValue, falseValue) {
476
- return getConditionValue(input, !input, trueValue, falseValue, this);
477
- },
478
- isMatch: function (input, matchArg, trueValue, falseValue) {
479
- matchArg = getStrOrVariable(matchArg, this);
480
- return getConditionValue(input, matchArg && (0, helper_1.string2regExp)("" + matchArg, false).test(String(input)), trueValue, falseValue, this);
481
- },
482
- notMatch: function (input, matchArg, trueValue, falseValue) {
483
- matchArg = getStrOrVariable(matchArg, this);
484
- return getConditionValue(input, matchArg && !(0, helper_1.string2regExp)("" + matchArg, false).test(String(input)), trueValue, falseValue, this);
485
- },
486
- isEquals: function (input, equalsValue, trueValue, falseValue) {
487
- equalsValue = /^\d+$/.test(equalsValue)
488
- ? parseInt(equalsValue, 10)
489
- : getStrOrVariable(equalsValue, this);
490
- return getConditionValue(input, input === equalsValue, trueValue, falseValue, this);
491
- },
492
- notEquals: function (input, equalsValue, trueValue, falseValue) {
493
- equalsValue = /^\d+$/.test(equalsValue)
494
- ? parseInt(equalsValue, 10)
495
- : getStrOrVariable(equalsValue, this);
496
- return getConditionValue(input, input !== equalsValue, trueValue, falseValue, this);
497
- }
498
- };
499
- /**
500
- * 如果当前传入字符为:'xxx'或者"xxx",则返回字符xxx
501
- * 否则去数据域中,获取变量xxx
502
- *
503
- * @param value 传入字符
504
- * @param data 数据域
505
- */
506
- function getStrOrVariable(value, data) {
507
- return /^('|")(.*)\1$/.test(value)
508
- ? RegExp.$2
509
- : /^-?\d+$/.test(value)
510
- ? parseInt(value, 10)
511
- : /^(-?\d+)\.\d+?$/.test(value)
512
- ? parseFloat(value)
513
- : /^\[.*\]$/.test(value)
514
- ? value
515
- .substring(1, value.length - 1)
516
- .split(/\s*,\s*/)
517
- .filter(function (item) { return item; })
518
- : /,/.test(value)
519
- ? value.split(/\s*,\s*/).filter(function (item) { return item; })
520
- : (0, exports.resolveVariable)(value, data);
521
- }
522
- function str2array(list) {
523
- if (list && typeof list === 'string') {
524
- if (/^\[.*\]$/.test(list)) {
525
- return list
526
- .substring(1, list.length - 1)
527
- .split(/\s*,\s*/)
528
- .filter(function (item) { return item; });
529
- }
530
- else {
531
- return list.split(/\s*,\s*/).filter(function (item) { return item; });
532
- }
533
- }
534
- return list;
535
- }
536
- function getConditionValue(input, isTrue, trueValue, falseValue, data) {
537
- return isTrue || (!isTrue && falseValue)
538
- ? getStrOrVariable(isTrue ? trueValue : falseValue, data)
539
- : input;
540
- }
541
- function registerFilter(name, fn) {
542
- exports.filters[name] = fn;
543
- }
544
- exports.registerFilter = registerFilter;
545
- function getFilters() {
546
- return exports.filters;
547
- }
548
- exports.getFilters = getFilters;
549
- function pickValues(names, data) {
550
- var _a;
551
- var arr;
552
- if (!names || ((arr = names.split(',')) && arr.length < 2)) {
553
- var idx = names.indexOf('~');
554
- if (~idx) {
555
- var key = names.substring(0, idx);
556
- var target = names.substring(idx + 1);
557
- return _a = {},
558
- _a[key] = (0, exports.resolveVariable)(target, data),
559
- _a;
560
- }
561
- return (0, exports.resolveVariable)(names, data);
562
- }
563
- var ret = {};
564
- arr.forEach(function (name) {
565
- var idx = name.indexOf('~');
566
- var target = name;
567
- if (~idx) {
568
- target = name.substring(idx + 1);
569
- name = name.substring(0, idx);
570
- }
571
- (0, helper_1.setVariable)(ret, name, (0, exports.resolveVariable)(target, data));
572
- });
573
- return ret;
574
- }
575
- exports.pickValues = pickValues;
576
- function objectGet(data, path) {
577
- if (typeof data[path] !== 'undefined') {
578
- return data[path];
579
- }
580
- var parts = (0, helper_1.keyToPath)(path.replace(/^{|}$/g, ''));
581
- return parts.reduce(function (data, path) {
582
- if (((0, helper_1.isObject)(data) || Array.isArray(data)) && path in data) {
583
- return data[path];
584
- }
585
- return undefined;
586
- }, data);
587
- }
588
- function parseJson(str, defaultValue) {
589
- try {
590
- return JSON.parse(str);
591
- }
592
- catch (e) {
593
- return defaultValue;
594
- }
595
- }
596
- function getCookie(name) {
597
- var value = "; " + document.cookie;
598
- var parts = value.split("; " + name + "=");
599
- if (parts.length === 2) {
600
- return parts.pop().split(';').shift();
601
- }
602
- return undefined;
603
- }
604
- var resolveVariable = function (path, data) {
605
- if (data === void 0) { data = {}; }
606
- if (!path || !data || typeof path !== 'string') {
607
- return undefined;
608
- }
609
- var _a = path.split(':'), ns = _a[0], varname = _a[1];
610
- if (!varname && ns) {
611
- varname = ns;
612
- ns = '';
613
- }
614
- if (ns === 'window') {
615
- data = window;
616
- }
617
- else if (ns === 'ls' || ns === 'ss') {
618
- var parts = (0, helper_1.keyToPath)(varname.replace(/^{|}$/g, ''));
619
- var key = parts.shift();
620
- var raw = ns === 'ss' ? sessionStorage.getItem(key) : localStorage.getItem(key);
621
- if (typeof raw === 'string') {
622
- var data_1 = parseJson(raw, raw);
623
- if ((0, helper_1.isObject)(data_1) && parts.length) {
624
- return objectGet(data_1, parts.join('.'));
625
- }
626
- return data_1;
627
- }
628
- return undefined;
629
- }
630
- else if (ns === 'cookie') {
631
- var key = varname.replace(/^{|}$/g, '').trim();
632
- return getCookie(key);
633
- }
634
- if (varname === '$$') {
635
- return data;
636
- }
637
- else if (varname[0] === '$') {
638
- varname = path.substring(1);
639
- }
640
- else if (varname === '&') {
641
- return data;
642
- }
643
- return objectGet(data, varname);
644
- };
645
- exports.resolveVariable = resolveVariable;
646
- function isPureVariable(path) {
647
- return typeof path === 'string'
648
- ? /^\$(?:((?:\w+\:)?[a-z0-9_.][a-z0-9_.\[\]]*)|{[^}{]+})$/i.test(path)
649
- : false;
650
- }
651
- exports.isPureVariable = isPureVariable;
652
- var resolveVariableAndFilter = function (path, data, defaultFilter, fallbackValue) {
653
- if (data === void 0) { data = {}; }
654
- if (defaultFilter === void 0) { defaultFilter = '| html'; }
655
- if (fallbackValue === void 0) { fallbackValue = function (value) { return value; }; }
656
- if (!path) {
657
- return undefined;
658
- }
659
- var m = /^(\\)?\$(?:((?:\w+\:)?[a-z0-9_.][a-z0-9_.\[\]]*)|{([\s\S]+)})$/i.exec(path);
660
- if (!m) {
661
- return undefined;
662
- }
663
- var _ = m[0], escape = m[1], key = m[2], key2 = m[3];
664
- // 如果是转义如: `\$abc` => `$abc`
665
- if (escape) {
666
- return _.substring(1);
667
- }
668
- var finalKey = key || key2;
669
- // 先只支持一层吧
670
- finalKey = finalKey.replace(/(\\|\\\$)?\$(?:([a-zA-Z0-9_.][a-zA-Z0-9_.\[\]]*)|{([^}{]+)})/g, function (_, escape) {
671
- return escape
672
- ? _.substring(1)
673
- : (0, exports.resolveVariableAndFilter)(_, data, defaultFilter);
674
- });
675
- // 默认 html 转义
676
- if (!~finalKey.indexOf('|')) {
677
- finalKey += defaultFilter;
678
- }
679
- var paths = finalKey.split(/\s*\|\s*/g);
680
- var originalKey = finalKey;
681
- finalKey = paths.shift();
682
- var ret = (0, exports.resolveVariable)(finalKey, data);
683
- var prevConInputChanged = false; // 前一个类三元过滤器生效,则跳过后续类三元过滤器
684
- return ret == null &&
685
- !~originalKey.indexOf('default') &&
686
- !~originalKey.indexOf('now')
687
- ? fallbackValue(ret)
688
- : paths.reduce(function (input, filter) {
689
- var _a, _b;
690
- var params = filter
691
- .replace(/([^\\])\\([\:\\])/g, function (_, affix, content) {
692
- return affix + "__" + (content === ':' ? 'colon' : 'slash') + "__";
693
- })
694
- .split(':')
695
- .map(function (item) {
696
- return item.replace(/__(slash|colon)__/g, function (_, type) {
697
- return type === 'colon' ? ':' : '\\';
698
- });
699
- });
700
- var key = params.shift();
701
- if (~[
702
- 'isTrue',
703
- 'isFalse',
704
- 'isMatch',
705
- 'isEquals',
706
- 'notMatch',
707
- 'notEquals'
708
- ].indexOf(key)) {
709
- if (prevConInputChanged) {
710
- return input;
711
- }
712
- else {
713
- var result = (_a = exports.filters[key]).call.apply(_a, (0, tslib_1.__spreadArray)([data, input], params, false));
714
- prevConInputChanged = result !== input;
715
- return result;
716
- }
717
- }
718
- else {
719
- // 后面再遇到非类三元filter就重置了吧,不影响再后面的其他三元filter
720
- prevConInputChanged = false;
721
- }
722
- return (_b = (exports.filters[key] || exports.filters.raw)).call.apply(_b, (0, tslib_1.__spreadArray)([data, input], params, false));
723
- }, ret);
724
- };
725
- exports.resolveVariableAndFilter = resolveVariableAndFilter;
726
- var tokenize = function (str, data, defaultFilter) {
727
- if (defaultFilter === void 0) { defaultFilter = '| html'; }
728
- if (!str || typeof str !== 'string') {
729
- return str;
730
- }
731
- return str.replace(/(\\)?\$(?:((?:\w+\:)?[a-z0-9_\.][a-z0-9_\.\[\]]*|&|\$)|{([^}{]+?)})/gi, function (_, escape, key1, key2, index, source) {
732
- var _a;
733
- if (!escape && key1 === '$') {
734
- var prefix = source[index - 1];
735
- return prefix === '='
736
- ? encodeURIComponent(JSON.stringify(data))
737
- : (0, helper_1.qsstringify)(data);
738
- }
739
- return escape
740
- ? _.substring(1)
741
- : (_a = (0, exports.resolveVariableAndFilter)(_, data, defaultFilter)) !== null && _a !== void 0 ? _a : '';
742
- });
743
- };
744
- exports.tokenize = tokenize;
7
+ var amis_formula_1 = require("amis-formula");
8
+ Object.defineProperty(exports, "prettyBytes", { enumerable: true, get: function () { return amis_formula_1.prettyBytes; } });
9
+ Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return amis_formula_1.escapeHtml; } });
10
+ Object.defineProperty(exports, "formatDuration", { enumerable: true, get: function () { return amis_formula_1.formatDuration; } });
11
+ Object.defineProperty(exports, "filterDate", { enumerable: true, get: function () { return amis_formula_1.filterDate; } });
12
+ Object.defineProperty(exports, "relativeValueRe", { enumerable: true, get: function () { return amis_formula_1.relativeValueRe; } });
13
+ Object.defineProperty(exports, "parseDuration", { enumerable: true, get: function () { return amis_formula_1.parseDuration; } });
14
+ Object.defineProperty(exports, "getFilters", { enumerable: true, get: function () { return amis_formula_1.getFilters; } });
15
+ Object.defineProperty(exports, "registerFilter", { enumerable: true, get: function () { return amis_formula_1.registerFilter; } });
16
+ Object.defineProperty(exports, "pickValues", { enumerable: true, get: function () { return amis_formula_1.pickValues; } });
17
+ Object.defineProperty(exports, "resolveVariable", { enumerable: true, get: function () { return amis_formula_1.resolveVariable; } });
18
+ Object.defineProperty(exports, "isPureVariable", { enumerable: true, get: function () { return amis_formula_1.isPureVariable; } });
19
+ Object.defineProperty(exports, "resolveVariableAndFilter", { enumerable: true, get: function () { return amis_formula_1.resolveVariableAndFilter; } });
20
+ Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return amis_formula_1.tokenize; } });
21
+ Object.defineProperty(exports, "stripNumber", { enumerable: true, get: function () { return amis_formula_1.stripNumber; } });
745
22
  function resolveMapping(value, data, defaultFilter) {
746
23
  if (defaultFilter === void 0) { defaultFilter = '| raw'; }
747
- return typeof value === 'string' && isPureVariable(value)
748
- ? (0, exports.resolveVariableAndFilter)(value, data, defaultFilter, function () { return ''; })
24
+ return typeof value === 'string' && (0, amis_formula_1.isPureVariable)(value)
25
+ ? (0, amis_formula_1.resolveVariableAndFilter)(value, data, defaultFilter, function () { return ''; })
749
26
  : typeof value === 'string' && ~value.indexOf('$')
750
- ? (0, exports.tokenize)(value, data, defaultFilter)
27
+ ? (0, amis_formula_1.tokenize)(value, data, defaultFilter)
751
28
  : value;
752
29
  }
753
30
  exports.resolveMapping = resolveMapping;
@@ -892,7 +169,12 @@ function register() {
892
169
  },
893
170
  compile: function (str, data, defaultFilter) {
894
171
  if (defaultFilter === void 0) { defaultFilter = '| html'; }
895
- return (0, exports.tokenize)(str, data, defaultFilter);
172
+ try {
173
+ return (0, amis_formula_1.tokenize)(str, data, defaultFilter);
174
+ }
175
+ catch (e) {
176
+ return "error: " + e.message;
177
+ }
896
178
  }
897
179
  };
898
180
  }