@fabio.caffarello/react-design-system 4.1.0 → 4.2.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/granular/ui/primitives/Input/Input.js +121 -317
- package/dist/granular/ui/primitives/Input/Input.js.map +1 -1
- package/dist/granular/ui/primitives/Input/InputBase.js +223 -0
- package/dist/granular/ui/primitives/Input/InputBase.js.map +1 -0
- package/dist/index.cjs +64 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2174 -2176
- package/dist/index.js.map +1 -1
- package/dist/react-design-system.css +1 -1
- package/dist/server/index.cjs +13 -13
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +754 -562
- package/dist/server/index.js.map +1 -1
- package/dist/ui/primitives/Input/Input.d.ts +13 -15
- package/dist/ui/primitives/Input/InputBase.d.ts +52 -0
- package/dist/ui/primitives/Input/index.d.ts +2 -0
- package/dist/ui/server.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type InputSize
|
|
3
|
-
export
|
|
4
|
-
export type InputState = "default" | "error" | "success";
|
|
5
|
-
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
6
|
-
label?: ReactNode;
|
|
7
|
-
error?: boolean;
|
|
8
|
-
success?: boolean;
|
|
9
|
-
helperText?: string;
|
|
10
|
-
size?: InputSize;
|
|
11
|
-
variant?: InputVariant;
|
|
12
|
-
leftIcon?: ReactNode;
|
|
13
|
-
rightIcon?: ReactNode;
|
|
1
|
+
import type { InputBaseProps } from "./InputBase";
|
|
2
|
+
export type { InputSize, InputVariant, InputState } from "./InputBase";
|
|
3
|
+
export interface InputProps extends Omit<InputBaseProps, "rightSlot"> {
|
|
14
4
|
showClearButton?: boolean;
|
|
15
5
|
onClear?: () => void;
|
|
16
6
|
}
|
|
17
7
|
/**
|
|
18
8
|
* Input Component
|
|
19
9
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
10
|
+
* The interactive text input: everything `InputBase` renders, plus the
|
|
11
|
+
* client-only affordances that require React state — the password
|
|
12
|
+
* visibility toggle (`type="password"`), the clear button
|
|
13
|
+
* (`showClearButton`), and the `useId` auto-id fallback. It **composes**
|
|
14
|
+
* `InputBase` (issue #224): the presentational shell lives once in
|
|
15
|
+
* `InputBase`, and `Input` layers the stateful affixes on top, passing
|
|
16
|
+
* the resolved `id`, the toggled `type`, and its buttons via `rightSlot`.
|
|
17
|
+
*
|
|
18
|
+
* Need a server-renderable / native-form input with no client state?
|
|
19
|
+
* Import `InputBase` from `@fabio.caffarello/react-design-system/server`.
|
|
22
20
|
*
|
|
23
21
|
* @example
|
|
24
22
|
* ```tsx
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type InputSize = "sm" | "md" | "lg";
|
|
3
|
+
export type InputVariant = "default" | "outlined" | "filled";
|
|
4
|
+
export type InputState = "default" | "error" | "success";
|
|
5
|
+
export interface InputBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
success?: boolean;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
size?: InputSize;
|
|
11
|
+
variant?: InputVariant;
|
|
12
|
+
leftIcon?: ReactNode;
|
|
13
|
+
rightIcon?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Raw trailing-affix slot rendered inside the input's right edge with
|
|
16
|
+
* full interactivity (no `pointer-events-none`). The interactive
|
|
17
|
+
* `Input` injects its password-toggle / clear buttons here; consumers
|
|
18
|
+
* can use it for a static suffix (a unit, a badge). When omitted,
|
|
19
|
+
* `rightIcon` renders instead with the muted decorative treatment.
|
|
20
|
+
*/
|
|
21
|
+
rightSlot?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* InputBase
|
|
25
|
+
*
|
|
26
|
+
* The **presentational core** of the text input — label, the `<input>`
|
|
27
|
+
* itself, decorative left/right icons, the trailing-affix slot, and the
|
|
28
|
+
* helper/error line. It holds **no React client state** (no `useState`,
|
|
29
|
+
* `useId`, `useCallback`), so it is server-safe and ships from the
|
|
30
|
+
* `./server` entry (issue #224).
|
|
31
|
+
*
|
|
32
|
+
* The interactive `Input` (default export of this folder) composes
|
|
33
|
+
* `InputBase`, owning the password-toggle state, the clear button, and
|
|
34
|
+
* the `useId` auto-id fallback — it passes the resolved `id`, the
|
|
35
|
+
* toggled `type`, and its affix buttons (`rightSlot`) down. Use
|
|
36
|
+
* `InputBase` directly for server-rendered / native-form inputs where
|
|
37
|
+
* none of that interactivity is needed (`<form method="GET">` filters,
|
|
38
|
+
* RSC pages).
|
|
39
|
+
*
|
|
40
|
+
* Accessible name: pass `id` when you pass `label` so the `<label
|
|
41
|
+
* htmlFor>` binds — `InputBase` does NOT auto-generate an id (that needs
|
|
42
|
+
* `useId`, which would make it client). A dev-only warning fires when a
|
|
43
|
+
* `label` is given without an `id`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* // Server component / native form — zero client state.
|
|
48
|
+
* <InputBase id="q" name="q" placeholder="Buscar…" />
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare const InputBase: import("react").ForwardRefExoticComponent<InputBaseProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
52
|
+
export default InputBase;
|
package/dist/ui/server.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { default as ErrorMessage } from "./primitives/ErrorMessage/ErrorMessage"
|
|
|
8
8
|
export type { ErrorMessageProps } from "./primitives/ErrorMessage/ErrorMessage";
|
|
9
9
|
export { default as Info } from "./primitives/Info/Info";
|
|
10
10
|
export type { InfoProps } from "./primitives/Info/Info";
|
|
11
|
+
export { default as InputBase } from "./primitives/Input/InputBase";
|
|
12
|
+
export type { InputBaseProps, InputSize, InputVariant, InputState, } from "./primitives/Input/InputBase";
|
|
11
13
|
export { default as Label } from "./primitives/Label/Label";
|
|
12
14
|
export { default as Progress } from "./primitives/Progress/Progress";
|
|
13
15
|
export type { ProgressProps, ProgressSize, ProgressVariant, } from "./primitives/Progress/Progress";
|