@wordpress/views 2.0.0 → 3.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/build/use-view-config.cjs +1 -1
- package/build/use-view-config.cjs.map +2 -2
- package/build-module/use-view-config.mjs +1 -1
- package/build-module/use-view-config.mjs.map +2 -2
- package/build-types/use-view-config.d.ts.map +1 -1
- package/package.json +10 -11
- package/src/use-view-config.ts +1 -3
- package/CHANGELOG.md +0 -46
|
@@ -32,7 +32,7 @@ function useViewConfig({
|
|
|
32
32
|
fields
|
|
33
33
|
}) {
|
|
34
34
|
const fieldList = Array.isArray(fields) ? fields : fields?.split(",");
|
|
35
|
-
const fieldsKey = fieldList ?
|
|
35
|
+
const fieldsKey = fieldList ? fieldList.toSorted().join(",") : void 0;
|
|
36
36
|
return (0, import_data.useSelect)(
|
|
37
37
|
(select) => {
|
|
38
38
|
return (0, import_lock_unlock.unlock)(select(import_core_data.store)).getViewConfig(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/use-view-config.ts"],
|
|
4
|
-
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,uBAAmC;AAEnC,yBAAuB;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList ? fieldList.toSorted().join( ',' ) : undefined;\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\treturn unlock( select( coreStore ) ).getViewConfig(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\tfieldsKey\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tfields: fieldsKey,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined\n\t\t\t);\n\t\t},\n\t\t[ kind, name, fieldsKey ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,uBAAmC;AAEnC,yBAAuB;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,YAAY,UAAU,SAAS,EAAE,KAAM,GAAI,IAAI;AACjE,aAAO;AAAA,IACN,CAAE,WAAY;AACb,iBAAO,2BAAQ,OAAQ,iBAAAA,KAAU,CAAE,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA,YACG;AAAA,UACA,QAAQ;AAAA,QACT,IACC;AAAA,MACJ;AAAA,IACD;AAAA,IACA,CAAE,MAAM,MAAM,SAAU;AAAA,EACzB;AACD;",
|
|
6
6
|
"names": ["coreStore"]
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ function useViewConfig({
|
|
|
8
8
|
fields
|
|
9
9
|
}) {
|
|
10
10
|
const fieldList = Array.isArray(fields) ? fields : fields?.split(",");
|
|
11
|
-
const fieldsKey = fieldList ?
|
|
11
|
+
const fieldsKey = fieldList ? fieldList.toSorted().join(",") : void 0;
|
|
12
12
|
return useSelect(
|
|
13
13
|
(select) => {
|
|
14
14
|
return unlock(select(coreStore)).getViewConfig(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/use-view-config.ts"],
|
|
4
|
-
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAEnC,SAAS,cAAc;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { View, SupportedLayouts, Form } from '@wordpress/dataviews';\nimport { unlock } from './lock-unlock';\n\n/**\n * A hook that retrieves the view configuration for a given entity\n * from the core data store.\n *\n * @param {Object} params\n * @param {string} params.kind The kind of the entity.\n * @param {string} params.name The name of the entity.\n * @param {?(string|string[])} [params.fields] Subset of top-level config\n * properties to request, as an array\n * or a comma-separated string\n * (mapped to the REST API `_fields`\n * parameter). When omitted, the full\n * config is requested.\n * @return {Object} An object containing the `default_view`, `default_layouts`, `view_list`, and `form` configuration for the entity.\n */\nexport function useViewConfig( {\n\tkind,\n\tname,\n\tfields,\n}: {\n\tkind: string;\n\tname: string;\n\tfields?: string | string[];\n} ): {\n\tdefault_view: View | undefined;\n\tdefault_layouts: SupportedLayouts | undefined;\n\tview_list: Array< any > | undefined;\n\tform: Form | undefined;\n} {\n\t// Sort fields so the cache key is independent of the order callers list\n\t// them; `['title','author']` and `['author','title']` request the same data.\n\tconst fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );\n\tconst fieldsKey = fieldList ? fieldList.toSorted().join( ',' ) : undefined;\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\treturn unlock( select( coreStore ) ).getViewConfig(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\tfieldsKey\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tfields: fieldsKey,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined\n\t\t\t);\n\t\t},\n\t\t[ kind, name, fieldsKey ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAEnC,SAAS,cAAc;AAiBhB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GASE;AAGD,QAAM,YAAY,MAAM,QAAS,MAAO,IAAI,SAAS,QAAQ,MAAO,GAAI;AACxE,QAAM,YAAY,YAAY,UAAU,SAAS,EAAE,KAAM,GAAI,IAAI;AACjE,SAAO;AAAA,IACN,CAAE,WAAY;AACb,aAAO,OAAQ,OAAQ,SAAU,CAAE,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA,YACG;AAAA,UACA,QAAQ;AAAA,QACT,IACC;AAAA,MACJ;AAAA,IACD;AAAA,IACA,CAAE,MAAM,MAAM,SAAU;AAAA,EACzB;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-view-config.d.ts","sourceRoot":"","sources":["../src/use-view-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAE,EAC9B,IAAI,EACJ,IAAI,EACJ,MAAM,GACN,EAAE;IACF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B,GAAI;IACJ,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B,eAAe,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC9C,SAAS,EAAE,KAAK,CAAE,GAAG,CAAE,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACvB,
|
|
1
|
+
{"version":3,"file":"use-view-config.d.ts","sourceRoot":"","sources":["../src/use-view-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAE,EAC9B,IAAI,EACJ,IAAI,EACJ,MAAM,GACN,EAAE;IACF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B,GAAI;IACJ,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B,eAAe,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC9C,SAAS,EAAE,KAAK,CAAE,GAAG,CAAE,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACvB,CAmBA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/views",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "View persistence and management for WordPress DataViews.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -19,14 +19,13 @@
|
|
|
19
19
|
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=22.13.0"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"src",
|
|
26
26
|
"build",
|
|
27
27
|
"build-module",
|
|
28
|
-
"build-types"
|
|
29
|
-
"*.md"
|
|
28
|
+
"build-types"
|
|
30
29
|
],
|
|
31
30
|
"main": "build/index.cjs",
|
|
32
31
|
"module": "build-module/index.mjs",
|
|
@@ -40,12 +39,12 @@
|
|
|
40
39
|
},
|
|
41
40
|
"types": "build-types",
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@wordpress/core-data": "^
|
|
44
|
-
"@wordpress/data": "^
|
|
45
|
-
"@wordpress/dataviews": "^
|
|
46
|
-
"@wordpress/element": "^
|
|
47
|
-
"@wordpress/preferences": "^
|
|
48
|
-
"@wordpress/private-apis": "^
|
|
42
|
+
"@wordpress/core-data": "^9.0.0",
|
|
43
|
+
"@wordpress/data": "^11.0.0",
|
|
44
|
+
"@wordpress/dataviews": "^21.0.0",
|
|
45
|
+
"@wordpress/element": "^10.0.0",
|
|
46
|
+
"@wordpress/preferences": "^5.0.0",
|
|
47
|
+
"@wordpress/private-apis": "^3.0.0",
|
|
49
48
|
"dequal": "^2.0.3"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
@@ -71,5 +70,5 @@
|
|
|
71
70
|
"publishConfig": {
|
|
72
71
|
"access": "public"
|
|
73
72
|
},
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
|
|
75
74
|
}
|
package/src/use-view-config.ts
CHANGED
|
@@ -35,9 +35,7 @@ export function useViewConfig( {
|
|
|
35
35
|
// Sort fields so the cache key is independent of the order callers list
|
|
36
36
|
// them; `['title','author']` and `['author','title']` request the same data.
|
|
37
37
|
const fieldList = Array.isArray( fields ) ? fields : fields?.split( ',' );
|
|
38
|
-
const fieldsKey = fieldList
|
|
39
|
-
? [ ...fieldList ].sort().join( ',' )
|
|
40
|
-
: undefined;
|
|
38
|
+
const fieldsKey = fieldList ? fieldList.toSorted().join( ',' ) : undefined;
|
|
41
39
|
return useSelect(
|
|
42
40
|
( select ) => {
|
|
43
41
|
return unlock( select( coreStore ) ).getViewConfig(
|
package/CHANGELOG.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. -->
|
|
2
|
-
|
|
3
|
-
## Unreleased
|
|
4
|
-
|
|
5
|
-
## 2.0.0 (2026-10-07)
|
|
6
|
-
|
|
7
|
-
### Breaking Changes
|
|
8
|
-
|
|
9
|
-
- Upgrade React to v19 ([#83941](https://github.com/WordPress/gutenberg/pull/83941)).
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
- Declare `react`, `react-dom`, and their types as peer dependencies, forwarding the peers of `@wordpress/element`, so strict package managers such as Yarn PnP can resolve them ([#83765](https://github.com/WordPress/gutenberg/pull/83765)).
|
|
14
|
-
|
|
15
|
-
## 1.23.0 (2026-09-23)
|
|
16
|
-
|
|
17
|
-
## 1.22.0 (2026-09-10)
|
|
18
|
-
|
|
19
|
-
### Bug Fixes
|
|
20
|
-
|
|
21
|
-
- `useViewConfig`: request the full configuration under the same cache key as `getViewConfig( kind, name )`, so a route loader that preloads it no longer triggers a second request. ([#82141](https://github.com/WordPress/gutenberg/pull/82141))
|
|
22
|
-
- `useView`, `loadView`: ignore a persisted layout `type` that `defaultLayouts` does not offer, resolving the type out of the layers below instead. DataViews renders nothing for a layout it is not given, so a preference saved when a screen still offered that layout used to leave the screen empty, with no way to reset it. Such a type does not count as a modification and is written out of the preference on the next update. ([#82457](https://github.com/WordPress/gutenberg/pull/82457))
|
|
23
|
-
|
|
24
|
-
## 1.21.0 (2026-08-26)
|
|
25
|
-
|
|
26
|
-
### Internal
|
|
27
|
-
|
|
28
|
-
- Point tsconfig references at split dependencies' build projects. ([#81515](https://github.com/WordPress/gutenberg/pull/81515))
|
|
29
|
-
- Split tsconfig into a build project and a default dev project so dev files are type checked without publishing their declarations. ([#81514](https://github.com/WordPress/gutenberg/pull/81514))
|
|
30
|
-
|
|
31
|
-
## 1.20.0 (2026-08-12)
|
|
32
|
-
|
|
33
|
-
### Bug Fixes
|
|
34
|
-
|
|
35
|
-
- `useView`, `loadView`. Resolve the view as a stack of layers — `defaultView`, `defaultLayouts` (for the effective type), `activeViewOverrides`, the user's preference, and the URL query params — and persist only the properties the user actually modified. Previously the whole view was persisted, so a later change to any of the lower layers stopped showing through, an override could bounce back a value the user had picked, and a partial `sort` or `layout` override marked the view as modified forever. `page` and `search` are now sourced from the URL alone, and `layout`, `groupBy` and `sort` merge leaf by leaf, so an override for one field's styles no longer wipes the other fields'. Persisted modifications that happen to coincide with the current view's base are retained on update, so a change made in one view no longer drops a pick made in another view sharing the preference. [#80832](https://github.com/WordPress/gutenberg/pull/80832)
|
|
36
|
-
|
|
37
|
-
### Internal
|
|
38
|
-
|
|
39
|
-
- Remove obsolete dependency grouping comments as part of the repository-wide separator-free import migration. ([#81248](https://github.com/WordPress/gutenberg/pull/81248))
|
|
40
|
-
- Add `react` and `react-dom` to the package's dev dependencies, so the tests resolve them from the package rather than relying on a hoisted install. [#81139](https://github.com/WordPress/gutenberg/pull/81139)
|
|
41
|
-
|
|
42
|
-
## 1.19.0 (2026-07-29)
|
|
43
|
-
|
|
44
|
-
## 1.18.0 (2026-07-14)
|
|
45
|
-
|
|
46
|
-
## 1.17.0 (2026-07-01)
|