@wordpress/dataviews 4.17.0 → 4.18.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.
@@ -110,7 +110,7 @@ export function ActionModal< Item >( {
110
110
  title={ action.modalHeader || label }
111
111
  __experimentalHideHeader={ !! action.hideModalHeader }
112
112
  onRequestClose={ closeModal }
113
- focusOnMount="firstContentElement"
113
+ focusOnMount={ action.modalFocusOnMount ?? true }
114
114
  size={ action.modalSize || 'medium' }
115
115
  overlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase(
116
116
  action.id
@@ -16,29 +16,41 @@ div.dataviews-view-list {
16
16
  }
17
17
 
18
18
  .dataviews-view-list__item-actions {
19
- flex: 0;
20
- overflow: hidden;
19
+ display: flex;
20
+ width: max-content;
21
+ flex: 0 0 auto;
22
+ gap: $grid-unit-05;
23
+
24
+ .components-button {
25
+ position: relative;
26
+ z-index: 1;
27
+ }
21
28
 
22
29
  > div {
23
30
  height: $button-size-small;
24
31
  }
25
32
 
26
- .components-button {
27
- position: relative;
28
- z-index: 1;
29
- opacity: 0;
33
+ > :not(:last-child) {
34
+ flex: 0;
35
+ overflow: hidden;
36
+ width: 0;
30
37
  }
31
38
  }
32
39
 
33
40
  &:where(.is-selected, .is-hovered, :focus-within) {
34
- .dataviews-view-list__item-actions {
41
+ .dataviews-view-list__item-actions > :not(:last-child) {
35
42
  flex-basis: min-content;
43
+ width: auto;
36
44
  overflow: unset;
37
- padding-inline-end: $grid-unit-05;
45
+ }
46
+ }
38
47
 
39
- .components-button {
40
- opacity: 1;
41
- }
48
+ @media (hover: none) {
49
+ // Show primary action on devices that do not support hover.
50
+ .dataviews-view-list__item-actions > :not(:last-child) {
51
+ flex-basis: min-content;
52
+ width: auto;
53
+ overflow: unset;
42
54
  }
43
55
  }
44
56
 
package/src/types.ts CHANGED
@@ -8,6 +8,11 @@ import type { ReactElement, ComponentType } from 'react';
8
8
  */
9
9
  import type { SetSelection } from './private-types';
10
10
 
11
+ /**
12
+ * WordPress dependencies
13
+ */
14
+ import type { useFocusOnMount } from '@wordpress/compose';
15
+
11
16
  export type SortDirection = 'asc' | 'desc';
12
17
 
13
18
  /**
@@ -470,6 +475,13 @@ export interface ActionModal< Item > extends ActionBase< Item > {
470
475
  * @default 'medium'
471
476
  */
472
477
  modalSize?: 'small' | 'medium' | 'large' | 'fill';
478
+
479
+ /**
480
+ * The focus on mount property of the modal.
481
+ */
482
+ modalFocusOnMount?:
483
+ | Parameters< typeof useFocusOnMount >[ 0 ]
484
+ | 'firstContentElement';
473
485
  }
474
486
 
475
487
  export interface ActionButton< Item > extends ActionBase< Item > {