@wordpress/dataviews 7.0.1-next.f34ab90e9.0 → 8.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/CHANGELOG.md +23 -0
- package/README.md +5 -5
- package/build/components/dataform-context/index.js +1 -0
- package/build/components/dataform-context/index.js.map +1 -1
- package/build/components/dataviews/index.js +4 -4
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews-context/index.js +1 -0
- package/build/components/dataviews-context/index.js.map +1 -1
- package/build/dataforms-layouts/card/index.js +6 -3
- package/build/dataforms-layouts/card/index.js.map +1 -1
- package/build/dataviews-layouts/grid/index.js +11 -3
- package/build/dataviews-layouts/grid/index.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/components/dataform-context/index.js +1 -0
- package/build-module/components/dataform-context/index.js.map +1 -1
- package/build-module/components/dataviews/index.js +4 -4
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews-context/index.js +1 -0
- package/build-module/components/dataviews-context/index.js.map +1 -1
- package/build-module/dataforms-layouts/card/index.js +6 -3
- package/build-module/dataforms-layouts/card/index.js.map +1 -1
- package/build-module/dataviews-layouts/grid/index.js +11 -3
- package/build-module/dataviews-layouts/grid/index.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +56 -3
- package/build-style/style.css +56 -3
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataform-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews/index.d.ts +3 -1
- package/build-types/components/dataviews/index.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/index.story.d.ts +12 -1
- package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews-context/index.d.ts +1 -1
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/card/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/grid/index.d.ts.map +1 -1
- package/build-types/field-types/stories/index.story.d.ts +69 -0
- package/build-types/field-types/stories/index.story.d.ts.map +1 -0
- package/build-types/types.d.ts +1 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-wp/index.js +58 -30
- package/package.json +15 -15
- package/src/components/dataform/stories/index.story.tsx +2 -0
- package/src/components/dataform-context/index.tsx +1 -0
- package/src/components/dataviews/index.tsx +14 -16
- package/src/components/dataviews/stories/fixtures.tsx +1 -1
- package/src/components/dataviews/stories/index.story.tsx +41 -7
- package/src/components/dataviews-context/index.ts +3 -1
- package/src/dataforms-layouts/card/index.tsx +5 -0
- package/src/dataforms-layouts/card/style.scss +7 -0
- package/src/dataviews-layouts/grid/index.tsx +31 -19
- package/src/dataviews-layouts/grid/style.scss +43 -3
- package/src/field-types/stories/index.story.tsx +581 -0
- package/src/style.scss +1 -0
- package/src/test/dataviews.tsx +86 -0
- package/src/types.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build-types/components/stories/index.story.d.ts +0 -63
- package/build-types/components/stories/index.story.d.ts.map +0 -1
- package/src/components/stories/index.story.tsx +0 -372
|
@@ -66,11 +66,9 @@ type DataViewsProps< Item > = {
|
|
|
66
66
|
header?: ReactNode;
|
|
67
67
|
getItemLevel?: ( item: Item ) => number;
|
|
68
68
|
children?: ReactNode;
|
|
69
|
-
config?:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
perPageSizes: number[];
|
|
73
|
-
};
|
|
69
|
+
config?: {
|
|
70
|
+
perPageSizes: number[];
|
|
71
|
+
};
|
|
74
72
|
empty?: ReactNode;
|
|
75
73
|
} & ( Item extends ItemWithId
|
|
76
74
|
? { getItemId?: ( item: Item ) => string }
|
|
@@ -90,7 +88,7 @@ function DefaultUI( {
|
|
|
90
88
|
search = true,
|
|
91
89
|
searchLabel = undefined,
|
|
92
90
|
}: DefaultUIProps ) {
|
|
93
|
-
const { isShowingFilter
|
|
91
|
+
const { isShowingFilter } = useContext( DataViewsContext );
|
|
94
92
|
return (
|
|
95
93
|
<>
|
|
96
94
|
<HStack
|
|
@@ -107,16 +105,14 @@ function DefaultUI( {
|
|
|
107
105
|
{ search && <DataViewsSearch label={ searchLabel } /> }
|
|
108
106
|
<FiltersToggle />
|
|
109
107
|
</HStack>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
</HStack>
|
|
119
|
-
) }
|
|
108
|
+
<HStack
|
|
109
|
+
spacing={ 1 }
|
|
110
|
+
expanded={ false }
|
|
111
|
+
style={ { flexShrink: 0 } }
|
|
112
|
+
>
|
|
113
|
+
<DataViewsViewConfig />
|
|
114
|
+
{ header }
|
|
115
|
+
</HStack>
|
|
120
116
|
</HStack>
|
|
121
117
|
{ isShowingFilter && (
|
|
122
118
|
<DataViewsFilters className="dataviews-filters__container" />
|
|
@@ -282,6 +278,7 @@ const DataViewsSubComponents = DataViews as typeof DataViews & {
|
|
|
282
278
|
Pagination: typeof DataViewsPagination;
|
|
283
279
|
Search: typeof DataViewsSearch;
|
|
284
280
|
ViewConfig: typeof DataviewsViewConfigDropdown;
|
|
281
|
+
Footer: typeof DataViewsFooter;
|
|
285
282
|
};
|
|
286
283
|
|
|
287
284
|
DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
|
|
@@ -292,5 +289,6 @@ DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
|
|
|
292
289
|
DataViewsSubComponents.Pagination = DataViewsPagination;
|
|
293
290
|
DataViewsSubComponents.Search = DataViewsSearch;
|
|
294
291
|
DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
|
|
292
|
+
DataViewsSubComponents.Footer = DataViewsFooter;
|
|
295
293
|
|
|
296
294
|
export default DataViewsSubComponents;
|
|
@@ -772,7 +772,7 @@ export const fields: Field< SpaceObject >[] = [
|
|
|
772
772
|
label: 'Title',
|
|
773
773
|
id: 'title',
|
|
774
774
|
type: 'text',
|
|
775
|
-
enableHiding:
|
|
775
|
+
enableHiding: true,
|
|
776
776
|
enableGlobalSearch: true,
|
|
777
777
|
filterBy: {
|
|
778
778
|
operators: [ 'contains', 'notContains', 'startsWith' ],
|
|
@@ -46,6 +46,20 @@ import './style.css';
|
|
|
46
46
|
const meta = {
|
|
47
47
|
title: 'DataViews/DataViews',
|
|
48
48
|
component: DataViews,
|
|
49
|
+
// Use fullscreen layout and a wrapper div with padding to resolve conflicts
|
|
50
|
+
// between Ariakit's Dialog (usePreventBodyScroll) and Storybook's body padding
|
|
51
|
+
// (sb-main-padding class). This ensures consistent layout in DataViews stories
|
|
52
|
+
// when clicking actions menus. Without this the padding on the body will jump.
|
|
53
|
+
parameters: {
|
|
54
|
+
layout: 'fullscreen',
|
|
55
|
+
},
|
|
56
|
+
decorators: [
|
|
57
|
+
( Story ) => (
|
|
58
|
+
<div style={ { padding: '1rem' } }>
|
|
59
|
+
<Story />
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
],
|
|
49
63
|
} as Meta< typeof DataViews >;
|
|
50
64
|
|
|
51
65
|
export default meta;
|
|
@@ -146,7 +160,11 @@ export const CustomEmpty = () => {
|
|
|
146
160
|
);
|
|
147
161
|
};
|
|
148
162
|
|
|
149
|
-
|
|
163
|
+
const MinimalUIComponent = ( {
|
|
164
|
+
layout = 'table',
|
|
165
|
+
}: {
|
|
166
|
+
layout: 'table' | 'list' | 'grid';
|
|
167
|
+
} ) => {
|
|
150
168
|
const [ view, setView ] = useState< View >( {
|
|
151
169
|
...DEFAULT_VIEW,
|
|
152
170
|
fields: [ 'title', 'description', 'categories' ],
|
|
@@ -165,6 +183,13 @@ export const MinimalUI = () => {
|
|
|
165
183
|
filterBy: false,
|
|
166
184
|
} ) );
|
|
167
185
|
|
|
186
|
+
useEffect( () => {
|
|
187
|
+
setView( {
|
|
188
|
+
...view,
|
|
189
|
+
type: layout as any,
|
|
190
|
+
} );
|
|
191
|
+
}, [ layout ] );
|
|
192
|
+
|
|
168
193
|
return (
|
|
169
194
|
<DataViews
|
|
170
195
|
getItemId={ ( item ) => item.id.toString() }
|
|
@@ -172,15 +197,24 @@ export const MinimalUI = () => {
|
|
|
172
197
|
data={ shownData }
|
|
173
198
|
view={ view }
|
|
174
199
|
fields={ _fields }
|
|
175
|
-
config={ false }
|
|
176
|
-
search={ false }
|
|
177
200
|
onChangeView={ setView }
|
|
178
|
-
defaultLayouts={ {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
201
|
+
defaultLayouts={ { [ layout ]: {} } }
|
|
202
|
+
>
|
|
203
|
+
<DataViews.Layout />
|
|
204
|
+
<DataViews.Footer />
|
|
205
|
+
</DataViews>
|
|
182
206
|
);
|
|
183
207
|
};
|
|
208
|
+
export const MinimalUI = {
|
|
209
|
+
render: MinimalUIComponent,
|
|
210
|
+
argTypes: {
|
|
211
|
+
layout: {
|
|
212
|
+
control: 'select',
|
|
213
|
+
options: [ 'table', 'list', 'grid' ],
|
|
214
|
+
defaultValue: 'table',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
};
|
|
184
218
|
|
|
185
219
|
/**
|
|
186
220
|
* Custom composition example
|
|
@@ -54,7 +54,7 @@ type DataViewsContextType< Item > = {
|
|
|
54
54
|
filters: NormalizedFilter[];
|
|
55
55
|
isShowingFilter: boolean;
|
|
56
56
|
setIsShowingFilter: ( value: boolean ) => void;
|
|
57
|
-
config:
|
|
57
|
+
config: { perPageSizes: number[] };
|
|
58
58
|
empty?: ReactNode;
|
|
59
59
|
hasInfiniteScrollHandler: boolean;
|
|
60
60
|
};
|
|
@@ -88,4 +88,6 @@ const DataViewsContext = createContext< DataViewsContextType< any > >( {
|
|
|
88
88
|
},
|
|
89
89
|
} );
|
|
90
90
|
|
|
91
|
+
DataViewsContext.displayName = 'DataViewsContext';
|
|
92
|
+
|
|
91
93
|
export default DataViewsContext;
|
|
@@ -104,6 +104,11 @@ export default function FormCardField< Item >( {
|
|
|
104
104
|
// If it doesn't have a header, keep it open.
|
|
105
105
|
// Otherwise, the card will not be visible.
|
|
106
106
|
<CardBody className="dataforms-layouts-card__field-control">
|
|
107
|
+
{ field.description && (
|
|
108
|
+
<div className="dataforms-layouts-card__field-description">
|
|
109
|
+
{ field.description }
|
|
110
|
+
</div>
|
|
111
|
+
) }
|
|
107
112
|
<DataFormLayout
|
|
108
113
|
data={ data }
|
|
109
114
|
form={ form }
|
|
@@ -108,6 +108,7 @@ function GridItem< Item >( {
|
|
|
108
108
|
showTitle && titleField?.render ? (
|
|
109
109
|
<titleField.render item={ item } field={ titleField } />
|
|
110
110
|
) : null;
|
|
111
|
+
const shouldRenderMedia = showMedia && renderedMediaField;
|
|
111
112
|
|
|
112
113
|
let mediaA11yProps;
|
|
113
114
|
let titleA11yProps;
|
|
@@ -154,7 +155,7 @@ function GridItem< Item >( {
|
|
|
154
155
|
}
|
|
155
156
|
aria-posinset={ posinset }
|
|
156
157
|
>
|
|
157
|
-
{
|
|
158
|
+
{ shouldRenderMedia && (
|
|
158
159
|
<ItemClickWrapper
|
|
159
160
|
item={ item }
|
|
160
161
|
isItemClickable={ isItemClickable }
|
|
@@ -166,7 +167,7 @@ function GridItem< Item >( {
|
|
|
166
167
|
{ renderedMediaField }
|
|
167
168
|
</ItemClickWrapper>
|
|
168
169
|
) }
|
|
169
|
-
{ hasBulkActions &&
|
|
170
|
+
{ hasBulkActions && shouldRenderMedia && (
|
|
170
171
|
<DataViewsSelectionCheckbox
|
|
171
172
|
item={ item }
|
|
172
173
|
selection={ selection }
|
|
@@ -176,24 +177,35 @@ function GridItem< Item >( {
|
|
|
176
177
|
disabled={ ! hasBulkAction }
|
|
177
178
|
/>
|
|
178
179
|
) }
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
className="dataviews-view-grid__title-actions"
|
|
182
|
-
>
|
|
183
|
-
<ItemClickWrapper
|
|
184
|
-
item={ item }
|
|
185
|
-
isItemClickable={ isItemClickable }
|
|
186
|
-
onClickItem={ onClickItem }
|
|
187
|
-
renderItemLink={ renderItemLink }
|
|
188
|
-
className="dataviews-view-grid__title-field dataviews-title-field"
|
|
189
|
-
{ ...titleA11yProps }
|
|
190
|
-
>
|
|
191
|
-
{ renderedTitleField }
|
|
192
|
-
</ItemClickWrapper>
|
|
193
|
-
{ !! actions?.length && (
|
|
180
|
+
{ ! showTitle && shouldRenderMedia && !! actions?.length && (
|
|
181
|
+
<div className="dataviews-view-grid__media-actions">
|
|
194
182
|
<ItemActions item={ item } actions={ actions } isCompact />
|
|
195
|
-
|
|
196
|
-
|
|
183
|
+
</div>
|
|
184
|
+
) }
|
|
185
|
+
{ showTitle && (
|
|
186
|
+
<HStack
|
|
187
|
+
justify="space-between"
|
|
188
|
+
className="dataviews-view-grid__title-actions"
|
|
189
|
+
>
|
|
190
|
+
<ItemClickWrapper
|
|
191
|
+
item={ item }
|
|
192
|
+
isItemClickable={ isItemClickable }
|
|
193
|
+
onClickItem={ onClickItem }
|
|
194
|
+
renderItemLink={ renderItemLink }
|
|
195
|
+
className="dataviews-view-grid__title-field dataviews-title-field"
|
|
196
|
+
{ ...titleA11yProps }
|
|
197
|
+
>
|
|
198
|
+
{ renderedTitleField }
|
|
199
|
+
</ItemClickWrapper>
|
|
200
|
+
{ !! actions?.length && (
|
|
201
|
+
<ItemActions
|
|
202
|
+
item={ item }
|
|
203
|
+
actions={ actions }
|
|
204
|
+
isCompact
|
|
205
|
+
/>
|
|
206
|
+
) }
|
|
207
|
+
</HStack>
|
|
208
|
+
) }
|
|
197
209
|
<VStack spacing={ 1 }>
|
|
198
210
|
{ showDescription && descriptionField?.render && (
|
|
199
211
|
<descriptionField.render
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
padding: 0 $grid-unit-60 $grid-unit-30;
|
|
8
8
|
container-type: inline-size;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Match the padding applied to other DataViews components at the same
|
|
11
|
+
* max-width.
|
|
12
12
|
*/
|
|
13
|
-
@container (max-width:
|
|
13
|
+
@container (max-width: 430px) {
|
|
14
14
|
padding-left: $grid-unit-30;
|
|
15
15
|
padding-right: $grid-unit-30;
|
|
16
16
|
}
|
|
@@ -139,9 +139,15 @@
|
|
|
139
139
|
top: -9999em;
|
|
140
140
|
left: $grid-unit-10;
|
|
141
141
|
z-index: z-index(".dataviews-view-grid__card .dataviews-selection-checkbox");
|
|
142
|
+
opacity: 0;
|
|
143
|
+
|
|
144
|
+
@media not (prefers-reduced-motion) {
|
|
145
|
+
transition: opacity 0.1s linear;
|
|
146
|
+
}
|
|
142
147
|
|
|
143
148
|
@media (hover: none) {
|
|
144
149
|
// Show checkboxes on devices that do not support hover.
|
|
150
|
+
opacity: 1;
|
|
145
151
|
top: $grid-unit-10;
|
|
146
152
|
}
|
|
147
153
|
}
|
|
@@ -149,9 +155,37 @@
|
|
|
149
155
|
.dataviews-view-grid__card:hover .dataviews-selection-checkbox,
|
|
150
156
|
.dataviews-view-grid__card:focus-within .dataviews-selection-checkbox,
|
|
151
157
|
.dataviews-view-grid__card.is-selected .dataviews-selection-checkbox {
|
|
158
|
+
opacity: 1;
|
|
152
159
|
top: $grid-unit-10;
|
|
153
160
|
}
|
|
154
161
|
|
|
162
|
+
.dataviews-view-grid__card .dataviews-view-grid__media-actions {
|
|
163
|
+
position: absolute;
|
|
164
|
+
top: $grid-unit-05;
|
|
165
|
+
opacity: 0;
|
|
166
|
+
right: $grid-unit-05;
|
|
167
|
+
|
|
168
|
+
.dataviews-all-actions-button {
|
|
169
|
+
background-color: $white;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@media not (prefers-reduced-motion) {
|
|
173
|
+
transition: opacity 0.1s linear;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@media (hover: none) {
|
|
177
|
+
// Show actions on devices that do not support hover.
|
|
178
|
+
opacity: 1;
|
|
179
|
+
top: $grid-unit-05;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.dataviews-view-grid__card:hover .dataviews-view-grid__media-actions,
|
|
184
|
+
.dataviews-view-grid__card:focus-within .dataviews-view-grid__media-actions,
|
|
185
|
+
.dataviews-view-grid__card .dataviews-view-grid__media-actions:has(.dataviews-all-actions-button[aria-expanded="true"]) {
|
|
186
|
+
opacity: 1;
|
|
187
|
+
}
|
|
188
|
+
|
|
155
189
|
.dataviews-view-grid__media--clickable {
|
|
156
190
|
cursor: pointer;
|
|
157
191
|
}
|
|
@@ -162,4 +196,10 @@
|
|
|
162
196
|
color: $gray-900;
|
|
163
197
|
margin: 0 0 $grid-unit-10 0;
|
|
164
198
|
padding: 0 $grid-unit-60;
|
|
199
|
+
container-type: inline-size;
|
|
200
|
+
|
|
201
|
+
@container (max-width: 430px) {
|
|
202
|
+
padding-left: $grid-unit-30;
|
|
203
|
+
padding-right: $grid-unit-30;
|
|
204
|
+
}
|
|
165
205
|
}
|