@wordpress/components 26.0.1 → 27.0.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.
- package/.stylelintrc.js +2 -2
- package/CHANGELOG.md +23 -0
- package/CONTRIBUTING.md +72 -0
- package/build/autocomplete/index.js +3 -8
- package/build/autocomplete/index.js.map +1 -1
- package/build/color-picker/component.js +10 -1
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/styles.js +8 -9
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +4 -9
- package/build/combobox-control/index.js.map +1 -1
- package/build/custom-select-control/index.js +2 -15
- package/build/custom-select-control/index.js.map +1 -1
- package/build/custom-select-control-v2/custom-select-item.js +32 -0
- package/build/custom-select-control-v2/custom-select-item.js.map +1 -0
- package/build/custom-select-control-v2/custom-select.js +91 -0
- package/build/custom-select-control-v2/custom-select.js.map +1 -0
- package/build/custom-select-control-v2/default-component/index.js +41 -0
- package/build/custom-select-control-v2/default-component/index.js.map +1 -0
- package/build/custom-select-control-v2/index.js +13 -82
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/custom-select-control-v2/legacy-adapter.js +29 -0
- package/build/custom-select-control-v2/legacy-adapter.js.map +1 -0
- package/build/custom-select-control-v2/legacy-component/index.js +123 -0
- package/build/custom-select-control-v2/legacy-component/index.js.map +1 -0
- package/build/custom-select-control-v2/styles.js +73 -50
- package/build/custom-select-control-v2/styles.js.map +1 -1
- package/build/custom-select-control-v2/types.js.map +1 -1
- package/build/font-size-picker/font-size-picker-select.js +0 -1
- package/build/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build/form-token-field/index.js +3 -8
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +5 -12
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -1
- package/build/modal/index.js +2 -10
- package/build/modal/index.js.map +1 -1
- package/build/progress-bar/styles.js +5 -5
- package/build/progress-bar/styles.js.map +1 -1
- package/build/utils/with-ignore-ime-events.js +34 -0
- package/build/utils/with-ignore-ime-events.js.map +1 -0
- package/build-module/autocomplete/index.js +3 -8
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/color-picker/component.js +11 -2
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -9
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +4 -9
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/custom-select-control/index.js +2 -15
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/custom-select-control-v2/custom-select-item.js +26 -0
- package/build-module/custom-select-control-v2/custom-select-item.js.map +1 -0
- package/build-module/custom-select-control-v2/custom-select.js +82 -0
- package/build-module/custom-select-control-v2/custom-select.js.map +1 -0
- package/build-module/custom-select-control-v2/default-component/index.js +30 -0
- package/build-module/custom-select-control-v2/default-component/index.js.map +1 -0
- package/build-module/custom-select-control-v2/index.js +2 -74
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/custom-select-control-v2/legacy-adapter.js +21 -0
- package/build-module/custom-select-control-v2/legacy-adapter.js.map +1 -0
- package/build-module/custom-select-control-v2/legacy-component/index.js +111 -0
- package/build-module/custom-select-control-v2/legacy-component/index.js.map +1 -0
- package/build-module/custom-select-control-v2/styles.js +73 -42
- package/build-module/custom-select-control-v2/styles.js.map +1 -1
- package/build-module/custom-select-control-v2/types.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-select.js +0 -1
- package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build-module/form-token-field/index.js +3 -8
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +5 -12
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -1
- package/build-module/modal/index.js +3 -10
- package/build-module/modal/index.js.map +1 -1
- package/build-module/progress-bar/styles.js +5 -5
- package/build-module/progress-bar/styles.js.map +1 -1
- package/build-module/utils/with-ignore-ime-events.js +28 -0
- package/build-module/utils/with-ignore-ime-events.js.map +1 -0
- package/build-style/style-rtl.css +8 -1
- package/build-style/style.css +8 -1
- package/build-types/alignment-matrix-control/stories/index.story.d.ts +1 -1
- package/build-types/angle-picker-control/stories/index.story.d.ts +1 -1
- package/build-types/animate/stories/index.story.d.ts +7 -7
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +1 -1
- package/build-types/border-control/stories/index.story.d.ts +6 -6
- package/build-types/box-control/stories/index.story.d.ts +6 -6
- package/build-types/button/stories/e2e/index.story.d.ts +1 -1
- package/build-types/button/stories/index.story.d.ts +7 -7
- package/build-types/card/stories/index.story.d.ts +2 -2
- package/build-types/circular-option-picker/stories/index.story.d.ts +5 -5
- package/build-types/color-palette/stories/index.story.d.ts +3 -3
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/stories/index.story.d.ts +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts +2 -2
- package/build-types/confirm-dialog/stories/index.story.d.ts +2 -2
- package/build-types/custom-gradient-picker/stories/index.story.d.ts +1 -1
- package/build-types/custom-select-control/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select-item.d.ts +9 -0
- package/build-types/custom-select-control-v2/custom-select-item.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/custom-select.d.ts +6 -0
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/default-component/index.d.ts +5 -0
- package/build-types/custom-select-control-v2/default-component/index.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/index.d.ts +5 -6
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/legacy-adapter.d.ts +6 -0
- package/build-types/custom-select-control-v2/legacy-adapter.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts +5 -0
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/stories/default.story.d.ts +29 -0
- package/build-types/custom-select-control-v2/stories/default.story.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/stories/legacy.story.d.ts +12 -0
- package/build-types/custom-select-control-v2/stories/legacy.story.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/styles.d.ts +31 -6
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/types.d.ts +137 -14
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
- package/build-types/dimension-control/stories/index.story.d.ts +2 -2
- package/build-types/drop-zone/stories/index.story.d.ts +1 -1
- package/build-types/dropdown/stories/index.story.d.ts +3 -3
- package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts +1 -1
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts +3 -3
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts +5 -5
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +3 -3
- package/build-types/guide/stories/index.story.d.ts +1 -1
- package/build-types/icon/stories/index.story.d.ts +4 -4
- package/build-types/input-control/stories/index.story.d.ts +6 -6
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts +1 -1
- package/build-types/menu-group/stories/index.story.d.ts +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/navigation/stories/index.story.d.ts +6 -6
- package/build-types/notice/stories/index.story.d.ts +4 -4
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/palette-edit/stories/index.story.d.ts +2 -2
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/query-controls/stories/index.story.d.ts +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/responsive-wrapper/stories/index.story.d.ts +1 -1
- package/build-types/sandbox/stories/index.story.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts +2 -2
- package/build-types/select-control/stories/index.story.d.ts +2 -2
- package/build-types/shortcut/stories/index.story.d.ts +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts +4 -4
- package/build-types/tabs/stories/index.story.d.ts +9 -9
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts +3 -3
- package/build-types/theme/stories/index.story.d.ts +1 -1
- package/build-types/theme/stories/index.story.d.ts.map +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toolbar/stories/index.story.d.ts +3 -3
- package/build-types/tooltip/stories/index.story.d.ts +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts +1 -1
- package/build-types/tree-select/stories/index.story.d.ts +1 -1
- package/build-types/utils/with-ignore-ime-events.d.ts +15 -0
- package/build-types/utils/with-ignore-ime-events.d.ts.map +1 -0
- package/build-types/v-stack/stories/index.story.d.ts +1 -1
- package/package.json +19 -20
- package/src/alignment-matrix-control/test/index.tsx +3 -1
- package/src/autocomplete/index.tsx +3 -10
- package/src/circular-option-picker/test/index.tsx +4 -1
- package/src/color-picker/component.tsx +22 -11
- package/src/color-picker/styles.ts +1 -15
- package/src/combobox-control/index.tsx +33 -41
- package/src/composite/legacy/test/index.tsx +18 -2
- package/src/custom-select-control/README.md +0 -10
- package/src/custom-select-control/index.js +3 -22
- package/src/custom-select-control/stories/index.story.js +0 -1
- package/src/custom-select-control/test/index.js +17 -17
- package/src/custom-select-control-v2/README.md +97 -7
- package/src/custom-select-control-v2/custom-select-item.tsx +29 -0
- package/src/custom-select-control-v2/custom-select.tsx +122 -0
- package/src/custom-select-control-v2/default-component/index.tsx +24 -0
- package/src/custom-select-control-v2/index.tsx +2 -102
- package/src/custom-select-control-v2/legacy-adapter.tsx +25 -0
- package/src/custom-select-control-v2/legacy-component/index.tsx +133 -0
- package/src/custom-select-control-v2/stories/{index.story.tsx → default.story.tsx} +27 -33
- package/src/custom-select-control-v2/stories/legacy.story.tsx +88 -0
- package/src/custom-select-control-v2/styles.ts +82 -38
- package/src/custom-select-control-v2/test/index.tsx +808 -148
- package/src/custom-select-control-v2/types.ts +148 -20
- package/src/dropdown-menu-v2/stories/index.story.tsx +1 -0
- package/src/dropdown-menu-v2/test/index.tsx +4 -1
- package/src/font-size-picker/font-size-picker-select.tsx +0 -1
- package/src/form-token-field/index.tsx +3 -10
- package/src/form-token-field/suggestions-list.tsx +5 -17
- package/src/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js +1 -1
- package/src/modal/index.tsx +2 -12
- package/src/modal/style.scss +1 -0
- package/src/progress-bar/stories/index.story.tsx +1 -0
- package/src/progress-bar/styles.ts +2 -2
- package/src/tab-panel/test/index.tsx +8 -1
- package/src/tabs/stories/index.story.tsx +1 -0
- package/src/tabs/test/index.tsx +36 -6
- package/src/theme/stories/index.story.tsx +1 -0
- package/src/toggle-group-control/test/index.tsx +4 -0
- package/src/toolbar/toolbar-group/style.scss +1 -0
- package/src/tooltip/test/index.tsx +5 -0
- package/src/utils/with-ignore-ime-events.ts +32 -0
- package/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/custom-select-control/styles.js +0 -27
- package/build/custom-select-control/styles.js.map +0 -1
- package/build-module/custom-select-control/styles.js +0 -18
- package/build-module/custom-select-control/styles.js.map +0 -1
- package/build-types/custom-select-control/styles.d.ts +0 -11
- package/build-types/custom-select-control/styles.d.ts.map +0 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +0 -20
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +0 -1
- package/src/custom-select-control/styles.ts +0 -28
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { createContext, useMemo } from '@wordpress/element';
|
|
6
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
+
import { Icon, chevronDown } from '@wordpress/icons';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { VisuallyHidden } from '..';
|
|
13
|
+
import * as Styled from './styles';
|
|
14
|
+
import { contextConnectWithoutRef, useContextSystem } from '../context';
|
|
15
|
+
export const CustomSelectContext = createContext(undefined);
|
|
16
|
+
function defaultRenderSelectedValue(value) {
|
|
17
|
+
const isValueEmpty = Array.isArray(value) ? value.length === 0 : value === undefined || value === null;
|
|
18
|
+
if (isValueEmpty) {
|
|
19
|
+
return __('Select an item');
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.length === 1 ? value[0] :
|
|
23
|
+
// translators: %s: number of items selected (it will always be 2 or more items)
|
|
24
|
+
sprintf(__('%s items selected'), value.length);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
const UnconnectedCustomSelectButton = props => {
|
|
29
|
+
const {
|
|
30
|
+
renderSelectedValue,
|
|
31
|
+
size = 'default',
|
|
32
|
+
store,
|
|
33
|
+
...restProps
|
|
34
|
+
} = useContextSystem(props, 'CustomSelectControlButton');
|
|
35
|
+
const {
|
|
36
|
+
value: currentValue
|
|
37
|
+
} = store.useState();
|
|
38
|
+
const computedRenderSelectedValue = useMemo(() => renderSelectedValue !== null && renderSelectedValue !== void 0 ? renderSelectedValue : defaultRenderSelectedValue, [renderSelectedValue]);
|
|
39
|
+
return createElement(Styled.Select, {
|
|
40
|
+
...restProps,
|
|
41
|
+
size: size,
|
|
42
|
+
hasCustomRenderProp: !!renderSelectedValue,
|
|
43
|
+
store: store
|
|
44
|
+
// to match legacy behavior where using arrow keys
|
|
45
|
+
// move selection rather than open the popover
|
|
46
|
+
,
|
|
47
|
+
showOnKeyDown: false
|
|
48
|
+
}, createElement("div", null, computedRenderSelectedValue(currentValue)), createElement(Icon, {
|
|
49
|
+
icon: chevronDown,
|
|
50
|
+
size: 18
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
const CustomSelectButton = contextConnectWithoutRef(UnconnectedCustomSelectButton, 'CustomSelectControlButton');
|
|
54
|
+
function _CustomSelect(props) {
|
|
55
|
+
const {
|
|
56
|
+
children,
|
|
57
|
+
hideLabelFromVision = false,
|
|
58
|
+
label,
|
|
59
|
+
store,
|
|
60
|
+
...restProps
|
|
61
|
+
} = props;
|
|
62
|
+
return createElement(Fragment, null, hideLabelFromVision ?
|
|
63
|
+
// TODO: Replace with BaseControl
|
|
64
|
+
createElement(VisuallyHidden, {
|
|
65
|
+
as: "label"
|
|
66
|
+
}, label) : createElement(Styled.SelectLabel, {
|
|
67
|
+
store: store
|
|
68
|
+
}, label), createElement(CustomSelectButton, {
|
|
69
|
+
...restProps,
|
|
70
|
+
store: store
|
|
71
|
+
}), createElement(Styled.SelectPopover, {
|
|
72
|
+
gutter: 12,
|
|
73
|
+
store: store,
|
|
74
|
+
sameWidth: true
|
|
75
|
+
}, createElement(CustomSelectContext.Provider, {
|
|
76
|
+
value: {
|
|
77
|
+
store
|
|
78
|
+
}
|
|
79
|
+
}, children)));
|
|
80
|
+
}
|
|
81
|
+
export default _CustomSelect;
|
|
82
|
+
//# sourceMappingURL=custom-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useMemo","__","sprintf","Icon","chevronDown","VisuallyHidden","Styled","contextConnectWithoutRef","useContextSystem","CustomSelectContext","undefined","defaultRenderSelectedValue","value","isValueEmpty","Array","isArray","length","UnconnectedCustomSelectButton","props","renderSelectedValue","size","store","restProps","currentValue","useState","computedRenderSelectedValue","createElement","Select","hasCustomRenderProp","showOnKeyDown","icon","CustomSelectButton","_CustomSelect","children","hideLabelFromVision","label","Fragment","as","SelectLabel","SelectPopover","gutter","sameWidth","Provider"],"sources":["@wordpress/components/src/custom-select-control-v2/custom-select.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { VisuallyHidden } from '..';\nimport * as Styled from './styles';\nimport type {\n\tCustomSelectContext as CustomSelectContextType,\n\tCustomSelectStore,\n\tCustomSelectButtonProps,\n\t_CustomSelectProps,\n} from './types';\nimport {\n\tcontextConnectWithoutRef,\n\tuseContextSystem,\n\ttype WordPressComponentProps,\n} from '../context';\n\nexport const CustomSelectContext =\n\tcreateContext< CustomSelectContextType >( undefined );\n\nfunction defaultRenderSelectedValue(\n\tvalue: CustomSelectButtonProps[ 'value' ]\n) {\n\tconst isValueEmpty = Array.isArray( value )\n\t\t? value.length === 0\n\t\t: value === undefined || value === null;\n\n\tif ( isValueEmpty ) {\n\t\treturn __( 'Select an item' );\n\t}\n\n\tif ( Array.isArray( value ) ) {\n\t\treturn value.length === 1\n\t\t\t? value[ 0 ]\n\t\t\t: // translators: %s: number of items selected (it will always be 2 or more items)\n\t\t\t sprintf( __( '%s items selected' ), value.length );\n\t}\n\n\treturn value;\n}\n\nconst UnconnectedCustomSelectButton = (\n\tprops: Omit<\n\t\tWordPressComponentProps<\n\t\t\tCustomSelectButtonProps & CustomSelectStore,\n\t\t\t'button',\n\t\t\tfalse\n\t\t>,\n\t\t'onChange'\n\t>\n) => {\n\tconst {\n\t\trenderSelectedValue,\n\t\tsize = 'default',\n\t\tstore,\n\t\t...restProps\n\t} = useContextSystem( props, 'CustomSelectControlButton' );\n\n\tconst { value: currentValue } = store.useState();\n\n\tconst computedRenderSelectedValue = useMemo(\n\t\t() => renderSelectedValue ?? defaultRenderSelectedValue,\n\t\t[ renderSelectedValue ]\n\t);\n\n\treturn (\n\t\t<Styled.Select\n\t\t\t{ ...restProps }\n\t\t\tsize={ size }\n\t\t\thasCustomRenderProp={ !! renderSelectedValue }\n\t\t\tstore={ store }\n\t\t\t// to match legacy behavior where using arrow keys\n\t\t\t// move selection rather than open the popover\n\t\t\tshowOnKeyDown={ false }\n\t\t>\n\t\t\t<div>{ computedRenderSelectedValue( currentValue ) }</div>\n\t\t\t<Icon icon={ chevronDown } size={ 18 } />\n\t\t</Styled.Select>\n\t);\n};\n\nconst CustomSelectButton = contextConnectWithoutRef(\n\tUnconnectedCustomSelectButton,\n\t'CustomSelectControlButton'\n);\n\nfunction _CustomSelect( props: _CustomSelectProps & CustomSelectStore ) {\n\tconst {\n\t\tchildren,\n\t\thideLabelFromVision = false,\n\t\tlabel,\n\t\tstore,\n\t\t...restProps\n\t} = props;\n\n\treturn (\n\t\t<>\n\t\t\t{ hideLabelFromVision ? ( // TODO: Replace with BaseControl\n\t\t\t\t<VisuallyHidden as=\"label\">{ label }</VisuallyHidden>\n\t\t\t) : (\n\t\t\t\t<Styled.SelectLabel store={ store }>\n\t\t\t\t\t{ label }\n\t\t\t\t</Styled.SelectLabel>\n\t\t\t) }\n\t\t\t<CustomSelectButton { ...restProps } store={ store } />\n\t\t\t<Styled.SelectPopover gutter={ 12 } store={ store } sameWidth>\n\t\t\t\t<CustomSelectContext.Provider value={ { store } }>\n\t\t\t\t\t{ children }\n\t\t\t\t</CustomSelectContext.Provider>\n\t\t\t</Styled.SelectPopover>\n\t\t</>\n\t);\n}\n\nexport default _CustomSelect;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,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|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line no-restricted-imports
|
|
6
|
+
import * as Ariakit from '@ariakit/react';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import _CustomSelect from '../custom-select';
|
|
11
|
+
function CustomSelect(props) {
|
|
12
|
+
const {
|
|
13
|
+
defaultValue,
|
|
14
|
+
onChange,
|
|
15
|
+
value,
|
|
16
|
+
...restProps
|
|
17
|
+
} = props;
|
|
18
|
+
// Forward props + store from v2 implementation
|
|
19
|
+
const store = Ariakit.useSelectStore({
|
|
20
|
+
setValue: nextValue => onChange?.(nextValue),
|
|
21
|
+
defaultValue,
|
|
22
|
+
value
|
|
23
|
+
});
|
|
24
|
+
return createElement(_CustomSelect, {
|
|
25
|
+
...restProps,
|
|
26
|
+
store: store
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export default CustomSelect;
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Ariakit","_CustomSelect","CustomSelect","props","defaultValue","onChange","value","restProps","store","useSelectStore","setValue","nextValue","createElement"],"sources":["@wordpress/components/src/custom-select-control-v2/default-component/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n/**\n * Internal dependencies\n */\nimport _CustomSelect from '../custom-select';\nimport type { CustomSelectProps } from '../types';\n\nfunction CustomSelect( props: CustomSelectProps ) {\n\tconst { defaultValue, onChange, value, ...restProps } = props;\n\t// Forward props + store from v2 implementation\n\tconst store = Ariakit.useSelectStore( {\n\t\tsetValue: ( nextValue ) => onChange?.( nextValue ),\n\t\tdefaultValue,\n\t\tvalue,\n\t} );\n\n\treturn <_CustomSelect { ...restProps } store={ store } />;\n}\n\nexport default CustomSelect;\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAG5C,SAASC,YAAYA,CAAEC,KAAwB,EAAG;EACjD,MAAM;IAAEC,YAAY;IAAEC,QAAQ;IAAEC,KAAK;IAAE,GAAGC;EAAU,CAAC,GAAGJ,KAAK;EAC7D;EACA,MAAMK,KAAK,GAAGR,OAAO,CAACS,cAAc,CAAE;IACrCC,QAAQ,EAAIC,SAAS,IAAMN,QAAQ,GAAIM,SAAU,CAAC;IAClDP,YAAY;IACZE;EACD,CAAE,CAAC;EAEH,OAAOM,aAAA,CAACX,aAAa;IAAA,GAAMM,SAAS;IAAGC,KAAK,EAAGA;EAAO,CAAE,CAAC;AAC1D;AAEA,eAAeN,YAAY"}
|
|
@@ -1,78 +1,6 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
// eslint-disable-next-line no-restricted-imports
|
|
6
|
-
import * as Ariakit from '@ariakit/react';
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { createContext, useContext } from '@wordpress/element';
|
|
11
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
12
|
-
|
|
13
1
|
/**
|
|
14
2
|
* Internal dependencies
|
|
15
3
|
*/
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
function defaultRenderSelectedValue(value) {
|
|
19
|
-
const isValueEmpty = Array.isArray(value) ? value.length === 0 : value === undefined || value === null;
|
|
20
|
-
if (isValueEmpty) {
|
|
21
|
-
return __('Select an item');
|
|
22
|
-
}
|
|
23
|
-
if (Array.isArray(value)) {
|
|
24
|
-
return value.length === 1 ? value[0] :
|
|
25
|
-
// translators: %s: number of items selected (it will always be 2 or more items)
|
|
26
|
-
sprintf(__('%s items selected'), value.length);
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
export function CustomSelect({
|
|
31
|
-
children,
|
|
32
|
-
defaultValue,
|
|
33
|
-
label,
|
|
34
|
-
onChange,
|
|
35
|
-
size = 'default',
|
|
36
|
-
value,
|
|
37
|
-
renderSelectedValue,
|
|
38
|
-
...props
|
|
39
|
-
}) {
|
|
40
|
-
const store = Ariakit.useSelectStore({
|
|
41
|
-
setValue: nextValue => onChange?.(nextValue),
|
|
42
|
-
defaultValue,
|
|
43
|
-
value,
|
|
44
|
-
// fix for Safari bug: https://github.com/WordPress/gutenberg/issues/55023#issuecomment-1834035917
|
|
45
|
-
virtualFocus: false
|
|
46
|
-
});
|
|
47
|
-
const {
|
|
48
|
-
value: currentValue
|
|
49
|
-
} = store.useState();
|
|
50
|
-
const computedRenderSelectedValue = renderSelectedValue !== null && renderSelectedValue !== void 0 ? renderSelectedValue : defaultRenderSelectedValue;
|
|
51
|
-
return createElement(Fragment, null, createElement(Styled.CustomSelectLabel, {
|
|
52
|
-
store: store
|
|
53
|
-
}, label), createElement(Styled.CustomSelectButton, {
|
|
54
|
-
...props,
|
|
55
|
-
size: size,
|
|
56
|
-
hasCustomRenderProp: !!renderSelectedValue,
|
|
57
|
-
store: store
|
|
58
|
-
}, computedRenderSelectedValue(currentValue), createElement(Ariakit.SelectArrow, null)), createElement(Styled.CustomSelectPopover, {
|
|
59
|
-
gutter: 12,
|
|
60
|
-
store: store,
|
|
61
|
-
sameWidth: true
|
|
62
|
-
}, createElement(CustomSelectContext.Provider, {
|
|
63
|
-
value: {
|
|
64
|
-
store
|
|
65
|
-
}
|
|
66
|
-
}, children)));
|
|
67
|
-
}
|
|
68
|
-
export function CustomSelectItem({
|
|
69
|
-
children,
|
|
70
|
-
...props
|
|
71
|
-
}) {
|
|
72
|
-
const customSelectContext = useContext(CustomSelectContext);
|
|
73
|
-
return createElement(Styled.CustomSelectItem, {
|
|
74
|
-
store: customSelectContext?.store,
|
|
75
|
-
...props
|
|
76
|
-
}, children !== null && children !== void 0 ? children : props.value, createElement(Ariakit.SelectItemCheck, null));
|
|
77
|
-
}
|
|
4
|
+
export { default as CustomSelect } from './legacy-adapter';
|
|
5
|
+
export { default as CustomSelectItem } from './custom-select-item';
|
|
78
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["default","CustomSelect","CustomSelectItem"],"sources":["@wordpress/components/src/custom-select-control-v2/index.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nexport { default as CustomSelect } from './legacy-adapter';\nexport { default as CustomSelectItem } from './custom-select-item';\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,IAAIC,YAAY,QAAQ,kBAAkB;AAC1D,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,sBAAsB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Internal dependencies
|
|
4
|
+
*/
|
|
5
|
+
import _LegacyCustomSelect from './legacy-component';
|
|
6
|
+
import _NewCustomSelect from './default-component';
|
|
7
|
+
function isLegacy(props) {
|
|
8
|
+
return typeof props.options !== 'undefined';
|
|
9
|
+
}
|
|
10
|
+
function CustomSelect(props) {
|
|
11
|
+
if (isLegacy(props)) {
|
|
12
|
+
return createElement(_LegacyCustomSelect, {
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return createElement(_NewCustomSelect, {
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export default CustomSelect;
|
|
21
|
+
//# sourceMappingURL=legacy-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_LegacyCustomSelect","_NewCustomSelect","isLegacy","props","options","CustomSelect","createElement"],"sources":["@wordpress/components/src/custom-select-control-v2/legacy-adapter.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport _LegacyCustomSelect from './legacy-component';\nimport _NewCustomSelect from './default-component';\nimport type { CustomSelectProps, LegacyCustomSelectProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nfunction isLegacy( props: any ): props is LegacyCustomSelectProps {\n\treturn typeof props.options !== 'undefined';\n}\n\nfunction CustomSelect(\n\tprops:\n\t\t| LegacyCustomSelectProps\n\t\t| WordPressComponentProps< CustomSelectProps, 'button', false >\n) {\n\tif ( isLegacy( props ) ) {\n\t\treturn <_LegacyCustomSelect { ...props } />;\n\t}\n\n\treturn <_NewCustomSelect { ...props } />;\n}\n\nexport default CustomSelect;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,mBAAmB,MAAM,oBAAoB;AACpD,OAAOC,gBAAgB,MAAM,qBAAqB;AAIlD,SAASC,QAAQA,CAAEC,KAAU,EAAqC;EACjE,OAAO,OAAOA,KAAK,CAACC,OAAO,KAAK,WAAW;AAC5C;AAEA,SAASC,YAAYA,CACpBF,KAEgE,EAC/D;EACD,IAAKD,QAAQ,CAAEC,KAAM,CAAC,EAAG;IACxB,OAAOG,aAAA,CAACN,mBAAmB;MAAA,GAAMG;IAAK,CAAI,CAAC;EAC5C;EAEA,OAAOG,aAAA,CAACL,gBAAgB;IAAA,GAAME;EAAK,CAAI,CAAC;AACzC;AAEA,eAAeE,YAAY"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line no-restricted-imports
|
|
6
|
+
import * as Ariakit from '@ariakit/react';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useMemo } from '@wordpress/element';
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import _CustomSelect from '../custom-select';
|
|
15
|
+
import { CustomSelectItem } from '..';
|
|
16
|
+
import * as Styled from '../styles';
|
|
17
|
+
import { ContextSystemProvider } from '../../context';
|
|
18
|
+
function CustomSelect(props) {
|
|
19
|
+
const {
|
|
20
|
+
__experimentalShowSelectedHint,
|
|
21
|
+
__next40pxDefaultSize = false,
|
|
22
|
+
options,
|
|
23
|
+
onChange,
|
|
24
|
+
size = 'default',
|
|
25
|
+
value,
|
|
26
|
+
...restProps
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
// Forward props + store from v2 implementation
|
|
30
|
+
const store = Ariakit.useSelectStore({
|
|
31
|
+
async setValue(nextValue) {
|
|
32
|
+
if (!onChange) return;
|
|
33
|
+
|
|
34
|
+
// Executes the logic in a microtask after the popup is closed.
|
|
35
|
+
// This is simply to ensure the isOpen state matches that in Downshift.
|
|
36
|
+
await Promise.resolve();
|
|
37
|
+
const state = store.getState();
|
|
38
|
+
const changeObject = {
|
|
39
|
+
highlightedIndex: state.renderedItems.findIndex(item => item.value === nextValue),
|
|
40
|
+
inputValue: '',
|
|
41
|
+
isOpen: state.open,
|
|
42
|
+
selectedItem: {
|
|
43
|
+
name: nextValue,
|
|
44
|
+
key: nextValue
|
|
45
|
+
},
|
|
46
|
+
type: ''
|
|
47
|
+
};
|
|
48
|
+
onChange(changeObject);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const children = options.map(({
|
|
52
|
+
name,
|
|
53
|
+
key,
|
|
54
|
+
__experimentalHint,
|
|
55
|
+
...rest
|
|
56
|
+
}) => {
|
|
57
|
+
const withHint = createElement(Styled.WithHintWrapper, null, createElement("span", null, name), createElement(Styled.ExperimentalHintItem, {
|
|
58
|
+
className: "components-custom-select-control__item-hint"
|
|
59
|
+
}, __experimentalHint));
|
|
60
|
+
return createElement(CustomSelectItem, {
|
|
61
|
+
key: key,
|
|
62
|
+
value: name,
|
|
63
|
+
children: __experimentalShowSelectedHint ? withHint : name,
|
|
64
|
+
...rest
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
const renderSelectedValueHint = () => {
|
|
68
|
+
const {
|
|
69
|
+
value: currentValue
|
|
70
|
+
} = store.getState();
|
|
71
|
+
const currentHint = options?.find(({
|
|
72
|
+
name
|
|
73
|
+
}) => currentValue === name);
|
|
74
|
+
return createElement(Fragment, null, currentValue, createElement(Styled.SelectedExperimentalHintItem, {
|
|
75
|
+
className: "components-custom-select-control__hint"
|
|
76
|
+
}, currentHint?.__experimentalHint));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// translate legacy button sizing
|
|
80
|
+
const contextSystemValue = useMemo(() => {
|
|
81
|
+
let selectedSize;
|
|
82
|
+
if (__next40pxDefaultSize && size === 'default' || size === '__unstable-large') {
|
|
83
|
+
selectedSize = 'default';
|
|
84
|
+
} else if (!__next40pxDefaultSize && size === 'default') {
|
|
85
|
+
selectedSize = 'compact';
|
|
86
|
+
} else {
|
|
87
|
+
selectedSize = size;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
CustomSelectControlButton: {
|
|
91
|
+
_overrides: {
|
|
92
|
+
size: selectedSize
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}, [__next40pxDefaultSize, size]);
|
|
97
|
+
const translatedProps = {
|
|
98
|
+
'aria-describedby': props.describedBy,
|
|
99
|
+
children,
|
|
100
|
+
renderSelectedValue: __experimentalShowSelectedHint ? renderSelectedValueHint : undefined,
|
|
101
|
+
...restProps
|
|
102
|
+
};
|
|
103
|
+
return createElement(ContextSystemProvider, {
|
|
104
|
+
value: contextSystemValue
|
|
105
|
+
}, createElement(_CustomSelect, {
|
|
106
|
+
...translatedProps,
|
|
107
|
+
store: store
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
export default CustomSelect;
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Ariakit","useMemo","_CustomSelect","CustomSelectItem","Styled","ContextSystemProvider","CustomSelect","props","__experimentalShowSelectedHint","__next40pxDefaultSize","options","onChange","size","value","restProps","store","useSelectStore","setValue","nextValue","Promise","resolve","state","getState","changeObject","highlightedIndex","renderedItems","findIndex","item","inputValue","isOpen","open","selectedItem","name","key","type","children","map","__experimentalHint","rest","withHint","createElement","WithHintWrapper","ExperimentalHintItem","className","renderSelectedValueHint","currentValue","currentHint","find","Fragment","SelectedExperimentalHintItem","contextSystemValue","selectedSize","CustomSelectControlButton","_overrides","translatedProps","describedBy","renderSelectedValue","undefined"],"sources":["@wordpress/components/src/custom-select-control-v2/legacy-component/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport _CustomSelect from '../custom-select';\nimport type { LegacyCustomSelectProps } from '../types';\nimport { CustomSelectItem } from '..';\nimport * as Styled from '../styles';\nimport { ContextSystemProvider } from '../../context';\n\nfunction CustomSelect( props: LegacyCustomSelectProps ) {\n\tconst {\n\t\t__experimentalShowSelectedHint,\n\t\t__next40pxDefaultSize = false,\n\t\toptions,\n\t\tonChange,\n\t\tsize = 'default',\n\t\tvalue,\n\t\t...restProps\n\t} = props;\n\n\t// Forward props + store from v2 implementation\n\tconst store = Ariakit.useSelectStore( {\n\t\tasync setValue( nextValue ) {\n\t\t\tif ( ! onChange ) return;\n\n\t\t\t// Executes the logic in a microtask after the popup is closed.\n\t\t\t// This is simply to ensure the isOpen state matches that in Downshift.\n\t\t\tawait Promise.resolve();\n\t\t\tconst state = store.getState();\n\n\t\t\tconst changeObject = {\n\t\t\t\thighlightedIndex: state.renderedItems.findIndex(\n\t\t\t\t\t( item ) => item.value === nextValue\n\t\t\t\t),\n\t\t\t\tinputValue: '',\n\t\t\t\tisOpen: state.open,\n\t\t\t\tselectedItem: {\n\t\t\t\t\tname: nextValue as string,\n\t\t\t\t\tkey: nextValue as string,\n\t\t\t\t},\n\t\t\t\ttype: '',\n\t\t\t};\n\t\t\tonChange( changeObject );\n\t\t},\n\t} );\n\n\tconst children = options.map(\n\t\t( { name, key, __experimentalHint, ...rest } ) => {\n\t\t\tconst withHint = (\n\t\t\t\t<Styled.WithHintWrapper>\n\t\t\t\t\t<span>{ name }</span>\n\t\t\t\t\t<Styled.ExperimentalHintItem className=\"components-custom-select-control__item-hint\">\n\t\t\t\t\t\t{ __experimentalHint }\n\t\t\t\t\t</Styled.ExperimentalHintItem>\n\t\t\t\t</Styled.WithHintWrapper>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<CustomSelectItem\n\t\t\t\t\tkey={ key }\n\t\t\t\t\tvalue={ name }\n\t\t\t\t\tchildren={\n\t\t\t\t\t\t__experimentalShowSelectedHint ? withHint : name\n\t\t\t\t\t}\n\t\t\t\t\t{ ...rest }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t);\n\n\tconst renderSelectedValueHint = () => {\n\t\tconst { value: currentValue } = store.getState();\n\n\t\tconst currentHint = options?.find(\n\t\t\t( { name } ) => currentValue === name\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ currentValue }\n\t\t\t\t<Styled.SelectedExperimentalHintItem className=\"components-custom-select-control__hint\">\n\t\t\t\t\t{ currentHint?.__experimentalHint }\n\t\t\t\t</Styled.SelectedExperimentalHintItem>\n\t\t\t</>\n\t\t);\n\t};\n\n\t// translate legacy button sizing\n\tconst contextSystemValue = useMemo( () => {\n\t\tlet selectedSize;\n\n\t\tif (\n\t\t\t( __next40pxDefaultSize && size === 'default' ) ||\n\t\t\tsize === '__unstable-large'\n\t\t) {\n\t\t\tselectedSize = 'default';\n\t\t} else if ( ! __next40pxDefaultSize && size === 'default' ) {\n\t\t\tselectedSize = 'compact';\n\t\t} else {\n\t\t\tselectedSize = size;\n\t\t}\n\n\t\treturn {\n\t\t\tCustomSelectControlButton: { _overrides: { size: selectedSize } },\n\t\t};\n\t}, [ __next40pxDefaultSize, size ] );\n\n\tconst translatedProps = {\n\t\t'aria-describedby': props.describedBy,\n\t\tchildren,\n\t\trenderSelectedValue: __experimentalShowSelectedHint\n\t\t\t? renderSelectedValueHint\n\t\t\t: undefined,\n\t\t...restProps,\n\t};\n\n\treturn (\n\t\t<ContextSystemProvider value={ contextSystemValue }>\n\t\t\t<_CustomSelect { ...translatedProps } store={ store } />\n\t\t</ContextSystemProvider>\n\t);\n}\n\nexport default CustomSelect;\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC;AACA;AACA;AACA,SAASC,OAAO,QAAQ,oBAAoB;AAC5C;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAE5C,SAASC,gBAAgB,QAAQ,IAAI;AACrC,OAAO,KAAKC,MAAM,MAAM,WAAW;AACnC,SAASC,qBAAqB,QAAQ,eAAe;AAErD,SAASC,YAAYA,CAAEC,KAA8B,EAAG;EACvD,MAAM;IACLC,8BAA8B;IAC9BC,qBAAqB,GAAG,KAAK;IAC7BC,OAAO;IACPC,QAAQ;IACRC,IAAI,GAAG,SAAS;IAChBC,KAAK;IACL,GAAGC;EACJ,CAAC,GAAGP,KAAK;;EAET;EACA,MAAMQ,KAAK,GAAGf,OAAO,CAACgB,cAAc,CAAE;IACrC,MAAMC,QAAQA,CAAEC,SAAS,EAAG;MAC3B,IAAK,CAAEP,QAAQ,EAAG;;MAElB;MACA;MACA,MAAMQ,OAAO,CAACC,OAAO,CAAC,CAAC;MACvB,MAAMC,KAAK,GAAGN,KAAK,CAACO,QAAQ,CAAC,CAAC;MAE9B,MAAMC,YAAY,GAAG;QACpBC,gBAAgB,EAAEH,KAAK,CAACI,aAAa,CAACC,SAAS,CAC5CC,IAAI,IAAMA,IAAI,CAACd,KAAK,KAAKK,SAC5B,CAAC;QACDU,UAAU,EAAE,EAAE;QACdC,MAAM,EAAER,KAAK,CAACS,IAAI;QAClBC,YAAY,EAAE;UACbC,IAAI,EAAEd,SAAmB;UACzBe,GAAG,EAAEf;QACN,CAAC;QACDgB,IAAI,EAAE;MACP,CAAC;MACDvB,QAAQ,CAAEY,YAA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