@wordpress/components 28.8.1-next.5368f64a9.0 → 28.8.2

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/build/box-control/all-input-control.js +1 -2
  3. package/build/box-control/all-input-control.js.map +1 -1
  4. package/build/box-control/utils.js +1 -1
  5. package/build/box-control/utils.js.map +1 -1
  6. package/build/card/card/component.js +2 -2
  7. package/build/card/card/component.js.map +1 -1
  8. package/build/card/styles.js +18 -18
  9. package/build/card/styles.js.map +1 -1
  10. package/build/combobox-control/index.js +3 -1
  11. package/build/combobox-control/index.js.map +1 -1
  12. package/build/combobox-control/types.js.map +1 -1
  13. package/build/custom-select-control-v2/styles.js +9 -9
  14. package/build/custom-select-control-v2/styles.js.map +1 -1
  15. package/build/dropdown-menu-v2/styles.js +17 -17
  16. package/build/dropdown-menu-v2/styles.js.map +1 -1
  17. package/build/modal/index.js +17 -9
  18. package/build/modal/index.js.map +1 -1
  19. package/build/modal/types.js.map +1 -1
  20. package/build/modal/use-modal-exit-animation.js +75 -0
  21. package/build/modal/use-modal-exit-animation.js.map +1 -0
  22. package/build/range-control/styles/range-control-styles.js +28 -28
  23. package/build/range-control/styles/range-control-styles.js.map +1 -1
  24. package/build/tabs/styles.js +3 -3
  25. package/build/tabs/styles.js.map +1 -1
  26. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  27. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  28. package/build/utils/config-values.js +5 -17
  29. package/build/utils/config-values.js.map +1 -1
  30. package/build-module/box-control/all-input-control.js +2 -2
  31. package/build-module/box-control/all-input-control.js.map +1 -1
  32. package/build-module/box-control/utils.js +1 -1
  33. package/build-module/box-control/utils.js.map +1 -1
  34. package/build-module/card/card/component.js +2 -2
  35. package/build-module/card/card/component.js.map +1 -1
  36. package/build-module/card/styles.js +18 -18
  37. package/build-module/card/styles.js.map +1 -1
  38. package/build-module/combobox-control/index.js +3 -1
  39. package/build-module/combobox-control/index.js.map +1 -1
  40. package/build-module/combobox-control/types.js.map +1 -1
  41. package/build-module/custom-select-control-v2/styles.js +9 -9
  42. package/build-module/custom-select-control-v2/styles.js.map +1 -1
  43. package/build-module/dropdown-menu-v2/styles.js +17 -17
  44. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  45. package/build-module/modal/index.js +18 -9
  46. package/build-module/modal/index.js.map +1 -1
  47. package/build-module/modal/types.js.map +1 -1
  48. package/build-module/modal/use-modal-exit-animation.js +68 -0
  49. package/build-module/modal/use-modal-exit-animation.js.map +1 -0
  50. package/build-module/range-control/styles/range-control-styles.js +28 -28
  51. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  52. package/build-module/tabs/styles.js +3 -3
  53. package/build-module/tabs/styles.js.map +1 -1
  54. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  55. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  56. package/build-module/utils/config-values.js +5 -17
  57. package/build-module/utils/config-values.js.map +1 -1
  58. package/build-style/style-rtl.css +51 -6
  59. package/build-style/style.css +51 -6
  60. package/build-types/box-control/all-input-control.d.ts.map +1 -1
  61. package/build-types/box-control/utils.d.ts +1 -1
  62. package/build-types/box-control/utils.d.ts.map +1 -1
  63. package/build-types/button-group/stories/index.story.d.ts +2 -2
  64. package/build-types/button-group/stories/index.story.d.ts.map +1 -1
  65. package/build-types/combobox-control/index.d.ts.map +1 -1
  66. package/build-types/combobox-control/stories/index.story.d.ts +4 -0
  67. package/build-types/combobox-control/stories/index.story.d.ts.map +1 -1
  68. package/build-types/combobox-control/types.d.ts +4 -0
  69. package/build-types/combobox-control/types.d.ts.map +1 -1
  70. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
  71. package/build-types/modal/index.d.ts.map +1 -1
  72. package/build-types/modal/types.d.ts +6 -10
  73. package/build-types/modal/types.d.ts.map +1 -1
  74. package/build-types/modal/use-modal-exit-animation.d.ts +9 -0
  75. package/build-types/modal/use-modal-exit-animation.d.ts.map +1 -0
  76. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  77. package/build-types/utils/config-values.d.ts +0 -11
  78. package/package.json +19 -19
  79. package/src/box-control/README.md +7 -0
  80. package/src/box-control/all-input-control.tsx +2 -3
  81. package/src/box-control/utils.ts +1 -1
  82. package/src/button-group/stories/index.story.tsx +10 -15
  83. package/src/card/card/component.tsx +1 -1
  84. package/src/card/styles.ts +1 -1
  85. package/src/card/test/__snapshots__/index.tsx.snap +54 -54
  86. package/src/combobox-control/README.md +7 -0
  87. package/src/combobox-control/index.tsx +2 -0
  88. package/src/combobox-control/test/index.tsx +40 -0
  89. package/src/combobox-control/types.ts +4 -0
  90. package/src/custom-select-control-v2/styles.ts +1 -0
  91. package/src/dropdown-menu-v2/styles.ts +1 -1
  92. package/src/form-toggle/style.scss +1 -0
  93. package/src/modal/index.tsx +27 -13
  94. package/src/modal/style.scss +30 -3
  95. package/src/modal/types.ts +6 -18
  96. package/src/modal/use-modal-exit-animation.ts +99 -0
  97. package/src/popover/style.scss +3 -2
  98. package/src/range-control/styles/range-control-styles.ts +1 -0
  99. package/src/resizable-box/style.scss +1 -1
  100. package/src/snackbar/style.scss +1 -1
  101. package/src/tabs/styles.ts +1 -1
  102. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +1 -1
  103. package/src/tooltip/style.scss +1 -0
  104. package/src/utils/config-values.js +5 -20
  105. package/tsconfig.tsbuildinfo +1 -1
