@json-render/shadcn 0.9.1 → 0.10.0
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/README.md +18 -7
- package/dist/catalog.d.mts +45 -0
- package/dist/catalog.d.ts +45 -0
- package/dist/catalog.js +29 -30
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/{chunk-VZQBPEYT.mjs → chunk-F5LRX6LB.mjs} +30 -31
- package/dist/chunk-F5LRX6LB.mjs.map +1 -0
- package/dist/index.js +99 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-VZQBPEYT.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
shadcnComponentDefinitions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F5LRX6LB.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components.tsx
|
|
6
6
|
import { useState as useState2 } from "react";
|
|
@@ -2061,10 +2061,11 @@ var shadcnComponents = {
|
|
|
2061
2061
|
const isBound = !!bindings?.value;
|
|
2062
2062
|
const value = isBound ? boundValue ?? "" : localValue;
|
|
2063
2063
|
const setValue = isBound ? setBoundValue : setLocalValue;
|
|
2064
|
+
const validateOn = props.validateOn ?? "blur";
|
|
2064
2065
|
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2065
2066
|
const { errors, validate } = useFieldValidation(
|
|
2066
2067
|
bindings?.value ?? "",
|
|
2067
|
-
hasValidation ? { checks: props.checks ?? [] } : void 0
|
|
2068
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2068
2069
|
);
|
|
2069
2070
|
return /* @__PURE__ */ jsxs10("div", { className: "space-y-2", children: [
|
|
2070
2071
|
props.label && /* @__PURE__ */ jsx30(Label, { htmlFor: props.name ?? void 0, children: props.label }),
|
|
@@ -2076,13 +2077,16 @@ var shadcnComponents = {
|
|
|
2076
2077
|
type: props.type ?? "text",
|
|
2077
2078
|
placeholder: props.placeholder ?? "",
|
|
2078
2079
|
value,
|
|
2079
|
-
onChange: (e) =>
|
|
2080
|
+
onChange: (e) => {
|
|
2081
|
+
setValue(e.target.value);
|
|
2082
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2083
|
+
},
|
|
2080
2084
|
onKeyDown: (e) => {
|
|
2081
2085
|
if (e.key === "Enter") emit("submit");
|
|
2082
2086
|
},
|
|
2083
2087
|
onFocus: () => emit("focus"),
|
|
2084
2088
|
onBlur: () => {
|
|
2085
|
-
if (hasValidation) validate();
|
|
2089
|
+
if (hasValidation && validateOn === "blur") validate();
|
|
2086
2090
|
emit("blur");
|
|
2087
2091
|
}
|
|
2088
2092
|
}
|
|
@@ -2102,10 +2106,11 @@ var shadcnComponents = {
|
|
|
2102
2106
|
const isBound = !!bindings?.value;
|
|
2103
2107
|
const value = isBound ? boundValue ?? "" : localValue;
|
|
2104
2108
|
const setValue = isBound ? setBoundValue : setLocalValue;
|
|
2109
|
+
const validateOn = props.validateOn ?? "blur";
|
|
2105
2110
|
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2106
2111
|
const { errors, validate } = useFieldValidation(
|
|
2107
2112
|
bindings?.value ?? "",
|
|
2108
|
-
hasValidation ? { checks: props.checks ?? [] } : void 0
|
|
2113
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2109
2114
|
);
|
|
2110
2115
|
return /* @__PURE__ */ jsxs10("div", { className: "space-y-2", children: [
|
|
2111
2116
|
props.label && /* @__PURE__ */ jsx30(Label, { htmlFor: props.name ?? void 0, children: props.label }),
|
|
@@ -2117,9 +2122,12 @@ var shadcnComponents = {
|
|
|
2117
2122
|
placeholder: props.placeholder ?? "",
|
|
2118
2123
|
rows: props.rows ?? 3,
|
|
2119
2124
|
value,
|
|
2120
|
-
onChange: (e) =>
|
|
2125
|
+
onChange: (e) => {
|
|
2126
|
+
setValue(e.target.value);
|
|
2127
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2128
|
+
},
|
|
2121
2129
|
onBlur: () => {
|
|
2122
|
-
if (hasValidation) validate();
|
|
2130
|
+
if (hasValidation && validateOn === "blur") validate();
|
|
2123
2131
|
}
|
|
2124
2132
|
}
|
|
2125
2133
|
),
|
|
@@ -2143,10 +2151,11 @@ var shadcnComponents = {
|
|
|
2143
2151
|
const options = rawOptions.map(
|
|
2144
2152
|
(opt) => typeof opt === "string" ? opt : String(opt ?? "")
|
|
2145
2153
|
);
|
|
2154
|
+
const validateOn = props.validateOn ?? "change";
|
|
2146
2155
|
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2147
2156
|
const { errors, validate } = useFieldValidation(
|
|
2148
2157
|
bindings?.value ?? "",
|
|
2149
|
-
hasValidation ? { checks: props.checks ?? [] } : void 0
|
|
2158
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2150
2159
|
);
|
|
2151
2160
|
return /* @__PURE__ */ jsxs10("div", { className: "space-y-2", children: [
|
|
2152
2161
|
/* @__PURE__ */ jsx30(Label, { children: props.label }),
|
|
@@ -2156,7 +2165,7 @@ var shadcnComponents = {
|
|
|
2156
2165
|
value,
|
|
2157
2166
|
onValueChange: (v) => {
|
|
2158
2167
|
setValue(v);
|
|
2159
|
-
if (hasValidation) validate();
|
|
2168
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2160
2169
|
emit("change");
|
|
2161
2170
|
},
|
|
2162
2171
|
children: [
|
|
@@ -2181,19 +2190,29 @@ var shadcnComponents = {
|
|
|
2181
2190
|
const isBound = !!bindings?.checked;
|
|
2182
2191
|
const checked = isBound ? boundChecked ?? false : localChecked;
|
|
2183
2192
|
const setChecked = isBound ? setBoundChecked : setLocalChecked;
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
+
const validateOn = props.validateOn ?? "change";
|
|
2194
|
+
const hasValidation = !!(bindings?.checked && props.checks?.length);
|
|
2195
|
+
const { errors, validate } = useFieldValidation(
|
|
2196
|
+
bindings?.checked ?? "",
|
|
2197
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2198
|
+
);
|
|
2199
|
+
return /* @__PURE__ */ jsxs10("div", { className: "space-y-1", children: [
|
|
2200
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center space-x-2", children: [
|
|
2201
|
+
/* @__PURE__ */ jsx30(
|
|
2202
|
+
Checkbox,
|
|
2203
|
+
{
|
|
2204
|
+
id: props.name ?? void 0,
|
|
2205
|
+
checked,
|
|
2206
|
+
onCheckedChange: (c) => {
|
|
2207
|
+
setChecked(c === true);
|
|
2208
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2209
|
+
emit("change");
|
|
2210
|
+
}
|
|
2193
2211
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2212
|
+
),
|
|
2213
|
+
/* @__PURE__ */ jsx30(Label, { htmlFor: props.name ?? void 0, className: "cursor-pointer", children: props.label })
|
|
2214
|
+
] }),
|
|
2215
|
+
errors.length > 0 && /* @__PURE__ */ jsx30("p", { className: "text-sm text-destructive", children: errors[0] })
|
|
2197
2216
|
] });
|
|
2198
2217
|
},
|
|
2199
2218
|
Radio: ({
|
|
@@ -2213,6 +2232,12 @@ var shadcnComponents = {
|
|
|
2213
2232
|
const isBound = !!bindings?.value;
|
|
2214
2233
|
const value = isBound ? boundValue ?? "" : localValue;
|
|
2215
2234
|
const setValue = isBound ? setBoundValue : setLocalValue;
|
|
2235
|
+
const validateOn = props.validateOn ?? "change";
|
|
2236
|
+
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2237
|
+
const { errors, validate } = useFieldValidation(
|
|
2238
|
+
bindings?.value ?? "",
|
|
2239
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2240
|
+
);
|
|
2216
2241
|
return /* @__PURE__ */ jsxs10("div", { className: "space-y-2", children: [
|
|
2217
2242
|
props.label && /* @__PURE__ */ jsx30(Label, { children: props.label }),
|
|
2218
2243
|
/* @__PURE__ */ jsx30(
|
|
@@ -2221,6 +2246,7 @@ var shadcnComponents = {
|
|
|
2221
2246
|
value,
|
|
2222
2247
|
onValueChange: (v) => {
|
|
2223
2248
|
setValue(v);
|
|
2249
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2224
2250
|
emit("change");
|
|
2225
2251
|
},
|
|
2226
2252
|
children: options.map((opt, idx) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center space-x-2", children: [
|
|
@@ -2241,7 +2267,8 @@ var shadcnComponents = {
|
|
|
2241
2267
|
)
|
|
2242
2268
|
] }, `${idx}-${opt}`))
|
|
2243
2269
|
}
|
|
2244
|
-
)
|
|
2270
|
+
),
|
|
2271
|
+
errors.length > 0 && /* @__PURE__ */ jsx30("p", { className: "text-sm text-destructive", children: errors[0] })
|
|
2245
2272
|
] });
|
|
2246
2273
|
},
|
|
2247
2274
|
Switch: ({
|
|
@@ -2257,19 +2284,29 @@ var shadcnComponents = {
|
|
|
2257
2284
|
const isBound = !!bindings?.checked;
|
|
2258
2285
|
const checked = isBound ? boundChecked ?? false : localChecked;
|
|
2259
2286
|
const setChecked = isBound ? setBoundChecked : setLocalChecked;
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2287
|
+
const validateOn = props.validateOn ?? "change";
|
|
2288
|
+
const hasValidation = !!(bindings?.checked && props.checks?.length);
|
|
2289
|
+
const { errors, validate } = useFieldValidation(
|
|
2290
|
+
bindings?.checked ?? "",
|
|
2291
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2292
|
+
);
|
|
2293
|
+
return /* @__PURE__ */ jsxs10("div", { className: "space-y-1", children: [
|
|
2294
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between space-x-2", children: [
|
|
2295
|
+
/* @__PURE__ */ jsx30(Label, { htmlFor: props.name ?? void 0, className: "cursor-pointer", children: props.label }),
|
|
2296
|
+
/* @__PURE__ */ jsx30(
|
|
2297
|
+
Switch,
|
|
2298
|
+
{
|
|
2299
|
+
id: props.name ?? void 0,
|
|
2300
|
+
checked,
|
|
2301
|
+
onCheckedChange: (c) => {
|
|
2302
|
+
setChecked(c);
|
|
2303
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2304
|
+
emit("change");
|
|
2305
|
+
}
|
|
2270
2306
|
}
|
|
2271
|
-
|
|
2272
|
-
)
|
|
2307
|
+
)
|
|
2308
|
+
] }),
|
|
2309
|
+
errors.length > 0 && /* @__PURE__ */ jsx30("p", { className: "text-sm text-destructive", children: errors[0] })
|
|
2273
2310
|
] });
|
|
2274
2311
|
},
|
|
2275
2312
|
Slider: ({
|