linear-react-components-ui 1.1.14-beta.0 → 1.1.14-beta.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 (367) hide show
  1. package/.eslintrc.json +45 -77
  2. package/.gitlab-ci.yml +13 -5
  3. package/.nvmrc +1 -0
  4. package/.vscode/settings.json +12 -3
  5. package/babel.config.json +4 -4
  6. package/lib/@types/SizePixels.d.ts +1 -1
  7. package/lib/alerts/AlertContainer.js +48 -57
  8. package/lib/alerts/AlertProvider.js +36 -54
  9. package/lib/alerts/BaseAlert.js +12 -19
  10. package/lib/alerts/Message.d.ts +1 -1
  11. package/lib/alerts/Message.js +78 -45
  12. package/lib/alerts/helpers.js +2 -3
  13. package/lib/alerts/index.js +3 -4
  14. package/lib/alerts/types.d.ts +1 -0
  15. package/lib/alerts/withAlert.js +10 -11
  16. package/lib/assets/styles/alerts.scss +4 -7
  17. package/lib/assets/styles/button.scss +11 -9
  18. package/lib/assets/styles/checkbox.scss +45 -38
  19. package/lib/assets/styles/colors.scss +3 -1
  20. package/lib/assets/styles/commons.scss +1 -0
  21. package/lib/assets/styles/dialog.scss +37 -20
  22. package/lib/assets/styles/drawers.scss +9 -6
  23. package/lib/assets/styles/error.scss +9 -0
  24. package/lib/assets/styles/fieldset.scss +3 -0
  25. package/lib/assets/styles/gridlayout.scss +0 -2
  26. package/lib/assets/styles/hint.scss +21 -0
  27. package/lib/assets/styles/icon.scss +31 -4
  28. package/lib/assets/styles/input.scss +7 -7
  29. package/lib/assets/styles/multiSelect.scss +6 -1
  30. package/lib/assets/styles/radio.scss +37 -35
  31. package/lib/assets/styles/select.scss +13 -7
  32. package/lib/assets/styles/table.scss +9 -1
  33. package/lib/assets/styles/tabs.scss +28 -18
  34. package/lib/assets/styles/textContent.scss +9 -0
  35. package/lib/avatar/index.js +41 -41
  36. package/lib/badge/index.js +12 -14
  37. package/lib/buttons/ActivateButton.js +6 -9
  38. package/lib/buttons/AddButton.js +9 -12
  39. package/lib/buttons/Button.js +11 -12
  40. package/lib/buttons/ButtonGroups.js +6 -5
  41. package/lib/buttons/CancelButton.js +10 -9
  42. package/lib/buttons/DangerButton.js +10 -9
  43. package/lib/buttons/DefaultButton.js +90 -90
  44. package/lib/buttons/DestroyButton.js +10 -9
  45. package/lib/buttons/EditButton.js +6 -9
  46. package/lib/buttons/InactivateButton.js +6 -9
  47. package/lib/buttons/InfoButton.js +10 -9
  48. package/lib/buttons/PrimaryButton.js +10 -9
  49. package/lib/buttons/RestoreButton.js +6 -9
  50. package/lib/buttons/SaveButton.js +10 -9
  51. package/lib/buttons/SuccessButton.js +10 -9
  52. package/lib/buttons/WarningButton.js +10 -9
  53. package/lib/buttons/button_container/index.js +17 -21
  54. package/lib/buttons/index.js +16 -17
  55. package/lib/buttons/split_button/index.js +22 -25
  56. package/lib/buttons/types.d.ts +1 -0
  57. package/lib/calendar/DangerCalendar.js +10 -9
  58. package/lib/calendar/InfoCalendar.js +10 -9
  59. package/lib/calendar/PrimaryCalendar.js +10 -9
  60. package/lib/calendar/SuccessCalendar.js +10 -9
  61. package/lib/calendar/WarningCalendar.js +10 -9
  62. package/lib/calendar/base/Day.js +13 -12
  63. package/lib/calendar/base/Month.js +13 -18
  64. package/lib/calendar/base/Week.js +13 -18
  65. package/lib/calendar/base/helpers.js +12 -12
  66. package/lib/calendar/base/index.js +30 -44
  67. package/lib/calendar/index.js +7 -8
  68. package/lib/checkbox/Label.js +20 -10
  69. package/lib/checkbox/index.d.ts +2 -2
  70. package/lib/checkbox/index.js +83 -97
  71. package/lib/checkbox/types.d.ts +2 -1
  72. package/lib/dialog/Alert.js +5 -6
  73. package/lib/dialog/Custom.js +16 -18
  74. package/lib/dialog/Error.js +5 -6
  75. package/lib/dialog/Information.js +5 -6
  76. package/lib/dialog/Question.js +13 -14
  77. package/lib/dialog/Warning.js +7 -7
  78. package/lib/dialog/base/Content.js +8 -6
  79. package/lib/dialog/base/Footer.js +5 -8
  80. package/lib/dialog/base/Header.js +29 -29
  81. package/lib/dialog/base/index.d.ts +8 -2
  82. package/lib/dialog/base/index.js +109 -105
  83. package/lib/dialog/base/style.js +7 -10
  84. package/lib/dialog/form/index.js +31 -34
  85. package/lib/dialog/index.js +8 -9
  86. package/lib/dialog/types.d.ts +8 -13
  87. package/lib/drawer/Content.js +12 -11
  88. package/lib/drawer/Drawer.js +74 -88
  89. package/lib/drawer/Header.js +34 -37
  90. package/lib/drawer/helpers.js +3 -4
  91. package/lib/drawer/index.js +4 -5
  92. package/lib/dropdown/Popup.d.ts +1 -1
  93. package/lib/dropdown/Popup.js +41 -42
  94. package/lib/dropdown/helper.js +3 -5
  95. package/lib/dropdown/types.d.ts +1 -0
  96. package/lib/dropdown/withDropdown.js +39 -60
  97. package/lib/fieldset/index.js +52 -58
  98. package/lib/fieldset/types.d.ts +2 -0
  99. package/lib/form/Field.d.ts +2 -0
  100. package/lib/form/Field.js +73 -79
  101. package/lib/form/FieldArray.d.ts +2 -0
  102. package/lib/form/FieldArray.js +70 -94
  103. package/lib/form/FieldNumber.d.ts +2 -0
  104. package/lib/form/FieldNumber.js +39 -48
  105. package/lib/form/FieldPeriod.d.ts +2 -0
  106. package/lib/form/FieldPeriod.js +48 -54
  107. package/lib/form/helpers.d.ts +2 -0
  108. package/lib/form/helpers.js +22 -27
  109. package/lib/form/index.d.ts +2 -0
  110. package/lib/form/index.js +114 -146
  111. package/lib/form/types.d.ts +6 -2
  112. package/lib/form/withFieldHOC.d.ts +2 -0
  113. package/lib/form/withFieldHOC.js +32 -39
  114. package/lib/form/withFormSecurity.d.ts +2 -0
  115. package/lib/form/withFormSecurity.js +27 -35
  116. package/lib/gridlayout/GridCol.js +14 -14
  117. package/lib/gridlayout/GridRow.js +18 -12
  118. package/lib/gridlayout/index.js +3 -4
  119. package/lib/gridlayout/types.d.ts +1 -1
  120. package/lib/hint/helpers.d.ts +3 -0
  121. package/lib/hint/helpers.js +21 -0
  122. package/lib/hint/index.d.ts +2 -1
  123. package/lib/hint/index.js +18 -29
  124. package/lib/hint/types.d.ts +3 -0
  125. package/lib/icons/helper.d.ts +4 -0
  126. package/lib/icons/helper.js +7 -4
  127. package/lib/icons/index.d.ts +3 -2
  128. package/lib/icons/index.js +43 -48
  129. package/lib/icons/types.d.ts +22 -9
  130. package/lib/index.d.ts +2 -1
  131. package/lib/index.js +10 -10
  132. package/lib/inputs/base/InputTextBase.d.ts +2 -0
  133. package/lib/inputs/base/InputTextBase.js +149 -113
  134. package/lib/inputs/base/Label.d.ts +14 -0
  135. package/lib/inputs/base/Label.js +35 -0
  136. package/lib/inputs/base/helpers.d.ts +3 -2
  137. package/lib/inputs/base/helpers.js +21 -26
  138. package/lib/inputs/base/types.d.ts +17 -2
  139. package/lib/inputs/color/index.js +29 -40
  140. package/lib/inputs/date/Dialog.d.ts +2 -0
  141. package/lib/inputs/date/Dialog.js +9 -10
  142. package/lib/inputs/date/Dropdown.d.ts +2 -0
  143. package/lib/inputs/date/Dropdown.js +12 -11
  144. package/lib/inputs/date/helpers.d.ts +2 -0
  145. package/lib/inputs/date/helpers.js +14 -14
  146. package/lib/inputs/date/index.d.ts +2 -0
  147. package/lib/inputs/date/index.js +127 -152
  148. package/lib/inputs/date/types.d.ts +4 -1
  149. package/lib/inputs/{mask/imaskHOC.d.ts → errorMessage/index.d.ts} +5 -7
  150. package/lib/inputs/errorMessage/index.js +26 -0
  151. package/lib/inputs/file/DefaultFile.d.ts +2 -0
  152. package/lib/inputs/file/DefaultFile.js +47 -74
  153. package/lib/inputs/file/DragDropFile.d.ts +2 -0
  154. package/lib/inputs/file/DragDropFile.js +97 -149
  155. package/lib/inputs/file/File.d.ts +3 -1
  156. package/lib/inputs/file/File.js +26 -32
  157. package/lib/inputs/file/FileButtonSettings.d.ts +2 -0
  158. package/lib/inputs/file/FileButtonSettings.js +13 -13
  159. package/lib/inputs/file/helpers.d.ts +2 -0
  160. package/lib/inputs/file/helpers.js +4 -6
  161. package/lib/inputs/file/index.d.ts +2 -0
  162. package/lib/inputs/file/index.js +4 -5
  163. package/lib/inputs/file/types.d.ts +2 -0
  164. package/lib/inputs/inputHOC.d.ts +2 -1
  165. package/lib/inputs/inputHOC.js +21 -34
  166. package/lib/inputs/mask/BaseMask.d.ts +4 -5
  167. package/lib/inputs/mask/BaseMask.js +125 -37
  168. package/lib/inputs/mask/Cnpj.d.ts +2 -0
  169. package/lib/inputs/mask/Cnpj.js +18 -31
  170. package/lib/inputs/mask/Cpf.d.ts +2 -0
  171. package/lib/inputs/mask/Cpf.js +20 -37
  172. package/lib/inputs/mask/Phone.d.ts +2 -0
  173. package/lib/inputs/mask/Phone.js +7 -6
  174. package/lib/inputs/mask/ZipCode.d.ts +2 -0
  175. package/lib/inputs/mask/ZipCode.js +6 -9
  176. package/lib/inputs/mask/helpers.d.ts +50 -12
  177. package/lib/inputs/mask/helpers.js +77 -37
  178. package/lib/inputs/mask/index.d.ts +4 -2
  179. package/lib/inputs/mask/index.js +6 -7
  180. package/lib/inputs/mask/types.d.ts +18 -17
  181. package/lib/inputs/multiSelect/ActionButtons.d.ts +2 -0
  182. package/lib/inputs/multiSelect/ActionButtons.js +23 -22
  183. package/lib/inputs/multiSelect/Dropdown.d.ts +2 -0
  184. package/lib/inputs/multiSelect/Dropdown.js +50 -67
  185. package/lib/inputs/multiSelect/helper.d.ts +2 -0
  186. package/lib/inputs/multiSelect/helper.js +8 -7
  187. package/lib/inputs/multiSelect/index.d.ts +2 -0
  188. package/lib/inputs/multiSelect/index.js +83 -135
  189. package/lib/inputs/multiSelect/types.d.ts +2 -0
  190. package/lib/inputs/number/BaseNumber.d.ts +2 -1
  191. package/lib/inputs/number/BaseNumber.js +25 -24
  192. package/lib/inputs/number/Currency.d.ts +2 -1
  193. package/lib/inputs/number/Currency.js +8 -8
  194. package/lib/inputs/number/Decimal.d.ts +2 -1
  195. package/lib/inputs/number/Decimal.js +3 -6
  196. package/lib/inputs/number/format_number.js +5 -5
  197. package/lib/inputs/number/index.d.ts +2 -1
  198. package/lib/inputs/number/index.js +20 -32
  199. package/lib/inputs/number/types.d.ts +2 -9
  200. package/lib/inputs/period/Dialog.d.ts +3 -1
  201. package/lib/inputs/period/Dialog.js +9 -10
  202. package/lib/inputs/period/Dropdown.d.ts +2 -0
  203. package/lib/inputs/period/Dropdown.js +8 -9
  204. package/lib/inputs/period/PeriodList.d.ts +2 -0
  205. package/lib/inputs/period/PeriodList.js +14 -13
  206. package/lib/inputs/period/helper.d.ts +2 -0
  207. package/lib/inputs/period/helper.js +34 -37
  208. package/lib/inputs/period/index.d.ts +2 -0
  209. package/lib/inputs/period/index.js +162 -196
  210. package/lib/inputs/period/types.d.ts +3 -1
  211. package/lib/inputs/search/index.d.ts +2 -1
  212. package/lib/inputs/search/index.js +45 -68
  213. package/lib/inputs/select/ActionButtons.d.ts +2 -1
  214. package/lib/inputs/select/ActionButtons.js +25 -35
  215. package/lib/inputs/select/Dropdown.d.ts +2 -1
  216. package/lib/inputs/select/Dropdown.js +41 -60
  217. package/lib/inputs/select/helper.d.ts +2 -1
  218. package/lib/inputs/select/helper.js +49 -43
  219. package/lib/inputs/select/index.d.ts +2 -0
  220. package/lib/inputs/select/index.js +13 -12
  221. package/lib/inputs/select/multiple/Selecteds.d.ts +3 -1
  222. package/lib/inputs/select/multiple/Selecteds.js +17 -22
  223. package/lib/inputs/select/multiple/index.d.ts +2 -0
  224. package/lib/inputs/select/multiple/index.js +125 -162
  225. package/lib/inputs/select/simple/index.d.ts +2 -0
  226. package/lib/inputs/select/simple/index.js +154 -179
  227. package/lib/inputs/select/types.d.ts +5 -2
  228. package/lib/inputs/text/index.js +3 -6
  229. package/lib/inputs/textarea/index.d.ts +2 -0
  230. package/lib/inputs/textarea/index.js +10 -10
  231. package/lib/inputs/textarea/types.d.ts +2 -0
  232. package/lib/inputs/types.d.ts +12 -9
  233. package/lib/internals/colorStyles.js +2 -3
  234. package/lib/internals/constants.js +2 -4
  235. package/lib/internals/types.d.ts +5 -2
  236. package/lib/internals/withTooltip.d.ts +3 -2
  237. package/lib/internals/withTooltip.js +76 -76
  238. package/lib/labelMessages/index.js +22 -42
  239. package/lib/labels/DangerLabel.js +10 -9
  240. package/lib/labels/DefaultLabel.js +26 -40
  241. package/lib/labels/InfoLabel.js +10 -9
  242. package/lib/labels/PrimaryLabel.js +10 -9
  243. package/lib/labels/SuccessLabel.js +10 -9
  244. package/lib/labels/WarningLabel.js +10 -9
  245. package/lib/labels/index.js +8 -9
  246. package/lib/labels/label_container/index.js +8 -8
  247. package/lib/list/Header.js +9 -8
  248. package/lib/list/Item.js +74 -70
  249. package/lib/list/Separator.js +5 -8
  250. package/lib/list/helpers.js +4 -6
  251. package/lib/list/index.js +74 -101
  252. package/lib/menus/float/MenuItem.js +19 -20
  253. package/lib/menus/float/SubMenuContainer.js +27 -33
  254. package/lib/menus/float/helpers.js +3 -4
  255. package/lib/menus/float/index.js +17 -18
  256. package/lib/menus/float/types.d.ts +1 -1
  257. package/lib/menus/index.js +2 -3
  258. package/lib/menus/sidenav/ExpandMenu.js +9 -8
  259. package/lib/menus/sidenav/MenuLink.js +10 -9
  260. package/lib/menus/sidenav/NavMenuGroup.js +12 -11
  261. package/lib/menus/sidenav/NavMenuItem.js +48 -62
  262. package/lib/menus/sidenav/NavSubMenuItem.js +20 -25
  263. package/lib/menus/sidenav/helpers.js +6 -9
  264. package/lib/menus/sidenav/index.js +85 -113
  265. package/lib/menus/sidenav/popup_menu_search/EmptyList.js +7 -7
  266. package/lib/menus/sidenav/popup_menu_search/index.js +64 -84
  267. package/lib/menus/sidenav/types.d.ts +1 -1
  268. package/lib/noPermission/index.js +14 -17
  269. package/lib/panel/Content.d.ts +1 -1
  270. package/lib/panel/Content.js +47 -60
  271. package/lib/panel/DangerPanel.d.ts +1 -1
  272. package/lib/panel/DangerPanel.js +6 -9
  273. package/lib/panel/Default.d.ts +1 -1
  274. package/lib/panel/Default.js +45 -60
  275. package/lib/panel/Header.d.ts +1 -1
  276. package/lib/panel/Header.js +32 -30
  277. package/lib/panel/InfoPanel.d.ts +1 -1
  278. package/lib/panel/InfoPanel.js +6 -9
  279. package/lib/panel/PrimaryPanel.d.ts +1 -1
  280. package/lib/panel/PrimaryPanel.js +6 -9
  281. package/lib/panel/SuccessPanel.d.ts +1 -1
  282. package/lib/panel/SuccessPanel.js +6 -9
  283. package/lib/panel/ToolBar.d.ts +1 -1
  284. package/lib/panel/ToolBar.js +6 -5
  285. package/lib/panel/WarningPanel.d.ts +1 -1
  286. package/lib/panel/WarningPanel.js +6 -9
  287. package/lib/panel/helpers.d.ts +7 -2
  288. package/lib/panel/helpers.js +12 -24
  289. package/lib/panel/index.d.ts +1 -1
  290. package/lib/panel/index.js +9 -10
  291. package/lib/panel/types.d.ts +46 -5
  292. package/lib/permissionValidations.js +24 -29
  293. package/lib/popover/PopoverText.js +6 -5
  294. package/lib/popover/PopoverTitle.js +6 -5
  295. package/lib/popover/index.js +15 -19
  296. package/lib/progress/Bar.js +31 -37
  297. package/lib/progress/index.js +18 -20
  298. package/lib/radio/index.js +36 -57
  299. package/lib/shortcuts/index.js +10 -9
  300. package/lib/skeleton/SkeletonContainer.js +10 -11
  301. package/lib/skeleton/index.js +27 -34
  302. package/lib/spinner/SpinnerLoading.js +7 -8
  303. package/lib/spinner/index.js +23 -37
  304. package/lib/split/Split.js +95 -112
  305. package/lib/split/SplitSide.js +20 -19
  306. package/lib/split/helpers.js +3 -4
  307. package/lib/split/index.js +3 -4
  308. package/lib/table/Body.js +42 -45
  309. package/lib/table/Header.js +29 -32
  310. package/lib/table/HeaderColumn.d.ts +1 -1
  311. package/lib/table/HeaderColumn.js +35 -22
  312. package/lib/table/Row.js +45 -48
  313. package/lib/table/RowColumn.js +38 -39
  314. package/lib/table/helpers.js +7 -13
  315. package/lib/table/index.js +82 -102
  316. package/lib/table/types.d.ts +3 -0
  317. package/lib/tabs/DropdownTabs.d.ts +11 -0
  318. package/lib/tabs/DropdownTabs.js +71 -0
  319. package/lib/tabs/Menu.d.ts +1 -1
  320. package/lib/tabs/Menu.js +35 -23
  321. package/lib/tabs/{DropdownItems.d.ts → MenuTabs.d.ts} +3 -3
  322. package/lib/tabs/MenuTabs.js +82 -0
  323. package/lib/tabs/Panel.d.ts +1 -1
  324. package/lib/tabs/Panel.js +70 -66
  325. package/lib/tabs/context.d.ts +12 -0
  326. package/lib/tabs/context.js +130 -0
  327. package/lib/tabs/index.d.ts +1 -1
  328. package/lib/tabs/index.js +46 -225
  329. package/lib/tabs/tabHelpers.d.ts +4 -15
  330. package/lib/tabs/tabHelpers.js +37 -42
  331. package/lib/tabs/types.d.ts +48 -15
  332. package/lib/tabs/useTabs.d.ts +11 -0
  333. package/lib/tabs/useTabs.js +11 -0
  334. package/lib/textContent/index.d.ts +8 -0
  335. package/lib/textContent/index.js +30 -0
  336. package/lib/toolbar/ButtonBar.js +39 -43
  337. package/lib/toolbar/LabelBar.js +36 -40
  338. package/lib/toolbar/Separator.js +5 -8
  339. package/lib/toolbar/ToolBarGroup.js +7 -7
  340. package/lib/toolbar/helpers.js +2 -3
  341. package/lib/toolbar/index.js +23 -25
  342. package/lib/toolbar/types.d.ts +1 -0
  343. package/lib/tooltip/index.js +28 -33
  344. package/lib/treetable/Body.js +21 -33
  345. package/lib/treetable/Header.js +11 -14
  346. package/lib/treetable/Row.js +90 -142
  347. package/lib/treetable/helpers.js +15 -24
  348. package/lib/treetable/index.js +11 -13
  349. package/lib/treeview/Header.js +8 -7
  350. package/lib/treeview/Node.js +96 -136
  351. package/lib/treeview/constants.js +2 -3
  352. package/lib/treeview/index.js +150 -216
  353. package/lib/uitour/helpers.js +4 -7
  354. package/lib/uitour/index.d.ts +2 -1
  355. package/lib/uitour/index.js +113 -100
  356. package/lib/uitour/types.d.ts +9 -1
  357. package/package.json +77 -82
  358. package/tsconfig.json +1 -0
  359. package/.tool-versions +0 -1
  360. package/lib/inputs/mask/imaskHOC.js +0 -224
  361. package/lib/tabs/DropdownItems.js +0 -65
  362. package/lib/tabs/MenuItems.d.ts +0 -11
  363. package/lib/tabs/MenuItems.js +0 -76
  364. package/lib/treeview_old/Header.js +0 -28
  365. package/lib/treeview_old/Node.js +0 -88
  366. package/lib/treeview_old/index.js +0 -42
  367. package/lib/types-c2a0f035.d.ts +0 -50
