@lindle/linoardo 1.0.31 → 1.0.32

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 CHANGED
@@ -2320,138 +2320,142 @@ var resolveIconClassName4 = (icon) => {
2320
2320
  const classes = [...baseClasses, normalizedName];
2321
2321
  return Array.from(new Set(classes)).join(" ");
2322
2322
  };
2323
- var Input = ({
2324
- variant = "outline",
2325
- size = "medium",
2326
- success,
2327
- error,
2328
- warn,
2329
- icon,
2330
- className,
2331
- wrapperClassName,
2332
- label,
2333
- ...props
2334
- }) => {
2335
- const { placeholder, onFocus, onBlur, ...inputProps } = props;
2336
- const reactId = React4__namespace.default.useId();
2337
- const hasLabel = Boolean(label);
2338
- const hasProvidedPlaceholder = typeof placeholder === "string" && placeholder.trim().length > 0;
2339
- const hidePlaceholderUntilFocus = hasLabel && hasProvidedPlaceholder;
2340
- const [isFocused, setIsFocused] = React4__namespace.default.useState(false);
2341
- const classBase = "input-base focus-visible:outline-none focus-visible:ring-primary transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed w-full text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400";
2342
- const variantClasses5 = {
2343
- solid: "rounded border border-gray-400 bg-white shadow-sm focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-visible:border-primary/70 dark:focus-visible:ring-primary/40",
2344
- sharp: "rounded-none border border-gray-400 bg-white shadow-sm focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-visible:border-primary/70 dark:focus-visible:ring-primary/40",
2345
- outline: "rounded border-2 border-black bg-white focus-visible:border-black focus-visible:ring-2 focus-visible:ring-black/30 dark:border-black dark:bg-transparent dark:focus-visible:border-black dark:focus-visible:ring-black/40",
2346
- text: "rounded-none border-0 border-b border-transparent px-0 bg-transparent focus-visible:border-primary focus-visible:ring-0 focus-visible:ring-transparent dark:border-b-gray-600 dark:focus-visible:border-primary/70",
2347
- ghost: "rounded border border-transparent bg-gray-50 text-gray-900 focus-visible:bg-white focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/15 dark:bg-slate-800 dark:text-gray-100 dark:focus-visible:bg-slate-700 dark:focus-visible:border-primary/60 dark:focus-visible:ring-primary/25",
2348
- filled: "rounded border border-gray-200 bg-gray-100 focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/25 dark:border-gray-700 dark:bg-slate-800 dark:focus-visible:border-primary/60 dark:focus-visible:ring-primary/30",
2349
- underlined: "rounded-none border-0 border-b border-gray-300 px-0 bg-transparent focus-visible:border-primary focus-visible:ring-0 focus-visible:ring-transparent dark:border-b-gray-600 dark:focus-visible:border-primary/70",
2350
- rounded: "rounded-full px-4 border border-gray-300 bg-white focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/20 shadow-sm dark:border-gray-600 dark:bg-slate-900 dark:focus-visible:border-primary/70 dark:focus-visible:ring-primary/30 dark:shadow-black/20"
2351
- };
2352
- const sizeClasses4 = {
2353
- "x-small": { paddingNoIcon: "px-2 py-2", paddingWithIcon: "pl-8 pr-2 py-2", text: "text-xs" },
2354
- small: {
2355
- paddingNoIcon: "px-2.5 py-2.5",
2356
- paddingWithIcon: "pl-9 pr-2.5 py-2.5",
2357
- text: "text-sm"
2358
- },
2359
- medium: { paddingNoIcon: "px-3 py-3", paddingWithIcon: "pl-10 pr-3 py-3", text: "text-base" },
2360
- large: {
2361
- paddingNoIcon: "px-3.5 py-3.5",
2362
- paddingWithIcon: "pl-11 pr-3.5 py-3.5",
2363
- text: "text-lg"
2364
- },
2365
- "x-large": { paddingNoIcon: "px-4 py-4", paddingWithIcon: "pl-12 pr-4 py-4", text: "text-xl" }
2366
- };
2367
- const status = error ? { tone: "error", message: error } : warn ? { tone: "warn", message: warn } : success ? { tone: "success", message: success } : void 0;
2368
- const statusClasses = {
2369
- error: "border-red-500 focus:border-red-500 focus:ring-red-400",
2370
- warn: "border-amber-500 focus:border-amber-500 focus:ring-amber-400",
2371
- success: "border-emerald-500 focus:border-emerald-500 focus:ring-emerald-400"
2372
- };
2373
- const statusMessageClasses = {
2374
- error: "text-red-600 dark:text-red-300",
2375
- warn: "text-amber-600 dark:text-amber-300",
2376
- success: "text-emerald-600 dark:text-emerald-300"
2377
- };
2378
- const variantClass = variantClasses5[variant] ?? variantClasses5.outline;
2379
- const toneClass = status ? statusClasses[status.tone] : void 0;
2380
- let prependIconClass = resolveIconClassName4(icon);
2381
- const sizeConfig = sizeClasses4[size] ?? sizeClasses4.medium;
2382
- const sizeClass = [
2383
- prependIconClass ? sizeConfig.paddingWithIcon : sizeConfig.paddingNoIcon,
2384
- sizeConfig.text
2385
- ].join(" ");
2386
- const inputName = inputProps.name || reactId;
2387
- const basePlaceholder = placeholder ?? (hasLabel ? " " : void 0);
2388
- const placeholderValue = hidePlaceholderUntilFocus ? isFocused ? placeholder : " " : basePlaceholder;
2389
- const placeholderClass = hidePlaceholderUntilFocus ? "placeholder-transparent focus:placeholder-gray-500 focus:dark:placeholder-gray-400" : void 0;
2390
- const labelLeftClass = prependIconClass ? "left-10" : "left-3";
2391
- const labelBgDefault = ["outline", "text", "underlined"].includes(variant) ? "bg-transparent" : "bg-white/90 dark:bg-slate-900";
2392
- const handleFocus = (event) => {
2393
- if (hidePlaceholderUntilFocus) setIsFocused(true);
2394
- onFocus?.(event);
2395
- };
2396
- const handleBlur = (event) => {
2397
- if (hidePlaceholderUntilFocus) setIsFocused(false);
2398
- onBlur?.(event);
2399
- };
2400
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex flex-col gap-1", wrapperClassName), children: [
2401
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex items-center", children: [
2402
- prependIconClass && /* @__PURE__ */ jsxRuntime.jsx(
2403
- "i",
2404
- {
2405
- className: tailwindMerge.twMerge(
2406
- "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-400",
2407
- status?.tone && statusMessageClasses[status?.tone] || "",
2408
- prependIconClass
2409
- ),
2410
- "aria-hidden": true
2411
- }
2412
- ),
2413
- /* @__PURE__ */ jsxRuntime.jsx(
2414
- "input",
2415
- {
2416
- ...inputProps,
2417
- id: inputName,
2418
- name: inputName,
2419
- placeholder: placeholderValue,
2420
- onFocus: handleFocus,
2421
- onBlur: handleBlur,
2422
- className: tailwindMerge.twMerge(
2423
- "peer",
2424
- classBase,
2425
- variantClass,
2426
- toneClass,
2427
- sizeClass,
2428
- placeholderClass,
2429
- className
2430
- )
2431
- }
2432
- ),
2433
- label && /* @__PURE__ */ jsxRuntime.jsx(
2434
- "label",
2435
- {
2436
- htmlFor: inputName,
2437
- className: tailwindMerge.twMerge(
2438
- "absolute transition-all duration-150 pointer-events-none text-gray-700 rounded dark:text-gray-200",
2439
- labelLeftClass,
2440
- // Floated state: center label's vertical middle on the top border line
2441
- "-top-1.5 left-1 peer-focus:left-7 -translate-y-2/3 text-xs px-1",
2442
- labelBgDefault,
2443
- // focus state mirrors floated state (keeps center on border)
2444
- "peer-focus:top-0 peer-focus:-translate-y-1/2 peer-focus:text-xs peer-focus:px-1 peer-focus:bg-white peer-focus:text-gray-600 dark:peer-focus:bg-slate-900 dark:peer-focus:text-gray-300",
2445
- // when input is empty (placeholder shown) -> center label inside input
2446
- "peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:text-sm peer-placeholder-shown:bg-transparent peer-placeholder-shown:text-gray-500 dark:peer-placeholder-shown:text-gray-400"
2447
- ),
2448
- children: label
2449
- }
2450
- )
2451
- ] }),
2452
- status?.message && /* @__PURE__ */ jsxRuntime.jsx("span", { className: tailwindMerge.twMerge("text-sm", statusMessageClasses[status.tone]), children: status.message })
2453
- ] });
2454
- };
2323
+ var Input = React4__namespace.default.forwardRef(
2324
+ ({
2325
+ variant = "outline",
2326
+ size = "medium",
2327
+ success,
2328
+ error,
2329
+ warn,
2330
+ icon,
2331
+ className,
2332
+ wrapperClassName,
2333
+ label,
2334
+ ...props
2335
+ }, ref) => {
2336
+ const { placeholder, onFocus, onBlur, ...inputProps } = props;
2337
+ const reactId = React4__namespace.default.useId();
2338
+ const hasLabel = Boolean(label);
2339
+ const hasProvidedPlaceholder = typeof placeholder === "string" && placeholder.trim().length > 0;
2340
+ const hidePlaceholderUntilFocus = hasLabel && hasProvidedPlaceholder;
2341
+ const [isFocused, setIsFocused] = React4__namespace.default.useState(false);
2342
+ const classBase = "input-base focus-visible:outline-none focus-visible:ring-primary transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed w-full text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400";
2343
+ const variantClasses5 = {
2344
+ solid: "rounded border border-gray-400 bg-white shadow-sm focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-visible:border-primary/70 dark:focus-visible:ring-primary/40",
2345
+ sharp: "rounded-none border border-gray-400 bg-white shadow-sm focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-visible:border-primary/70 dark:focus-visible:ring-primary/40",
2346
+ outline: "rounded border-2 border-black bg-white focus-visible:border-black focus-visible:ring-2 focus-visible:ring-black/30 dark:border-black dark:bg-transparent dark:focus-visible:border-black dark:focus-visible:ring-black/40",
2347
+ text: "rounded-none border-0 border-b border-transparent px-0 bg-transparent focus-visible:border-primary focus-visible:ring-0 focus-visible:ring-transparent dark:border-b-gray-600 dark:focus-visible:border-primary/70",
2348
+ ghost: "rounded border border-transparent bg-gray-50 text-gray-900 focus-visible:bg-white focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/15 dark:bg-slate-800 dark:text-gray-100 dark:focus-visible:bg-slate-700 dark:focus-visible:border-primary/60 dark:focus-visible:ring-primary/25",
2349
+ filled: "rounded border border-gray-200 bg-gray-100 focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/25 dark:border-gray-700 dark:bg-slate-800 dark:focus-visible:border-primary/60 dark:focus-visible:ring-primary/30",
2350
+ underlined: "rounded-none border-0 border-b border-gray-300 px-0 bg-transparent focus-visible:border-primary focus-visible:ring-0 focus-visible:ring-transparent dark:border-b-gray-600 dark:focus-visible:border-primary/70",
2351
+ rounded: "rounded-full px-4 border border-gray-300 bg-white focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/20 shadow-sm dark:border-gray-600 dark:bg-slate-900 dark:focus-visible:border-primary/70 dark:focus-visible:ring-primary/30 dark:shadow-black/20"
2352
+ };
2353
+ const sizeClasses4 = {
2354
+ "x-small": { paddingNoIcon: "px-2 py-2", paddingWithIcon: "pl-8 pr-2 py-2", text: "text-xs" },
2355
+ small: {
2356
+ paddingNoIcon: "px-2.5 py-2.5",
2357
+ paddingWithIcon: "pl-9 pr-2.5 py-2.5",
2358
+ text: "text-sm"
2359
+ },
2360
+ medium: { paddingNoIcon: "px-3 py-3", paddingWithIcon: "pl-10 pr-3 py-3", text: "text-base" },
2361
+ large: {
2362
+ paddingNoIcon: "px-3.5 py-3.5",
2363
+ paddingWithIcon: "pl-11 pr-3.5 py-3.5",
2364
+ text: "text-lg"
2365
+ },
2366
+ "x-large": { paddingNoIcon: "px-4 py-4", paddingWithIcon: "pl-12 pr-4 py-4", text: "text-xl" }
2367
+ };
2368
+ const status = error ? { tone: "error", message: error } : warn ? { tone: "warn", message: warn } : success ? { tone: "success", message: success } : void 0;
2369
+ const statusClasses = {
2370
+ error: "border-red-500 focus:border-red-500 focus:ring-red-400",
2371
+ warn: "border-amber-500 focus:border-amber-500 focus:ring-amber-400",
2372
+ success: "border-emerald-500 focus:border-emerald-500 focus:ring-emerald-400"
2373
+ };
2374
+ const statusMessageClasses = {
2375
+ error: "text-red-600 dark:text-red-300",
2376
+ warn: "text-amber-600 dark:text-amber-300",
2377
+ success: "text-emerald-600 dark:text-emerald-300"
2378
+ };
2379
+ const variantClass = variantClasses5[variant] ?? variantClasses5.outline;
2380
+ const toneClass = status ? statusClasses[status.tone] : void 0;
2381
+ let prependIconClass = resolveIconClassName4(icon);
2382
+ const sizeConfig = sizeClasses4[size] ?? sizeClasses4.medium;
2383
+ const sizeClass = [
2384
+ prependIconClass ? sizeConfig.paddingWithIcon : sizeConfig.paddingNoIcon,
2385
+ sizeConfig.text
2386
+ ].join(" ");
2387
+ const inputName = inputProps.name || reactId;
2388
+ const basePlaceholder = placeholder ?? (hasLabel ? " " : void 0);
2389
+ const placeholderValue = hidePlaceholderUntilFocus ? isFocused ? placeholder : " " : basePlaceholder;
2390
+ const placeholderClass = hidePlaceholderUntilFocus ? "placeholder-transparent focus:placeholder-gray-500 focus:dark:placeholder-gray-400" : void 0;
2391
+ const labelLeftClass = prependIconClass ? "left-10" : "left-3";
2392
+ const labelBgDefault = ["outline", "text", "underlined"].includes(variant) ? "bg-transparent" : "bg-white/90 dark:bg-slate-900";
2393
+ const handleFocus = (event) => {
2394
+ if (hidePlaceholderUntilFocus) setIsFocused(true);
2395
+ onFocus?.(event);
2396
+ };
2397
+ const handleBlur = (event) => {
2398
+ if (hidePlaceholderUntilFocus) setIsFocused(false);
2399
+ onBlur?.(event);
2400
+ };
2401
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex flex-col gap-1", wrapperClassName), children: [
2402
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex items-center", children: [
2403
+ prependIconClass && /* @__PURE__ */ jsxRuntime.jsx(
2404
+ "i",
2405
+ {
2406
+ className: tailwindMerge.twMerge(
2407
+ "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-400",
2408
+ status?.tone && statusMessageClasses[status?.tone] || "",
2409
+ prependIconClass
2410
+ ),
2411
+ "aria-hidden": true
2412
+ }
2413
+ ),
2414
+ /* @__PURE__ */ jsxRuntime.jsx(
2415
+ "input",
2416
+ {
2417
+ ...inputProps,
2418
+ ref,
2419
+ id: inputName,
2420
+ name: inputName,
2421
+ placeholder: placeholderValue,
2422
+ onFocus: handleFocus,
2423
+ onBlur: handleBlur,
2424
+ className: tailwindMerge.twMerge(
2425
+ "peer",
2426
+ classBase,
2427
+ variantClass,
2428
+ toneClass,
2429
+ sizeClass,
2430
+ placeholderClass,
2431
+ className
2432
+ )
2433
+ }
2434
+ ),
2435
+ label && /* @__PURE__ */ jsxRuntime.jsx(
2436
+ "label",
2437
+ {
2438
+ htmlFor: inputName,
2439
+ className: tailwindMerge.twMerge(
2440
+ "absolute transition-all duration-150 pointer-events-none text-gray-700 rounded dark:text-gray-200",
2441
+ labelLeftClass,
2442
+ // Floated state: center label's vertical middle on the top border line
2443
+ "-top-1.5 left-1 peer-focus:left-7 -translate-y-2/3 text-xs px-1",
2444
+ labelBgDefault,
2445
+ // focus state mirrors floated state (keeps center on border)
2446
+ "peer-focus:top-0 peer-focus:-translate-y-1/2 peer-focus:text-xs peer-focus:px-1 peer-focus:bg-white peer-focus:text-gray-600 dark:peer-focus:bg-slate-900 dark:peer-focus:text-gray-300",
2447
+ // when input is empty (placeholder shown) -> center label inside input
2448
+ "peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:text-sm peer-placeholder-shown:bg-transparent peer-placeholder-shown:text-gray-500 dark:peer-placeholder-shown:text-gray-400"
2449
+ ),
2450
+ children: label
2451
+ }
2452
+ )
2453
+ ] }),
2454
+ status?.message && /* @__PURE__ */ jsxRuntime.jsx("span", { className: tailwindMerge.twMerge("text-sm", statusMessageClasses[status.tone]), children: status.message })
2455
+ ] });
2456
+ }
2457
+ );
2458
+ Input.displayName = "Input";
2455
2459
  var Input_default = Input;
2456
2460
 
2457
2461
  // src/utils/helpers/randomStr.ts