@wordpress/components 23.7.0 → 23.8.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/CHANGELOG.md +17 -6
- package/build/custom-gradient-picker/serializer.js +0 -4
- package/build/custom-gradient-picker/serializer.js.map +1 -1
- package/build/drop-zone/index.js +8 -8
- package/build/drop-zone/index.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +0 -4
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +100 -55
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +82 -0
- package/build/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +85 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +44 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +53 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js.map +1 -0
- package/build/navigator/navigator-provider/component.js +4 -2
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +4 -3
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/private-apis.js.map +1 -1
- package/build/query-controls/author-select.js +2 -1
- package/build/query-controls/author-select.js.map +1 -1
- package/build/query-controls/category-select.js +3 -1
- package/build/query-controls/category-select.js.map +1 -1
- package/build/query-controls/index.js +7 -1
- package/build/query-controls/index.js.map +1 -1
- package/build/sandbox/index.native.js +51 -28
- package/build/sandbox/index.native.js.map +1 -1
- package/build-module/custom-gradient-picker/serializer.js +0 -4
- package/build-module/custom-gradient-picker/serializer.js.map +1 -1
- package/build-module/drop-zone/index.js +8 -8
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +0 -4
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +97 -54
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +73 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +76 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +33 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +40 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js.map +1 -0
- package/build-module/navigator/navigator-provider/component.js +4 -2
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +4 -3
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/query-controls/author-select.js +2 -1
- package/build-module/query-controls/author-select.js.map +1 -1
- package/build-module/query-controls/category-select.js +3 -1
- package/build-module/query-controls/category-select.js.map +1 -1
- package/build-module/query-controls/index.js +7 -2
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +52 -30
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-style/style-rtl.css +1 -1
- package/build-style/style.css +1 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +2 -2
- package/build-types/border-control/border-control/hook.d.ts +2 -2
- package/build-types/border-control/border-control-dropdown/hook.d.ts +2 -2
- package/build-types/border-control/border-control-style-picker/hook.d.ts +2 -2
- package/build-types/box-control/styles/box-control-styles.d.ts +5 -5
- package/build-types/button/deprecated.d.ts +2 -2
- package/build-types/card/card/hook.d.ts +2 -2
- package/build-types/card/card-body/hook.d.ts +2 -2
- package/build-types/card/card-divider/hook.d.ts +2 -2
- package/build-types/card/card-footer/hook.d.ts +2 -2
- package/build-types/card/card-header/hook.d.ts +2 -2
- package/build-types/card/card-media/hook.d.ts +2 -2
- package/build-types/color-palette/styles.d.ts +1 -1
- package/build-types/color-picker/styles.d.ts +5 -5
- package/build-types/combobox-control/styles.d.ts +1 -1
- package/build-types/custom-gradient-picker/serializer.d.ts +1 -5
- package/build-types/custom-gradient-picker/serializer.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/types.d.ts +0 -2
- package/build-types/custom-gradient-picker/types.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +2 -2
- package/build-types/date-time/date-time/styles.d.ts +1 -1
- package/build-types/date-time/time/styles.d.ts +8 -8
- package/build-types/drop-zone/index.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +2 -2
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/flex/flex/hook.d.ts +2 -2
- package/build-types/flex/flex-block/hook.d.ts +2 -2
- package/build-types/flex/flex-item/hook.d.ts +2 -2
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -2
- package/build-types/form-token-field/styles.d.ts +1 -1
- package/build-types/grid/hook.d.ts +2 -2
- package/build-types/h-stack/hook.d.ts +2 -2
- package/build-types/heading/hook.d.ts +2 -2
- package/build-types/index.d.ts +128 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/input-control/styles/input-control-styles.d.ts +2 -2
- package/build-types/item-group/item/hook.d.ts +2 -2
- package/build-types/item-group/item-group/hook.d.ts +2 -2
- package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
- package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
- package/build-types/navigator/navigator-button/hook.d.ts +2 -2
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/stories/index.d.ts +1 -0
- package/build-types/navigator/stories/index.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +2 -2
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +2 -2
- package/build-types/number-control/stories/index.d.ts +2 -2
- package/build-types/palette-edit/styles.d.ts +3 -3
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/stories/e2e/index.d.ts +1 -1
- package/build-types/private-apis.d.ts +2 -3
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/query-controls/author-select.d.ts.map +1 -1
- package/build-types/query-controls/category-select.d.ts.map +1 -1
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +2 -2
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/stories/index.d.ts +2 -2
- package/build-types/scrollable/hook.d.ts +2 -2
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.d.ts +2 -2
- package/build-types/spacer/hook.d.ts +2 -2
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/surface/hook.d.ts +2 -2
- package/build-types/text/hook.d.ts +2 -2
- package/build-types/text-control/index.d.ts +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +2 -2
- package/build-types/tools-panel/tools-panel/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -2
- package/build-types/truncate/hook.d.ts +2 -2
- package/build-types/ui/control-group/hook.d.ts +2 -2
- package/build-types/ui/control-label/hook.d.ts +2 -2
- package/build-types/ui/form-group/form-group.d.ts +2 -2
- package/build-types/ui/form-group/use-form-group.d.ts +2 -2
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -2
- package/build-types/v-stack/hook.d.ts +2 -2
- package/package.json +20 -19
- package/src/custom-gradient-picker/serializer.ts +2 -6
- package/src/custom-gradient-picker/types.ts +0 -18
- package/src/drop-zone/index.tsx +12 -8
- package/src/drop-zone/style.scss +1 -1
- package/src/mobile/keyboard-aware-flat-list/index.android.js +0 -4
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +118 -67
- package/src/mobile/keyboard-aware-flat-list/test/use-keyboard-offset.native.js +203 -0
- package/src/mobile/keyboard-aware-flat-list/test/use-scroll-to-text-input.native.js +140 -0
- package/src/mobile/keyboard-aware-flat-list/test/use-text-input-caret-position.native.js +82 -0
- package/src/mobile/keyboard-aware-flat-list/test/use-text-input-offset.native.js +147 -0
- package/src/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +87 -0
- package/src/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +105 -0
- package/src/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +36 -0
- package/src/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +54 -0
- package/src/navigator/navigator-provider/component.tsx +2 -0
- package/src/navigator/navigator-screen/component.tsx +5 -2
- package/src/navigator/stories/index.tsx +68 -0
- package/src/navigator/test/index.tsx +52 -0
- package/src/navigator/types.ts +2 -1
- package/src/query-controls/author-select.tsx +1 -0
- package/src/query-controls/category-select.tsx +1 -0
- package/src/query-controls/index.tsx +4 -2
- package/src/sandbox/index.native.js +70 -36
- package/tsconfig.json +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- /package/src/{index.js → index.ts} +0 -0
- /package/src/{private-apis.js → private-apis.ts} +0 -0
|
@@ -11,6 +11,7 @@ import CategorySelect from './category-select';
|
|
|
11
11
|
import FormTokenField from '../form-token-field';
|
|
12
12
|
import RangeControl from '../range-control';
|
|
13
13
|
import SelectControl from '../select-control';
|
|
14
|
+
import { VStack } from '../v-stack';
|
|
14
15
|
import type {
|
|
15
16
|
QueryControlsProps,
|
|
16
17
|
QueryControlsWithMultipleCategorySelectionProps,
|
|
@@ -75,7 +76,7 @@ export function QueryControls( {
|
|
|
75
76
|
...props
|
|
76
77
|
}: QueryControlsProps ) {
|
|
77
78
|
return (
|
|
78
|
-
|
|
79
|
+
<VStack spacing="4" className="components-query-controls">
|
|
79
80
|
{ [
|
|
80
81
|
onOrderChange && onOrderByChange && (
|
|
81
82
|
<SelectControl
|
|
@@ -142,6 +143,7 @@ export function QueryControls( {
|
|
|
142
143
|
props.categorySuggestions &&
|
|
143
144
|
props.onCategoryChange && (
|
|
144
145
|
<FormTokenField
|
|
146
|
+
__nextHasNoMarginBottom
|
|
145
147
|
key="query-controls-categories-select"
|
|
146
148
|
label={ __( 'Categories' ) }
|
|
147
149
|
value={
|
|
@@ -185,7 +187,7 @@ export function QueryControls( {
|
|
|
185
187
|
/>
|
|
186
188
|
),
|
|
187
189
|
] }
|
|
188
|
-
|
|
190
|
+
</VStack>
|
|
189
191
|
);
|
|
190
192
|
}
|
|
191
193
|
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
useRef,
|
|
15
15
|
useState,
|
|
16
16
|
useEffect,
|
|
17
|
+
forwardRef,
|
|
18
|
+
useCallback,
|
|
17
19
|
} from '@wordpress/element';
|
|
18
20
|
import { usePreferredColorScheme } from '@wordpress/compose';
|
|
19
21
|
|
|
@@ -98,7 +100,6 @@ const observeAndResizeJS = `
|
|
|
98
100
|
// get an DOM mutations for that, so do the resize when the window is resized, too.
|
|
99
101
|
window.addEventListener( 'resize', sendResize, true );
|
|
100
102
|
window.addEventListener( 'orientationchange', sendResize, true );
|
|
101
|
-
widow.addEventListener( 'click', sendResize, true );
|
|
102
103
|
})();
|
|
103
104
|
`;
|
|
104
105
|
|
|
@@ -171,20 +172,23 @@ const style = `
|
|
|
171
172
|
|
|
172
173
|
const EMPTY_ARRAY = [];
|
|
173
174
|
|
|
174
|
-
function Sandbox(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
175
|
+
const Sandbox = forwardRef( function Sandbox(
|
|
176
|
+
{
|
|
177
|
+
containerStyle,
|
|
178
|
+
customJS,
|
|
179
|
+
html = '',
|
|
180
|
+
lang = 'en',
|
|
181
|
+
providerUrl = '',
|
|
182
|
+
scripts = EMPTY_ARRAY,
|
|
183
|
+
styles = EMPTY_ARRAY,
|
|
184
|
+
title = '',
|
|
185
|
+
type,
|
|
186
|
+
url,
|
|
187
|
+
onWindowEvents = {},
|
|
188
|
+
},
|
|
189
|
+
ref
|
|
190
|
+
) {
|
|
186
191
|
const colorScheme = usePreferredColorScheme();
|
|
187
|
-
const ref = useRef();
|
|
188
192
|
const [ height, setHeight ] = useState( 0 );
|
|
189
193
|
const [ contentHtml, setContentHtml ] = useState( getHtmlDoc() );
|
|
190
194
|
|
|
@@ -239,6 +243,21 @@ function Sandbox( {
|
|
|
239
243
|
return '<!DOCTYPE html>' + renderToString( htmlDoc );
|
|
240
244
|
}
|
|
241
245
|
|
|
246
|
+
const getInjectedJavaScript = useCallback( () => {
|
|
247
|
+
// Allow parent to override the resize observers with prop.customJS (legacy support)
|
|
248
|
+
let injectedJS = customJS || observeAndResizeJS;
|
|
249
|
+
|
|
250
|
+
// Add any event listeners that were passed in.
|
|
251
|
+
Object.keys( onWindowEvents ).forEach( ( eventType ) => {
|
|
252
|
+
injectedJS += `
|
|
253
|
+
window.addEventListener( '${ eventType }', function( event ) {
|
|
254
|
+
window.ReactNativeWebView.postMessage( JSON.stringify( { type: '${ eventType }', ...event.data } ) );
|
|
255
|
+
});`;
|
|
256
|
+
} );
|
|
257
|
+
|
|
258
|
+
return injectedJS;
|
|
259
|
+
}, [ customJS, onWindowEvents ] );
|
|
260
|
+
|
|
242
261
|
function updateContentHtml( forceRerender = false ) {
|
|
243
262
|
const newContentHtml = getHtmlDoc();
|
|
244
263
|
|
|
@@ -253,25 +272,6 @@ function Sandbox( {
|
|
|
253
272
|
}
|
|
254
273
|
}
|
|
255
274
|
|
|
256
|
-
function checkMessageForResize( event ) {
|
|
257
|
-
// Attempt to parse the message data as JSON if passed as string.
|
|
258
|
-
let data = event.nativeEvent.data || {};
|
|
259
|
-
|
|
260
|
-
if ( 'string' === typeof data ) {
|
|
261
|
-
try {
|
|
262
|
-
data = JSON.parse( data );
|
|
263
|
-
} catch ( e ) {}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Update the state only if the message is formatted as we expect,
|
|
267
|
-
// i.e. as an object with a 'resize' action.
|
|
268
|
-
if ( 'resize' !== data.action ) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
setHeight( data.height );
|
|
273
|
-
}
|
|
274
|
-
|
|
275
275
|
function getSizeStyle() {
|
|
276
276
|
const contentHeight = Math.ceil( height );
|
|
277
277
|
|
|
@@ -282,6 +282,39 @@ function Sandbox( {
|
|
|
282
282
|
setIsLandscape( dimensions.window.width >= dimensions.window.height );
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
const onMessage = useCallback(
|
|
286
|
+
( message ) => {
|
|
287
|
+
let data = message?.nativeEvent?.data;
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
data = JSON.parse( data );
|
|
291
|
+
} catch ( e ) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// check for resize event
|
|
296
|
+
if ( 'resize' === data?.action ) {
|
|
297
|
+
setHeight( data.height );
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Forward the event to parent event listeners
|
|
301
|
+
Object.keys( onWindowEvents ).forEach( ( eventType ) => {
|
|
302
|
+
if ( data?.type === eventType ) {
|
|
303
|
+
try {
|
|
304
|
+
onWindowEvents[ eventType ]( data );
|
|
305
|
+
} catch ( e ) {
|
|
306
|
+
// eslint-disable-next-line no-console
|
|
307
|
+
console.warn(
|
|
308
|
+
`Error handling event ${ eventType }`,
|
|
309
|
+
e
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
} );
|
|
314
|
+
},
|
|
315
|
+
[ onWindowEvents ]
|
|
316
|
+
);
|
|
317
|
+
|
|
285
318
|
useEffect( () => {
|
|
286
319
|
const dimensionsChangeSubscription = Dimensions.addEventListener(
|
|
287
320
|
'change',
|
|
@@ -314,7 +347,7 @@ function Sandbox( {
|
|
|
314
347
|
sandboxStyles[ 'sandbox-webview__container' ],
|
|
315
348
|
containerStyle,
|
|
316
349
|
] }
|
|
317
|
-
injectedJavaScript={
|
|
350
|
+
injectedJavaScript={ getInjectedJavaScript() }
|
|
318
351
|
key={ key }
|
|
319
352
|
ref={ ref }
|
|
320
353
|
source={ { baseUrl: providerUrl, html: contentHtml } }
|
|
@@ -326,14 +359,15 @@ function Sandbox( {
|
|
|
326
359
|
getSizeStyle(),
|
|
327
360
|
Platform.isAndroid && workaroundStyles.webView,
|
|
328
361
|
] }
|
|
329
|
-
onMessage={
|
|
362
|
+
onMessage={ onMessage }
|
|
330
363
|
scrollEnabled={ false }
|
|
331
364
|
setBuiltInZoomControls={ false }
|
|
332
365
|
showsHorizontalScrollIndicator={ false }
|
|
333
366
|
showsVerticalScrollIndicator={ false }
|
|
367
|
+
mediaPlaybackRequiresUserAction={ false }
|
|
334
368
|
/>
|
|
335
369
|
);
|
|
336
|
-
}
|
|
370
|
+
} );
|
|
337
371
|
|
|
338
372
|
const workaroundStyles = StyleSheet.create( {
|
|
339
373
|
webView: {
|
package/tsconfig.json
CHANGED
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"src/**/*.native.js",
|
|
44
44
|
"src/**/react-native-*",
|
|
45
45
|
"src/**/stories/**/*.js", // only exclude js files, tsx files should be checked
|
|
46
|
-
"src/**/test/**/*.js"
|
|
47
|
-
"src/index.js"
|
|
46
|
+
"src/**/test/**/*.js" // only exclude js files, ts{x} files should be checked
|
|
48
47
|
]
|
|
49
48
|
}
|