Sha256: 007b029b71619219e325c5380c67400e0e5aa573a1f1f086a02447769c7ec68d

Contents?: true

Size: 850 Bytes

Versions: 21

Compression:

Stored size: 850 Bytes

Contents

export default function paramsEditorFieldComponent({ name, value }) {
  return {
    name,
    value,

    init() {
      this.$watch("value", () => this.update());
    },

    update() {
      if (this.validate()) {
        const searchParams = new URLSearchParams(window.location.search);
        searchParams.set(this.name, this.value);
        const path = location.href.replace(location.search, "");
        this.navigateTo(`${path}?${searchParams.toString()}`);
      }
    },

    validate() {
      return this.$root.reportValidity ? this.$root.reportValidity() : true;
    },

    get isNarrowLayout() {
      return this.narrow || false;
    },

    bindings: {
      input: {
        [":id"]: "`param-${name}`",
        ["x-ref"]: "input",
        ["x-model.debounce.200"]: "value",
        ["@keydown.stop"]: true,
      },
    },
  };
}

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
lookbook-1.0.8 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.7 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.6 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.5 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.4 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.3 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.2 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.1 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.rc.3 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.rc.2 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.rc.1 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.8 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.7 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.6 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.5 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.4 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.3 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.2 app/components/lookbook/params_editor/field/component.js
lookbook-1.0.0.beta.1 app/components/lookbook/params_editor/field/component.js