@wordpress/dataviews 14.1.1-next.v.202604091042.0 → 14.2.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 +18 -1
- package/build/components/dataform-controls/array.cjs +2 -2
- package/build/components/dataform-controls/array.cjs.map +2 -2
- package/build/components/dataform-controls/date.cjs +16 -5
- package/build/components/dataform-controls/date.cjs.map +3 -3
- package/build/components/dataform-controls/datetime.cjs +6 -2
- package/build/components/dataform-controls/datetime.cjs.map +3 -3
- package/build/components/dataform-controls/utils/use-disabled-date-matchers.cjs +48 -0
- package/build/components/dataform-controls/utils/use-disabled-date-matchers.cjs.map +7 -0
- package/build/components/dataform-layouts/card/index.cjs.map +2 -2
- package/build/components/dataform-layouts/panel/summary-button.cjs +0 -1
- package/build/components/dataform-layouts/panel/summary-button.cjs.map +2 -2
- package/build/components/dataviews-context/index.cjs.map +1 -1
- package/build/components/dataviews-filters/search-widget.cjs +2 -7
- package/build/components/dataviews-filters/search-widget.cjs.map +2 -2
- package/build/components/dataviews-layouts/activity/activity-item.cjs +2 -3
- package/build/components/dataviews-layouts/activity/activity-item.cjs.map +2 -2
- package/build/components/dataviews-layouts/grid/composite-grid.cjs +2 -2
- package/build/components/dataviews-layouts/grid/composite-grid.cjs.map +2 -2
- package/build/components/dataviews-layouts/list/index.cjs +2 -2
- package/build/components/dataviews-layouts/list/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/picker-grid/index.cjs +3 -6
- package/build/components/dataviews-layouts/picker-grid/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/picker-table/index.cjs +15 -12
- package/build/components/dataviews-layouts/picker-table/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/table/index.cjs +0 -1
- package/build/components/dataviews-layouts/table/index.cjs.map +2 -2
- package/build/dataviews/index.cjs +10 -8
- package/build/dataviews/index.cjs.map +2 -2
- package/build/dataviews-picker/index.cjs +16 -9
- package/build/dataviews-picker/index.cjs.map +2 -2
- package/build/field-types/date.cjs +4 -1
- package/build/field-types/date.cjs.map +2 -2
- package/build/field-types/datetime.cjs +4 -1
- package/build/field-types/datetime.cjs.map +2 -2
- package/build/field-types/utils/get-is-valid.cjs +29 -24
- package/build/field-types/utils/get-is-valid.cjs.map +2 -2
- package/build/field-types/utils/is-valid-date-boundary.cjs +64 -0
- package/build/field-types/utils/is-valid-date-boundary.cjs.map +7 -0
- package/build/types/dataviews.cjs.map +1 -1
- package/build/types/field-api.cjs.map +1 -1
- package/build-module/components/dataform-controls/array.mjs +2 -2
- package/build-module/components/dataform-controls/array.mjs.map +2 -2
- package/build-module/components/dataform-controls/date.mjs +16 -5
- package/build-module/components/dataform-controls/date.mjs.map +2 -2
- package/build-module/components/dataform-controls/datetime.mjs +6 -2
- package/build-module/components/dataform-controls/datetime.mjs.map +2 -2
- package/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs +27 -0
- package/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs.map +7 -0
- package/build-module/components/dataform-layouts/card/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/summary-button.mjs +0 -1
- package/build-module/components/dataform-layouts/panel/summary-button.mjs.map +2 -2
- package/build-module/components/dataviews-context/index.mjs.map +1 -1
- package/build-module/components/dataviews-filters/search-widget.mjs +3 -13
- package/build-module/components/dataviews-filters/search-widget.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/activity/activity-item.mjs +2 -3
- package/build-module/components/dataviews-layouts/activity/activity-item.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs +2 -2
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/list/index.mjs +2 -3
- package/build-module/components/dataviews-layouts/list/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/picker-grid/index.mjs +3 -6
- package/build-module/components/dataviews-layouts/picker-grid/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/picker-table/index.mjs +15 -12
- package/build-module/components/dataviews-layouts/picker-table/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/table/index.mjs +0 -1
- package/build-module/components/dataviews-layouts/table/index.mjs.map +2 -2
- package/build-module/dataviews/index.mjs +10 -8
- package/build-module/dataviews/index.mjs.map +2 -2
- package/build-module/dataviews-picker/index.mjs +16 -9
- package/build-module/dataviews-picker/index.mjs.map +2 -2
- package/build-module/field-types/date.mjs +4 -1
- package/build-module/field-types/date.mjs.map +2 -2
- package/build-module/field-types/datetime.mjs +4 -1
- package/build-module/field-types/datetime.mjs.map +2 -2
- package/build-module/field-types/utils/get-is-valid.mjs +29 -24
- package/build-module/field-types/utils/get-is-valid.mjs.map +2 -2
- package/build-module/field-types/utils/is-valid-date-boundary.mjs +38 -0
- package/build-module/field-types/utils/is-valid-date-boundary.mjs.map +7 -0
- package/build-style/style-rtl.css +12 -13
- package/build-style/style.css +12 -13
- package/build-types/components/dataform-controls/array.d.ts.map +1 -1
- package/build-types/components/dataform-controls/date.d.ts.map +1 -1
- package/build-types/components/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/components/dataform-controls/utils/use-disabled-date-matchers.d.ts +16 -0
- package/build-types/components/dataform-controls/utils/use-disabled-date-matchers.d.ts.map +1 -0
- package/build-types/components/dataform-layouts/card/index.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/summary-button.d.ts.map +1 -1
- package/build-types/components/dataviews-context/index.d.ts +2 -2
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/activity/activity-item.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/list/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/picker-grid/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/picker-table/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/table/index.d.ts.map +1 -1
- package/build-types/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/dataform/stories/layout-regular.d.ts.map +1 -1
- package/build-types/dataform/stories/validation.d.ts.map +1 -1
- package/build-types/dataviews/index.d.ts +1 -1
- package/build-types/dataviews/index.d.ts.map +1 -1
- package/build-types/dataviews/stories/free-composition.d.ts.map +1 -1
- package/build-types/dataviews/stories/index.story.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-activity.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-grid.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-list.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-table.d.ts.map +1 -1
- package/build-types/dataviews/stories/with-card.d.ts.map +1 -1
- package/build-types/dataviews-picker/index.d.ts +3 -2
- package/build-types/dataviews-picker/index.d.ts.map +1 -1
- package/build-types/dataviews-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/field-types/date.d.ts +3 -0
- package/build-types/field-types/date.d.ts.map +1 -1
- package/build-types/field-types/datetime.d.ts +3 -0
- package/build-types/field-types/datetime.d.ts.map +1 -1
- package/build-types/field-types/utils/get-is-valid.d.ts.map +1 -1
- package/build-types/field-types/utils/is-valid-date-boundary.d.ts +7 -0
- package/build-types/field-types/utils/is-valid-date-boundary.d.ts.map +1 -0
- package/build-types/types/dataviews.d.ts +8 -0
- package/build-types/types/dataviews.d.ts.map +1 -1
- package/build-types/types/field-api.d.ts +11 -9
- package/build-types/types/field-api.d.ts.map +1 -1
- package/build-wp/index.js +1173 -1017
- package/package.json +16 -16
- package/src/components/dataform-controls/array.tsx +3 -2
- package/src/components/dataform-controls/date.tsx +17 -2
- package/src/components/dataform-controls/datetime.tsx +15 -1
- package/src/components/dataform-controls/utils/use-disabled-date-matchers.ts +48 -0
- package/src/components/dataform-layouts/card/index.tsx +0 -3
- package/src/components/dataform-layouts/panel/style.scss +4 -5
- package/src/components/dataform-layouts/panel/summary-button.tsx +0 -1
- package/src/components/dataviews-context/index.ts +2 -2
- package/src/components/dataviews-filters/search-widget.tsx +4 -14
- package/src/components/dataviews-filters/style.scss +2 -2
- package/src/components/dataviews-layouts/activity/activity-item.tsx +2 -3
- package/src/components/dataviews-layouts/activity/style.scss +1 -1
- package/src/components/dataviews-layouts/grid/composite-grid.tsx +3 -3
- package/src/components/dataviews-layouts/grid/style.scss +1 -1
- package/src/components/dataviews-layouts/list/index.tsx +2 -3
- package/src/components/dataviews-layouts/list/style.scss +1 -1
- package/src/components/dataviews-layouts/picker-grid/index.tsx +5 -9
- package/src/components/dataviews-layouts/picker-grid/style.scss +1 -1
- package/src/components/dataviews-layouts/picker-table/index.tsx +9 -7
- package/src/components/dataviews-layouts/picker-table/style.scss +1 -1
- package/src/components/dataviews-layouts/table/index.tsx +0 -2
- package/src/dataform/stories/content.story.tsx +1 -1
- package/src/dataform/stories/data-adapter.tsx +6 -6
- package/src/dataform/stories/layout-card.tsx +8 -8
- package/src/dataform/stories/layout-details.tsx +5 -5
- package/src/dataform/stories/layout-panel.tsx +9 -9
- package/src/dataform/stories/layout-regular.tsx +16 -9
- package/src/dataform/stories/layout-row.tsx +9 -9
- package/src/dataform/stories/validation.tsx +25 -10
- package/src/dataviews/index.tsx +11 -7
- package/src/dataviews/stories/empty.tsx +6 -6
- package/src/dataviews/stories/fixtures.tsx +2 -2
- package/src/dataviews/stories/free-composition.tsx +10 -13
- package/src/dataviews/stories/infinite-scroll.tsx +4 -4
- package/src/dataviews/stories/layout-activity.tsx +7 -9
- package/src/dataviews/stories/layout-custom.tsx +1 -1
- package/src/dataviews/stories/layout-grid.tsx +5 -7
- package/src/dataviews/stories/layout-list.tsx +6 -8
- package/src/dataviews/stories/layout-table.tsx +5 -7
- package/src/dataviews/stories/minimal-ui.tsx +1 -1
- package/src/dataviews/stories/with-card.tsx +4 -7
- package/src/dataviews/style.scss +1 -1
- package/src/dataviews/test/dataviews.tsx +73 -6
- package/src/dataviews-picker/index.tsx +17 -7
- package/src/dataviews-picker/stories/index.story.tsx +1 -5
- package/src/dataviews-picker/test/dataviews-picker.tsx +79 -2
- package/src/field-types/date.tsx +3 -0
- package/src/field-types/datetime.tsx +3 -0
- package/src/field-types/stories/index.story.tsx +1 -1
- package/src/field-types/test/normalize-fields.ts +44 -0
- package/src/field-types/utils/get-is-valid.ts +44 -31
- package/src/field-types/utils/is-valid-date-boundary.ts +80 -0
- package/src/hooks/test/use-form-validity.ts +479 -0
- package/src/types/dataviews.ts +9 -0
- package/src/types/field-api.ts +11 -9
|
@@ -54,17 +54,17 @@ const DataAdapterComponent = () => {
|
|
|
54
54
|
// for nested data based on the field id.
|
|
55
55
|
{
|
|
56
56
|
id: 'user.profile.name',
|
|
57
|
-
label: 'User
|
|
57
|
+
label: 'User name',
|
|
58
58
|
type: 'text',
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
id: 'user.profile.email',
|
|
62
|
-
label: 'User
|
|
62
|
+
label: 'User email',
|
|
63
63
|
type: 'email',
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
id: 'user.profile.tags',
|
|
67
|
-
label: 'User
|
|
67
|
+
label: 'User tags',
|
|
68
68
|
type: 'array',
|
|
69
69
|
placeholder: 'Enter comma-separated tags',
|
|
70
70
|
description:
|
|
@@ -101,13 +101,13 @@ const DataAdapterComponent = () => {
|
|
|
101
101
|
// Example of deriving data by leveraging setValue method.
|
|
102
102
|
{
|
|
103
103
|
id: 'revenue.total',
|
|
104
|
-
label: 'Total
|
|
104
|
+
label: 'Total revenue',
|
|
105
105
|
type: 'integer',
|
|
106
106
|
readOnly: true,
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
id: 'revenue.pricePerUnit',
|
|
110
|
-
label: 'Price
|
|
110
|
+
label: 'Price per unit',
|
|
111
111
|
type: 'integer',
|
|
112
112
|
setValue: ( { item, value } ) => ( {
|
|
113
113
|
revenue: {
|
|
@@ -174,7 +174,7 @@ const DataAdapterComponent = () => {
|
|
|
174
174
|
fields: [
|
|
175
175
|
{
|
|
176
176
|
id: 'userProfile',
|
|
177
|
-
label: 'User
|
|
177
|
+
label: 'User profile',
|
|
178
178
|
children: [
|
|
179
179
|
'user.profile.name',
|
|
180
180
|
'user.profile.email',
|
|
@@ -11,7 +11,7 @@ import DataForm from '../index';
|
|
|
11
11
|
import type { Field, Form } from '../../types';
|
|
12
12
|
import { unlock } from '../../lock-unlock';
|
|
13
13
|
|
|
14
|
-
const { Badge } = unlock( privateApis );
|
|
14
|
+
const { Badge: WCBadge } = unlock( privateApis );
|
|
15
15
|
|
|
16
16
|
const LayoutCardComponent = ( {
|
|
17
17
|
withHeader,
|
|
@@ -44,7 +44,7 @@ const LayoutCardComponent = ( {
|
|
|
44
44
|
const customerFields: Field< Customer >[] = [
|
|
45
45
|
{
|
|
46
46
|
id: 'name',
|
|
47
|
-
label: 'Customer
|
|
47
|
+
label: 'Customer name',
|
|
48
48
|
type: 'text',
|
|
49
49
|
},
|
|
50
50
|
{
|
|
@@ -70,17 +70,17 @@ const LayoutCardComponent = ( {
|
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
id: 'shippingAddress',
|
|
73
|
-
label: 'Shipping
|
|
73
|
+
label: 'Shipping address',
|
|
74
74
|
type: 'text',
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
id: 'billingAddress',
|
|
78
|
-
label: 'Billing
|
|
78
|
+
label: 'Billing address',
|
|
79
79
|
type: 'text',
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
id: 'displayPayments',
|
|
83
|
-
label: 'Display
|
|
83
|
+
label: 'Display payments?',
|
|
84
84
|
type: 'boolean',
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -112,10 +112,10 @@ const LayoutCardComponent = ( {
|
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
id: 'dueDate',
|
|
115
|
-
label: 'Due
|
|
115
|
+
label: 'Due date',
|
|
116
116
|
type: 'text',
|
|
117
117
|
render: ( { item } ) => {
|
|
118
|
-
return <
|
|
118
|
+
return <WCBadge>Due on: { item.dueDate }</WCBadge>;
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
121
|
{
|
|
@@ -123,7 +123,7 @@ const LayoutCardComponent = ( {
|
|
|
123
123
|
type: 'text',
|
|
124
124
|
readOnly: true,
|
|
125
125
|
render: ( { item } ) => {
|
|
126
|
-
return <
|
|
126
|
+
return <WCBadge>{ item.plan }</WCBadge>;
|
|
127
127
|
},
|
|
128
128
|
},
|
|
129
129
|
];
|
|
@@ -123,7 +123,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
id: 'filesize',
|
|
126
|
-
label: 'File
|
|
126
|
+
label: 'File size',
|
|
127
127
|
type: 'integer',
|
|
128
128
|
readOnly: true,
|
|
129
129
|
},
|
|
@@ -170,7 +170,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
id: 'longDescription',
|
|
173
|
-
label: 'Long
|
|
173
|
+
label: 'Long description',
|
|
174
174
|
type: 'text',
|
|
175
175
|
Edit: {
|
|
176
176
|
control: 'textarea',
|
|
@@ -179,7 +179,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
id: 'comment_status',
|
|
182
|
-
label: 'Comment
|
|
182
|
+
label: 'Comment status',
|
|
183
183
|
type: 'text',
|
|
184
184
|
Edit: 'radio',
|
|
185
185
|
elements: [
|
|
@@ -189,7 +189,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
189
189
|
},
|
|
190
190
|
{
|
|
191
191
|
id: 'ping_status',
|
|
192
|
-
label: 'Allow
|
|
192
|
+
label: 'Allow pings/trackbacks',
|
|
193
193
|
type: 'boolean',
|
|
194
194
|
},
|
|
195
195
|
{
|
|
@@ -223,7 +223,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
225
|
id: 'flight_status',
|
|
226
|
-
label: 'Flight
|
|
226
|
+
label: 'Flight status',
|
|
227
227
|
type: 'text',
|
|
228
228
|
Edit: 'radio',
|
|
229
229
|
elements: [
|
|
@@ -133,7 +133,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
id: 'filesize',
|
|
136
|
-
label: 'File
|
|
136
|
+
label: 'File size',
|
|
137
137
|
type: 'integer',
|
|
138
138
|
readOnly: true,
|
|
139
139
|
},
|
|
@@ -180,7 +180,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
182
|
id: 'longDescription',
|
|
183
|
-
label: 'Long
|
|
183
|
+
label: 'Long description',
|
|
184
184
|
type: 'text',
|
|
185
185
|
Edit: {
|
|
186
186
|
control: 'textarea',
|
|
@@ -189,7 +189,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
189
189
|
},
|
|
190
190
|
{
|
|
191
191
|
id: 'comment_status',
|
|
192
|
-
label: 'Comment
|
|
192
|
+
label: 'Comment status',
|
|
193
193
|
type: 'text',
|
|
194
194
|
Edit: 'radio',
|
|
195
195
|
elements: [
|
|
@@ -199,7 +199,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
199
199
|
},
|
|
200
200
|
{
|
|
201
201
|
id: 'ping_status',
|
|
202
|
-
label: 'Allow
|
|
202
|
+
label: 'Allow pings/trackbacks',
|
|
203
203
|
type: 'boolean',
|
|
204
204
|
},
|
|
205
205
|
{
|
|
@@ -233,7 +233,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
id: 'flight_status',
|
|
236
|
-
label: 'Flight
|
|
236
|
+
label: 'Flight status',
|
|
237
237
|
type: 'text',
|
|
238
238
|
Edit: 'radio',
|
|
239
239
|
elements: [
|
|
@@ -360,7 +360,7 @@ const LayoutPanelComponent = ( {
|
|
|
360
360
|
'title',
|
|
361
361
|
{
|
|
362
362
|
id: 'status',
|
|
363
|
-
label: 'Status &
|
|
363
|
+
label: 'Status & visibility',
|
|
364
364
|
children: [ 'status', 'password' ],
|
|
365
365
|
},
|
|
366
366
|
'order',
|
|
@@ -375,12 +375,12 @@ const LayoutPanelComponent = ( {
|
|
|
375
375
|
},
|
|
376
376
|
{
|
|
377
377
|
id: 'address1',
|
|
378
|
-
label: 'Combined
|
|
378
|
+
label: 'Combined address',
|
|
379
379
|
children: [ 'address1', 'address2', 'city' ],
|
|
380
380
|
},
|
|
381
381
|
{
|
|
382
382
|
id: 'flight_info',
|
|
383
|
-
label: 'Flight
|
|
383
|
+
label: 'Flight information',
|
|
384
384
|
children: [
|
|
385
385
|
'origin',
|
|
386
386
|
'destination',
|
|
@@ -396,7 +396,7 @@ const LayoutPanelComponent = ( {
|
|
|
396
396
|
},
|
|
397
397
|
{
|
|
398
398
|
id: 'passenger_details',
|
|
399
|
-
label: 'Passenger
|
|
399
|
+
label: 'Passenger details',
|
|
400
400
|
children: [ 'author', 'seat' ],
|
|
401
401
|
layout: getPanelLayoutFromStoryArgs( {
|
|
402
402
|
summary: [ 'author', 'seat' ],
|
|
@@ -55,11 +55,16 @@ const fields: Field< SamplePost >[] = [
|
|
|
55
55
|
{
|
|
56
56
|
id: 'date',
|
|
57
57
|
label: 'Date',
|
|
58
|
+
type: 'date',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'datetime',
|
|
62
|
+
label: 'DateTime',
|
|
58
63
|
type: 'datetime',
|
|
59
64
|
},
|
|
60
65
|
{
|
|
61
66
|
id: 'birthdate',
|
|
62
|
-
label: '
|
|
67
|
+
label: 'DateTime as options',
|
|
63
68
|
type: 'datetime',
|
|
64
69
|
elements: [
|
|
65
70
|
{ value: '', label: 'Select a date' },
|
|
@@ -126,11 +131,11 @@ const fields: Field< SamplePost >[] = [
|
|
|
126
131
|
id: 'can_comment',
|
|
127
132
|
label: 'Allow people to leave a comment',
|
|
128
133
|
type: 'boolean',
|
|
129
|
-
Edit: '
|
|
134
|
+
Edit: 'toggle',
|
|
130
135
|
},
|
|
131
136
|
{
|
|
132
137
|
id: 'filesize',
|
|
133
|
-
label: 'File
|
|
138
|
+
label: 'File size',
|
|
134
139
|
type: 'integer',
|
|
135
140
|
readOnly: true,
|
|
136
141
|
},
|
|
@@ -177,7 +182,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
177
182
|
},
|
|
178
183
|
{
|
|
179
184
|
id: 'longDescription',
|
|
180
|
-
label: 'Long
|
|
185
|
+
label: 'Long description',
|
|
181
186
|
type: 'text',
|
|
182
187
|
Edit: {
|
|
183
188
|
control: 'textarea',
|
|
@@ -186,7 +191,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
186
191
|
},
|
|
187
192
|
{
|
|
188
193
|
id: 'comment_status',
|
|
189
|
-
label: 'Comment
|
|
194
|
+
label: 'Comment status',
|
|
190
195
|
type: 'text',
|
|
191
196
|
Edit: 'radio',
|
|
192
197
|
elements: [
|
|
@@ -196,7 +201,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
196
201
|
},
|
|
197
202
|
{
|
|
198
203
|
id: 'ping_status',
|
|
199
|
-
label: 'Allow
|
|
204
|
+
label: 'Allow pings/trackbacks',
|
|
200
205
|
type: 'boolean',
|
|
201
206
|
},
|
|
202
207
|
{
|
|
@@ -230,7 +235,7 @@ const fields: Field< SamplePost >[] = [
|
|
|
230
235
|
},
|
|
231
236
|
{
|
|
232
237
|
id: 'flight_status',
|
|
233
|
-
label: 'Flight
|
|
238
|
+
label: 'Flight status',
|
|
234
239
|
type: 'text',
|
|
235
240
|
Edit: 'radio',
|
|
236
241
|
elements: [
|
|
@@ -324,7 +329,8 @@ const LayoutRegularComponent = ( {
|
|
|
324
329
|
status: 'draft',
|
|
325
330
|
reviewer: 'fulano',
|
|
326
331
|
email: 'hello@wordpress.org',
|
|
327
|
-
date: '2021-01-
|
|
332
|
+
date: '2021-01-01',
|
|
333
|
+
datetime: '2021-01-01T12:00:00',
|
|
328
334
|
birthdate: '1950-02-23T12:00:00',
|
|
329
335
|
sticky: false,
|
|
330
336
|
can_comment: false,
|
|
@@ -356,14 +362,15 @@ const LayoutRegularComponent = ( {
|
|
|
356
362
|
'title',
|
|
357
363
|
'order',
|
|
358
364
|
'sticky',
|
|
365
|
+
'can_comment',
|
|
359
366
|
'author',
|
|
360
367
|
'status',
|
|
361
368
|
'reviewer',
|
|
362
369
|
'email',
|
|
363
370
|
'password',
|
|
364
371
|
'date',
|
|
372
|
+
'datetime',
|
|
365
373
|
'birthdate',
|
|
366
|
-
'can_comment',
|
|
367
374
|
'filesize',
|
|
368
375
|
'dimensions',
|
|
369
376
|
'tags',
|
|
@@ -42,7 +42,7 @@ const LayoutRowComponent = ( {
|
|
|
42
42
|
const customerFields: Field< Customer >[] = [
|
|
43
43
|
{
|
|
44
44
|
id: 'name',
|
|
45
|
-
label: 'Customer
|
|
45
|
+
label: 'Customer name',
|
|
46
46
|
type: 'text',
|
|
47
47
|
},
|
|
48
48
|
{
|
|
@@ -57,37 +57,37 @@ const LayoutRowComponent = ( {
|
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
id: 'shippingAddress',
|
|
60
|
-
label: 'Shipping
|
|
60
|
+
label: 'Shipping address',
|
|
61
61
|
type: 'text',
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
id: 'shippingCity',
|
|
65
|
-
label: 'Shipping
|
|
65
|
+
label: 'Shipping city',
|
|
66
66
|
type: 'text',
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
id: 'shippingPostalCode',
|
|
70
|
-
label: 'Shipping
|
|
70
|
+
label: 'Shipping postal code',
|
|
71
71
|
type: 'text',
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
id: 'shippingCountry',
|
|
75
|
-
label: 'Shipping
|
|
75
|
+
label: 'Shipping country',
|
|
76
76
|
type: 'text',
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
id: 'billingAddress',
|
|
80
|
-
label: 'Billing
|
|
80
|
+
label: 'Billing address',
|
|
81
81
|
type: 'text',
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
id: 'billingCity',
|
|
85
|
-
label: 'Billing
|
|
85
|
+
label: 'Billing city',
|
|
86
86
|
type: 'text',
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
89
|
id: 'billingPostalCode',
|
|
90
|
-
label: 'Billing
|
|
90
|
+
label: 'Billing postal code',
|
|
91
91
|
type: 'text',
|
|
92
92
|
},
|
|
93
93
|
{
|
|
@@ -102,7 +102,7 @@ const LayoutRowComponent = ( {
|
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
id: 'hasDiscount',
|
|
105
|
-
label: 'Has
|
|
105
|
+
label: 'Has discount?',
|
|
106
106
|
type: 'boolean',
|
|
107
107
|
},
|
|
108
108
|
{
|
|
@@ -739,7 +739,7 @@ const ValidationComponent = ( {
|
|
|
739
739
|
},
|
|
740
740
|
{
|
|
741
741
|
id: 'customEdit',
|
|
742
|
-
label: 'Custom
|
|
742
|
+
label: 'Custom control',
|
|
743
743
|
Edit: CustomEditControl,
|
|
744
744
|
isValid: {
|
|
745
745
|
required,
|
|
@@ -783,7 +783,7 @@ const ValidationComponent = ( {
|
|
|
783
783
|
{
|
|
784
784
|
id: 'toggleGroup',
|
|
785
785
|
type: 'text',
|
|
786
|
-
label: 'Toggle
|
|
786
|
+
label: 'Toggle group',
|
|
787
787
|
Edit: 'toggleGroup',
|
|
788
788
|
elements:
|
|
789
789
|
elements === 'async'
|
|
@@ -849,31 +849,46 @@ const ValidationComponent = ( {
|
|
|
849
849
|
id: 'date',
|
|
850
850
|
type: 'date',
|
|
851
851
|
label: 'Date',
|
|
852
|
+
description: minMax
|
|
853
|
+
? 'Must be between Apr 1 and Apr 20, 2026'
|
|
854
|
+
: undefined,
|
|
852
855
|
isValid: {
|
|
853
856
|
required,
|
|
854
857
|
elements: elements !== 'none' ? true : false,
|
|
855
858
|
custom: maybeCustomRule( customDateRule ),
|
|
859
|
+
min: minMax ? '2026-04-01' : undefined,
|
|
860
|
+
max: minMax ? '2026-04-20' : undefined,
|
|
856
861
|
},
|
|
857
862
|
},
|
|
858
863
|
{
|
|
859
864
|
id: 'dateRange',
|
|
860
865
|
type: 'date',
|
|
861
|
-
label: 'Date
|
|
866
|
+
label: 'Date range',
|
|
862
867
|
Edit: DateRangeEdit,
|
|
868
|
+
description: minMax
|
|
869
|
+
? 'Must be between Apr 1 and Apr 20, 2026'
|
|
870
|
+
: undefined,
|
|
863
871
|
isValid: {
|
|
864
872
|
required,
|
|
865
873
|
elements: elements !== 'none' ? true : false,
|
|
866
874
|
custom: maybeCustomRule( customDateRangeRule ),
|
|
875
|
+
min: minMax ? '2026-04-01' : undefined,
|
|
876
|
+
max: minMax ? '2026-04-20' : undefined,
|
|
867
877
|
},
|
|
868
878
|
},
|
|
869
879
|
{
|
|
870
880
|
id: 'datetime',
|
|
871
881
|
type: 'datetime',
|
|
872
|
-
label: 'Date
|
|
882
|
+
label: 'Date time',
|
|
883
|
+
description: minMax
|
|
884
|
+
? 'Must be between Apr 1 and Apr 20, 2026'
|
|
885
|
+
: undefined,
|
|
873
886
|
isValid: {
|
|
874
887
|
required,
|
|
875
888
|
elements: elements !== 'none' ? true : false,
|
|
876
889
|
custom: maybeCustomRule( customDateTimeRule ),
|
|
890
|
+
min: minMax ? '2026-04-01T00:00:00.000Z' : undefined,
|
|
891
|
+
max: minMax ? '2026-04-20T23:59:59.000Z' : undefined,
|
|
877
892
|
},
|
|
878
893
|
},
|
|
879
894
|
];
|
|
@@ -947,34 +962,34 @@ const ValidationComponent = ( {
|
|
|
947
962
|
const groupedFields = [
|
|
948
963
|
{
|
|
949
964
|
id: 'textFields',
|
|
950
|
-
label: 'Text
|
|
965
|
+
label: 'Text fields',
|
|
951
966
|
children: [ 'text', 'textarea', 'password', 'customEdit' ],
|
|
952
967
|
},
|
|
953
968
|
{
|
|
954
969
|
id: 'numberFields',
|
|
955
|
-
label: 'Number
|
|
970
|
+
label: 'Number fields',
|
|
956
971
|
children: [ 'integer', 'number' ],
|
|
957
972
|
},
|
|
958
973
|
{
|
|
959
974
|
id: 'contactFields',
|
|
960
|
-
label: 'Contact
|
|
975
|
+
label: 'Contact fields',
|
|
961
976
|
children: [ 'email', 'telephone', 'url' ],
|
|
962
977
|
},
|
|
963
978
|
{
|
|
964
979
|
id: 'selectFields',
|
|
965
|
-
label: 'Selection
|
|
980
|
+
label: 'Selection fields',
|
|
966
981
|
children: [ 'select', 'combobox', 'textWithRadio' ],
|
|
967
982
|
},
|
|
968
983
|
{
|
|
969
984
|
id: 'booleanFields',
|
|
970
|
-
label: 'Boolean
|
|
985
|
+
label: 'Boolean fields',
|
|
971
986
|
children: [ 'boolean', 'toggle', 'toggleGroup' ],
|
|
972
987
|
},
|
|
973
988
|
{ id: 'color' },
|
|
974
989
|
{ id: 'array' },
|
|
975
990
|
{
|
|
976
991
|
id: 'dateFields',
|
|
977
|
-
label: 'Date
|
|
992
|
+
label: 'Date fields',
|
|
978
993
|
children: [ 'date', 'dateRange', 'datetime' ],
|
|
979
994
|
},
|
|
980
995
|
];
|
package/src/dataviews/index.tsx
CHANGED
|
@@ -57,7 +57,7 @@ type DataViewsProps< Item > = {
|
|
|
57
57
|
totalItems: number;
|
|
58
58
|
totalPages: number;
|
|
59
59
|
};
|
|
60
|
-
defaultLayouts
|
|
60
|
+
defaultLayouts?: SupportedLayouts;
|
|
61
61
|
selection?: string[];
|
|
62
62
|
onChangeSelection?: ( items: string[] ) => void;
|
|
63
63
|
onClickItem?: ( item: Item ) => void;
|
|
@@ -82,6 +82,7 @@ type DataViewsProps< Item > = {
|
|
|
82
82
|
const defaultGetItemId = ( item: ItemWithId ) => item.id;
|
|
83
83
|
const defaultIsItemClickable = () => true;
|
|
84
84
|
const EMPTY_ARRAY: any[] = [];
|
|
85
|
+
const DEFAULT_LAYOUTS: SupportedLayouts = { table: {}, grid: {}, list: {} };
|
|
85
86
|
|
|
86
87
|
const dataViewsLayouts = VIEW_LAYOUTS.filter(
|
|
87
88
|
( viewLayout ) => ! viewLayout.isPicker
|
|
@@ -144,7 +145,7 @@ function DataViews< Item >( {
|
|
|
144
145
|
getItemLevel,
|
|
145
146
|
isLoading = false,
|
|
146
147
|
paginationInfo,
|
|
147
|
-
defaultLayouts: defaultLayoutsProperty,
|
|
148
|
+
defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
|
|
148
149
|
selection: selectionProperty,
|
|
149
150
|
onChangeSelection,
|
|
150
151
|
onClickItem,
|
|
@@ -241,17 +242,20 @@ function DataViews< Item >( {
|
|
|
241
242
|
}
|
|
242
243
|
}, [ hasPrimaryOrLockedFilters, isShowingFilter ] );
|
|
243
244
|
|
|
244
|
-
// Filter out DataViewsPicker layouts
|
|
245
|
+
// Filter out DataViewsPicker layouts and normalize `true` to `{}`.
|
|
245
246
|
const defaultLayouts = useMemo(
|
|
246
247
|
() =>
|
|
247
248
|
Object.fromEntries(
|
|
248
|
-
Object.entries( defaultLayoutsProperty )
|
|
249
|
-
( [ layoutType ] ) => {
|
|
249
|
+
Object.entries( defaultLayoutsProperty )
|
|
250
|
+
.filter( ( [ layoutType ] ) => {
|
|
250
251
|
return dataViewsLayouts.some(
|
|
251
252
|
( viewLayout ) => viewLayout.type === layoutType
|
|
252
253
|
);
|
|
253
|
-
}
|
|
254
|
-
|
|
254
|
+
} )
|
|
255
|
+
.map( ( [ key, value ] ) => [
|
|
256
|
+
key,
|
|
257
|
+
value === true ? {} : value,
|
|
258
|
+
] )
|
|
255
259
|
),
|
|
256
260
|
[ defaultLayoutsProperty ]
|
|
257
261
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useState } from '@wordpress/element';
|
|
5
|
-
import { __experimentalText as
|
|
5
|
+
import { __experimentalText as WCText } from '@wordpress/components';
|
|
6
6
|
import { Stack } from '@wordpress/ui';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -41,7 +41,7 @@ const PlanetIllustration = () => (
|
|
|
41
41
|
const CustomEmptyComponent = () => (
|
|
42
42
|
<Stack direction="column" align="center" justify="center" gap="md">
|
|
43
43
|
<PlanetIllustration />
|
|
44
|
-
<
|
|
44
|
+
<WCText>No celestial bodies found</WCText>
|
|
45
45
|
</Stack>
|
|
46
46
|
);
|
|
47
47
|
|
|
@@ -79,10 +79,10 @@ const EmptyComponent = ( {
|
|
|
79
79
|
onChangeView={ setView }
|
|
80
80
|
actions={ actions }
|
|
81
81
|
defaultLayouts={ {
|
|
82
|
-
[ LAYOUT_TABLE ]:
|
|
83
|
-
[ LAYOUT_GRID ]:
|
|
84
|
-
[ LAYOUT_LIST ]:
|
|
85
|
-
[ LAYOUT_ACTIVITY ]:
|
|
82
|
+
[ LAYOUT_TABLE ]: true,
|
|
83
|
+
[ LAYOUT_GRID ]: true,
|
|
84
|
+
[ LAYOUT_LIST ]: true,
|
|
85
|
+
[ LAYOUT_ACTIVITY ]: true,
|
|
86
86
|
} }
|
|
87
87
|
isLoading={ isLoading }
|
|
88
88
|
empty={ customEmpty ? <CustomEmptyComponent /> : undefined }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { trash, image, Icon, category } from '@wordpress/icons';
|
|
5
|
-
import { Button, __experimentalText as
|
|
5
|
+
import { Button, __experimentalText as WCText } from '@wordpress/components';
|
|
6
6
|
import { Stack } from '@wordpress/ui';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -642,7 +642,7 @@ export const actions: Action< SpaceObject >[] = [
|
|
|
642
642
|
: `Are you sure you want to delete "${ items[ 0 ].name.title }"?`;
|
|
643
643
|
return (
|
|
644
644
|
<Stack direction="column" gap="xl">
|
|
645
|
-
<
|
|
645
|
+
<WCText>{ label }</WCText>
|
|
646
646
|
<Stack direction="row" gap="sm" justify="right">
|
|
647
647
|
<Button
|
|
648
648
|
__next40pxDefaultSize
|
|
@@ -8,13 +8,10 @@ import {
|
|
|
8
8
|
} from '@wordpress/element';
|
|
9
9
|
import {
|
|
10
10
|
__experimentalHeading as Heading,
|
|
11
|
-
__experimentalText as
|
|
11
|
+
__experimentalText as WCText,
|
|
12
12
|
Button,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { __, _n } from '@wordpress/i18n';
|
|
15
|
-
// TODO: enable in the ESlint rule once we complete
|
|
16
|
-
// https://github.com/WordPress/gutenberg/issues/76135.
|
|
17
|
-
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
18
15
|
import { Card, Stack } from '@wordpress/ui';
|
|
19
16
|
|
|
20
17
|
/**
|
|
@@ -56,7 +53,7 @@ function PlanetOverview( { planets }: { planets: SpaceObject[] } ) {
|
|
|
56
53
|
<Card.Root>
|
|
57
54
|
<Card.Content>
|
|
58
55
|
<Stack direction="column" gap="sm">
|
|
59
|
-
<
|
|
56
|
+
<WCText size={ 18 } as="p">
|
|
60
57
|
{ createInterpolateElement(
|
|
61
58
|
_n(
|
|
62
59
|
'<PlanetsNumber /> planet',
|
|
@@ -71,9 +68,9 @@ function PlanetOverview( { planets }: { planets: SpaceObject[] } ) {
|
|
|
71
68
|
),
|
|
72
69
|
}
|
|
73
70
|
) }
|
|
74
|
-
</
|
|
71
|
+
</WCText>
|
|
75
72
|
|
|
76
|
-
<
|
|
73
|
+
<WCText size={ 18 } as="p">
|
|
77
74
|
{ createInterpolateElement(
|
|
78
75
|
_n(
|
|
79
76
|
'<SatellitesNumber /> moon',
|
|
@@ -86,7 +83,7 @@ function PlanetOverview( { planets }: { planets: SpaceObject[] } ) {
|
|
|
86
83
|
),
|
|
87
84
|
}
|
|
88
85
|
) }
|
|
89
|
-
</
|
|
86
|
+
</WCText>
|
|
90
87
|
</Stack>
|
|
91
88
|
</Card.Content>
|
|
92
89
|
</Card.Root>
|
|
@@ -162,8 +159,8 @@ export const FreeCompositionComponent = () => {
|
|
|
162
159
|
actions={ actions }
|
|
163
160
|
onChangeView={ setView }
|
|
164
161
|
defaultLayouts={ {
|
|
165
|
-
table:
|
|
166
|
-
grid:
|
|
162
|
+
table: true,
|
|
163
|
+
grid: true,
|
|
167
164
|
} }
|
|
168
165
|
empty={
|
|
169
166
|
<Stack
|
|
@@ -173,10 +170,10 @@ export const FreeCompositionComponent = () => {
|
|
|
173
170
|
align="center"
|
|
174
171
|
className="free-composition-dataviews-empty"
|
|
175
172
|
>
|
|
176
|
-
<
|
|
173
|
+
<WCText size={ 18 } as="p">
|
|
177
174
|
No planets
|
|
178
|
-
</
|
|
179
|
-
<
|
|
175
|
+
</WCText>
|
|
176
|
+
<WCText variant="muted">{ `Try a different search because “${ view.search }” returned no results.` }</WCText>
|
|
180
177
|
<Button variant="secondary">Create new planet</Button>
|
|
181
178
|
</Stack>
|
|
182
179
|
}
|
|
@@ -50,10 +50,10 @@ const InfiniteScroll = () => {
|
|
|
50
50
|
onChangeView={ setView }
|
|
51
51
|
actions={ actions }
|
|
52
52
|
defaultLayouts={ {
|
|
53
|
-
[ LAYOUT_TABLE ]:
|
|
54
|
-
[ LAYOUT_GRID ]:
|
|
55
|
-
[ LAYOUT_LIST ]:
|
|
56
|
-
[ LAYOUT_ACTIVITY ]:
|
|
53
|
+
[ LAYOUT_TABLE ]: true,
|
|
54
|
+
[ LAYOUT_GRID ]: true,
|
|
55
|
+
[ LAYOUT_LIST ]: true,
|
|
56
|
+
[ LAYOUT_ACTIVITY ]: true,
|
|
57
57
|
} }
|
|
58
58
|
/>
|
|
59
59
|
</>
|