@nr1e/qwik-ui 2.0.3 → 2.0.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/lib/components/select-field.qwik.cjs +9 -0
- package/lib/components/select-field.qwik.mjs +9 -0
- package/lib/components/text-field.qwik.cjs +18 -1
- package/lib/components/text-field.qwik.mjs +18 -1
- package/lib-types/components/select-field.d.ts +4 -0
- package/lib-types/components/text-field.d.ts +5 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const qwik = require("@builder.io/qwik");
|
|
|
5
5
|
const SelectField = qwik.component$((props) => {
|
|
6
6
|
const error = qwik.useSignal(typeof props.error === "string" ? props.error : props.error?.value);
|
|
7
7
|
const value = qwik.useSignal(typeof props.value === "string" ? props.value : props.value?.value);
|
|
8
|
+
const originalValue = typeof props.value === "string" ? props.value : props.value?.value;
|
|
8
9
|
const disabled = qwik.useSignal(false);
|
|
9
10
|
if (props.disabled) {
|
|
10
11
|
if (typeof props.disabled === "boolean") {
|
|
@@ -62,6 +63,14 @@ const SelectField = qwik.component$((props) => {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
});
|
|
66
|
+
qwik.useTask$(async ({ track }) => {
|
|
67
|
+
if (props.reset) {
|
|
68
|
+
track(() => props.reset?.value);
|
|
69
|
+
value.value = originalValue;
|
|
70
|
+
error.value = void 0;
|
|
71
|
+
touched.value = false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
65
74
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
66
75
|
class: "fieldset",
|
|
67
76
|
children: [
|
|
@@ -3,6 +3,7 @@ import { component$, useSignal, useTask$, Slot } from "@builder.io/qwik";
|
|
|
3
3
|
const SelectField = component$((props) => {
|
|
4
4
|
const error = useSignal(typeof props.error === "string" ? props.error : props.error?.value);
|
|
5
5
|
const value = useSignal(typeof props.value === "string" ? props.value : props.value?.value);
|
|
6
|
+
const originalValue = typeof props.value === "string" ? props.value : props.value?.value;
|
|
6
7
|
const disabled = useSignal(false);
|
|
7
8
|
if (props.disabled) {
|
|
8
9
|
if (typeof props.disabled === "boolean") {
|
|
@@ -60,6 +61,14 @@ const SelectField = component$((props) => {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
});
|
|
64
|
+
useTask$(async ({ track }) => {
|
|
65
|
+
if (props.reset) {
|
|
66
|
+
track(() => props.reset?.value);
|
|
67
|
+
value.value = originalValue;
|
|
68
|
+
error.value = void 0;
|
|
69
|
+
touched.value = false;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
63
72
|
return /* @__PURE__ */ jsxs("div", {
|
|
64
73
|
class: "fieldset",
|
|
65
74
|
children: [
|
|
@@ -6,6 +6,7 @@ const index = require("../node_modules/.pnpm/valibot@1.2.0_typescript@5.9.3/node
|
|
|
6
6
|
const TextField = qwik.component$((props) => {
|
|
7
7
|
const error = qwik.useSignal(typeof props.error === "string" ? props.error : props.error?.value);
|
|
8
8
|
const value = qwik.useSignal(typeof props.value === "string" ? props.value : props.value?.value);
|
|
9
|
+
const originalValue = typeof props.value === "string" ? props.value : props.value?.value;
|
|
9
10
|
const disabled = qwik.useSignal(false);
|
|
10
11
|
if (props.disabled) {
|
|
11
12
|
if (typeof props.disabled === "boolean") {
|
|
@@ -63,6 +64,14 @@ const TextField = qwik.component$((props) => {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
});
|
|
67
|
+
qwik.useTask$(async ({ track }) => {
|
|
68
|
+
if (props.reset) {
|
|
69
|
+
track(() => props.reset?.value);
|
|
70
|
+
value.value = originalValue;
|
|
71
|
+
error.value = void 0;
|
|
72
|
+
touched.value = false;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
66
75
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
67
76
|
class: "fieldset",
|
|
68
77
|
children: [
|
|
@@ -127,11 +136,19 @@ const TextField = qwik.component$((props) => {
|
|
|
127
136
|
const schema = await props.schema$();
|
|
128
137
|
const result = index.safeParse(schema, value.value);
|
|
129
138
|
if (result.success) {
|
|
139
|
+
if (props.valid) {
|
|
140
|
+
props.valid.value = true;
|
|
141
|
+
}
|
|
130
142
|
error.value = void 0;
|
|
131
143
|
} else if (result.issues.length > 0) {
|
|
132
|
-
|
|
144
|
+
if (props.valid) {
|
|
145
|
+
props.valid.value = false;
|
|
146
|
+
}
|
|
133
147
|
error.value = result.issues[0].message;
|
|
134
148
|
} else {
|
|
149
|
+
if (props.valid) {
|
|
150
|
+
props.valid.value = false;
|
|
151
|
+
}
|
|
135
152
|
error.value = "Invalid value";
|
|
136
153
|
}
|
|
137
154
|
}
|
|
@@ -4,6 +4,7 @@ import { safeParse } from "../node_modules/.pnpm/valibot@1.2.0_typescript@5.9.3/
|
|
|
4
4
|
const TextField = component$((props) => {
|
|
5
5
|
const error = useSignal(typeof props.error === "string" ? props.error : props.error?.value);
|
|
6
6
|
const value = useSignal(typeof props.value === "string" ? props.value : props.value?.value);
|
|
7
|
+
const originalValue = typeof props.value === "string" ? props.value : props.value?.value;
|
|
7
8
|
const disabled = useSignal(false);
|
|
8
9
|
if (props.disabled) {
|
|
9
10
|
if (typeof props.disabled === "boolean") {
|
|
@@ -61,6 +62,14 @@ const TextField = component$((props) => {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
});
|
|
65
|
+
useTask$(async ({ track }) => {
|
|
66
|
+
if (props.reset) {
|
|
67
|
+
track(() => props.reset?.value);
|
|
68
|
+
value.value = originalValue;
|
|
69
|
+
error.value = void 0;
|
|
70
|
+
touched.value = false;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
64
73
|
return /* @__PURE__ */ jsxs("div", {
|
|
65
74
|
class: "fieldset",
|
|
66
75
|
children: [
|
|
@@ -125,11 +134,19 @@ const TextField = component$((props) => {
|
|
|
125
134
|
const schema = await props.schema$();
|
|
126
135
|
const result = safeParse(schema, value.value);
|
|
127
136
|
if (result.success) {
|
|
137
|
+
if (props.valid) {
|
|
138
|
+
props.valid.value = true;
|
|
139
|
+
}
|
|
128
140
|
error.value = void 0;
|
|
129
141
|
} else if (result.issues.length > 0) {
|
|
130
|
-
|
|
142
|
+
if (props.valid) {
|
|
143
|
+
props.valid.value = false;
|
|
144
|
+
}
|
|
131
145
|
error.value = result.issues[0].message;
|
|
132
146
|
} else {
|
|
147
|
+
if (props.valid) {
|
|
148
|
+
props.valid.value = false;
|
|
149
|
+
}
|
|
133
150
|
error.value = "Invalid value";
|
|
134
151
|
}
|
|
135
152
|
}
|
|
@@ -11,5 +11,9 @@ export interface SelectFieldProps {
|
|
|
11
11
|
onBlur$?: QRL<(event: FocusEvent, value: string, error: Signal<string | undefined>) => void>;
|
|
12
12
|
onEvent$?: QRL<(type: 'blur' | 'change', event: Event, value: string, error: Signal<string | undefined>) => void>;
|
|
13
13
|
validate$?: QRL<(value: string) => string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Increment the value of this signal to reset the input to its original value.
|
|
16
|
+
*/
|
|
17
|
+
reset?: Signal<number>;
|
|
14
18
|
}
|
|
15
19
|
export declare const SelectField: import("@builder.io/qwik").Component<SelectFieldProps>;
|
|
@@ -15,5 +15,10 @@ export interface TextFieldProps {
|
|
|
15
15
|
onEvent$?: QRL<(type: 'blur' | 'input', event: FocusEvent | InputEvent, value: string, error: Signal<string | undefined>) => void>;
|
|
16
16
|
validate$?: QRL<(value: string) => string | undefined>;
|
|
17
17
|
schema$?: QRL<() => v.BaseSchema<any, any, any>>;
|
|
18
|
+
valid?: Signal<undefined | boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Increment the value of this signal to reset the input to its original value.
|
|
21
|
+
*/
|
|
22
|
+
reset?: Signal<number>;
|
|
18
23
|
}
|
|
19
24
|
export declare const TextField: import("@builder.io/qwik").Component<TextFieldProps>;
|