@purpurds/text-field 3.0.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/LICENSE.txt +66 -0
- package/dist/styles.css +1 -0
- package/dist/text-field.cjs.js +30 -0
- package/dist/text-field.cjs.js.map +1 -0
- package/dist/text-field.d.ts +98 -0
- package/dist/text-field.d.ts.map +1 -0
- package/dist/text-field.es.js +708 -0
- package/dist/text-field.es.js.map +1 -0
- package/dist/text-field.system.js +30 -0
- package/dist/text-field.system.js.map +1 -0
- package/package.json +65 -0
- package/readme.mdx +61 -0
- package/src/global.d.ts +4 -0
- package/src/text-field.module.scss +143 -0
- package/src/text-field.stories.tsx +71 -0
- package/src/text-field.test.tsx +218 -0
- package/src/text-field.tsx +184 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { ComponentPropsWithoutRef, HTMLInputTypeAttribute, ReactNode } from "react";
|
|
2
|
+
export type TextFieldProps = ComponentPropsWithoutRef<"input"> & {
|
|
3
|
+
id: string;
|
|
4
|
+
["data-testid"]?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Use to display e.g. a button after the text field.
|
|
8
|
+
*
|
|
9
|
+
* _NOTE: Should ideally only be used by other purpur components!_
|
|
10
|
+
*/
|
|
11
|
+
afterField?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Use to display e.g. an icon at the end inside of the text field.
|
|
14
|
+
*
|
|
15
|
+
* _NOTE: Should ideally only be used by other purpur components!_
|
|
16
|
+
*/
|
|
17
|
+
endAdornment?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Use to render error message below the text field. The text field renders with error appearance.
|
|
20
|
+
* */
|
|
21
|
+
errorText?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Use to give context about the field's input. Renders below the field.
|
|
24
|
+
* */
|
|
25
|
+
helperText?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The label of the text field.
|
|
28
|
+
* */
|
|
29
|
+
label?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Use to render a spinner at the end inside of the text field.
|
|
32
|
+
*/
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Use to display e.g. an icon at the start inside of the text field.
|
|
36
|
+
*
|
|
37
|
+
* _NOTE: Should ideally only be used by other purpur components!_
|
|
38
|
+
*/
|
|
39
|
+
startAdornment?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Use to set the type of the field.
|
|
42
|
+
*/
|
|
43
|
+
type?: Extract<HTMLInputTypeAttribute, "email" | "number" | "password" | "search" | "tel" | "text">;
|
|
44
|
+
/**
|
|
45
|
+
* Use to render text field with valid appearance. A check
|
|
46
|
+
* icon will render at the start inside of the input.
|
|
47
|
+
*/
|
|
48
|
+
valid?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export declare const TextField: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
|
|
51
|
+
id: string;
|
|
52
|
+
"data-testid"?: string | undefined;
|
|
53
|
+
className?: string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Use to display e.g. a button after the text field.
|
|
56
|
+
*
|
|
57
|
+
* _NOTE: Should ideally only be used by other purpur components!_
|
|
58
|
+
*/
|
|
59
|
+
afterField?: ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Use to display e.g. an icon at the end inside of the text field.
|
|
62
|
+
*
|
|
63
|
+
* _NOTE: Should ideally only be used by other purpur components!_
|
|
64
|
+
*/
|
|
65
|
+
endAdornment?: ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
* Use to render error message below the text field. The text field renders with error appearance.
|
|
68
|
+
* */
|
|
69
|
+
errorText?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Use to give context about the field's input. Renders below the field.
|
|
72
|
+
* */
|
|
73
|
+
helperText?: string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* The label of the text field.
|
|
76
|
+
* */
|
|
77
|
+
label?: string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Use to render a spinner at the end inside of the text field.
|
|
80
|
+
*/
|
|
81
|
+
loading?: boolean | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Use to display e.g. an icon at the start inside of the text field.
|
|
84
|
+
*
|
|
85
|
+
* _NOTE: Should ideally only be used by other purpur components!_
|
|
86
|
+
*/
|
|
87
|
+
startAdornment?: ReactNode;
|
|
88
|
+
/**
|
|
89
|
+
* Use to set the type of the field.
|
|
90
|
+
*/
|
|
91
|
+
type?: "number" | "search" | "text" | "email" | "password" | "tel" | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Use to render text field with valid appearance. A check
|
|
94
|
+
* icon will render at the start inside of the input.
|
|
95
|
+
*/
|
|
96
|
+
valid?: boolean | undefined;
|
|
97
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
98
|
+
//# sourceMappingURL=text-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-field.d.ts","sourceRoot":"","sources":["../src/text-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,wBAAwB,EAGxB,sBAAsB,EACtB,SAAS,EACV,MAAM,OAAO,CAAC;AAUf,MAAM,MAAM,cAAc,GAAG,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;SAEK;IACL,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;SAEK;IACL,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;SAEK;IACL,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CACZ,sBAAsB,EACtB,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAC5D,CAAC;IACF;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAoHF,eAAO,MAAM,SAAS;QArKhB,MAAM;;;IAGV;;;;OAIG;iBACU,SAAS;IACtB;;;;OAIG;mBACY,SAAS;IACxB;;SAEK;;IAEL;;SAEK;;IAEL;;SAEK;;IAEL;;OAEG;;IAEH;;;;OAIG;qBACc,SAAS;IAC1B;;OAEG;;IAKH;;;OAGG;;0CAsHkD,CAAC"}
|