diginet-core-ui 1.3.78 → 1.3.79

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 (209) hide show
  1. package/components/accordion/details.js +2 -6
  2. package/components/accordion/group.js +2 -9
  3. package/components/accordion/index.js +2 -15
  4. package/components/accordion/summary.js +4 -27
  5. package/components/alert/index.js +98 -137
  6. package/components/alert/notify.js +97 -166
  7. package/components/avatar/index.js +4 -63
  8. package/components/badge/index.js +7 -34
  9. package/components/button/icon.js +120 -186
  10. package/components/button/index.js +136 -205
  11. package/components/button/more.js +0 -12
  12. package/components/button/ripple-effect.js +46 -44
  13. package/components/card/body.js +2 -7
  14. package/components/card/extra.js +2 -7
  15. package/components/card/footer.js +2 -7
  16. package/components/card/header.js +2 -7
  17. package/components/card/index.js +2 -22
  18. package/components/chart/Pie/Circle.js +0 -1
  19. package/components/chart/Pie/Sector.js +0 -17
  20. package/components/chart/Pie/Sectors.js +0 -10
  21. package/components/chart/Pie/index.js +4 -36
  22. package/components/chart/Pie-v2/Circle.js +0 -1
  23. package/components/chart/Pie-v2/Sector.js +0 -13
  24. package/components/chart/Pie-v2/Sectors.js +0 -20
  25. package/components/chart/Pie-v2/index.js +11 -38
  26. package/components/chart/bar/Axis.js +0 -12
  27. package/components/chart/bar/Bar.js +13 -35
  28. package/components/chart/bar/Grid.js +0 -18
  29. package/components/chart/bar/Labels.js +0 -18
  30. package/components/chart/bar/Points.js +0 -17
  31. package/components/chart/bar/index.js +6 -26
  32. package/components/chart/bar-v2/Axis.js +0 -12
  33. package/components/chart/bar-v2/Bar.js +15 -36
  34. package/components/chart/bar-v2/Grid.js +0 -18
  35. package/components/chart/bar-v2/Labels.js +0 -18
  36. package/components/chart/bar-v2/Points.js +0 -17
  37. package/components/chart/bar-v2/index.js +6 -26
  38. package/components/chart/line/Axis.js +4 -16
  39. package/components/chart/line/Grid.js +2 -19
  40. package/components/chart/line/Labels.js +0 -18
  41. package/components/chart/line/Path.js +23 -33
  42. package/components/chart/line/Point.js +6 -40
  43. package/components/chart/line/Title.js +0 -3
  44. package/components/chart/line/index.js +12 -35
  45. package/components/chart/line-v2/Axis.js +0 -13
  46. package/components/chart/line-v2/Grid.js +0 -18
  47. package/components/chart/line-v2/Labels.js +0 -18
  48. package/components/chart/line-v2/Path.js +23 -33
  49. package/components/chart/line-v2/Point.js +6 -35
  50. package/components/chart/line-v2/Title.js +0 -3
  51. package/components/chart/line-v2/index.js +12 -30
  52. package/components/check-text/index.js +0 -8
  53. package/components/check-text/interview-confirmation.js +0 -7
  54. package/components/check-text/interview-status.js +0 -7
  55. package/components/chip/attach.js +4 -17
  56. package/components/chip/index.js +6 -33
  57. package/components/collapse/index.js +0 -13
  58. package/components/divider/index.js +0 -8
  59. package/components/form-control/attachment/index.js +24 -202
  60. package/components/form-control/calendar/function.js +40 -94
  61. package/components/form-control/calendar/index.js +5 -30
  62. package/components/form-control/calendar/range.js +11 -28
  63. package/components/form-control/checkbox/index.js +4 -37
  64. package/components/form-control/control/index.js +3 -13
  65. package/components/form-control/date-picker/index-old.js +18 -0
  66. package/components/form-control/date-picker/index.js +23 -99
  67. package/components/form-control/date-range-picker/index.js +86 -221
  68. package/components/form-control/dropdown/index.js +72 -289
  69. package/components/form-control/dropdown-box/index.js +6 -35
  70. package/components/form-control/form/index.js +0 -2
  71. package/components/form-control/form-group/index.js +1 -6
  72. package/components/form-control/helper-text/index.js +2 -9
  73. package/components/form-control/input-base/index.js +218 -399
  74. package/components/form-control/label/index.js +2 -12
  75. package/components/form-control/money-input/index.js +43 -132
  76. package/components/form-control/number-input/index.js +15 -113
  77. package/components/form-control/number-input/index2.js +78 -119
  78. package/components/form-control/phone-input/index.js +16 -78
  79. package/components/form-control/radio/index.js +4 -23
  80. package/components/form-control/text-input/index.js +33 -256
  81. package/components/form-control/time-picker/index.js +14 -71
  82. package/components/form-control/time-picker/swiper.js +21 -73
  83. package/components/form-control/toggle/index.js +4 -19
  84. package/components/form-view/helper-text.js +2 -2
  85. package/components/form-view/index.js +0 -14
  86. package/components/form-view/input.js +2 -13
  87. package/components/form-view/label.js +0 -2
  88. package/components/grid/Col.js +2 -15
  89. package/components/grid/Container.js +2 -21
  90. package/components/grid/Row.js +2 -21
  91. package/components/grid/index.js +2 -43
  92. package/components/image/index.js +2 -22
  93. package/components/index.js +62 -31
  94. package/components/list/list-item-action.js +0 -9
  95. package/components/list/list-item-icon.js +0 -9
  96. package/components/list/list-item-text.js +0 -5
  97. package/components/list/list-item.js +0 -11
  98. package/components/list/list.js +0 -13
  99. package/components/list/sub-header.js +0 -4
  100. package/components/modal/body.js +2 -6
  101. package/components/modal/footer.js +2 -11
  102. package/components/modal/header.js +2 -12
  103. package/components/modal/index.js +2 -10
  104. package/components/modal/modal.js +11 -52
  105. package/components/others/extra/index.js +3 -10
  106. package/components/others/import/index.js +0 -7
  107. package/components/others/option-wrapper/index.js +4 -7
  108. package/components/others/scrollbar/index.js +0 -3
  109. package/components/paging/page-info.js +39 -101
  110. package/components/paging/page-selector.js +7 -35
  111. package/components/paging/page-selector2.js +35 -74
  112. package/components/paper/index.js +0 -11
  113. package/components/popover/body.js +2 -6
  114. package/components/popover/footer.js +2 -11
  115. package/components/popover/header.js +2 -7
  116. package/components/popover/index.js +39 -123
  117. package/components/popup/danger_popup.js +0 -19
  118. package/components/popup/index.js +2 -48
  119. package/components/popup/proposals_popup.js +10 -49
  120. package/components/popup/v2/index.js +0 -31
  121. package/components/progress/circular.js +19 -81
  122. package/components/progress/linear.js +4 -20
  123. package/components/rating/index.js +0 -24
  124. package/components/slider/slider-container.js +3 -40
  125. package/components/slider/slider-item.js +10 -25
  126. package/components/status/index.js +2 -16
  127. package/components/tab/tab-container.js +2 -16
  128. package/components/tab/tab-header.js +4 -24
  129. package/components/tab/tab-panel.js +4 -16
  130. package/components/tab/tab.js +4 -28
  131. package/components/tooltip/index.js +12 -97
  132. package/components/tooltip/portal.js +0 -2
  133. package/components/transfer/index.js +22 -67
  134. package/components/tree-view/index.js +62 -202
  135. package/components/typography/index.js +3 -31
  136. package/global/index.js +0 -8
  137. package/icons/basic.js +0 -48
  138. package/icons/effect.js +17 -29
  139. package/icons/general/clock/clock.js +0 -2
  140. package/icons/general/color-handler/background.js +0 -2
  141. package/icons/general/color-handler/text.js +0 -2
  142. package/icons/general/emoji/emoji.js +0 -2
  143. package/icons/general/font-properties/bold.js +0 -2
  144. package/icons/general/font-properties/font-family.js +0 -2
  145. package/icons/general/font-properties/font-size.js +0 -2
  146. package/icons/general/font-properties/italic.js +0 -2
  147. package/icons/general/font-properties/underline.js +0 -2
  148. package/icons/general/hyperlink/hyperlink.js +0 -2
  149. package/icons/general/indent/decrease.js +0 -2
  150. package/icons/general/indent/increase.js +0 -2
  151. package/icons/general/list/bullets.js +0 -2
  152. package/icons/general/list/numbering.js +0 -2
  153. package/icons/general/picture/picture.js +0 -2
  154. package/icons/general/steps/redo.js +0 -2
  155. package/icons/general/steps/undo.js +0 -2
  156. package/icons/general/text-align/center.js +0 -2
  157. package/icons/general/text-align/justify.js +0 -2
  158. package/icons/general/text-align/left.js +0 -2
  159. package/icons/general/text-align/right.js +0 -2
  160. package/icons/menu/dhr.js +2 -1
  161. package/icons/menu/index.js +2 -2
  162. package/icons/menu/v2/index.js +0 -10
  163. package/package.json +1 -1
  164. package/readme.md +11 -1
  165. package/styles/animation.js +15 -58
  166. package/styles/color-helper.js +24 -54
  167. package/styles/colors.js +17 -9
  168. package/styles/general.js +6 -2
  169. package/styles/typography.js +4 -4
  170. package/styles/utils.js +2 -2
  171. package/theme/createBreakpoints.js +7 -18
  172. package/theme/make-styles.js +2 -5
  173. package/theme/set-theme.js +3 -6
  174. package/theme/settings.js +3 -2
  175. package/theme/theme-provider.js +0 -1
  176. package/utils/array/array.js +14 -23
  177. package/utils/classNames.js +0 -5
  178. package/utils/console.js +0 -6
  179. package/utils/date.js +13 -82
  180. package/utils/error/error.js +1 -9
  181. package/utils/error/errors.js +1 -48
  182. package/utils/getFileType.js +0 -9
  183. package/utils/handleBreakpoints.js +0 -5
  184. package/utils/intersectionObserver.js +0 -5
  185. package/utils/iterator.js +0 -9
  186. package/utils/map-parent.js +3 -10
  187. package/utils/object/extend.js +0 -10
  188. package/utils/object/object.js +12 -11
  189. package/utils/parseHTML.js +0 -1
  190. package/utils/promisify.js +0 -5
  191. package/utils/randomString.js +0 -7
  192. package/utils/remove-unicode.js +0 -1
  193. package/utils/render-portal.js +1 -9
  194. package/utils/renderHTML.js +4 -6
  195. package/utils/renderIcon.js +4 -14
  196. package/utils/sb-template.js +6 -5
  197. package/utils/string/capitalize.js +0 -1
  198. package/utils/string/capitalizeSentenceCase.js +0 -2
  199. package/utils/string/string.js +0 -13
  200. package/utils/type.js +0 -21
  201. package/utils/updatePosition.js +4 -5
  202. package/utils/useDelayUnmount.js +0 -4
  203. package/utils/useElementSize.js +9 -3
  204. package/utils/useEventListener.js +12 -6
  205. package/utils/useInput.js +0 -6
  206. package/utils/useMediaQuery.js +8 -10
  207. package/utils/useOnClickOutside.js +0 -2
  208. package/utils/usePortal.js +3 -10
  209. package/utils/validate.js +6 -20
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const FontFamily = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -32,5 +31,4 @@ const FontFamily = ({
32
31
  fill: pathFill
33
32
  })));
