@nucleux/md3-text-field 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nucleux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @nucleux/md3-text-field
2
+
3
+ Material 3 text field (filled, outlined) — Nucleux agentic UI for React.
4
+
5
+ Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @nucleux/md3-text-field @nucleux/tokens
11
+ ```
12
+
13
+ `react` / `react-dom` are peer dependencies.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import { Md3TextField } from "@nucleux/md3-text-field";
19
+ ```
20
+
21
+ Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
22
+ and the Tailwind preset from `@nucleux/tokens/preset`.
23
+
24
+ ## License
25
+
26
+ MIT © Nucleux
package/dist/index.cjs ADDED
@@ -0,0 +1,118 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var utils = require('@nucleux/utils');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
+
28
+ // src/index.tsx
29
+ var Md3TextField = React__namespace.forwardRef(
30
+ ({
31
+ label,
32
+ variant = "filled",
33
+ supportingText,
34
+ error = false,
35
+ leadingIcon,
36
+ trailingIcon,
37
+ id,
38
+ className,
39
+ disabled,
40
+ ...props
41
+ }, ref) => {
42
+ const generatedId = React__namespace.useId();
43
+ const inputId = id ?? generatedId;
44
+ const supportId = `${inputId}-support`;
45
+ const filled = variant === "filled";
46
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils.cn("w-full", disabled && "opacity-[0.38]", className), children: [
47
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
48
+ leadingIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-md-on-surface-variant [&_svg]:size-5", children: leadingIcon }),
49
+ /* @__PURE__ */ jsxRuntime.jsx(
50
+ "input",
51
+ {
52
+ ref,
53
+ id: inputId,
54
+ placeholder: " ",
55
+ disabled,
56
+ "aria-invalid": error || void 0,
57
+ "aria-describedby": supportingText ? supportId : void 0,
58
+ className: utils.cn(
59
+ "peer h-14 w-full text-base text-md-on-surface outline-none transition-colors placeholder:text-transparent disabled:cursor-not-allowed",
60
+ leadingIcon ? "pl-11" : "pl-4",
61
+ trailingIcon ? "pr-11" : "pr-4",
62
+ filled ? utils.cn(
63
+ "rounded-t-md-xs border-0 border-b-2 bg-md-surface-container-high pb-2 pt-6",
64
+ error ? "border-md-error" : "border-md-on-surface-variant focus:border-md-primary"
65
+ ) : utils.cn(
66
+ "rounded-md-xs border bg-transparent py-4",
67
+ error ? "border-md-error" : "border-md-outline focus:border-md-primary"
68
+ )
69
+ ),
70
+ ...props
71
+ }
72
+ ),
73
+ /* @__PURE__ */ jsxRuntime.jsx(
74
+ "label",
75
+ {
76
+ htmlFor: inputId,
77
+ className: utils.cn(
78
+ "pointer-events-none absolute transition-all",
79
+ leadingIcon ? "left-11" : "left-4",
80
+ // Floated (default: filled value / outlined value) position
81
+ filled ? "top-2 text-xs" : "-top-2 bg-md-surface px-1 text-xs",
82
+ // Resting position when empty & unfocused
83
+ "peer-placeholder-shown:text-base peer-placeholder-shown:text-md-on-surface-variant",
84
+ filled ? "peer-placeholder-shown:top-4" : "peer-placeholder-shown:top-4 peer-placeholder-shown:bg-transparent",
85
+ // Focused position + color
86
+ filled ? "peer-focus:top-2 peer-focus:text-xs" : "peer-focus:-top-2 peer-focus:bg-md-surface peer-focus:px-1 peer-focus:text-xs",
87
+ error ? "text-md-error peer-focus:text-md-error" : "text-md-on-surface-variant peer-focus:text-md-primary"
88
+ ),
89
+ children: label
90
+ }
91
+ ),
92
+ trailingIcon && /* @__PURE__ */ jsxRuntime.jsx(
93
+ "span",
94
+ {
95
+ className: utils.cn(
96
+ "pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 [&_svg]:size-5",
97
+ error ? "text-md-error" : "text-md-on-surface-variant"
98
+ ),
99
+ children: trailingIcon
100
+ }
101
+ )
102
+ ] }),
103
+ supportingText && /* @__PURE__ */ jsxRuntime.jsx(
104
+ "p",
105
+ {
106
+ id: supportId,
107
+ className: utils.cn("px-4 pt-1 text-xs", error ? "text-md-error" : "text-md-on-surface-variant"),
108
+ children: supportingText
109
+ }
110
+ )
111
+ ] });
112
+ }
113
+ );
114
+ Md3TextField.displayName = "Md3TextField";
115
+
116
+ exports.Md3TextField = Md3TextField;
117
+ //# sourceMappingURL=index.cjs.map
118
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["React","jsxs","cn","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,IAAM,YAAA,GAAqBA,gBAAA,CAAA,UAAA;AAAA,EAChC,CACE;AAAA,IACE,KAAA;AAAA,IACA,OAAA,GAAU,QAAA;AAAA,IACV,cAAA;AAAA,IACA,KAAA,GAAQ,KAAA;AAAA,IACR,WAAA;AAAA,IACA,YAAA;AAAA,IACA,EAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,cAAoBA,gBAAA,CAAA,KAAA,EAAM;AAChC,IAAA,MAAM,UAAU,EAAA,IAAM,WAAA;AACtB,IAAA,MAAM,SAAA,GAAY,GAAG,OAAO,CAAA,QAAA,CAAA;AAC5B,IAAA,MAAM,SAAS,OAAA,KAAY,QAAA;AAE3B,IAAA,uBACEC,eAAA,CAAC,SAAI,SAAA,EAAWC,QAAA,CAAG,UAAU,QAAA,IAAY,gBAAA,EAAkB,SAAS,CAAA,EAClE,QAAA,EAAA;AAAA,sBAAAD,eAAA,CAAC,KAAA,EAAA,EAAI,WAAU,UAAA,EACZ,QAAA,EAAA;AAAA,QAAA,WAAA,oBACCE,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,wGAAA,EACb,QAAA,EAAA,WAAA,EACH,CAAA;AAAA,wBAGFA,cAAA;AAAA,UAAC,O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AAAA,UACJ,SAAA,EAAWD,QAAA,CAAG,mBAAA,EAAqB,KAAA,GAAQ,kBAAkB,4BAA4B,CAAA;AAAA,UAExF,QAAA,EAAA;AAAA;AAAA;AACH,KAAA,EAEJ,CAAA;AAAA,EAEJ;AACF;AACA,YAAA,CAAa,WAAA,GAAc,cAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport type Md3TextFieldVariant = \"filled\" | \"outlined\";\n\nexport interface Md3TextFieldProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"placeholder\"> {\n label: string;\n variant?: Md3TextFieldVariant;\n supportingText?: React.ReactNode;\n error?: boolean;\n leadingIcon?: React.ReactNode;\n trailingIcon?: React.ReactNode;\n}\n\n/**\n * A Material Design 3 text field (filled or outlined) with a floating label,\n * optional leading/trailing icons, supporting text, and an error state.\n */\nexport const Md3TextField = React.forwardRef<HTMLInputElement, Md3TextFieldProps>(\n (\n {\n label,\n variant = \"filled\",\n supportingText,\n error = false,\n leadingIcon,\n trailingIcon,\n id,\n className,\n disabled,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id ?? generatedId;\n const supportId = `${inputId}-support`;\n const filled = variant === \"filled\";\n\n return (\n <div className={cn(\"w-full\", disabled && \"opacity-[0.38]\", className)}>\n <div className=\"relative\">\n {leadingIcon && (\n <span className=\"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-md-on-surface-variant [&_svg]:size-5\">\n {leadingIcon}\n </span>\n )}\n\n <input\n ref={ref}\n id={inputId}\n placeholder=\" \"\n disabled={disabled}\n aria-invalid={error || undefined}\n aria-describedby={supportingText ? supportId : undefined}\n className={cn(\n \"peer h-14 w-full text-base text-md-on-surface outline-none transition-colors placeholder:text-transparent disabled:cursor-not-allowed\",\n leadingIcon ? \"pl-11\" : \"pl-4\",\n trailingIcon ? \"pr-11\" : \"pr-4\",\n filled\n ? cn(\n \"rounded-t-md-xs border-0 border-b-2 bg-md-surface-container-high pb-2 pt-6\",\n error ? \"border-md-error\" : \"border-md-on-surface-variant focus:border-md-primary\",\n )\n : cn(\n \"rounded-md-xs border bg-transparent py-4\",\n error ? \"border-md-error\" : \"border-md-outline focus:border-md-primary\",\n ),\n )}\n {...props}\n />\n\n <label\n htmlFor={inputId}\n className={cn(\n \"pointer-events-none absolute transition-all\",\n leadingIcon ? \"left-11\" : \"left-4\",\n // Floated (default: filled value / outlined value) position\n filled ? \"top-2 text-xs\" : \"-top-2 bg-md-surface px-1 text-xs\",\n // Resting position when empty & unfocused\n \"peer-placeholder-shown:text-base peer-placeholder-shown:text-md-on-surface-variant\",\n filled\n ? \"peer-placeholder-shown:top-4\"\n : \"peer-placeholder-shown:top-4 peer-placeholder-shown:bg-transparent\",\n // Focused position + color\n filled\n ? \"peer-focus:top-2 peer-focus:text-xs\"\n : \"peer-focus:-top-2 peer-focus:bg-md-surface peer-focus:px-1 peer-focus:text-xs\",\n error\n ? \"text-md-error peer-focus:text-md-error\"\n : \"text-md-on-surface-variant peer-focus:text-md-primary\",\n )}\n >\n {label}\n </label>\n\n {trailingIcon && (\n <span\n className={cn(\n \"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 [&_svg]:size-5\",\n error ? \"text-md-error\" : \"text-md-on-surface-variant\",\n )}\n >\n {trailingIcon}\n </span>\n )}\n </div>\n\n {supportingText && (\n <p\n id={supportId}\n className={cn(\"px-4 pt-1 text-xs\", error ? \"text-md-error\" : \"text-md-on-surface-variant\")}\n >\n {supportingText}\n </p>\n )}\n </div>\n );\n },\n);\nMd3TextField.displayName = \"Md3TextField\";\n"]}
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ type Md3TextFieldVariant = "filled" | "outlined";
4
+ interface Md3TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "placeholder"> {
5
+ label: string;
6
+ variant?: Md3TextFieldVariant;
7
+ supportingText?: React.ReactNode;
8
+ error?: boolean;
9
+ leadingIcon?: React.ReactNode;
10
+ trailingIcon?: React.ReactNode;
11
+ }
12
+ /**
13
+ * A Material Design 3 text field (filled or outlined) with a floating label,
14
+ * optional leading/trailing icons, supporting text, and an error state.
15
+ */
16
+ declare const Md3TextField: React.ForwardRefExoticComponent<Md3TextFieldProps & React.RefAttributes<HTMLInputElement>>;
17
+
18
+ export { Md3TextField, type Md3TextFieldProps, type Md3TextFieldVariant };
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ type Md3TextFieldVariant = "filled" | "outlined";
4
+ interface Md3TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "placeholder"> {
5
+ label: string;
6
+ variant?: Md3TextFieldVariant;
7
+ supportingText?: React.ReactNode;
8
+ error?: boolean;
9
+ leadingIcon?: React.ReactNode;
10
+ trailingIcon?: React.ReactNode;
11
+ }
12
+ /**
13
+ * A Material Design 3 text field (filled or outlined) with a floating label,
14
+ * optional leading/trailing icons, supporting text, and an error state.
15
+ */
16
+ declare const Md3TextField: React.ForwardRefExoticComponent<Md3TextFieldProps & React.RefAttributes<HTMLInputElement>>;
17
+
18
+ export { Md3TextField, type Md3TextFieldProps, type Md3TextFieldVariant };
package/dist/index.js ADDED
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { cn } from '@nucleux/utils';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ // src/index.tsx
7
+ var Md3TextField = React.forwardRef(
8
+ ({
9
+ label,
10
+ variant = "filled",
11
+ supportingText,
12
+ error = false,
13
+ leadingIcon,
14
+ trailingIcon,
15
+ id,
16
+ className,
17
+ disabled,
18
+ ...props
19
+ }, ref) => {
20
+ const generatedId = React.useId();
21
+ const inputId = id ?? generatedId;
22
+ const supportId = `${inputId}-support`;
23
+ const filled = variant === "filled";
24
+ return /* @__PURE__ */ jsxs("div", { className: cn("w-full", disabled && "opacity-[0.38]", className), children: [
25
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
26
+ leadingIcon && /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-md-on-surface-variant [&_svg]:size-5", children: leadingIcon }),
27
+ /* @__PURE__ */ jsx(
28
+ "input",
29
+ {
30
+ ref,
31
+ id: inputId,
32
+ placeholder: " ",
33
+ disabled,
34
+ "aria-invalid": error || void 0,
35
+ "aria-describedby": supportingText ? supportId : void 0,
36
+ className: cn(
37
+ "peer h-14 w-full text-base text-md-on-surface outline-none transition-colors placeholder:text-transparent disabled:cursor-not-allowed",
38
+ leadingIcon ? "pl-11" : "pl-4",
39
+ trailingIcon ? "pr-11" : "pr-4",
40
+ filled ? cn(
41
+ "rounded-t-md-xs border-0 border-b-2 bg-md-surface-container-high pb-2 pt-6",
42
+ error ? "border-md-error" : "border-md-on-surface-variant focus:border-md-primary"
43
+ ) : cn(
44
+ "rounded-md-xs border bg-transparent py-4",
45
+ error ? "border-md-error" : "border-md-outline focus:border-md-primary"
46
+ )
47
+ ),
48
+ ...props
49
+ }
50
+ ),
51
+ /* @__PURE__ */ jsx(
52
+ "label",
53
+ {
54
+ htmlFor: inputId,
55
+ className: cn(
56
+ "pointer-events-none absolute transition-all",
57
+ leadingIcon ? "left-11" : "left-4",
58
+ // Floated (default: filled value / outlined value) position
59
+ filled ? "top-2 text-xs" : "-top-2 bg-md-surface px-1 text-xs",
60
+ // Resting position when empty & unfocused
61
+ "peer-placeholder-shown:text-base peer-placeholder-shown:text-md-on-surface-variant",
62
+ filled ? "peer-placeholder-shown:top-4" : "peer-placeholder-shown:top-4 peer-placeholder-shown:bg-transparent",
63
+ // Focused position + color
64
+ filled ? "peer-focus:top-2 peer-focus:text-xs" : "peer-focus:-top-2 peer-focus:bg-md-surface peer-focus:px-1 peer-focus:text-xs",
65
+ error ? "text-md-error peer-focus:text-md-error" : "text-md-on-surface-variant peer-focus:text-md-primary"
66
+ ),
67
+ children: label
68
+ }
69
+ ),
70
+ trailingIcon && /* @__PURE__ */ jsx(
71
+ "span",
72
+ {
73
+ className: cn(
74
+ "pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 [&_svg]:size-5",
75
+ error ? "text-md-error" : "text-md-on-surface-variant"
76
+ ),
77
+ children: trailingIcon
78
+ }
79
+ )
80
+ ] }),
81
+ supportingText && /* @__PURE__ */ jsx(
82
+ "p",
83
+ {
84
+ id: supportId,
85
+ className: cn("px-4 pt-1 text-xs", error ? "text-md-error" : "text-md-on-surface-variant"),
86
+ children: supportingText
87
+ }
88
+ )
89
+ ] });
90
+ }
91
+ );
92
+ Md3TextField.displayName = "Md3TextField";
93
+
94
+ export { Md3TextField };
95
+ //# sourceMappingURL=index.js.map
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAmBO,IAAM,YAAA,GAAqB,KAAA,CAAA,UAAA;AAAA,EAChC,CACE;AAAA,IACE,KAAA;AAAA,IACA,OAAA,GAAU,QAAA;AAAA,IACV,cAAA;AAAA,IACA,KAAA,GAAQ,KAAA;AAAA,IACR,WAAA;AAAA,IACA,YAAA;AAAA,IACA,EAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,cAAoB,KAAA,CAAA,KAAA,EAAM;AAChC,IAAA,MAAM,UAAU,EAAA,IAAM,WAAA;AACtB,IAAA,MAAM,SAAA,GAAY,GAAG,OAAO,CAAA,QAAA,CAAA;AAC5B,IAAA,MAAM,SAAS,OAAA,KAAY,QAAA;AAE3B,IAAA,uBACE,IAAA,CAAC,SAAI,SAAA,EAAW,EAAA,CAAG,UAAU,QAAA,IAAY,gBAAA,EAAkB,SAAS,CAAA,EAClE,QAAA,EAAA;AAAA,sBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,WAAU,UAAA,EACZ,QAAA,EAAA;AAAA,QAAA,WAAA,oBACC,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU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GAAA;AAAA,QAAC,GAAA;AAAA,QAAA;AAAA,UACC,EAAA,EAAI,SAAA;AAAA,UACJ,SAAA,EAAW,EAAA,CAAG,mBAAA,EAAqB,KAAA,GAAQ,kBAAkB,4BAA4B,CAAA;AAAA,UAExF,QAAA,EAAA;AAAA;AAAA;AACH,KAAA,EAEJ,CAAA;AAAA,EAEJ;AACF;AACA,YAAA,CAAa,WAAA,GAAc,cAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport type Md3TextFieldVariant = \"filled\" | \"outlined\";\n\nexport interface Md3TextFieldProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"placeholder\"> {\n label: string;\n variant?: Md3TextFieldVariant;\n supportingText?: React.ReactNode;\n error?: boolean;\n leadingIcon?: React.ReactNode;\n trailingIcon?: React.ReactNode;\n}\n\n/**\n * A Material Design 3 text field (filled or outlined) with a floating label,\n * optional leading/trailing icons, supporting text, and an error state.\n */\nexport const Md3TextField = React.forwardRef<HTMLInputElement, Md3TextFieldProps>(\n (\n {\n label,\n variant = \"filled\",\n supportingText,\n error = false,\n leadingIcon,\n trailingIcon,\n id,\n className,\n disabled,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id ?? generatedId;\n const supportId = `${inputId}-support`;\n const filled = variant === \"filled\";\n\n return (\n <div className={cn(\"w-full\", disabled && \"opacity-[0.38]\", className)}>\n <div className=\"relative\">\n {leadingIcon && (\n <span className=\"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-md-on-surface-variant [&_svg]:size-5\">\n {leadingIcon}\n </span>\n )}\n\n <input\n ref={ref}\n id={inputId}\n placeholder=\" \"\n disabled={disabled}\n aria-invalid={error || undefined}\n aria-describedby={supportingText ? supportId : undefined}\n className={cn(\n \"peer h-14 w-full text-base text-md-on-surface outline-none transition-colors placeholder:text-transparent disabled:cursor-not-allowed\",\n leadingIcon ? \"pl-11\" : \"pl-4\",\n trailingIcon ? \"pr-11\" : \"pr-4\",\n filled\n ? cn(\n \"rounded-t-md-xs border-0 border-b-2 bg-md-surface-container-high pb-2 pt-6\",\n error ? \"border-md-error\" : \"border-md-on-surface-variant focus:border-md-primary\",\n )\n : cn(\n \"rounded-md-xs border bg-transparent py-4\",\n error ? \"border-md-error\" : \"border-md-outline focus:border-md-primary\",\n ),\n )}\n {...props}\n />\n\n <label\n htmlFor={inputId}\n className={cn(\n \"pointer-events-none absolute transition-all\",\n leadingIcon ? \"left-11\" : \"left-4\",\n // Floated (default: filled value / outlined value) position\n filled ? \"top-2 text-xs\" : \"-top-2 bg-md-surface px-1 text-xs\",\n // Resting position when empty & unfocused\n \"peer-placeholder-shown:text-base peer-placeholder-shown:text-md-on-surface-variant\",\n filled\n ? \"peer-placeholder-shown:top-4\"\n : \"peer-placeholder-shown:top-4 peer-placeholder-shown:bg-transparent\",\n // Focused position + color\n filled\n ? \"peer-focus:top-2 peer-focus:text-xs\"\n : \"peer-focus:-top-2 peer-focus:bg-md-surface peer-focus:px-1 peer-focus:text-xs\",\n error\n ? \"text-md-error peer-focus:text-md-error\"\n : \"text-md-on-surface-variant peer-focus:text-md-primary\",\n )}\n >\n {label}\n </label>\n\n {trailingIcon && (\n <span\n className={cn(\n \"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 [&_svg]:size-5\",\n error ? \"text-md-error\" : \"text-md-on-surface-variant\",\n )}\n >\n {trailingIcon}\n </span>\n )}\n </div>\n\n {supportingText && (\n <p\n id={supportId}\n className={cn(\"px-4 pt-1 text-xs\", error ? \"text-md-error\" : \"text-md-on-surface-variant\")}\n >\n {supportingText}\n </p>\n )}\n </div>\n );\n },\n);\nMd3TextField.displayName = \"Md3TextField\";\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nucleux/md3-text-field",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "Material 3 text field (filled, outlined) — Nucleux agentic UI for React.",
7
+ "keywords": [
8
+ "nucleux",
9
+ "react",
10
+ "ui",
11
+ "components",
12
+ "agentic",
13
+ "ai",
14
+ "tailwind",
15
+ "md3-text-field"
16
+ ],
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md"
30
+ ],
31
+ "peerDependencies": {
32
+ "react": ">=18",
33
+ "react-dom": ">=18"
34
+ },
35
+ "dependencies": {
36
+ "@nucleux/utils": "0.3.0"
37
+ },
38
+ "devDependencies": {
39
+ "tsup": "^8.3.5",
40
+ "typescript": "^5.7.2",
41
+ "@types/react": "^18.3.18",
42
+ "react": "^18.3.1",
43
+ "lucide-react": "^0.469.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
52
+ "directory": "packages/md3-text-field"
53
+ },
54
+ "homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
55
+ "scripts": {
56
+ "build": "tsup"
57
+ }
58
+ }