@@ -147,3 +147,28 @@ export const dockPanelsSelector = (state) => state?.maplayout?.dockPanels ?? { l
147147
148148export const dockStyleSelector = state => mapLayoutValuesSelector ( state , { height : true , right : true } , true ) ;
149149export const helpStyleSelector = state => mapLayoutValuesSelector ( state , { right : true } , true ) ;
150+
151+ /**
152+ * Retrieve only specific attribute from bounding map rect layout
153+ * @function
154+ * @memberof selectors.mapLayout
155+ * @param {object } state the state
156+ * @param {object } attributes attributes to retrieve, bool {left: true}
157+ * @param {boolean } isDock flag to use dock paddings instead of toolbar paddings
158+ * @return {object } selected attributes of layout of the map
159+ */
160+ export const boundingMapRectLayoutValuesSelector = memoize ( ( state , attributes = { } , isDock = false ) => {
161+ const layout = boundingMapRectSelector ( state ) ;
162+ const boundingSidebarRect = boundingSidebarRectSelector ( state ) ;
163+ return layout && Object . keys ( layout ) . filter ( key =>
164+ attributes [ key ] ) . reduce ( ( a , key ) => {
165+ if ( isDock ) {
166+ return ( { ...a , [ key ] : ( boundingSidebarRect [ key ] ?? layout [ key ] ) } ) ;
167+ }
168+ return ( { ...a , [ key ] : layout [ key ] } ) ;
169+ } ,
170+ { } ) || { } ;
171+ } , ( state , attributes , isDock ) =>
172+ JSON . stringify ( boundingMapRectSelector ( state ) ) +
173+ JSON . stringify ( boundingSidebarRectSelector ( state ) ) +
174+ JSON . stringify ( attributes ) + ( isDock ? '_isDock' : '' ) ) ;
0 commit comments