@@ -1,15 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type {
5
- AriaRole,
6
- CSSProperties,
7
- ReactNode,
8
- KeyboardEventHandler,
9
- KeyboardEvent,
10
- SyntheticEvent,
11
- } from 'react';
12
-
13
1
  /**
14
2
  * WordPress dependencies
15
3
  */
@@ -42,7 +30,7 @@ export type ModalProps = {
42
30
  /**
43
31
  * The children elements.
44
32
  */
45
- children: ReactNode;
33
+ children: React.ReactNode;
46
34
  /**
47
35
  * If this property is added, it will an additional class name to the modal
48
36
  * content `div`.
@@ -77,7 +65,7 @@ export type ModalProps = {
77
65
  *
78
66
  * @default null
79
67
  */
80
- headerActions?: ReactNode;
68
+ headerActions?: React.ReactNode;
81
69
 
82
70
  /**
83
71
  * If this property is added, an icon will be added before the title.
@@ -108,12 +96,12 @@ export type ModalProps = {
108
96
  /**
109
97
  * Handle the key down on the modal frame `div`.
110
98
  */
111
- onKeyDown?: KeyboardEventHandler< HTMLDivElement >;
99
+ onKeyDown?: React.KeyboardEventHandler< HTMLDivElement >;
112
100
  /**
113
101
  * This function is called to indicate that the modal should be closed.
114
102
  */
115
103
  onRequestClose: (
116
- event?: KeyboardEvent< HTMLDivElement > | SyntheticEvent
104
+ event?: React.KeyboardEvent< HTMLDivElement > | React.SyntheticEvent
117
105
  ) => void;
118
106
  /**
119
107
  * If this property is added, it will an additional class name to the modal
@@ -126,7 +114,7 @@ export type ModalProps = {
126
114
  *
127
115
  * @default 'dialog'
128
116
  */
129
- role?: AriaRole;
117
+ role?: React.AriaRole;
130
118
  /**
131
119
  * If this property is added, it will determine whether the modal requests
132
120
  * to close when a mouse click occurs outside of the modal content.
@@ -144,7 +132,7 @@ export type ModalProps = {
144
132
  /**
145
133
  * If this property is added, it will be added to the modal frame `div`.
146
134
  */
147
- style?: CSSProperties;
135
+ style?: React.CSSProperties;
148
136
  /**
149
137
  * This property is used as the modal header's title.
150
138
  *
@@ -0,0 +1,99 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useReducedMotion } from '@wordpress/compose';
5
+ import { useCallback, useRef, useState } from '@wordpress/element';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { CONFIG } from '../utils';
11
+ import warning from '@wordpress/warning';
12
+
13
+ // Animation duration (ms) extracted to JS in order to be used on a setTimeout.
14
+ const FRAME_ANIMATION_DURATION = CONFIG.transitionDuration;
15
+ const FRAME_ANIMATION_DURATION_NUMBER = Number.parseInt(
16
+ CONFIG.transitionDuration
17
+ );
18
+
19
+ const EXIT_ANIMATION_NAME = 'components-modal__disappear-animation';
20
+
21
+ export function useModalExitAnimation() {
22
+ const frameRef = useRef< HTMLDivElement >();
23
+ const [ isAnimatingOut, setIsAnimatingOut ] = useState( false );
24
+ const isReducedMotion = useReducedMotion();
25
+
26
+ const closeModal = useCallback(
27
+ () =>
28
+ new Promise< void >( ( closeModalResolve ) => {
29
+ // Grab a "stable" reference of the frame element, since
30
+ // the value held by the react ref might change at runtime.
31
+ const frameEl = frameRef.current;
32
+
33
+ if ( isReducedMotion ) {
34
+ closeModalResolve();
35
+ return;
36
+ }
37
+
38
+ if ( ! frameEl ) {
39
+ warning(
40
+ "wp.components.Modal: the Modal component can't be closed with an exit animation because of a missing reference to the modal frame element."
41
+ );
42
+ closeModalResolve();
43
+ return;
44
+ }
45
+
46
+ let handleAnimationEnd:
47
+ | undefined
48
+ | ( ( e: AnimationEvent ) => void );
49
+
50
+ const startAnimation = () =>
51
+ new Promise< void >( ( animationResolve ) => {
52
+ handleAnimationEnd = ( e: AnimationEvent ) => {
53
+ if ( e.animationName === EXIT_ANIMATION_NAME ) {
54
+ animationResolve();
55
+ }
56
+ };
57
+
58
+ frameEl.addEventListener(
59
+ 'animationend',
60
+ handleAnimationEnd
61
+ );
62
+ setIsAnimatingOut( true );
63
+ } );
64
+ const animationTimeout = () =>
65
+ new Promise< void >( ( timeoutResolve ) => {
66
+ setTimeout(
67
+ () => timeoutResolve(),
68
+ // Allow an extra 20% of the animation duration for the
69
+ // animationend event to fire, in case the animation frame is
70
+ // slightly delayes by some other events in the event loop.
71
+ FRAME_ANIMATION_DURATION_NUMBER * 1.2
72
+ );
73
+ } );
74
+
75
+ Promise.race( [ startAnimation(), animationTimeout() ] ).then(
76
+ () => {
77
+ if ( handleAnimationEnd ) {
78
+ frameEl.removeEventListener(
79
+ 'animationend',
80
+ handleAnimationEnd
81
+ );
82
+ }
83
+ setIsAnimatingOut( false );
84
+ closeModalResolve();
85
+ }
86
+ );
87
+ } ),
88
+ [ isReducedMotion ]
89
+ );
90
+
91
+ return {
92
+ overlayClassname: isAnimatingOut ? 'is-animating-out' : undefined,
93
+ frameRef,
94
+ frameStyle: {
95
+ '--modal-frame-animation-duration': `${ FRAME_ANIMATION_DURATION }`,
96
+ },
97
+ closeModal,
98
+ };
99
+ }
@@ -22,14 +22,15 @@ $shadow-popover-border-top-only-alternate: 0 #{-$border-width} 0 $gray-900;
22
22
 
23
23
  .components-popover__content {
24
24
  background: $white;
25
- box-shadow: $shadow-popover-border-default, $elevation-x-small;
25
+ box-shadow: $shadow-popover-border-default, $elevation-medium;
26
26
  border-radius: $radius-medium;
27
27
  box-sizing: border-box;
28
28
  width: min-content;
29
29
 
30
- // Alternate treatment for popovers that put them at elevation zero with high contrast.
30
+ // Alternate treatment for popovers that put them at elevation zero with high contrast and smaller radius.
31
31
  .is-alternate & {
32
32
  box-shadow: $shadow-popover-border-default-alternate;
33
+ border-radius: $radius-small;
33
34
  }
34
35
 
35
36
  // A style that gives the popover no visible ui.
@@ -239,6 +239,7 @@ export const Thumb = styled.span< ThumbProps >`
239
239
  position: absolute;
240
240
  user-select: none;
241
241
  width: 100%;
242
+ box-shadow: ${ CONFIG.elevationXSmall };
242
243
 
243
244
  ${ thumbColor };
244
245
  ${ thumbFocus };
@@ -35,7 +35,7 @@ $resize-handler-container-size: $resize-handler-size + ($grid-unit-05 * 2); // M
35
35
  top: calc(50% - #{ceil($resize-handler-size * 0.5)});
36
36
  right: calc(50% - #{ceil($resize-handler-size * 0.5)});
37
37
 
38
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
38
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent, $elevation-x-small;
39
39
  // Only visible in Windows High Contrast mode.
40
40
  outline: 2px solid transparent;
41
41
  }
@@ -4,7 +4,7 @@
4
4
  background: rgba($black, 0.85); // Emulates #1e1e1e closely.
5
5
  backdrop-filter: blur($grid-unit-20) saturate(180%);
6
6
  border-radius: $radius-medium;
7
- box-shadow: $elevation-x-small;
7
+ box-shadow: $elevation-small;
8
8
  color: $white;
9
9
  padding: $grid-unit-15 ($grid-unit-05 * 5);
10
10
  width: 100%;
@@ -76,7 +76,7 @@ export const TabListWrapper = styled.div`
76
76
  top: 0;
77
77
  left: 0;
78
78
  width: 100%;
79
- width: calc( var( --antialiasing-factor ) * 1px );
79
+ height: calc( var( --antialiasing-factor ) * 1px );
80
80
  transform: translateY( calc( var( --indicator-top ) * 1px ) )
81
81
  scaleY(
82
82
  calc( var( --indicator-height ) / var( --antialiasing-factor ) )
@@ -70,7 +70,7 @@ export const buttonView = ( {
70
70
  }
71
71
 
72
72
  &:active {
73
- background: ${ CONFIG.toggleGroupControlBackgroundColor };
73
+ background: ${ CONFIG.controlBackgroundColor };
74
74
  }
75
75
 
76
76
  ${ isDeselectable && deselectable }
@@ -8,6 +8,7 @@
8
8
  font-size: 12px;
9
9
  padding: $grid-unit-05 $grid-unit-10;
10
10
  z-index: z-index(".components-tooltip");
11
+ box-shadow: $elevation-small;
11
12
  }
12
13
 
13
14
  .components-tooltip__shortcut {
@@ -7,18 +7,13 @@ import { COLORS } from './colors-values';
7
7
  const CONTROL_HEIGHT = '36px';
8
8
 
9
9
  const CONTROL_PROPS = {
10
- controlSurfaceColor: COLORS.white,
11
- controlTextActiveColor: COLORS.theme.accent,
12
-
13
10
  // These values should be shared with TextControl.
14
11
  controlPaddingX: 12,
15
12
  controlPaddingXSmall: 8,
16
13
  controlPaddingXLarge: 12 * 1.3334, // TODO: Deprecate
17
14
 
18
15
  controlBackgroundColor: COLORS.white,
19
- controlBoxShadow: 'transparent',
20
16
  controlBoxShadowFocus: `0 0 0 0.5px ${ COLORS.theme.accent }`,
21
- controlDestructiveBorderColor: COLORS.alert.red,
22
17
  controlHeight: CONTROL_HEIGHT,
23
18
  controlHeightXSmall: `calc( ${ CONTROL_HEIGHT } * 0.6 )`,
24
19
  controlHeightSmall: `calc( ${ CONTROL_HEIGHT } * 0.8 )`,
@@ -26,18 +21,9 @@ const CONTROL_PROPS = {
26
21
  controlHeightXLarge: `calc( ${ CONTROL_HEIGHT } * 1.4 )`,
27
22
  };
28
23
 
29
- const TOGGLE_GROUP_CONTROL_PROPS = {
30
- toggleGroupControlBackgroundColor: CONTROL_PROPS.controlBackgroundColor,
31
- toggleGroupControlBorderColor: COLORS.ui.border,
32
- toggleGroupControlBackdropBackgroundColor:
33
- CONTROL_PROPS.controlSurfaceColor,
34
- toggleGroupControlBackdropBorderColor: COLORS.ui.border,
35
- toggleGroupControlButtonColorActive: CONTROL_PROPS.controlBackgroundColor,
36
- };
37
-
38
24
  // Using Object.assign to avoid creating circular references when emitting
39
25
  // TypeScript type declarations.
40
- export default Object.assign( {}, CONTROL_PROPS, TOGGLE_GROUP_CONTROL_PROPS, {
26
+ export default Object.assign( {}, CONTROL_PROPS, {
41
27
  colorDivider: 'rgba(0, 0, 0, 0.1)',
42
28
  colorScrollbarThumb: 'rgba(0, 0, 0, 0.2)',
43
29
  colorScrollbarThumbHover: 'rgba(0, 0, 0, 0.5)',
@@ -68,15 +54,14 @@ export default Object.assign( {}, CONTROL_PROPS, TOGGLE_GROUP_CONTROL_PROPS, {
68
54
  fontWeight: 'normal',
69
55
  fontWeightHeading: '600',
70
56
  gridBase: '4px',
71
- cardBorderRadius: '2px',
72
57
  cardPaddingXSmall: `${ space( 2 ) }`,
73
58
  cardPaddingSmall: `${ space( 4 ) }`,
74
59
  cardPaddingMedium: `${ space( 4 ) } ${ space( 6 ) }`,
75
60
  cardPaddingLarge: `${ space( 6 ) } ${ space( 8 ) }`,
76
- elevationXSmall: `0 0.7px 1px rgba(0, 0, 0, 0.1), 0 1.2px 1.7px -0.2px rgba(0, 0, 0, 0.1), 0 2.3px 3.3px -0.5px rgba(0, 0, 0, 0.1)`,
77
- elevationSmall: `0 0.7px 1px 0 rgba(0, 0, 0, 0.12), 0 2.2px 3.7px -0.2px rgba(0, 0, 0, 0.12), 0 5.3px 7.3px -0.5px rgba(0, 0, 0, 0.12)`,
78
- elevationMedium: `0 0.7px 1px 0 rgba(0, 0, 0, 0.14), 0 4.2px 5.7px -0.2px rgba(0, 0, 0, 0.14), 0 7.3px 9.3px -0.5px rgba(0, 0, 0, 0.14)`,
79
- elevationLarge: `0 0.7px 1px rgba(0, 0, 0, 0.15), 0 2.7px 3.8px -0.2px rgba(0, 0, 0, 0.15), 0 5.5px 7.8px -0.3px rgba(0, 0, 0, 0.15), 0.1px 11.5px 16.4px -0.5px rgba(0, 0, 0, 0.15)`,
61
+ elevationXSmall: `0 1px 1px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02), 0 3px 3px rgba(0, 0, 0, 0.02), 0 4px 4px rgba(0, 0, 0, 0.01)`,
62
+ elevationSmall: `0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 3px rgba(0, 0, 0, 0.04), 0 6px 6px rgba(0, 0, 0, 0.03), 0 8px 8px rgba(0, 0, 0, 0.02)`,
63
+ elevationMedium: `0 2px 3px rgba(0, 0, 0, 0.05), 0 4px 5px rgba(0, 0, 0, 0.04), 0 12px 12px rgba(0, 0, 0, 0.03), 0 16px 16px rgba(0, 0, 0, 0.02)`,
64
+ elevationLarge: `0 5px 15px rgba(0, 0, 0, 0.08), 0 15px 27px rgba(0, 0, 0, 0.07), 0 30px 36px rgba(0, 0, 0, 0.04), 0 50px 43px rgba(0, 0, 0, 0.02)`,
80
65
  surfaceBackgroundColor: COLORS.white,
81
66
  surfaceBackgroundSubtleColor: '#F3F3F3',
82
67
  surfaceBackgroundTintColor: '#F5F5F5',