Skip to content

Commit 27b4b12

Browse files
committed
textarea
1 parent 6ccfaad commit 27b4b12

File tree

11 files changed

+41
-102
lines changed

11 files changed

+41
-102
lines changed

static/usage/v7/textarea/autogrow/vue.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
</ion-item>
1111
</template>
1212

13-
<script>
13+
<script lang="ts" setup>
1414
import { IonItem, IonTextarea } from '@ionic/vue';
15-
import { defineComponent } from 'vue';
16-
17-
export default defineComponent({
18-
components: { IonItem, IonTextarea },
19-
});
2015
</script>
2116
```

static/usage/v7/textarea/basic/vue.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
</ion-list>
1414
</template>
1515

16-
<script>
16+
<script lang="ts" setup>
1717
import { IonItem, IonList, IonTextarea } from '@ionic/vue';
18-
import { defineComponent } from 'vue';
19-
20-
export default defineComponent({
21-
components: { IonItem, IonList, IonTextarea },
22-
});
2318
</script>
2419
```

static/usage/v7/textarea/clear-on-edit/vue.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
></ion-textarea>
77
</template>
88

9-
<script>
9+
<script lang="ts" setup>
1010
import { IonTextarea } from '@ionic/vue';
11-
import { defineComponent } from 'vue';
12-
13-
export default defineComponent({
14-
components: { IonTextarea },
15-
});
1611
</script>
1712
```

static/usage/v7/textarea/counter/vue.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,11 @@
1111
></ion-textarea>
1212
</template>
1313

14-
<script lang="ts">
14+
<script lang="ts" setup>
1515
import { IonTextarea } from '@ionic/vue';
16-
import { defineComponent } from 'vue';
1716
18-
export default defineComponent({
19-
components: { IonTextarea },
20-
methods: {
21-
customFormatter(inputLength, maxLength) {
22-
return `${maxLength - inputLength} characters remaining`;
23-
},
24-
},
25-
});
17+
function customFormatter(inputLength, maxLength) {
18+
return `${maxLength - inputLength} characters remaining`;
19+
}
2620
</script>
2721
```

static/usage/v7/textarea/fill/vue.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
></ion-textarea>
1313
</template>
1414

15-
<script>
15+
<script lang="ts" setup>
1616
import { IonTextarea } from '@ionic/vue';
17-
import { defineComponent } from 'vue';
18-
19-
export default defineComponent({
20-
components: { IonTextarea },
21-
});
2217
</script>
2318
```

static/usage/v7/textarea/helper-error/vue.md

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,31 @@
1212
></ion-textarea>
1313
</template>
1414

15-
<script lang="ts">
15+
<script lang="ts" setup>
1616
import { IonTextarea } from '@ionic/vue';
17-
import { defineComponent } from 'vue';
18-
19-
export default defineComponent({
20-
components: { IonTextarea },
21-
methods: {
22-
validateEmail(email) {
23-
return email.match(
24-
/^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
25-
);
26-
},
27-
28-
validate(ev) {
29-
const value = ev.target.value;
30-
31-
this.$refs.input.$el.classList.remove('ion-valid');
32-
this.$refs.input.$el.classList.remove('ion-invalid');
33-
34-
if (value === '') return;
35-
36-
this.validateEmail(value)
37-
? this.$refs.input.$el.classList.add('ion-valid')
38-
: this.$refs.input.$el.classList.add('ion-invalid');
39-
},
40-
41-
markTouched() {
42-
this.$refs.input.$el.classList.add('ion-touched');
43-
},
44-
},
45-
});
17+
import { ref } from 'vue';
18+
19+
const input = ref();
20+
21+
function validateEmail(email) {
22+
return email.match(
23+
/^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
24+
);
25+
}
26+
27+
function validate(ev) {
28+
const value = ev.target.value;
29+
30+
input.value.$el.classList.remove('ion-valid');
31+
input.value.$el.classList.remove('ion-invalid');
32+
33+
if (value === '') return;
34+
35+
validateEmail(value) ? input.value.$el.classList.add('ion-valid') : input.value.$el.classList.add('ion-invalid');
36+
}
37+
38+
function markTouched() {
39+
input.value.$el.classList.add('ion-touched');
40+
}
4641
</script>
4742
```

static/usage/v7/textarea/label-placement/vue.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616
</ion-list>
1717
</template>
1818

19-
<script lang="ts">
19+
<script lang="ts" setup>
2020
import { IonTextarea, IonItem, IonList } from '@ionic/vue';
21-
import { defineComponent } from 'vue';
22-
23-
export default defineComponent({
24-
components: { IonTextarea, IonItem, IonList },
25-
});
2621
</script>
2722
```

static/usage/v7/textarea/label-slot/vue.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
</ion-list>
1010
</template>
1111

12-
<script lang="ts">
12+
<script lang="ts" setup>
1313
import { IonTextarea, IonItem, IonList, IonText } from '@ionic/vue';
14-
import { defineComponent } from 'vue';
15-
16-
export default defineComponent({
17-
components: { IonTextarea, IonItem, IonList, IonText },
18-
});
1914
</script>
2015
```

static/usage/v7/textarea/no-visible-label/vue.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
</ion-list>
88
</template>
99

10-
<script lang="ts">
10+
<script lang="ts" setup>
1111
import { IonTextarea, IonItem, IonList } from '@ionic/vue';
12-
import { defineComponent } from 'vue';
13-
14-
export default defineComponent({
15-
components: { IonTextarea, IonItem, IonList },
16-
});
1712
</script>
1813
```

static/usage/v7/textarea/start-end-slots/vue.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,12 @@
1212
</ion-list>
1313
</template>
1414

15-
<script lang="ts">
15+
<script lang="ts" setup>
1616
import { IonButton, IonIcon, IonItem, IonList, IonTextarea } from '@ionic/vue';
1717
import { eye, lockClosed } from 'ionicons/icons';
18-
import { defineComponent } from 'vue';
1918
20-
export default defineComponent({
21-
components: {
22-
IonButton,
23-
IonIcon,
24-
IonItem,
25-
IonList,
26-
IonTextarea,
27-
},
28-
setup() {
29-
return { eye, lockClosed };
30-
},
31-
});
19+
function setup() {
20+
return { eye, lockClosed };
21+
}
3222
</script>
3323
```

0 commit comments

Comments
 (0)