How to use the timm.replaceAt 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 guigrpa / storyboard / packages / storyboard-extension-chrome / src / reducers / storiesReducer.js View on Github external
// Handle consecutive repetitions
    if (fShorthandForDuplicates && !record.fStory) {
      const idx = prevRecords.length - 1;
      const prevLastRecord = prevRecords[idx];
      if (prevLastRecord != null &&
        prevLastRecord.msg === record.msg &&
        prevLastRecord.src === record.src &&
        _.isEqual(prevLastRecord.obj, record.obj)
      ) {
        fDuplicate = true;
        const repetitions = prevLastRecord.repetitions || 0;
        const nextLastRecord = timm.merge(prevLastRecord, {
          repetitions: repetitions + 1,
          tLastRepetition: record.t,
        });
        nextRecords = timm.replaceAt(prevRecords, idx, nextLastRecord);
      }
    }

    // Normal case
    if (nextRecords == null) nextRecords = timm.addLast(prevRecords, record);
    return nextRecords;
  });
github guigrpa / mady / src / client / components / aeSettings.js View on Github external
onUpdateListItem = (ev: SyntheticEvent) => {
    if (!(ev.currentTarget instanceof HTMLInputElement)) return;
    const value = ev.currentTarget.value;
    const [id, idx] = ev.currentTarget.id.split('.');
    const newList = timm.replaceAt(this.state[id], Number(idx), value);
    this.setState({ [id]: newList });
  };
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / EditorArrayComponent.js View on Github external
replaceItem(itemIndex, itemData, meta) {
    const itemDataStripped = stripSystemKeys(itemData, { exclude: ["_id"] });
    const itemDataWithIds = setIds(itemDataStripped, meta.idOptions);
    const dbValue = this.getDBValue() || [];
    const updatedValue = replaceAt(dbValue, itemIndex, itemDataWithIds);

    this.handleValueChange(updatedValue, {
      arrayOperation: "replace",
      itemIndex,
      oldValue: dbValue
    });
  }
github ThemeFuse / Brizy / public / editor-src / editor / js / component / Prompts / PromptForm / Step / CustomFields.js View on Github external
handleActive = (id, target) => {
    const { formFields } = this.state;
    const index = formFields.findIndex(({ sourceId }) => sourceId === id);

    this.setState({
      formFields: replaceAt(formFields, index, { ...formFields[index], target })
    });
  };
github ThemeFuse / Brizy / public / editor-src / editor / js / component / Prompts / PromptForm / EmailApp / LinkFields / index.jsx View on Github external
onChange = (inputId, linked) => {
    const { app } = this.props;
    const { appFields } = this.state;
    let newAppFields;

    if (app === "wordpress") {
      newAppFields = Object.assign({}, appFields, {
        [`${inputId}`]: linked
      });
    } else {
      let index = _.indexOf(_.pluck(appFields, "id"), inputId);
      const newObj = Object.assign({}, appFields[index], { linked });
      newAppFields = replaceAt(appFields, index, newObj);
    }

    this.setState({
      appFields: newAppFields
    });
  };
github ThemeFuse / Brizy / public / editor-src / editor / js / component / Prompts / PromptForm / Step / Fields.js View on Github external
handleActive = (id, target) => {
    const { formFields } = this.state;
    const index = formFields.findIndex(({ sourceId }) => sourceId === id);

    this.setState({
      formFields: replaceAt(formFields, index, { ...formFields[index], target })
    });
  };
github guigrpa / mady / src / client / components / adTranslator.js View on Github external
const prevLangs = this.state.langs;
    if (!(ev.currentTarget instanceof HTMLElement)) return;
    const idx = Number(ev.currentTarget.id);
    let fFound = false;
    for (let i = 0; i < prevLangs.length; i++) {
      if (i === idx) continue;
      if (prevLangs[i] === lang) {
        fFound = true;
        break;
      }
    }
    if (fFound) {
      this.removeLang(idx);
      return;
    }
    const nextLangs = timm.replaceAt(this.state.langs, idx, lang);
    this.updateLangs(nextLangs);
  };
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / Form / Input / types / Select.jsx View on Github external
handleOptionsChange = (value, index) => {
    const options = replaceAt(this.props.options, index, value);
    this.props.onChange({ options });
  };
  handleOptionsAdd = () => {