@codeleap/web 2.0.1 → 2.3.13

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 (97) hide show
  1. package/dist/components/ActivityIndicator/index.d.ts +12 -12
  2. package/dist/components/ActivityIndicator/index.js +60 -60
  3. package/dist/components/ActivityIndicator/styles.d.ts +53 -53
  4. package/dist/components/ActivityIndicator/styles.js +21 -21
  5. package/dist/components/Button.d.ts +18 -18
  6. package/dist/components/Button.js +66 -66
  7. package/dist/components/CenterWrapper.d.ts +7 -7
  8. package/dist/components/CenterWrapper.js +27 -27
  9. package/dist/components/Checkbox/index.d.ts +12 -12
  10. package/dist/components/Checkbox/index.js +61 -61
  11. package/dist/components/Checkbox/styles.d.ts +53 -53
  12. package/dist/components/Checkbox/styles.js +63 -63
  13. package/dist/components/Collapse.d.ts +20 -20
  14. package/dist/components/Collapse.js +67 -67
  15. package/dist/components/ContentView.d.ts +10 -10
  16. package/dist/components/ContentView.js +51 -51
  17. package/dist/components/Drawer.d.ts +23 -23
  18. package/dist/components/Drawer.js +72 -72
  19. package/dist/components/FileInput.d.ts +8 -8
  20. package/dist/components/FileInput.js +72 -72
  21. package/dist/components/HorizontalScroll.d.ts +3 -3
  22. package/dist/components/HorizontalScroll.js +41 -41
  23. package/dist/components/Icon.d.ts +8 -8
  24. package/dist/components/Icon.js +54 -54
  25. package/dist/components/Link.d.ts +7 -7
  26. package/dist/components/Link.js +62 -62
  27. package/dist/components/List.d.ts +18 -18
  28. package/dist/components/List.js +51 -51
  29. package/dist/components/Modal/index.d.ts +21 -21
  30. package/dist/components/Modal/index.js +119 -119
  31. package/dist/components/Modal/styles.d.ts +56 -56
  32. package/dist/components/Modal/styles.js +35 -35
  33. package/dist/components/Overlay.d.ts +10 -10
  34. package/dist/components/Overlay.js +40 -40
  35. package/dist/components/RadioInput/index.d.ts +21 -21
  36. package/dist/components/RadioInput/index.js +54 -54
  37. package/dist/components/RadioInput/styles.d.ts +54 -54
  38. package/dist/components/RadioInput/styles.js +43 -43
  39. package/dist/components/RouterPage/Menu.d.ts +10 -10
  40. package/dist/components/RouterPage/Menu.js +35 -35
  41. package/dist/components/RouterPage/MenuItem.d.ts +12 -12
  42. package/dist/components/RouterPage/MenuItem.js +41 -41
  43. package/dist/components/RouterPage/Router.d.ts +8 -8
  44. package/dist/components/RouterPage/Router.js +26 -26
  45. package/dist/components/RouterPage/index.d.ts +29 -29
  46. package/dist/components/RouterPage/index.js +88 -88
  47. package/dist/components/RouterPage/styles.d.ts +54 -54
  48. package/dist/components/RouterPage/styles.js +86 -86
  49. package/dist/components/Scroll.d.ts +5 -5
  50. package/dist/components/Scroll.js +23 -23
  51. package/dist/components/Select/Custom.d.ts +8 -8
  52. package/dist/components/Select/Custom.js +103 -103
  53. package/dist/components/Select/Multi.d.ts +3 -3
  54. package/dist/components/Select/Multi.js +104 -104
  55. package/dist/components/Select/Native.d.ts +17 -17
  56. package/dist/components/Select/Native.js +43 -43
  57. package/dist/components/Select/index.d.ts +12 -12
  58. package/dist/components/Select/index.js +43 -43
  59. package/dist/components/Select/styles.d.ts +5 -5
  60. package/dist/components/Select/styles.js +56 -56
  61. package/dist/components/Select/types.d.ts +49 -49
  62. package/dist/components/Select/types.js +2 -2
  63. package/dist/components/Slider.d.ts +5 -5
  64. package/dist/components/Slider.js +35 -35
  65. package/dist/components/Text.d.ts +9 -9
  66. package/dist/components/Text.js +40 -40
  67. package/dist/components/TextInput.d.ts +150 -150
  68. package/dist/components/TextInput.js +124 -124
  69. package/dist/components/Tooltip.d.ts +12 -12
  70. package/dist/components/Tooltip.js +121 -121
  71. package/dist/components/Touchable.d.ts +15 -15
  72. package/dist/components/Touchable.js +51 -51
  73. package/dist/components/View.d.ts +10 -10
  74. package/dist/components/View.js +61 -61
  75. package/dist/components/index.d.ts +24 -24
  76. package/dist/components/index.js +40 -40
  77. package/dist/index.d.ts +6 -6
  78. package/dist/index.js +28 -28
  79. package/dist/lib/OSAlert.d.ts +21 -21
  80. package/dist/lib/OSAlert.js +139 -139
  81. package/dist/lib/Toast.d.ts +13 -13
  82. package/dist/lib/Toast.js +31 -31
  83. package/dist/lib/hooks.d.ts +28 -28
  84. package/dist/lib/hooks.js +182 -182
  85. package/dist/lib/logger.d.ts +2 -2
  86. package/dist/lib/logger.js +15 -15
  87. package/dist/lib/utils/cookies.d.ts +6 -6
  88. package/dist/lib/utils/cookies.js +14 -14
  89. package/dist/lib/utils/index.d.ts +4 -4
  90. package/dist/lib/utils/index.js +26 -26
  91. package/dist/lib/utils/pollyfils/scroll.d.ts +1 -1
  92. package/dist/lib/utils/pollyfils/scroll.js +65 -65
  93. package/dist/lib/utils/stopPropagation.d.ts +1 -1
  94. package/dist/lib/utils/stopPropagation.js +19 -19
  95. package/dist/types/utility.d.ts +2 -2
  96. package/dist/types/utility.js +2 -2
  97. package/package.json +47 -47
