@v1nt1248/3nclient-lib 0.3.2 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui3n-text/types.d.ts +3 -2
- package/dist/components/ui3n-text/ui3n-text.vue.d.ts +2 -2
- package/dist/style.css +1 -1
- package/dist/ui3n-components.js +34 -29
- package/package.json +1 -1
- package/src/components/ui3n-input/ui3n-input.vue +0 -8
- package/src/components/ui3n-text/types.ts +13 -9
- package/src/components/ui3n-text/ui3n-text.vue +52 -42
package/dist/ui3n-components.js
CHANGED
|
@@ -17457,7 +17457,7 @@ var Vo = {
|
|
|
17457
17457
|
"update:valid"
|
|
17458
17458
|
],
|
|
17459
17459
|
setup(e, { expose: t, emit: n }) {
|
|
17460
|
-
M((e) => ({
|
|
17460
|
+
M((e) => ({ a55771ac: h.value }));
|
|
17461
17461
|
let r = e, l = n, u = C(null), d = C(""), f = C(!1), p = C(!1), m = C(""), h = i(() => r.disabled ? "var(--color-icon-control-primary-disabled)" : r.iconColor || "var(--color-icon-control-primary-default)");
|
|
17462
17462
|
function _(e) {
|
|
17463
17463
|
p.value = !0, l("focus", e);
|
|
@@ -17469,15 +17469,15 @@ var Vo = {
|
|
|
17469
17469
|
}
|
|
17470
17470
|
function y(e) {
|
|
17471
17471
|
let t = e.target.value;
|
|
17472
|
-
k(t),
|
|
17472
|
+
k(t), l("change", t);
|
|
17473
17473
|
}
|
|
17474
17474
|
function S(e) {
|
|
17475
17475
|
let t = e.target.value;
|
|
17476
|
-
d.value = t, f.value = !0, k(t),
|
|
17476
|
+
d.value = t, f.value = !0, k(t), l("update:modelValue", t), l("input", t);
|
|
17477
17477
|
}
|
|
17478
17478
|
function w(e) {
|
|
17479
17479
|
let { altKey: t, ctrlKey: n, metaKey: r, shiftKey: i, target: a } = e, o = a.value;
|
|
17480
|
-
f.value = !0, k(o),
|
|
17480
|
+
f.value = !0, k(o), l("update:modelValue", o), l("enter", {
|
|
17481
17481
|
value: o,
|
|
17482
17482
|
altKey: t,
|
|
17483
17483
|
ctrlKey: n,
|
|
@@ -17487,13 +17487,13 @@ var Vo = {
|
|
|
17487
17487
|
}
|
|
17488
17488
|
function T(e) {
|
|
17489
17489
|
let t = e.target.value;
|
|
17490
|
-
f.value = !0, k(t),
|
|
17490
|
+
f.value = !0, k(t), l("update:modelValue", t), l("escape", e);
|
|
17491
17491
|
}
|
|
17492
17492
|
function E(e) {
|
|
17493
17493
|
l("keydown", e);
|
|
17494
17494
|
}
|
|
17495
17495
|
function O() {
|
|
17496
|
-
d.value = "", f.value = !1, k(""),
|
|
17496
|
+
d.value = "", f.value = !1, k(""), l("update:modelValue", ""), l("input", ""), l("change", ""), l("clear");
|
|
17497
17497
|
}
|
|
17498
17498
|
function k(e) {
|
|
17499
17499
|
if (m.value = "", r.rules && r.rules.length) {
|
|
@@ -17502,16 +17502,16 @@ var Vo = {
|
|
|
17502
17502
|
typeof n == "string" && (m.value += `${n} `);
|
|
17503
17503
|
}
|
|
17504
17504
|
}
|
|
17505
|
-
f.value &&
|
|
17505
|
+
f.value && l("update:valid", !m.value);
|
|
17506
17506
|
}
|
|
17507
17507
|
return t({
|
|
17508
17508
|
isDirty: f,
|
|
17509
17509
|
isFocused: p,
|
|
17510
17510
|
clearValue: O
|
|
17511
17511
|
}), b(() => {
|
|
17512
|
-
r.autofocus && u.value && u.value.focus(), l("init", u.value), r.validateAtStartup &&
|
|
17512
|
+
r.autofocus && u.value && u.value.focus(), l("init", u.value), r.validateAtStartup && k(d.value);
|
|
17513
17513
|
}), F(() => r.modelValue, (e, t) => {
|
|
17514
|
-
(e ?? "") !== (t ?? "") && (d.value = e ?? "",
|
|
17514
|
+
(e ?? "") !== (t ?? "") && (d.value = e ?? "", k(d.value));
|
|
17515
17515
|
}, { immediate: !0 }), (t, n) => (x(), s("div", { class: g([
|
|
17516
17516
|
t.$style.ui3nInput,
|
|
17517
17517
|
e.label && t.$style.withLabel,
|
|
@@ -17832,12 +17832,13 @@ var Vo = {
|
|
|
17832
17832
|
], zs = /* @__PURE__ */ X(/* @__PURE__ */ d({
|
|
17833
17833
|
__name: "ui3n-text",
|
|
17834
17834
|
props: {
|
|
17835
|
-
|
|
17835
|
+
modelValue: {},
|
|
17836
17836
|
rows: { default: 6 },
|
|
17837
17837
|
maxRows: { default: 6 },
|
|
17838
17838
|
label: { default: "" },
|
|
17839
17839
|
placeholder: { default: "" },
|
|
17840
17840
|
rules: {},
|
|
17841
|
+
validateAtStartup: { type: Boolean },
|
|
17841
17842
|
disabled: {
|
|
17842
17843
|
type: Boolean,
|
|
17843
17844
|
default: !1
|
|
@@ -17852,37 +17853,37 @@ var Vo = {
|
|
|
17852
17853
|
"escape",
|
|
17853
17854
|
"focus",
|
|
17854
17855
|
"blur",
|
|
17855
|
-
"update:
|
|
17856
|
+
"update:modelValue",
|
|
17856
17857
|
"update:valid"
|
|
17857
17858
|
],
|
|
17858
17859
|
setup(e, { emit: t }) {
|
|
17859
|
-
let n = e, r = t,
|
|
17860
|
-
b(() => {
|
|
17861
|
-
a.value && (Za(a.value), r("init", a.value));
|
|
17862
|
-
}), F(() => d.value, (e) => r("update:valid", e), { immediate: !0 });
|
|
17860
|
+
let n = e, r = t, i = C(null), a = C(""), l = C(!1), u = C(!1), d = C("");
|
|
17863
17861
|
function f(e) {
|
|
17864
|
-
if (
|
|
17862
|
+
if (d.value = "", n.rules && n.rules.length) {
|
|
17865
17863
|
for (let t of n.rules) if (typeof t == "function") {
|
|
17866
17864
|
let n = t(e);
|
|
17867
|
-
typeof n == "string" && (
|
|
17865
|
+
typeof n == "string" && (d.value += n);
|
|
17868
17866
|
}
|
|
17869
17867
|
}
|
|
17868
|
+
l.value && r("update:valid", !d.value);
|
|
17870
17869
|
}
|
|
17871
17870
|
function p(e) {
|
|
17872
|
-
|
|
17871
|
+
u.value = !0, r("focus", e);
|
|
17873
17872
|
}
|
|
17874
17873
|
function h(e) {
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17874
|
+
setTimeout(() => {
|
|
17875
|
+
u.value = !1;
|
|
17876
|
+
let t = e.target.value;
|
|
17877
|
+
f(t), r("blur", e), r("change", t), r("update:modelValue", t);
|
|
17878
|
+
}, 100);
|
|
17878
17879
|
}
|
|
17879
17880
|
function _(e) {
|
|
17880
17881
|
let t = e.target.value;
|
|
17881
|
-
f(t), r("update:
|
|
17882
|
+
a.value = t, l.value = !0, f(t), r("update:modelValue", t), r("input", t);
|
|
17882
17883
|
}
|
|
17883
17884
|
function v(e) {
|
|
17884
17885
|
let { altKey: t, ctrlKey: n, shiftKey: i, metaKey: a, target: o } = e, s = o.value;
|
|
17885
|
-
f(s), r("update:
|
|
17886
|
+
l.value = !0, f(s), r("update:modelValue", s), r("enter", {
|
|
17886
17887
|
value: s,
|
|
17887
17888
|
altKey: t,
|
|
17888
17889
|
ctrlKey: n,
|
|
@@ -17892,23 +17893,27 @@ var Vo = {
|
|
|
17892
17893
|
}
|
|
17893
17894
|
function y(e) {
|
|
17894
17895
|
let t = e.target.value;
|
|
17895
|
-
f(t), r("update:
|
|
17896
|
+
l.value = !0, f(t), r("update:modelValue", t), r("escape", e);
|
|
17896
17897
|
}
|
|
17897
17898
|
function S(e) {
|
|
17898
17899
|
r("keydown", e);
|
|
17899
17900
|
}
|
|
17900
|
-
return (
|
|
17901
|
+
return b(() => {
|
|
17902
|
+
i.value && (Za(i.value), r("init", i.value)), n.validateAtStartup && f(a.value);
|
|
17903
|
+
}), F(() => n.modelValue, (e, t) => {
|
|
17904
|
+
(e ?? "") !== (t ?? "") && (a.value = e ?? "", f(a.value));
|
|
17905
|
+
}, { immediate: !0 }), (t, n) => (x(), s("div", { class: g([
|
|
17901
17906
|
t.$style.ui3nText,
|
|
17902
17907
|
e.disabled && t.$style.disabled,
|
|
17903
|
-
|
|
17908
|
+
u.value && t.$style.focused
|
|
17904
17909
|
]) }, [e.label ? (x(), s("label", {
|
|
17905
17910
|
key: 0,
|
|
17906
17911
|
class: g(t.$style.label)
|
|
17907
17912
|
}, D(e.label), 3)) : o("", !0), c("div", { class: g(t.$style.body) }, [c("textarea", m({
|
|
17908
17913
|
ref_key: "textareaElement",
|
|
17909
|
-
ref:
|
|
17914
|
+
ref: i,
|
|
17910
17915
|
class: t.$style.content,
|
|
17911
|
-
value:
|
|
17916
|
+
value: a.value,
|
|
17912
17917
|
placeholder: e.placeholder,
|
|
17913
17918
|
readonly: e.disabled,
|
|
17914
17919
|
rows: e.rows,
|
|
@@ -17918,7 +17923,7 @@ var Vo = {
|
|
|
17918
17923
|
onInput: _,
|
|
17919
17924
|
onKeydown: [
|
|
17920
17925
|
R(v, ["enter"]),
|
|
17921
|
-
R(y, ["
|
|
17926
|
+
R(y, ["esc"]),
|
|
17922
17927
|
S
|
|
17923
17928
|
],
|
|
17924
17929
|
onFocusin: p,
|
package/package.json
CHANGED
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
function onChange(event: Event) {
|
|
37
37
|
const value = (event.target as HTMLInputElement).value;
|
|
38
38
|
validate(value);
|
|
39
|
-
console.log('[Ui3nInput] ON_CHANGE');
|
|
40
39
|
emits('change', value);
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -45,7 +44,6 @@
|
|
|
45
44
|
text.value = value;
|
|
46
45
|
isDirty.value = true;
|
|
47
46
|
validate(value);
|
|
48
|
-
console.log('[Ui3nInput] ON_INPUT');
|
|
49
47
|
emits('update:modelValue', value);
|
|
50
48
|
emits('input', value);
|
|
51
49
|
}
|
|
@@ -55,7 +53,6 @@
|
|
|
55
53
|
const value = (target as HTMLInputElement).value;
|
|
56
54
|
isDirty.value = true;
|
|
57
55
|
validate(value);
|
|
58
|
-
console.log('[Ui3nInput] ON_ENTER_KEYDOWN');
|
|
59
56
|
emits('update:modelValue', value);
|
|
60
57
|
emits('enter', { value, altKey, ctrlKey, metaKey, shiftKey });
|
|
61
58
|
}
|
|
@@ -64,7 +61,6 @@
|
|
|
64
61
|
const value = (event.target as HTMLInputElement).value;
|
|
65
62
|
isDirty.value = true;
|
|
66
63
|
validate(value);
|
|
67
|
-
console.log('[Ui3nInput] ON_ESCAPE_KEYDOWN');
|
|
68
64
|
emits('update:modelValue', value);
|
|
69
65
|
emits('escape', event);
|
|
70
66
|
}
|
|
@@ -77,7 +73,6 @@
|
|
|
77
73
|
text.value = '';
|
|
78
74
|
isDirty.value = false;
|
|
79
75
|
validate('');
|
|
80
|
-
console.log('[Ui3nInput] CLEAR_VALUE');
|
|
81
76
|
emits('update:modelValue', '');
|
|
82
77
|
emits('input', '');
|
|
83
78
|
emits('change', '');
|
|
@@ -98,7 +93,6 @@
|
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
if (isDirty.value) {
|
|
101
|
-
console.log('[Ui3nInput] UPDATE:VALID => ', !errorMessage.value, ' | ', errorMessage.value);
|
|
102
96
|
emits('update:valid', !errorMessage.value);
|
|
103
97
|
}
|
|
104
98
|
}
|
|
@@ -116,7 +110,6 @@
|
|
|
116
110
|
|
|
117
111
|
emits('init', inputElement.value!);
|
|
118
112
|
if (props.validateAtStartup) {
|
|
119
|
-
console.log('[Ui3nInput] ON_MOUNTED');
|
|
120
113
|
validate(text.value);
|
|
121
114
|
}
|
|
122
115
|
});
|
|
@@ -126,7 +119,6 @@
|
|
|
126
119
|
(val, oldVal) => {
|
|
127
120
|
if ((val ?? '') !== (oldVal ?? '')) {
|
|
128
121
|
text.value = val ?? '';
|
|
129
|
-
console.log('[Ui3nInput] WATCH => ', oldVal, ' => ', val);
|
|
130
122
|
validate(text.value);
|
|
131
123
|
}
|
|
132
124
|
},
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export interface Ui3nTextProps {
|
|
2
|
-
|
|
2
|
+
modelValue: string;
|
|
3
3
|
rows?: number;
|
|
4
4
|
maxRows?: number;
|
|
5
5
|
label?: string;
|
|
6
6
|
placeholder?: string;
|
|
7
7
|
rules?: Array<(v: string) => string | boolean>;
|
|
8
|
+
validateAtStartup?: boolean;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -13,16 +14,19 @@ export interface Ui3nTextEmits {
|
|
|
13
14
|
(event: 'input', value: string): void;
|
|
14
15
|
(event: 'change', value: string): void;
|
|
15
16
|
(event: 'keydown', value: KeyboardEvent): void;
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
(
|
|
18
|
+
event: 'enter',
|
|
19
|
+
value: {
|
|
20
|
+
value: string;
|
|
21
|
+
altKey: boolean;
|
|
22
|
+
ctrlKey: boolean;
|
|
23
|
+
shiftKey: boolean;
|
|
24
|
+
metaKey: boolean;
|
|
25
|
+
},
|
|
26
|
+
): void;
|
|
23
27
|
(event: 'escape', value: Event): void;
|
|
24
28
|
(event: 'focus', value: Event): void;
|
|
25
29
|
(event: 'blur', value: Event): void;
|
|
26
|
-
(event: 'update:
|
|
30
|
+
(event: 'update:modelValue', value: string): void;
|
|
27
31
|
(event: 'update:valid', value: boolean): void;
|
|
28
32
|
}
|
|
@@ -1,45 +1,23 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { onMounted, ref, watch } from 'vue';
|
|
3
3
|
import { patchTextareaMaxRowsSupport } from '@/utils';
|
|
4
4
|
import type { Ui3nTextEmits, Ui3nTextProps } from './types';
|
|
5
5
|
|
|
6
|
-
const props = withDefaults(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
disabled: false,
|
|
14
|
-
},
|
|
15
|
-
);
|
|
6
|
+
const props = withDefaults(defineProps<Ui3nTextProps>(), {
|
|
7
|
+
rows: 6,
|
|
8
|
+
maxRows: 6,
|
|
9
|
+
label: '',
|
|
10
|
+
placeholder: '',
|
|
11
|
+
disabled: false,
|
|
12
|
+
});
|
|
16
13
|
const emits = defineEmits<Ui3nTextEmits>();
|
|
17
14
|
|
|
18
15
|
const textareaElement = ref<HTMLTextAreaElement | null>(null);
|
|
16
|
+
const text = ref<string>('');
|
|
17
|
+
const isDirty = ref(false);
|
|
19
18
|
const isFocused = ref(false);
|
|
20
19
|
const errorMessage = ref('');
|
|
21
20
|
|
|
22
|
-
const isValid = computed(() => {
|
|
23
|
-
if (!props.text) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return !errorMessage.value;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
onMounted(() => {
|
|
31
|
-
if (textareaElement.value) {
|
|
32
|
-
patchTextareaMaxRowsSupport(textareaElement.value!);
|
|
33
|
-
emits('init', textareaElement.value!);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
watch(
|
|
38
|
-
() => isValid.value,
|
|
39
|
-
val => emits('update:valid', val),
|
|
40
|
-
{ immediate: true },
|
|
41
|
-
);
|
|
42
|
-
|
|
43
21
|
function validate(text: string) {
|
|
44
22
|
errorMessage.value = '';
|
|
45
23
|
if (props.rules && props.rules.length) {
|
|
@@ -52,6 +30,10 @@
|
|
|
52
30
|
}
|
|
53
31
|
}
|
|
54
32
|
}
|
|
33
|
+
|
|
34
|
+
if (isDirty.value) {
|
|
35
|
+
emits('update:valid', !errorMessage.value);
|
|
36
|
+
}
|
|
55
37
|
}
|
|
56
38
|
|
|
57
39
|
function onFocus(event: Event) {
|
|
@@ -60,39 +42,67 @@
|
|
|
60
42
|
}
|
|
61
43
|
|
|
62
44
|
function onBlur(event: Event) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
isFocused.value = false;
|
|
47
|
+
const value = (event.target as HTMLInputElement).value;
|
|
48
|
+
validate(value);
|
|
49
|
+
emits('blur', event);
|
|
50
|
+
emits('change', value);
|
|
51
|
+
emits('update:modelValue', value);
|
|
52
|
+
}, 100);
|
|
69
53
|
}
|
|
70
54
|
|
|
71
55
|
function onInput(event: Event) {
|
|
72
56
|
const value = (event.target as HTMLInputElement).value;
|
|
57
|
+
text.value = value;
|
|
58
|
+
isDirty.value = true;
|
|
73
59
|
validate(value);
|
|
74
|
-
emits('update:
|
|
60
|
+
emits('update:modelValue', value);
|
|
75
61
|
emits('input', value);
|
|
76
62
|
}
|
|
77
63
|
|
|
78
64
|
function onEnterKeydown(event: KeyboardEvent) {
|
|
79
65
|
const { altKey, ctrlKey, shiftKey, metaKey, target } = event;
|
|
80
66
|
const value = (target as HTMLInputElement).value;
|
|
67
|
+
isDirty.value = true;
|
|
81
68
|
validate(value);
|
|
82
|
-
emits('update:
|
|
69
|
+
emits('update:modelValue', value);
|
|
83
70
|
emits('enter', { value, altKey, ctrlKey, shiftKey, metaKey });
|
|
84
71
|
}
|
|
85
72
|
|
|
86
73
|
function onEscapeKeydown(event: KeyboardEvent) {
|
|
87
74
|
const value = (event.target as HTMLInputElement).value;
|
|
75
|
+
isDirty.value = true;
|
|
88
76
|
validate(value);
|
|
89
|
-
emits('update:
|
|
77
|
+
emits('update:modelValue', value);
|
|
90
78
|
emits('escape', event);
|
|
91
79
|
}
|
|
92
80
|
|
|
93
81
|
function onKeydown(event: KeyboardEvent) {
|
|
94
82
|
emits('keydown', event);
|
|
95
83
|
}
|
|
84
|
+
|
|
85
|
+
onMounted(() => {
|
|
86
|
+
if (textareaElement.value) {
|
|
87
|
+
patchTextareaMaxRowsSupport(textareaElement.value!);
|
|
88
|
+
emits('init', textareaElement.value!);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (props.validateAtStartup) {
|
|
92
|
+
validate(text.value);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
watch(
|
|
97
|
+
() => props.modelValue,
|
|
98
|
+
(val, oldVal) => {
|
|
99
|
+
if ((val ?? '') !== (oldVal ?? '')) {
|
|
100
|
+
text.value = val ?? '';
|
|
101
|
+
validate(text.value);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{ immediate: true },
|
|
105
|
+
);
|
|
96
106
|
</script>
|
|
97
107
|
|
|
98
108
|
<template>
|
|
@@ -117,7 +127,7 @@
|
|
|
117
127
|
v-bind="$attrs"
|
|
118
128
|
@input="onInput"
|
|
119
129
|
@keydown.enter="onEnterKeydown"
|
|
120
|
-
@keydown.
|
|
130
|
+
@keydown.esc="onEscapeKeydown"
|
|
121
131
|
@keydown="onKeydown"
|
|
122
132
|
@focusin="onFocus"
|
|
123
133
|
@focusout="onBlur"
|