@megafon/ui-core 9.4.0 → 9.4.1-old-ui-images

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 (133) hide show
  1. package/dist/es/components/Accordion/Accordion.js +3 -1
  2. package/dist/es/components/Badges/CounterBadge/CounterBadge.js +1 -1
  3. package/dist/es/components/Badges/InfoBadge/InfoBadge.js +16 -28
  4. package/dist/es/components/Badges/PriceBadge/PriceBadge.js +16 -28
  5. package/dist/es/components/Badges/PromoBadge/PromoBadge.js +0 -1
  6. package/dist/es/components/Badges/StatusBadge/StatusBadge.js +9 -13
  7. package/dist/es/components/Badges/TimerBadge/TimerBadge.js +1 -3
  8. package/dist/es/components/Buttons/Button/Button.js +1 -1
  9. package/dist/es/components/Buttons/ButtonClose/ButtonClose.js +2 -1
  10. package/dist/es/components/Calendar/components/_Month/Month.js +6 -2
  11. package/dist/es/components/Checkbox/Checkbox.js +1 -1
  12. package/dist/es/components/Chips/Chips/Chip.js +6 -2
  13. package/dist/es/components/ContentView/ContentView.css +1 -1
  14. package/dist/es/components/ContentView/ContentView.d.ts +1 -1
  15. package/dist/es/components/ContentView/img/alarm.png +0 -0
  16. package/dist/es/components/ContentView/img/empty.png +0 -0
  17. package/dist/es/components/ContentView/img/error.png +0 -0
  18. package/dist/es/components/ContentView/img/fail.png +0 -0
  19. package/dist/es/components/ContentView/img/searchNoResult.png +0 -0
  20. package/dist/es/components/ContentView/img/submit.png +0 -0
  21. package/dist/es/components/ContentView/img/success.png +0 -0
  22. package/dist/es/components/ContentView/img/update.png +0 -0
  23. package/dist/es/components/ContentView/img/waiting.png +0 -0
  24. package/dist/es/components/Counter/Counter.js +2 -2
  25. package/dist/es/components/ErrorLoad/ErrorLoad.js +3 -1
  26. package/dist/es/components/ListData/ListData.js +13 -9
  27. package/dist/es/components/ListData/components/ListDataSortable.js +3 -1
  28. package/dist/es/components/Modal/Modal.js +3 -27
  29. package/dist/es/components/Modal/_ModalContent/ModalContent.js +3 -2
  30. package/dist/es/components/Modal/_ModalMobile/ModalMobile.css +1 -1
  31. package/dist/es/components/Modal/_ModalMobile/ModalMobile.d.ts +0 -1
  32. package/dist/es/components/Modal/_ModalMobile/ModalMobile.js +4 -9
  33. package/dist/es/components/Modal/utils/utils.d.ts +0 -1
  34. package/dist/es/components/Modal/utils/utils.js +2 -3
  35. package/dist/es/components/MultipleSelect/MultipleSelect.js +5 -2
  36. package/dist/es/components/NavArrow/NavArrow.js +4 -4
  37. package/dist/es/components/Notification/Notification.js +9 -13
  38. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +4 -2
  39. package/dist/es/components/Parameter/Parameter.js +1 -3
  40. package/dist/es/components/Row/Row.js +1 -1
  41. package/dist/es/components/Search/Search.js +3 -3
  42. package/dist/es/components/SectionAccordionGroup/SectionAccordionGroup.js +3 -1
  43. package/dist/es/components/Snackbar/Snackbar.js +6 -10
  44. package/dist/es/components/Stepper/Stepper.js +1 -1
  45. package/dist/es/components/Switcher/Switcher.js +1 -3
  46. package/dist/es/components/Tabs/Tabs.js +1 -1
  47. package/dist/es/components/TextField/TextField.js +7 -13
  48. package/dist/es/components/Tooltip/Tooltip.js +3 -5
  49. package/dist/es/components/UploadForm/UploadField/components/_UploadFieldDropArea/UploadFieldDropArea.js +1 -5
  50. package/dist/es/components/UploadForm/UploadFileItem/UploadFileItem.js +4 -3
  51. package/dist/es/components/UploadForm/UploadFileItem/components/_UploadFileItemIcon/UploadFileItemIcon.js +0 -6
  52. package/dist/es/index.d.ts +0 -1
  53. package/dist/es/index.js +0 -1
  54. package/dist/lib/components/Accordion/Accordion.js +3 -1
  55. package/dist/lib/components/Badges/CounterBadge/CounterBadge.js +1 -1
  56. package/dist/lib/components/Badges/InfoBadge/InfoBadge.js +16 -28
  57. package/dist/lib/components/Badges/PriceBadge/PriceBadge.js +16 -28
  58. package/dist/lib/components/Badges/PromoBadge/PromoBadge.js +0 -1
  59. package/dist/lib/components/Badges/StatusBadge/StatusBadge.js +9 -13
  60. package/dist/lib/components/Badges/TimerBadge/TimerBadge.js +1 -3
  61. package/dist/lib/components/Buttons/Button/Button.js +1 -1
  62. package/dist/lib/components/Buttons/ButtonClose/ButtonClose.js +2 -1
  63. package/dist/lib/components/Calendar/components/_Month/Month.js +6 -2
  64. package/dist/lib/components/Checkbox/Checkbox.js +1 -1
  65. package/dist/lib/components/Chips/Chips/Chip.js +6 -2
  66. package/dist/lib/components/ContentView/ContentView.css +1 -1
  67. package/dist/lib/components/ContentView/ContentView.d.ts +1 -1
  68. package/dist/lib/components/ContentView/img/alarm.png +0 -0
  69. package/dist/lib/components/ContentView/img/empty.png +0 -0
  70. package/dist/lib/components/ContentView/img/error.png +0 -0
  71. package/dist/lib/components/ContentView/img/fail.png +0 -0
  72. package/dist/lib/components/ContentView/img/searchNoResult.png +0 -0
  73. package/dist/lib/components/ContentView/img/submit.png +0 -0
  74. package/dist/lib/components/ContentView/img/success.png +0 -0
  75. package/dist/lib/components/ContentView/img/update.png +0 -0
  76. package/dist/lib/components/ContentView/img/waiting.png +0 -0
  77. package/dist/lib/components/Counter/Counter.js +2 -2
  78. package/dist/lib/components/ErrorLoad/ErrorLoad.js +3 -1
  79. package/dist/lib/components/ListData/ListData.js +13 -9
  80. package/dist/lib/components/ListData/components/ListDataSortable.js +3 -1
  81. package/dist/lib/components/Modal/Modal.js +3 -27
  82. package/dist/lib/components/Modal/_ModalContent/ModalContent.js +3 -2
  83. package/dist/lib/components/Modal/_ModalMobile/ModalMobile.css +1 -1
  84. package/dist/lib/components/Modal/_ModalMobile/ModalMobile.d.ts +0 -1
  85. package/dist/lib/components/Modal/_ModalMobile/ModalMobile.js +4 -9
  86. package/dist/lib/components/Modal/utils/utils.d.ts +0 -1
  87. package/dist/lib/components/Modal/utils/utils.js +2 -3
  88. package/dist/lib/components/MultipleSelect/MultipleSelect.js +5 -2
  89. package/dist/lib/components/NavArrow/NavArrow.js +4 -4
  90. package/dist/lib/components/Notification/Notification.js +9 -13
  91. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +4 -2
  92. package/dist/lib/components/Parameter/Parameter.js +1 -3
  93. package/dist/lib/components/Row/Row.js +1 -1
  94. package/dist/lib/components/Search/Search.js +3 -3
  95. package/dist/lib/components/SectionAccordionGroup/SectionAccordionGroup.js +3 -1
  96. package/dist/lib/components/Snackbar/Snackbar.js +6 -10
  97. package/dist/lib/components/Stepper/Stepper.js +1 -1
  98. package/dist/lib/components/Switcher/Switcher.js +1 -3
  99. package/dist/lib/components/Tabs/Tabs.js +1 -1
  100. package/dist/lib/components/TextField/TextField.js +7 -13
  101. package/dist/lib/components/Tooltip/Tooltip.js +3 -5
  102. package/dist/lib/components/UploadForm/UploadField/components/_UploadFieldDropArea/UploadFieldDropArea.js +1 -5
  103. package/dist/lib/components/UploadForm/UploadFileItem/UploadFileItem.js +4 -3
  104. package/dist/lib/components/UploadForm/UploadFileItem/components/_UploadFileItemIcon/UploadFileItemIcon.js +0 -6
  105. package/dist/lib/index.d.ts +0 -1
  106. package/dist/lib/index.js +0 -7
  107. package/package.json +3 -4
  108. package/dist/es/components/ContentView/img/info.png +0 -0
  109. package/dist/es/components/Modal/utils/usePreventScroll.d.ts +0 -17
  110. package/dist/es/components/Modal/utils/usePreventScroll.js +0 -252
  111. package/dist/es/hooks/useEvent.d.ts +0 -3
  112. package/dist/es/hooks/useEvent.js +0 -11
  113. package/dist/es/hooks/useLatest.d.ts +0 -2
  114. package/dist/es/hooks/useLatest.js +0 -8
  115. package/dist/es/hooks/useVisualViewport.d.ts +0 -10
  116. package/dist/es/hooks/useVisualViewport.js +0 -55
  117. package/dist/es/utils/browser.d.ts +0 -7
  118. package/dist/es/utils/browser.js +0 -30
  119. package/dist/es/utils/is.d.ts +0 -19
  120. package/dist/es/utils/is.js +0 -70
  121. package/dist/lib/components/ContentView/img/info.png +0 -0
  122. package/dist/lib/components/Modal/utils/usePreventScroll.d.ts +0 -17
  123. package/dist/lib/components/Modal/utils/usePreventScroll.js +0 -263
  124. package/dist/lib/hooks/useEvent.d.ts +0 -3
  125. package/dist/lib/hooks/useEvent.js +0 -17
  126. package/dist/lib/hooks/useLatest.d.ts +0 -2
  127. package/dist/lib/hooks/useLatest.js +0 -14
  128. package/dist/lib/hooks/useVisualViewport.d.ts +0 -10
  129. package/dist/lib/hooks/useVisualViewport.js +0 -62
  130. package/dist/lib/utils/browser.d.ts +0 -7
  131. package/dist/lib/utils/browser.js +0 -42
  132. package/dist/lib/utils/is.d.ts +0 -19
  133. package/dist/lib/utils/is.js +0 -92
