@atlaskit/react-select 2.4.4 → 2.4.5
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/CHANGELOG.md +8 -0
- package/dist/cjs/select.js +5 -1
- package/dist/cjs/utils.js +39 -1
- package/dist/es2019/select.js +6 -2
- package/dist/es2019/utils.js +36 -0
- package/dist/esm/select.js +6 -2
- package/dist/esm/utils.js +38 -0
- package/dist/types/select.d.ts +2 -2
- package/dist/types/utils.d.ts +6 -0
- package/dist/types-ts4.5/select.d.ts +2 -2
- package/dist/types-ts4.5/utils.d.ts +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/react-select
|
|
2
2
|
|
|
3
|
+
## 2.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#146587](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/146587)
|
|
8
|
+
[`f296c108b483f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f296c108b483f) -
|
|
9
|
+
Filter out unsupported styles from styles props under feature flag
|
|
10
|
+
|
|
3
11
|
## 2.4.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/select.js
CHANGED
|
@@ -406,7 +406,11 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
406
406
|
var base = _styles.defaultStyles[key](props);
|
|
407
407
|
base.boxSizing = 'border-box';
|
|
408
408
|
var custom = _this.props.styles[key];
|
|
409
|
-
|
|
409
|
+
if (!custom) {
|
|
410
|
+
return base;
|
|
411
|
+
}
|
|
412
|
+
var customStyles = (0, _platformFeatureFlags.fg)('compiled-react-select') ? (0, _utils.filterUnsupportedSelectors)(custom(base, props)) : custom(base, props);
|
|
413
|
+
return customStyles;
|
|
410
414
|
});
|
|
411
415
|
(0, _defineProperty2.default)(_this, "getClassNames", function (key, props) {
|
|
412
416
|
var _this$props$className, _this$props$className2;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.animatedScrollTo = animatedScrollTo;
|
|
8
8
|
exports.classNames = classNames;
|
|
9
|
-
exports.cleanValue = exports.cleanCommonProps = void 0;
|
|
9
|
+
exports.filterUnsupportedSelectors = exports.cleanValue = exports.cleanCommonProps = void 0;
|
|
10
10
|
exports.getBoundingClientObj = getBoundingClientObj;
|
|
11
11
|
exports.getScrollParent = getScrollParent;
|
|
12
12
|
exports.getScrollTop = getScrollTop;
|
|
@@ -342,4 +342,42 @@ var removeProps = exports.removeProps = function removeProps(propsObj) {
|
|
|
342
342
|
newProps[key] = val;
|
|
343
343
|
return newProps;
|
|
344
344
|
}, {});
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Filters out unsupported selectors (e.g., pseudo-classes, complex selectors) from a styles object.
|
|
349
|
+
* @param styles - The styles object to filter.
|
|
350
|
+
* @returns A new object containing only supported styles.
|
|
351
|
+
*/
|
|
352
|
+
var filterUnsupportedSelectors = exports.filterUnsupportedSelectors = function filterUnsupportedSelectors(styles) {
|
|
353
|
+
var unsupportedSelectors = [':hover', ':focus', ':active', ':visited', ':link', ':checked', ':disabled', ':enabled', ':first-child', ':last-child', ':nth-child', ':nth-last-child', ':only-child', ':first-of-type', ':last-of-type', ':nth-of-type', ':nth-last-of-type', ':only-of-type', ':empty', ':not', ':root', ':target', ':before', ':after', '::before', '::after', '::placeholder', '::selection', '::backdrop', '::marker', '::first-line', '::first-letter', '::spelling-error', '::grammar-error', '[attr]',
|
|
354
|
+
// Attribute selectors
|
|
355
|
+
'[attr=value]',
|
|
356
|
+
// Attribute value selectors
|
|
357
|
+
'[attr^=value]',
|
|
358
|
+
// Attribute starts with
|
|
359
|
+
'[attr$=value]',
|
|
360
|
+
// Attribute ends with
|
|
361
|
+
'[attr*=value]',
|
|
362
|
+
// Attribute contains
|
|
363
|
+
'[attr|=value]',
|
|
364
|
+
// Attribute value with hyphen
|
|
365
|
+
'[attr~=value]',
|
|
366
|
+
// Attribute value in space-separated list
|
|
367
|
+
'>',
|
|
368
|
+
// Child combinator
|
|
369
|
+
'+',
|
|
370
|
+
// Adjacent sibling combinator
|
|
371
|
+
'~',
|
|
372
|
+
// General sibling combinator
|
|
373
|
+
' ' // Descendant combinator
|
|
374
|
+
];
|
|
375
|
+
return Object.keys(styles).reduce(function (filteredStyles, key) {
|
|
376
|
+
if (!unsupportedSelectors.some(function (selector) {
|
|
377
|
+
return key.includes(selector);
|
|
378
|
+
})) {
|
|
379
|
+
filteredStyles[key] = styles[key];
|
|
380
|
+
}
|
|
381
|
+
return filteredStyles;
|
|
382
|
+
}, {});
|
|
345
383
|
};
|
package/dist/es2019/select.js
CHANGED
|
@@ -12,7 +12,7 @@ import LiveRegion from './components/live-region';
|
|
|
12
12
|
import { MenuPlacer } from './components/menu';
|
|
13
13
|
import { createFilter } from './filters';
|
|
14
14
|
import { defaultStyles } from './styles';
|
|
15
|
-
import { classNames, cleanValue, isDocumentElement, isMobileDevice, isTouchCapable, multiValueAsValue, noop, notNullish, scrollIntoView, singleValueAsValue, valueTernary } from './utils';
|
|
15
|
+
import { classNames, cleanValue, filterUnsupportedSelectors, isDocumentElement, isMobileDevice, isTouchCapable, multiValueAsValue, noop, notNullish, scrollIntoView, singleValueAsValue, valueTernary } from './utils';
|
|
16
16
|
export const defaultProps = {
|
|
17
17
|
// aria-live is by default with the live region so we don't need it
|
|
18
18
|
// eslint-disable-next-line @atlaskit/platform/no-module-level-eval
|
|
@@ -380,7 +380,11 @@ export default class Select extends Component {
|
|
|
380
380
|
const base = defaultStyles[key](props);
|
|
381
381
|
base.boxSizing = 'border-box';
|
|
382
382
|
const custom = this.props.styles[key];
|
|
383
|
-
|
|
383
|
+
if (!custom) {
|
|
384
|
+
return base;
|
|
385
|
+
}
|
|
386
|
+
const customStyles = fg('compiled-react-select') ? filterUnsupportedSelectors(custom(base, props)) : custom(base, props);
|
|
387
|
+
return customStyles;
|
|
384
388
|
});
|
|
385
389
|
_defineProperty(this, "getClassNames", (key, props) => {
|
|
386
390
|
var _this$props$className, _this$props$className2;
|
package/dist/es2019/utils.js
CHANGED
|
@@ -297,4 +297,40 @@ export const removeProps = (propsObj, ...properties) => {
|
|
|
297
297
|
newProps[key] = val;
|
|
298
298
|
return newProps;
|
|
299
299
|
}, {});
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Filters out unsupported selectors (e.g., pseudo-classes, complex selectors) from a styles object.
|
|
304
|
+
* @param styles - The styles object to filter.
|
|
305
|
+
* @returns A new object containing only supported styles.
|
|
306
|
+
*/
|
|
307
|
+
export const filterUnsupportedSelectors = styles => {
|
|
308
|
+
const unsupportedSelectors = [':hover', ':focus', ':active', ':visited', ':link', ':checked', ':disabled', ':enabled', ':first-child', ':last-child', ':nth-child', ':nth-last-child', ':only-child', ':first-of-type', ':last-of-type', ':nth-of-type', ':nth-last-of-type', ':only-of-type', ':empty', ':not', ':root', ':target', ':before', ':after', '::before', '::after', '::placeholder', '::selection', '::backdrop', '::marker', '::first-line', '::first-letter', '::spelling-error', '::grammar-error', '[attr]',
|
|
309
|
+
// Attribute selectors
|
|
310
|
+
'[attr=value]',
|
|
311
|
+
// Attribute value selectors
|
|
312
|
+
'[attr^=value]',
|
|
313
|
+
// Attribute starts with
|
|
314
|
+
'[attr$=value]',
|
|
315
|
+
// Attribute ends with
|
|
316
|
+
'[attr*=value]',
|
|
317
|
+
// Attribute contains
|
|
318
|
+
'[attr|=value]',
|
|
319
|
+
// Attribute value with hyphen
|
|
320
|
+
'[attr~=value]',
|
|
321
|
+
// Attribute value in space-separated list
|
|
322
|
+
'>',
|
|
323
|
+
// Child combinator
|
|
324
|
+
'+',
|
|
325
|
+
// Adjacent sibling combinator
|
|
326
|
+
'~',
|
|
327
|
+
// General sibling combinator
|
|
328
|
+
' ' // Descendant combinator
|
|
329
|
+
];
|
|
330
|
+
return Object.keys(styles).reduce((filteredStyles, key) => {
|
|
331
|
+
if (!unsupportedSelectors.some(selector => key.includes(selector))) {
|
|
332
|
+
filteredStyles[key] = styles[key];
|
|
333
|
+
}
|
|
334
|
+
return filteredStyles;
|
|
335
|
+
}, {});
|
|
300
336
|
};
|
package/dist/esm/select.js
CHANGED
|
@@ -23,7 +23,7 @@ import LiveRegion from './components/live-region';
|
|
|
23
23
|
import { MenuPlacer } from './components/menu';
|
|
24
24
|
import { createFilter } from './filters';
|
|
25
25
|
import { defaultStyles } from './styles';
|
|
26
|
-
import { classNames, cleanValue, isDocumentElement, isMobileDevice, isTouchCapable, multiValueAsValue, noop, notNullish, scrollIntoView, singleValueAsValue, valueTernary } from './utils';
|
|
26
|
+
import { classNames, cleanValue, filterUnsupportedSelectors, isDocumentElement, isMobileDevice, isTouchCapable, multiValueAsValue, noop, notNullish, scrollIntoView, singleValueAsValue, valueTernary } from './utils';
|
|
27
27
|
export var defaultProps = {
|
|
28
28
|
// aria-live is by default with the live region so we don't need it
|
|
29
29
|
// eslint-disable-next-line @atlaskit/platform/no-module-level-eval
|
|
@@ -397,7 +397,11 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
397
397
|
var base = defaultStyles[key](props);
|
|
398
398
|
base.boxSizing = 'border-box';
|
|
399
399
|
var custom = _this.props.styles[key];
|
|
400
|
-
|
|
400
|
+
if (!custom) {
|
|
401
|
+
return base;
|
|
402
|
+
}
|
|
403
|
+
var customStyles = fg('compiled-react-select') ? filterUnsupportedSelectors(custom(base, props)) : custom(base, props);
|
|
404
|
+
return customStyles;
|
|
401
405
|
});
|
|
402
406
|
_defineProperty(_this, "getClassNames", function (key, props) {
|
|
403
407
|
var _this$props$className, _this$props$className2;
|
package/dist/esm/utils.js
CHANGED
|
@@ -315,4 +315,42 @@ export var removeProps = function removeProps(propsObj) {
|
|
|
315
315
|
newProps[key] = val;
|
|
316
316
|
return newProps;
|
|
317
317
|
}, {});
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Filters out unsupported selectors (e.g., pseudo-classes, complex selectors) from a styles object.
|
|
322
|
+
* @param styles - The styles object to filter.
|
|
323
|
+
* @returns A new object containing only supported styles.
|
|
324
|
+
*/
|
|
325
|
+
export var filterUnsupportedSelectors = function filterUnsupportedSelectors(styles) {
|
|
326
|
+
var unsupportedSelectors = [':hover', ':focus', ':active', ':visited', ':link', ':checked', ':disabled', ':enabled', ':first-child', ':last-child', ':nth-child', ':nth-last-child', ':only-child', ':first-of-type', ':last-of-type', ':nth-of-type', ':nth-last-of-type', ':only-of-type', ':empty', ':not', ':root', ':target', ':before', ':after', '::before', '::after', '::placeholder', '::selection', '::backdrop', '::marker', '::first-line', '::first-letter', '::spelling-error', '::grammar-error', '[attr]',
|
|
327
|
+
// Attribute selectors
|
|
328
|
+
'[attr=value]',
|
|
329
|
+
// Attribute value selectors
|
|
330
|
+
'[attr^=value]',
|
|
331
|
+
// Attribute starts with
|
|
332
|
+
'[attr$=value]',
|
|
333
|
+
// Attribute ends with
|
|
334
|
+
'[attr*=value]',
|
|
335
|
+
// Attribute contains
|
|
336
|
+
'[attr|=value]',
|
|
337
|
+
// Attribute value with hyphen
|
|
338
|
+
'[attr~=value]',
|
|
339
|
+
// Attribute value in space-separated list
|
|
340
|
+
'>',
|
|
341
|
+
// Child combinator
|
|
342
|
+
'+',
|
|
343
|
+
// Adjacent sibling combinator
|
|
344
|
+
'~',
|
|
345
|
+
// General sibling combinator
|
|
346
|
+
' ' // Descendant combinator
|
|
347
|
+
];
|
|
348
|
+
return Object.keys(styles).reduce(function (filteredStyles, key) {
|
|
349
|
+
if (!unsupportedSelectors.some(function (selector) {
|
|
350
|
+
return key.includes(selector);
|
|
351
|
+
})) {
|
|
352
|
+
filteredStyles[key] = styles[key];
|
|
353
|
+
}
|
|
354
|
+
return filteredStyles;
|
|
355
|
+
}, {});
|
|
318
356
|
};
|
package/dist/types/select.d.ts
CHANGED
|
@@ -607,7 +607,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
|
|
|
607
607
|
getCommonProps(): {
|
|
608
608
|
clearValue: () => void;
|
|
609
609
|
cx: (...args: any) => string;
|
|
610
|
-
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) =>
|
|
610
|
+
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => Record<string, any>;
|
|
611
611
|
getClassNames: <Key_1 extends keyof StylesProps<Option, IsMulti, Group>>(key: Key_1, props: StylesProps<Option, IsMulti, Group>[Key_1]) => string | undefined;
|
|
612
612
|
getValue: () => Options<Option>;
|
|
613
613
|
hasValue: boolean;
|
|
@@ -620,7 +620,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
|
|
|
620
620
|
};
|
|
621
621
|
getOptionLabel: (data: Option) => string;
|
|
622
622
|
getOptionValue: (data: Option) => string;
|
|
623
|
-
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) =>
|
|
623
|
+
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => Record<string, any>;
|
|
624
624
|
getClassNames: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => string | undefined;
|
|
625
625
|
getElementId: (element: 'group' | 'input' | 'listbox' | 'option' | 'placeholder' | 'live-region' | 'multi-message' | 'selected-value') => string;
|
|
626
626
|
getComponents: () => {
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -32,3 +32,9 @@ export declare function valueTernary<Option, IsMulti extends boolean>(isMulti: I
|
|
|
32
32
|
export declare function singleValueAsValue<Option, IsMulti extends boolean>(singleValue: SingleValue<Option>): OnChangeValue<Option, IsMulti>;
|
|
33
33
|
export declare function multiValueAsValue<Option, IsMulti extends boolean>(multiValue: MultiValue<Option>): OnChangeValue<Option, IsMulti>;
|
|
34
34
|
export declare const removeProps: <Props extends object, K extends string[]>(propsObj: Props, ...properties: K) => Omit<Props, K[number]>;
|
|
35
|
+
/**
|
|
36
|
+
* Filters out unsupported selectors (e.g., pseudo-classes, complex selectors) from a styles object.
|
|
37
|
+
* @param styles - The styles object to filter.
|
|
38
|
+
* @returns A new object containing only supported styles.
|
|
39
|
+
*/
|
|
40
|
+
export declare const filterUnsupportedSelectors: (styles: Record<string, any>) => Record<string, any>;
|
|
@@ -607,7 +607,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
|
|
|
607
607
|
getCommonProps(): {
|
|
608
608
|
clearValue: () => void;
|
|
609
609
|
cx: (...args: any) => string;
|
|
610
|
-
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) =>
|
|
610
|
+
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => Record<string, any>;
|
|
611
611
|
getClassNames: <Key_1 extends keyof StylesProps<Option, IsMulti, Group>>(key: Key_1, props: StylesProps<Option, IsMulti, Group>[Key_1]) => string | undefined;
|
|
612
612
|
getValue: () => Options<Option>;
|
|
613
613
|
hasValue: boolean;
|
|
@@ -620,7 +620,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
|
|
|
620
620
|
};
|
|
621
621
|
getOptionLabel: (data: Option) => string;
|
|
622
622
|
getOptionValue: (data: Option) => string;
|
|
623
|
-
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) =>
|
|
623
|
+
getStyles: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => Record<string, any>;
|
|
624
624
|
getClassNames: <Key extends keyof StylesProps<Option, IsMulti, Group>>(key: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => string | undefined;
|
|
625
625
|
getElementId: (element: 'group' | 'input' | 'listbox' | 'option' | 'placeholder' | 'live-region' | 'multi-message' | 'selected-value') => string;
|
|
626
626
|
getComponents: () => {
|
|
@@ -32,3 +32,9 @@ export declare function valueTernary<Option, IsMulti extends boolean>(isMulti: I
|
|
|
32
32
|
export declare function singleValueAsValue<Option, IsMulti extends boolean>(singleValue: SingleValue<Option>): OnChangeValue<Option, IsMulti>;
|
|
33
33
|
export declare function multiValueAsValue<Option, IsMulti extends boolean>(multiValue: MultiValue<Option>): OnChangeValue<Option, IsMulti>;
|
|
34
34
|
export declare const removeProps: <Props extends object, K extends string[]>(propsObj: Props, ...properties: K) => Omit<Props, K[number]>;
|
|
35
|
+
/**
|
|
36
|
+
* Filters out unsupported selectors (e.g., pseudo-classes, complex selectors) from a styles object.
|
|
37
|
+
* @param styles - The styles object to filter.
|
|
38
|
+
* @returns A new object containing only supported styles.
|
|
39
|
+
*/
|
|
40
|
+
export declare const filterUnsupportedSelectors: (styles: Record<string, any>) => Record<string, any>;
|