@wordpress/dataviews 11.1.1-next.76cff8c98.0 → 11.2.1-next.06ee73755.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 +7 -1
- package/build/components/dataviews-filters/input-widget.cjs +1 -1
- package/build/components/dataviews-filters/input-widget.cjs.map +1 -1
- package/build/components/dataviews-layouts/index.cjs +3 -2
- package/build/components/dataviews-layouts/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/list/index.cjs +5 -1
- package/build/components/dataviews-layouts/list/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/{table → utils}/density-picker.cjs +1 -1
- package/build/components/dataviews-layouts/{table → utils}/density-picker.cjs.map +2 -2
- package/build/components/dataviews-view-config/properties-section.cjs +11 -39
- package/build/components/dataviews-view-config/properties-section.cjs.map +2 -2
- package/build/hooks/use-form-validity.cjs +1 -1
- package/build/hooks/use-form-validity.cjs.map +1 -1
- package/build/types/dataviews.cjs.map +1 -1
- package/build-module/components/dataviews-filters/input-widget.mjs +1 -1
- package/build-module/components/dataviews-filters/input-widget.mjs.map +1 -1
- package/build-module/components/dataviews-layouts/index.mjs +3 -2
- package/build-module/components/dataviews-layouts/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/list/index.mjs +5 -1
- package/build-module/components/dataviews-layouts/list/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/{table → utils}/density-picker.mjs +1 -1
- package/build-module/components/dataviews-layouts/utils/density-picker.mjs.map +7 -0
- package/build-module/components/dataviews-view-config/properties-section.mjs +11 -39
- package/build-module/components/dataviews-view-config/properties-section.mjs.map +2 -2
- package/build-module/hooks/use-form-validity.mjs +1 -1
- package/build-module/hooks/use-form-validity.mjs.map +1 -1
- package/build-style/style-rtl.css +49 -5
- package/build-style/style.css +49 -5
- package/build-types/components/dataviews-layouts/index.d.ts +2 -2
- package/build-types/components/dataviews-layouts/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/list/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/{table → utils}/density-picker.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/properties-section.d.ts.map +1 -1
- package/build-types/dataform/stories/index.story.d.ts +1 -1
- package/build-types/dataform/stories/validation.d.ts +1 -1
- package/build-types/dataform/stories/validation.d.ts.map +1 -1
- package/build-types/types/dataviews.d.ts +6 -0
- package/build-types/types/dataviews.d.ts.map +1 -1
- package/build-wp/index.js +165 -188
- package/package.json +23 -20
- package/src/components/dataviews-filters/input-widget.tsx +1 -1
- package/src/components/dataviews-layouts/index.ts +2 -1
- package/src/components/dataviews-layouts/list/index.tsx +7 -1
- package/src/components/dataviews-layouts/list/style.scss +65 -0
- package/src/components/dataviews-layouts/{table → utils}/density-picker.tsx +2 -2
- package/src/components/dataviews-view-config/properties-section.tsx +24 -49
- package/src/dataform/stories/index.story.tsx +1 -1
- package/src/dataform/stories/validation.tsx +8 -1
- package/src/hooks/use-form-validity.ts +1 -1
- package/src/types/dataviews.ts +7 -0
- package/build-module/components/dataviews-layouts/table/density-picker.mjs.map +0 -7
- /package/build-types/components/dataviews-layouts/{table → utils}/density-picker.d.ts +0 -0
|
@@ -78,41 +78,26 @@ export function PropertiesSection( {
|
|
|
78
78
|
field: descriptionField,
|
|
79
79
|
isVisibleFlag: 'showDescription',
|
|
80
80
|
},
|
|
81
|
-
].filter( ( { field } ) => isDefined( field ) )
|
|
81
|
+
].filter( ( { field } ) => isDefined( field ) ) as Array< {
|
|
82
|
+
field: NormalizedField< any >;
|
|
83
|
+
isVisibleFlag: string;
|
|
84
|
+
} >;
|
|
82
85
|
const visibleFieldIds = view.fields ?? [];
|
|
83
86
|
const visibleRegularFieldsCount = regularFields.filter( ( f ) =>
|
|
84
87
|
visibleFieldIds.includes( f.id )
|
|
85
88
|
).length;
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
( {
|
|
90
|
+
const visibleLockedFields = lockedFields.filter(
|
|
91
|
+
( { isVisibleFlag } ) =>
|
|
89
92
|
// @ts-expect-error
|
|
90
|
-
|
|
91
|
-
)
|
|
92
|
-
field: NormalizedField< any >;
|
|
93
|
-
isVisibleFlag: string;
|
|
94
|
-
} >;
|
|
93
|
+
view[ isVisibleFlag ] ?? true
|
|
94
|
+
);
|
|
95
95
|
|
|
96
96
|
// If only one field (locked or regular) is visible, prevent it from being hidden
|
|
97
97
|
const totalVisibleFields =
|
|
98
98
|
visibleLockedFields.length + visibleRegularFieldsCount;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
visibleLockedFields = visibleLockedFields.map( ( locked ) => ( {
|
|
102
|
-
...locked,
|
|
103
|
-
field: { ...locked.field, enableHiding: false },
|
|
104
|
-
} ) );
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const hiddenLockedFields = lockedFields.filter(
|
|
109
|
-
( { field, isVisibleFlag } ) =>
|
|
110
|
-
// @ts-expect-error
|
|
111
|
-
isDefined( field ) && ! ( view[ isVisibleFlag ] ?? true )
|
|
112
|
-
) as Array< {
|
|
113
|
-
field: NormalizedField< any >;
|
|
114
|
-
isVisibleFlag: string;
|
|
115
|
-
} >;
|
|
99
|
+
const isSingleVisibleLockedField =
|
|
100
|
+
totalVisibleFields === 1 && visibleLockedFields.length === 1;
|
|
116
101
|
|
|
117
102
|
return (
|
|
118
103
|
<Stack direction="column" className="dataviews-field-control">
|
|
@@ -126,32 +111,23 @@ export function PropertiesSection( {
|
|
|
126
111
|
className="dataviews-view-config__properties"
|
|
127
112
|
>
|
|
128
113
|
<ItemGroup isBordered isSeparated size="medium">
|
|
129
|
-
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
onChangeView( {
|
|
137
|
-
...view,
|
|
138
|
-
[ isVisibleFlag ]: false,
|
|
139
|
-
} );
|
|
140
|
-
} }
|
|
141
|
-
/>
|
|
142
|
-
);
|
|
143
|
-
} ) }
|
|
114
|
+
{ lockedFields.map( ( { field, isVisibleFlag } ) => {
|
|
115
|
+
// @ts-expect-error
|
|
116
|
+
const isVisible = view[ isVisibleFlag ] ?? true;
|
|
117
|
+
const fieldToRender =
|
|
118
|
+
isSingleVisibleLockedField && isVisible
|
|
119
|
+
? { ...field, enableHiding: false }
|
|
120
|
+
: field;
|
|
144
121
|
|
|
145
|
-
{ hiddenLockedFields.map( ( { field, isVisibleFlag } ) => {
|
|
146
122
|
return (
|
|
147
123
|
<FieldItem
|
|
148
124
|
key={ field.id }
|
|
149
|
-
field={
|
|
150
|
-
isVisible={
|
|
125
|
+
field={ fieldToRender }
|
|
126
|
+
isVisible={ isVisible }
|
|
151
127
|
onToggleVisibility={ () => {
|
|
152
128
|
onChangeView( {
|
|
153
129
|
...view,
|
|
154
|
-
[ isVisibleFlag ]:
|
|
130
|
+
[ isVisibleFlag ]: ! isVisible,
|
|
155
131
|
} );
|
|
156
132
|
} }
|
|
157
133
|
/>
|
|
@@ -161,11 +137,10 @@ export function PropertiesSection( {
|
|
|
161
137
|
{ regularFields.map( ( field ) => {
|
|
162
138
|
// Check if this is the last visible field to prevent hiding
|
|
163
139
|
const isVisible = visibleFieldIds.includes( field.id );
|
|
164
|
-
const
|
|
165
|
-
totalVisibleFields === 1 && isVisible
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
: field;
|
|
140
|
+
const fieldToRender =
|
|
141
|
+
totalVisibleFields === 1 && isVisible
|
|
142
|
+
? { ...field, enableHiding: false }
|
|
143
|
+
: field;
|
|
169
144
|
|
|
170
145
|
return (
|
|
171
146
|
<FieldItem
|
|
@@ -100,7 +100,7 @@ export const Validation = {
|
|
|
100
100
|
layout: {
|
|
101
101
|
control: { type: 'select' },
|
|
102
102
|
description: 'Choose the form layout type.',
|
|
103
|
-
options: [ 'regular', 'panel', 'card' ],
|
|
103
|
+
options: [ 'regular', 'panel', 'card', 'details' ],
|
|
104
104
|
},
|
|
105
105
|
required: {
|
|
106
106
|
control: { type: 'boolean' },
|
|
@@ -86,7 +86,7 @@ const ValidationComponent = ( {
|
|
|
86
86
|
custom: 'sync' | 'async' | 'none';
|
|
87
87
|
pattern: boolean;
|
|
88
88
|
minMax: boolean;
|
|
89
|
-
layout: 'regular' | 'panel' | 'card';
|
|
89
|
+
layout: 'regular' | 'panel' | 'card' | 'details';
|
|
90
90
|
} ) => {
|
|
91
91
|
type ValidatedItem = {
|
|
92
92
|
text: string;
|
|
@@ -908,6 +908,13 @@ const ValidationComponent = ( {
|
|
|
908
908
|
};
|
|
909
909
|
}
|
|
910
910
|
|
|
911
|
+
if ( layout === 'details' ) {
|
|
912
|
+
return {
|
|
913
|
+
layout: { type: 'details' as const },
|
|
914
|
+
fields: groupedFields,
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
|
|
911
918
|
return {
|
|
912
919
|
layout: { type: 'card' as const },
|
|
913
920
|
fields: groupedFields,
|
package/src/types/dataviews.ts
CHANGED
|
@@ -252,6 +252,13 @@ export interface ViewTable extends ViewBase {
|
|
|
252
252
|
|
|
253
253
|
export interface ViewList extends ViewBase {
|
|
254
254
|
type: 'list';
|
|
255
|
+
|
|
256
|
+
layout?: {
|
|
257
|
+
/**
|
|
258
|
+
* The density of the view.
|
|
259
|
+
*/
|
|
260
|
+
density?: Density;
|
|
261
|
+
};
|
|
255
262
|
}
|
|
256
263
|
|
|
257
264
|
export interface ViewActivity extends ViewBase {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/dataviews-layouts/table/density-picker.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../../dataviews-context';\nimport type { ViewTable, Density } from '../../../types';\n\nexport default function DensityPicker() {\n\tconst context = useContext( DataViewsContext );\n\tconst view = context.view as ViewTable;\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tsize=\"__unstable-large\"\n\t\t\tlabel={ __( 'Density' ) }\n\t\t\tvalue={ view.layout?.density || 'balanced' }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tcontext.onChangeView( {\n\t\t\t\t\t...view,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...view.layout,\n\t\t\t\t\t\tdensity: value as Density,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tisBlock\n\t\t>\n\t\t\t<ToggleGroupControlOption\n\t\t\t\tkey=\"comfortable\"\n\t\t\t\tvalue=\"comfortable\"\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Comfortable',\n\t\t\t\t\t'Density option for DataView layout'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<ToggleGroupControlOption\n\t\t\t\tkey=\"balanced\"\n\t\t\t\tvalue=\"balanced\"\n\t\t\t\tlabel={ _x( 'Balanced', 'Density option for DataView layout' ) }\n\t\t\t/>\n\t\t\t<ToggleGroupControlOption\n\t\t\t\tkey=\"compact\"\n\t\t\t\tvalue=\"compact\"\n\t\t\t\tlabel={ _x( 'Compact', 'Density option for DataView layout' ) }\n\t\t\t/>\n\t\t</ToggleGroupControl>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC,oCAAoC;AAAA,EACpC,0CAA0C;AAAA,OACpC;AACP,SAAS,IAAI,UAAU;AACvB,SAAS,kBAAkB;AAK3B,OAAO,sBAAsB;AAO3B,SAeC,KAfD;AAJa,SAAR,gBAAiC;AACvC,QAAM,UAAU,WAAY,gBAAiB;AAC7C,QAAM,OAAO,QAAQ;AACrB,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,OAAQ,GAAI,SAAU;AAAA,MACtB,OAAQ,KAAK,QAAQ,WAAW;AAAA,MAChC,UAAW,CAAE,UAAW;AACvB,gBAAQ,aAAc;AAAA,UACrB,GAAG;AAAA,UACH,QAAQ;AAAA,YACP,GAAG,KAAK;AAAA,YACR,SAAS;AAAA,UACV;AAAA,QACD,CAAE;AAAA,MACH;AAAA,MACA,SAAO;AAAA,MAEP;AAAA;AAAA,UAAC;AAAA;AAAA,YAEA,OAAM;AAAA,YACN,OAAQ;AAAA,cACP;AAAA,cACA;AAAA,YACD;AAAA;AAAA,UALI;AAAA,QAML;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YAEA,OAAM;AAAA,YACN,OAAQ,GAAI,YAAY,oCAAqC;AAAA;AAAA,UAFzD;AAAA,QAGL;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YAEA,OAAM;AAAA,YACN,OAAQ,GAAI,WAAW,oCAAqC;AAAA;AAAA,UAFxD;AAAA,QAGL;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
File without changes
|