@asnewyla/unstyled-input 0.2.0 → 0.2.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.js +34 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/dist/test-utils.d.mts +3 -0
- package/dist/test-utils.d.ts +3 -0
- package/dist/test-utils.js +35 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/test-utils.mjs +11 -0
- package/dist/test-utils.mjs.map +1 -0
- package/package.json +19 -4
package/dist/index.js
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
'use
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
20
|
|
|
3
|
-
|
|
4
|
-
var
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
UnstyledInput: () => UnstyledInput
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
5
27
|
|
|
6
28
|
// src/components/UnstyledInput.tsx
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
7
31
|
function booleanToString(value) {
|
|
8
32
|
return value ? "true" : void 0;
|
|
9
33
|
}
|
|
@@ -17,7 +41,7 @@ function UnstyledInputInner({
|
|
|
17
41
|
onBlur,
|
|
18
42
|
...rest
|
|
19
43
|
}, ref) {
|
|
20
|
-
const [focused, setFocused] =
|
|
44
|
+
const [focused, setFocused] = (0, import_react.useState)(false);
|
|
21
45
|
const handleFocus = (e) => {
|
|
22
46
|
setFocused(true);
|
|
23
47
|
onFocus?.(e);
|
|
@@ -26,7 +50,7 @@ function UnstyledInputInner({
|
|
|
26
50
|
setFocused(false);
|
|
27
51
|
onBlur?.(e);
|
|
28
52
|
};
|
|
29
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
30
54
|
"input",
|
|
31
55
|
{
|
|
32
56
|
defaultValue,
|
|
@@ -44,10 +68,11 @@ function UnstyledInputInner({
|
|
|
44
68
|
}
|
|
45
69
|
);
|
|
46
70
|
}
|
|
47
|
-
var UnstyledInput =
|
|
71
|
+
var UnstyledInput = (0, import_react.forwardRef)(
|
|
48
72
|
UnstyledInputInner
|
|
49
73
|
);
|
|
50
|
-
|
|
51
|
-
exports
|
|
52
|
-
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
UnstyledInput
|
|
77
|
+
});
|
|
53
78
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/UnstyledInput.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/UnstyledInput.tsx"],"sourcesContent":["export { type UnstyledInputProps, UnstyledInput } from './components';\n","import { type ForwardedRef, forwardRef, useState } from 'react';\n\nexport type UnstyledInputProps = {\n defaultValue?: string;\n value?: string;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n disabled?: boolean;\n invalid?: boolean;\n} & Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'defaultValue' | 'value' | 'onChange' | 'disabled' | 'invalid'\n>;\n\nfunction booleanToString(value: boolean | undefined): string | undefined {\n return value ? 'true' : undefined;\n}\n\nfunction UnstyledInputInner(\n {\n defaultValue,\n value,\n onChange,\n disabled,\n invalid,\n onFocus,\n onBlur,\n ...rest\n }: UnstyledInputProps,\n ref: ForwardedRef<HTMLInputElement>,\n) {\n const [focused, setFocused] = useState(false);\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(e);\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(e);\n };\n\n return (\n <input\n defaultValue={defaultValue}\n value={value}\n onChange={onChange}\n data-focused={booleanToString(focused)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n disabled={disabled}\n data-disabled={booleanToString(disabled)}\n data-invalid={booleanToString(invalid)}\n aria-invalid={invalid ? 'true' : undefined}\n ref={ref}\n {...rest}\n />\n );\n}\n\nexport const UnstyledInput = forwardRef<HTMLInputElement, UnstyledInputProps>(\n UnstyledInputInner,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAwD;AA2CpD;AA9BJ,SAAS,gBAAgB,OAAgD;AACvE,SAAO,QAAQ,SAAS;AAC1B;AAEA,SAAS,mBACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAE5C,QAAM,cAAc,CAAC,MAA0C;AAC7D,eAAW,IAAI;AACf,cAAU,CAAC;AAAA,EACb;AAEA,QAAM,aAAa,CAAC,MAA0C;AAC5D,eAAW,KAAK;AAChB,aAAS,CAAC;AAAA,EACZ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAc,gBAAgB,OAAO;AAAA,MACrC,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA,iBAAe,gBAAgB,QAAQ;AAAA,MACvC,gBAAc,gBAAgB,OAAO;AAAA,MACrC,gBAAc,UAAU,SAAS;AAAA,MACjC;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEO,IAAM,oBAAgB;AAAA,EAC3B;AACF;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
'use client';
|
|
3
2
|
|
|
4
3
|
// src/components/UnstyledInput.tsx
|
|
4
|
+
import { forwardRef, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
function booleanToString(value) {
|
|
6
7
|
return value ? "true" : void 0;
|
|
7
8
|
}
|
|
@@ -45,7 +46,7 @@ function UnstyledInputInner({
|
|
|
45
46
|
var UnstyledInput = forwardRef(
|
|
46
47
|
UnstyledInputInner
|
|
47
48
|
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
export {
|
|
50
|
+
UnstyledInput
|
|
51
|
+
};
|
|
51
52
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/UnstyledInput.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../src/components/UnstyledInput.tsx"],"sourcesContent":["import { type ForwardedRef, forwardRef, useState } from 'react';\n\nexport type UnstyledInputProps = {\n defaultValue?: string;\n value?: string;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n disabled?: boolean;\n invalid?: boolean;\n} & Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'defaultValue' | 'value' | 'onChange' | 'disabled' | 'invalid'\n>;\n\nfunction booleanToString(value: boolean | undefined): string | undefined {\n return value ? 'true' : undefined;\n}\n\nfunction UnstyledInputInner(\n {\n defaultValue,\n value,\n onChange,\n disabled,\n invalid,\n onFocus,\n onBlur,\n ...rest\n }: UnstyledInputProps,\n ref: ForwardedRef<HTMLInputElement>,\n) {\n const [focused, setFocused] = useState(false);\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(e);\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(e);\n };\n\n return (\n <input\n defaultValue={defaultValue}\n value={value}\n onChange={onChange}\n data-focused={booleanToString(focused)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n disabled={disabled}\n data-disabled={booleanToString(disabled)}\n data-invalid={booleanToString(invalid)}\n aria-invalid={invalid ? 'true' : undefined}\n ref={ref}\n {...rest}\n />\n );\n}\n\nexport const UnstyledInput = forwardRef<HTMLInputElement, UnstyledInputProps>(\n UnstyledInputInner,\n);\n"],"mappings":";;;AAAA,SAA4B,YAAY,gBAAgB;AA2CpD;AA9BJ,SAAS,gBAAgB,OAAgD;AACvE,SAAO,QAAQ,SAAS;AAC1B;AAEA,SAAS,mBACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,QAAM,cAAc,CAAC,MAA0C;AAC7D,eAAW,IAAI;AACf,cAAU,CAAC;AAAA,EACb;AAEA,QAAM,aAAa,CAAC,MAA0C;AAC5D,eAAW,KAAK;AAChB,aAAS,CAAC;AAAA,EACZ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAc,gBAAgB,OAAO;AAAA,MACrC,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA,iBAAe,gBAAgB,QAAQ;AAAA,MACvC,gBAAc,gBAAgB,OAAO;AAAA,MACrC,gBAAc,UAAU,SAAS;AAAA,MACjC;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEO,IAAM,gBAAgB;AAAA,EAC3B;AACF;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/test-utils.ts
|
|
22
|
+
var test_utils_exports = {};
|
|
23
|
+
__export(test_utils_exports, {
|
|
24
|
+
getInput: () => getInput
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(test_utils_exports);
|
|
27
|
+
var import_react = require("@testing-library/react");
|
|
28
|
+
function getInput(name) {
|
|
29
|
+
return import_react.screen.getByRole("textbox", name === void 0 ? void 0 : { name });
|
|
30
|
+
}
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
getInput
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test-utils.ts"],"sourcesContent":["import { screen } from '@testing-library/react';\n\nexport function getInput(name?: string | RegExp): HTMLElement {\n return screen.getByRole('textbox', name === undefined ? undefined : { name });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEhB,SAAS,SAAS,MAAqC;AAC5D,SAAO,oBAAO,UAAU,WAAW,SAAS,SAAY,SAAY,EAAE,KAAK,CAAC;AAC9E;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/test-utils.ts
|
|
4
|
+
import { screen } from "@testing-library/react";
|
|
5
|
+
function getInput(name) {
|
|
6
|
+
return screen.getByRole("textbox", name === void 0 ? void 0 : { name });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
getInput
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=test-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test-utils.ts"],"sourcesContent":["import { screen } from '@testing-library/react';\n\nexport function getInput(name?: string | RegExp): HTMLElement {\n return screen.getByRole('textbox', name === undefined ? undefined : { name });\n}\n"],"mappings":";;;AAAA,SAAS,cAAc;AAEhB,SAAS,SAAS,MAAqC;AAC5D,SAAO,OAAO,UAAU,WAAW,SAAS,SAAY,SAAY,EAAE,KAAK,CAAC;AAC9E;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asnewyla/unstyled-input",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Unstyled text input primitive with accessibility",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,9 +16,14 @@
|
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
19
20
|
"import": "./dist/index.mjs",
|
|
20
|
-
"require": "./dist/index.js"
|
|
21
|
-
|
|
21
|
+
"require": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./test-utils": {
|
|
24
|
+
"types": "./dist/test-utils.d.ts",
|
|
25
|
+
"import": "./dist/test-utils.mjs",
|
|
26
|
+
"require": "./dist/test-utils.js"
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
"files": [
|
|
@@ -33,7 +38,17 @@
|
|
|
33
38
|
],
|
|
34
39
|
"peerDependencies": {
|
|
35
40
|
"react": "^18.0.0 || ^19.0.0",
|
|
36
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
41
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
42
|
+
"@testing-library/react": "^16.0.0",
|
|
43
|
+
"@testing-library/user-event": "^14.5.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@testing-library/react": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"@testing-library/user-event": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
37
52
|
},
|
|
38
53
|
"devDependencies": {
|
|
39
54
|
"react": "^18.3.0",
|