34
33
  };
35
-
36
34
  export default FontFamily;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const FontSize = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -24,5 +23,4 @@ const FontSize = ({
24
23
  fill: pathFill
25
24
  }));
26
25
  };
27
-
28
26
  export default FontSize;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Italic = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Italic = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Italic;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Underline = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -28,5 +27,4 @@ const Underline = ({
28
27
  fill: pathFill
29
28
  })));
30
29
  };
31
-
32
30
  export default Underline;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Hyperlink = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -35,5 +34,4 @@ const Hyperlink = ({
35
34
  fill: pathFill
36
35
  })));
37
36
  };
38
-
39
37
  export default Hyperlink;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Decrease = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -52,5 +51,4 @@ const Decrease = ({
52
51
  fill: pathFill
53
52
  })));
54
53
  };
55
-
56
54
  export default Decrease;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Increase = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -52,5 +51,4 @@ const Increase = ({
52
51
  fill: pathFill
53
52
  })));
54
53
  };
55
-
56
54
  export default Increase;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Bullets = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -74,5 +73,4 @@ const Bullets = ({
74
73
  fill: pathFill
75
74
  })));
76
75
  };
77
-
78
76
  export default Bullets;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Bullets = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -68,5 +67,4 @@ const Bullets = ({
68
67
  fill: pathFill
69
68
  })));