package/lib/form/index.js CHANGED
@@ -1,30 +1,29 @@
1
1
  "use strict";
2
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
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  Object.defineProperty(exports, "Field", {
8
7
  enumerable: true,
9
- get: function get() {
8
+ get: function () {
10
9
  return _Field.default;
11
10
  }
12
11
  });
13
12
  Object.defineProperty(exports, "FieldArray", {
14
13
  enumerable: true,
15
- get: function get() {
14
+ get: function () {
16
15
  return _FieldArray.default;
17
16
  }
18
17
  });
19
18
  Object.defineProperty(exports, "FieldNumber", {
20
19
  enumerable: true,
21
- get: function get() {
20
+ get: function () {
22
21
  return _FieldNumber.default;
23
22
  }
24
23
  });
25
24
  Object.defineProperty(exports, "FieldPeriod", {
26
25
  enumerable: true,
27
- get: function get() {
26
+ get: function () {
28
27
  return _FieldPeriod.default;
29
28
  }
30
29
  });
@@ -39,131 +38,107 @@ var _FieldPeriod = _interopRequireDefault(require("./FieldPeriod"));
39
38
  require("../assets/styles/form.scss");
40
39
  var _dialog = require("../dialog");
41
40
  var _withFormSecurity = require("./withFormSecurity");
42
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
- 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); }
44
- 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; }
45
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
46
- 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; }
47
- 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; }
48
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
49
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
50
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
51
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
52
- 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."); }
53
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
54
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
55
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
56
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
57
- 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); }
58
- 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; }
59
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
60
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
61
- var Form = function Form(_ref) {
62
- var _ref$submitOnPressEnt = _ref.submitOnPressEnterKey,
63
- submitOnPressEnterKey = _ref$submitOnPressEnt === void 0 ? true : _ref$submitOnPressEnt,
64
- dataSource = _ref.dataSource,
65
- securityBeforeUnload = _ref.securityBeforeUnload,
66
- handlerReset = _ref.handlerReset,
67
- handlerSubmit = _ref.handlerSubmit,
68
- handlerValidates = _ref.handlerValidates,
69
- style = _ref.style,
70
- customClass = _ref.customClass,
71
- securityTitle = _ref.securityTitle,
72
- securityText = _ref.securityText,
73
- securityData = _ref.securityData,
74
- onDataChange = _ref.onDataChange,
75
- onValidateForm = _ref.onValidateForm,
76
- externalFieldErrors = _ref.externalFieldErrors,
77
- onSubmit = _ref.onSubmit,
78
- skeletonize = _ref.skeletonize,
79
- disabled = _ref.disabled,
80
- children = _ref.children,
81
- _ref$useInternalState = _ref.useInternalState,
82
- useInternalState = _ref$useInternalState === void 0 ? false : _ref$useInternalState;
83
- var _useState = (0, _react.useState)(dataSource),
84
- _useState2 = _slicedToArray(_useState, 2),
85
- data = _useState2[0],
86
- setData = _useState2[1];
87
- var _useState3 = (0, _react.useState)(dataSource),
88
- _useState4 = _slicedToArray(_useState3, 2),
89
- originalData = _useState4[0],
90
- setOriginalData = _useState4[1];
91
- var _useState5 = (0, _react.useState)(submitOnPressEnterKey),
92
- _useState6 = _slicedToArray(_useState5, 2),
93
- submitFormOnEnter = _useState6[0],
94
- setSubmitFormOnEnter = _useState6[1];
95
- var _useState7 = (0, _react.useState)({}),
96
- _useState8 = _slicedToArray(_useState7, 2),
97
- fieldErrors = _useState8[0],
98
- setFieldErrors = _useState8[1];
99
- var fieldsValidators = (0, _react.useRef)({});
100
- var _useState9 = (0, _react.useState)(0),
101
- _useState10 = _slicedToArray(_useState9, 2),
102
- oldFieldsValidatorsQuantity = _useState10[0],
103
- setOldFieldsValidatorsQuantity = _useState10[1];
104
- var context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
105
- var usedData = useInternalState ? data : dataSource;
106
- var getValidatesErrorMessages = function getValidatesErrorMessages(validators, fieldValue) {
107
- var validatorsArray = !(validators instanceof Array) ? [validators] : validators;
108
- var errors = [];
109
- validatorsArray.forEach(function (validator) {
41
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
42
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
43
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
44
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
45
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
46
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
47
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
48
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
49
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
50
+ const Form = _ref => {
51
+ let {
52
+ submitOnPressEnterKey = true,
53
+ dataSource,
54
+ securityBeforeUnload,
55
+ handlerReset,
56
+ handlerSubmit,
57
+ handlerValidates,
58
+ style,
59
+ customClass,
60
+ securityTitle,
61
+ securityText,
62
+ securityData,
63
+ onDataChange,
64
+ onValidateForm,
65
+ externalFieldErrors,
66
+ onSubmit,
67
+ skeletonize,
68
+ disabled,
69
+ children,
70
+ useInternalState = false
71
+ } = _ref;
72
+ const [data, setData] = (0, _react.useState)(dataSource);
73
+ const [originalData, setOriginalData] = (0, _react.useState)(dataSource);
74
+ const [submitFormOnEnter, setSubmitFormOnEnter] = (0, _react.useState)(submitOnPressEnterKey);
75
+ const [fieldErrors, setFieldErrors] = (0, _react.useState)({});
76
+ const fieldsValidators = (0, _react.useRef)({});
77
+ const [oldFieldsValidatorsQuantity, setOldFieldsValidatorsQuantity] = (0, _react.useState)(0);
78
+ const context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
79
+ const usedData = useInternalState ? data : dataSource;
80
+ const getValidatesErrorMessages = (validators, fieldValue) => {
81
+ const validatorsArray = !(validators instanceof Array) ? [validators] : validators;
82
+ let errors = [];
83
+ validatorsArray.forEach(validator => {
110
84
  if (typeof validator === 'function') {
111
- var result = validator(fieldValue);
112
- if (result) errors = [].concat(_toConsumableArray(errors), [result]);
85
+ const result = validator(fieldValue);
86
+ if (result) errors = [...errors, result];
113
87
  }
114
88
  });
115
89
  return errors;
116
90
  };
117
- var getErrorMessages = function getErrorMessages(currentData, currentValidators) {
118
- var dataValidate = currentData || usedData;
119
- var currentFieldErrors = _lodash.default.pickBy(fieldErrors, function (error, fieldName) {
120
- var fieldValidatorsNames = Object.keys(currentValidators);
91
+ const getErrorMessages = (currentData, currentValidators) => {
92
+ const dataValidate = currentData || usedData;
93
+ let currentFieldErrors = _lodash.default.pickBy(fieldErrors, (error, fieldName) => {
94
+ const fieldValidatorsNames = Object.keys(currentValidators);
121
95
  return fieldValidatorsNames.includes(fieldName);
122
96
  });
123
- _lodash.default.forEach(currentValidators, function (validators, fieldName) {
124
- var fieldValue = _lodash.default.get(dataValidate, fieldName);
125
- var messages = getValidatesErrorMessages(validators, fieldValue);
126
- currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, _defineProperty({}, fieldName, messages));
97
+ _lodash.default.forEach(currentValidators, (validators, fieldName) => {
98
+ const fieldValue = _lodash.default.get(dataValidate, fieldName);
99
+ const messages = getValidatesErrorMessages(validators, fieldValue);
100
+ currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, {
101
+ [fieldName]: messages
102
+ });
127
103
  });
128
104
  return currentFieldErrors;
129
105
  };
130
- var checkIsValid = function checkIsValid(currentData) {
131
- var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
132
- var currentValidators = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
133
- var currentFieldErrors = getErrorMessages(currentData, currentValidators || fieldsValidators.current);
106
+ const checkIsValid = function (currentData) {
107
+ let updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
108
+ let currentValidators = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
109
+ const currentFieldErrors = getErrorMessages(currentData, currentValidators || fieldsValidators.current);
134
110
  if (updateState) setFieldErrors(currentFieldErrors);
135
- return Object.values(currentFieldErrors).every(function (value) {
136
- return value.length === 0;
137
- });
111
+ return Object.values(currentFieldErrors).every(value => value.length === 0);
138
112
  };
139
- var onFieldChange = function onFieldChange(event) {
140
- var target = event.target;
113
+ const onFieldChange = (0, _react.useCallback)(event => {
114
+ const {
115
+ target
116
+ } = event;
141
117
  if (!useInternalState && onDataChange) {
142
- var newData = (0, _helpers.changeValue)(dataSource, target);
143
- onDataChange(newData);
118
+ onDataChange(prevState => (0, _helpers.changeValue)(prevState, target));
144
119
  } else {
145
- setData(function (prevState) {
146
- return (0, _helpers.changeValue)(prevState, target);
147
- });
120
+ setData(prevState => (0, _helpers.changeValue)(prevState, target));
148
121
  }
149
- };
150
- var onValidate = function onValidate(fieldName, fieldValue, validators) {
122
+ }, []);
123
+ const onValidate = (fieldName, fieldValue, validators) => {
151
124
  if (validators) {
152
- var currentFieldErrors = fieldErrors;
153
- var errors = getValidatesErrorMessages(validators, fieldValue);
125
+ let currentFieldErrors = fieldErrors;
126
+ const errors = getValidatesErrorMessages(validators, fieldValue);
154
127
  if (errors.length === 0) {
155
128
  currentFieldErrors = _lodash.default.omit(currentFieldErrors, fieldName);
156
129
  } else {
157
- currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, _defineProperty({}, fieldName, errors));
130
+ currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, {
131
+ [fieldName]: errors
132
+ });
158
133
  }
159
134
  setFieldErrors(currentFieldErrors);
160
135
  }
161
136
  };
162
- var onFormSubmit = function onFormSubmit(event) {
137
+ const onFormSubmit = (0, _react.useCallback)(event => {
163
138
  if (event) event.preventDefault();
164
139
  if (checkIsValid(usedData)) onSubmit(usedData);
165
- };
166
- var onReset = function onReset() {
140
+ }, [usedData]);
141
+ const onReset = () => {
167
142
  if (!useInternalState && onDataChange) {
168
143
  onDataChange(JSON.parse(JSON.stringify(originalData)));
169
144
  } else {
@@ -171,101 +146,95 @@ var Form = function Form(_ref) {
171
146
  }
172
147
  setFieldErrors({});
173
148
  };
174
- var onRemoveFieldValidators = function onRemoveFieldValidators(fieldName) {
175
- var newFieldsValidators = _lodash.default.omit(fieldsValidators, fieldName);
149
+ const onRemoveFieldValidators = fieldName => {
150
+ const newFieldsValidators = _lodash.default.omit(fieldsValidators, fieldName);
176
151
  fieldsValidators.current = newFieldsValidators;
177
152
  };
178
- var onBeforeUnload = function onBeforeUnload(e) {
179
- var event = e;
153
+ const onBeforeUnload = e => {
154
+ const event = e;
180
155
  event.preventDefault();
181
156
  if (_lodash.default.isEqual(usedData, originalData)) {
182
157
  return;
183
158
  }
184
159
  event.returnValue = true;
185
160
  };
186
- var submitOnEnter = function submitOnEnter(event) {
161
+ const submitOnEnter = event => {
187
162
  if (event.key === 'Enter') {
188
163
  event.preventDefault();
189
164
  if (submitFormOnEnter) onFormSubmit();
190
165
  }
191
166
  };
192
- var formProps = function formProps() {
193
- var propsForm = null;
167
+ const formProps = () => {
168
+ let propsForm = null;
194
169
  if (!disabled) {
195
170
  propsForm = {
196
- onSubmit: function onSubmit(event) {
197
- return event.preventDefault();
198
- },
199
- onKeyPress: function onKeyPress(event) {
200
- return submitOnEnter(event);
201
- }
171
+ onSubmit: event => event.preventDefault(),
172
+ onKeyPress: event => submitOnEnter(event)
202
173
  };
203
174
  }
204
175
  return propsForm;
205
176
  };
206
- var updateFormState = function updateFormState() {
177
+ const updateFormState = () => {
207
178
  if (!_lodash.default.isEmpty(context)) {
208
- var onChangedData = context.onChangedData;
179
+ const {
180
+ onChangedData
181
+ } = context;
209
182
  if (securityData && !_lodash.default.isEqual(usedData, securityData)) {
210
183
  onChangedData(true);
211
184
  } else {
212
185
  onChangedData(false);
213
186
  }
214
187
  }
215
- if (onDataChange) onDataChange(usedData);
188
+ if (onDataChange && useInternalState) onDataChange(usedData);
216
189
 
217
190
  // TODO - Usar debounce para evitar chamada a cada letra digitada
218
191
  if (onValidateForm) onValidateForm(checkIsValid(usedData, true));
219
192
  if (!disabled) {
220
193
  handlerSubmit(onFormSubmit);
221
194
  if (handlerReset) handlerReset(onReset);
222
- if (handlerValidates) handlerValidates(function () {
223
- return checkIsValid(usedData);
224
- });
195
+ if (handlerValidates) handlerValidates(() => checkIsValid(usedData));
225
196
  }
226
197
  if (_lodash.default.isEmpty(usedData)) setOriginalData(usedData);
227
198
  };
228
- (0, _react.useEffect)(function () {
199
+ (0, _react.useEffect)(() => {
229
200
  if (useInternalState) updateFormState();
230
201
  }, [JSON.stringify(data), useInternalState]);
231
- (0, _react.useEffect)(function () {
202
+ (0, _react.useEffect)(() => {
232
203
  if (!useInternalState && onDataChange) updateFormState();
233
204
  }, [JSON.stringify(dataSource), useInternalState]);
234
- (0, _react.useEffect)(function () {
205
+ (0, _react.useEffect)(() => {
235
206
  if (securityBeforeUnload) {
236
207
  if (context) context.setSecurityBeforeUnload(true);
237
208
  window.addEventListener('beforeunload', onBeforeUnload);
238
209
  }
239
- return function () {
240
- return window.removeEventListener('beforeunload', onBeforeUnload);
241
- };
210
+ return () => window.removeEventListener('beforeunload', onBeforeUnload);
242
211
  }, [securityBeforeUnload, onBeforeUnload]);
243
- (0, _react.useEffect)(function () {
212
+ (0, _react.useEffect)(() => {
244
213
  if (!disabled && submitOnPressEnterKey !== submitFormOnEnter) {
245
214
  setSubmitFormOnEnter(submitOnPressEnterKey);
246
215
  }
247
216
  }, [submitOnPressEnterKey]);
248
- (0, _react.useEffect)(function () {
249
- var newValidatorsQuantity = Object.values(fieldsValidators.current).reduce(function (acc, currentValue) {
250
- return acc + ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) || 0);
251
- }, 0);
217
+ (0, _react.useEffect)(() => {
218
+ const newValidatorsQuantity = Object.values(fieldsValidators.current).reduce((acc, currentValue) => acc + ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) || 0), 0);
252
219
  if (fieldsValidators.current && onValidateForm && oldFieldsValidatorsQuantity !== newValidatorsQuantity) {
253
220
  setOldFieldsValidatorsQuantity(newValidatorsQuantity);
254
221
  onValidateForm(checkIsValid(usedData, true, fieldsValidators.current));
255
222
  }
256
223
  }, [fieldsValidators.current, oldFieldsValidatorsQuantity, onValidateForm, JSON.stringify(usedData)]);
257
- var contextValues = {
258
- skeletonize: skeletonize,
224
+ const contextValues = {
225
+ skeletonize,
259
226
  handlerFieldChange: onFieldChange,
260
227
  handlerFieldValidade: onValidate,
261
- handlerStoreValidators: function handlerStoreValidators(fieldName, fieldValidates) {
262
- fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, _defineProperty({}, fieldName, fieldValidates));
228
+ handlerStoreValidators: (fieldName, fieldValidates) => {
229
+ fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, {
230
+ [fieldName]: fieldValidates
231
+ });
263
232
  },
264
233
  handlerRemoveValidators: onRemoveFieldValidators,
265
234
  data: useInternalState ? data : dataSource,
266
- originalData: originalData,
267
- fieldErrors: fieldErrors,
268
- externalFieldErrors: externalFieldErrors
235
+ originalData,
236
+ fieldErrors,
237
+ externalFieldErrors
269
238
  };
270
239
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_helpers.FormContext.Provider, {
271
240
  value: contextValues
@@ -279,9 +248,8 @@ var Form = function Form(_ref) {
279
248
  title: securityTitle || 'Dados Alterados',
280
249
  text: securityText || 'Você possui dados alterados, confirma o fechamento?',
281
250
  visible: !_lodash.default.isEmpty(context) && context.showQuestion,
282
- onConfirmClick: context ? context.onConfirmClick : function () {},
283
- onUnconfirmClick: context ? context.onUnconfirmClick : function () {}
251
+ onConfirmClick: context ? context.onConfirmClick : () => {},
252
+ onUnconfirmClick: context ? context.onUnconfirmClick : () => {}
284
253
  }));
285
254
  };
286
- var _default = Form;
287
- exports.default = _default;
255
+ var _default = exports.default = Form;
@@ -5,6 +5,8 @@ import '../@types/DataCombo.js';
5
5
  import '../@types/PermissionAttr.js';
6
6
  import '../inputs/base/types.js';
7
7
  import '../@types/Period.js';
8
+ import '../internals/types.js';
9
+ import '../@types/Position.js';
8
10
 
9
11
  type Validator = (value: string) => string | undefined;
10
12
  type PeriodValidator = (value: {
@@ -36,12 +38,13 @@ type BaseFormProps = {
36
38
  skeletonize?: boolean;
37
39
  disabled?: boolean;
38
40
  };
41
+ type OnDataChange = React.Dispatch<React.SetStateAction<any>>;
39
42
  type FormProps = BaseFormProps & ({
40
43
  useInternalState?: false;
41
- onDataChange: (data: object) => void;
44
+ onDataChange: OnDataChange;
42
45
  } | {
43
46
  useInternalState: true;
44
- onDataChange?: (data: object) => void;
47
+ onDataChange?: OnDataChange;
45
48
  });
46
49
  type Data = {
47
50
  [key: string]: any;
@@ -176,6 +179,7 @@ interface IWithFieldContext {
176
179
  handlerSetValidatorFromComponent: (validator: Validator | Validator[]) => void;
177
180
  }
178
181
  interface IWithFormSecurity {
182
+ onOpenChange?: (open: boolean) => void;
179
183
  handlerClose?: () => void;
180
184
  onClick?: MouseEventHandler;
181
185
  children?: ReactNode;
@@ -6,6 +6,8 @@ import '../@types/DataCombo.js';
6
6
  import '../@types/PermissionAttr.js';
7
7
  import '../inputs/base/types.js';
8
8
  import '../@types/Period.js';
9
+ import '../internals/types.js';
10
+ import '../@types/Position.js';
9
11
 
10
12
  declare const withFieldHOC: <ComponentProps extends WithFieldProps>(WrappedComponent: React__default.ComponentType<ComponentProps>) => React__default.ForwardRefExoticComponent<React__default.PropsWithoutRef<ComponentProps> & React__default.RefAttributes<HTMLElement>>;
11
13
 
@@ -1,47 +1,39 @@
1
1
  "use strict";
2
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
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
7
  var _react = _interopRequireWildcard(require("react"));
9
8
  var _helpers = require("./helpers");
10
- 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); }
11
- 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; }
12
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
- 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); }
16
- 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; }
17
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
18
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
- var withFieldHOC = function withFieldHOC(WrappedComponent) {
20
- var EnhancedComponent = function EnhancedComponent(props) {
21
- var name = props.name,
22
- validators = props.validators,
23
- handlerStoreValidators = props.handlerStoreValidators,
24
- handlerRemoveValidators = props.handlerRemoveValidators;
25
- var _useState = (0, _react.useState)(undefined),
26
- _useState2 = _slicedToArray(_useState, 2),
27
- validatorFromComponent = _useState2[0],
28
- setValidatorFromComponent = _useState2[1];
29
- var updateValidators = function updateValidators() {
30
- var validatorsArray = (0, _helpers.getValidatorsArray)(validators, validatorFromComponent);
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
12
+ const withFieldHOC = WrappedComponent => {
13
+ const EnhancedComponent = props => {
14
+ const {
15
+ name,
16
+ validators,
17
+ handlerStoreValidators,
18
+ handlerRemoveValidators
19
+ } = props;
20
+ const [validatorFromComponent, setValidatorFromComponent] = (0, _react.useState)(undefined);
21
+ const updateValidators = () => {
22
+ const validatorsArray = (0, _helpers.getValidatorsArray)(validators, validatorFromComponent);
31
23
  if (validatorsArray && handlerStoreValidators) handlerStoreValidators(name, validatorsArray);
32
24
  };
33
- (0, _react.useEffect)(function () {
25
+ (0, _react.useEffect)(() => {
34
26
  updateValidators();
35
- return function () {
27
+ return () => {
36
28
  if (validators && handlerRemoveValidators) handlerRemoveValidators(name);
37
29
  };
38
30
  }, []);
39
- (0, _react.useEffect)(function () {
31
+ (0, _react.useEffect)(() => {
40
32
  updateValidators();
41
33
  }, [validators]);
42
- var contextValues = {
43
- validatorFromComponent: validatorFromComponent,
44
- handlerSetValidatorFromComponent: function handlerSetValidatorFromComponent(validator) {
34
+ const contextValues = {
35
+ validatorFromComponent,
36
+ handlerSetValidatorFromComponent: validator => {
45
37
  setValidatorFromComponent(validator);
46
38
  }
47
39
  };
@@ -50,15 +42,17 @@ var withFieldHOC = function withFieldHOC(WrappedComponent) {
50
42
  }, /*#__PURE__*/_react.default.createElement(WrappedComponent, props));
51
43
  };
52
44
  function forwardRef(props, ref) {
53
- return /*#__PURE__*/_react.default.createElement(_helpers.FormContext.Consumer, null, function (_ref) {
54
- var handlerFieldChange = _ref.handlerFieldChange,
55
- handlerFieldValidade = _ref.handlerFieldValidade,
56
- data = _ref.data,
57
- fieldErrors = _ref.fieldErrors,
58
- externalFieldErrors = _ref.externalFieldErrors,
59
- handlerStoreValidators = _ref.handlerStoreValidators,
60
- handlerRemoveValidators = _ref.handlerRemoveValidators,
61
- skeletonize = _ref.skeletonize;
45
+ return /*#__PURE__*/_react.default.createElement(_helpers.FormContext.Consumer, null, _ref => {
46
+ let {
47
+ handlerFieldChange,
48
+ handlerFieldValidade,
49
+ data,
50
+ fieldErrors,
51
+ externalFieldErrors,
52
+ handlerStoreValidators,
53
+ handlerRemoveValidators,
54
+ skeletonize
55
+ } = _ref;
62
56
  return /*#__PURE__*/_react.default.createElement(EnhancedComponent, _extends({}, props, {
63
57
  skeletonize: skeletonize,
64
58
  handlerFieldChange: handlerFieldChange,
@@ -74,5 +68,4 @@ var withFieldHOC = function withFieldHOC(WrappedComponent) {
74
68
  }
75
69
  return /*#__PURE__*/_react.default.forwardRef(forwardRef);
76
70
  };
77
- var _default = withFieldHOC;
78
- exports.default = _default;
71
+ var _default = exports.default = withFieldHOC;
@@ -6,6 +6,8 @@ import '../@types/DataCombo.js';
6
6
  import '../@types/PermissionAttr.js';
7
7
  import '../inputs/base/types.js';
8
8
  import '../@types/Period.js';
9
+ import '../internals/types.js';
10
+ import '../@types/Position.js';
9
11
 
10
12
  declare const FormSecurityContext: React__default.Context<IFormSecurityContext>;
11
13
  declare const withFormSecurity: <ComponentProps extends IWithFormSecurity>(WrappedComponent: React__default.ComponentType<ComponentProps>) => (props: ComponentProps) => JSX.Element;