-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlTextFieldPage.vue
More file actions
60 lines (50 loc) · 1.61 KB
/
PlTextFieldPage.vue
File metadata and controls
60 lines (50 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<script setup lang="ts">
import { PlAlert, PlBlockPage, PlTextField } from "@platforma-sdk/ui-vue";
import { reactive } from "vue";
const data = reactive({
text: "lorem ipsum",
optionalText: "optional",
num: "0",
optionalNum: "" as string,
});
function numberRule(v: string): string | undefined {
if (v === "") return undefined;
const parsed = Number(v);
if (!Number.isFinite(parsed)) return "Not a number";
return undefined;
}
</script>
<template>
<PlBlockPage style="max-width: 100%">
<div class="d-flex flex-column gap-16" style="width: 400px">
<PlTextField v-model="data.text" label="Text" placeholder="Text" />
<PlTextField
v-model="data.optionalText"
label="Optional text (string | undefined)"
placeholder="Now value is undefined"
clearable
/>
<PlTextField v-model="data.text" label="Password" placeholder="Password" type="password" />
<PlTextField v-model="data.text" label="Disabled" disabled placeholder="Text" />
<PlTextField
v-model="data.text"
label="Disabled Password"
disabled
placeholder="Password"
type="password"
/>
<div>Number (string) + clearable</div>
<PlTextField v-model="data.num" placeholder="Number" :validate="numberRule" clearable />
<div>Optional number (string)</div>
<PlTextField
v-model="data.optionalNum"
placeholder="Number"
:validate="numberRule"
clearable
/>
<PlAlert white-space-pre label="Data">
{{ JSON.stringify(data, null, 2) }}
</PlAlert>
</div>
</PlBlockPage>
</template>