70
69
  };
71
-
72
70
  export default Bullets;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Picture = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Picture = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Picture;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Redo = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Redo = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Redo;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Undo = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Undo = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Undo;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Center = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Center = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Center;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Justify = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Justify = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Justify;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Left = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Left = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Left;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
-
4
3
  const Right = ({
5
4
  width = '1em',
6
5
  height = '1em',
@@ -18,5 +17,4 @@ const Right = ({
18
17
  fill: pathFill
19
18
  }));
20
19
  };
21
-
22
20
  export default Right;
package/icons/menu/dhr.js CHANGED
@@ -1501,8 +1501,9 @@ export const MHRP77N0010 = /*#__PURE__*/memo(() => {
1501
1501
  d: "M29.24 19a10 10 0 1010 10 10 10 0 00-10-10zm6.23 6.77l-5.94 8.05a1.944 1.944 0 01-1.45.78 1.893 1.893 0 01-1.52-.63l-3.46-3.84a1.487 1.487 0 112.21-1.99l2.45 2.72a.2.2 0 00.14.06.21.21 0 00.14-.07l5.04-6.83a1.486 1.486 0 012.08-.31 1.46 1.46 0 01.31 2.06z",
1502
1502
  fill: "#1ca261"
1503
1503
  }))));
1504
- }); // Icon HRM Web6
1504
+ });
1505
1505
 
