@atlassian/aui 9.12.6 → 10.0.0-M02
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.
- package/dist/aui/aui-css-deprecations.js +1 -1
- package/dist/aui/aui-css-deprecations.js.map +1 -1
- package/dist/aui/aui-prototyping-browserfocus.css +1 -1
- package/dist/aui/aui-prototyping-browserfocus.css.map +1 -1
- package/dist/aui/aui-prototyping-darkmode.css.map +1 -1
- package/dist/aui/aui-prototyping-design-tokens-api-full.js +1 -1
- package/dist/aui/aui-prototyping-design-tokens-api.js +1 -1
- package/dist/aui/aui-prototyping-design-tokens-base-themes-css.css +1 -1
- package/dist/aui/aui-prototyping-design-tokens-base-themes-css.js +1 -1
- package/dist/aui/aui-prototyping-design-tokens-base-themes.js +1 -1
- package/dist/aui/aui-prototyping.css +4 -4
- package/dist/aui/aui-prototyping.css.map +1 -1
- package/dist/aui/aui-prototyping.js +10 -10
- package/dist/aui/aui-prototyping.js.map +1 -1
- package/dist/aui/aui-prototyping.nodeps.css +4 -4
- package/dist/aui/aui-prototyping.nodeps.css.map +1 -1
- package/dist/aui/aui-prototyping.nodeps.js +10 -10
- package/dist/aui/aui-prototyping.nodeps.js.map +1 -1
- package/entry/internal/deprecation.js +1 -1
- package/package.json +6 -4
- package/src/js/aui/dialog.js +10 -2
- package/src/js/aui/internal/deprecation.ts +368 -0
- package/src/js/aui/internal/select/suggestions-model.js +72 -50
- package/src/js/aui/internal/select/suggestions-view.js +103 -58
- package/src/js/aui/layer-manager-global.js +2 -2
- package/src/less/aui-select2.less +1 -1
- package/src/less/forms-current.less +9 -11
- package/src/less/imports/aui-theme/core/colors.less +2 -2
- package/src/js/aui/internal/deprecation.js +0 -323
|
@@ -1 +1 @@
|
|
|
1
|
-
import '@atlassian/aui/src/js/aui/internal/deprecation
|
|
1
|
+
import '@atlassian/aui/src/js/aui/internal/deprecation';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlassian/aui",
|
|
3
3
|
"description": "Atlassian User Interface library",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "10.0.0-M02",
|
|
5
5
|
"author": "Atlassian Pty Ltd.",
|
|
6
6
|
"homepage": "https://aui.atlassian.com",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -51,9 +51,11 @@
|
|
|
51
51
|
"underscore": "1.13.7"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@atlassian/aui-webpack-config": "3.0.
|
|
55
|
-
"@babel/core": "7.
|
|
56
|
-
"@babel/preset-env": "7.
|
|
54
|
+
"@atlassian/aui-webpack-config": "3.0.2",
|
|
55
|
+
"@babel/core": "7.25.8",
|
|
56
|
+
"@babel/preset-env": "7.25.8",
|
|
57
|
+
"@types/jqueryui": "1.12.23",
|
|
58
|
+
"@types/backbone": "1.4.22",
|
|
57
59
|
"fs-extra": "9.1.0",
|
|
58
60
|
"ignore-emit-webpack-plugin": "2.0.6",
|
|
59
61
|
"jquery": "3.5.1",
|
package/src/js/aui/dialog.js
CHANGED
|
@@ -23,6 +23,7 @@ const ZINDEX_DIALOG_1 = 2600; // see also dialog.less
|
|
|
23
23
|
* </pre>
|
|
24
24
|
* @param options {object} [optional] Permitted options and defaults are as follows:
|
|
25
25
|
* width (800), height (600), keypressListener (closes dialog on ESC).
|
|
26
|
+
* @returns {Popup}
|
|
26
27
|
*/
|
|
27
28
|
function createPopup (options) {
|
|
28
29
|
var defaults = {
|
|
@@ -80,7 +81,11 @@ function createPopup (options) {
|
|
|
80
81
|
* Popup object
|
|
81
82
|
* @class Popup
|
|
82
83
|
* @static
|
|
83
|
-
|
|
84
|
+
* @property {function(): void} enable
|
|
85
|
+
* @property {function(): void} disable
|
|
86
|
+
* @property {function(): void} remove
|
|
87
|
+
* @property {function(): void} show
|
|
88
|
+
*/
|
|
84
89
|
|
|
85
90
|
//blanket for reference further down
|
|
86
91
|
var blanket = $('.aui-blanket');
|
|
@@ -212,7 +217,10 @@ function createPopup (options) {
|
|
|
212
217
|
return res;
|
|
213
218
|
}
|
|
214
219
|
|
|
215
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Scoping function
|
|
222
|
+
* @type {(function(number, number, number): Dialog)|*}
|
|
223
|
+
*/
|
|
216
224
|
var Dialog = (function () {
|
|
217
225
|
/**
|
|
218
226
|
* @class Button
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import globalize from './globalize';
|
|
2
|
+
|
|
3
|
+
type ArbitraryFunction = () => unknown;
|
|
4
|
+
|
|
5
|
+
type SelectorMap = {
|
|
6
|
+
selector: string,
|
|
7
|
+
options?: DeprecationOptions,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Purely to reflect the existing state of the code, not ideal.
|
|
12
|
+
*/
|
|
13
|
+
export type DeprecationOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* the version this has been deprecated since
|
|
16
|
+
*/
|
|
17
|
+
sinceVersion?: string;
|
|
18
|
+
/**
|
|
19
|
+
* the version this will be removed in
|
|
20
|
+
*/
|
|
21
|
+
removeInVersion?: string;
|
|
22
|
+
/**
|
|
23
|
+
* the name of an alternative to use
|
|
24
|
+
*/
|
|
25
|
+
alternativeName?: string;
|
|
26
|
+
/**
|
|
27
|
+
* extra information to be printed at the end of the deprecation log
|
|
28
|
+
*/
|
|
29
|
+
extraInfo?: string;
|
|
30
|
+
/**
|
|
31
|
+
* an extra object that will be printed at the end
|
|
32
|
+
*/
|
|
33
|
+
extraObject?: object | string;
|
|
34
|
+
/**
|
|
35
|
+
* a human-readable name to show in the deprecation message. If not provided, it is inferred from the function or object being deprecated.
|
|
36
|
+
*/
|
|
37
|
+
displayName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* type of the deprecation to append to the start of the deprecation message. e.g. JS or CSS
|
|
40
|
+
*/
|
|
41
|
+
deprecationType?: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method -- Leaving behaviour identical for now
|
|
45
|
+
const has = Object.prototype.hasOwnProperty;
|
|
46
|
+
const deprecationCalls: (string | string[])[] = [];
|
|
47
|
+
|
|
48
|
+
function toSentenceCase (name: string): string {
|
|
49
|
+
if (!name) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
name = '' + name;
|
|
53
|
+
|
|
54
|
+
return name.charAt(0).toUpperCase() + name.substring(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getDeprecatedLocation (printFrameOffset: number) {
|
|
58
|
+
const error = new Error();
|
|
59
|
+
|
|
60
|
+
let stacktraceString: string | undefined = error.stack ??
|
|
61
|
+
// @ts-expect-error -- preserving the legacy, not sure what .stacktrace would exist on, guessing the type
|
|
62
|
+
(error.stacktrace as string | undefined);
|
|
63
|
+
stacktraceString = (stacktraceString?.replace(/^Error\n/, '')) ?? '';
|
|
64
|
+
|
|
65
|
+
const stacktrace = stacktraceString.split('\n');
|
|
66
|
+
return stacktrace[printFrameOffset + 2];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function logger(...args: unknown[]): void {
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS test DOM environments
|
|
71
|
+
if (typeof console !== 'undefined' && console.warn) {
|
|
72
|
+
Function.prototype.apply.call(console.warn, console, args);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Return a function that logs a deprecation warning to the console the first time it is called from a certain location.
|
|
78
|
+
* It will also print the stack frame of the calling function.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} displayName the name of the thing being deprecated
|
|
81
|
+
* @param {DeprecationOptions} options
|
|
82
|
+
* @return {Function} that logs the warning and stack frame of the calling function. Takes in an optional parameter for the offset of
|
|
83
|
+
* the stack frame to print, the default is 0. For example, 0 will log it for the line of the calling function,
|
|
84
|
+
* -1 will print the location the logger was called from
|
|
85
|
+
*/
|
|
86
|
+
const getShowDeprecationMessagePublic = (displayName: string, options: DeprecationOptions): ArbitraryFunction => {
|
|
87
|
+
return getShowDeprecationMessageInternal(displayName, options);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Return a function that logs a deprecation warning to the console the first time it is called from a certain location.
|
|
92
|
+
* It will also print the stack frame of the calling function.
|
|
93
|
+
*
|
|
94
|
+
* @param {string | symbol | number | Function} displayName the name of the thing being deprecated
|
|
95
|
+
* @param {DeprecationOptions} [options]
|
|
96
|
+
* @return {Function} that logs the warning and stack frame of the calling function. Takes in an optional parameter for the offset of
|
|
97
|
+
* the stack frame to print, the default is 0. For example, 0 will log it for the line of the calling function,
|
|
98
|
+
* -1 will print the location the logger was called from
|
|
99
|
+
*/
|
|
100
|
+
function getShowDeprecationMessageInternal(displayName: string | ArbitraryFunction, options?: DeprecationOptions): ArbitraryFunction {
|
|
101
|
+
// This can be used internally to pas in a showmessage fn
|
|
102
|
+
if (typeof displayName === 'function') {
|
|
103
|
+
return displayName;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let called = false;
|
|
107
|
+
options = options ?? {};
|
|
108
|
+
|
|
109
|
+
return function (printFrameOffset?: number): void {
|
|
110
|
+
let deprecatedLocation = getDeprecatedLocation(printFrameOffset ? printFrameOffset : 1) ?? '';
|
|
111
|
+
// Only log once if the stack frame doesn't exist to avoid spamming the console/test output
|
|
112
|
+
if (!called || !deprecationCalls.includes(deprecatedLocation)) {
|
|
113
|
+
deprecationCalls.push(deprecatedLocation);
|
|
114
|
+
|
|
115
|
+
called = true;
|
|
116
|
+
|
|
117
|
+
const deprecationType = options.deprecationType ?? '';
|
|
118
|
+
|
|
119
|
+
let message = 'DEPRECATED ' + deprecationType + '- ' + toSentenceCase(displayName) +
|
|
120
|
+
' has been deprecated' + (options.sinceVersion ? ' since ' + options.sinceVersion : '') +
|
|
121
|
+
' and will be removed in ' + (options.removeInVersion ?? 'a future release') + '.';
|
|
122
|
+
|
|
123
|
+
if (options.alternativeName) {
|
|
124
|
+
message += ' Use ' + options.alternativeName + ' instead. ';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (options.extraInfo) {
|
|
128
|
+
message += ' ' + options.extraInfo;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (deprecatedLocation === '') {
|
|
132
|
+
deprecatedLocation = ' \n ' + 'No stack trace of the deprecated usage is available in your current browser.';
|
|
133
|
+
} else {
|
|
134
|
+
deprecatedLocation = ' \n ' + String(deprecatedLocation);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (options.extraObject) {
|
|
138
|
+
message += '\n';
|
|
139
|
+
logger(message, options.extraObject, deprecatedLocation);
|
|
140
|
+
} else {
|
|
141
|
+
logger(message, deprecatedLocation);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function logCssDeprecation (selectorMap: SelectorMap, newNode: Node) {
|
|
148
|
+
let displayName = selectorMap.options?.displayName;
|
|
149
|
+
displayName = displayName ? ' (' + displayName + ')' : '';
|
|
150
|
+
|
|
151
|
+
const options: DeprecationOptions = Object.assign({
|
|
152
|
+
deprecationType: 'CSS',
|
|
153
|
+
extraObject: newNode,
|
|
154
|
+
}, selectorMap.options);
|
|
155
|
+
|
|
156
|
+
getShowDeprecationMessageInternal('\'' + selectorMap.selector + '\' pattern' + displayName, options)();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Returns a wrapped version of the function that logs a deprecation warning when the function is used.
|
|
161
|
+
* @param {Function} fn the fn to wrap
|
|
162
|
+
* @param {string} displayName the name of the fn to be displayed in the message
|
|
163
|
+
* @param {DeprecationOptions} options
|
|
164
|
+
* @return {Function} wrapping the original function
|
|
165
|
+
*/
|
|
166
|
+
function deprecateFunctionExpression(fn: ArbitraryFunction, displayName: string, options: DeprecationOptions): ArbitraryFunction {
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Just in case someone outside AUI is using it
|
|
168
|
+
options = options ?? {};
|
|
169
|
+
options.deprecationType = options.deprecationType ?? 'JS';
|
|
170
|
+
|
|
171
|
+
const showDeprecationMessage = getShowDeprecationMessageInternal(displayName || fn.name || 'this function', options);
|
|
172
|
+
return function (...args: unknown[]) {
|
|
173
|
+
showDeprecationMessage();
|
|
174
|
+
// @ts-expect-error Sorry TS, don't want to change this behaviour just yet in case of side effects
|
|
175
|
+
return fn.apply(this, args);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Returns a wrapped version of the constructor that logs a deprecation warning when the constructor is instantiated.
|
|
181
|
+
* @param {Function} constructorFn the constructor function to wrap
|
|
182
|
+
* @param {string} displayName the name of the fn to be displayed in the message
|
|
183
|
+
* @param {DeprecationOptions} options
|
|
184
|
+
* @return {Function} wrapping the original function
|
|
185
|
+
*/
|
|
186
|
+
function deprecateConstructor(constructorFn: ArbitraryFunction, displayName: string, options: DeprecationOptions): ArbitraryFunction {
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Just in case someone outside AUI is using it
|
|
188
|
+
options = options ?? {};
|
|
189
|
+
options.deprecationType = options.deprecationType ?? 'JS';
|
|
190
|
+
|
|
191
|
+
const deprecatedConstructor = deprecateFunctionExpression(constructorFn, displayName, options);
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
193
|
+
deprecatedConstructor.prototype = constructorFn.prototype;
|
|
194
|
+
Object.assign(deprecatedConstructor, constructorFn) //copy static methods across;
|
|
195
|
+
|
|
196
|
+
return deprecatedConstructor;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Wraps a "value" object property in a deprecation warning in browsers supporting Object.defineProperty
|
|
201
|
+
* @param {Object} obj the object containing the property
|
|
202
|
+
* @param {string} prop the name of the property to deprecate
|
|
203
|
+
* @param {DeprecationOptions} [options]
|
|
204
|
+
*/
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- This is easier to read
|
|
206
|
+
function deprecateValueProperty<T extends object, K extends keyof T & string>(obj: T, prop: K, options?: DeprecationOptions) {
|
|
207
|
+
let oldVal = obj[prop];
|
|
208
|
+
options = options ?? {};
|
|
209
|
+
options.deprecationType = options.deprecationType ?? 'JS';
|
|
210
|
+
|
|
211
|
+
const displayNameOrShowMessageFn = options.displayName ?? prop;
|
|
212
|
+
const showDeprecationMessage = getShowDeprecationMessageInternal(displayNameOrShowMessageFn, options);
|
|
213
|
+
Object.defineProperty(obj, prop, {
|
|
214
|
+
get: function (): T[K] {
|
|
215
|
+
showDeprecationMessage();
|
|
216
|
+
return oldVal;
|
|
217
|
+
},
|
|
218
|
+
set: function (val: T[K]): T[K] {
|
|
219
|
+
oldVal = val;
|
|
220
|
+
showDeprecationMessage();
|
|
221
|
+
return val;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Wraps an object property in a deprecation warning, if possible. functions will always log warnings, but other
|
|
228
|
+
* types of properties will only log in browsers supporting Object.defineProperty
|
|
229
|
+
* @param {Object} object the object containing the property
|
|
230
|
+
* @param {string} propertyKey the name of the property to deprecate
|
|
231
|
+
* @param {DeprecationOptions} options
|
|
232
|
+
*/
|
|
233
|
+
function deprecateObjectProperty<T extends object>(object: T, propertyKey: string & keyof T, options: DeprecationOptions) {
|
|
234
|
+
if (typeof object[propertyKey] === 'function') {
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Just in case someone outside AUI is using it
|
|
236
|
+
options = options ?? {};
|
|
237
|
+
options.deprecationType = options.deprecationType ?? 'JS';
|
|
238
|
+
|
|
239
|
+
const displayNameOrShowMessageFn = options.displayName ?? propertyKey;
|
|
240
|
+
// @ts-expect-error -- Maybe a TypeScript wizard can figure out something
|
|
241
|
+
// better than me so TS is happy. We only care it's a function.
|
|
242
|
+
object[propertyKey] = deprecateFunctionExpression(object[propertyKey], displayNameOrShowMessageFn, options);
|
|
243
|
+
} else {
|
|
244
|
+
deprecateValueProperty(object, propertyKey, options);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
type DeprecationOptionsWithAltNamePrefix = DeprecationOptions & {
|
|
249
|
+
/**
|
|
250
|
+
* a prefix for the alternative property name. Used to generate alternativeName per property.
|
|
251
|
+
*/
|
|
252
|
+
alternativeNamePrefix?: string
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Wraps all an objects properties in a deprecation warning, if possible. functions will always log warnings, but other
|
|
257
|
+
* types of properties will only log in browsers supporting Object.defineProperty
|
|
258
|
+
* @param {Object} obj the object to be wrapped
|
|
259
|
+
* @param {string} objDisplayPrefix the object's prefix to be used in logs
|
|
260
|
+
* @param {DeprecationOptionsWithAltNamePrefix} options
|
|
261
|
+
*/
|
|
262
|
+
function deprecateAllProperties(obj: object, objDisplayPrefix: string, options: DeprecationOptionsWithAltNamePrefix) {
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Just in case someone outside AUI is using it
|
|
264
|
+
options = options ?? {};
|
|
265
|
+
for (const attr in obj) {
|
|
266
|
+
if (has.call(obj, attr)) {
|
|
267
|
+
options.deprecationType = options.deprecationType ?? 'JS';
|
|
268
|
+
options.displayName = objDisplayPrefix + attr;
|
|
269
|
+
options.alternativeName = options.alternativeNamePrefix && (options.alternativeNamePrefix + attr);
|
|
270
|
+
deprecateObjectProperty(obj,
|
|
271
|
+
// @ts-expect-error -- We're very safely checking this is actually an attribute on the object
|
|
272
|
+
attr,
|
|
273
|
+
Object.assign({}, options));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function matchesSelector(node: Node, selector: string) {
|
|
279
|
+
if (node instanceof Element) {
|
|
280
|
+
return node.matches(selector);
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function handleAddingSelector(options?: DeprecationOptions) {
|
|
286
|
+
return function (selector: string) {
|
|
287
|
+
const selectorMap: SelectorMap = {
|
|
288
|
+
selector: selector,
|
|
289
|
+
options: options,
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// Search if matches have already been added
|
|
293
|
+
const matches = document.querySelectorAll(selector);
|
|
294
|
+
for (const match of matches) {
|
|
295
|
+
logCssDeprecation(selectorMap, match);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
observeFutureChange(selectorMap);
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Return a function that logs a deprecation warning to the console the first time it is called from a certain location.
|
|
304
|
+
* It will also print the stack frame of the calling function.
|
|
305
|
+
*/
|
|
306
|
+
function deprecateCSS(selectors: string | string[], options?: DeprecationOptions): void {
|
|
307
|
+
if (typeof selectors === 'string') {
|
|
308
|
+
selectors = [selectors];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
selectors.forEach(handleAddingSelector(options));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function testAndHandleDeprecation(newNode: Node) {
|
|
315
|
+
return function (selectorMap: SelectorMap) {
|
|
316
|
+
if (matchesSelector(newNode, selectorMap.selector)) {
|
|
317
|
+
logCssDeprecation(selectorMap, newNode);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const deprecatedSelectorMap: SelectorMap[] = [];
|
|
323
|
+
let observer: MutationObserver | undefined = undefined;
|
|
324
|
+
|
|
325
|
+
function observeFutureChange(selectorMap: SelectorMap) {
|
|
326
|
+
deprecatedSelectorMap.push(selectorMap);
|
|
327
|
+
|
|
328
|
+
// Lazily instantiate a mutation observer because they're expensive.
|
|
329
|
+
if (observer === undefined) {
|
|
330
|
+
observer = new MutationObserver(function (mutations) {
|
|
331
|
+
mutations.forEach(function (mutation) {
|
|
332
|
+
// TODO - should this also look at class changes, if possible?
|
|
333
|
+
const addedNodes = mutation.addedNodes;
|
|
334
|
+
|
|
335
|
+
for (const newNode of addedNodes) {
|
|
336
|
+
if (newNode.nodeType === 1) {
|
|
337
|
+
deprecatedSelectorMap.forEach(testAndHandleDeprecation(newNode));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const config = {
|
|
344
|
+
childList: true,
|
|
345
|
+
subtree: true
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
observer.observe(document, config);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
globalize('deprecate', {
|
|
353
|
+
fn: deprecateFunctionExpression,
|
|
354
|
+
construct: deprecateConstructor,
|
|
355
|
+
css: deprecateCSS,
|
|
356
|
+
prop: deprecateObjectProperty,
|
|
357
|
+
obj: deprecateAllProperties,
|
|
358
|
+
getMessageLogger: getShowDeprecationMessagePublic
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
export {
|
|
362
|
+
deprecateFunctionExpression as fn,
|
|
363
|
+
deprecateConstructor as construct,
|
|
364
|
+
deprecateCSS as css,
|
|
365
|
+
deprecateObjectProperty as prop,
|
|
366
|
+
deprecateAllProperties as obj,
|
|
367
|
+
getShowDeprecationMessagePublic as getMessageLogger
|
|
368
|
+
};
|
|
@@ -1,68 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Suggestion
|
|
3
|
+
* @property {string|number} id
|
|
4
|
+
*/
|
|
1
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} SuggestionsModelType
|
|
8
|
+
* @property {(oldSuggestions: Suggestion[]) => void} onChange
|
|
9
|
+
* @property {() => void} onHighlightChange
|
|
10
|
+
* @property {(index: number) => Suggestion|undefined} get
|
|
11
|
+
* @property {(suggestions?: Suggestion[]) => SuggestionsModelType} set
|
|
12
|
+
* @property {() => number} getNumberOfResults
|
|
13
|
+
* @property {(toHighlight?: Suggestion) => SuggestionsModelType} setHighlighted
|
|
14
|
+
* @property {(index: number) => SuggestionsModelType} highlight
|
|
15
|
+
* @property {() => SuggestionsModelType} highlightPrevious
|
|
16
|
+
* @property {() => SuggestionsModelType} highlightNext
|
|
17
|
+
* @property {() => Suggestion|undefined} highlighted
|
|
18
|
+
* @property {() => number} highlightedIndex
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @returns {SuggestionsModelType}
|
|
23
|
+
*/
|
|
2
24
|
function SuggestionsModel () {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
25
|
+
return {
|
|
26
|
+
_suggestions: [],
|
|
27
|
+
_activeIndex: -1,
|
|
6
28
|
|
|
7
|
-
|
|
8
|
-
onChange: function () {},
|
|
29
|
+
onChange: function () {},
|
|
9
30
|
|
|
10
|
-
|
|
31
|
+
onHighlightChange: function () {},
|
|
11
32
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
get: function (index) {
|
|
34
|
+
return this._suggestions[index];
|
|
35
|
+
},
|
|
15
36
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
set: function (suggestions) {
|
|
38
|
+
var oldSuggestions = this._suggestions;
|
|
39
|
+
this._suggestions = suggestions || [];
|
|
40
|
+
this.onChange(oldSuggestions);
|
|
41
|
+
return this;
|
|
42
|
+
},
|
|
22
43
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
getNumberOfResults: function () {
|
|
45
|
+
return this._suggestions.length;
|
|
46
|
+
},
|
|
26
47
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
48
|
+
setHighlighted: function (toHighlight) {
|
|
49
|
+
if (toHighlight) {
|
|
50
|
+
for (var i = 0; i < this._suggestions.length; i++) {
|
|
51
|
+
if (this._suggestions[i].id === toHighlight.id) {
|
|
52
|
+
this.highlight(i);
|
|
53
|
+
}
|
|
32
54
|
}
|
|
33
55
|
}
|
|
34
|
-
}
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
return this;
|
|
58
|
+
},
|
|
38
59
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
highlight: function (index) {
|
|
61
|
+
this._activeIndex = index;
|
|
62
|
+
this.onHighlightChange();
|
|
63
|
+
return this;
|
|
64
|
+
},
|
|
44
65
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
highlightPrevious: function () {
|
|
67
|
+
const current = this._activeIndex;
|
|
68
|
+
const previousActiveIndex = (current === 0) ? this._suggestions.length - 1 : (current - 1);
|
|
69
|
+
this.highlight(previousActiveIndex);
|
|
70
|
+
return this;
|
|
71
|
+
},
|
|
51
72
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
73
|
+
highlightNext: function () {
|
|
74
|
+
const current = this._activeIndex;
|
|
75
|
+
const nextActiveIndex = (current === this._suggestions.length - 1) ? 0 : (current + 1);
|
|
76
|
+
this.highlight(nextActiveIndex);
|
|
77
|
+
return this;
|
|
78
|
+
},
|
|
58
79
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
highlighted: function () {
|
|
81
|
+
return this.get(this._activeIndex);
|
|
82
|
+
},
|
|
62
83
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
84
|
+
highlightedIndex: function () {
|
|
85
|
+
return this._activeIndex;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
67
89
|
|
|
68
90
|
export default SuggestionsModel;
|