@gravity-ui/navigation 1.1.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +28 -1
  2. package/build/cjs/ActionBar-393db3ea.js +62 -0
  3. package/build/cjs/ActionBar-393db3ea.js.map +1 -0
  4. package/build/cjs/AsideHeader.js +50 -0
  5. package/build/cjs/AsideHeader.js.map +1 -0
  6. package/build/cjs/AsideHeaderContext.js +41 -0
  7. package/build/cjs/AsideHeaderContext.js.map +1 -0
  8. package/build/cjs/Content-64d5738a.js +20 -0
  9. package/build/cjs/Content-64d5738a.js.map +1 -0
  10. package/build/cjs/Drawer.js +3091 -0
  11. package/build/cjs/Drawer.js.map +1 -0
  12. package/build/cjs/FooterItem-01b32eb7.js +286 -0
  13. package/build/cjs/FooterItem-01b32eb7.js.map +1 -0
  14. package/build/cjs/FooterItem.js +30 -0
  15. package/build/cjs/FooterItem.js.map +1 -0
  16. package/build/cjs/HotkeysPanel-9e5af200.js +66 -0
  17. package/build/cjs/HotkeysPanel-9e5af200.js.map +1 -0
  18. package/build/cjs/Item-ff00938b.js +294 -0
  19. package/build/cjs/Item-ff00938b.js.map +1 -0
  20. package/build/cjs/PageLayout.js +36 -0
  21. package/build/cjs/PageLayout.js.map +1 -0
  22. package/build/cjs/PageLayoutAside.js +967 -0
  23. package/build/cjs/PageLayoutAside.js.map +1 -0
  24. package/build/cjs/Settings-014971f7.js +489 -0
  25. package/build/cjs/Settings-014971f7.js.map +1 -0
  26. package/build/cjs/Title-d58ff158.js +41 -0
  27. package/build/cjs/Title-d58ff158.js.map +1 -0
  28. package/build/cjs/components/AsideHeader/AsideHeader.d.ts +15 -1
  29. package/build/cjs/components/AsideHeader/AsideHeaderContext.d.ts +1 -2
  30. package/build/cjs/components/AsideHeader/__stories__/AsideHeader.stories.d.ts +1 -0
  31. package/build/cjs/components/AsideHeader/components/PageLayout/PageLayout.d.ts +11 -0
  32. package/build/cjs/components/AsideHeader/components/PageLayout/PageLayoutAside.d.ts +5 -0
  33. package/build/cjs/components/AsideHeader/types.d.ts +8 -3
  34. package/build/cjs/components/CompositeBar/utils.d.ts +1 -1
  35. package/build/cjs/components/Content/Content.d.ts +1 -2
  36. package/build/cjs/components/index.d.ts +2 -0
  37. package/build/cjs/constants-9783dc2d.js +10 -0
  38. package/build/cjs/constants-9783dc2d.js.map +1 -0
  39. package/build/cjs/debounce-8772fd80.js +545 -0
  40. package/build/cjs/debounce-8772fd80.js.map +1 -0
  41. package/build/cjs/index.js +47 -6036
  42. package/build/cjs/index.js.map +1 -1
  43. package/build/cjs/index2.js +13 -0
  44. package/build/cjs/index2.js.map +1 -0
  45. package/build/cjs/index3.js +16 -0
  46. package/build/cjs/index3.js.map +1 -0
  47. package/build/cjs/index4.js +17 -0
  48. package/build/cjs/index4.js.map +1 -0
  49. package/build/cjs/index5.js +20 -0
  50. package/build/cjs/index5.js.map +1 -0
  51. package/build/cjs/index6.js +19 -0
  52. package/build/cjs/index6.js.map +1 -0
  53. package/build/cjs/registerKeyset-f4ce9ee7.js +215 -0
  54. package/build/cjs/registerKeyset-f4ce9ee7.js.map +1 -0
  55. package/build/cjs/style-inject.es-935afc04.js +38 -0
  56. package/build/cjs/style-inject.es-935afc04.js.map +1 -0
  57. package/build/cjs/tslib.es6-705c6589.js +36 -0
  58. package/build/cjs/tslib.es6-705c6589.js.map +1 -0
  59. package/build/cjs/utils-e82025ce.js +8 -0
  60. package/build/cjs/utils-e82025ce.js.map +1 -0
  61. package/build/esm/ActionBar-f1c9a2d3.js +56 -0
  62. package/build/esm/ActionBar-f1c9a2d3.js.map +1 -0
  63. package/build/esm/AsideHeader.js +42 -0
  64. package/build/esm/AsideHeader.js.map +1 -0
  65. package/build/esm/AsideHeaderContext.js +28 -0
  66. package/build/esm/AsideHeaderContext.js.map +1 -0
  67. package/build/esm/Content-f94ba85d.js +14 -0
  68. package/build/esm/Content-f94ba85d.js.map +1 -0
  69. package/build/esm/Drawer.js +3081 -0
  70. package/build/esm/Drawer.js.map +1 -0
  71. package/build/esm/FooterItem-d66ab545.js +279 -0
  72. package/build/esm/FooterItem-d66ab545.js.map +1 -0
  73. package/build/esm/FooterItem.js +22 -0
  74. package/build/esm/FooterItem.js.map +1 -0
  75. package/build/esm/HotkeysPanel-67f3066d.js +60 -0
  76. package/build/esm/HotkeysPanel-67f3066d.js.map +1 -0
  77. package/build/esm/Item-30c88899.js +280 -0
  78. package/build/esm/Item-30c88899.js.map +1 -0
  79. package/build/esm/PageLayout.js +28 -0
  80. package/build/esm/PageLayout.js.map +1 -0
  81. package/build/esm/PageLayoutAside.js +941 -0
  82. package/build/esm/PageLayoutAside.js.map +1 -0
  83. package/build/esm/Settings-ea96388d.js +464 -0
  84. package/build/esm/Settings-ea96388d.js.map +1 -0
  85. package/build/esm/Title-3d579ca4.js +35 -0
  86. package/build/esm/Title-3d579ca4.js.map +1 -0
  87. package/build/esm/components/AsideHeader/AsideHeader.d.ts +15 -1
  88. package/build/esm/components/AsideHeader/AsideHeaderContext.d.ts +1 -2
  89. package/build/esm/components/AsideHeader/__stories__/AsideHeader.stories.d.ts +1 -0
  90. package/build/esm/components/AsideHeader/components/PageLayout/PageLayout.d.ts +11 -0
  91. package/build/esm/components/AsideHeader/components/PageLayout/PageLayoutAside.d.ts +5 -0
  92. package/build/esm/components/AsideHeader/types.d.ts +8 -3
  93. package/build/esm/components/CompositeBar/utils.d.ts +1 -1
  94. package/build/esm/components/Content/Content.d.ts +1 -2
  95. package/build/esm/components/index.d.ts +2 -0
  96. package/build/esm/constants-b3a73cd1.js +6 -0
  97. package/build/esm/constants-b3a73cd1.js.map +1 -0
  98. package/build/esm/debounce-64cd2b4c.js +543 -0
  99. package/build/esm/debounce-64cd2b4c.js.map +1 -0
  100. package/build/esm/index.js +24 -6000
  101. package/build/esm/index.js.map +1 -1
  102. package/build/esm/index2.js +5 -0
  103. package/build/esm/index2.js.map +1 -0
  104. package/build/esm/index3.js +8 -0
  105. package/build/esm/index3.js.map +1 -0
  106. package/build/esm/index4.js +9 -0
  107. package/build/esm/index4.js.map +1 -0
  108. package/build/esm/index5.js +11 -0
  109. package/build/esm/index5.js.map +1 -0
  110. package/build/esm/index6.js +10 -0
  111. package/build/esm/index6.js.map +1 -0
  112. package/build/esm/registerKeyset-35f1ea08.js +212 -0
  113. package/build/esm/registerKeyset-35f1ea08.js.map +1 -0
  114. package/build/esm/style-inject.es-cfd97593.js +35 -0
  115. package/build/esm/style-inject.es-cfd97593.js.map +1 -0
  116. package/build/esm/tslib.es6-3cd4e99f.js +34 -0
  117. package/build/esm/tslib.es6-3cd4e99f.js.map +1 -0
  118. package/build/esm/utils-cc9b1968.js +6 -0
  119. package/build/esm/utils-cc9b1968.js.map +1 -0
  120. package/package.json +3 -3
