@negative-space/input 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Matheus Bastani
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,15 @@
1
+ # @negative-space/input
2
+
3
+ Headless Input component by Negative Space, providing accessible behavior without visual constraints.
4
+
5
+ ## Installation
6
+
7
+ # Using Yarn
8
+ yarn add @negative-space/input
9
+
10
+ # Using npm
11
+ npm install @negative-space/input
12
+
13
+ ## Contributing
14
+
15
+ Feel free to fork, tweak, and send a pull request!
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { IconButtonProps } from '@negative-space/button';
3
+
4
+ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'className' | 'prefix' | 'style'> {
5
+ classNames?: {
6
+ field?: {
7
+ root?: string;
8
+ label?: string;
9
+ error?: string;
10
+ };
11
+ root?: string;
12
+ prefix?: string;
13
+ content?: string;
14
+ suffix?: string;
15
+ };
16
+ styles?: {
17
+ field?: {
18
+ root?: React.CSSProperties;
19
+ label?: React.CSSProperties;
20
+ error?: React.CSSProperties;
21
+ };
22
+ root?: React.CSSProperties;
23
+ prefix?: React.CSSProperties;
24
+ content?: React.CSSProperties;
25
+ suffix?: React.CSSProperties;
26
+ };
27
+ label?: string;
28
+ error?: string;
29
+ prefix?: React.ReactNode;
30
+ suffix?: React.ReactNode;
31
+ htmlFor?: string;
32
+ }
33
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
34
+
35
+ interface InputPasswordProps extends Omit<InputProps, 'classNames' | 'styles' | 'suffix' | 'type'> {
36
+ classNames?: InputProps['classNames'] & {
37
+ button?: string;
38
+ };
39
+ styles?: InputProps['styles'] & {
40
+ button?: React.CSSProperties;
41
+ };
42
+ onToggleVisibility?: (visible: boolean) => void;
43
+ buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label'>;
44
+ }
45
+ declare const InputPassword: React.ForwardRefExoticComponent<InputPasswordProps & React.RefAttributes<HTMLInputElement>>;
46
+
47
+ export { Input, InputPassword, type InputPasswordProps, type InputProps };
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { IconButtonProps } from '@negative-space/button';
3
+
4
+ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'className' | 'prefix' | 'style'> {
5
+ classNames?: {
6
+ field?: {
7
+ root?: string;
8
+ label?: string;
9
+ error?: string;
10
+ };
11
+ root?: string;
12
+ prefix?: string;
13
+ content?: string;
14
+ suffix?: string;
15
+ };
16
+ styles?: {
17
+ field?: {
18
+ root?: React.CSSProperties;
19
+ label?: React.CSSProperties;
20
+ error?: React.CSSProperties;
21
+ };
22
+ root?: React.CSSProperties;
23
+ prefix?: React.CSSProperties;
24
+ content?: React.CSSProperties;
25
+ suffix?: React.CSSProperties;
26
+ };
27
+ label?: string;
28
+ error?: string;
29
+ prefix?: React.ReactNode;
30
+ suffix?: React.ReactNode;
31
+ htmlFor?: string;
32
+ }
33
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
34
+
35
+ interface InputPasswordProps extends Omit<InputProps, 'classNames' | 'styles' | 'suffix' | 'type'> {
36
+ classNames?: InputProps['classNames'] & {
37
+ button?: string;
38
+ };
39
+ styles?: InputProps['styles'] & {
40
+ button?: React.CSSProperties;
41
+ };
42
+ onToggleVisibility?: (visible: boolean) => void;
43
+ buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label'>;
44
+ }
45
+ declare const InputPassword: React.ForwardRefExoticComponent<InputPasswordProps & React.RefAttributes<HTMLInputElement>>;
46
+
47
+ export { Input, InputPassword, type InputPasswordProps, type InputProps };
package/dist/index.js ADDED
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var system = require('@negative-space/system');
5
+ var field = require('@negative-space/field');
6
+ var flex = require('@negative-space/flex');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var button = require('@negative-space/button');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefault(React);
13
+
14
+ // src/Input.tsx
15
+ var Input = React__default.default.forwardRef(
16
+ ({ classNames, styles, label, error, prefix, suffix, htmlFor, id, ...props }, ref) => {
17
+ const { global } = system.useNSUI();
18
+ const generatedId = React__default.default.useId();
19
+ const inputId = id ?? generatedId;
20
+ return /* @__PURE__ */ jsxRuntime.jsx(
21
+ field.Field,
22
+ {
23
+ classNames: classNames?.field,
24
+ styles: styles?.field,
25
+ label,
26
+ error,
27
+ htmlFor: htmlFor ?? inputId,
28
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
29
+ flex.Flex,
30
+ {
31
+ alignItems: "center",
32
+ className: system.cn(`${global.prefixCls}-input-root`, classNames?.root),
33
+ style: { marginTop: "6px", ...styles?.root },
34
+ children: [
35
+ prefix && /* @__PURE__ */ jsxRuntime.jsx(
36
+ "span",
37
+ {
38
+ className: system.cn(`${global.prefixCls}-input-prefix`, classNames?.prefix),
39
+ style: styles?.prefix,
40
+ children: prefix
41
+ }
42
+ ),
43
+ /* @__PURE__ */ jsxRuntime.jsx(
44
+ "input",
45
+ {
46
+ ...props,
47
+ ref,
48
+ id: inputId,
49
+ className: system.cn(`${global.prefixCls}-input-content`, classNames?.content),
50
+ style: { outline: "none", ...styles?.content }
51
+ }
52
+ ),
53
+ suffix && /* @__PURE__ */ jsxRuntime.jsx(
54
+ "span",
55
+ {
56
+ className: system.cn(`${global.prefixCls}-input-suffix`, classNames?.suffix),
57
+ style: styles?.suffix,
58
+ children: suffix
59
+ }
60
+ )
61
+ ]
62
+ }
63
+ )
64
+ }
65
+ );
66
+ }
67
+ );
68
+ Input.displayName = "Input";
69
+ var InputPassword = React__default.default.forwardRef(
70
+ ({ onToggleVisibility, classNames, styles, buttonProps, ...rest }, ref) => {
71
+ const { global } = system.useNSUI();
72
+ const [visible, setVisible] = React__default.default.useState(false);
73
+ const handleToggle = () => {
74
+ setVisible((prev) => {
75
+ const next = !prev;
76
+ onToggleVisibility?.(next);
77
+ return next;
78
+ });
79
+ };
80
+ return /* @__PURE__ */ jsxRuntime.jsx(
81
+ Input,
82
+ {
83
+ ...rest,
84
+ ref,
85
+ type: visible ? "text" : "password",
86
+ "data-visible": visible,
87
+ classNames: {
88
+ ...classNames,
89
+ root: system.cn(classNames?.root, `${global.prefixCls}-input-password`)
90
+ },
91
+ styles,
92
+ suffix: /* @__PURE__ */ jsxRuntime.jsx(
93
+ button.IconButton,
94
+ {
95
+ ...buttonProps,
96
+ onClick: handleToggle,
97
+ "aria-label": visible ? "Hide password" : "Show password",
98
+ className: classNames?.button,
99
+ style: styles?.button,
100
+ children: visible ? /* @__PURE__ */ jsxRuntime.jsx(system.EyeOff, {}) : /* @__PURE__ */ jsxRuntime.jsx(system.Eye, {})
101
+ }
102
+ )
103
+ }
104
+ );
105
+ }
106
+ );
107
+ InputPassword.displayName = "InputPassword";
108
+
109
+ exports.Input = Input;
110
+ exports.InputPassword = InputPassword;
111
+ //# sourceMappingURL=index.js.map
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Input.tsx","../src/InputPassword.tsx"],"names":["React","useNSUI","jsx","Field","jsxs","Flex","cn","IconButton","EyeOff","Eye"],"mappings":";;;;;;;;;;;;;;AAsCO,IAAM,QAAQA,sBAAA,CAAM,UAAA;AAAA,EACzB,CAAC,EAAE,UAAA,EAAY,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,EAAA,EAAI,GAAG,KAAA,IAAS,GAAA,KAAQ;AACpF,IAAA,MAAM,EAAE,MAAA,EAAO,GAAIC,cAAA,EAAQ;AAC3B,IAAA,MAAM,WAAA,GAAcD,uBAAM,KAAA,EAAM;AAChC,IAAA,MAAM,UAAU,EAAA,IAAM,WAAA;AAEtB,IAAA,uBACEE,cAAA;AAAA,MAACC,WAAA;AAAA,MAAA;AAAA,QACC,YAAY,UAAA,EAAY,KAAA;AAAA,QACxB,QAAQ,MAAA,EAAQ,KAAA;AAAA,QAChB,KAAA;AAAA,QACA,KAAA;AAAA,QACA,SAAS,OAAA,IAAW,OAAA;AAAA,QAEpB,QAAA,kBAAAC,eAAA;AAAA,UAACC,SAAA;AAAA,UAAA;AAAA,YACC,UAAA,EAAW,QAAA;AAAA,YACX,WAAWC,SAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAAA,WAAA,CAAA,EAAe,YAAY,IAAI,CAAA;AAAA,YAChE,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,GAAG,QAAQ,IAAA,EAAK;AAAA,YAE1C,QAAA,EAAA;AAAA,cAAA,MAAA,oBACCJ,cAAA;AAAA,gBAAC,MAAA;AA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C,IAAA;AACd,QAAA,kBAAA,GAAqB,IAAI,CAAA;AACzB,QAAA,OAAO,IAAA;AAAA,MACT,CAAC,CAAA;AAAA,IACH,CAAA;AAEA,IAAA,uBACEE,cAAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACE,GAAG,IAAA;AAAA,QACJ,GAAA;AAAA,QACA,IAAA,EAAM,UAAU,MAAA,GAAS,UAAA;AAAA,QACzB,cAAA,EAAc,OAAA;AAAA,QACd,UAAA,EAAY;AAAA,UACV,GAAG,UAAA;AAAA,UACH,MAAMI,SAAAA,CAAG,UAAA,EAAY,MAAM,CAAA,EAAG,MAAA,CAAO,SAAS,CAAA,eAAA,CAAiB;AAAA,SACjE;AAAA,QACA,MAAA;AAAA,QACA,wBACEJ,cAAAA;AAAA,UAACK,iBAAA;AAAA,UAAA;AAAA,YACE,GAAG,WAAA;AAAA,YACJ,OAAA,EAAS,YAAA;AAAA,YACT,YAAA,EAAY,UAAU,eAAA,GAAkB,eAAA;AAAA,YACxC,WAAW,UAAA,EAAY,MAAA;AAAA,YACvB,OAAO,MAAA,EAAQ,MAAA;AAAA,YAEd,oCAAUL,cAAAA,CAACM,iBAAO,CAAA,mBAAKN,eAACO,UAAA,EAAA,EAAI;AAAA;AAAA;AAC/B;AAAA,KAEJ;AAAA,EAEJ;AACF;AAEA,aAAA,CAAc,WAAA,GAAc,eAAA","file":"index.js","sourcesContent":["import React from 'react'\nimport { cn, useNSUI } from '@negative-space/system'\nimport { Field } from '@negative-space/field'\nimport { Flex } from '@negative-space/flex'\n\nexport interface InputProps extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'className' | 'prefix' | 'style'\n> {\n classNames?: {\n field?: {\n root?: string\n label?: string\n error?: string\n }\n root?: string\n prefix?: string\n content?: string\n suffix?: string\n }\n styles?: {\n field?: {\n root?: React.CSSProperties\n label?: React.CSSProperties\n error?: React.CSSProperties\n }\n root?: React.CSSProperties\n prefix?: React.CSSProperties\n content?: React.CSSProperties\n suffix?: React.CSSProperties\n }\n label?: string\n error?: string\n prefix?: React.ReactNode\n suffix?: React.ReactNode\n htmlFor?: string\n}\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ classNames, styles, label, error, prefix, suffix, htmlFor, id, ...props }, ref) => {\n const { global } = useNSUI()\n const generatedId = React.useId()\n const inputId = id ?? generatedId\n\n return (\n <Field\n classNames={classNames?.field}\n styles={styles?.field}\n label={label}\n error={error}\n htmlFor={htmlFor ?? inputId}\n >\n <Flex\n alignItems=\"center\"\n className={cn(`${global.prefixCls}-input-root`, classNames?.root)}\n style={{ marginTop: '6px', ...styles?.root }}\n >\n {prefix && (\n <span\n className={cn(`${global.prefixCls}-input-prefix`, classNames?.prefix)}\n style={styles?.prefix}\n >\n {prefix}\n </span>\n )}\n\n <input\n {...props}\n ref={ref}\n id={inputId}\n className={cn(`${global.prefixCls}-input-content`, classNames?.content)}\n style={{ outline: 'none', ...styles?.content }}\n />\n\n {suffix && (\n <span\n className={cn(`${global.prefixCls}-input-suffix`, classNames?.suffix)}\n style={styles?.suffix}\n >\n {suffix}\n </span>\n )}\n </Flex>\n </Field>\n )\n }\n)\n\nInput.displayName = 'Input'\n","import React from 'react'\nimport { cn, useNSUI, Eye, EyeOff } from '@negative-space/system'\nimport { Input, type InputProps } from '.'\nimport { IconButton, type IconButtonProps } from '@negative-space/button'\n\nexport interface InputPasswordProps extends Omit<\n InputProps,\n 'classNames' | 'styles' | 'suffix' | 'type'\n> {\n classNames?: InputProps['classNames'] & {\n button?: string\n }\n styles?: InputProps['styles'] & {\n button?: React.CSSProperties\n }\n onToggleVisibility?: (visible: boolean) => void\n buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label'>\n}\n\nexport const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(\n ({ onToggleVisibility, classNames, styles, buttonProps, ...rest }, ref) => {\n const { global } = useNSUI()\n const [visible, setVisible] = React.useState(false)\n\n const handleToggle = () => {\n setVisible((prev) => {\n const next = !prev\n onToggleVisibility?.(next)\n return next\n })\n }\n\n return (\n <Input\n {...rest}\n ref={ref}\n type={visible ? 'text' : 'password'}\n data-visible={visible}\n classNames={{\n ...classNames,\n root: cn(classNames?.root, `${global.prefixCls}-input-password`)\n }}\n styles={styles}\n suffix={\n <IconButton\n {...buttonProps}\n onClick={handleToggle}\n aria-label={visible ? 'Hide password' : 'Show password'}\n className={classNames?.button}\n style={styles?.button}\n >\n {visible ? <EyeOff /> : <Eye />}\n </IconButton>\n }\n />\n )\n }\n)\n\nInputPassword.displayName = 'InputPassword'\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import { useNSUI, cn, EyeOff, Eye } from '@negative-space/system';
3
+ import { Field } from '@negative-space/field';
4
+ import { Flex } from '@negative-space/flex';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+ import { IconButton } from '@negative-space/button';
7
+
8
+ // src/Input.tsx
9
+ var Input = React.forwardRef(
10
+ ({ classNames, styles, label, error, prefix, suffix, htmlFor, id, ...props }, ref) => {
11
+ const { global } = useNSUI();
12
+ const generatedId = React.useId();
13
+ const inputId = id ?? generatedId;
14
+ return /* @__PURE__ */ jsx(
15
+ Field,
16
+ {
17
+ classNames: classNames?.field,
18
+ styles: styles?.field,
19
+ label,
20
+ error,
21
+ htmlFor: htmlFor ?? inputId,
22
+ children: /* @__PURE__ */ jsxs(
23
+ Flex,
24
+ {
25
+ alignItems: "center",
26
+ className: cn(`${global.prefixCls}-input-root`, classNames?.root),
27
+ style: { marginTop: "6px", ...styles?.root },
28
+ children: [
29
+ prefix && /* @__PURE__ */ jsx(
30
+ "span",
31
+ {
32
+ className: cn(`${global.prefixCls}-input-prefix`, classNames?.prefix),
33
+ style: styles?.prefix,
34
+ children: prefix
35
+ }
36
+ ),
37
+ /* @__PURE__ */ jsx(
38
+ "input",
39
+ {
40
+ ...props,
41
+ ref,
42
+ id: inputId,
43
+ className: cn(`${global.prefixCls}-input-content`, classNames?.content),
44
+ style: { outline: "none", ...styles?.content }
45
+ }
46
+ ),
47
+ suffix && /* @__PURE__ */ jsx(
48
+ "span",
49
+ {
50
+ className: cn(`${global.prefixCls}-input-suffix`, classNames?.suffix),
51
+ style: styles?.suffix,
52
+ children: suffix
53
+ }
54
+ )
55
+ ]
56
+ }
57
+ )
58
+ }
59
+ );
60
+ }
61
+ );
62
+ Input.displayName = "Input";
63
+ var InputPassword = React.forwardRef(
64
+ ({ onToggleVisibility, classNames, styles, buttonProps, ...rest }, ref) => {
65
+ const { global } = useNSUI();
66
+ const [visible, setVisible] = React.useState(false);
67
+ const handleToggle = () => {
68
+ setVisible((prev) => {
69
+ const next = !prev;
70
+ onToggleVisibility?.(next);
71
+ return next;
72
+ });
73
+ };
74
+ return /* @__PURE__ */ jsx(
75
+ Input,
76
+ {
77
+ ...rest,
78
+ ref,
79
+ type: visible ? "text" : "password",
80
+ "data-visible": visible,
81
+ classNames: {
82
+ ...classNames,
83
+ root: cn(classNames?.root, `${global.prefixCls}-input-password`)
84
+ },
85
+ styles,
86
+ suffix: /* @__PURE__ */ jsx(
87
+ IconButton,
88
+ {
89
+ ...buttonProps,
90
+ onClick: handleToggle,
91
+ "aria-label": visible ? "Hide password" : "Show password",
92
+ className: classNames?.button,
93
+ style: styles?.button,
94
+ children: visible ? /* @__PURE__ */ jsx(EyeOff, {}) : /* @__PURE__ */ jsx(Eye, {})
95
+ }
96
+ )
97
+ }
98
+ );
99
+ }
100
+ );
101
+ InputPassword.displayName = "InputPassword";
102
+
103
+ export { Input, InputPassword };
104
+ //# sourceMappingURL=index.mjs.map
105
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Input.tsx","../src/InputPassword.tsx"],"names":["React","useNSUI","jsx","cn"],"mappings":";;;;;;;;AAsCO,IAAM,QAAQ,KAAA,CAAM,UAAA;AAAA,EACzB,CAAC,EAAE,UAAA,EAAY,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO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AA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACE,GAAG,WAAA;AAAA,YACJ,OAAA,EAAS,YAAA;AAAA,YACT,YAAA,EAAY,UAAU,eAAA,GAAkB,eAAA;AAAA,YACxC,WAAW,UAAA,EAAY,MAAA;AAAA,YACvB,OAAO,MAAA,EAAQ,MAAA;AAAA,YAEd,oCAAUA,GAAAA,CAAC,UAAO,CAAA,mBAAKA,IAAC,GAAA,EAAA,EAAI;AAAA;AAAA;AAC/B;AAAA,KAEJ;AAAA,EAEJ;AACF;AAEA,aAAA,CAAc,WAAA,GAAc,eAAA","file":"index.mjs","sourcesContent":["import React from 'react'\nimport { cn, useNSUI } from '@negative-space/system'\nimport { Field } from '@negative-space/field'\nimport { Flex } from '@negative-space/flex'\n\nexport interface InputProps extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'className' | 'prefix' | 'style'\n> {\n classNames?: {\n field?: {\n root?: string\n label?: string\n error?: string\n }\n root?: string\n prefix?: string\n content?: string\n suffix?: string\n }\n styles?: {\n field?: {\n root?: React.CSSProperties\n label?: React.CSSProperties\n error?: React.CSSProperties\n }\n root?: React.CSSProperties\n prefix?: React.CSSProperties\n content?: React.CSSProperties\n suffix?: React.CSSProperties\n }\n label?: string\n error?: string\n prefix?: React.ReactNode\n suffix?: React.ReactNode\n htmlFor?: string\n}\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ classNames, styles, label, error, prefix, suffix, htmlFor, id, ...props }, ref) => {\n const { global } = useNSUI()\n const generatedId = React.useId()\n const inputId = id ?? generatedId\n\n return (\n <Field\n classNames={classNames?.field}\n styles={styles?.field}\n label={label}\n error={error}\n htmlFor={htmlFor ?? inputId}\n >\n <Flex\n alignItems=\"center\"\n className={cn(`${global.prefixCls}-input-root`, classNames?.root)}\n style={{ marginTop: '6px', ...styles?.root }}\n >\n {prefix && (\n <span\n className={cn(`${global.prefixCls}-input-prefix`, classNames?.prefix)}\n style={styles?.prefix}\n >\n {prefix}\n </span>\n )}\n\n <input\n {...props}\n ref={ref}\n id={inputId}\n className={cn(`${global.prefixCls}-input-content`, classNames?.content)}\n style={{ outline: 'none', ...styles?.content }}\n />\n\n {suffix && (\n <span\n className={cn(`${global.prefixCls}-input-suffix`, classNames?.suffix)}\n style={styles?.suffix}\n >\n {suffix}\n </span>\n )}\n </Flex>\n </Field>\n )\n }\n)\n\nInput.displayName = 'Input'\n","import React from 'react'\nimport { cn, useNSUI, Eye, EyeOff } from '@negative-space/system'\nimport { Input, type InputProps } from '.'\nimport { IconButton, type IconButtonProps } from '@negative-space/button'\n\nexport interface InputPasswordProps extends Omit<\n InputProps,\n 'classNames' | 'styles' | 'suffix' | 'type'\n> {\n classNames?: InputProps['classNames'] & {\n button?: string\n }\n styles?: InputProps['styles'] & {\n button?: React.CSSProperties\n }\n onToggleVisibility?: (visible: boolean) => void\n buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label'>\n}\n\nexport const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(\n ({ onToggleVisibility, classNames, styles, buttonProps, ...rest }, ref) => {\n const { global } = useNSUI()\n const [visible, setVisible] = React.useState(false)\n\n const handleToggle = () => {\n setVisible((prev) => {\n const next = !prev\n onToggleVisibility?.(next)\n return next\n })\n }\n\n return (\n <Input\n {...rest}\n ref={ref}\n type={visible ? 'text' : 'password'}\n data-visible={visible}\n classNames={{\n ...classNames,\n root: cn(classNames?.root, `${global.prefixCls}-input-password`)\n }}\n styles={styles}\n suffix={\n <IconButton\n {...buttonProps}\n onClick={handleToggle}\n aria-label={visible ? 'Hide password' : 'Show password'}\n className={classNames?.button}\n style={styles?.button}\n >\n {visible ? <EyeOff /> : <Eye />}\n </IconButton>\n }\n />\n )\n }\n)\n\nInputPassword.displayName = 'InputPassword'\n"]}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@negative-space/input",
3
+ "version": "1.0.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Headless Input component by Negative Space, providing accessible behavior without visual constraints",
8
+ "keywords": [
9
+ "data-entry",
10
+ "input",
11
+ "negative-space",
12
+ "nsui",
13
+ "ui"
14
+ ],
15
+ "license": "MIT",
16
+ "main": "dist/index.js",
17
+ "module": "dist/index.mjs",
18
+ "types": "dist/index.d.ts",
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/negative-space-ui/nsui",
25
+ "directory": "packages/ui/input"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/negative-space-ui/nsui/issues"
29
+ },
30
+ "dependencies": {
31
+ "@negative-space/button": "2.4.2",
32
+ "@negative-space/field": "1.0.1",
33
+ "@negative-space/flex": "1.2.2",
34
+ "@negative-space/system": "1.3.0"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "^19.2.3"
38
+ },
39
+ "clean-package": "../../../../clean-package.config.json",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "import": "./dist/index.mjs",
44
+ "require": "./dist/index.js"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "clean": "rimraf dist .turbo",
51
+ "dev": "pnpm build:fast --watch",
52
+ "lint": "eslint . --ext ts,tsx",
53
+ "typecheck": "tsc --noEmit"
54
+ }
55
+ }