@nr1e/qwik-ui 2.0.0 → 2.0.2
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/text-field.qwik.cjs +12 -0
- package/lib/components/text-field.qwik.mjs +12 -0
- 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/text-field.d.ts +2 -0
- package/package.json +2 -1
|
@@ -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);
|
|
@@ -126,6 +127,17 @@ const TextField = qwik.component$((props) => {
|
|
|
126
127
|
if (props.validate$) {
|
|
127
128
|
error.value = await props.validate$(target.value);
|
|
128
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
|
+
}
|
|
140
|
+
}
|
|
129
141
|
}
|
|
130
142
|
}),
|
|
131
143
|
/* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {
|
|
@@ -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);
|
|
@@ -124,6 +125,17 @@ const TextField = component$((props) => {
|
|
|
124
125
|
if (props.validate$) {
|
|
125
126
|
error.value = await props.validate$(target.value);
|
|
126
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
|
+
}
|
|
138
|
+
}
|
|
127
139
|
}
|
|
128
140
|
}),
|
|
129
141
|
/* @__PURE__ */ jsx(Slot, {
|
|
@@ -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
|
+
};
|
|
@@ -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;
|
|
@@ -13,5 +14,6 @@ export interface TextFieldProps {
|
|
|
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
16
|
validate$?: QRL<(value: string) => string | undefined>;
|
|
17
|
+
schema$?: QRL<() => v.BaseSchema<any, any, any>>;
|
|
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": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
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"
|