@@ -1,4 +1,18 @@
1
1
  import React from 'react';
2
2
  import { AsideHeaderProps } from './types';
3
- import './AsideHeader.scss';
3
+ /**
4
+ * Simply usage of AsideHeader:
5
+ * @example
6
+ * <AsideHeader renderContent={renderContent} {...props} />
7
+ *
8
+ * Advanced usage of AsideHeader:
9
+ * @example
10
+ * <PageLayout reverse >
11
+ * <PageLayout.Content>
12
+ * <Content />
13
+ * </PageLayout.Content>
14
+ *
15
+ * <PageLayoutAside {...props} />
16
+ * </PageLayout>
17
+ */
4
18
  export declare const AsideHeader: React.ForwardRefExoticComponent<AsideHeaderProps & React.RefAttributes<HTMLDivElement>>;
@@ -4,14 +4,13 @@ import { AsideHeaderInnerProps } from './types';
4
4
  export interface AsideHeaderInnerContextType extends AsideHeaderInnerProps {
5
5
  menuItems: MenuItem[];
6
6
  allPagesIsAvailable: boolean;
7
- size: number;
8
7
  onItemClick: (item: MenuItem, collapsed: boolean, event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
9
8
  }
10
9
  export declare const AsideHeaderInnerContext: React.Context<AsideHeaderInnerContextType | undefined>;
11
10
  export declare const AsideHeaderInnerContextProvider: React.Provider<AsideHeaderInnerContextType | undefined>;
12
11
  export declare const useAsideHeaderInnerContext: () => AsideHeaderInnerContextType;
13
12
  export interface AsideHeaderContextType {
14
- compact?: boolean;
13
+ compact: boolean;
15
14
  size: number;
16
15
  }
17
16
  export declare const AsideHeaderContext: React.Context<AsideHeaderContextType | undefined>;
@@ -3,3 +3,4 @@ export default _default;
3
3
  export declare const Showcase: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
4
4
  export declare const Compact: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
5
5
  export declare const MultipleTooltip: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
6
+ export declare const AdvancedUsage: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
@@ -0,0 +1,11 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { ContentProps } from '../../../Content';
3
+ import { LayoutProps } from '../../types';
4
+ import '../../AsideHeader.scss';
5
+ export interface PageLayoutProps extends PropsWithChildren<LayoutProps> {
6
+ reverse?: boolean;
7
+ }
8
+ declare const PageLayout: (({ compact, reverse, className, children }: PageLayoutProps) => React.JSX.Element) & {
9
+ Content: React.FC<React.PropsWithChildren<Pick<ContentProps, "renderContent">>>;
10
+ };
11
+ export { PageLayout };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { AsideHeaderProps } from '../../types';
3
+ type Props = Omit<AsideHeaderProps, 'compact' | 'size'>;
4
+ export declare const PageLayoutAside: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
5
+ export {};
@@ -2,10 +2,15 @@
2
2
  import { RenderContentType } from '../Content';
3
3
  import { DrawerItemProps } from '../Drawer/Drawer';
4
4
  import { LogoProps, MenuItem, SubheaderMenuItem, OpenModalSubscriber } from '../types';
5
+ import { AsideHeaderContextType } from './AsideHeaderContext';
6
+ export interface LayoutProps {
7
+ compact: boolean;
8
+ className?: string;
9
+ }
5
10
  export interface AsideHeaderGeneralProps {
6
11
  logo: LogoProps;
7
- compact: boolean;
8
12
  multipleTooltip?: boolean;
13
+ reverse?: boolean;
9
14
  className?: string;
10
15
  collapseTitle?: string;
11
16
  expandTitle?: string;
@@ -27,8 +32,8 @@ export interface AsideHeaderDefaultProps {
27
32
  onMenuItemsChanged?: (items: MenuItem[]) => void;
28
33
  headerDecoration?: boolean;
29
34
  }
30
- export type AsideHeaderInnerProps = AsideHeaderGeneralProps & AsideHeaderDefaultProps;
31
- export interface AsideHeaderProps extends AsideHeaderGeneralProps, Partial<AsideHeaderDefaultProps> {
35
+ export type AsideHeaderInnerProps = AsideHeaderGeneralProps & AsideHeaderDefaultProps & AsideHeaderContextType;
36
+ export interface AsideHeaderProps extends AsideHeaderGeneralProps, LayoutProps, Partial<AsideHeaderDefaultProps> {
32
37
  }
33
38
  export declare enum InnerPanels {
34
39
  AllPages = "all-pages"
@@ -1,6 +1,6 @@
1
1
  import { MenuItem } from './../types';
2
2
  import { CompositeBarItem } from '../CompositeBar/CompositeBar';
3
- export declare function getItemHeight(item: CompositeBarItem): 40 | 15 | 50;
3
+ export declare function getItemHeight(item: CompositeBarItem): 15 | 40 | 50;
4
4
  export declare function getItemsHeight<T extends CompositeBarItem>(items: T[]): number;
5
5
  export declare function getSelectedItemIndex(items: MenuItem[]): number | undefined;
6
6
  export declare function getPinnedItems(items: MenuItem[]): MenuItem[];
@@ -2,11 +2,10 @@ import React from 'react';
2
2
  export type RenderContentType = (data: {
3
3
  size: number;
4
4
  }) => React.ReactNode;
5
- interface ContentProps {
5
+ export interface ContentProps {
6
6
  size: number;
7
7
  className?: string;
8
8
  cssSizeVariableName?: string;
9
9
  renderContent?: RenderContentType;
10
10
  }
11
11
  export declare const Content: React.FC<ContentProps>;
12
- export {};
@@ -3,6 +3,8 @@ export type { AsideHeaderProps } from './AsideHeader/types';
3
3
  export { AsideHeaderContextProvider, useAsideHeaderContext } from './AsideHeader/AsideHeaderContext';
4
4
  export { Drawer, DrawerProps, DrawerItemProps, DrawerItem } from './Drawer/Drawer';
5
5
  export { FooterItem, FooterItemProps } from './FooterItem/FooterItem';
6
+ export { PageLayout, type PageLayoutProps } from './AsideHeader/components/PageLayout/PageLayout';
7
+ export { PageLayoutAside } from './AsideHeader/components/PageLayout/PageLayoutAside';
6
8
  export * from './ActionBar';
7
9
  export * from './Title';
8
10
  export * from './HotkeysPanel';
@@ -0,0 +1,6 @@
1
+ const ASIDE_HEADER_ICON_SIZE = 18;
2
+ const ASIDE_HEADER_COMPACT_WIDTH = 56;
3
+ const ASIDE_HEADER_EXPANDED_WIDTH = 236;
4
+
5
+ export { ASIDE_HEADER_ICON_SIZE as A, ASIDE_HEADER_COMPACT_WIDTH as a, ASIDE_HEADER_EXPANDED_WIDTH as b };
6
+ //# sourceMappingURL=constants-b3a73cd1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-b3a73cd1.js","sources":["../../../src/components/constants.ts"],"sourcesContent":["export const ASIDE_HEADER_ICON_SIZE = 18;\nexport const ASIDE_HEADER_COMPACT_WIDTH = 56;\nexport const ASIDE_HEADER_EXPANDED_WIDTH = 236;\n"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG,GAAG;AAClC,MAAM,0BAA0B,GAAG,GAAG;AACtC,MAAM,2BAA2B,GAAG;;;;"}
@@ -0,0 +1,543 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ /**
4
+ * Checks if `value` is the
5
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
6
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
7
+ *
8
+ * @static
9
+ * @memberOf _
10
+ * @since 0.1.0
11
+ * @category Lang
12
+ * @param {*} value The value to check.
13
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
14
+ * @example
15
+ *
16
+ * _.isObject({});
17
+ * // => true
18
+ *
19
+ * _.isObject([1, 2, 3]);
20
+ * // => true
21
+ *
22
+ * _.isObject(_.noop);
23
+ * // => true
24
+ *
25
+ * _.isObject(null);
26
+ * // => false
27
+ */
28
+
29
+ function isObject$2(value) {
30
+ var type = typeof value;
31
+ return value != null && (type == 'object' || type == 'function');
32
+ }
33
+
34
+ var isObject_1 = isObject$2;
35
+
36
+ /** Detect free variable `global` from Node.js. */
37
+
38
+ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
39
+
40
+ var _freeGlobal = freeGlobal$1;
41
+
42
+ var freeGlobal = _freeGlobal;
43
+
44
+ /** Detect free variable `self`. */
45
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
46
+
47
+ /** Used as a reference to the global object. */
48
+ var root$2 = freeGlobal || freeSelf || Function('return this')();
49
+
50
+ var _root = root$2;
51
+
52
+ var root$1 = _root;
53
+
54
+ /**
55
+ * Gets the timestamp of the number of milliseconds that have elapsed since
56
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
57
+ *
58
+ * @static
59
+ * @memberOf _
60
+ * @since 2.4.0
61
+ * @category Date
62
+ * @returns {number} Returns the timestamp.
63
+ * @example
64
+ *
65
+ * _.defer(function(stamp) {
66
+ * console.log(_.now() - stamp);
67
+ * }, _.now());
68
+ * // => Logs the number of milliseconds it took for the deferred invocation.
69
+ */
70
+ var now$1 = function() {
71
+ return root$1.Date.now();
72
+ };
73
+
74
+ var now_1 = now$1;
75
+
76
+ /** Used to match a single whitespace character. */
77
+
78
+ var reWhitespace = /\s/;
79
+
80
+ /**
81
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
82
+ * character of `string`.
83
+ *
84
+ * @private
85
+ * @param {string} string The string to inspect.
86
+ * @returns {number} Returns the index of the last non-whitespace character.
87
+ */
88
+ function trimmedEndIndex$1(string) {
89
+ var index = string.length;
90
+
91
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
92
+ return index;
93
+ }
94
+
95
+ var _trimmedEndIndex = trimmedEndIndex$1;
96
+
97
+ var trimmedEndIndex = _trimmedEndIndex;
98
+
99
+ /** Used to match leading whitespace. */
100
+ var reTrimStart = /^\s+/;
101
+
102
+ /**
103
+ * The base implementation of `_.trim`.
104
+ *
105
+ * @private
106
+ * @param {string} string The string to trim.
107
+ * @returns {string} Returns the trimmed string.
108
+ */
109
+ function baseTrim$1(string) {
110
+ return string
111
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
112
+ : string;
113
+ }
114
+
115
+ var _baseTrim = baseTrim$1;
116
+
117
+ var root = _root;
118
+
119
+ /** Built-in value references. */
120
+ var Symbol$2 = root.Symbol;
121
+
122
+ var _Symbol = Symbol$2;
123
+
124
+ var Symbol$1 = _Symbol;
125
+
126
+ /** Used for built-in method references. */
127
+ var objectProto$1 = Object.prototype;
128
+
129
+ /** Used to check objects for own properties. */
130
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
131
+
132
+ /**
133
+ * Used to resolve the
134
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
135
+ * of values.
136
+ */
137
+ var nativeObjectToString$1 = objectProto$1.toString;
138
+
139
+ /** Built-in value references. */
140
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
141
+
142
+ /**
143
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
144
+ *
145
+ * @private
146
+ * @param {*} value The value to query.
147
+ * @returns {string} Returns the raw `toStringTag`.
148
+ */
149
+ function getRawTag$1(value) {
150
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1),
151
+ tag = value[symToStringTag$1];
152
+
153
+ try {
154
+ value[symToStringTag$1] = undefined;
155
+ var unmasked = true;
156
+ } catch (e) {}
157
+
158
+ var result = nativeObjectToString$1.call(value);
159
+ if (unmasked) {
160
+ if (isOwn) {
161
+ value[symToStringTag$1] = tag;
162
+ } else {
163
+ delete value[symToStringTag$1];
164
+ }
165
+ }
166
+ return result;
167
+ }
168
+
169
+ var _getRawTag = getRawTag$1;
170
+
171
+ /** Used for built-in method references. */
172
+
173
+ var objectProto = Object.prototype;
174
+
175
+ /**
176
+ * Used to resolve the
177
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
178
+ * of values.
179
+ */
180
+ var nativeObjectToString = objectProto.toString;
181
+
182
+ /**
183
+ * Converts `value` to a string using `Object.prototype.toString`.
184
+ *
185
+ * @private
186
+ * @param {*} value The value to convert.
187
+ * @returns {string} Returns the converted string.
188
+ */
189
+ function objectToString$1(value) {
190
+ return nativeObjectToString.call(value);
191
+ }
192
+
193
+ var _objectToString = objectToString$1;
194
+
195
+ var Symbol = _Symbol,
196
+ getRawTag = _getRawTag,
197
+ objectToString = _objectToString;
198
+
199
+ /** `Object#toString` result references. */
200
+ var nullTag = '[object Null]',
201
+ undefinedTag = '[object Undefined]';
202
+
203
+ /** Built-in value references. */
204
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
205
+
206
+ /**
207
+ * The base implementation of `getTag` without fallbacks for buggy environments.
208
+ *
209
+ * @private
210
+ * @param {*} value The value to query.
211
+ * @returns {string} Returns the `toStringTag`.
212
+ */
213
+ function baseGetTag$1(value) {
214
+ if (value == null) {
215
+ return value === undefined ? undefinedTag : nullTag;
216
+ }
217
+ return (symToStringTag && symToStringTag in Object(value))
218
+ ? getRawTag(value)
219
+ : objectToString(value);
220
+ }
221
+
222
+ var _baseGetTag = baseGetTag$1;
223
+
224
+ /**
225
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
226
+ * and has a `typeof` result of "object".
227
+ *
228
+ * @static
229
+ * @memberOf _
230
+ * @since 4.0.0
231
+ * @category Lang
232
+ * @param {*} value The value to check.
233
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
234
+ * @example
235
+ *
236
+ * _.isObjectLike({});
237
+ * // => true
238
+ *
239
+ * _.isObjectLike([1, 2, 3]);
240
+ * // => true
241
+ *
242
+ * _.isObjectLike(_.noop);
243
+ * // => false
244
+ *
245
+ * _.isObjectLike(null);
246
+ * // => false
247
+ */
248
+
249
+ function isObjectLike$1(value) {
250
+ return value != null && typeof value == 'object';
251
+ }
252
+
253
+ var isObjectLike_1 = isObjectLike$1;
254
+
255
+ var baseGetTag = _baseGetTag,
256
+ isObjectLike = isObjectLike_1;
257
+
258
+ /** `Object#toString` result references. */
259
+ var symbolTag = '[object Symbol]';
260
+
261
+ /**
262
+ * Checks if `value` is classified as a `Symbol` primitive or object.
263
+ *
264
+ * @static
265
+ * @memberOf _
266
+ * @since 4.0.0
267
+ * @category Lang
268
+ * @param {*} value The value to check.
269
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
270
+ * @example
271
+ *
272
+ * _.isSymbol(Symbol.iterator);
273
+ * // => true
274
+ *
275
+ * _.isSymbol('abc');
276
+ * // => false
277
+ */
278
+ function isSymbol$1(value) {
279
+ return typeof value == 'symbol' ||
280
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
281
+ }
282
+
283
+ var isSymbol_1 = isSymbol$1;
284
+
285
+ var baseTrim = _baseTrim,
286
+ isObject$1 = isObject_1,
287
+ isSymbol = isSymbol_1;
288
+
289
+ /** Used as references for various `Number` constants. */
290
+ var NAN = 0 / 0;
291
+
292
+ /** Used to detect bad signed hexadecimal string values. */
293
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
294
+
295
+ /** Used to detect binary string values. */
296
+ var reIsBinary = /^0b[01]+$/i;
297
+
298
+ /** Used to detect octal string values. */
299
+ var reIsOctal = /^0o[0-7]+$/i;
300
+
301
+ /** Built-in method references without a dependency on `root`. */
302
+ var freeParseInt = parseInt;
303
+
304
+ /**
305
+ * Converts `value` to a number.
306
+ *
307
+ * @static
308
+ * @memberOf _
309
+ * @since 4.0.0
310
+ * @category Lang
311
+ * @param {*} value The value to process.
312
+ * @returns {number} Returns the number.
313
+ * @example
314
+ *
315
+ * _.toNumber(3.2);
316
+ * // => 3.2
317
+ *
318
+ * _.toNumber(Number.MIN_VALUE);
319
+ * // => 5e-324
320
+ *
321
+ * _.toNumber(Infinity);
322
+ * // => Infinity
323
+ *
324
+ * _.toNumber('3.2');
325
+ * // => 3.2
326
+ */
327
+ function toNumber$1(value) {
328
+ if (typeof value == 'number') {
329
+ return value;
330
+ }
331
+ if (isSymbol(value)) {
332
+ return NAN;
333
+ }
334
+ if (isObject$1(value)) {
335
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
336
+ value = isObject$1(other) ? (other + '') : other;
337
+ }
338
+ if (typeof value != 'string') {
339
+ return value === 0 ? value : +value;
340
+ }
341
+ value = baseTrim(value);
342
+ var isBinary = reIsBinary.test(value);
343
+ return (isBinary || reIsOctal.test(value))
344
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
345
+ : (reIsBadHex.test(value) ? NAN : +value);
346
+ }
347
+
348
+ var toNumber_1 = toNumber$1;
349
+
350
+ var isObject = isObject_1,
351
+ now = now_1,
352
+ toNumber = toNumber_1;
353
+
354
+ /** Error message constants. */
355
+ var FUNC_ERROR_TEXT = 'Expected a function';
356
+
357
+ /* Built-in method references for those with the same name as other `lodash` methods. */
358
+ var nativeMax = Math.max,
359
+ nativeMin = Math.min;
360
+
361
+ /**
362
+ * Creates a debounced function that delays invoking `func` until after `wait`
363
+ * milliseconds have elapsed since the last time the debounced function was
364
+ * invoked. The debounced function comes with a `cancel` method to cancel
365
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
366
+ * Provide `options` to indicate whether `func` should be invoked on the
367
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
368
+ * with the last arguments provided to the debounced function. Subsequent
369
+ * calls to the debounced function return the result of the last `func`
370
+ * invocation.
371
+ *
372
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
373
+ * invoked on the trailing edge of the timeout only if the debounced function
374
+ * is invoked more than once during the `wait` timeout.
375
+ *
376
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
377
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
378
+ *
379
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
380
+ * for details over the differences between `_.debounce` and `_.throttle`.
381
+ *
382
+ * @static
383
+ * @memberOf _
384
+ * @since 0.1.0
385
+ * @category Function
386
+ * @param {Function} func The function to debounce.
387
+ * @param {number} [wait=0] The number of milliseconds to delay.
388
+ * @param {Object} [options={}] The options object.
389
+ * @param {boolean} [options.leading=false]
390
+ * Specify invoking on the leading edge of the timeout.
391
+ * @param {number} [options.maxWait]
392
+ * The maximum time `func` is allowed to be delayed before it's invoked.
393
+ * @param {boolean} [options.trailing=true]
394
+ * Specify invoking on the trailing edge of the timeout.
395
+ * @returns {Function} Returns the new debounced function.
396
+ * @example
397
+ *
398
+ * // Avoid costly calculations while the window size is in flux.
399
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
400
+ *
401
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
402
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
403
+ * 'leading': true,
404
+ * 'trailing': false
405
+ * }));
406
+ *
407
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
408
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
409
+ * var source = new EventSource('/stream');
410
+ * jQuery(source).on('message', debounced);
411
+ *
412
+ * // Cancel the trailing debounced invocation.
413
+ * jQuery(window).on('popstate', debounced.cancel);
414
+ */
415
+ function debounce(func, wait, options) {
416
+ var lastArgs,
417
+ lastThis,
418
+ maxWait,
419
+ result,
420
+ timerId,
421
+ lastCallTime,
422
+ lastInvokeTime = 0,
423
+ leading = false,
424
+ maxing = false,
425
+ trailing = true;
426
+
427
+ if (typeof func != 'function') {
428
+ throw new TypeError(FUNC_ERROR_TEXT);
429
+ }
430
+ wait = toNumber(wait) || 0;
431
+ if (isObject(options)) {
432
+ leading = !!options.leading;
433
+ maxing = 'maxWait' in options;
434
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
435
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
436
+ }
437
+
438
+ function invokeFunc(time) {
439
+ var args = lastArgs,
440
+ thisArg = lastThis;
441
+
442
+ lastArgs = lastThis = undefined;
443
+ lastInvokeTime = time;
444
+ result = func.apply(thisArg, args);
445
+ return result;
446
+ }
447
+
448
+ function leadingEdge(time) {
449
+ // Reset any `maxWait` timer.
450
+ lastInvokeTime = time;
451
+ // Start the timer for the trailing edge.
452
+ timerId = setTimeout(timerExpired, wait);
453
+ // Invoke the leading edge.
454
+ return leading ? invokeFunc(time) : result;
455
+ }
456
+
457
+ function remainingWait(time) {
458
+ var timeSinceLastCall = time - lastCallTime,
459
+ timeSinceLastInvoke = time - lastInvokeTime,
460
+ timeWaiting = wait - timeSinceLastCall;
461
+
462
+ return maxing
463
+ ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
464
+ : timeWaiting;
465
+ }
466
+
467
+ function shouldInvoke(time) {
468
+ var timeSinceLastCall = time - lastCallTime,
469
+ timeSinceLastInvoke = time - lastInvokeTime;
470
+
471
+ // Either this is the first call, activity has stopped and we're at the
472
+ // trailing edge, the system time has gone backwards and we're treating
473
+ // it as the trailing edge, or we've hit the `maxWait` limit.
474
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
475
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
476
+ }
477
+
478
+ function timerExpired() {
479
+ var time = now();
480
+ if (shouldInvoke(time)) {
481
+ return trailingEdge(time);
482
+ }
483
+ // Restart the timer.
484
+ timerId = setTimeout(timerExpired, remainingWait(time));
485
+ }
486
+
487
+ function trailingEdge(time) {
488
+ timerId = undefined;
489
+
490
+ // Only invoke if we have `lastArgs` which means `func` has been
491
+ // debounced at least once.
492
+ if (trailing && lastArgs) {
493
+ return invokeFunc(time);
494
+ }
495
+ lastArgs = lastThis = undefined;
496
+ return result;
497
+ }
498
+
499
+ function cancel() {
500
+ if (timerId !== undefined) {
501
+ clearTimeout(timerId);
502
+ }
503
+ lastInvokeTime = 0;
504
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
505
+ }
506
+
507
+ function flush() {
508
+ return timerId === undefined ? result : trailingEdge(now());
509
+ }
510
+
511
+ function debounced() {
512
+ var time = now(),
513
+ isInvoking = shouldInvoke(time);
514
+
515
+ lastArgs = arguments;
516
+ lastThis = this;
517
+ lastCallTime = time;
518
+
519
+ if (isInvoking) {
520
+ if (timerId === undefined) {
521
+ return leadingEdge(lastCallTime);
522
+ }
523
+ if (maxing) {
524
+ // Handle invocations in a tight loop.
525
+ clearTimeout(timerId);
526
+ timerId = setTimeout(timerExpired, wait);
527
+ return invokeFunc(lastCallTime);
528
+ }
529
+ }
530
+ if (timerId === undefined) {
531
+ timerId = setTimeout(timerExpired, wait);
532
+ }
533
+ return result;
534
+ }
535
+ debounced.cancel = cancel;
536
+ debounced.flush = flush;
537
+ return debounced;
538
+ }
539
+
540
+ var debounce_1 = debounce;
541
+
542
+ export { debounce_1 as d };
543
+ //# sourceMappingURL=debounce-64cd2b4c.js.map