@wordpress/components 27.2.0 → 27.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +13 -0
- package/build/button/index.js +1 -1
- package/build/button/index.js.map +1 -1
- package/build/color-picker/component.js +2 -12
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/picker.js +18 -77
- package/build/color-picker/picker.js.map +1 -1
- package/build/color-picker/types.js.map +1 -1
- package/build/custom-select-control-v2/default-component/index.js +4 -2
- package/build/custom-select-control-v2/default-component/index.js.map +1 -1
- package/build/custom-select-control-v2/index.js +1 -8
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/custom-select-control-v2/{custom-select-item.js → item.js} +2 -1
- package/build/custom-select-control-v2/{custom-select-item.js.map → item.js.map} +1 -1
- package/build/custom-select-control-v2/legacy-component/index.js +5 -5
- package/build/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build/input-control/input-field.js +2 -1
- package/build/input-control/input-field.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +1 -0
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/navigable-container/container.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +162 -120
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +2 -2
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/popover/index.js +7 -34
- package/build/popover/index.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +29 -29
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/component.js +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/color-picker/component.js +3 -13
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/picker.js +19 -78
- package/build-module/color-picker/picker.js.map +1 -1
- package/build-module/color-picker/types.js.map +1 -1
- package/build-module/custom-select-control-v2/default-component/index.js +4 -2
- package/build-module/custom-select-control-v2/default-component/index.js.map +1 -1
- package/build-module/custom-select-control-v2/index.js +1 -2
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/custom-select-control-v2/{custom-select-item.js → item.js} +2 -1
- package/build-module/custom-select-control-v2/{custom-select-item.js.map → item.js.map} +1 -1
- package/build-module/custom-select-control-v2/legacy-component/index.js +4 -4
- package/build-module/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build-module/input-control/input-field.js +2 -1
- package/build-module/input-control/input-field.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +1 -0
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/navigable-container/container.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +163 -121
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +2 -2
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/popover/index.js +9 -36
- package/build-module/popover/index.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +29 -29
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +2 -2
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build-style/style-rtl.css +2 -8
- package/build-style/style.css +2 -8
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +1 -1
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +0 -3
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/custom-select-control/stories/index.story.d.ts +35 -0
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/default-component/index.d.ts +5 -2
- package/build-types/custom-select-control-v2/default-component/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/index.d.ts +1 -2
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/{custom-select-item.d.ts → item.d.ts} +4 -1
- package/build-types/custom-select-control-v2/item.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts +2 -2
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/default.story.d.ts +2 -2
- package/build-types/custom-select-control-v2/stories/default.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/legacy.story.d.ts +4 -2
- package/build-types/custom-select-control-v2/stories/legacy.story.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/button/index.tsx +1 -1
- package/src/color-picker/component.tsx +3 -25
- package/src/color-picker/picker.tsx +12 -96
- package/src/color-picker/types.ts +0 -3
- package/src/custom-select-control/stories/{index.story.js → index.story.tsx} +8 -3
- package/src/custom-select-control/test/index.js +24 -0
- package/src/custom-select-control-v2/README.md +27 -27
- package/src/custom-select-control-v2/default-component/index.tsx +5 -2
- package/src/custom-select-control-v2/index.tsx +1 -2
- package/src/custom-select-control-v2/{custom-select-item.tsx → item.tsx} +2 -0
- package/src/custom-select-control-v2/legacy-component/index.tsx +4 -6
- package/src/custom-select-control-v2/legacy-component/test/index.tsx +13 -10
- package/src/custom-select-control-v2/stories/default.story.tsx +16 -17
- package/src/custom-select-control-v2/stories/legacy.story.tsx +20 -35
- package/src/custom-select-control-v2/test/index.tsx +26 -16
- package/src/dropdown/style.scss +3 -3
- package/src/input-control/input-field.tsx +2 -1
- package/src/mobile/color-settings/palette.screen.native.js +5 -1
- package/src/navigable-container/container.tsx +1 -1
- package/src/navigator/navigator-provider/component.tsx +187 -188
- package/src/navigator/navigator-screen/component.tsx +2 -4
- package/src/popover/index.tsx +59 -99
- package/src/popover/style.scss +0 -9
- package/src/range-control/styles/range-control-styles.ts +1 -1
- package/src/text-control/style.scss +2 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +2 -2
- package/src/toolbar/toolbar/style.scss +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build-types/custom-select-control-v2/custom-select-item.d.ts.map +0 -1
package/src/popover/index.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
// eslint-disable-next-line no-restricted-imports
|
|
17
17
|
import type { HTMLMotionProps, MotionProps } from 'framer-motion';
|
|
18
18
|
// eslint-disable-next-line no-restricted-imports
|
|
19
|
-
import { motion
|
|
19
|
+
import { motion } from 'framer-motion';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* WordPress dependencies
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
createPortal,
|
|
34
34
|
} from '@wordpress/element';
|
|
35
35
|
import {
|
|
36
|
+
useReducedMotion,
|
|
36
37
|
useViewportMatch,
|
|
37
38
|
useMergeRefs,
|
|
38
39
|
__experimentalUseDialog as useDialog,
|
|
@@ -53,11 +54,7 @@ import {
|
|
|
53
54
|
placementToMotionAnimationProps,
|
|
54
55
|
getReferenceElement,
|
|
55
56
|
} from './utils';
|
|
56
|
-
import {
|
|
57
|
-
contextConnect,
|
|
58
|
-
useContextSystem,
|
|
59
|
-
ContextSystemProvider,
|
|
60
|
-
} from '../context';
|
|
57
|
+
import { contextConnect, useContextSystem } from '../context';
|
|
61
58
|
import type { WordPressComponentProps } from '../context';
|
|
62
59
|
import type {
|
|
63
60
|
PopoverProps,
|
|
@@ -113,7 +110,7 @@ const getPopoverFallbackContainer = () => {
|
|
|
113
110
|
return container;
|
|
114
111
|
};
|
|
115
112
|
|
|
116
|
-
const
|
|
113
|
+
const UnforwardedPopover = (
|
|
117
114
|
props: Omit<
|
|
118
115
|
WordPressComponentProps< PopoverProps, 'div', false >,
|
|
119
116
|
// To avoid overlaps between the standard HTML attributes and the props
|
|
@@ -390,100 +387,63 @@ const UnconnectedPopover = (
|
|
|
390
387
|
const isPositioned =
|
|
391
388
|
( ! shouldAnimate || animationFinished ) && x !== null && y !== null;
|
|
392
389
|
|
|
393
|
-
// In case a `ColorPicker` component is rendered as a child of `Popover`,
|
|
394
|
-
// the `Popover` component can be notified of when the user is dragging
|
|
395
|
-
// parts of the `ColorPicker` UI (this is possible because the `ColorPicker`
|
|
396
|
-
// component exposes the `onPickerDragStart` and `onPickerDragEnd` props
|
|
397
|
-
// via internal context).
|
|
398
|
-
// While the user is performing a pointer drag, the `Popover` will render
|
|
399
|
-
// a transparent backdrop element that will serve as a "pointer events trap",
|
|
400
|
-
// making sure that no pointer events reach any potential `iframe` element
|
|
401
|
-
// underneath (like, for example, the editor canvas in the WordPress editor).
|
|
402
|
-
const [ showBackdrop, setShowBackdrop ] = useState( false );
|
|
403
|
-
const contextValue = useMemo(
|
|
404
|
-
() => ( {
|
|
405
|
-
ColorPicker: {
|
|
406
|
-
onPickerDragStart() {
|
|
407
|
-
setShowBackdrop( true );
|
|
408
|
-
},
|
|
409
|
-
onPickerDragEnd() {
|
|
410
|
-
setShowBackdrop( false );
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
} ),
|
|
414
|
-
[]
|
|
415
|
-
);
|
|
416
|
-
|
|
417
390
|
let content = (
|
|
418
|
-
|
|
419
|
-
{
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
391
|
+
<motion.div
|
|
392
|
+
className={ classnames( className, {
|
|
393
|
+
'is-expanded': isExpanded,
|
|
394
|
+
'is-positioned': isPositioned,
|
|
395
|
+
// Use the 'alternate' classname for 'toolbar' variant for back compat.
|
|
396
|
+
[ `is-${
|
|
397
|
+
computedVariant === 'toolbar'
|
|
398
|
+
? 'alternate'
|
|
399
|
+
: computedVariant
|
|
400
|
+
}` ]: computedVariant,
|
|
401
|
+
} ) }
|
|
402
|
+
{ ...animationProps }
|
|
403
|
+
{ ...contentProps }
|
|
404
|
+
ref={ mergedFloatingRef }
|
|
405
|
+
{ ...dialogProps }
|
|
406
|
+
tabIndex={ -1 }
|
|
407
|
+
>
|
|
408
|
+
{ /* Prevents scroll on the document */ }
|
|
409
|
+
{ isExpanded && <ScrollLock /> }
|
|
410
|
+
{ isExpanded && (
|
|
411
|
+
<div className="components-popover__header">
|
|
412
|
+
<span className="components-popover__header-title">
|
|
413
|
+
{ headerTitle }
|
|
414
|
+
</span>
|
|
415
|
+
<Button
|
|
416
|
+
className="components-popover__close"
|
|
417
|
+
icon={ close }
|
|
418
|
+
onClick={ onClose }
|
|
419
|
+
/>
|
|
420
|
+
</div>
|
|
425
421
|
) }
|
|
426
|
-
<
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
{ headerTitle }
|
|
449
|
-
</span>
|
|
450
|
-
<Button
|
|
451
|
-
className="components-popover__close"
|
|
452
|
-
icon={ close }
|
|
453
|
-
onClick={ onClose }
|
|
454
|
-
/>
|
|
455
|
-
</div>
|
|
456
|
-
) }
|
|
457
|
-
<div className="components-popover__content">
|
|
458
|
-
<ContextSystemProvider value={ contextValue }>
|
|
459
|
-
{ children }
|
|
460
|
-
</ContextSystemProvider>
|
|
422
|
+
<div className="components-popover__content">{ children }</div>
|
|
423
|
+
{ hasArrow && (
|
|
424
|
+
<div
|
|
425
|
+
ref={ arrowCallbackRef }
|
|
426
|
+
className={ [
|
|
427
|
+
'components-popover__arrow',
|
|
428
|
+
`is-${ computedPlacement.split( '-' )[ 0 ] }`,
|
|
429
|
+
].join( ' ' ) }
|
|
430
|
+
style={ {
|
|
431
|
+
left:
|
|
432
|
+
typeof arrowData?.x !== 'undefined' &&
|
|
433
|
+
Number.isFinite( arrowData.x )
|
|
434
|
+
? `${ arrowData.x }px`
|
|
435
|
+
: '',
|
|
436
|
+
top:
|
|
437
|
+
typeof arrowData?.y !== 'undefined' &&
|
|
438
|
+
Number.isFinite( arrowData.y )
|
|
439
|
+
? `${ arrowData.y }px`
|
|
440
|
+
: '',
|
|
441
|
+
} }
|
|
442
|
+
>
|
|
443
|
+
<ArrowTriangle />
|
|
461
444
|
</div>
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
ref={ arrowCallbackRef }
|
|
465
|
-
className={ [
|
|
466
|
-
'components-popover__arrow',
|
|
467
|
-
`is-${ computedPlacement.split( '-' )[ 0 ] }`,
|
|
468
|
-
].join( ' ' ) }
|
|
469
|
-
style={ {
|
|
470
|
-
left:
|
|
471
|
-
typeof arrowData?.x !== 'undefined' &&
|
|
472
|
-
Number.isFinite( arrowData.x )
|
|
473
|
-
? `${ arrowData.x }px`
|
|
474
|
-
: '',
|
|
475
|
-
top:
|
|
476
|
-
typeof arrowData?.y !== 'undefined' &&
|
|
477
|
-
Number.isFinite( arrowData.y )
|
|
478
|
-
? `${ arrowData.y }px`
|
|
479
|
-
: '',
|
|
480
|
-
} }
|
|
481
|
-
>
|
|
482
|
-
<ArrowTriangle />
|
|
483
|
-
</div>
|
|
484
|
-
) }
|
|
485
|
-
</motion.div>
|
|
486
|
-
</>
|
|
445
|
+
) }
|
|
446
|
+
</motion.div>
|
|
487
447
|
);
|
|
488
448
|
|
|
489
449
|
const shouldRenderWithinSlot = slot.ref && ! inline;
|
|
@@ -533,7 +493,7 @@ const UnconnectedPopover = (
|
|
|
533
493
|
* ```
|
|
534
494
|
*
|
|
535
495
|
*/
|
|
536
|
-
export const Popover = contextConnect(
|
|
496
|
+
export const Popover = contextConnect( UnforwardedPopover, 'Popover' );
|
|
537
497
|
|
|
538
498
|
function PopoverSlot(
|
|
539
499
|
{ name = SLOT_NAME }: { name?: string },
|
package/src/popover/style.scss
CHANGED
|
@@ -134,12 +134,3 @@ $shadow-popover-border-top-only-alternate: 0 #{-$border-width} 0 $gray-900;
|
|
|
134
134
|
stroke: $gray-900;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
|
|
138
|
-
.components-popover-pointer-events-trap {
|
|
139
|
-
// Same z-index as popover, but rendered before the popover element
|
|
140
|
-
// in DOM order = it will display just under the popover
|
|
141
|
-
z-index: z-index(".components-popover");
|
|
142
|
-
position: fixed;
|
|
143
|
-
inset: 0;
|
|
144
|
-
background-color: transparent;
|
|
145
|
-
}
|
|
@@ -300,7 +300,7 @@ export const Tooltip = styled.span< TooltipProps >`
|
|
|
300
300
|
) }
|
|
301
301
|
`;
|
|
302
302
|
|
|
303
|
-
// @todo
|
|
303
|
+
// @todo Refactor RangeControl with latest HStack configuration
|
|
304
304
|
// @see: packages/components/src/h-stack
|
|
305
305
|
export const InputNumber = styled( NumberControl )`
|
|
306
306
|
display: inline-block;
|
|
@@ -5,12 +5,12 @@ import type { ForwardedRef } from 'react';
|
|
|
5
5
|
// eslint-disable-next-line no-restricted-imports
|
|
6
6
|
import * as Ariakit from '@ariakit/react';
|
|
7
7
|
// eslint-disable-next-line no-restricted-imports
|
|
8
|
-
import { motion
|
|
8
|
+
import { motion } from 'framer-motion';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* WordPress dependencies
|
|
12
12
|
*/
|
|
13
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
13
|
+
import { useReducedMotion, useInstanceId } from '@wordpress/compose';
|
|
14
14
|
import { useMemo } from '@wordpress/element';
|
|
15
15
|
|
|
16
16
|
/**
|