@nr1e/qwik-ui 1.0.5 → 2.0.1
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/drop-up.qwik.mjs +1 -1
- package/lib/components/select-field.qwik.cjs +4 -4
- package/lib/components/select-field.qwik.mjs +4 -4
- package/lib/components/text-field.qwik.cjs +16 -4
- package/lib/components/text-field.qwik.mjs +16 -4
- package/lib/node_modules/.pnpm/valibot@1.2.0_typescript@5.9.3/node_modules/valibot/dist/index.qwik.cjs +24 -0
- package/lib/node_modules/.pnpm/valibot@1.2.0_typescript@5.9.3/node_modules/valibot/dist/index.qwik.mjs +24 -0
- package/lib-types/components/select-field.d.ts +1 -1
- package/lib-types/components/text-field.d.ts +3 -1
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "@builder.io/qwik/jsx-runtime";
|
|
2
|
-
import { component$,
|
|
2
|
+
import { component$, useSignal, useTask$, useOnDocument, $, Slot } from "@builder.io/qwik";
|
|
3
3
|
import { Link } from "@builder.io/qwik-city";
|
|
4
4
|
const DropUpButton = component$((props) => {
|
|
5
5
|
return /* @__PURE__ */ jsx("li", {
|
|
@@ -86,7 +86,7 @@ const SelectField = qwik.component$((props) => {
|
|
|
86
86
|
"aria-required": props.required,
|
|
87
87
|
disabled: disabled.value,
|
|
88
88
|
class: `select ${error.value ? "select-error" : ""}`,
|
|
89
|
-
onChange$: (e) => {
|
|
89
|
+
onChange$: async (e) => {
|
|
90
90
|
const target = e.target;
|
|
91
91
|
if (props.onChange$) {
|
|
92
92
|
props.onChange$(e, target.value, error);
|
|
@@ -98,10 +98,10 @@ const SelectField = qwik.component$((props) => {
|
|
|
98
98
|
value.value = target.value;
|
|
99
99
|
}
|
|
100
100
|
if (props.validate$) {
|
|
101
|
-
props.validate$(target.value
|
|
101
|
+
error.value = await props.validate$(target.value);
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
|
-
onBlur$: (e) => {
|
|
104
|
+
onBlur$: async (e) => {
|
|
105
105
|
touched.value = true;
|
|
106
106
|
const target = e.target;
|
|
107
107
|
if (props.onBlur$) {
|
|
@@ -114,7 +114,7 @@ const SelectField = qwik.component$((props) => {
|
|
|
114
114
|
value.value = target.value;
|
|
115
115
|
}
|
|
116
116
|
if (props.validate$) {
|
|
117
|
-
props.validate$(target.value
|
|
117
|
+
error.value = await props.validate$(target.value);
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
|
|
@@ -84,7 +84,7 @@ const SelectField = component$((props) => {
|
|
|
84
84
|
"aria-required": props.required,
|
|
85
85
|
disabled: disabled.value,
|
|
86
86
|
class: `select ${error.value ? "select-error" : ""}`,
|
|
87
|
-
onChange$: (e) => {
|
|
87
|
+
onChange$: async (e) => {
|
|
88
88
|
const target = e.target;
|
|
89
89
|
if (props.onChange$) {
|
|
90
90
|
props.onChange$(e, target.value, error);
|
|
@@ -96,10 +96,10 @@ const SelectField = component$((props) => {
|
|
|
96
96
|
value.value = target.value;
|
|
97
97
|
}
|
|
98
98
|
if (props.validate$) {
|
|
99
|
-
props.validate$(target.value
|
|
99
|
+
error.value = await props.validate$(target.value);
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
|
-
onBlur$: (e) => {
|
|
102
|
+
onBlur$: async (e) => {
|
|
103
103
|
touched.value = true;
|
|
104
104
|
const target = e.target;
|
|
105
105
|
if (props.onBlur$) {
|
|
@@ -112,7 +112,7 @@ const SelectField = component$((props) => {
|
|
|
112
112
|
value.value = target.value;
|
|
113
113
|
}
|
|
114
114
|
if (props.validate$) {
|
|
115
|
-
props.validate$(target.value
|
|
115
|
+
error.value = await props.validate$(target.value);
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
children: /* @__PURE__ */ jsx(Slot, {})
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
|
|
4
4
|
const qwik = require("@builder.io/qwik");
|
|
5
|
+
const index = require("../node_modules/.pnpm/valibot@1.2.0_typescript@5.9.3/node_modules/valibot/dist/index.qwik.cjs");
|
|
5
6
|
const TextField = qwik.component$((props) => {
|
|
6
7
|
const error = qwik.useSignal(typeof props.error === "string" ? props.error : props.error?.value);
|
|
7
8
|
const value = qwik.useSignal(typeof props.value === "string" ? props.value : props.value?.value);
|
|
@@ -96,7 +97,7 @@ const TextField = qwik.component$((props) => {
|
|
|
96
97
|
value: value.value,
|
|
97
98
|
class: "placeholder:opacity-50",
|
|
98
99
|
placeholder: props.placeholder,
|
|
99
|
-
onBlur$: (e) => {
|
|
100
|
+
onBlur$: async (e) => {
|
|
100
101
|
touched.value = true;
|
|
101
102
|
const target = e.target;
|
|
102
103
|
if (props.onBlur$) {
|
|
@@ -109,10 +110,10 @@ const TextField = qwik.component$((props) => {
|
|
|
109
110
|
value.value = target.value;
|
|
110
111
|
}
|
|
111
112
|
if (props.validate$) {
|
|
112
|
-
props.validate$(target.value
|
|
113
|
+
error.value = await props.validate$(target.value);
|
|
113
114
|
}
|
|
114
115
|
},
|
|
115
|
-
onInput$: (e) => {
|
|
116
|
+
onInput$: async (e) => {
|
|
116
117
|
const target = e.target;
|
|
117
118
|
if (props.onInput$) {
|
|
118
119
|
props.onInput$(e, target.value, error);
|
|
@@ -124,7 +125,18 @@ const TextField = qwik.component$((props) => {
|
|
|
124
125
|
value.value = target.value;
|
|
125
126
|
}
|
|
126
127
|
if (props.validate$) {
|
|
127
|
-
props.validate$(target.value
|
|
128
|
+
error.value = await props.validate$(target.value);
|
|
129
|
+
}
|
|
130
|
+
if (props.schema$) {
|
|
131
|
+
const schema = await props.schema$();
|
|
132
|
+
const result = index.safeParse(schema, value.value);
|
|
133
|
+
if (result.success) {
|
|
134
|
+
error.value = void 0;
|
|
135
|
+
} else if (result.issues.length > 0) {
|
|
136
|
+
error.value = result.issues[0].message;
|
|
137
|
+
} else {
|
|
138
|
+
error.value = "Invalid value";
|
|
139
|
+
}
|
|
128
140
|
}
|
|
129
141
|
}
|
|
130
142
|
}),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "@builder.io/qwik/jsx-runtime";
|
|
2
2
|
import { component$, useSignal, useTask$, Slot } from "@builder.io/qwik";
|
|
3
|
+
import { safeParse } from "../node_modules/.pnpm/valibot@1.2.0_typescript@5.9.3/node_modules/valibot/dist/index.qwik.mjs";
|
|
3
4
|
const TextField = component$((props) => {
|
|
4
5
|
const error = useSignal(typeof props.error === "string" ? props.error : props.error?.value);
|
|
5
6
|
const value = useSignal(typeof props.value === "string" ? props.value : props.value?.value);
|
|
@@ -94,7 +95,7 @@ const TextField = component$((props) => {
|
|
|
94
95
|
value: value.value,
|
|
95
96
|
class: "placeholder:opacity-50",
|
|
96
97
|
placeholder: props.placeholder,
|
|
97
|
-
onBlur$: (e) => {
|
|
98
|
+
onBlur$: async (e) => {
|
|
98
99
|
touched.value = true;
|
|
99
100
|
const target = e.target;
|
|
100
101
|
if (props.onBlur$) {
|
|
@@ -107,10 +108,10 @@ const TextField = component$((props) => {
|
|
|
107
108
|
value.value = target.value;
|
|
108
109
|
}
|
|
109
110
|
if (props.validate$) {
|
|
110
|
-
props.validate$(target.value
|
|
111
|
+
error.value = await props.validate$(target.value);
|
|
111
112
|
}
|
|
112
113
|
},
|
|
113
|
-
onInput$: (e) => {
|
|
114
|
+
onInput$: async (e) => {
|
|
114
115
|
const target = e.target;
|
|
115
116
|
if (props.onInput$) {
|
|
116
117
|
props.onInput$(e, target.value, error);
|
|
@@ -122,7 +123,18 @@ const TextField = component$((props) => {
|
|
|
122
123
|
value.value = target.value;
|
|
123
124
|
}
|
|
124
125
|
if (props.validate$) {
|
|
125
|
-
props.validate$(target.value
|
|
126
|
+
error.value = await props.validate$(target.value);
|
|
127
|
+
}
|
|
128
|
+
if (props.schema$) {
|
|
129
|
+
const schema = await props.schema$();
|
|
130
|
+
const result = safeParse(schema, value.value);
|
|
131
|
+
if (result.success) {
|
|
132
|
+
error.value = void 0;
|
|
133
|
+
} else if (result.issues.length > 0) {
|
|
134
|
+
error.value = result.issues[0].message;
|
|
135
|
+
} else {
|
|
136
|
+
error.value = "Invalid value";
|
|
137
|
+
}
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
}),
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let store$4;
|
|
4
|
+
// @__NO_SIDE_EFFECTS__
|
|
5
|
+
function getGlobalConfig(config$1) {
|
|
6
|
+
return {
|
|
7
|
+
lang: config$1?.lang ?? store$4?.lang,
|
|
8
|
+
message: config$1?.message,
|
|
9
|
+
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
10
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
// @__NO_SIDE_EFFECTS__
|
|
14
|
+
function safeParse(schema, input, config$1) {
|
|
15
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
16
|
+
return {
|
|
17
|
+
typed: dataset.typed,
|
|
18
|
+
success: !dataset.issues,
|
|
19
|
+
output: dataset.value,
|
|
20
|
+
issues: dataset.issues
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.getGlobalConfig = getGlobalConfig;
|
|
24
|
+
exports.safeParse = safeParse;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
let store$4;
|
|
2
|
+
// @__NO_SIDE_EFFECTS__
|
|
3
|
+
function getGlobalConfig(config$1) {
|
|
4
|
+
return {
|
|
5
|
+
lang: config$1?.lang ?? store$4?.lang,
|
|
6
|
+
message: config$1?.message,
|
|
7
|
+
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
8
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
// @__NO_SIDE_EFFECTS__
|
|
12
|
+
function safeParse(schema, input, config$1) {
|
|
13
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
14
|
+
return {
|
|
15
|
+
typed: dataset.typed,
|
|
16
|
+
success: !dataset.issues,
|
|
17
|
+
output: dataset.value,
|
|
18
|
+
issues: dataset.issues
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
getGlobalConfig,
|
|
23
|
+
safeParse
|
|
24
|
+
};
|
|
@@ -10,6 +10,6 @@ export interface SelectFieldProps {
|
|
|
10
10
|
onChange$?: QRL<(event: Event, value: string, error: Signal<string | undefined>) => void>;
|
|
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
|
-
validate$?: QRL<(value: string
|
|
13
|
+
validate$?: QRL<(value: string) => string | undefined>;
|
|
14
14
|
}
|
|
15
15
|
export declare const SelectField: import("@builder.io/qwik").Component<SelectFieldProps>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { QRL, Signal } from '@builder.io/qwik';
|
|
2
|
+
import * as v from 'valibot';
|
|
2
3
|
export interface TextFieldProps {
|
|
3
4
|
id?: string;
|
|
4
5
|
label?: string;
|
|
@@ -12,6 +13,7 @@ export interface TextFieldProps {
|
|
|
12
13
|
onBlur$?: QRL<(event: FocusEvent, value: string, error: Signal<string | undefined>) => void>;
|
|
13
14
|
onInput$?: QRL<(event: InputEvent, value: string, error: Signal<string | undefined>) => void>;
|
|
14
15
|
onEvent$?: QRL<(type: 'blur' | 'input', event: FocusEvent | InputEvent, value: string, error: Signal<string | undefined>) => void>;
|
|
15
|
-
validate$?: QRL<(value: string
|
|
16
|
+
validate$?: QRL<(value: string) => string | undefined>;
|
|
17
|
+
schema$?: QRL<() => v.AnySchema>;
|
|
16
18
|
}
|
|
17
19
|
export declare const TextField: import("@builder.io/qwik").Component<TextFieldProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nr1e/qwik-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "NR1E Qwik UI Library",
|
|
5
5
|
"author": "NR1E, Inc.",
|
|
6
6
|
"publishConfig": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"typescript": "5.9.3",
|
|
55
55
|
"typescript-eslint": "8.56.1",
|
|
56
56
|
"undici": "*",
|
|
57
|
+
"valibot": "^1.2.0",
|
|
57
58
|
"vite": "7.3.1",
|
|
58
59
|
"vite-tsconfig-paths": "^6.1.1",
|
|
59
60
|
"vitest": "4.0.18"
|