shadcn-zod-formkit 1.27.4 → 1.28.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 +2 -0
- package/dist/index.cjs +58 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +59 -16
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.28.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.27.4.tgz +0 -0
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { cva } from 'class-variance-authority';
|
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import * as React3 from 'react';
|
|
7
|
-
import React3__default, {
|
|
7
|
+
import React3__default, { useState, useMemo, useEffect, useRef, useTransition } from 'react';
|
|
8
8
|
import { FormProvider, Controller, useFormContext, useFormState, useFieldArray, useForm } from 'react-hook-form';
|
|
9
9
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
10
10
|
import { Slot } from '@radix-ui/react-slot';
|
|
@@ -2183,6 +2183,28 @@ var ColorInput = class extends BaseInput {
|
|
|
2183
2183
|
return /* @__PURE__ */ jsx(FieldColor, { input, form, isSubmitting });
|
|
2184
2184
|
}
|
|
2185
2185
|
};
|
|
2186
|
+
var PRESET_COLORS = [
|
|
2187
|
+
"#ef4444",
|
|
2188
|
+
// red
|
|
2189
|
+
"#f97316",
|
|
2190
|
+
// orange
|
|
2191
|
+
"#eab308",
|
|
2192
|
+
// yellow
|
|
2193
|
+
"#22c55e",
|
|
2194
|
+
// green
|
|
2195
|
+
"#06b6d4",
|
|
2196
|
+
// cyan
|
|
2197
|
+
"#3b82f6",
|
|
2198
|
+
// blue
|
|
2199
|
+
"#8b5cf6",
|
|
2200
|
+
// purple
|
|
2201
|
+
"#ec4899",
|
|
2202
|
+
// pink
|
|
2203
|
+
"#64748b",
|
|
2204
|
+
// slate
|
|
2205
|
+
"#000000"
|
|
2206
|
+
// black
|
|
2207
|
+
];
|
|
2186
2208
|
var FieldColor = ({ form, input, isSubmitting }) => {
|
|
2187
2209
|
const [ColorCmp, _setColorCmp] = useState(ColorComp);
|
|
2188
2210
|
return /* @__PURE__ */ jsx(
|
|
@@ -2213,13 +2235,17 @@ var FieldColor = ({ form, input, isSubmitting }) => {
|
|
|
2213
2235
|
var ColorComp = React3__default.forwardRef(
|
|
2214
2236
|
({ value = "#000000", onChange, onBlur, disabled, className, hideInput = ["hsv"] }, ref) => {
|
|
2215
2237
|
const [color, setColor] = useColor(value);
|
|
2216
|
-
const [open, setOpen] =
|
|
2238
|
+
const [open, setOpen] = useState(false);
|
|
2217
2239
|
React3__default.useEffect(() => {
|
|
2218
2240
|
if (value !== color.hex) {
|
|
2219
2241
|
setColor({ ...color, hex: value });
|
|
2220
2242
|
}
|
|
2221
|
-
}, [
|
|
2243
|
+
}, [value]);
|
|
2222
2244
|
const handleColorChange = (newColor) => {
|
|
2245
|
+
setColor({ ...color, hex: newColor });
|
|
2246
|
+
onChange?.(newColor);
|
|
2247
|
+
};
|
|
2248
|
+
const handlePickerChange = (newColor) => {
|
|
2223
2249
|
setColor(newColor);
|
|
2224
2250
|
onChange?.(newColor.hex);
|
|
2225
2251
|
};
|
|
@@ -2229,21 +2255,38 @@ var ColorComp = React3__default.forwardRef(
|
|
|
2229
2255
|
onBlur?.();
|
|
2230
2256
|
}
|
|
2231
2257
|
};
|
|
2232
|
-
return /* @__PURE__ */ jsxs(
|
|
2233
|
-
/* @__PURE__ */ jsx(
|
|
2234
|
-
|
|
2258
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2259
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2 p-2", children: PRESET_COLORS.map((presetColor) => /* @__PURE__ */ jsx(
|
|
2260
|
+
"button",
|
|
2235
2261
|
{
|
|
2236
|
-
|
|
2237
|
-
variant: "outline",
|
|
2262
|
+
type: "button",
|
|
2238
2263
|
disabled,
|
|
2239
|
-
className: cn(
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2264
|
+
className: cn(
|
|
2265
|
+
"size-6 rounded-md border-2 transition-all hover:scale-110 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
2266
|
+
color.hex === presetColor ? "border-foreground ring-2 ring-foreground/20" : "border-border hover:border-foreground/50"
|
|
2267
|
+
),
|
|
2268
|
+
style: { backgroundColor: presetColor },
|
|
2269
|
+
onClick: () => handleColorChange(presetColor),
|
|
2270
|
+
"aria-label": `Select color ${presetColor}`
|
|
2271
|
+
},
|
|
2272
|
+
presetColor
|
|
2273
|
+
)) }),
|
|
2274
|
+
/* @__PURE__ */ jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
2275
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
2276
|
+
Button,
|
|
2277
|
+
{
|
|
2278
|
+
ref,
|
|
2279
|
+
variant: "outline",
|
|
2280
|
+
disabled,
|
|
2281
|
+
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
|
|
2282
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2283
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-4 border border-border rounded-sm", style: { backgroundColor: color.hex, width: 20, height: 20 } }),
|
|
2284
|
+
/* @__PURE__ */ jsx("span", { children: color.hex })
|
|
2285
|
+
] })
|
|
2286
|
+
}
|
|
2287
|
+
) }),
|
|
2288
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-3", align: "start", children: /* @__PURE__ */ jsx(ColorPicker, { color, onChange: handlePickerChange, hideInput }) })
|
|
2289
|
+
] })
|
|
2247
2290
|
] });
|
|
2248
2291
|
}
|
|
2249
2292
|
);
|