@versini/ui-textinput 6.1.1 → 6.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/index.d.ts CHANGED
@@ -1,32 +1,72 @@
1
+ import { JSX } from 'react/jsx-runtime';
1
2
  import { default as React_2 } from 'react';
2
3
 
3
- declare type Size = "xs" | "sm" | "md" | "lg" | "xl";
4
-
5
- export declare const TEXT_INPUT_CLASSNAME = "av-text-input";
6
-
7
- export declare const TEXT_INPUT_HELPER_TEXT_CLASSNAME = "av-text-input-helper-text";
8
-
9
- export declare const TEXT_INPUT_SIMPLE_CLASSNAME = "av-text-input-simple";
10
-
11
- export declare const TEXT_INPUT_WRAPPER_CLASSNAME = "av-text-input-wrapper";
12
-
13
- export declare const TextInput: React_2.ForwardRefExoticComponent<{
14
- rightElement?: React_2.ReactElement;
15
- rightElementClassName?: string;
16
- } & {
4
+ declare type CommonTextInputProps = {
5
+ /**
6
+ * The label of the TextInput.
7
+ */
17
8
  label: string;
9
+ /**
10
+ * The name of the TextInput.
11
+ */
18
12
  name: string;
13
+ /**
14
+ * Whether or not the TextInput is in error state.
15
+ * @default false
16
+ */
19
17
  error?: boolean;
18
+ /**
19
+ * The type of focus for the TextInput. This will change the color
20
+ * of the focus ring around the TextInput.
21
+ */
20
22
  focusMode?: "dark" | "light" | "system" | "alt-system";
23
+ /**
24
+ * Text to add to the bottom of the TextInput.
25
+ */
21
26
  helperText?: string;
27
+ /**
28
+ * CSS class(es) to add to the actual textarea element.
29
+ */
22
30
  inputClassName?: string;
31
+ /**
32
+ * Hides the label visually but retain accessible relationship with the TextInput.
33
+ */
23
34
  labelHidden?: boolean;
35
+ /**
36
+ * Id to use for the TextInput label.
37
+ */
24
38
  labelId?: string;
39
+ /**
40
+ * The mode of TextInput. This will change the color of the TextInput.
41
+ */
25
42
  mode?: "dark" | "light" | "system" | "alt-system";
43
+ /**
44
+ * Whether or not the TextInput has a border.
45
+ * @default false
46
+ */
26
47
  noBorder?: boolean;
48
+ /**
49
+ * Whether or not to render the TextInput with styles or not.
50
+ * @default false
51
+ */
27
52
  raw?: boolean;
53
+ /**
54
+ * Controls input height and horizontal padding, 'md' by default
55
+ */
28
56
  size?: Size;
29
- } & Omit<React_2.InputHTMLAttributes<HTMLInputElement>, "size"> & React_2.RefAttributes<HTMLInputElement>>;
57
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">;
58
+
59
+ declare type Size = "xs" | "sm" | "md" | "lg" | "xl";
60
+
61
+ export declare const TEXT_INPUT_CLASSNAME = "av-text-input";
62
+
63
+ export declare const TEXT_INPUT_HELPER_TEXT_CLASSNAME = "av-text-input-helper-text";
64
+
65
+ export declare const TEXT_INPUT_SIMPLE_CLASSNAME = "av-text-input-simple";
66
+
67
+ export declare const TEXT_INPUT_WRAPPER_CLASSNAME = "av-text-input-wrapper";
68
+
69
+ export declare function TextInput({ id, name, label, error, raw, className, inputClassName, mode, focusMode, disabled, noBorder, labelId, labelHidden, type, helperText, rightElement, rightElementClassName, size, ref, ...extraProps }: TextInputProps): JSX.Element;
30
70
 
31
71
  export declare const TextInputMask: React_2.ForwardRefExoticComponent<{
32
72
  rightElement: React_2.ReactElement;
@@ -47,4 +87,21 @@ export declare const TextInputMask: React_2.ForwardRefExoticComponent<{
47
87
  size?: Size;
48
88
  } & Omit<React_2.InputHTMLAttributes<HTMLInputElement>, "size"> & React_2.RefAttributes<HTMLInputElement>>;
49
89
 
90
+ declare type TextInputProps = {
91
+ /**
92
+ * A ref to the input element.
93
+ */
94
+ ref?: React.Ref<HTMLInputElement>;
95
+ /**
96
+ * This prop allows you to pass in a React element to render on the right
97
+ * side of the TextInput. This is useful for adding icons or actionable
98
+ * elements, such a Button.
99
+ */
100
+ rightElement?: React.ReactElement;
101
+ /**
102
+ * Extra classes to add to the right element container.
103
+ */
104
+ rightElementClassName?: string;
105
+ } & CommonTextInputProps;
106
+
50
107
  export { }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- @versini/ui-textinput v6.1.1
2
+ @versini/ui-textinput v6.2.0
3
3
  © 2025 gizmette.com
4
4
  */
5
5
 
@@ -166,7 +166,7 @@ const getTextInputClasses = ({ className, inputClassName, raw, disabled, noBorde
166
166
 
167
167
 
168
168
 
169
- const TextInput = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = false, raw = false, className, inputClassName, mode = "system", focusMode = "system", disabled = false, noBorder = false, labelId, labelHidden = false, type = "text", helperText = "", rightElement, rightElementClassName, size = "md", ...extraProps }, ref)=>{
169
+ function TextInput({ id, name, label, error = false, raw = false, className, inputClassName, mode = "system", focusMode = "system", disabled = false, noBorder = false, labelId, labelHidden = false, type = "text", helperText = "", rightElement, rightElementClassName, size = "md", ref, ...extraProps }) {
170
170
  const [rightElementRef, rect] = useResizeObserver();
171
171
  const [inputPaddingRight, setInputPaddingRight] = useState(0);
172
172
  const inputId = useUniqueId({
@@ -213,20 +213,20 @@ const TextInput = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fal
213
213
  /* c8 ignore start - ResizeObserver is tough to test... */ useLayoutEffect(()=>{
214
214
  if (rect && rect.width) {
215
215
  /**
216
- * - rect.width is the width of the right element (Button, Icon, etc.)
217
- * - The main input field has default left/right paddings of
218
- * 16px (px-4) + 2px border (border-2) = 18px
219
- * - We add 10px to the right padding to give some space between the right
220
- * element and the input field.
221
- */ setInputPaddingRight(rect.width + 18 + 10);
216
+ * - rect.width is the width of the right element (Button, Icon, etc.)
217
+ * - The main input field has default left/right paddings of
218
+ * 16px (px-4) + 2px border (border-2) = 18px
219
+ * - We add 10px to the right padding to give some space between the right
220
+ * element and the input field.
221
+ */ setInputPaddingRight(rect.width + 18 + 10);
222
222
  }
223
223
  }, [
224
224
  rect
225
225
  ]);
226
226
  /* c8 ignore end */ /**
227
- * This effect sets the label and helper text position based on
228
- * the size of the input.
229
- */ useLayoutEffect(()=>{
227
+ * This effect sets the label and helper text position based on
228
+ * the size of the input.
229
+ */ useLayoutEffect(()=>{
230
230
  const { label, helperText } = sizeStyles[size];
231
231
  labelRef?.current?.style.setProperty("--av-text-input-label", label);
232
232
  helperTextRef?.current?.style.setProperty("--av-text-input-helper-text", helperText);
@@ -288,8 +288,7 @@ const TextInput = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fal
288
288
  })
289
289
  ]
290
290
  });
291
- });
292
- TextInput.displayName = "TextInput";
291
+ }
293
292
 
294
293
  ;// CONCATENATED MODULE: external "@versini/ui-hooks/use-merge-refs"
295
294
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-textinput",
3
- "version": "6.1.1",
3
+ "version": "6.2.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -50,5 +50,5 @@
50
50
  "sideEffects": [
51
51
  "**/*.css"
52
52
  ],
53
- "gitHead": "a3730974df8fcea3c016bd83844c4243dbb10208"
53
+ "gitHead": "217f53cc7772e8cbe38e72582cbd65adb133fcd9"
54
54
  }