@wordpress/views 3.1.0 → 3.3.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/resolve-view.cjs
CHANGED
|
@@ -133,8 +133,7 @@ function getApplicablePersistedView(persistedView, defaultLayouts) {
|
|
|
133
133
|
*/
|
|
134
134
|
function resolveBaseView(layers, effectiveType) {
|
|
135
135
|
const { defaultView, defaultLayouts, activeViewOverrides } = layers;
|
|
136
|
-
|
|
137
|
-
return applyLockedFilters([layoutDefaults, activeViewOverrides].reduce((lower, upper) => mergeLayer(lower, withoutQueryParams(upper)), withoutQueryParams(defaultView)), activeViewOverrides);
|
|
136
|
+
return applyLockedFilters([defaultLayouts?.[effectiveType], activeViewOverrides].reduce((lower, upper) => mergeLayer(lower, withoutQueryParams(upper)), withoutQueryParams(defaultView)), activeViewOverrides);
|
|
138
137
|
}
|
|
139
138
|
/**
|
|
140
139
|
* Resolves a view out of its layers. Later layers override earlier ones:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-view.cjs","names":[],"sources":["../src/resolve-view.ts"],"sourcesContent":["import { dequal } from 'dequal';\nimport type { View, Filter, SupportedLayouts } from '@wordpress/dataviews';\nimport type { ViewOverrides } from './types';\n\ntype PlainObject = Record< string, unknown >;\n\n/**\n * `page` and `search` are URL-managed: the URL is their only source. They are\n * never persisted, and no other layer may configure them — an absent URL param\n * is indistinguishable from the user having cleared the value, so any fallback\n * would resurrect a cleared search on the next read.\n */\nconst QUERY_PARAMS = [ 'page', 'search' ] as const;\n\nfunction isPlainObject( value: unknown ): value is PlainObject {\n\treturn (\n\t\ttypeof value === 'object' && value !== null && ! Array.isArray( value )\n\t);\n}\n\n/**\n * Copies a layer without the URL-managed properties.\n *\n * @param layer The layer to copy.\n * @return A copy of the layer with `page` and `search` removed.\n */\nfunction withoutQueryParams( layer: unknown ): PlainObject {\n\tconst result: PlainObject = isPlainObject( layer ) ? { ...layer } : {};\n\tfor ( const key of QUERY_PARAMS ) {\n\t\tdelete result[ key ];\n\t}\n\treturn result;\n}\n\n/**\n * Merges a layer on top of another, recursing into plain objects so the upper\n * layer only takes over the leaves it declares. Arrays and scalars are leaves:\n * they are replaced wholesale.\n *\n * Nested properties (`layout.styles.<field>.width`, `groupBy.direction`,\n * `sort.direction`) are merged leaf by leaf: a shallow merge would let a layer\n * that only declares one leaf wipe every sibling the layers below provide.\n *\n * @param lower The layer to merge into.\n * @param upper The layer to merge on top.\n * @return The merged layer.\n */\nfunction mergeLayer( lower: PlainObject, upper: PlainObject ): PlainObject {\n\tconst result: PlainObject = { ...lower };\n\tfor ( const key of Object.keys( upper ) ) {\n\t\tconst value = upper[ key ];\n\t\tconst current = result[ key ];\n\t\tresult[ key ] =\n\t\t\tisPlainObject( current ) && isPlainObject( value )\n\t\t\t\t? mergeLayer( current, value )\n\t\t\t\t: value;\n\t}\n\treturn result;\n}\n\n/**\n * The leaves of `value` that differ from `base`. Mirrors `mergeLayer`:\n * `mergeLayer( base, diffLayer( value, base ) )` resolves back to `value`.\n *\n * A persisted leaf that equals both `value` and `base` is kept even though it\n * is not a difference: the preference is shared by every view of the same\n * entity, and such a leaf may only differ from the base of *another* view. In\n * this one, where it coincides with the base, a revert is unobservable — so\n * equality cannot mean the user reverted it. Dropping a persisted leaf\n * requires `value` to actually move away from it, back to `base`.\n *\n * @param value The layer to compare.\n * @param base The layer to compare it against.\n * @param persisted The previously persisted leaves.\n * @return The leaves that differ, as a layer of its own.\n */\nfunction diffLayer(\n\tvalue: PlainObject,\n\tbase: PlainObject,\n\tpersisted: PlainObject = {}\n): PlainObject {\n\tconst result: PlainObject = {};\n\tfor ( const key of Object.keys( value ) ) {\n\t\tconst next = value[ key ];\n\t\tconst current = base[ key ];\n\t\tconst prev = persisted[ key ];\n\t\tif ( next === undefined ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( isPlainObject( next ) && isPlainObject( current ) ) {\n\t\t\tconst nested = diffLayer(\n\t\t\t\tnext,\n\t\t\t\tcurrent,\n\t\t\t\tisPlainObject( prev ) ? prev : {}\n\t\t\t);\n\t\t\tif ( Object.keys( nested ).length > 0 ) {\n\t\t\t\tresult[ key ] = nested;\n\t\t\t}\n\t\t} else if ( ! dequal( next, current ) ) {\n\t\t\tresult[ key ] = next;\n\t\t} else if ( prev !== undefined && dequal( next, prev ) ) {\n\t\t\tresult[ key ] = prev;\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction getLockedFilters( overrides?: ViewOverrides ): Filter[] {\n\treturn ( overrides?.filters ?? [] ).filter( ( filter ) => filter.isLocked );\n}\n\n/**\n * Hoists the locked filters an override provides to the front of the view's\n * filters, replacing any same-field filter. Locked filters are not the user's\n * to change, so they are pinned in place instead of taking part in the layer\n * resolution.\n *\n * @param view The view to apply the locked filters to.\n * @param overrides The active view overrides.\n * @return The view with the locked filters applied.\n */\nfunction applyLockedFilters(\n\tview: PlainObject,\n\toverrides?: ViewOverrides\n): PlainObject {\n\tconst locked = getLockedFilters( overrides );\n\tif ( locked.length === 0 ) {\n\t\treturn view;\n\t}\n\tconst rest = ( ( view.filters ?? [] ) as Filter[] ).filter(\n\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t);\n\treturn { ...view, filters: [ ...locked, ...rest ] };\n}\n\ninterface ViewLayers {\n\tdefaultView?: View;\n\tdefaultLayouts?: SupportedLayouts;\n\tactiveViewOverrides?: ViewOverrides;\n\t/**\n\t * The user's persisted modifications: a partial view holding only the\n\t * properties they actually changed.\n\t */\n\tpersistedView?: ViewOverrides;\n}\n\ninterface ResolveViewArgs extends ViewLayers {\n\tpage?: number;\n\tsearch?: string;\n}\n\n/**\n * The user's persisted modifications that still apply.\n *\n * A persisted `type` that `defaultLayouts` does not offer is dropped: DataViews\n * renders nothing for a layout it is not given, and the preference may predate\n * the current set of layouts (a screen that used to offer the list layout, say,\n * and no longer does). The type then resolves out of the layers below, and the\n * other modifications are kept. Without `defaultLayouts` every type is offered.\n *\n * `true` is a valid entry, so the check mirrors DataViews': an entry counts as\n * long as it is truthy.\n *\n * @param persistedView The user's persisted modifications.\n * @param defaultLayouts The layouts on offer, keyed by layout type.\n * @return The modifications that apply, or `undefined` when there are none.\n */\nexport function getApplicablePersistedView(\n\tpersistedView: ViewOverrides | undefined,\n\tdefaultLayouts: SupportedLayouts | undefined\n): ViewOverrides | undefined {\n\tif (\n\t\t! persistedView ||\n\t\tpersistedView.type === undefined ||\n\t\t! defaultLayouts ||\n\t\tdefaultLayouts[ persistedView.type as keyof SupportedLayouts ]\n\t) {\n\t\treturn persistedView;\n\t}\n\tconst { type, ...rest } = persistedView;\n\treturn Object.keys( rest ).length > 0 ? rest : undefined;\n}\n\n/**\n * Resolves the layers below the user's modifications — what a modification has\n * to differ from to count as one. The layout type selects which entry of\n * `defaultLayouts` applies, so the base only makes sense relative to a type.\n *\n * @param layers The layers to resolve.\n * @param effectiveType The layout type to resolve the base at.\n * @return The resolved base view.\n */\nfunction resolveBaseView(\n\tlayers: ViewLayers,\n\teffectiveType: View[ 'type' ] | undefined\n): PlainObject {\n\tconst { defaultView, defaultLayouts, activeViewOverrides } = layers;\n\tconst layoutDefaults =\n\t\tdefaultLayouts?.[ effectiveType as keyof SupportedLayouts ];\n\treturn applyLockedFilters(\n\t\t[ layoutDefaults, activeViewOverrides ].reduce< PlainObject >(\n\t\t\t( lower, upper ) =>\n\t\t\t\tmergeLayer( lower, withoutQueryParams( upper ) ),\n\t\t\twithoutQueryParams( defaultView )\n\t\t),\n\t\tactiveViewOverrides\n\t);\n}\n\n/**\n * Resolves a view out of its layers. Later layers override earlier ones:\n *\n * 1. `defaultView`\n * 2. `defaultLayouts` (for the effective type)\n * 3. `activeViewOverrides`\n * 4. the user's persisted modifications (see `getApplicablePersistedView`)\n * 5. the URL query params (`page` and `search` only)\n *\n * @param args See `ResolveViewArgs`.\n * @return The resolved `view`.\n */\nexport function resolveView( args: ResolveViewArgs ): View {\n\tconst { defaultView, defaultLayouts, activeViewOverrides, page, search } =\n\t\targs;\n\tconst persistedView = getApplicablePersistedView(\n\t\targs.persistedView,\n\t\tdefaultLayouts\n\t);\n\n\t// Resolve the effective layout type first: it selects which entry of\n\t// `defaultLayouts` applies, and the layers above the layouts may change it.\n\tconst effectiveType =\n\t\tpersistedView?.type ?? activeViewOverrides?.type ?? defaultView?.type;\n\tconst baseView = resolveBaseView( args, effectiveType );\n\n\tconst view = {\n\t\t...applyLockedFilters(\n\t\t\tmergeLayer( baseView, withoutQueryParams( persistedView ) ),\n\t\t\tactiveViewOverrides\n\t\t),\n\t\tpage: Number( page ?? 1 ),\n\t\tsearch: search ?? '',\n\t};\n\n\t// The layers are resolved as plain objects: `View` requires a `type`, which\n\t// only the layers taken together are guaranteed to provide.\n\treturn view as unknown as View;\n}\n\n/**\n * The user's modifications: the leaves of the view they interacted with that\n * the layers below do not already resolve to. This is what gets persisted, so\n * that a change to any of those layers keeps showing through the properties the\n * user never touched.\n *\n * Previously persisted leaves that coincide with the base of the current view\n * are carried over rather than dropped: they may still make a difference in\n * another view sharing the preference. See `diffLayer`.\n *\n * The diff basis is resolved at `newView.type`, not at the type the previous\n * resolution used: the type selects the `defaultLayouts` entry, and a layout\n * switch reports the new type together with that entry's values. Diffing them\n * against the previous type's base would persist the difference between the\n * two entries as if the user had picked those values — leaves the layouts\n * already provide, which then linger as phantom modifications after switching\n * back.\n *\n * A persisted `type` the current layouts do not offer never applied (see\n * `getApplicablePersistedView`), so it is not carried over either: the\n * modifications returned replace it with whatever the user picked.\n *\n * @param newView The view the user produced.\n * @param layers The layers the view resolves from. See `ViewLayers`.\n * @return The modified properties, or `undefined` when the user modified none.\n */\nexport function getUserModifications(\n\tnewView: View,\n\tlayers: ViewLayers\n): ViewOverrides | undefined {\n\tconst { defaultLayouts, activeViewOverrides } = layers;\n\tconst persistedView = getApplicablePersistedView(\n\t\tlayers.persistedView,\n\t\tdefaultLayouts\n\t);\n\tconst baseView = resolveBaseView( layers, newView.type );\n\n\tconst modifications = diffLayer(\n\t\twithoutQueryParams( newView ),\n\t\twithoutQueryParams( baseView ),\n\t\twithoutQueryParams( persistedView )\n\t);\n\n\t// Locked filters are pinned on every read, so persisting them would only\n\t// leak them into the views that do not lock them.\n\tconst locked = getLockedFilters( activeViewOverrides );\n\tif ( locked.length > 0 && Array.isArray( modifications.filters ) ) {\n\t\tmodifications.filters = ( modifications.filters as Filter[] ).filter(\n\t\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t\t);\n\t}\n\n\treturn Object.keys( modifications ).length > 0\n\t\t? ( modifications as ViewOverrides )\n\t\t: undefined;\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,eAAe,CAAE,QAAQ,QAAS;AAExC,SAAS,cAAe,OAAuC;CAC9D,OACC,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAE,MAAM,QAAS,KAAM;AAExE;;;;;;;AAQA,SAAS,mBAAoB,OAA8B;CAC1D,MAAM,SAAsB,cAAe,KAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC;CACrE,KAAM,MAAM,OAAO,cAClB,OAAO,OAAQ;CAEhB,OAAO;AACR;;;;;;;;;;;;;;AAeA,SAAS,WAAY,OAAoB,OAAkC;CAC1E,MAAM,SAAsB,EAAE,GAAG,MAAM;CACvC,KAAM,MAAM,OAAO,OAAO,KAAM,KAAM,GAAI;EACzC,MAAM,QAAQ,MAAO;EACrB,MAAM,UAAU,OAAQ;EACxB,OAAQ,OACP,cAAe,OAAQ,KAAK,cAAe,KAAM,IAC9C,WAAY,SAAS,KAAM,IAC3B;CACL;CACA,OAAO;AACR;;;;;;;;;;;;;;;;;AAkBA,SAAS,UACR,OACA,MACA,YAAyB,CAAC,GACZ;CACd,MAAM,SAAsB,CAAC;CAC7B,KAAM,MAAM,OAAO,OAAO,KAAM,KAAM,GAAI;EACzC,MAAM,OAAO,MAAO;EACpB,MAAM,UAAU,KAAM;EACtB,MAAM,OAAO,UAAW;EACxB,IAAK,SAAS,KAAA,GACb;EAED,IAAK,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AAoB,WAAY,CACjC,GACA,mBACD;AACD;;;;;;;;;;;;;AAcA,SAAgB,YAAa,MAA8B;CAC1D,MAAM,EAAE,aAAa,gBAAgB,qBAAqB,MAAM,WAC/D;CACD,MAAM,gBAAgB,2BACrB,KAAK,eACL,cACD;CAmBA,OAAO;EAVN,GAAG,mBACF,WAJe,gBAAiB,MADjC,eAAe,QAAQ,qBAAqB,QAAQ,aAAa,IAK7C,GAAG,mBAAoB,aAAc,CAAE,GAC1D,mBACD;EACA,MAAM,OAAQ,QAAQ,CAAE;EACxB,QAAQ,UAAU;CAKT;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,qBACf,SACA,QAC4B;CAC5B,MAAM,EAAE,gBAAgB,wBAAwB;CAChD,MAAM,gBAAgB,2BACrB,OAAO,eACP,cACD;CACA,MAAM,WAAW,gBAAiB,QAAQ,QAAQ,IAAK;CAEvD,MAAM,gBAAgB,UACrB,mBAAoB,OAAQ,GAC5B,mBAAoB,QAAS,GAC7B,mBAAoB,aAAc,CACnC;CAIA,MAAM,SAAS,iBAAkB,mBAAoB;CACrD,IAAK,OAAO,SAAS,KAAK,MAAM,QAAS,cAAc,OAAQ,GAC9D,cAAc,UAAY,cAAc,QAAsB,QAC3D,WAAY,CAAE,OAAO,MAAQ,MAAO,EAAE,UAAU,OAAO,KAAM,CAChE;CAGD,OAAO,OAAO,KAAM,aAAc,CAAC,CAAC,SAAS,IACxC,gBACF,KAAA;AACJ"}
|
|
1
|
+
{"version":3,"file":"resolve-view.cjs","names":[],"sources":["../src/resolve-view.ts"],"sourcesContent":["import { dequal } from 'dequal';\nimport type { View, Filter, SupportedLayouts } from '@wordpress/dataviews';\nimport type { ViewOverrides } from './types';\n\ntype PlainObject = Record< string, unknown >;\n\n/**\n * `page` and `search` are URL-managed: the URL is their only source. They are\n * never persisted, and no other layer may configure them — an absent URL param\n * is indistinguishable from the user having cleared the value, so any fallback\n * would resurrect a cleared search on the next read.\n */\nconst QUERY_PARAMS = [ 'page', 'search' ] as const;\n\nfunction isPlainObject( value: unknown ): value is PlainObject {\n\treturn (\n\t\ttypeof value === 'object' && value !== null && ! Array.isArray( value )\n\t);\n}\n\n/**\n * Copies a layer without the URL-managed properties.\n *\n * @param layer The layer to copy.\n * @return A copy of the layer with `page` and `search` removed.\n */\nfunction withoutQueryParams( layer: unknown ): PlainObject {\n\tconst result: PlainObject = isPlainObject( layer ) ? { ...layer } : {};\n\tfor ( const key of QUERY_PARAMS ) {\n\t\tdelete result[ key ];\n\t}\n\treturn result;\n}\n\n/**\n * Merges a layer on top of another, recursing into plain objects so the upper\n * layer only takes over the leaves it declares. Arrays and scalars are leaves:\n * they are replaced wholesale.\n *\n * Nested properties (`layout.styles.<field>.width`, `groupBy.direction`,\n * `sort.direction`) are merged leaf by leaf: a shallow merge would let a layer\n * that only declares one leaf wipe every sibling the layers below provide.\n *\n * @param lower The layer to merge into.\n * @param upper The layer to merge on top.\n * @return The merged layer.\n */\nfunction mergeLayer( lower: PlainObject, upper: PlainObject ): PlainObject {\n\tconst result: PlainObject = { ...lower };\n\tfor ( const key of Object.keys( upper ) ) {\n\t\tconst value = upper[ key ];\n\t\tconst current = result[ key ];\n\t\tresult[ key ] =\n\t\t\tisPlainObject( current ) && isPlainObject( value )\n\t\t\t\t? mergeLayer( current, value )\n\t\t\t\t: value;\n\t}\n\treturn result;\n}\n\n/**\n * The leaves of `value` that differ from `base`. Mirrors `mergeLayer`:\n * `mergeLayer( base, diffLayer( value, base ) )` resolves back to `value`.\n *\n * A persisted leaf that equals both `value` and `base` is kept even though it\n * is not a difference: the preference is shared by every view of the same\n * entity, and such a leaf may only differ from the base of *another* view. In\n * this one, where it coincides with the base, a revert is unobservable — so\n * equality cannot mean the user reverted it. Dropping a persisted leaf\n * requires `value` to actually move away from it, back to `base`.\n *\n * @param value The layer to compare.\n * @param base The layer to compare it against.\n * @param persisted The previously persisted leaves.\n * @return The leaves that differ, as a layer of its own.\n */\nfunction diffLayer(\n\tvalue: PlainObject,\n\tbase: PlainObject,\n\tpersisted: PlainObject = {}\n): PlainObject {\n\tconst result: PlainObject = {};\n\tfor ( const key of Object.keys( value ) ) {\n\t\tconst next = value[ key ];\n\t\tconst current = base[ key ];\n\t\tconst prev = persisted[ key ];\n\t\tif ( next === undefined ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( isPlainObject( next ) && isPlainObject( current ) ) {\n\t\t\tconst nested = diffLayer(\n\t\t\t\tnext,\n\t\t\t\tcurrent,\n\t\t\t\tisPlainObject( prev ) ? prev : {}\n\t\t\t);\n\t\t\tif ( Object.keys( nested ).length > 0 ) {\n\t\t\t\tresult[ key ] = nested;\n\t\t\t}\n\t\t} else if ( ! dequal( next, current ) ) {\n\t\t\tresult[ key ] = next;\n\t\t} else if ( prev !== undefined && dequal( next, prev ) ) {\n\t\t\tresult[ key ] = prev;\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction getLockedFilters( overrides?: ViewOverrides ): Filter[] {\n\treturn ( overrides?.filters ?? [] ).filter( ( filter ) => filter.isLocked );\n}\n\n/**\n * Hoists the locked filters an override provides to the front of the view's\n * filters, replacing any same-field filter. Locked filters are not the user's\n * to change, so they are pinned in place instead of taking part in the layer\n * resolution.\n *\n * @param view The view to apply the locked filters to.\n * @param overrides The active view overrides.\n * @return The view with the locked filters applied.\n */\nfunction applyLockedFilters(\n\tview: PlainObject,\n\toverrides?: ViewOverrides\n): PlainObject {\n\tconst locked = getLockedFilters( overrides );\n\tif ( locked.length === 0 ) {\n\t\treturn view;\n\t}\n\tconst rest = ( ( view.filters ?? [] ) as Filter[] ).filter(\n\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t);\n\treturn { ...view, filters: [ ...locked, ...rest ] };\n}\n\ninterface ViewLayers {\n\tdefaultView?: View;\n\tdefaultLayouts?: SupportedLayouts;\n\tactiveViewOverrides?: ViewOverrides;\n\t/**\n\t * The user's persisted modifications: a partial view holding only the\n\t * properties they actually changed.\n\t */\n\tpersistedView?: ViewOverrides;\n}\n\ninterface ResolveViewArgs extends ViewLayers {\n\tpage?: number;\n\tsearch?: string;\n}\n\n/**\n * The user's persisted modifications that still apply.\n *\n * A persisted `type` that `defaultLayouts` does not offer is dropped: DataViews\n * renders nothing for a layout it is not given, and the preference may predate\n * the current set of layouts (a screen that used to offer the list layout, say,\n * and no longer does). The type then resolves out of the layers below, and the\n * other modifications are kept. Without `defaultLayouts` every type is offered.\n *\n * `true` is a valid entry, so the check mirrors DataViews': an entry counts as\n * long as it is truthy.\n *\n * @param persistedView The user's persisted modifications.\n * @param defaultLayouts The layouts on offer, keyed by layout type.\n * @return The modifications that apply, or `undefined` when there are none.\n */\nexport function getApplicablePersistedView(\n\tpersistedView: ViewOverrides | undefined,\n\tdefaultLayouts: SupportedLayouts | undefined\n): ViewOverrides | undefined {\n\tif (\n\t\t! persistedView ||\n\t\tpersistedView.type === undefined ||\n\t\t! defaultLayouts ||\n\t\tdefaultLayouts[ persistedView.type as keyof SupportedLayouts ]\n\t) {\n\t\treturn persistedView;\n\t}\n\tconst { type, ...rest } = persistedView;\n\treturn Object.keys( rest ).length > 0 ? rest : undefined;\n}\n\n/**\n * Resolves the layers below the user's modifications — what a modification has\n * to differ from to count as one. The layout type selects which entry of\n * `defaultLayouts` applies, so the base only makes sense relative to a type.\n *\n * @param layers The layers to resolve.\n * @param effectiveType The layout type to resolve the base at.\n * @return The resolved base view.\n */\nfunction resolveBaseView(\n\tlayers: ViewLayers,\n\teffectiveType: View[ 'type' ] | undefined\n): PlainObject {\n\tconst { defaultView, defaultLayouts, activeViewOverrides } = layers;\n\tconst layoutDefaults =\n\t\tdefaultLayouts?.[ effectiveType as keyof SupportedLayouts ];\n\treturn applyLockedFilters(\n\t\t[ layoutDefaults, activeViewOverrides ].reduce< PlainObject >(\n\t\t\t( lower, upper ) =>\n\t\t\t\tmergeLayer( lower, withoutQueryParams( upper ) ),\n\t\t\twithoutQueryParams( defaultView )\n\t\t),\n\t\tactiveViewOverrides\n\t);\n}\n\n/**\n * Resolves a view out of its layers. Later layers override earlier ones:\n *\n * 1. `defaultView`\n * 2. `defaultLayouts` (for the effective type)\n * 3. `activeViewOverrides`\n * 4. the user's persisted modifications (see `getApplicablePersistedView`)\n * 5. the URL query params (`page` and `search` only)\n *\n * @param args See `ResolveViewArgs`.\n * @return The resolved `view`.\n */\nexport function resolveView( args: ResolveViewArgs ): View {\n\tconst { defaultView, defaultLayouts, activeViewOverrides, page, search } =\n\t\targs;\n\tconst persistedView = getApplicablePersistedView(\n\t\targs.persistedView,\n\t\tdefaultLayouts\n\t);\n\n\t// Resolve the effective layout type first: it selects which entry of\n\t// `defaultLayouts` applies, and the layers above the layouts may change it.\n\tconst effectiveType =\n\t\tpersistedView?.type ?? activeViewOverrides?.type ?? defaultView?.type;\n\tconst baseView = resolveBaseView( args, effectiveType );\n\n\tconst view = {\n\t\t...applyLockedFilters(\n\t\t\tmergeLayer( baseView, withoutQueryParams( persistedView ) ),\n\t\t\tactiveViewOverrides\n\t\t),\n\t\tpage: Number( page ?? 1 ),\n\t\tsearch: search ?? '',\n\t};\n\n\t// The layers are resolved as plain objects: `View` requires a `type`, which\n\t// only the layers taken together are guaranteed to provide.\n\treturn view as unknown as View;\n}\n\n/**\n * The user's modifications: the leaves of the view they interacted with that\n * the layers below do not already resolve to. This is what gets persisted, so\n * that a change to any of those layers keeps showing through the properties the\n * user never touched.\n *\n * Previously persisted leaves that coincide with the base of the current view\n * are carried over rather than dropped: they may still make a difference in\n * another view sharing the preference. See `diffLayer`.\n *\n * The diff basis is resolved at `newView.type`, not at the type the previous\n * resolution used: the type selects the `defaultLayouts` entry, and a layout\n * switch reports the new type together with that entry's values. Diffing them\n * against the previous type's base would persist the difference between the\n * two entries as if the user had picked those values — leaves the layouts\n * already provide, which then linger as phantom modifications after switching\n * back.\n *\n * A persisted `type` the current layouts do not offer never applied (see\n * `getApplicablePersistedView`), so it is not carried over either: the\n * modifications returned replace it with whatever the user picked.\n *\n * @param newView The view the user produced.\n * @param layers The layers the view resolves from. See `ViewLayers`.\n * @return The modified properties, or `undefined` when the user modified none.\n */\nexport function getUserModifications(\n\tnewView: View,\n\tlayers: ViewLayers\n): ViewOverrides | undefined {\n\tconst { defaultLayouts, activeViewOverrides } = layers;\n\tconst persistedView = getApplicablePersistedView(\n\t\tlayers.persistedView,\n\t\tdefaultLayouts\n\t);\n\tconst baseView = resolveBaseView( layers, newView.type );\n\n\tconst modifications = diffLayer(\n\t\twithoutQueryParams( newView ),\n\t\twithoutQueryParams( baseView ),\n\t\twithoutQueryParams( persistedView )\n\t);\n\n\t// Locked filters are pinned on every read, so persisting them would only\n\t// leak them into the views that do not lock them.\n\tconst locked = getLockedFilters( activeViewOverrides );\n\tif ( locked.length > 0 && Array.isArray( modifications.filters ) ) {\n\t\tmodifications.filters = ( modifications.filters as Filter[] ).filter(\n\t\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t\t);\n\t}\n\n\treturn Object.keys( modifications ).length > 0\n\t\t? ( modifications as ViewOverrides )\n\t\t: undefined;\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,eAAe,CAAE,QAAQ,QAAS;AAExC,SAAS,cAAe,OAAuC;CAC9D,OACC,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAE,MAAM,QAAS,KAAM;AAExE;;;;;;;AAQA,SAAS,mBAAoB,OAA8B;CAC1D,MAAM,SAAsB,cAAe,KAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC;CACrE,KAAM,MAAM,OAAO,cAClB,OAAO,OAAQ;CAEhB,OAAO;AACR;;;;;;;;;;;;;;AAeA,SAAS,WAAY,OAAoB,OAAkC;CAC1E,MAAM,SAAsB,EAAE,GAAG,MAAM;CACvC,KAAM,MAAM,OAAO,OAAO,KAAM,KAAM,GAAI;EACzC,MAAM,QAAQ,MAAO;EACrB,MAAM,UAAU,OAAQ;EACxB,OAAQ,OACP,cAAe,OAAQ,KAAK,cAAe,KAAM,IAC9C,WAAY,SAAS,KAAM,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
|
|
128
128
|
*/
|
|
129
129
|
function resolveBaseView(layers, effectiveType) {
|
|
130
130
|
const { defaultView, defaultLayouts, activeViewOverrides } = layers;
|
|
131
|
-
|
|
132
|
-
return applyLockedFilters([layoutDefaults, activeViewOverrides].reduce((lower, upper) => mergeLayer(lower, withoutQueryParams(upper)), withoutQueryParams(defaultView)), activeViewOverrides);
|
|
131
|
+
return applyLockedFilters([defaultLayouts?.[effectiveType], activeViewOverrides].reduce((lower, upper) => mergeLayer(lower, withoutQueryParams(upper)), withoutQueryParams(defaultView)), activeViewOverrides);
|
|
133
132
|
}
|
|
134
133
|
/**
|
|
135
134
|
* Resolves a view out of its layers. Later layers override earlier ones:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-view.mjs","names":[],"sources":["../src/resolve-view.ts"],"sourcesContent":["import { dequal } from 'dequal';\nimport type { View, Filter, SupportedLayouts } from '@wordpress/dataviews';\nimport type { ViewOverrides } from './types';\n\ntype PlainObject = Record< string, unknown >;\n\n/**\n * `page` and `search` are URL-managed: the URL is their only source. They are\n * never persisted, and no other layer may configure them — an absent URL param\n * is indistinguishable from the user having cleared the value, so any fallback\n * would resurrect a cleared search on the next read.\n */\nconst QUERY_PARAMS = [ 'page', 'search' ] as const;\n\nfunction isPlainObject( value: unknown ): value is PlainObject {\n\treturn (\n\t\ttypeof value === 'object' && value !== null && ! Array.isArray( value )\n\t);\n}\n\n/**\n * Copies a layer without the URL-managed properties.\n *\n * @param layer The layer to copy.\n * @return A copy of the layer with `page` and `search` removed.\n */\nfunction withoutQueryParams( layer: unknown ): PlainObject {\n\tconst result: PlainObject = isPlainObject( layer ) ? { ...layer } : {};\n\tfor ( const key of QUERY_PARAMS ) {\n\t\tdelete result[ key ];\n\t}\n\treturn result;\n}\n\n/**\n * Merges a layer on top of another, recursing into plain objects so the upper\n * layer only takes over the leaves it declares. Arrays and scalars are leaves:\n * they are replaced wholesale.\n *\n * Nested properties (`layout.styles.<field>.width`, `groupBy.direction`,\n * `sort.direction`) are merged leaf by leaf: a shallow merge would let a layer\n * that only declares one leaf wipe every sibling the layers below provide.\n *\n * @param lower The layer to merge into.\n * @param upper The layer to merge on top.\n * @return The merged layer.\n */\nfunction mergeLayer( lower: PlainObject, upper: PlainObject ): PlainObject {\n\tconst result: PlainObject = { ...lower };\n\tfor ( const key of Object.keys( upper ) ) {\n\t\tconst value = upper[ key ];\n\t\tconst current = result[ key ];\n\t\tresult[ key ] =\n\t\t\tisPlainObject( current ) && isPlainObject( value )\n\t\t\t\t? mergeLayer( current, value )\n\t\t\t\t: value;\n\t}\n\treturn result;\n}\n\n/**\n * The leaves of `value` that differ from `base`. Mirrors `mergeLayer`:\n * `mergeLayer( base, diffLayer( value, base ) )` resolves back to `value`.\n *\n * A persisted leaf that equals both `value` and `base` is kept even though it\n * is not a difference: the preference is shared by every view of the same\n * entity, and such a leaf may only differ from the base of *another* view. In\n * this one, where it coincides with the base, a revert is unobservable — so\n * equality cannot mean the user reverted it. Dropping a persisted leaf\n * requires `value` to actually move away from it, back to `base`.\n *\n * @param value The layer to compare.\n * @param base The layer to compare it against.\n * @param persisted The previously persisted leaves.\n * @return The leaves that differ, as a layer of its own.\n */\nfunction diffLayer(\n\tvalue: PlainObject,\n\tbase: PlainObject,\n\tpersisted: PlainObject = {}\n): PlainObject {\n\tconst result: PlainObject = {};\n\tfor ( const key of Object.keys( value ) ) {\n\t\tconst next = value[ key ];\n\t\tconst current = base[ key ];\n\t\tconst prev = persisted[ key ];\n\t\tif ( next === undefined ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( isPlainObject( next ) && isPlainObject( current ) ) {\n\t\t\tconst nested = diffLayer(\n\t\t\t\tnext,\n\t\t\t\tcurrent,\n\t\t\t\tisPlainObject( prev ) ? prev : {}\n\t\t\t);\n\t\t\tif ( Object.keys( nested ).length > 0 ) {\n\t\t\t\tresult[ key ] = nested;\n\t\t\t}\n\t\t} else if ( ! dequal( next, current ) ) {\n\t\t\tresult[ key ] = next;\n\t\t} else if ( prev !== undefined && dequal( next, prev ) ) {\n\t\t\tresult[ key ] = prev;\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction getLockedFilters( overrides?: ViewOverrides ): Filter[] {\n\treturn ( overrides?.filters ?? [] ).filter( ( filter ) => filter.isLocked );\n}\n\n/**\n * Hoists the locked filters an override provides to the front of the view's\n * filters, replacing any same-field filter. Locked filters are not the user's\n * to change, so they are pinned in place instead of taking part in the layer\n * resolution.\n *\n * @param view The view to apply the locked filters to.\n * @param overrides The active view overrides.\n * @return The view with the locked filters applied.\n */\nfunction applyLockedFilters(\n\tview: PlainObject,\n\toverrides?: ViewOverrides\n): PlainObject {\n\tconst locked = getLockedFilters( overrides );\n\tif ( locked.length === 0 ) {\n\t\treturn view;\n\t}\n\tconst rest = ( ( view.filters ?? [] ) as Filter[] ).filter(\n\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t);\n\treturn { ...view, filters: [ ...locked, ...rest ] };\n}\n\ninterface ViewLayers {\n\tdefaultView?: View;\n\tdefaultLayouts?: SupportedLayouts;\n\tactiveViewOverrides?: ViewOverrides;\n\t/**\n\t * The user's persisted modifications: a partial view holding only the\n\t * properties they actually changed.\n\t */\n\tpersistedView?: ViewOverrides;\n}\n\ninterface ResolveViewArgs extends ViewLayers {\n\tpage?: number;\n\tsearch?: string;\n}\n\n/**\n * The user's persisted modifications that still apply.\n *\n * A persisted `type` that `defaultLayouts` does not offer is dropped: DataViews\n * renders nothing for a layout it is not given, and the preference may predate\n * the current set of layouts (a screen that used to offer the list layout, say,\n * and no longer does). The type then resolves out of the layers below, and the\n * other modifications are kept. Without `defaultLayouts` every type is offered.\n *\n * `true` is a valid entry, so the check mirrors DataViews': an entry counts as\n * long as it is truthy.\n *\n * @param persistedView The user's persisted modifications.\n * @param defaultLayouts The layouts on offer, keyed by layout type.\n * @return The modifications that apply, or `undefined` when there are none.\n */\nexport function getApplicablePersistedView(\n\tpersistedView: ViewOverrides | undefined,\n\tdefaultLayouts: SupportedLayouts | undefined\n): ViewOverrides | undefined {\n\tif (\n\t\t! persistedView ||\n\t\tpersistedView.type === undefined ||\n\t\t! defaultLayouts ||\n\t\tdefaultLayouts[ persistedView.type as keyof SupportedLayouts ]\n\t) {\n\t\treturn persistedView;\n\t}\n\tconst { type, ...rest } = persistedView;\n\treturn Object.keys( rest ).length > 0 ? rest : undefined;\n}\n\n/**\n * Resolves the layers below the user's modifications — what a modification has\n * to differ from to count as one. The layout type selects which entry of\n * `defaultLayouts` applies, so the base only makes sense relative to a type.\n *\n * @param layers The layers to resolve.\n * @param effectiveType The layout type to resolve the base at.\n * @return The resolved base view.\n */\nfunction resolveBaseView(\n\tlayers: ViewLayers,\n\teffectiveType: View[ 'type' ] | undefined\n): PlainObject {\n\tconst { defaultView, defaultLayouts, activeViewOverrides } = layers;\n\tconst layoutDefaults =\n\t\tdefaultLayouts?.[ effectiveType as keyof SupportedLayouts ];\n\treturn applyLockedFilters(\n\t\t[ layoutDefaults, activeViewOverrides ].reduce< PlainObject >(\n\t\t\t( lower, upper ) =>\n\t\t\t\tmergeLayer( lower, withoutQueryParams( upper ) ),\n\t\t\twithoutQueryParams( defaultView )\n\t\t),\n\t\tactiveViewOverrides\n\t);\n}\n\n/**\n * Resolves a view out of its layers. Later layers override earlier ones:\n *\n * 1. `defaultView`\n * 2. `defaultLayouts` (for the effective type)\n * 3. `activeViewOverrides`\n * 4. the user's persisted modifications (see `getApplicablePersistedView`)\n * 5. the URL query params (`page` and `search` only)\n *\n * @param args See `ResolveViewArgs`.\n * @return The resolved `view`.\n */\nexport function resolveView( args: ResolveViewArgs ): View {\n\tconst { defaultView, defaultLayouts, activeViewOverrides, page, search } =\n\t\targs;\n\tconst persistedView = getApplicablePersistedView(\n\t\targs.persistedView,\n\t\tdefaultLayouts\n\t);\n\n\t// Resolve the effective layout type first: it selects which entry of\n\t// `defaultLayouts` applies, and the layers above the layouts may change it.\n\tconst effectiveType =\n\t\tpersistedView?.type ?? activeViewOverrides?.type ?? defaultView?.type;\n\tconst baseView = resolveBaseView( args, effectiveType );\n\n\tconst view = {\n\t\t...applyLockedFilters(\n\t\t\tmergeLayer( baseView, withoutQueryParams( persistedView ) ),\n\t\t\tactiveViewOverrides\n\t\t),\n\t\tpage: Number( page ?? 1 ),\n\t\tsearch: search ?? '',\n\t};\n\n\t// The layers are resolved as plain objects: `View` requires a `type`, which\n\t// only the layers taken together are guaranteed to provide.\n\treturn view as unknown as View;\n}\n\n/**\n * The user's modifications: the leaves of the view they interacted with that\n * the layers below do not already resolve to. This is what gets persisted, so\n * that a change to any of those layers keeps showing through the properties the\n * user never touched.\n *\n * Previously persisted leaves that coincide with the base of the current view\n * are carried over rather than dropped: they may still make a difference in\n * another view sharing the preference. See `diffLayer`.\n *\n * The diff basis is resolved at `newView.type`, not at the type the previous\n * resolution used: the type selects the `defaultLayouts` entry, and a layout\n * switch reports the new type together with that entry's values. Diffing them\n * against the previous type's base would persist the difference between the\n * two entries as if the user had picked those values — leaves the layouts\n * already provide, which then linger as phantom modifications after switching\n * back.\n *\n * A persisted `type` the current layouts do not offer never applied (see\n * `getApplicablePersistedView`), so it is not carried over either: the\n * modifications returned replace it with whatever the user picked.\n *\n * @param newView The view the user produced.\n * @param layers The layers the view resolves from. See `ViewLayers`.\n * @return The modified properties, or `undefined` when the user modified none.\n */\nexport function getUserModifications(\n\tnewView: View,\n\tlayers: ViewLayers\n): ViewOverrides | undefined {\n\tconst { defaultLayouts, activeViewOverrides } = layers;\n\tconst persistedView = getApplicablePersistedView(\n\t\tlayers.persistedView,\n\t\tdefaultLayouts\n\t);\n\tconst baseView = resolveBaseView( layers, newView.type );\n\n\tconst modifications = diffLayer(\n\t\twithoutQueryParams( newView ),\n\t\twithoutQueryParams( baseView ),\n\t\twithoutQueryParams( persistedView )\n\t);\n\n\t// Locked filters are pinned on every read, so persisting them would only\n\t// leak them into the views that do not lock them.\n\tconst locked = getLockedFilters( activeViewOverrides );\n\tif ( locked.length > 0 && Array.isArray( modifications.filters ) ) {\n\t\tmodifications.filters = ( modifications.filters as Filter[] ).filter(\n\t\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t\t);\n\t}\n\n\treturn Object.keys( modifications ).length > 0\n\t\t? ( modifications as ViewOverrides )\n\t\t: undefined;\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,eAAe,CAAE,QAAQ,QAAS;AAExC,SAAS,cAAe,OAAuC;CAC9D,OACC,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAE,MAAM,QAAS,KAAM;AAExE;;;;;;;AAQA,SAAS,mBAAoB,OAA8B;CAC1D,MAAM,SAAsB,cAAe,KAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC;CACrE,KAAM,MAAM,OAAO,cAClB,OAAO,OAAQ;CAEhB,OAAO;AACR;;;;;;;;;;;;;;AAeA,SAAS,WAAY,OAAoB,OAAkC;CAC1E,MAAM,SAAsB,EAAE,GAAG,MAAM;CACvC,KAAM,MAAM,OAAO,OAAO,KAAM,KAAM,GAAI;EACzC,MAAM,QAAQ,MAAO;EACrB,MAAM,UAAU,OAAQ;EACxB,OAAQ,OACP,cAAe,OAAQ,KAAK,cAAe,KAAM,IAC9C,WAAY,SAAS,KAAM,IAC3B;CACL;CACA,OAAO;AACR;;;;;;;;;;;;;;;;;AAkBA,SAAS,UACR,OACA,MACA,YAAyB,CAAC,GACZ;CACd,MAAM,SAAsB,CAAC;CAC7B,KAAM,MAAM,OAAO,OAAO,KAAM,KAAM,GAAI;EACzC,MAAM,OAAO,MAAO;EACpB,MAAM,UAAU,KAAM;EACtB,MAAM,OAAO,UAAW;EACxB,IAAK,SAAS,KAAA,GACb;EAED,IAAK,cAAe,IAAK,KAAK,cAAe,OAAQ,GAAI;GACxD,MAAM,SAAS,UACd,MACA,SACA,cAAe,IAAK,IAAI,OAAO,CAAC,CACjC;GACA,IAAK,OAAO,KAAM,MAAO,CAAC,CAAC,SAAS,GACnC,OAAQ,OAAQ;EAElB,OAAO,IAAK,CAA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AAQ,qBAAqB,QAAQ,aAAa,IAK7C,GAAG,mBAAoB,aAAc,CAAE,GAC1D,mBACD;EACA,MAAM,OAAQ,QAAQ,CAAE;EACxB,QAAQ,UAAU;CAKT;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,qBACf,SACA,QAC4B;CAC5B,MAAM,EAAE,gBAAgB,wBAAwB;CAChD,MAAM,gBAAgB,2BACrB,OAAO,eACP,cACD;CACA,MAAM,WAAW,gBAAiB,QAAQ,QAAQ,IAAK;CAEvD,MAAM,gBAAgB,UACrB,mBAAoB,OAAQ,GAC5B,mBAAoB,QAAS,GAC7B,mBAAoB,aAAc,CACnC;CAIA,MAAM,SAAS,iBAAkB,mBAAoB;CACrD,IAAK,OAAO,SAAS,KAAK,MAAM,QAAS,cAAc,OAAQ,GAC9D,cAAc,UAAY,cAAc,QAAsB,QAC3D,WAAY,CAAE,OAAO,MAAQ,MAAO,EAAE,UAAU,OAAO,KAAM,CAChE;CAGD,OAAO,OAAO,KAAM,aAAc,CAAC,CAAC,SAAS,IACxC,gBACF,KAAA;AACJ"}
|
|
1
|
+
{"version":3,"file":"resolve-view.mjs","names":[],"sources":["../src/resolve-view.ts"],"sourcesContent":["import { dequal } from 'dequal';\nimport type { View, Filter, SupportedLayouts } from '@wordpress/dataviews';\nimport type { ViewOverrides } from './types';\n\ntype PlainObject = Record< string, unknown >;\n\n/**\n * `page` and `search` are URL-managed: the URL is their only source. They are\n * never persisted, and no other layer may configure them — an absent URL param\n * is indistinguishable from the user having cleared the value, so any fallback\n * would resurrect a cleared search on the next read.\n */\nconst QUERY_PARAMS = [ 'page', 'search' ] as const;\n\nfunction isPlainObject( value: unknown ): value is PlainObject {\n\treturn (\n\t\ttypeof value === 'object' && value !== null && ! Array.isArray( value )\n\t);\n}\n\n/**\n * Copies a layer without the URL-managed properties.\n *\n * @param layer The layer to copy.\n * @return A copy of the layer with `page` and `search` removed.\n */\nfunction withoutQueryParams( layer: unknown ): PlainObject {\n\tconst result: PlainObject = isPlainObject( layer ) ? { ...layer } : {};\n\tfor ( const key of QUERY_PARAMS ) {\n\t\tdelete result[ key ];\n\t}\n\treturn result;\n}\n\n/**\n * Merges a layer on top of another, recursing into plain objects so the upper\n * layer only takes over the leaves it declares. Arrays and scalars are leaves:\n * they are replaced wholesale.\n *\n * Nested properties (`layout.styles.<field>.width`, `groupBy.direction`,\n * `sort.direction`) are merged leaf by leaf: a shallow merge would let a layer\n * that only declares one leaf wipe every sibling the layers below provide.\n *\n * @param lower The layer to merge into.\n * @param upper The layer to merge on top.\n * @return The merged layer.\n */\nfunction mergeLayer( lower: PlainObject, upper: PlainObject ): PlainObject {\n\tconst result: PlainObject = { ...lower };\n\tfor ( const key of Object.keys( upper ) ) {\n\t\tconst value = upper[ key ];\n\t\tconst current = result[ key ];\n\t\tresult[ key ] =\n\t\t\tisPlainObject( current ) && isPlainObject( value )\n\t\t\t\t? mergeLayer( current, value )\n\t\t\t\t: value;\n\t}\n\treturn result;\n}\n\n/**\n * The leaves of `value` that differ from `base`. Mirrors `mergeLayer`:\n * `mergeLayer( base, diffLayer( value, base ) )` resolves back to `value`.\n *\n * A persisted leaf that equals both `value` and `base` is kept even though it\n * is not a difference: the preference is shared by every view of the same\n * entity, and such a leaf may only differ from the base of *another* view. In\n * this one, where it coincides with the base, a revert is unobservable — so\n * equality cannot mean the user reverted it. Dropping a persisted leaf\n * requires `value` to actually move away from it, back to `base`.\n *\n * @param value The layer to compare.\n * @param base The layer to compare it against.\n * @param persisted The previously persisted leaves.\n * @return The leaves that differ, as a layer of its own.\n */\nfunction diffLayer(\n\tvalue: PlainObject,\n\tbase: PlainObject,\n\tpersisted: PlainObject = {}\n): PlainObject {\n\tconst result: PlainObject = {};\n\tfor ( const key of Object.keys( value ) ) {\n\t\tconst next = value[ key ];\n\t\tconst current = base[ key ];\n\t\tconst prev = persisted[ key ];\n\t\tif ( next === undefined ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( isPlainObject( next ) && isPlainObject( current ) ) {\n\t\t\tconst nested = diffLayer(\n\t\t\t\tnext,\n\t\t\t\tcurrent,\n\t\t\t\tisPlainObject( prev ) ? prev : {}\n\t\t\t);\n\t\t\tif ( Object.keys( nested ).length > 0 ) {\n\t\t\t\tresult[ key ] = nested;\n\t\t\t}\n\t\t} else if ( ! dequal( next, current ) ) {\n\t\t\tresult[ key ] = next;\n\t\t} else if ( prev !== undefined && dequal( next, prev ) ) {\n\t\t\tresult[ key ] = prev;\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction getLockedFilters( overrides?: ViewOverrides ): Filter[] {\n\treturn ( overrides?.filters ?? [] ).filter( ( filter ) => filter.isLocked );\n}\n\n/**\n * Hoists the locked filters an override provides to the front of the view's\n * filters, replacing any same-field filter. Locked filters are not the user's\n * to change, so they are pinned in place instead of taking part in the layer\n * resolution.\n *\n * @param view The view to apply the locked filters to.\n * @param overrides The active view overrides.\n * @return The view with the locked filters applied.\n */\nfunction applyLockedFilters(\n\tview: PlainObject,\n\toverrides?: ViewOverrides\n): PlainObject {\n\tconst locked = getLockedFilters( overrides );\n\tif ( locked.length === 0 ) {\n\t\treturn view;\n\t}\n\tconst rest = ( ( view.filters ?? [] ) as Filter[] ).filter(\n\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t);\n\treturn { ...view, filters: [ ...locked, ...rest ] };\n}\n\ninterface ViewLayers {\n\tdefaultView?: View;\n\tdefaultLayouts?: SupportedLayouts;\n\tactiveViewOverrides?: ViewOverrides;\n\t/**\n\t * The user's persisted modifications: a partial view holding only the\n\t * properties they actually changed.\n\t */\n\tpersistedView?: ViewOverrides;\n}\n\ninterface ResolveViewArgs extends ViewLayers {\n\tpage?: number;\n\tsearch?: string;\n}\n\n/**\n * The user's persisted modifications that still apply.\n *\n * A persisted `type` that `defaultLayouts` does not offer is dropped: DataViews\n * renders nothing for a layout it is not given, and the preference may predate\n * the current set of layouts (a screen that used to offer the list layout, say,\n * and no longer does). The type then resolves out of the layers below, and the\n * other modifications are kept. Without `defaultLayouts` every type is offered.\n *\n * `true` is a valid entry, so the check mirrors DataViews': an entry counts as\n * long as it is truthy.\n *\n * @param persistedView The user's persisted modifications.\n * @param defaultLayouts The layouts on offer, keyed by layout type.\n * @return The modifications that apply, or `undefined` when there are none.\n */\nexport function getApplicablePersistedView(\n\tpersistedView: ViewOverrides | undefined,\n\tdefaultLayouts: SupportedLayouts | undefined\n): ViewOverrides | undefined {\n\tif (\n\t\t! persistedView ||\n\t\tpersistedView.type === undefined ||\n\t\t! defaultLayouts ||\n\t\tdefaultLayouts[ persistedView.type as keyof SupportedLayouts ]\n\t) {\n\t\treturn persistedView;\n\t}\n\tconst { type, ...rest } = persistedView;\n\treturn Object.keys( rest ).length > 0 ? rest : undefined;\n}\n\n/**\n * Resolves the layers below the user's modifications — what a modification has\n * to differ from to count as one. The layout type selects which entry of\n * `defaultLayouts` applies, so the base only makes sense relative to a type.\n *\n * @param layers The layers to resolve.\n * @param effectiveType The layout type to resolve the base at.\n * @return The resolved base view.\n */\nfunction resolveBaseView(\n\tlayers: ViewLayers,\n\teffectiveType: View[ 'type' ] | undefined\n): PlainObject {\n\tconst { defaultView, defaultLayouts, activeViewOverrides } = layers;\n\tconst layoutDefaults =\n\t\tdefaultLayouts?.[ effectiveType as keyof SupportedLayouts ];\n\treturn applyLockedFilters(\n\t\t[ layoutDefaults, activeViewOverrides ].reduce< PlainObject >(\n\t\t\t( lower, upper ) =>\n\t\t\t\tmergeLayer( lower, withoutQueryParams( upper ) ),\n\t\t\twithoutQueryParams( defaultView )\n\t\t),\n\t\tactiveViewOverrides\n\t);\n}\n\n/**\n * Resolves a view out of its layers. Later layers override earlier ones:\n *\n * 1. `defaultView`\n * 2. `defaultLayouts` (for the effective type)\n * 3. `activeViewOverrides`\n * 4. the user's persisted modifications (see `getApplicablePersistedView`)\n * 5. the URL query params (`page` and `search` only)\n *\n * @param args See `ResolveViewArgs`.\n * @return The resolved `view`.\n */\nexport function resolveView( args: ResolveViewArgs ): View {\n\tconst { defaultView, defaultLayouts, activeViewOverrides, page, search } =\n\t\targs;\n\tconst persistedView = getApplicablePersistedView(\n\t\targs.persistedView,\n\t\tdefaultLayouts\n\t);\n\n\t// Resolve the effective layout type first: it selects which entry of\n\t// `defaultLayouts` applies, and the layers above the layouts may change it.\n\tconst effectiveType =\n\t\tpersistedView?.type ?? activeViewOverrides?.type ?? defaultView?.type;\n\tconst baseView = resolveBaseView( args, effectiveType );\n\n\tconst view = {\n\t\t...applyLockedFilters(\n\t\t\tmergeLayer( baseView, withoutQueryParams( persistedView ) ),\n\t\t\tactiveViewOverrides\n\t\t),\n\t\tpage: Number( page ?? 1 ),\n\t\tsearch: search ?? '',\n\t};\n\n\t// The layers are resolved as plain objects: `View` requires a `type`, which\n\t// only the layers taken together are guaranteed to provide.\n\treturn view as unknown as View;\n}\n\n/**\n * The user's modifications: the leaves of the view they interacted with that\n * the layers below do not already resolve to. This is what gets persisted, so\n * that a change to any of those layers keeps showing through the properties the\n * user never touched.\n *\n * Previously persisted leaves that coincide with the base of the current view\n * are carried over rather than dropped: they may still make a difference in\n * another view sharing the preference. See `diffLayer`.\n *\n * The diff basis is resolved at `newView.type`, not at the type the previous\n * resolution used: the type selects the `defaultLayouts` entry, and a layout\n * switch reports the new type together with that entry's values. Diffing them\n * against the previous type's base would persist the difference between the\n * two entries as if the user had picked those values — leaves the layouts\n * already provide, which then linger as phantom modifications after switching\n * back.\n *\n * A persisted `type` the current layouts do not offer never applied (see\n * `getApplicablePersistedView`), so it is not carried over either: the\n * modifications returned replace it with whatever the user picked.\n *\n * @param newView The view the user produced.\n * @param layers The layers the view resolves from. See `ViewLayers`.\n * @return The modified properties, or `undefined` when the user modified none.\n */\nexport function getUserModifications(\n\tnewView: View,\n\tlayers: ViewLayers\n): ViewOverrides | undefined {\n\tconst { defaultLayouts, activeViewOverrides } = layers;\n\tconst persistedView = getApplicablePersistedView(\n\t\tlayers.persistedView,\n\t\tdefaultLayouts\n\t);\n\tconst baseView = resolveBaseView( layers, newView.type );\n\n\tconst modifications = diffLayer(\n\t\twithoutQueryParams( newView ),\n\t\twithoutQueryParams( baseView ),\n\t\twithoutQueryParams( persistedView )\n\t);\n\n\t// Locked filters are pinned on every read, so persisting them would only\n\t// leak them into the views that do not lock them.\n\tconst locked = getLockedFilters( activeViewOverrides );\n\tif ( locked.length > 0 && Array.isArray( modifications.filters ) ) {\n\t\tmodifications.filters = ( modifications.filters as Filter[] ).filter(\n\t\t\t( filter ) => ! locked.some( ( f ) => f.field === filter.field )\n\t\t);\n\t}\n\n\treturn Object.keys( modifications ).length > 0\n\t\t? ( modifications as ViewOverrides )\n\t\t: undefined;\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,eAAe,CAAE,QAAQ,QAAS;AAExC,SAAS,cAAe,OAAuC;CAC9D,OACC,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAE,MAAM,QAAS,KAAM;AAExE;;;;;;;AAQA,SAAS,mBAAoB,OAA8B;CAC1D,MAAM,SAAsB,cAAe,KAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC;CACrE,KAAM,MAAM,OAAO,cAClB,OAAO,OAAQ;CAEhB,OAAO;AACR;;;;;;;;;;;;;;AAeA,SAAS,WAAY,OAAoB,OAAkC;CAC1E,MAAM,SAAsB,EAAE,GAAG,MAAM;CACvC,KAAM,MAAM,OAAO,OAAO,KAAM,KAAM,GAAI;EACzC,MAAM,QAAQ,MAAO;EACrB,MAAM,UAAU,OAAQ;EACxB,OAAQ,OACP,cAAe,OAAQ,KAAK,cAAe,KAAM,IAC9C,WAAY,SAAS,KAAM,IAC3B;CACL;CACA,OAAO;AACR;;;;;;;;;;;;;;;;;AAkBA,SAAS,UACR,OACA,MACA,YAAyB,CAAC,GACZ;CACd,MAAM,SAAsB,CAAC;CAC7B,KAAM,MAAM,OAAO,OAAO,KAAM,KAAM,GAAI;EACzC,MAAM,OAAO,MAAO;EACpB,MAAM,UAAU,KAAM;EACtB,MAAM,OAAO,UAA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ACjC,GACA,mBACD;AACD;;;;;;;;;;;;;AAcA,SAAgB,YAAa,MAA8B;CAC1D,MAAM,EAAE,aAAa,gBAAgB,qBAAqB,MAAM,WAC/D;CACD,MAAM,gBAAgB,2BACrB,KAAK,eACL,cACD;CAmBA,OAAO;EAVN,GAAG,mBACF,WAJe,gBAAiB,MADjC,eAAe,QAAQ,qBAAqB,QAAQ,aAAa,IAK7C,GAAG,mBAAoB,aAAc,CAAE,GAC1D,mBACD;EACA,MAAM,OAAQ,QAAQ,CAAE;EACxB,QAAQ,UAAU;CAKT;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,qBACf,SACA,QAC4B;CAC5B,MAAM,EAAE,gBAAgB,wBAAwB;CAChD,MAAM,gBAAgB,2BACrB,OAAO,eACP,cACD;CACA,MAAM,WAAW,gBAAiB,QAAQ,QAAQ,IAAK;CAEvD,MAAM,gBAAgB,UACrB,mBAAoB,OAAQ,GAC5B,mBAAoB,QAAS,GAC7B,mBAAoB,aAAc,CACnC;CAIA,MAAM,SAAS,iBAAkB,mBAAoB;CACrD,IAAK,OAAO,SAAS,KAAK,MAAM,QAAS,cAAc,OAAQ,GAC9D,cAAc,UAAY,cAAc,QAAsB,QAC3D,WAAY,CAAE,OAAO,MAAQ,MAAO,EAAE,UAAU,OAAO,KAAM,CAChE;CAGD,OAAO,OAAO,KAAM,aAAc,CAAC,CAAC,SAAS,IACxC,gBACF,KAAA;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/views",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.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",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
},
|
|
40
40
|
"types": "build-types",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@wordpress/core-data": "^9.
|
|
43
|
-
"@wordpress/data": "^11.
|
|
44
|
-
"@wordpress/dataviews": "^22.
|
|
45
|
-
"@wordpress/element": "^10.
|
|
46
|
-
"@wordpress/preferences": "^5.
|
|
47
|
-
"@wordpress/private-apis": "^3.
|
|
42
|
+
"@wordpress/core-data": "^9.3.0",
|
|
43
|
+
"@wordpress/data": "^11.3.0",
|
|
44
|
+
"@wordpress/dataviews": "^22.2.0",
|
|
45
|
+
"@wordpress/element": "^10.3.0",
|
|
46
|
+
"@wordpress/preferences": "^5.3.0",
|
|
47
|
+
"@wordpress/private-apis": "^3.3.0",
|
|
48
48
|
"dequal": "^2.0.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@testing-library/react": "^16.3.3",
|
|
52
52
|
"react": "^19.3.0",
|
|
53
53
|
"react-dom": "^19.3.0",
|
|
54
|
-
"vitest": "^5.
|
|
54
|
+
"vitest": "^5.1.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@types/react": "^18 || ^19",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7f19202f61aeba8f4bdce892a1a0df485ad76e2b"
|
|
74
74
|
}
|