1506
+ // Icon HRM Web6
1506
1507
  export const MHRM39N0014 = /*#__PURE__*/memo(() => {
1507
1508
  return /*#__PURE__*/React.createElement("svg", {
1508
1509
  width: 29.707,
@@ -1,5 +1,5 @@
1
- import * as IconMenu from '.'; // MENU
2
-
1
+ import * as IconMenu from '.';
2
+ // MENU
3
3
  export * as DHR from './menu/dhr';
4
4
  export * as ERP from './menu/erp';
5
5
  export default IconMenu;
@@ -1,9 +1,6 @@
1
1
  /* eslint-disable no-undef */
2
-
3
2
  /* eslint-disable no-empty */
4
-
5
3
  /** @jsxRuntime classic */
6
-
7
4
  /** @jsx jsx */
8
5
  import { memo, forwardRef, useRef, useMemo } from 'react';
9
6
  import PropTypes from 'prop-types';
@@ -17,17 +14,13 @@ const IconMenu = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
17
14
  if (!ref) {
18
15
  ref = useRef(null);
19
16
  }
20
-
21
17
  const getResourceImage = fileName => {
22
18
  let icon = require('../../../assets/images/menu/dhr/Default.svg');
23
-
24
19
  try {
25
20
  icon = require('../../../assets/images/menu/' + `${type}/` + fileName);
26
21
  } catch (e) {}
27
-
28
22
  return icon;
29
23
  };
30
-
31
24
  return useMemo(() => jsx("img", {
32
25
  src: getResourceImage(name + '.svg'),
33
26
  width: width,
@@ -44,13 +37,10 @@ IconMenu.defaultProps = {
44
37
  IconMenu.propTypes = {
45
38
  /** Menu type (DHR || ERP || BEM). */
46
39
  type: PropTypes.oneOf(['dhr', 'erp', 'bem']),
47
-
48
40
  /** Name of icon. */
49
41
  name: PropTypes.string,
50
-
51
42
  /** Width of icon. */
52
43
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
53
-
54
44
  /** Height of icon. */
55
45
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
56
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.78",
3
+ "version": "1.3.79",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -38,8 +38,18 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.79
42
+ - \[Changed\]: Button – Add prop labelProps; Allow use CUI colors
43
+ - \[Changed\]: InputBase – Add startIcon, endIcon to multiline textarea; Add viewType none; Optimize code
44
+ - \[Changed\]: Notify – Replace prop color with type; Change duration from seconds to milliseconds; Refactoring code
45
+ - \[Changed\]: ButtonIcon – Add tabIndex; Optimize code
46
+ - \[Changed\]: DateRangePicker – Hide clear button when disabled or readonly
47
+ - \[Changed\]: TextInput – Add prop nonStyle; Add viewType none
48
+ - \[Changed\]: Ripple – useImperativeHandle method start
49
+ - \[Fixed\]: Popover – Fix wrong position when use method show
50
+
41
51
  ## 1.3.78
42
- - \[Changed\]: DropDown – Update UI mode multi and optimize render multi selected
52
+ - \[Changed\]: Dropdown – Update UI mode multi and optimize render multi selected
43
53
 
44
54
  ## 1.3.77
45
55
  - \[Changed\]: DateRangePicker – Add method show to ref
@@ -1,23 +1,20 @@
1
1
  /* eslint-disable no-prototype-builtins */
2
2
  import { keyframes } from '@emotion/core';
3
3
  import { promisify } from '../utils';
4
-
5
4
  const loadStyles = css => {
6
- let head = document.head || document.getElementsByTagName('head')[0]; // no <head> node? create one...
5
+ let head = document.head || document.getElementsByTagName('head')[0];
7
6
 
7
+ // no <head> node? create one...
8
8
  if (!head) {
9
9
  head = document.createElement('head');
10
10
  const body = document.body || document.getElementsByTagName('body')[0];
11
-
12
11
  if (body) {
13
12
  body.parentNode.insertBefore(head, body);
14
13
  } else {
15
14
  document.documentElement.appendChild(head);
16
15
  }
17
16
  }
18
-
19
17
  const style = document.createElement('style');
20
-
21
18
  if (style.styleSheet) {
22
19
  // IE
23
20
  style.styleSheet.cssText = css;
@@ -25,61 +22,48 @@ const loadStyles = css => {
25
22
  // the world
26
23
  style.appendChild(document.createTextNode(css));
27
24
  }
28
-
29
25
  head.appendChild(style);
30
26
  return style;
31
27
  };
32
-
33
28
  const pfx = ['webkit', 'moz', 'MS', 'o', ''];
34
-
35
29
  const addStyleEvent = (el, type, callback = () => {}) => {
36
30
  for (let p in pfx) {
37
31
  if (!pfx[p]) {
38
32
  type = type.toLowerCase();
39
33
  }
40
-
41
34
  el.addEventListener(pfx[p] + type, callback, false);
42
35
  }
43
36
  };
44
-
45
37
  const removeStyleEvent = (el, type, callback = () => {}) => {
46
38
  for (let p in pfx) {
47
39
  if (!pfx[p]) {
48
40
  type = type.toLowerCase();
49
41
  }
50
-
51
42
  el.removeEventListener(pfx[p] + type, callback, false);
52
43
  }
53
44
  };
54
-
55
45
  const getTransformProperty = () => {
56
46
  const styles = ['webkitTransform', 'MozTransform', 'msTransform', 'OTransform', 'transform'];
57
47
  const el = document.createElement('p');
58
48
  let style;
59
-
60
49
  for (let i in styles) {
61
50
  style = styles[i];
62
-
63
51
  if (el.style[style] !== null) {
64
52
  return style;
65
53
  }
66
54
  }
67
55
  };
68
-
69
56
  const getAnimationProperty = () => {
70
57
  const styles = ['webkitAnimation', 'MozAnimation', 'msAnimation', 'OAnimation', 'animation'];
71
58
  const el = document.createElement('div');
72
59
  let style;
73
-
74
60
  for (let i in styles) {
75
61
  style = styles[i];
76
-
77
62
  if (el.style[style] !== null) {
78
63
  return style;
79
64
  }
80
65
  }
81
66
  };
82
-
83
67
  const registeredAnimations = {};
84
68
  const mainDefaults = {
85
69
  duration: 1000,
@@ -94,51 +78,43 @@ const mainDefaults = {
94
78
  export const hasAnimation = name => {
95
79
  return registeredAnimations.hasOwnProperty(name);
96
80
  };
97
-
98
81
  const clearTransformProp = el => {
99
82
  el.style.transform = '';
100
83
  el.style[getTransformProperty()] = '';
101
84
  };
102
-
103
85
  const clearAnimationProp = el => {
104
86
  el.style[getAnimationProperty()] = '';
105
87
  el.style.animation = '';
106
88
  };
107
-
108
89
  const setAnimationProp = (els, val, opts) => {
109
- const clearTransforms = opts && opts.clearTransforms === true; // we got a collection, potentially
110
-
90
+ const clearTransforms = opts && opts.clearTransforms === true;
91
+ // we got a collection, potentially
111
92
  for (let i in els) {
112
93
  // we do both because... chrome does both
113
94
  if (clearTransforms) {
114
95
  clearTransformProp(els[i]);
115
96
  }
116
-
117
97
  if (els[i].style) {
118
98
  els[i].style[getAnimationProperty()] = val;
119
99
  }
120
100
  }
121
101
  };
122
-
123
102
  const addUnit = (item, unit) => {
124
103
  if (typeof item === 'string') {
125
104
  return item;
126
105
  }
127
-
128
106
  return item + unit;
129
107
  };
130
-
131
108
  const getValueForProperty = (val, prop) => {
132
109
  if (val.hasOwnProperty(prop)) {
133
110
  return val[prop];
134
111
  }
135
-
136
112
  return 0;
137
113
  };
138
-
139
114
  const createCssTranslateString = val => {
140
- var res = []; // array of values is assumed to be [x,y,(z)]
115
+ var res = [];
141
116
 
117
+ // array of values is assumed to be [x,y,(z)]
142
118
  if (Array.isArray(val)) {
143
119
  if (val.length === 2) {
144
120
  res = res.concat(val, 0);
@@ -150,13 +126,11 @@ const createCssTranslateString = val => {
150
126
  res.push(getValueForProperty(val, 'y'));
151
127
  res.push(getValueForProperty(val, 'z'));
152
128
  }
153
-
154
129
  res = res.map(function (val) {
155
130
  return addUnit(val, 'px');
156
131
  });
157
132
  return 'translate3d(' + res.join(',') + ')';
158
133
  };
159
-
160
134
  const lookups = {
161
135
  scale: val => {
162
136
  return 'scale(' + val + ')';
@@ -171,23 +145,22 @@ const lookups = {
171
145
  return val;
172
146
  }
173
147
  };
174
-
175
148
  const prefix = () => {
176
149
  if (typeof document !== 'undefined') {
177
150
  const el = document.documentElement || document.createElement('div');
178
151
  return el.style.animation !== null ? '' : '-webkit-';
179
152
  }
180
153
  };
181
-
182
154
  const getStyles = obj => {
183
155
  // array of values is assumed to be [x,y,(z)]
156
+
184
157
  if (Array.isArray(obj)) {
185
158
  return prefix() + 'transform:' + createCssTranslateString(obj);
186
159
  }
187
-
188
160
  let transformBuff = [],
189
- otherStyles = []; // object assumes
161
+ otherStyles = [];
190
162
 
163
+ // object assumes
191
164
  if (typeof obj === 'object') {
192
165
  for (let key in obj) {
193
166
  if (lookups[key]) {
@@ -197,34 +170,29 @@ const getStyles = obj => {
197
170
  }
198
171
  }
199
172
  }
200
-
201
173
  otherStyles.push(prefix() + 'transform:' + transformBuff.join(''));
202
174
  return otherStyles.join(';');
203
175
  };
204
-
205
176
  const getLine = (percentage, styles) => {
206
177
  if (typeof percentage === 'number') {
207
178
  percentage += '%';
208
179
  } else if (typeof percentage === 'string' && percentage.indexOf('%') === -1) {
209
180
  percentage += '%';
210
181
  }
211
-
212
182
  return percentage + '{' + getStyles(styles) + '}';
213
183
  };
214
-
215
184
  const createKeyframeAnimation = (name, positions) => {
216
- let buf = '@' + prefix() + 'keyframes ' + name + '{'; // we got an array of arrays
185
+ let buf = '@' + prefix() + 'keyframes ' + name + '{';
217
186
 
187
+ // we got an array of arrays
218
188
  if (Array.isArray(positions)) {
219
189
  buf += positions.map(function (pos, index) {
220
190
  let percentage;
221
-
222
191
  if (index) {
223
192
  percentage = index / (positions.length - 1) * 100;
224
193
  } else {
225
194
  percentage = 0;
226
195
  }
227
-
228
196
  return getLine(percentage, pos);
229
197
  }).join('');
230
198
  } else {
@@ -232,58 +200,47 @@ const createKeyframeAnimation = (name, positions) => {
232
200
  buf += getLine(key, positions[key]);
233
201
  }
234
202
  }
235
-
236
203
  buf += '}';
237
204
  return buf;
238
205
  };
239
-
240
206
  const setAnimationAsTransform = (els, opts) => {
241
- const clearAnimations = opts && opts.clearAnimations === true; // we got a collection, potentially
242
-
207
+ const clearAnimations = opts && opts.clearAnimations === true;
208
+ // we got a collection, potentially
243
209
  for (let i in els) {
244
210
  els[i].style[getTransformProperty()] = getComputedStyle(els[i])[getTransformProperty()];
245
211
  if (clearAnimations) clearAnimationProp(els[i]);
246
212
  }
247
213
  };
248
-
249
214
  export const runAnimation = promisify((els, opts, cb = () => {}) => {
250
215
  if (typeof opts === 'string') {
251
216
  opts = {
252
217
  name: opts
253
218
  };
254
219
  }
255
-
256
220
  if (!els.length) {
257
221
  els = [els];
258
222
  }
259
-
260
223
  if (!opts.name) {
261
224
  return cb(Error('must supply animation name'));
262
225
  }
263
-
264
226
  const found = registeredAnimations[opts.name];
265
-
266
227
  if (!found) {
267
228
  return cb(Error(`no animation named ${opts.name} exists`));
268
229
  }
269
-
270
- opts = { ...opts,
230
+ opts = {
231
+ ...opts,
271
232
  ...found.presets,
272
233
  ...mainDefaults
273
234
  };
274
-
275
235
  const animationEnd = () => {
276
236
  removeStyleEvent(els[0], 'AnimationEnd', animationEnd);
277
-
278
237
  if (opts.resetWhenDone) {
279
238
  setAnimationAsTransform(els, {
280
239
  clearAnimations: true
281
240
  });
282
241
  }
283
-
284
242
  return cb(null, els);
285
243
  };
286
-
287
244
  addStyleEvent(els[0], 'AnimationEnd', animationEnd);
288
245
  const styles = [opts.name, addUnit(opts.duration, 'ms'), opts.easing, opts.iterations, addUnit(opts.delay, 'ms'), opts.direction, opts.fillMode];
289
246
  setAnimationProp(els, styles.join(' '), {