@json-render/shadcn 0.9.0 → 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.js
CHANGED
|
@@ -2086,10 +2086,11 @@ var shadcnComponents = {
|
|
|
2086
2086
|
const isBound = !!bindings?.value;
|
|
2087
2087
|
const value = isBound ? boundValue ?? "" : localValue;
|
|
2088
2088
|
const setValue = isBound ? setBoundValue : setLocalValue;
|
|
2089
|
+
const validateOn = props.validateOn ?? "blur";
|
|
2089
2090
|
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2090
2091
|
const { errors, validate } = (0, import_react2.useFieldValidation)(
|
|
2091
2092
|
bindings?.value ?? "",
|
|
2092
|
-
hasValidation ? { checks: props.checks ?? [] } : void 0
|
|
2093
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2093
2094
|
);
|
|
2094
2095
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-2", children: [
|
|
2095
2096
|
props.label && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Label, { htmlFor: props.name ?? void 0, children: props.label }),
|
|
@@ -2101,13 +2102,16 @@ var shadcnComponents = {
|
|
|
2101
2102
|
type: props.type ?? "text",
|
|
2102
2103
|
placeholder: props.placeholder ?? "",
|
|
2103
2104
|
value,
|
|
2104
|
-
onChange: (e) =>
|
|
2105
|
+
onChange: (e) => {
|
|
2106
|
+
setValue(e.target.value);
|
|
2107
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2108
|
+
},
|
|
2105
2109
|
onKeyDown: (e) => {
|
|
2106
2110
|
if (e.key === "Enter") emit("submit");
|
|
2107
2111
|
},
|
|
2108
2112
|
onFocus: () => emit("focus"),
|
|
2109
2113
|
onBlur: () => {
|
|
2110
|
-
if (hasValidation) validate();
|
|
2114
|
+
if (hasValidation && validateOn === "blur") validate();
|
|
2111
2115
|
emit("blur");
|
|
2112
2116
|
}
|
|
2113
2117
|
}
|
|
@@ -2127,10 +2131,11 @@ var shadcnComponents = {
|
|
|
2127
2131
|
const isBound = !!bindings?.value;
|
|
2128
2132
|
const value = isBound ? boundValue ?? "" : localValue;
|
|
2129
2133
|
const setValue = isBound ? setBoundValue : setLocalValue;
|
|
2134
|
+
const validateOn = props.validateOn ?? "blur";
|
|
2130
2135
|
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2131
2136
|
const { errors, validate } = (0, import_react2.useFieldValidation)(
|
|
2132
2137
|
bindings?.value ?? "",
|
|
2133
|
-
hasValidation ? { checks: props.checks ?? [] } : void 0
|
|
2138
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2134
2139
|
);
|
|
2135
2140
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-2", children: [
|
|
2136
2141
|
props.label && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Label, { htmlFor: props.name ?? void 0, children: props.label }),
|
|
@@ -2142,9 +2147,12 @@ var shadcnComponents = {
|
|
|
2142
2147
|
placeholder: props.placeholder ?? "",
|
|
2143
2148
|
rows: props.rows ?? 3,
|
|
2144
2149
|
value,
|
|
2145
|
-
onChange: (e) =>
|
|
2150
|
+
onChange: (e) => {
|
|
2151
|
+
setValue(e.target.value);
|
|
2152
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2153
|
+
},
|
|
2146
2154
|
onBlur: () => {
|
|
2147
|
-
if (hasValidation) validate();
|
|
2155
|
+
if (hasValidation && validateOn === "blur") validate();
|
|
2148
2156
|
}
|
|
2149
2157
|
}
|
|
2150
2158
|
),
|
|
@@ -2168,10 +2176,11 @@ var shadcnComponents = {
|
|
|
2168
2176
|
const options = rawOptions.map(
|
|
2169
2177
|
(opt) => typeof opt === "string" ? opt : String(opt ?? "")
|
|
2170
2178
|
);
|
|
2179
|
+
const validateOn = props.validateOn ?? "change";
|
|
2171
2180
|
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2172
2181
|
const { errors, validate } = (0, import_react2.useFieldValidation)(
|
|
2173
2182
|
bindings?.value ?? "",
|
|
2174
|
-
hasValidation ? { checks: props.checks ?? [] } : void 0
|
|
2183
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2175
2184
|
);
|
|
2176
2185
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-2", children: [
|
|
2177
2186
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Label, { children: props.label }),
|
|
@@ -2181,7 +2190,7 @@ var shadcnComponents = {
|
|
|
2181
2190
|
value,
|
|
2182
2191
|
onValueChange: (v) => {
|
|
2183
2192
|
setValue(v);
|
|
2184
|
-
if (hasValidation) validate();
|
|
2193
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2185
2194
|
emit("change");
|
|
2186
2195
|
},
|
|
2187
2196
|
children: [
|
|
@@ -2206,19 +2215,29 @@ var shadcnComponents = {
|
|
|
2206
2215
|
const isBound = !!bindings?.checked;
|
|
2207
2216
|
const checked = isBound ? boundChecked ?? false : localChecked;
|
|
2208
2217
|
const setChecked = isBound ? setBoundChecked : setLocalChecked;
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
+
const validateOn = props.validateOn ?? "change";
|
|
2219
|
+
const hasValidation = !!(bindings?.checked && props.checks?.length);
|
|
2220
|
+
const { errors, validate } = (0, import_react2.useFieldValidation)(
|
|
2221
|
+
bindings?.checked ?? "",
|
|
2222
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2223
|
+
);
|
|
2224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-1", children: [
|
|
2225
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center space-x-2", children: [
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2227
|
+
Checkbox,
|
|
2228
|
+
{
|
|
2229
|
+
id: props.name ?? void 0,
|
|
2230
|
+
checked,
|
|
2231
|
+
onCheckedChange: (c) => {
|
|
2232
|
+
setChecked(c === true);
|
|
2233
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2234
|
+
emit("change");
|
|
2235
|
+
}
|
|
2218
2236
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2237
|
+
),
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Label, { htmlFor: props.name ?? void 0, className: "cursor-pointer", children: props.label })
|
|
2239
|
+
] }),
|
|
2240
|
+
errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-sm text-destructive", children: errors[0] })
|
|
2222
2241
|
] });
|
|
2223
2242
|
},
|
|
2224
2243
|
Radio: ({
|
|
@@ -2238,6 +2257,12 @@ var shadcnComponents = {
|
|
|
2238
2257
|
const isBound = !!bindings?.value;
|
|
2239
2258
|
const value = isBound ? boundValue ?? "" : localValue;
|
|
2240
2259
|
const setValue = isBound ? setBoundValue : setLocalValue;
|
|
2260
|
+
const validateOn = props.validateOn ?? "change";
|
|
2261
|
+
const hasValidation = !!(bindings?.value && props.checks?.length);
|
|
2262
|
+
const { errors, validate } = (0, import_react2.useFieldValidation)(
|
|
2263
|
+
bindings?.value ?? "",
|
|
2264
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2265
|
+
);
|
|
2241
2266
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-2", children: [
|
|
2242
2267
|
props.label && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Label, { children: props.label }),
|
|
2243
2268
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
@@ -2246,6 +2271,7 @@ var shadcnComponents = {
|
|
|
2246
2271
|
value,
|
|
2247
2272
|
onValueChange: (v) => {
|
|
2248
2273
|
setValue(v);
|
|
2274
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2249
2275
|
emit("change");
|
|
2250
2276
|
},
|
|
2251
2277
|
children: options.map((opt, idx) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center space-x-2", children: [
|
|
@@ -2266,7 +2292,8 @@ var shadcnComponents = {
|
|
|
2266
2292
|
)
|
|
2267
2293
|
] }, `${idx}-${opt}`))
|
|
2268
2294
|
}
|
|
2269
|
-
)
|
|
2295
|
+
),
|
|
2296
|
+
errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-sm text-destructive", children: errors[0] })
|
|
2270
2297
|
] });
|
|
2271
2298
|
},
|
|
2272
2299
|
Switch: ({
|
|
@@ -2282,19 +2309,29 @@ var shadcnComponents = {
|
|
|
2282
2309
|
const isBound = !!bindings?.checked;
|
|
2283
2310
|
const checked = isBound ? boundChecked ?? false : localChecked;
|
|
2284
2311
|
const setChecked = isBound ? setBoundChecked : setLocalChecked;
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2312
|
+
const validateOn = props.validateOn ?? "change";
|
|
2313
|
+
const hasValidation = !!(bindings?.checked && props.checks?.length);
|
|
2314
|
+
const { errors, validate } = (0, import_react2.useFieldValidation)(
|
|
2315
|
+
bindings?.checked ?? "",
|
|
2316
|
+
hasValidation ? { checks: props.checks ?? [], validateOn } : void 0
|
|
2317
|
+
);
|
|
2318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-1", children: [
|
|
2319
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center justify-between space-x-2", children: [
|
|
2320
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Label, { htmlFor: props.name ?? void 0, className: "cursor-pointer", children: props.label }),
|
|
2321
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2322
|
+
Switch,
|
|
2323
|
+
{
|
|
2324
|
+
id: props.name ?? void 0,
|
|
2325
|
+
checked,
|
|
2326
|
+
onCheckedChange: (c) => {
|
|
2327
|
+
setChecked(c);
|
|
2328
|
+
if (hasValidation && validateOn === "change") validate();
|
|
2329
|
+
emit("change");
|
|
2330
|
+
}
|
|
2295
2331
|
}
|
|
2296
|
-
|
|
2297
|
-
)
|
|
2332
|
+
)
|
|
2333
|
+
] }),
|
|
2334
|
+
errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-sm text-destructive", children: errors[0] })
|
|
2298
2335
|
] });
|
|
2299
2336
|
},
|
|
2300
2337
|
Slider: ({
|
|
@@ -2541,6 +2578,14 @@ var shadcnComponents = {
|
|
|
2541
2578
|
|
|
2542
2579
|
// src/catalog.ts
|
|
2543
2580
|
var import_zod = require("zod");
|
|
2581
|
+
var validationCheckSchema = import_zod.z.array(
|
|
2582
|
+
import_zod.z.object({
|
|
2583
|
+
type: import_zod.z.string(),
|
|
2584
|
+
message: import_zod.z.string(),
|
|
2585
|
+
args: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
2586
|
+
})
|
|
2587
|
+
).nullable();
|
|
2588
|
+
var validateOnSchema = import_zod.z.enum(["change", "blur", "submit"]).nullable();
|
|
2544
2589
|
var shadcnComponentDefinitions = {
|
|
2545
2590
|
// ==========================================================================
|
|
2546
2591
|
// Layout Components
|
|
@@ -2767,16 +2812,11 @@ var shadcnComponentDefinitions = {
|
|
|
2767
2812
|
type: import_zod.z.enum(["text", "email", "password", "number"]).nullable(),
|
|
2768
2813
|
placeholder: import_zod.z.string().nullable(),
|
|
2769
2814
|
value: import_zod.z.string().nullable(),
|
|
2770
|
-
checks:
|
|
2771
|
-
|
|
2772
|
-
type: import_zod.z.string(),
|
|
2773
|
-
message: import_zod.z.string(),
|
|
2774
|
-
args: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
2775
|
-
})
|
|
2776
|
-
).nullable()
|
|
2815
|
+
checks: validationCheckSchema,
|
|
2816
|
+
validateOn: validateOnSchema
|
|
2777
2817
|
}),
|
|
2778
2818
|
events: ["submit", "focus", "blur"],
|
|
2779
|
-
description: "Text input field. Use { $bindState } on value for two-way binding. Use checks for validation (e.g. required, email, minLength).",
|
|
2819
|
+
description: "Text input field. Use { $bindState } on value for two-way binding. Use checks for validation (e.g. required, email, minLength). validateOn controls timing (default: blur).",
|
|
2780
2820
|
example: {
|
|
2781
2821
|
label: "Email",
|
|
2782
2822
|
name: "email",
|
|
@@ -2791,15 +2831,10 @@ var shadcnComponentDefinitions = {
|
|
|
2791
2831
|
placeholder: import_zod.z.string().nullable(),
|
|
2792
2832
|
rows: import_zod.z.number().nullable(),
|
|
2793
2833
|
value: import_zod.z.string().nullable(),
|
|
2794
|
-
checks:
|
|
2795
|
-
|
|
2796
|
-
type: import_zod.z.string(),
|
|
2797
|
-
message: import_zod.z.string(),
|
|
2798
|
-
args: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
2799
|
-
})
|
|
2800
|
-
).nullable()
|
|
2834
|
+
checks: validationCheckSchema,
|
|
2835
|
+
validateOn: validateOnSchema
|
|
2801
2836
|
}),
|
|
2802
|
-
description: "Multi-line text input. Use { $bindState } on value for binding. Use checks for validation."
|
|
2837
|
+
description: "Multi-line text input. Use { $bindState } on value for binding. Use checks for validation. validateOn controls timing (default: blur)."
|
|
2803
2838
|
},
|
|
2804
2839
|
Select: {
|
|
2805
2840
|
props: import_zod.z.object({
|
|
@@ -2808,44 +2843,45 @@ var shadcnComponentDefinitions = {
|
|
|
2808
2843
|
options: import_zod.z.array(import_zod.z.string()),
|
|
2809
2844
|
placeholder: import_zod.z.string().nullable(),
|
|
2810
2845
|
value: import_zod.z.string().nullable(),
|
|
2811
|
-
checks:
|
|
2812
|
-
|
|
2813
|
-
type: import_zod.z.string(),
|
|
2814
|
-
message: import_zod.z.string(),
|
|
2815
|
-
args: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
2816
|
-
})
|
|
2817
|
-
).nullable()
|
|
2846
|
+
checks: validationCheckSchema,
|
|
2847
|
+
validateOn: validateOnSchema
|
|
2818
2848
|
}),
|
|
2819
2849
|
events: ["change"],
|
|
2820
|
-
description: "Dropdown select input. Use { $bindState } on value for binding. Use checks for validation."
|
|
2850
|
+
description: "Dropdown select input. Use { $bindState } on value for binding. Use checks for validation. validateOn controls timing (default: change)."
|
|
2821
2851
|
},
|
|
2822
2852
|
Checkbox: {
|
|
2823
2853
|
props: import_zod.z.object({
|
|
2824
2854
|
label: import_zod.z.string(),
|
|
2825
2855
|
name: import_zod.z.string(),
|
|
2826
|
-
checked: import_zod.z.boolean().nullable()
|
|
2856
|
+
checked: import_zod.z.boolean().nullable(),
|
|
2857
|
+
checks: validationCheckSchema,
|
|
2858
|
+
validateOn: validateOnSchema
|
|
2827
2859
|
}),
|
|
2828
2860
|
events: ["change"],
|
|
2829
|
-
description: "Checkbox input. Use { $bindState } on checked for binding."
|
|
2861
|
+
description: "Checkbox input. Use { $bindState } on checked for binding. Use checks for validation. validateOn controls timing (default: change)."
|
|
2830
2862
|
},
|
|
2831
2863
|
Radio: {
|
|
2832
2864
|
props: import_zod.z.object({
|
|
2833
2865
|
label: import_zod.z.string(),
|
|
2834
2866
|
name: import_zod.z.string(),
|
|
2835
2867
|
options: import_zod.z.array(import_zod.z.string()),
|
|
2836
|
-
value: import_zod.z.string().nullable()
|
|
2868
|
+
value: import_zod.z.string().nullable(),
|
|
2869
|
+
checks: validationCheckSchema,
|
|
2870
|
+
validateOn: validateOnSchema
|
|
2837
2871
|
}),
|
|
2838
2872
|
events: ["change"],
|
|
2839
|
-
description: "Radio button group. Use { $bindState } on value for binding."
|
|
2873
|
+
description: "Radio button group. Use { $bindState } on value for binding. Use checks for validation. validateOn controls timing (default: change)."
|
|
2840
2874
|
},
|
|
2841
2875
|
Switch: {
|
|
2842
2876
|
props: import_zod.z.object({
|
|
2843
2877
|
label: import_zod.z.string(),
|
|
2844
2878
|
name: import_zod.z.string(),
|
|
2845
|
-
checked: import_zod.z.boolean().nullable()
|
|
2879
|
+
checked: import_zod.z.boolean().nullable(),
|
|
2880
|
+
checks: validationCheckSchema,
|
|
2881
|
+
validateOn: validateOnSchema
|
|
2846
2882
|
}),
|
|
2847
2883
|
events: ["change"],
|
|
2848
|
-
description: "Toggle switch. Use { $bindState } on checked for binding."
|
|
2884
|
+
description: "Toggle switch. Use { $bindState } on checked for binding. Use checks for validation. validateOn controls timing (default: change)."
|
|
2849
2885
|
},
|
|
2850
2886
|
Slider: {
|
|
2851
2887
|
props: import_zod.z.object({
|