@bento/input 0.1.0 → 0.1.1
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.cjs +59 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.cts.map +1 -0
- package/dist/{index.d.ts → index.d.mts} +8 -6
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +59 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +22 -15
- package/dist/index.js +0 -39
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,45 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#endregion
|
|
3
|
+
require("react");
|
|
4
|
+
let _bento_use_data_attributes = require("@bento/use-data-attributes");
|
|
5
|
+
let _bento_use_props = require("@bento/use-props");
|
|
6
|
+
let _bento_slots = require("@bento/slots");
|
|
7
|
+
let react_aria = require("react-aria");
|
|
8
|
+
let _react_aria_utils = require("@react-aria/utils");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
//#region src/index.tsx
|
|
11
|
+
/* v8 ignore next */
|
|
12
|
+
/**
|
|
13
|
+
* A universal input primitive component that renders an `<input>` element with React Aria interactions.
|
|
14
|
+
* Supports all HTML input types with proper accessibility, hover, and focus management.
|
|
15
|
+
*
|
|
16
|
+
* @component
|
|
17
|
+
* @param {InputProps} props - The properties passed to the Input component.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // Text input
|
|
22
|
+
* <Input type="text" placeholder="Enter text" />
|
|
23
|
+
*
|
|
24
|
+
* // Checkbox
|
|
25
|
+
* <Input type="checkbox" />
|
|
26
|
+
*
|
|
27
|
+
* // With render props
|
|
28
|
+
* <Input
|
|
29
|
+
* type="email"
|
|
30
|
+
* className={(state) => state.isFocusVisible ? 'focused' : ''}
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
const Input = (0, _bento_slots.withSlots)("BentoInput", function Input(...args) {
|
|
37
|
+
const { props, apply } = (0, _bento_use_props.useProps)(args);
|
|
38
|
+
const { autoFocus } = props;
|
|
39
|
+
const { isFocused, isFocusVisible, focusProps } = (0, react_aria.useFocusRing)({
|
|
40
|
+
isTextInput: true,
|
|
41
|
+
autoFocus
|
|
42
|
+
});
|
|
43
|
+
const { hoverProps, isHovered } = (0, react_aria.useHover)(props);
|
|
44
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
45
|
+
...apply((0, _react_aria_utils.mergeProps)(props, focusProps, hoverProps)),
|
|
46
|
+
...(0, _bento_use_data_attributes.useDataAttributes)({
|
|
47
|
+
focused: isFocused,
|
|
48
|
+
hovered: isHovered,
|
|
49
|
+
focusVisible: isFocusVisible,
|
|
50
|
+
disabled: props.disabled || false,
|
|
51
|
+
invalid: !!props["aria-invalid"] && props["aria-invalid"] !== "false",
|
|
52
|
+
readonly: props.readOnly || false,
|
|
53
|
+
required: props.required || false,
|
|
54
|
+
empty: props.value === "" || props.value === void 0 || props.value === null,
|
|
55
|
+
checked: props.type === "checkbox" || props.type === "radio" ? !!props.checked : void 0
|
|
56
|
+
})
|
|
57
|
+
});
|
|
41
58
|
});
|
|
42
|
-
|
|
59
|
+
//#endregion
|
|
43
60
|
exports.Input = Input;
|
|
44
|
-
|
|
61
|
+
|
|
45
62
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* v8 ignore next */\nimport React from 'react';\nimport type { InputHTMLAttributes } from 'react';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport { useFocusRing, useHover } from 'react-aria';\nimport { mergeProps } from '@react-aria/utils';\nimport type { HoverEvents } from 'react-aria';\n\n/**\n * Props for the Input component.\n */\nexport interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, keyof HoverEvents> {\n /** Whether the input should be focused on mount. */\n autoFocus?: boolean;\n}\n\n/**\n * A universal input primitive component that renders an `<input>` element with React Aria interactions.\n * Supports all HTML input types with proper accessibility, hover, and focus management.\n *\n * @component\n * @param {InputProps} props - The properties passed to the Input component.\n *\n * @example\n * ```tsx\n * // Text input\n * <Input type=\"text\" placeholder=\"Enter text\" />\n *\n * // Checkbox\n * <Input type=\"checkbox\" />\n *\n * // With render props\n * <Input\n * type=\"email\"\n * className={(state) => state.isFocusVisible ? 'focused' : ''}\n * />\n * ```\n *\n * @public\n */\nexport const Input = withSlots('BentoInput', function Input(...args: [InputProps, React.Ref<HTMLInputElement>?]) {\n const { props, apply } = useProps(args);\n const { autoFocus } = props;\n\n const { isFocused, isFocusVisible, focusProps } = useFocusRing({\n isTextInput: true,\n autoFocus: autoFocus\n });\n const { hoverProps, isHovered } = useHover(props);\n\n const mergedProps = mergeProps(props, focusProps, hoverProps);\n\n return (\n <input\n {...apply(mergedProps)}\n {...useDataAttributes({\n focused: isFocused,\n hovered: isHovered,\n focusVisible: isFocusVisible,\n disabled: props.disabled || false,\n invalid: !!props['aria-invalid'] && props['aria-invalid'] !== 'false',\n readonly: props.readOnly || false,\n required: props.required || false,\n empty: props.value === '' || props.value === undefined || props.value === null,\n checked: props.type === 'checkbox' || props.type === 'radio' ? !!props.checked : undefined\n })}\n />\n );\n}) as React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,SAAA,GAAA,aAAA,WAAkB,cAAc,SAAS,MAAM,GAAG,MAAkD;CAC/G,MAAM,EAAE,OAAO,WAAA,GAAA,iBAAA,UAAmB,IAAI;CACtC,MAAM,EAAE,cAAc;CAEtB,MAAM,EAAE,WAAW,gBAAgB,gBAAA,GAAA,WAAA,cAA4B;EAC7D,aAAa;EACF;CACb,CAAC;CACD,MAAM,EAAE,YAAY,eAAA,GAAA,WAAA,UAAuB,KAAK;CAIhD,OACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;EACE,GAAI,OAAA,GAAA,kBAAA,YAJuB,OAAO,YAAY,UAI1B,CAAC;EACrB,IAAA,GAAA,2BAAA,mBAAsB;GACpB,SAAS;GACT,SAAS;GACT,cAAc;GACd,UAAU,MAAM,YAAY;GAC5B,SAAS,CAAC,CAAC,MAAM,mBAAmB,MAAM,oBAAoB;GAC9D,UAAU,MAAM,YAAY;GAC5B,UAAU,MAAM,YAAY;GAC5B,OAAO,MAAM,UAAU,MAAM,MAAM,UAAU,KAAA,KAAa,MAAM,UAAU;GAC1E,SAAS,MAAM,SAAS,cAAc,MAAM,SAAS,UAAU,CAAC,CAAC,MAAM,UAAU,KAAA;EACnF,CAAC;CACF,CAAA;AAEL,CAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import React, { InputHTMLAttributes } from
|
|
2
|
-
import { HoverEvents } from
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { HoverEvents } from "react-aria";
|
|
3
3
|
|
|
4
|
+
//#region src/index.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Props for the Input component.
|
|
6
7
|
*/
|
|
7
8
|
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, keyof HoverEvents> {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/** Whether the input should be focused on mount. */
|
|
10
|
+
autoFocus?: boolean;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* A universal input primitive component that renders an `<input>` element with React Aria interactions.
|
|
@@ -33,5 +34,6 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, keyof H
|
|
|
33
34
|
* @public
|
|
34
35
|
*/
|
|
35
36
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
36
|
-
|
|
37
|
-
export { Input,
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Input, InputProps };
|
|
39
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;AAaA;;UAAiB,UAAA,SAAmB,IAAA,CAAK,mBAAA,CAAoB,gBAAA,SAAyB,WAAA;EAAzB;EAE3D,SAAA;AAAA;;;;;;;;;;AAAS;AA2BX;;;;;;;;;;;;;;cAAa,KAAA,EA4BP,KAAA,CAAM,yBAAA,CAA0B,UAAA,GAAa,KAAA,CAAM,aAAA,CAAc,gBAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import React, { InputHTMLAttributes } from
|
|
2
|
-
import { HoverEvents } from
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { HoverEvents } from "react-aria";
|
|
3
3
|
|
|
4
|
+
//#region src/index.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Props for the Input component.
|
|
6
7
|
*/
|
|
7
8
|
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, keyof HoverEvents> {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/** Whether the input should be focused on mount. */
|
|
10
|
+
autoFocus?: boolean;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* A universal input primitive component that renders an `<input>` element with React Aria interactions.
|
|
@@ -33,5 +34,6 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, keyof H
|
|
|
33
34
|
* @public
|
|
34
35
|
*/
|
|
35
36
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
36
|
-
|
|
37
|
-
export { Input,
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Input, InputProps };
|
|
39
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;AAaA;;UAAiB,UAAA,SAAmB,IAAA,CAAK,mBAAA,CAAoB,gBAAA,SAAyB,WAAA;EAAzB;EAE3D,SAAA;AAAA;;;;;;;;;;AAAS;AA2BX;;;;;;;;;;;;;;cAAa,KAAA,EA4BP,KAAA,CAAM,yBAAA,CAA0B,UAAA,GAAa,KAAA,CAAM,aAAA,CAAc,gBAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { useDataAttributes } from "@bento/use-data-attributes";
|
|
3
|
+
import { useProps } from "@bento/use-props";
|
|
4
|
+
import { withSlots } from "@bento/slots";
|
|
5
|
+
import { useFocusRing, useHover } from "react-aria";
|
|
6
|
+
import { mergeProps } from "@react-aria/utils";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/index.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A universal input primitive component that renders an `<input>` element with React Aria interactions.
|
|
11
|
+
* Supports all HTML input types with proper accessibility, hover, and focus management.
|
|
12
|
+
*
|
|
13
|
+
* @component
|
|
14
|
+
* @param {InputProps} props - The properties passed to the Input component.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* // Text input
|
|
19
|
+
* <Input type="text" placeholder="Enter text" />
|
|
20
|
+
*
|
|
21
|
+
* // Checkbox
|
|
22
|
+
* <Input type="checkbox" />
|
|
23
|
+
*
|
|
24
|
+
* // With render props
|
|
25
|
+
* <Input
|
|
26
|
+
* type="email"
|
|
27
|
+
* className={(state) => state.isFocusVisible ? 'focused' : ''}
|
|
28
|
+
* />
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
const Input = withSlots("BentoInput", function Input(...args) {
|
|
34
|
+
const { props, apply } = useProps(args);
|
|
35
|
+
const { autoFocus } = props;
|
|
36
|
+
const { isFocused, isFocusVisible, focusProps } = useFocusRing({
|
|
37
|
+
isTextInput: true,
|
|
38
|
+
autoFocus
|
|
39
|
+
});
|
|
40
|
+
const { hoverProps, isHovered } = useHover(props);
|
|
41
|
+
return /* @__PURE__ */ jsx("input", {
|
|
42
|
+
...apply(mergeProps(props, focusProps, hoverProps)),
|
|
43
|
+
...useDataAttributes({
|
|
44
|
+
focused: isFocused,
|
|
45
|
+
hovered: isHovered,
|
|
46
|
+
focusVisible: isFocusVisible,
|
|
47
|
+
disabled: props.disabled || false,
|
|
48
|
+
invalid: !!props["aria-invalid"] && props["aria-invalid"] !== "false",
|
|
49
|
+
readonly: props.readOnly || false,
|
|
50
|
+
required: props.required || false,
|
|
51
|
+
empty: props.value === "" || props.value === void 0 || props.value === null,
|
|
52
|
+
checked: props.type === "checkbox" || props.type === "radio" ? !!props.checked : void 0
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//#endregion
|
|
57
|
+
export { Input };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* v8 ignore next */\nimport React from 'react';\nimport type { InputHTMLAttributes } from 'react';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport { useFocusRing, useHover } from 'react-aria';\nimport { mergeProps } from '@react-aria/utils';\nimport type { HoverEvents } from 'react-aria';\n\n/**\n * Props for the Input component.\n */\nexport interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, keyof HoverEvents> {\n /** Whether the input should be focused on mount. */\n autoFocus?: boolean;\n}\n\n/**\n * A universal input primitive component that renders an `<input>` element with React Aria interactions.\n * Supports all HTML input types with proper accessibility, hover, and focus management.\n *\n * @component\n * @param {InputProps} props - The properties passed to the Input component.\n *\n * @example\n * ```tsx\n * // Text input\n * <Input type=\"text\" placeholder=\"Enter text\" />\n *\n * // Checkbox\n * <Input type=\"checkbox\" />\n *\n * // With render props\n * <Input\n * type=\"email\"\n * className={(state) => state.isFocusVisible ? 'focused' : ''}\n * />\n * ```\n *\n * @public\n */\nexport const Input = withSlots('BentoInput', function Input(...args: [InputProps, React.Ref<HTMLInputElement>?]) {\n const { props, apply } = useProps(args);\n const { autoFocus } = props;\n\n const { isFocused, isFocusVisible, focusProps } = useFocusRing({\n isTextInput: true,\n autoFocus: autoFocus\n });\n const { hoverProps, isHovered } = useHover(props);\n\n const mergedProps = mergeProps(props, focusProps, hoverProps);\n\n return (\n <input\n {...apply(mergedProps)}\n {...useDataAttributes({\n focused: isFocused,\n hovered: isHovered,\n focusVisible: isFocusVisible,\n disabled: props.disabled || false,\n invalid: !!props['aria-invalid'] && props['aria-invalid'] !== 'false',\n readonly: props.readOnly || false,\n required: props.required || false,\n empty: props.value === '' || props.value === undefined || props.value === null,\n checked: props.type === 'checkbox' || props.type === 'radio' ? !!props.checked : undefined\n })}\n />\n );\n}) as React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,QAAQ,UAAU,cAAc,SAAS,MAAM,GAAG,MAAkD;CAC/G,MAAM,EAAE,OAAO,UAAU,SAAS,IAAI;CACtC,MAAM,EAAE,cAAc;CAEtB,MAAM,EAAE,WAAW,gBAAgB,eAAe,aAAa;EAC7D,aAAa;EACF;CACb,CAAC;CACD,MAAM,EAAE,YAAY,cAAc,SAAS,KAAK;CAIhD,OACE,oBAAC,SAAD;EACE,GAAI,MAJY,WAAW,OAAO,YAAY,UAI1B,CAAC;EACrB,GAAI,kBAAkB;GACpB,SAAS;GACT,SAAS;GACT,cAAc;GACd,UAAU,MAAM,YAAY;GAC5B,SAAS,CAAC,CAAC,MAAM,mBAAmB,MAAM,oBAAoB;GAC9D,UAAU,MAAM,YAAY;GAC5B,UAAU,MAAM,YAAY;GAC5B,OAAO,MAAM,UAAU,MAAM,MAAM,UAAU,KAAA,KAAa,MAAM,UAAU;GAC1E,SAAS,MAAM,SAAS,cAAc,MAAM,SAAS,UAAU,CAAC,CAAC,MAAM,UAAU,KAAA;EACnF,CAAC;CACF,CAAA;AAEL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento/input",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Universal input primitive component supporting all HTML input types",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "
|
|
10
|
-
"lint": "biome lint &&
|
|
11
|
-
"posttest": "npm run lint",
|
|
12
|
-
"pretest": "npm run build",
|
|
9
|
+
"build": "tsdown",
|
|
10
|
+
"lint": "biome lint && tsgo --noEmit",
|
|
13
11
|
"test": "vitest --run",
|
|
14
|
-
"test:watch": "vitest"
|
|
12
|
+
"test:watch": "vitest",
|
|
13
|
+
"typecheck": "tsgo --noEmit -p tsconfig.json"
|
|
15
14
|
},
|
|
16
15
|
"repository": {
|
|
17
16
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/godaddy/
|
|
17
|
+
"url": "git+https://github.com/godaddy/antares.git"
|
|
19
18
|
},
|
|
20
19
|
"keywords": [
|
|
21
20
|
"accessibility",
|
|
@@ -29,9 +28,9 @@
|
|
|
29
28
|
"author": "GoDaddy Operating Company, LLC",
|
|
30
29
|
"license": "MIT",
|
|
31
30
|
"bugs": {
|
|
32
|
-
"url": "https://github.com/godaddy/
|
|
31
|
+
"url": "https://github.com/godaddy/antares/issues"
|
|
33
32
|
},
|
|
34
|
-
"homepage": "https://github.com/godaddy/
|
|
33
|
+
"homepage": "https://github.com/godaddy/antares#readme",
|
|
35
34
|
"files": [
|
|
36
35
|
"dist",
|
|
37
36
|
"src",
|
|
@@ -42,9 +41,17 @@
|
|
|
42
41
|
"@bento/slots": "^0.3.0",
|
|
43
42
|
"@bento/text": "^0.1.4",
|
|
44
43
|
"@bento/use-data-attributes": "^0.1.1",
|
|
45
|
-
"@bento/use-props": "^0.2.
|
|
46
|
-
"@react-aria/utils": "^3.
|
|
47
|
-
"react-aria": "^3.
|
|
44
|
+
"@bento/use-props": "^0.2.3",
|
|
45
|
+
"@react-aria/utils": "^3.34.0",
|
|
46
|
+
"react-aria": "^3.48.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/react": "^19.2.15",
|
|
50
|
+
"@types/react-dom": "^19.2.3",
|
|
51
|
+
"tsdown": "^0.22.1",
|
|
52
|
+
"typescript": "^6.0.3",
|
|
53
|
+
"vitest": "^4.1.7",
|
|
54
|
+
"vitest-browser-react": "^2.2.0"
|
|
48
55
|
},
|
|
49
56
|
"peerDependencies": {
|
|
50
57
|
"react": "18.x || 19.x",
|
|
@@ -53,8 +60,8 @@
|
|
|
53
60
|
"exports": {
|
|
54
61
|
".": {
|
|
55
62
|
"import": {
|
|
56
|
-
"types": "./dist/index.d.
|
|
57
|
-
"default": "./dist/index.
|
|
63
|
+
"types": "./dist/index.d.mts",
|
|
64
|
+
"default": "./dist/index.mjs"
|
|
58
65
|
},
|
|
59
66
|
"require": {
|
|
60
67
|
"types": "./dist/index.d.cts",
|
package/dist/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useDataAttributes } from '@bento/use-data-attributes';
|
|
3
|
-
import { useProps } from '@bento/use-props';
|
|
4
|
-
import { withSlots } from '@bento/slots';
|
|
5
|
-
import { useFocusRing, useHover } from 'react-aria';
|
|
6
|
-
import { mergeProps } from '@react-aria/utils';
|
|
7
|
-
|
|
8
|
-
// src/index.tsx
|
|
9
|
-
var Input = withSlots("BentoInput", function Input2(...args) {
|
|
10
|
-
const { props, apply } = useProps(args);
|
|
11
|
-
const { autoFocus } = props;
|
|
12
|
-
const { isFocused, isFocusVisible, focusProps } = useFocusRing({
|
|
13
|
-
isTextInput: true,
|
|
14
|
-
autoFocus
|
|
15
|
-
});
|
|
16
|
-
const { hoverProps, isHovered } = useHover(props);
|
|
17
|
-
const mergedProps = mergeProps(props, focusProps, hoverProps);
|
|
18
|
-
return /* @__PURE__ */ React.createElement(
|
|
19
|
-
"input",
|
|
20
|
-
{
|
|
21
|
-
...apply(mergedProps),
|
|
22
|
-
...useDataAttributes({
|
|
23
|
-
focused: isFocused,
|
|
24
|
-
hovered: isHovered,
|
|
25
|
-
focusVisible: isFocusVisible,
|
|
26
|
-
disabled: props.disabled || false,
|
|
27
|
-
invalid: !!props["aria-invalid"] && props["aria-invalid"] !== "false",
|
|
28
|
-
readonly: props.readOnly || false,
|
|
29
|
-
required: props.required || false,
|
|
30
|
-
empty: props.value === "" || props.value === void 0 || props.value === null,
|
|
31
|
-
checked: props.type === "checkbox" || props.type === "radio" ? !!props.checked : void 0
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export { Input };
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"names":["Input"],"mappings":";;;;;;;;AA0CO,IAAM,KAAA,GAAQ,SAAA,CAAU,YAAA,EAAc,SAASA,UAAS,IAAA,EAAkD;AAC/G,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAM,GAAI,SAAS,IAAI,CAAA;AACtC,EAAA,MAAM,EAAE,WAAU,GAAI,KAAA;AAEtB,EAAA,MAAM,EAAE,SAAA,EAAW,cAAA,EAAgB,UAAA,KAAe,YAAA,CAAa;AAAA,IAC7D,WAAA,EAAa,IAAA;AAAA,IACb;AAAA,GACD,CAAA;AACD,EAAA,MAAM,EAAE,UAAA,EAAY,SAAA,EAAU,GAAI,SAAS,KAAK,CAAA;AAEhD,EAAA,MAAM,WAAA,GAAc,UAAA,CAAW,KAAA,EAAO,UAAA,EAAY,UAAU,CAAA;AAE5D,EAAA,uBACE,KAAA,CAAA,aAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACE,GAAG,MAAM,WAAW,CAAA;AAAA,MACpB,GAAG,iBAAA,CAAkB;AAAA,QACpB,OAAA,EAAS,SAAA;AAAA,QACT,OAAA,EAAS,SAAA;AAAA,QACT,YAAA,EAAc,cAAA;AAAA,QACd,QAAA,EAAU,MAAM,QAAA,IAAY,KAAA;AAAA,QAC5B,OAAA,EAAS,CAAC,CAAC,KAAA,CAAM,cAAc,CAAA,IAAK,KAAA,CAAM,cAAc,CAAA,KAAM,OAAA;AAAA,QAC9D,QAAA,EAAU,MAAM,QAAA,IAAY,KAAA;AAAA,QAC5B,QAAA,EAAU,MAAM,QAAA,IAAY,KAAA;AAAA,QAC5B,KAAA,EAAO,MAAM,KAAA,KAAU,EAAA,IAAM,MAAM,KAAA,KAAU,MAAA,IAAa,MAAM,KAAA,KAAU,IAAA;AAAA,QAC1E,OAAA,EAAS,KAAA,CAAM,IAAA,KAAS,UAAA,IAAc,KAAA,CAAM,SAAS,OAAA,GAAU,CAAC,CAAC,KAAA,CAAM,OAAA,GAAU;AAAA,OAClF;AAAA;AAAA,GACH;AAEJ,CAAC","file":"index.js","sourcesContent":["/* v8 ignore next */\nimport React from 'react';\nimport type { InputHTMLAttributes } from 'react';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport { useFocusRing, useHover } from 'react-aria';\nimport { mergeProps } from '@react-aria/utils';\nimport type { HoverEvents } from 'react-aria';\n\n/**\n * Props for the Input component.\n */\nexport interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, keyof HoverEvents> {\n /** Whether the input should be focused on mount. */\n autoFocus?: boolean;\n}\n\n/**\n * A universal input primitive component that renders an `<input>` element with React Aria interactions.\n * Supports all HTML input types with proper accessibility, hover, and focus management.\n *\n * @component\n * @param {InputProps} props - The properties passed to the Input component.\n *\n * @example\n * ```tsx\n * // Text input\n * <Input type=\"text\" placeholder=\"Enter text\" />\n *\n * // Checkbox\n * <Input type=\"checkbox\" />\n *\n * // With render props\n * <Input\n * type=\"email\"\n * className={(state) => state.isFocusVisible ? 'focused' : ''}\n * />\n * ```\n *\n * @public\n */\nexport const Input = withSlots('BentoInput', function Input(...args: [InputProps, React.Ref<HTMLInputElement>?]) {\n const { props, apply } = useProps(args);\n const { autoFocus } = props;\n\n const { isFocused, isFocusVisible, focusProps } = useFocusRing({\n isTextInput: true,\n autoFocus: autoFocus\n });\n const { hoverProps, isHovered } = useHover(props);\n\n const mergedProps = mergeProps(props, focusProps, hoverProps);\n\n return (\n <input\n {...apply(mergedProps)}\n {...useDataAttributes({\n focused: isFocused,\n hovered: isHovered,\n focusVisible: isFocusVisible,\n disabled: props.disabled || false,\n invalid: !!props['aria-invalid'] && props['aria-invalid'] !== 'false',\n readonly: props.readOnly || false,\n required: props.required || false,\n empty: props.value === '' || props.value === undefined || props.value === null,\n checked: props.type === 'checkbox' || props.type === 'radio' ? !!props.checked : undefined\n })}\n />\n );\n}) as React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;\n"]}
|