@@ -1,19 +0,0 @@
1
- export declare function isNumber(value: unknown): value is number;
2
- export declare function isInteger(v: unknown): boolean;
3
- export declare function isArray<T>(value: unknown): value is Array<T>;
4
- export declare function isEmptyArray(value: unknown): boolean;
5
- type AnyFunction = (...args: unknown[]) => unknown;
6
- export declare function isFunction<T extends AnyFunction = AnyFunction>(value: unknown): value is T;
7
- export declare function isDefined(value: unknown): boolean;
8
- export declare function isUndefined(value: unknown): value is undefined;
9
- export declare function isObject(value: unknown): value is Record<string, unknown>;
10
- export declare function isEmptyObject(value: unknown): boolean;
11
- export declare function isNull(value: unknown): value is null;
12
- export declare function isString(value: unknown): value is string;
13
- export declare function isCssVar(value: string): boolean;
14
- export declare function isEmpty(value: unknown): boolean;
15
- export declare const isBoolean: (value: unknown) => value is boolean;
16
- type Falsy = false | 0 | '' | null | undefined | bigint;
17
- export declare const isTruthy: <T>(value: T) => value is Exclude<T, Falsy>;
18
- export declare const isHTMLElement: (value: unknown) => value is HTMLElement;
19
- export {};
@@ -1,70 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import "core-js/modules/es.array.is-array.js";
3
- import "core-js/modules/es.date.to-string.js";
4
- import "core-js/modules/es.number.constructor.js";
5
- import "core-js/modules/es.number.is-finite.js";
6
- import "core-js/modules/es.number.is-nan.js";
7
- import "core-js/modules/es.object.keys.js";
8
- import "core-js/modules/es.object.to-string.js";
9
- import "core-js/modules/es.regexp.exec.js";
10
- import "core-js/modules/es.regexp.test.js";
11
- import "core-js/modules/es.regexp.to-string.js";
12
- export function isNumber(value) {
13
- return typeof value === 'number';
14
- }
15
- export function isInteger(v) {
16
- var value = Number(v);
17
- return typeof value === 'number' && !Number.isNaN(value) && Number.isFinite(value) && Math.floor(value) === value;
18
- }
19
- export function isArray(value) {
20
- return Array.isArray(value);
21
- }
22
- export function isEmptyArray(value) {
23
- return isArray(value) && value.length === 0;
24
- }
25
- export function isFunction(value) {
26
- return typeof value === 'function';
27
- }
28
- export function isDefined(value) {
29
- return typeof value !== 'undefined' && value !== undefined;
30
- }
31
- export function isUndefined(value) {
32
- return typeof value === 'undefined' || value === undefined;
33
- }
34
- export function isObject(value) {
35
- var type = _typeof(value);
36
- return value != null && (type === 'object' || type === 'function') && !isArray(value);
37
- }
38
- export function isEmptyObject(value) {
39
- return isObject(value) && Object.keys(value).length === 0;
40
- }
41
- export function isNull(value) {
42
- return value === null;
43
- }
44
- export function isString(value) {
45
- return Object.prototype.toString.call(value) === '[object String]';
46
- }
47
- export function isCssVar(value) {
48
- return /^var\(--.+\)$/.test(value);
49
- }
50
- export function isEmpty(value) {
51
- if (isArray(value)) {
52
- return isEmptyArray(value);
53
- }
54
- if (isObject(value)) {
55
- return isEmptyObject(value);
56
- }
57
- if (value == null || value === '') {
58
- return true;
59
- }
60
- return false;
61
- }
62
- export var isBoolean = function isBoolean(value) {
63
- return typeof value === 'boolean';
64
- };
65
- export var isTruthy = function isTruthy(value) {
66
- return Boolean(value);
67
- };
68
- export var isHTMLElement = function isHTMLElement(value) {
69
- return value instanceof HTMLElement;
70
- };
@@ -1,17 +0,0 @@
1
- import { useEffect } from 'react';
2
- export declare const useIsomorphicLayoutEffect: typeof useEffect;
3
- interface PreventScrollOptions {
4
- /** Whether the scroll lock is disabled. */
5
- isDisabled?: boolean;
6
- focusCallback?: () => void;
7
- }
8
- export declare function isScrollable(node: Element): boolean;
9
- export declare function getScrollParent(node: Element): Element;
10
- /**
11
- * Prevents scrolling on the document body on mount, and
12
- * restores it on unmount. Also ensures that content does not
13
- * shift due to the scrollbars disappearing.
14
- */
15
- declare function usePreventScroll(options?: PreventScrollOptions): void;
16
- export declare function isInput(target: Element): boolean;
17
- export default usePreventScroll;
@@ -1,263 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- exports.getScrollParent = getScrollParent;
8
- exports.isInput = isInput;
9
- exports.isScrollable = isScrollable;
10
- exports.useIsomorphicLayoutEffect = void 0;
11
- require("core-js/modules/es.array.iterator.js");
12
- require("core-js/modules/es.object.to-string.js");
13
- require("core-js/modules/es.regexp.exec.js");
14
- require("core-js/modules/es.regexp.test.js");
15
- require("core-js/modules/es.set.js");
16
- require("core-js/modules/es.string.iterator.js");
17
- require("core-js/modules/web.dom-collections.iterator.js");
18
- var _react = require("react");
19
- var _browser = require("../../../utils/browser");
20
- // This code comes from https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/usePreventScroll.ts
21
- /* eslint-disable */
22
-
23
- var KEYBOARD_BUFFER = 24;
24
- var useIsomorphicLayoutEffect = exports.useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
25
- function chain() {
26
- for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
27
- callbacks[_key] = arguments[_key];
28
- }
29
- return function () {
30
- for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
31
- var callback = _callbacks[_i];
32
- if (typeof callback === 'function') {
33
- callback.apply(void 0, arguments);
34
- }
35
- }
36
- };
37
- }
38
- // @ts-ignore
39
- var visualViewport = typeof document !== 'undefined' && window.visualViewport;
40
- function isScrollable(node) {
41
- var style = window.getComputedStyle(node);
42
- return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
43
- }
44
- function getScrollParent(node) {
45
- if (isScrollable(node)) {
46
- node = node.parentElement;
47
- }
48
- while (node && !isScrollable(node)) {
49
- node = node.parentElement;
50
- }
51
- return node || document.scrollingElement || document.documentElement;
52
- }
53
- // HTML input types that do not cause the software keyboard to appear.
54
- var nonTextInputTypes = new Set(['checkbox', 'radio', 'range', 'color', 'file', 'image', 'button', 'submit', 'reset']);
55
- // The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
56
- var preventScrollCount = 0;
57
- var restore;
58
- /**
59
- * Prevents scrolling on the document body on mount, and
60
- * restores it on unmount. Also ensures that content does not
61
- * shift due to the scrollbars disappearing.
62
- */
63
- function usePreventScroll() {
64
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
65
- var isDisabled = options.isDisabled;
66
- useIsomorphicLayoutEffect(function () {
67
- if (isDisabled) {
68
- return;
69
- }
70
- preventScrollCount++;
71
- if (preventScrollCount === 1) {
72
- if ((0, _browser.isIOS)()) {
73
- restore = preventScrollMobileSafari();
74
- }
75
- }
76
- return function () {
77
- preventScrollCount--;
78
- if (preventScrollCount === 0) {
79
- restore === null || restore === void 0 ? void 0 : restore();
80
- }
81
- };
82
- }, [isDisabled]);
83
- }
84
- // Mobile Safari is a whole different beast. Even with overflow: hidden,
85
- // it still scrolls the page in many situations:
86
- //
87
- // 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
88
- // 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
89
- // it, so it becomes scrollable.
90
- // 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
91
- // This may cause even fixed position elements to scroll off the screen.
92
- // 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
93
- // scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
94
- //
95
- // In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
96
- //
97
- // 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
98
- // on the window.
99
- // 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the
100
- // top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.
101
- // 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
102
- // 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
103
- // of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
104
- // into view ourselves, without scrolling the whole page.
105
- // 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
106
- // same visually, but makes the actual scroll position always zero. This is required to make all of the
107
- // above work or Safari will still try to scroll the page when focusing an input.
108
- // 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
109
- // to navigate to an input with the next/previous buttons that's outside a modal.
110
- function preventScrollMobileSafari() {
111
- var scrollable;
112
- var lastY = 0;
113
- var onTouchStart = function onTouchStart(e) {
114
- // Store the nearest scrollable parent element from the element that the user touched.
115
- scrollable = getScrollParent(e.target);
116
- if (scrollable === document.documentElement && scrollable === document.body) {
117
- return;
118
- }
119
- lastY = e.changedTouches[0].pageY;
120
- };
121
- var onTouchMove = function onTouchMove(e) {
122
- // Prevent scrolling the window.
123
- if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
124
- e.preventDefault();
125
- return;
126
- }
127
- // Prevent scrolling up when at the top and scrolling down when at the bottom
128
- // of a nested scrollable area, otherwise mobile Safari will start scrolling
129
- // the window instead. Unfortunately, this disables bounce scrolling when at
130
- // the top but it's the best we can do.
131
- var y = e.changedTouches[0].pageY;
132
- var _scrollable = scrollable,
133
- scrollTop = _scrollable.scrollTop;
134
- var bottom = scrollable.scrollHeight - scrollable.clientHeight;
135
- if (bottom === 0) {
136
- return;
137
- }
138
- if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
139
- e.preventDefault();
140
- }
141
- lastY = y;
142
- };
143
- var onTouchEnd = function onTouchEnd(e) {
144
- var target = e.target;
145
- // Apply this change if we're not already focused on the target element
146
- if (isInput(target) && target !== document.activeElement) {
147
- e.preventDefault();
148
- // Apply a transform to trick Safari into thinking the input is at the top of the page
149
- // so it doesn't try to scroll it into view. When tapping on an input, this needs to
150
- // be done before the "focus" event, so we have to focus the element ourselves.
151
- target.style.transform = 'translateY(-2000px)';
152
- target.focus();
153
- requestAnimationFrame(function () {
154
- target.style.transform = '';
155
- });
156
- }
157
- };
158
- var onFocus = function onFocus(e) {
159
- var target = e.target;
160
- if (isInput(target)) {
161
- // Transform also needs to be applied in the focus event in cases where focus moves
162
- // other than tapping on an input directly, e.g. the next/previous buttons in the
163
- // software keyboard. In these cases, it seems applying the transform in the focus event
164
- // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷‍♂️
165
- target.style.transform = 'translateY(-2000px)';
166
- requestAnimationFrame(function () {
167
- target.style.transform = '';
168
- // This will have prevented the browser from scrolling the focused element into view,
169
- // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
170
- if (visualViewport) {
171
- if (visualViewport.height < window.innerHeight) {
172
- // If the keyboard is already visible, do this after one additional frame
173
- // to wait for the transform to be removed.
174
- requestAnimationFrame(function () {
175
- scrollIntoView(target);
176
- });
177
- } else {
178
- // Otherwise, wait for the visual viewport to resize before scrolling so we can
179
- // measure the correct position to scroll to.
180
- visualViewport.addEventListener('resize', function () {
181
- return scrollIntoView(target);
182
- }, {
183
- once: true
184
- });
185
- }
186
- }
187
- });
188
- }
189
- };
190
- var onWindowScroll = function onWindowScroll() {
191
- // Last resort. If the window scrolled, scroll it back to the top.
192
- // It should always be at the top because the body will have a negative margin (see below).
193
- window.scrollTo(0, 0);
194
- };
195
- // Record the original scroll position so we can restore it.
196
- // Then apply a negative margin to the body to offset it by the scroll position. This will
197
- // enable us to scroll the window to the top, which is required for the rest of this to work.
198
- var scrollX = window.pageXOffset;
199
- var scrollY = window.pageYOffset;
200
- var restoreStyles = chain(setStyle(document.documentElement, 'paddingRight', "".concat(window.innerWidth - document.documentElement.clientWidth, "px")));
201
- // Scroll to the top. The negative margin on the body will make this appear the same.
202
- window.scrollTo(0, 0);
203
- var removeEvents = chain(addEvent(document, 'touchstart', onTouchStart, {
204
- passive: false,
205
- capture: true
206
- }), addEvent(document, 'touchmove', onTouchMove, {
207
- passive: false,
208
- capture: true
209
- }), addEvent(document, 'touchend', onTouchEnd, {
210
- passive: false,
211
- capture: true
212
- }), addEvent(document, 'focus', onFocus, true), addEvent(window, 'scroll', onWindowScroll));
213
- return function () {
214
- // Restore styles and scroll the page back to where it was.
215
- restoreStyles();
216
- removeEvents();
217
- window.scrollTo(scrollX, scrollY);
218
- };
219
- }
220
- // Sets a CSS property on an element, and returns a function to revert it to the previous value.
221
- function setStyle(element, style, value) {
222
- // https://github.com/microsoft/TypeScript/issues/17827#issuecomment-391663310
223
- // @ts-ignore
224
- var cur = element.style[style];
225
- // @ts-ignore
226
- element.style[style] = value;
227
- return function () {
228
- // @ts-ignore
229
- element.style[style] = cur;
230
- };
231
- }
232
- // Adds an event listener to an element, and returns a function to remove it.
233
- function addEvent(target, event, handler, options) {
234
- // @ts-ignore
235
- target.addEventListener(event, handler, options);
236
- return function () {
237
- // @ts-ignore
238
- target.removeEventListener(event, handler, options);
239
- };
240
- }
241
- function scrollIntoView(target) {
242
- var root = document.scrollingElement || document.documentElement;
243
- while (target && target !== root) {
244
- // Find the parent scrollable element and adjust the scroll position if the target is not already in view.
245
- var scrollable = getScrollParent(target);
246
- if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
247
- var scrollableTop = scrollable.getBoundingClientRect().top;
248
- var targetTop = target.getBoundingClientRect().top;
249
- var targetBottom = target.getBoundingClientRect().bottom;
250
- // Buffer is needed for some edge cases
251
- var keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
252
- if (targetBottom > keyboardHeight) {
253
- scrollable.scrollTop += targetTop - scrollableTop;
254
- }
255
- }
256
- // @ts-ignore
257
- target = scrollable.parentElement;
258
- }
259
- }
260
- function isInput(target) {
261
- return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
262
- }
263
- var _default = exports["default"] = usePreventScroll;
@@ -1,3 +0,0 @@
1
- type Fn<ARGS extends unknown[], R> = (...args: ARGS) => R;
2
- export declare const useEvent: <A extends unknown[], R>(fn: Fn<A, R>) => Fn<A, R>;
3
- export {};
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useEvent = void 0;
7
- var _react = require("react");
8
- var _useLatest = require("./useLatest");
9
- var useEvent = exports.useEvent = function useEvent(fn) {
10
- var ref = (0, _useLatest.useLatest)(fn);
11
- return (0, _react.useMemo)(function () {
12
- return function () {
13
- var current = ref.current;
14
- return current.apply(void 0, arguments);
15
- };
16
- }, [ref]);
17
- };
@@ -1,2 +0,0 @@
1
- import type { RefObject } from 'react';
2
- export declare const useLatest: <T>(value: T) => RefObject<T>;
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useLatest = void 0;
7
- var _react = require("react");
8
- var useLatest = exports.useLatest = function useLatest(value) {
9
- var valueRef = (0, _react.useRef)(value);
10
- (0, _react.useInsertionEffect)(function () {
11
- valueRef.current = value;
12
- }, [value]);
13
- return valueRef;
14
- };
@@ -1,10 +0,0 @@
1
- type Metrics = {
2
- keyboardOffset: number;
3
- viewportHeight: number;
4
- isKeyboardOpen: boolean;
5
- };
6
- declare function useVisualViewport({ enabled, onChange, }: {
7
- enabled?: boolean;
8
- onChange: (metrics: Metrics) => void;
9
- }): Metrics;
10
- export default useVisualViewport;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
- var _react = require("react");
9
- var _useEvent = require("./useEvent");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
- var getDefaultMetrics = function getDefaultMetrics() {
12
- return {
13
- keyboardOffset: 0,
14
- viewportHeight: window.innerHeight,
15
- isKeyboardOpen: false
16
- };
17
- };
18
- var getMetrics = function getMetrics() {
19
- var viewport = window.visualViewport;
20
- if (!viewport) {
21
- return getDefaultMetrics();
22
- }
23
- var keyboardOffset = Math.max(0, window.innerHeight - viewport.height - viewport.offsetTop);
24
- var isKeyboardOpen = viewport.height < window.innerHeight && window.innerHeight - viewport.height > 150;
25
- return {
26
- keyboardOffset: keyboardOffset,
27
- viewportHeight: viewport.height,
28
- isKeyboardOpen: isKeyboardOpen
29
- };
30
- };
31
- function useVisualViewport(_ref) {
32
- var _ref$enabled = _ref.enabled,
33
- enabled = _ref$enabled === void 0 ? true : _ref$enabled,
34
- onChange = _ref.onChange;
35
- var _useState = (0, _react.useState)(function () {
36
- return getMetrics();
37
- }),
38
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
39
- metrics = _useState2[0],
40
- setMetrics = _useState2[1];
41
- var onChangeMetrics = (0, _useEvent.useEvent)(onChange);
42
- (0, _react.useEffect)(function () {
43
- if (!enabled) {
44
- return undefined;
45
- }
46
- var updateMetrics = function updateMetrics() {
47
- var currentMetrics = getMetrics();
48
- setMetrics(currentMetrics);
49
- onChangeMetrics(currentMetrics);
50
- };
51
- updateMetrics();
52
- var viewport = window.visualViewport;
53
- viewport === null || viewport === void 0 ? void 0 : viewport.addEventListener('resize', updateMetrics);
54
- viewport === null || viewport === void 0 ? void 0 : viewport.addEventListener('scroll', updateMetrics);
55
- return function () {
56
- viewport === null || viewport === void 0 ? void 0 : viewport.removeEventListener('resize', updateMetrics);
57
- viewport === null || viewport === void 0 ? void 0 : viewport.removeEventListener('scroll', updateMetrics);
58
- };
59
- }, [enabled, onChangeMetrics]);
60
- return metrics;
61
- }
62
- var _default = exports["default"] = useVisualViewport;
@@ -1,7 +0,0 @@
1
- export declare function isMobileFirefox(): boolean | undefined;
2
- export declare function testPlatform(re: RegExp): boolean | undefined;
3
- export declare function isMac(): boolean | undefined;
4
- export declare function isIPhone(): boolean | undefined;
5
- export declare function isSafari(): boolean | undefined;
6
- export declare function isIPad(): boolean | undefined;
7
- export declare function isIOS(): boolean | undefined;
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isIOS = isIOS;
7
- exports.isIPad = isIPad;
8
- exports.isIPhone = isIPhone;
9
- exports.isMac = isMac;
10
- exports.isMobileFirefox = isMobileFirefox;
11
- exports.isSafari = isSafari;
12
- exports.testPlatform = testPlatform;
13
- require("core-js/modules/es.regexp.exec.js");
14
- require("core-js/modules/es.regexp.test.js");
15
- function isMobileFirefox() {
16
- var _navigator = navigator,
17
- userAgent = _navigator.userAgent;
18
- return typeof window !== 'undefined' && (/Firefox/.test(userAgent) && /Mobile/.test(userAgent) ||
19
- // Android Firefox
20
- /FxiOS/.test(userAgent)) // iOS Firefox
21
- ;
22
- }
23
- function testPlatform(re) {
24
- return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : undefined;
25
- }
26
- function isMac() {
27
- return testPlatform(/^Mac/);
28
- }
29
- function isIPhone() {
30
- return testPlatform(/^iPhone/);
31
- }
32
- function isSafari() {
33
- return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
34
- }
35
- function isIPad() {
36
- return testPlatform(/^iPad/) ||
37
- // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
38
- isMac() && navigator.maxTouchPoints > 1;
39
- }
40
- function isIOS() {
41
- return isIPhone() || isIPad();
42
- }
@@ -1,19 +0,0 @@
1
- export declare function isNumber(value: unknown): value is number;
2
- export declare function isInteger(v: unknown): boolean;
3
- export declare function isArray<T>(value: unknown): value is Array<T>;
4
- export declare function isEmptyArray(value: unknown): boolean;
5
- type AnyFunction = (...args: unknown[]) => unknown;
6
- export declare function isFunction<T extends AnyFunction = AnyFunction>(value: unknown): value is T;
7
- export declare function isDefined(value: unknown): boolean;
8
- export declare function isUndefined(value: unknown): value is undefined;
9
- export declare function isObject(value: unknown): value is Record<string, unknown>;
10
- export declare function isEmptyObject(value: unknown): boolean;
11
- export declare function isNull(value: unknown): value is null;
12
- export declare function isString(value: unknown): value is string;
13
- export declare function isCssVar(value: string): boolean;
14
- export declare function isEmpty(value: unknown): boolean;
15
- export declare const isBoolean: (value: unknown) => value is boolean;
16
- type Falsy = false | 0 | '' | null | undefined | bigint;
17
- export declare const isTruthy: <T>(value: T) => value is Exclude<T, Falsy>;
18
- export declare const isHTMLElement: (value: unknown) => value is HTMLElement;
19
- export {};
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isArray = isArray;
7
- exports.isBoolean = void 0;
8
- exports.isCssVar = isCssVar;
9
- exports.isDefined = isDefined;
10
- exports.isEmpty = isEmpty;
11
- exports.isEmptyArray = isEmptyArray;
12
- exports.isEmptyObject = isEmptyObject;
13
- exports.isFunction = isFunction;
14
- exports.isHTMLElement = void 0;
15
- exports.isInteger = isInteger;
16
- exports.isNull = isNull;
17
- exports.isNumber = isNumber;
18
- exports.isObject = isObject;
19
- exports.isString = isString;
20
- exports.isTruthy = void 0;
21
- exports.isUndefined = isUndefined;
22
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
23
- require("core-js/modules/es.array.is-array.js");
24
- require("core-js/modules/es.date.to-string.js");
25
- require("core-js/modules/es.number.constructor.js");
26
- require("core-js/modules/es.number.is-finite.js");
27
- require("core-js/modules/es.number.is-nan.js");
28
- require("core-js/modules/es.object.keys.js");
29
- require("core-js/modules/es.object.to-string.js");
30
- require("core-js/modules/es.regexp.exec.js");
31
- require("core-js/modules/es.regexp.test.js");
32
- require("core-js/modules/es.regexp.to-string.js");
33
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
34
- function isNumber(value) {
35
- return typeof value === 'number';
36
- }
37
- function isInteger(v) {
38
- var value = Number(v);
39
- return typeof value === 'number' && !Number.isNaN(value) && Number.isFinite(value) && Math.floor(value) === value;
40
- }
41
- function isArray(value) {
42
- return Array.isArray(value);
43
- }
44
- function isEmptyArray(value) {
45
- return isArray(value) && value.length === 0;
46
- }
47
- function isFunction(value) {
48
- return typeof value === 'function';
49
- }
50
- function isDefined(value) {
51
- return typeof value !== 'undefined' && value !== undefined;
52
- }
53
- function isUndefined(value) {
54
- return typeof value === 'undefined' || value === undefined;
55
- }
56
- function isObject(value) {
57
- var type = (0, _typeof2["default"])(value);
58
- return value != null && (type === 'object' || type === 'function') && !isArray(value);
59
- }
60
- function isEmptyObject(value) {
61
- return isObject(value) && Object.keys(value).length === 0;
62
- }
63
- function isNull(value) {
64
- return value === null;
65
- }
66
- function isString(value) {
67
- return Object.prototype.toString.call(value) === '[object String]';
68
- }
69
- function isCssVar(value) {
70
- return /^var\(--.+\)$/.test(value);
71
- }
72
- function isEmpty(value) {
73
- if (isArray(value)) {
74
- return isEmptyArray(value);
75
- }
76
- if (isObject(value)) {
77
- return isEmptyObject(value);
78
- }
79
- if (value == null || value === '') {
80
- return true;
81
- }
82
- return false;
83
- }
84
- var isBoolean = exports.isBoolean = function isBoolean(value) {
85
- return typeof value === 'boolean';
86
- };
87
- var isTruthy = exports.isTruthy = function isTruthy(value) {
88
- return Boolean(value);
89
- };
90
- var isHTMLElement = exports.isHTMLElement = function isHTMLElement(value) {
91
- return value instanceof HTMLElement;
92
- };