package/dist/lib/hooks.js CHANGED
@@ -1,183 +1,183 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.usePagination = exports.DOTS = exports.useScrollEffect = exports.useClickOutside = exports.useWindowSize = void 0;
13
- var common_1 = require("@codeleap/common");
14
- var react_1 = require("react");
15
- function useWindowSize() {
16
- var _a = (0, react_1.useState)([]), size = _a[0], setSize = _a[1];
17
- (0, common_1.onMount)(function () {
18
- setSize([window.innerWidth, window.innerWidth]);
19
- });
20
- function handleResize() {
21
- setSize([window.innerWidth, window.innerHeight]);
22
- }
23
- (0, common_1.onUpdate)(function () {
24
- window.addEventListener('resize', handleResize);
25
- return function () {
26
- window.removeEventListener('resize', handleResize);
27
- };
28
- }, []);
29
- return size;
30
- }
31
- exports.useWindowSize = useWindowSize;
32
- // type UseClickOutsideOpts = {
33
- // customId?: string
34
- // deps?: any[]
35
- // }
36
- // export function useClickOutside(
37
- // callback: AnyFunction,
38
- // deps?: UseClickOutsideOpts,
39
- // ) {
40
- // const id = useRef(deps?.customId || v4())
41
- // const onClick = useCallback((e: Event) => {
42
- // const element = document.getElementById(id.current)
43
- // if (!element) return
44
- // const isInside = element.contains(e.target as Node) || ((e.target as HTMLElement).id === id.current)
45
- // // const iterNodes = (el:HTMLElement|Element) => {
46
- // // if (isInside) return
47
- // // for (let i = 0; i < el.children.length; i++) {
48
- // // const node = el.children.item(i)
49
- // // if (!node) return
50
- // // const _isInside = node.contains(e.target as Node)
51
- // // if (_isInside) {
52
- // // isInside = _isInside
53
- // // }
54
- // // if (isInside) break
55
- // // if (node.hasChildNodes()) {
56
- // // iterNodes(node)
57
- // // }
58
- // // if (isInside) break
59
- // // }
60
- // // }
61
- // // if (!isInside) {
62
- // // iterNodes(element)
63
- // // }
64
- // if (!isInside) {
65
- // callback(e)
66
- // }
67
- // }, deps?.deps || [])
68
- // onUpdate(() => {
69
- // document.addEventListener('click', onClick)
70
- // return () => {
71
- // document.removeEventListener('click', onClick)
72
- // }
73
- // }, [onClick])
74
- // return id.current
75
- // }
76
- var react_2 = require("react");
77
- var DEFAULT_EVENTS = ['mousedown', 'touchstart'];
78
- function useClickOutside(handler, events, nodes) {
79
- var ref = (0, react_1.useRef)();
80
- (0, react_2.useEffect)(function () {
81
- var listener = function (event) {
82
- var _a;
83
- if (Array.isArray(nodes)) {
84
- var shouldIgnore = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-ignore-outside-clicks');
85
- var shouldTrigger = nodes.every(function (node) { return !!node && !node.contains(event.target); });
86
- shouldTrigger && !shouldIgnore && handler();
87
- }
88
- else if (ref.current && !ref.current.contains(event.target)) {
89
- handler();
90
- }
91
- };
92
- (events || DEFAULT_EVENTS).forEach(function (fn) { return document.addEventListener(fn, listener); });
93
- return function () {
94
- (events || DEFAULT_EVENTS).forEach(function (fn) { return document.removeEventListener(fn, listener); });
95
- };
96
- }, [ref, handler, nodes]);
97
- return ref;
98
- }
99
- exports.useClickOutside = useClickOutside;
100
- function useScrollEffect(effect, breakpoint, extraDependencies) {
101
- if (extraDependencies === void 0) { extraDependencies = []; }
102
- function handleScroll() {
103
- var passed = window.scrollY > breakpoint;
104
- effect(passed, window.scrollY);
105
- }
106
- (0, common_1.onUpdate)(function () {
107
- document.addEventListener('scroll', handleScroll);
108
- return function () {
109
- document.removeEventListener('scroll', handleScroll);
110
- };
111
- }, __spreadArray([breakpoint], extraDependencies, true));
112
- }
113
- exports.useScrollEffect = useScrollEffect;
114
- exports.DOTS = 'dots';
115
- function usePagination(_a) {
116
- var total = _a.total, _b = _a.siblings, siblings = _b === void 0 ? 1 : _b, _c = _a.boundaries, boundaries = _c === void 0 ? 1 : _c, page = _a.page, _d = _a.initialPage, initialPage = _d === void 0 ? 1 : _d, onChange = _a.onChange;
117
- var _e = (0, common_1.useUncontrolled)({
118
- value: page,
119
- onChange: onChange,
120
- defaultValue: initialPage,
121
- finalValue: initialPage,
122
- rule: function (_page) { return typeof _page === 'number' && _page <= total; },
123
- }), activePage = _e[0], setActivePage = _e[1];
124
- var setPage = function (pageNumber) {
125
- if (pageNumber <= 0) {
126
- setActivePage(1);
127
- }
128
- else if (pageNumber > total) {
129
- setActivePage(total);
130
- }
131
- else {
132
- setActivePage(pageNumber);
133
- }
134
- };
135
- var next = function () { return setPage(activePage + 1); };
136
- var previous = function () { return setPage(activePage - 1); };
137
- var first = function () { return setPage(1); };
138
- var last = function () { return setPage(total); };
139
- var paginationRange = (0, react_1.useMemo)(function () {
140
- // Pages count is determined as siblings (left/right) + boundaries(left/right) + currentPage + 2*DOTS
141
- var totalPageNumbers = siblings * 2 + 3 + boundaries * 2;
142
- /*
143
- * If the number of pages is less than the page numbers we want to show in our
144
- * paginationComponent, we return the range [1..total]
145
- */
146
- if (totalPageNumbers >= total) {
147
- return (0, common_1.range)(1, total);
148
- }
149
- var leftSiblingIndex = Math.max(activePage - siblings, boundaries);
150
- var rightSiblingIndex = Math.min(activePage + siblings, total - boundaries);
151
- /*
152
- * We do not want to show dots if there is only one position left
153
- * after/before the left/right page count as that would lead to a change if our Pagination
154
- * component size which we do not want
155
- */
156
- var shouldShowLeftDots = leftSiblingIndex > boundaries + 2;
157
- var shouldShowRightDots = rightSiblingIndex < total - (boundaries + 1);
158
- if (!shouldShowLeftDots && shouldShowRightDots) {
159
- var leftItemCount = siblings * 2 + boundaries + 2;
160
- return __spreadArray(__spreadArray(__spreadArray([], (0, common_1.range)(1, leftItemCount), true), [exports.DOTS], false), (0, common_1.range)(total - (boundaries - 1), total), true);
161
- }
162
- if (shouldShowLeftDots && !shouldShowRightDots) {
163
- var rightItemCount = boundaries + 1 + 2 * siblings;
164
- return __spreadArray(__spreadArray(__spreadArray([], (0, common_1.range)(1, boundaries), true), [exports.DOTS], false), (0, common_1.range)(total - rightItemCount, total), true);
165
- }
166
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], (0, common_1.range)(1, boundaries), true), [
167
- exports.DOTS
168
- ], false), (0, common_1.range)(leftSiblingIndex, rightSiblingIndex), true), [
169
- exports.DOTS
170
- ], false), (0, common_1.range)(total - boundaries + 1, total), true);
171
- }, [total, siblings, activePage]);
172
- return {
173
- range: paginationRange,
174
- active: activePage,
175
- setPage: setPage,
176
- next: next,
177
- previous: previous,
178
- first: first,
179
- last: last,
180
- };
181
- }
182
- exports.usePagination = usePagination;
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.usePagination = exports.DOTS = exports.useScrollEffect = exports.useClickOutside = exports.useWindowSize = void 0;
13
+ var common_1 = require("@codeleap/common");
14
+ var react_1 = require("react");
15
+ function useWindowSize() {
16
+ var _a = (0, react_1.useState)([]), size = _a[0], setSize = _a[1];
17
+ (0, common_1.onMount)(function () {
18
+ setSize([window.innerWidth, window.innerWidth]);
19
+ });
20
+ function handleResize() {
21
+ setSize([window.innerWidth, window.innerHeight]);
22
+ }
23
+ (0, common_1.onUpdate)(function () {
24
+ window.addEventListener('resize', handleResize);
25
+ return function () {
26
+ window.removeEventListener('resize', handleResize);
27
+ };
28
+ }, []);
29
+ return size;
30
+ }
31
+ exports.useWindowSize = useWindowSize;
32
+ // type UseClickOutsideOpts = {
33
+ // customId?: string
34
+ // deps?: any[]
35
+ // }
36
+ // export function useClickOutside(
37
+ // callback: AnyFunction,
38
+ // deps?: UseClickOutsideOpts,
39
+ // ) {
40
+ // const id = useRef(deps?.customId || v4())
41
+ // const onClick = useCallback((e: Event) => {
42
+ // const element = document.getElementById(id.current)
43
+ // if (!element) return
44
+ // const isInside = element.contains(e.target as Node) || ((e.target as HTMLElement).id === id.current)
45
+ // // const iterNodes = (el:HTMLElement|Element) => {
46
+ // // if (isInside) return
47
+ // // for (let i = 0; i < el.children.length; i++) {
48
+ // // const node = el.children.item(i)
49
+ // // if (!node) return
50
+ // // const _isInside = node.contains(e.target as Node)
51
+ // // if (_isInside) {
52
+ // // isInside = _isInside
53
+ // // }
54
+ // // if (isInside) break
55
+ // // if (node.hasChildNodes()) {
56
+ // // iterNodes(node)
57
+ // // }
58
+ // // if (isInside) break
59
+ // // }
60
+ // // }
61
+ // // if (!isInside) {
62
+ // // iterNodes(element)
63
+ // // }
64
+ // if (!isInside) {
65
+ // callback(e)
66
+ // }
67
+ // }, deps?.deps || [])
68
+ // onUpdate(() => {
69
+ // document.addEventListener('click', onClick)
70
+ // return () => {
71
+ // document.removeEventListener('click', onClick)
72
+ // }
73
+ // }, [onClick])
74
+ // return id.current
75
+ // }
76
+ var react_2 = require("react");
77
+ var DEFAULT_EVENTS = ['mousedown', 'touchstart'];
78
+ function useClickOutside(handler, events, nodes) {
79
+ var ref = (0, react_1.useRef)();
80
+ (0, react_2.useEffect)(function () {
81
+ var listener = function (event) {
82
+ var _a;
83
+ if (Array.isArray(nodes)) {
84
+ var shouldIgnore = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-ignore-outside-clicks');
85
+ var shouldTrigger = nodes.every(function (node) { return !!node && !node.contains(event.target); });
86
+ shouldTrigger && !shouldIgnore && handler();
87
+ }
88
+ else if (ref.current && !ref.current.contains(event.target)) {
89
+ handler();
90
+ }
91
+ };
92
+ (events || DEFAULT_EVENTS).forEach(function (fn) { return document.addEventListener(fn, listener); });
93
+ return function () {
94
+ (events || DEFAULT_EVENTS).forEach(function (fn) { return document.removeEventListener(fn, listener); });
95
+ };
96
+ }, [ref, handler, nodes]);
97
+ return ref;
98
+ }
99
+ exports.useClickOutside = useClickOutside;
100
+ function useScrollEffect(effect, breakpoint, extraDependencies) {
101
+ if (extraDependencies === void 0) { extraDependencies = []; }
102
+ function handleScroll() {
103
+ var passed = window.scrollY > breakpoint;
104
+ effect(passed, window.scrollY);
105
+ }
106
+ (0, common_1.onUpdate)(function () {
107
+ document.addEventListener('scroll', handleScroll);
108
+ return function () {
109
+ document.removeEventListener('scroll', handleScroll);
110
+ };
111
+ }, __spreadArray([breakpoint], extraDependencies, true));
112
+ }
113
+ exports.useScrollEffect = useScrollEffect;
114
+ exports.DOTS = 'dots';
115
+ function usePagination(_a) {
116
+ var total = _a.total, _b = _a.siblings, siblings = _b === void 0 ? 1 : _b, _c = _a.boundaries, boundaries = _c === void 0 ? 1 : _c, page = _a.page, _d = _a.initialPage, initialPage = _d === void 0 ? 1 : _d, onChange = _a.onChange;
117
+ var _e = (0, common_1.useUncontrolled)({
118
+ value: page,
119
+ onChange: onChange,
120
+ defaultValue: initialPage,
121
+ finalValue: initialPage,
122
+ rule: function (_page) { return typeof _page === 'number' && _page <= total; },
123
+ }), activePage = _e[0], setActivePage = _e[1];
124
+ var setPage = function (pageNumber) {
125
+ if (pageNumber <= 0) {
126
+ setActivePage(1);
127
+ }
128
+ else if (pageNumber > total) {
129
+ setActivePage(total);
130
+ }
131
+ else {
132
+ setActivePage(pageNumber);
133
+ }
134
+ };
135
+ var next = function () { return setPage(activePage + 1); };
136
+ var previous = function () { return setPage(activePage - 1); };
137
+ var first = function () { return setPage(1); };
138
+ var last = function () { return setPage(total); };
139
+ var paginationRange = (0, react_1.useMemo)(function () {
140
+ // Pages count is determined as siblings (left/right) + boundaries(left/right) + currentPage + 2*DOTS
141
+ var totalPageNumbers = siblings * 2 + 3 + boundaries * 2;
142
+ /*
143
+ * If the number of pages is less than the page numbers we want to show in our
144
+ * paginationComponent, we return the range [1..total]
145
+ */
146
+ if (totalPageNumbers >= total) {
147
+ return (0, common_1.range)(1, total);
148
+ }
149
+ var leftSiblingIndex = Math.max(activePage - siblings, boundaries);
150
+ var rightSiblingIndex = Math.min(activePage + siblings, total - boundaries);
151
+ /*
152
+ * We do not want to show dots if there is only one position left
153
+ * after/before the left/right page count as that would lead to a change if our Pagination
154
+ * component size which we do not want
155
+ */
156
+ var shouldShowLeftDots = leftSiblingIndex > boundaries + 2;
157
+ var shouldShowRightDots = rightSiblingIndex < total - (boundaries + 1);
158
+ if (!shouldShowLeftDots && shouldShowRightDots) {
159
+ var leftItemCount = siblings * 2 + boundaries + 2;
160
+ return __spreadArray(__spreadArray(__spreadArray([], (0, common_1.range)(1, leftItemCount), true), [exports.DOTS], false), (0, common_1.range)(total - (boundaries - 1), total), true);
161
+ }
162
+ if (shouldShowLeftDots && !shouldShowRightDots) {
163
+ var rightItemCount = boundaries + 1 + 2 * siblings;
164
+ return __spreadArray(__spreadArray(__spreadArray([], (0, common_1.range)(1, boundaries), true), [exports.DOTS], false), (0, common_1.range)(total - rightItemCount, total), true);
165
+ }
166
+ return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], (0, common_1.range)(1, boundaries), true), [
167
+ exports.DOTS
168
+ ], false), (0, common_1.range)(leftSiblingIndex, rightSiblingIndex), true), [
169
+ exports.DOTS
170
+ ], false), (0, common_1.range)(total - boundaries + 1, total), true);
171
+ }, [total, siblings, activePage]);
172
+ return {
173
+ range: paginationRange,
174
+ active: activePage,
175
+ setPage: setPage,
176
+ next: next,
177
+ previous: previous,
178
+ first: first,
179
+ last: last,
180
+ };
181
+ }
182
+ exports.usePagination = usePagination;
183
183
  //# sourceMappingURL=hooks.js.map
