Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

  1. <template>
  2. <div id="pattern-box" class="pattern-box-wrapper">
  3. <InputText autofocus
  4. v-model="pattern"
  5. placeholder="Enter pattern"
  6. class="pattern-box"
  7. type="text">
  8. </InputText>
  9. <p v-show="error" class="error-text">{{ error }}</p>
  10. </div>
  11. </template>
  12. <script lang="ts">
  13. import {Component, Prop, Watch, Vue} from "vue-property-decorator";
  14. @Component
  15. export default class PatternBox extends Vue {
  16. private pattern: string = '';
  17. private error: string = '';
  18. @Prop({default: ''}) public readonly value!: string;
  19. @Watch('pattern')
  20. patternChanged(value: string) {
  21. try {
  22. new RegExp(value);
  23. this.$emit('input', value);
  24. this.error = '';
  25. } catch (error) {
  26. this.error = 'Expression is invalid';
  27. }
  28. }
  29. @Watch('value')
  30. valueChanged(value: string) {
  31. this.pattern = value
  32. }
  33. created() {
  34. this.pattern = this.value
  35. }
  36. };
  37. </script>