import { GridBaseState, gridSizePresets, LayoutType, ToolbarCollectionState, topGridSizePreset, } from '../../state'; import { GridSectionsState, SectionRange } from './GridSectionsState'; import { FiltersMap } from '@wix/bex-core'; import { computed, makeObservable } from 'mobx'; export interface GridSectionsSectionStateParams { readonly imagePlacement?: 'side' | 'top'; readonly gridSections: GridSectionsState; readonly sectionDescriptor: SectionRange; readonly layoutType: LayoutType | undefined; readonly draggable?: 'none' | 'draggable'; } export class GridSectionsSectionState { gridBase; gridSections; sectionDescriptor; constructor(params: GridSectionsSectionStateParams) { this.gridSections = params.gridSections; this.sectionDescriptor = params.sectionDescriptor; const { imagePlacement, draggable, layoutType } = params; const { toolbar } = this.gridSections; this.gridBase = new GridBaseState({ container: toolbar.container, toolbar: toolbar as ToolbarCollectionState>, collection: toolbar.collection, sizePreset: imagePlacement ? gridSizePresets[imagePlacement] : topGridSizePreset, range: params.sectionDescriptor.range, parentState: this.gridSections.parentState, layoutType, draggable, }); makeObservable(this, { isLast: computed, }); } get isLast() { const { sectionDescriptor: { sectionId }, gridSections: { sections }, } = this; return sections[sections.length - 1]?.sectionId === sectionId; } }