@@ -1,2 +1,2 @@
1
- import { Logger } from '@codeleap/common';
2
- export declare const logger: Logger;
1
+ import { Logger } from '@codeleap/common';
2
+ export declare const logger: Logger;
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logger = void 0;
4
- var common_1 = require("@codeleap/common");
5
- exports.logger = new common_1.Logger({
6
- Environment: {
7
- IsDev: true,
8
- },
9
- Sentry: {
10
- enable: false,
11
- },
12
- Logger: {
13
- Level: 'debug',
14
- },
15
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ var common_1 = require("@codeleap/common");
5
+ exports.logger = new common_1.Logger({
6
+ Environment: {
7
+ IsDev: true,
8
+ },
9
+ Sentry: {
10
+ enable: false,
11
+ },
12
+ Logger: {
13
+ Level: 'debug',
14
+ },
15
+ });
16
16
  //# sourceMappingURL=logger.js.map
@@ -1,6 +1,6 @@
1
- declare const _default: {
2
- get: (key: any) => string;
3
- set: (key: any, value: any) => string;
4
- remove: (key: any) => void;
5
- };
6
- export default _default;
1
+ declare const _default: {
2
+ get: (key: any) => string;
3
+ set: (key: any, value: any) => string;
4
+ remove: (key: any) => void;
5
+ };
6
+ export default _default;
@@ -1,15 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var js_cookie_1 = __importDefault(require("js-cookie"));
7
- var get = function (key) { return js_cookie_1.default.get(key); };
8
- var set = function (key, value) { return js_cookie_1.default.set(key, value, { expires: 365 }); };
9
- var remove = function (key) { return js_cookie_1.default.remove(key); };
10
- exports.default = {
11
- get: get,
12
- set: set,
13
- remove: remove,
14
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var js_cookie_1 = __importDefault(require("js-cookie"));
7
+ var get = function (key) { return js_cookie_1.default.get(key); };
8
+ var set = function (key, value) { return js_cookie_1.default.set(key, value, { expires: 365 }); };
9
+ var remove = function (key) { return js_cookie_1.default.remove(key); };
10
+ exports.default = {
11
+ get: get,
12
+ set: set,
13
+ remove: remove,
14
+ };
15
15
  //# sourceMappingURL=cookies.js.map
@@ -1,4 +1,4 @@
1
- export * from './pollyfils/scroll';
2
- export * from './stopPropagation';
3
- export { default as url } from 'url-parse';
4
- export { default as Cookies } from './cookies';
1
+ export * from './pollyfils/scroll';
2
+ export * from './stopPropagation';
3
+ export { default as url } from 'url-parse';
4
+ export { default as Cookies } from './cookies';
@@ -1,27 +1,27 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Cookies = exports.url = void 0;
21
- __exportStar(require("./pollyfils/scroll"), exports);
22
- __exportStar(require("./stopPropagation"), exports);
23
- var url_parse_1 = require("url-parse");
24
- Object.defineProperty(exports, "url", { enumerable: true, get: function () { return __importDefault(url_parse_1).default; } });
25
- var cookies_1 = require("./cookies");
26
- Object.defineProperty(exports, "Cookies", { enumerable: true, get: function () { return __importDefault(cookies_1).default; } });
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Cookies = exports.url = void 0;
21
+ __exportStar(require("./pollyfils/scroll"), exports);
22
+ __exportStar(require("./stopPropagation"), exports);
23
+ var url_parse_1 = require("url-parse");
24
+ Object.defineProperty(exports, "url", { enumerable: true, get: function () { return __importDefault(url_parse_1).default; } });
25
+ var cookies_1 = require("./cookies");
26
+ Object.defineProperty(exports, "Cookies", { enumerable: true, get: function () { return __importDefault(cookies_1).default; } });
27
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export declare const scrollToElem: (elemSelector: any, padOffsets?: number[]) => void;
1
+ export declare const scrollToElem: (elemSelector: any, padOffsets?: number[]) => void;
@@ -1,66 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scrollToElem = void 0;
4
- // native smooth scrolling for Chrome, Firefox & Opera
5
- // @see: https://caniuse.com/#feat=css-scroll-behavior
6
- var nativeSmoothScrollTo = function (elem, pad) {
7
- if (pad === void 0) { pad = 0; }
8
- if (!window)
9
- return;
10
- window.scroll({
11
- behavior: 'smooth',
12
- left: 0,
13
- top: elem.getBoundingClientRect().top + window.pageYOffset + pad,
14
- });
15
- };
16
- // polyfilled smooth scrolling for IE, Edge & Safari
17
- var smoothScrollTo = function (to, duration) {
18
- if (!document)
19
- return;
20
- var element = document.scrollingElement || document.documentElement, start = element.scrollTop, change = to - start, startDate = +new Date();
21
- // t = current time
22
- // b = start value
23
- // c = change in value
24
- // d = duration
25
- var easeInOutQuad = function (t, b, c, d) {
26
- t /= d / 2;
27
- if (t < 1)
28
- return (c / 2) * t * t + b;
29
- t--;
30
- return (-c / 2) * (t * (t - 2) - 1) + b;
31
- };
32
- var animateScroll = function () {
33
- var currentDate = +new Date();
34
- var currentTime = currentDate - startDate;
35
- element.scrollTop = parseInt(easeInOutQuad(currentTime, start, change, duration));
36
- if (currentTime < duration) {
37
- requestAnimationFrame(animateScroll);
38
- }
39
- else {
40
- element.scrollTop = to;
41
- }
42
- };
43
- animateScroll();
44
- };
45
- // detect support for the behavior property in ScrollOptions
46
- // smooth scrolling stub
47
- var scrollToElem = function (elemSelector, padOffsets) {
48
- if (padOffsets === void 0) { padOffsets = [0, 0]; }
49
- if (!document)
50
- return;
51
- var supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style || {};
52
- if (!elemSelector) {
53
- return;
54
- }
55
- var elem = document.querySelector(elemSelector);
56
- if (elem) {
57
- if (supportsNativeSmoothScroll) {
58
- nativeSmoothScrollTo(elem, padOffsets[0]);
59
- }
60
- else {
61
- smoothScrollTo(elem.offsetTop + padOffsets[0], 600);
62
- }
63
- }
64
- };
65
- exports.scrollToElem = scrollToElem;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scrollToElem = void 0;
4
+ // native smooth scrolling for Chrome, Firefox & Opera
5
+ // @see: https://caniuse.com/#feat=css-scroll-behavior
6
+ var nativeSmoothScrollTo = function (elem, pad) {
7
+ if (pad === void 0) { pad = 0; }
8
+ if (!window)
9
+ return;
10
+ window.scroll({
11
+ behavior: 'smooth',
12
+ left: 0,
13
+ top: elem.getBoundingClientRect().top + window.pageYOffset + pad,
14
+ });
15
+ };
16
+ // polyfilled smooth scrolling for IE, Edge & Safari
17
+ var smoothScrollTo = function (to, duration) {
18
+ if (!document)
19
+ return;
20
+ var element = document.scrollingElement || document.documentElement, start = element.scrollTop, change = to - start, startDate = +new Date();
21
+ // t = current time
22
+ // b = start value
23
+ // c = change in value
24
+ // d = duration
25
+ var easeInOutQuad = function (t, b, c, d) {
26
+ t /= d / 2;
27
+ if (t < 1)
28
+ return (c / 2) * t * t + b;
29
+ t--;
30
+ return (-c / 2) * (t * (t - 2) - 1) + b;
31
+ };
32
+ var animateScroll = function () {
33
+ var currentDate = +new Date();
34
+ var currentTime = currentDate - startDate;
35
+ element.scrollTop = parseInt(easeInOutQuad(currentTime, start, change, duration));
36
+ if (currentTime < duration) {
37
+ requestAnimationFrame(animateScroll);
38
+ }
39
+ else {
40
+ element.scrollTop = to;
41
+ }
42
+ };
43
+ animateScroll();
44
+ };
45
+ // detect support for the behavior property in ScrollOptions
46
+ // smooth scrolling stub
47
+ var scrollToElem = function (elemSelector, padOffsets) {
48
+ if (padOffsets === void 0) { padOffsets = [0, 0]; }
49
+ if (!document)
50
+ return;
51
+ var supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style || {};
52
+ if (!elemSelector) {
53
+ return;
54
+ }
55
+ var elem = document.querySelector(elemSelector);
56
+ if (elem) {
57
+ if (supportsNativeSmoothScroll) {
58
+ nativeSmoothScrollTo(elem, padOffsets[0]);
59
+ }
60
+ else {
61
+ smoothScrollTo(elem.offsetTop + padOffsets[0], 600);
62
+ }
63
+ }
64
+ };
65
+ exports.scrollToElem = scrollToElem;
66
66
  //# sourceMappingURL=scroll.js.map
@@ -1 +1 @@
1
- export declare function stopPropagation(event: any): void;
1
+ export declare function stopPropagation(event: any): void;