How to use the react-mosaic-component.getLeaves function in react-mosaic-component

To help you get started, we’ve selected a few react-mosaic-component examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cruise-automation / webviz / packages / webviz-core / src / reducers / panels.js View on Github external
function changePanelLayout(state: PanelsState, layout: any): PanelsState {
  // filter saved props in case a panel was removed from the layout
  // we don't want it saved props hanging around forever
  const savedProps = pick(state.savedProps, getLeaves(layout));
  return { ...state, savedProps, layout };
}
github ProjectMirador / mirador / src / components / WorkspaceMosaic.js View on Github external
determineWorkspaceLayout() {
    const { windows, layout } = this.props;
    const sortedWindows = toPairs(windows)
      .sort((a, b) => a.layoutOrder - b.layoutOrder).map(val => val[0]);
    const leaveKeys = getLeaves(layout);
    // Windows were added
    if (!sortedWindows.every(e => leaveKeys.includes(e))) {
      // No current layout, so just generate a new one
      if (leaveKeys.length < 2) {
        return createBalancedTreeFromLeaves(sortedWindows);
      }
      // Add new windows to layout
      const addedWindows = difference(sortedWindows, leaveKeys);
      const newLayout = new MosaicLayout(layout);
      newLayout.addWindows(addedWindows);
      return newLayout.layout;
    }
    // Windows were removed (perhaps in a different Workspace). We don't have a
    // way to reconfigure.. so we have to random generate
    if (!leaveKeys.every(e => sortedWindows.includes(e))) {
      return createBalancedTreeFromLeaves(sortedWindows);