@particle-academy/react-fancy 4.19.1 → 5.1.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/dist/index.cjs +42 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +42 -3
- package/dist/index.js.map +1 -1
- package/package.json +94 -91
package/dist/index.cjs
CHANGED
|
@@ -3179,12 +3179,21 @@ var Input = react.forwardRef(
|
|
|
3179
3179
|
mode,
|
|
3180
3180
|
onValueChange,
|
|
3181
3181
|
onChange,
|
|
3182
|
+
reveal,
|
|
3183
|
+
revealed,
|
|
3184
|
+
onRevealedChange,
|
|
3185
|
+
revealLabel = "Show password",
|
|
3186
|
+
hideLabel = "Hide password",
|
|
3182
3187
|
...props
|
|
3183
3188
|
}, ref) => {
|
|
3184
3189
|
const autoId = react.useId();
|
|
3185
3190
|
const inputId = id ?? autoId;
|
|
3186
3191
|
const resolvedMode = useFieldMode(mode);
|
|
3187
3192
|
const { showControl, interactive, enterEdit, exitEdit } = useInlineEdit(resolvedMode, disabled);
|
|
3193
|
+
const canReveal = reveal === true && type === "password";
|
|
3194
|
+
const [isRevealed, setRevealed] = useControllableState(revealed, false, onRevealedChange);
|
|
3195
|
+
const shown = canReveal && isRevealed;
|
|
3196
|
+
const renderedType = shown ? "text" : type;
|
|
3188
3197
|
const input = !showControl ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3189
3198
|
DisplayValue,
|
|
3190
3199
|
{
|
|
@@ -3210,7 +3219,7 @@ var Input = react.forwardRef(
|
|
|
3210
3219
|
{
|
|
3211
3220
|
ref,
|
|
3212
3221
|
id: inputId,
|
|
3213
|
-
type,
|
|
3222
|
+
type: renderedType,
|
|
3214
3223
|
disabled,
|
|
3215
3224
|
required,
|
|
3216
3225
|
className: cn(
|
|
@@ -3220,7 +3229,7 @@ var Input = react.forwardRef(
|
|
|
3220
3229
|
errorClasses(error),
|
|
3221
3230
|
"w-full",
|
|
3222
3231
|
leading && "pl-9",
|
|
3223
|
-
trailing && "pr-9",
|
|
3232
|
+
(trailing || canReveal) && "pr-9",
|
|
3224
3233
|
className
|
|
3225
3234
|
),
|
|
3226
3235
|
onChange: (e) => {
|
|
@@ -3235,7 +3244,23 @@ var Input = react.forwardRef(
|
|
|
3235
3244
|
}
|
|
3236
3245
|
}
|
|
3237
3246
|
),
|
|
3238
|
-
|
|
3247
|
+
canReveal ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3248
|
+
"button",
|
|
3249
|
+
{
|
|
3250
|
+
type: "button",
|
|
3251
|
+
id: `${inputId}-reveal`,
|
|
3252
|
+
"data-react-fancy-reveal": "",
|
|
3253
|
+
onClick: () => setRevealed((v) => !v),
|
|
3254
|
+
disabled,
|
|
3255
|
+
"aria-controls": inputId,
|
|
3256
|
+
"aria-pressed": shown,
|
|
3257
|
+
"aria-label": shown ? hideLabel : revealLabel,
|
|
3258
|
+
title: shown ? hideLabel : revealLabel,
|
|
3259
|
+
tabIndex: -1,
|
|
3260
|
+
className: "absolute right-2 inline-flex items-center justify-center rounded p-1 text-zinc-400 transition-colors hover:text-zinc-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/40 disabled:cursor-not-allowed disabled:opacity-50 dark:text-zinc-500 dark:hover:text-zinc-300",
|
|
3261
|
+
children: shown ? /* @__PURE__ */ jsxRuntime.jsx(EyeOffIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(EyeIcon, {})
|
|
3262
|
+
}
|
|
3263
|
+
) : trailing && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute right-3 text-zinc-400 dark:text-zinc-500", children: trailing })
|
|
3239
3264
|
] })
|
|
3240
3265
|
}
|
|
3241
3266
|
);
|
|
@@ -3257,6 +3282,20 @@ var Input = react.forwardRef(
|
|
|
3257
3282
|
}
|
|
3258
3283
|
);
|
|
3259
3284
|
Input.displayName = "Input";
|
|
3285
|
+
function EyeIcon() {
|
|
3286
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
3287
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }),
|
|
3288
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
3289
|
+
] });
|
|
3290
|
+
}
|
|
3291
|
+
function EyeOffIcon() {
|
|
3292
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
3293
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" }),
|
|
3294
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242" }),
|
|
3295
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" }),
|
|
3296
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m2 2 20 20" })
|
|
3297
|
+
] });
|
|
3298
|
+
}
|
|
3260
3299
|
var Textarea = react.forwardRef(
|
|
3261
3300
|
({
|
|
3262
3301
|
size = "md",
|