@dax-ui/text-field 0.0.0-stage → 0.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/CHANGELOG.md +8 -0
- package/LICENSE +12 -0
- package/README.md +67 -2
- package/lib/index.d.ts +63 -0
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -0
- package/package.json +55 -3
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2026 Digital Auxilius. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its source code are proprietary. They are made publicly available
|
|
4
|
+
for viewing and installation only. No license is granted to use, copy, modify, merge,
|
|
5
|
+
publish, distribute, sublicense or sell copies of this software, in whole or in part,
|
|
6
|
+
except under a separate written agreement with Digital Auxilius.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
9
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
10
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
11
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR
|
|
12
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dax-ui/text-field
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Single- or multi-line text input with a label, helper text and error state.
|
|
4
|
+
Wraps MUI's TextField, fixed to the outlined style, small and full width by default.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm add @dax-ui/text-field
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
MUI and Emotion are included; the app only needs React 18 or 19.
|
|
13
|
+
|
|
14
|
+
One-time setup per app (skip if the app already uses dax-ui): install
|
|
15
|
+
[`@dax-ui/theme`](https://www.npmjs.com/package/@dax-ui/theme) and wrap the app in its `UIProvider`.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @dax-ui/theme
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { TextField } from '@dax-ui/text-field';
|
|
25
|
+
|
|
26
|
+
// Controlled
|
|
27
|
+
const [email, setEmail] = useState('');
|
|
28
|
+
<TextField label="Email" type="email" value={email} onChange={(e) => setEmail(e.target.value)} />
|
|
29
|
+
|
|
30
|
+
// Validation message
|
|
31
|
+
<TextField label="Email" error={!isValid} helperText={isValid ? ' ' : 'Enter a valid email address'} />
|
|
32
|
+
|
|
33
|
+
// Required
|
|
34
|
+
<TextField label="Company name" required />
|
|
35
|
+
|
|
36
|
+
// Multi-line
|
|
37
|
+
<TextField label="Notes" multiline minRows={3} maxRows={8} />
|
|
38
|
+
|
|
39
|
+
// Uncontrolled, inside a form
|
|
40
|
+
<form onSubmit={handleSubmit}>
|
|
41
|
+
<TextField label="Name" name="name" defaultValue="Ada" />
|
|
42
|
+
</form>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Props
|
|
46
|
+
|
|
47
|
+
<!-- props:start TextField -->
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
| --- | --- | --- | --- |
|
|
50
|
+
| `defaultValue` | `unknown` | | Initial value, for an uncontrolled field. |
|
|
51
|
+
| `disabled` | `boolean` | `false` | Disables the field. |
|
|
52
|
+
| `error` | `boolean` | `false` | Shows the field in its error state and marks the input `aria-invalid`. Pair it with `helperText` explaining what is wrong. |
|
|
53
|
+
| `fullWidth` | `boolean` | `true` | Stretches the field to the full width of its container. |
|
|
54
|
+
| `helperText` | `ReactNode` | | Text under the field: a hint normally, the error message when `error` is set. |
|
|
55
|
+
| `label` | `ReactNode` | | Label shown on the field's border. Also the input's accessible name, so always set it. |
|
|
56
|
+
| `multiline` | `boolean` | `false` | Renders a growing `<textarea>` instead of an `<input>`. Use `minRows` / `maxRows` to bound it. |
|
|
57
|
+
| `name` | `string` | | Name submitted with the form. |
|
|
58
|
+
| `onChange` | `ChangeEventHandler<HTMLInputElement \| HTMLTextAreaElement, Element>` | | Called on every change; read the new value from `event.target.value`. |
|
|
59
|
+
| `placeholder` | `string` | | Hint shown inside the empty input. Don't use it instead of `label`. |
|
|
60
|
+
| `required` | `boolean` | `false` | Marks the field as required: adds an asterisk to the label and `required` to the input. |
|
|
61
|
+
| `size` | `"small" \| "medium"` | `small` | Field height: `small` (40px) or `medium` (56px). |
|
|
62
|
+
| `type` | `HTMLInputTypeAttribute` | `text` | HTML input type, e.g. `email`, `password`, `number`. |
|
|
63
|
+
| `value` | `unknown` | | Current value, for a controlled field. Use with `onChange`. |
|
|
64
|
+
<!-- props:end -->
|
|
65
|
+
|
|
66
|
+
Any other [MUI TextField prop](https://mui.com/material-ui/api/text-field/) (`minRows`,
|
|
67
|
+
`maxRows`, `autoComplete`, `slotProps`, `sx`, ...) is passed through to MUI. `variant` is
|
|
68
|
+
fixed to `outlined`. `ref` is forwarded to the root element.
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
|
|
4
|
+
interface TextFieldProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
5
|
+
/** Label shown on the field's border. Also the input's accessible name, so always set it. */
|
|
6
|
+
label?: OutlinedTextFieldProps['label'];
|
|
7
|
+
/** Hint shown inside the empty input. Don't use it instead of `label`. */
|
|
8
|
+
placeholder?: OutlinedTextFieldProps['placeholder'];
|
|
9
|
+
/** Text under the field: a hint normally, the error message when `error` is set. */
|
|
10
|
+
helperText?: OutlinedTextFieldProps['helperText'];
|
|
11
|
+
/**
|
|
12
|
+
* Shows the field in its error state and marks the input `aria-invalid`.
|
|
13
|
+
* Pair it with `helperText` explaining what is wrong.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
error?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Marks the field as required: adds an asterisk to the label and `required` to the input.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Disables the field.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Current value, for a controlled field. Use with `onChange`. */
|
|
28
|
+
value?: OutlinedTextFieldProps['value'];
|
|
29
|
+
/** Initial value, for an uncontrolled field. */
|
|
30
|
+
defaultValue?: OutlinedTextFieldProps['defaultValue'];
|
|
31
|
+
/** Called on every change; read the new value from `event.target.value`. */
|
|
32
|
+
onChange?: OutlinedTextFieldProps['onChange'];
|
|
33
|
+
/**
|
|
34
|
+
* HTML input type, e.g. `email`, `password`, `number`.
|
|
35
|
+
* @default 'text'
|
|
36
|
+
*/
|
|
37
|
+
type?: OutlinedTextFieldProps['type'];
|
|
38
|
+
/**
|
|
39
|
+
* Field height: `small` (40px) or `medium` (56px).
|
|
40
|
+
* @default 'small'
|
|
41
|
+
*/
|
|
42
|
+
size?: OutlinedTextFieldProps['size'];
|
|
43
|
+
/**
|
|
44
|
+
* Stretches the field to the full width of its container.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
fullWidth?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Renders a growing `<textarea>` instead of an `<input>`. Use `minRows` / `maxRows` to bound it.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
multiline?: boolean;
|
|
53
|
+
/** Name submitted with the form. */
|
|
54
|
+
name?: OutlinedTextFieldProps['name'];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Single- or multi-line text input with a label, helper text and error state.
|
|
59
|
+
* Wraps MUI's TextField, fixed to the outlined style, small and full width by default.
|
|
60
|
+
*/
|
|
61
|
+
declare const TextField: react.ForwardRefExoticComponent<Omit<TextFieldProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
62
|
+
|
|
63
|
+
export { TextField, type TextFieldProps };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/TextField.tsx
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import MuiTextField from "@mui/material/TextField";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var TextField = forwardRef(function TextField2({ size = "small", fullWidth = true, ...rest }, ref) {
|
|
8
|
+
return /* @__PURE__ */ jsx(MuiTextField, { ref, variant: "outlined", size, fullWidth, ...rest });
|
|
9
|
+
});
|
|
10
|
+
export {
|
|
11
|
+
TextField
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/TextField.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport MuiTextField from '@mui/material/TextField';\nimport type { TextFieldProps } from './TextField.types';\n\n/**\n * Single- or multi-line text input with a label, helper text and error state.\n * Wraps MUI's TextField, fixed to the outlined style, small and full width by default.\n */\nexport const TextField = forwardRef<HTMLDivElement, TextFieldProps>(function TextField(\n { size = 'small', fullWidth = true, ...rest },\n ref,\n) {\n return <MuiTextField ref={ref} variant=\"outlined\" size={size} fullWidth={fullWidth} {...rest} />;\n});\n"],"mappings":";;;AAAA,SAAS,kBAAkB;AAC3B,OAAO,kBAAkB;AAWhB;AAJF,IAAM,YAAY,WAA2C,SAASA,WAC3E,EAAE,OAAO,SAAS,YAAY,MAAM,GAAG,KAAK,GAC5C,KACA;AACA,SAAO,oBAAC,gBAAa,KAAU,SAAQ,YAAW,MAAY,WAAuB,GAAG,MAAM;AAChG,CAAC;","names":["TextField"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dax-ui/text-field",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "dax-ui TextField",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dax-ui",
|
|
7
|
+
"react",
|
|
8
|
+
"design-system",
|
|
9
|
+
"text-field",
|
|
10
|
+
"input",
|
|
11
|
+
"form",
|
|
12
|
+
"mui"
|
|
13
|
+
],
|
|
14
|
+
"author": "Digital Auxilius",
|
|
15
|
+
"homepage": "https://github.com/FaaizHussain26/DAX-UI/tree/main/packages/text-field#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/FaaizHussain26/DAX-UI.git",
|
|
19
|
+
"directory": "packages/text-field"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/FaaizHussain26/DAX-UI/issues"
|
|
23
|
+
},
|
|
24
|
+
"license": "UNLICENSED",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "lib/index.js",
|
|
28
|
+
"types": "lib/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./lib/index.d.ts",
|
|
32
|
+
"default": "./lib/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"lib",
|
|
38
|
+
"CHANGELOG.md"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@emotion/react": "^11.14.0",
|
|
42
|
+
"@emotion/styled": "^11.14.0",
|
|
43
|
+
"@mui/material": "^9.5.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
47
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@dax-ui/builder": "^0.0.0"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "builder"
|
|
57
|
+
}
|
|
6
58
|
}
|