How to use the timm.insert function in timm

To help you get started, we’ve selected a few timm 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 ThemeFuse / Brizy / public / editor-src / editor / js / component / LeftSidebar / components / BlocksSortable / index.jsx View on Github external
state => {
          const { blocks } = state;
          const movedBlock = blocks[oldIndex];

          return {
            blocks: insert(removeAt(blocks, oldIndex), newIndex, movedBlock),
            optimistic: true,
            isSorting: false
          };
        },
        () => {
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / EditorArrayComponent.js View on Github external
static insertItem(items, itemIndex, itemData) {
    const itemDataStripped = stripSystemKeys(itemData);
    const itemDataWithIds = setIds(itemDataStripped);
    const updatedValue = insert(items, itemIndex, itemDataWithIds);

    return updatedValue;
  }
github ThemeFuse / Brizy / public / editor-src / editor / js / redux / reducers / index.js View on Github external
insertIndex,
        [block]
      );

      return newPageBlocks;
    }
    case REMOVE_BLOCK: {
      const { index } = action.payload;
      const newBlocks = removeAt(state, index);

      return newBlocks;
    }
    case REORDER_BLOCKS: {
      const { oldIndex, newIndex } = action.payload;
      const movedBlock = state[oldIndex];
      const newBlocks = insert(removeAt(state, oldIndex), newIndex, movedBlock);

      return newBlocks;
    }
    case UPDATE_BLOCKS: {
      const { blocks } = action.payload;

      return blocks;
    }
    case IMPORT_TEMPLATE: {
      const { blocks: templateBlocks } = action.payload;
      const { insertIndex } = action.meta;
      const newPageBlocks = EditorArrayComponent.insertItemsBatch(
        state,
        insertIndex,
        templateBlocks
      );
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / EditorArrayComponent.js View on Github external
const updatedValue = itemsData.reduce((acc, itemData, index) => {
      const itemDataStripped = stripSystemKeys(itemData);
      const itemDataWithIds = setIds(itemDataStripped);

      return insert(acc, itemIndex + index, itemDataWithIds);
    }, dbValue);
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / Page / utils / changeValueAfterDND.js View on Github external
const addIn = (object, [...path], value) => {
  let index = path.pop();
  index = Number(index) ? Number(index) : index;
  let newObj = getIn(object, path);
  newObj = insert(newObj, index, value);

  return setIn(object, path, newObj);
};
const removeIn = (object, [...path]) => {
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / EditorArrayComponent.js View on Github external
insertItem(itemIndex, itemData) {
    const itemDataStripped = stripSystemKeys(itemData);
    const itemDataWithIds = setIds(itemDataStripped);
    const dbValue = this.getDBValue() || [];
    const updatedValue = insert(dbValue, itemIndex, itemDataWithIds);

    this.handleValueChange(updatedValue, { arrayOperation: "insert" });
  }