@yamada-ui/input 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.
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/input-group.tsx
21
+ var input_group_exports = {};
22
+ __export(input_group_exports, {
23
+ InputGroup: () => InputGroup,
24
+ useInputGroup: () => useInputGroup
25
+ });
26
+ module.exports = __toCommonJS(input_group_exports);
27
+ var import_core4 = require("@yamada-ui/core");
28
+ var import_file_input = require("@yamada-ui/file-input");
29
+ var import_use_token = require("@yamada-ui/use-token");
30
+ var import_utils4 = require("@yamada-ui/utils");
31
+ var import_react = require("react");
32
+
33
+ // src/input.tsx
34
+ var import_core = require("@yamada-ui/core");
35
+ var import_form_control = require("@yamada-ui/form-control");
36
+ var import_utils = require("@yamada-ui/utils");
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var Input = (0, import_core.forwardRef)((props, ref) => {
39
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Input", props);
40
+ let { className, htmlSize, ...rest } = (0, import_core.omitThemeProps)(mergedProps);
41
+ rest = (0, import_form_control.useFormControlProps)(rest);
42
+ const css = { ...styles.field };
43
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44
+ import_core.ui.input,
45
+ {
46
+ ref,
47
+ className: (0, import_utils.cx)("ui-input", className),
48
+ size: htmlSize,
49
+ __css: css,
50
+ ...rest
51
+ }
52
+ );
53
+ });
54
+
55
+ // src/input-addon.tsx
56
+ var import_core2 = require("@yamada-ui/core");
57
+ var import_utils2 = require("@yamada-ui/utils");
58
+ var import_jsx_runtime2 = require("react/jsx-runtime");
59
+ var InputAddon = (0, import_core2.forwardRef)(
60
+ ({ className, placement = "left", ...rest }, ref) => {
61
+ const styles = useInputGroup();
62
+ const placementStyles = {
63
+ left: {
64
+ me: "-1px",
65
+ roundedRight: 0,
66
+ borderEndColor: "transparent"
67
+ },
68
+ right: {
69
+ ms: "-1px",
70
+ roundedLeft: 0,
71
+ borderStartColor: "transparent"
72
+ }
73
+ };
74
+ const css = {
75
+ flex: "0 0 auto",
76
+ w: "auto",
77
+ display: "flex",
78
+ alignItems: "center",
79
+ whiteSpace: "nowrap",
80
+ ...styles.addon,
81
+ ...placementStyles[placement]
82
+ };
83
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-input-addon", className), __css: css, ...rest });
84
+ }
85
+ );
86
+ var InputLeftAddon = (0, import_core2.forwardRef)(({ className, ...rest }, ref) => {
87
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
88
+ InputAddon,
89
+ {
90
+ ref,
91
+ className: (0, import_utils2.cx)("ui-input-addon-left", className),
92
+ placement: "left",
93
+ ...rest
94
+ }
95
+ );
96
+ });
97
+ var InputRightAddon = (0, import_core2.forwardRef)(({ className, ...rest }, ref) => {
98
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
99
+ InputAddon,
100
+ {
101
+ ref,
102
+ className: (0, import_utils2.cx)("ui-input-addon-right", className),
103
+ placement: "right",
104
+ ...rest
105
+ }
106
+ );
107
+ });
108
+
109
+ // src/input-element.tsx
110
+ var import_core3 = require("@yamada-ui/core");
111
+ var import_utils3 = require("@yamada-ui/utils");
112
+ var import_jsx_runtime3 = require("react/jsx-runtime");
113
+ var InputElement = (0, import_core3.forwardRef)(
114
+ ({ className, isClick = false, placement = "left", ...rest }, ref) => {
115
+ var _a, _b, _c, _d, _e, _f, _g, _h;
116
+ const styles = useInputGroup();
117
+ const css = {
118
+ position: "absolute",
119
+ top: "0",
120
+ [placement === "left" ? "insetStart" : "insetEnd"]: "0",
121
+ zIndex: 2,
122
+ display: "flex",
123
+ alignItems: "center",
124
+ justifyContent: "center",
125
+ w: (_g = (_e = (_c = (_a = styles.field) == null ? void 0 : _a.height) != null ? _c : (_b = styles.field) == null ? void 0 : _b.h) != null ? _e : (_d = styles.field) == null ? void 0 : _d.minHeight) != null ? _g : (_f = styles.field) == null ? void 0 : _f.minH,
126
+ h: "full",
127
+ fontSize: (_h = styles.field) == null ? void 0 : _h.fontSize,
128
+ pointerEvents: isClick ? "auto" : "none",
129
+ cursor: isClick ? "pointer" : "auto",
130
+ ...styles.element
131
+ };
132
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.div, { ref, className: (0, import_utils3.cx)("ui-input-element", className), __css: css, ...rest });
133
+ }
134
+ );
135
+ var InputLeftElement = (0, import_core3.forwardRef)(
136
+ ({ className, ...rest }, ref) => {
137
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
138
+ InputElement,
139
+ {
140
+ ref,
141
+ className: (0, import_utils3.cx)("ui-input-element-left", className),
142
+ placement: "left",
143
+ ...rest
144
+ }
145
+ );
146
+ }
147
+ );
148
+ var InputRightElement = (0, import_core3.forwardRef)(
149
+ ({ className, ...rest }, ref) => {
150
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
151
+ InputElement,
152
+ {
153
+ ref,
154
+ className: (0, import_utils3.cx)("ui-input-element-right", className),
155
+ placement: "right",
156
+ ...rest
157
+ }
158
+ );
159
+ }
160
+ );
161
+
162
+ // src/input-group.tsx
163
+ var import_jsx_runtime4 = require("react/jsx-runtime");
164
+ var [InputGroupProvider, useInputGroup] = (0, import_utils4.createContext)({
165
+ name: "InputGroupContext",
166
+ errorMessage: `useInputGroup returned is 'undefined'. Seems you forgot to wrap the components in "<InputGroup />" `
167
+ });
168
+ var InputGroup = (0, import_core4.forwardRef)((props, ref) => {
169
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
170
+ const [styles] = (0, import_core4.useMultiComponentStyle)("Input", props);
171
+ const { className, children, ...rest } = (0, import_core4.omitThemeProps)(props);
172
+ const css = {
173
+ width: "100%",
174
+ display: "flex",
175
+ position: "relative"
176
+ };
177
+ const groupProps = {};
178
+ const minHeight = (_g = (_e = (0, import_use_token.useToken)("sizes", (_c = (_a = styles.field) == null ? void 0 : _a.minHeight) != null ? _c : (_b = styles.field) == null ? void 0 : _b.minH)) != null ? _e : (_d = styles.field) == null ? void 0 : _d.minHeight) != null ? _g : (_f = styles.field) == null ? void 0 : _f.minH;
179
+ const height = (_n = (_l = (0, import_use_token.useToken)("sizes", (_j = (_h = styles.field) == null ? void 0 : _h.height) != null ? _j : (_i = styles.field) == null ? void 0 : _i.h)) != null ? _l : (_k = styles.field) == null ? void 0 : _k.height) != null ? _n : (_m = styles.field) == null ? void 0 : _m.h;
180
+ const validChildren = (0, import_utils4.getValidChildren)(children);
181
+ validChildren.forEach((child) => {
182
+ if ((minHeight || height) && child.type === InputLeftElement)
183
+ groupProps.paddingStart = height != null ? height : minHeight;
184
+ if ((minHeight || height) && child.type === InputRightElement)
185
+ groupProps.paddingEnd = height != null ? height : minHeight;
186
+ if (child.type === InputLeftAddon)
187
+ groupProps.roundedLeft = 0;
188
+ if (child.type === InputRightAddon)
189
+ groupProps.roundedRight = 0;
190
+ });
191
+ const cloneChildren = validChildren.map((child) => {
192
+ var _a2, _b2;
193
+ const childProps = (0, import_utils4.filterUndefined)({
194
+ size: ((_a2 = child.props) == null ? void 0 : _a2.size) || props.size,
195
+ variant: ((_b2 = child.props) == null ? void 0 : _b2.variant) || props.variant,
196
+ ...child.props
197
+ });
198
+ return child.type !== Input && child.type !== import_file_input.FileInput ? (0, import_react.cloneElement)(child, childProps) : (0, import_react.cloneElement)(child, Object.assign(childProps, groupProps));
199
+ });
200
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InputGroupProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
201
+ import_core4.ui.div,
202
+ {
203
+ ref,
204
+ className: (0, import_utils4.cx)("ui-input-group", className),
205
+ role: "group",
206
+ __css: css,
207
+ ...rest,
208
+ children: cloneChildren
209
+ }
210
+ ) });
211
+ });
212
+ // Annotate the CommonJS export names for ESM import in node:
213
+ 0 && (module.exports = {
214
+ InputGroup,
215
+ useInputGroup
216
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ InputGroup,
3
+ useInputGroup
4
+ } from "./chunk-5IBH3I64.mjs";
5
+ import "./chunk-BFONSAR4.mjs";
6
+ export {
7
+ InputGroup,
8
+ useInputGroup
9
+ };
@@ -0,0 +1,13 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, ThemeProps, CSSUIProps } from '@yamada-ui/core';
3
+ import { FormControlOptions } from '@yamada-ui/form-control';
4
+
5
+ type InputOptions = {
6
+ focusBorderColor?: CSSUIProps<'unresponsive'>['borderColor'];
7
+ errorBorderColor?: CSSUIProps<'unresponsive'>['borderColor'];
8
+ htmlSize?: number;
9
+ };
10
+ type InputProps = Omit<HTMLUIProps<'input'>, 'disabled' | 'required' | 'readOnly' | 'size'> & ThemeProps<'Input'> & InputOptions & FormControlOptions;
11
+ declare const Input: _yamada_ui_core.Component<"input", InputProps>;
12
+
13
+ export { Input, InputProps };
package/dist/input.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/input.tsx
21
+ var input_exports = {};
22
+ __export(input_exports, {
23
+ Input: () => Input
24
+ });
25
+ module.exports = __toCommonJS(input_exports);
26
+ var import_core = require("@yamada-ui/core");
27
+ var import_form_control = require("@yamada-ui/form-control");
28
+ var import_utils = require("@yamada-ui/utils");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var Input = (0, import_core.forwardRef)((props, ref) => {
31
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Input", props);
32
+ let { className, htmlSize, ...rest } = (0, import_core.omitThemeProps)(mergedProps);
33
+ rest = (0, import_form_control.useFormControlProps)(rest);
34
+ const css = { ...styles.field };
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
36
+ import_core.ui.input,
37
+ {
38
+ ref,
39
+ className: (0, import_utils.cx)("ui-input", className),
40
+ size: htmlSize,
41
+ __css: css,
42
+ ...rest
43
+ }
44
+ );
45
+ });
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ Input
49
+ });
package/dist/input.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import {
2
+ Input
3
+ } from "./chunk-BFONSAR4.mjs";
4
+ export {
5
+ Input
6
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@yamada-ui/input",
3
+ "version": "0.1.0",
4
+ "description": "Yamada UI input component",
5
+ "keywords": [
6
+ "yamada",
7
+ "yamada ui",
8
+ "react",
9
+ "emotion",
10
+ "component",
11
+ "input",
12
+ "ui",
13
+ "uikit",
14
+ "styled",
15
+ "style-props",
16
+ "styled-component",
17
+ "css-in-js"
18
+ ],
19
+ "author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
20
+ "license": "MIT",
21
+ "main": "dist/index.js",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "sideEffects": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/hirotomoyamada/yamada-ui",
32
+ "directory": "packages/components/input"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
36
+ },
37
+ "dependencies": {
38
+ "@yamada-ui/core": "0.1.0",
39
+ "@yamada-ui/utils": "0.1.0",
40
+ "@yamada-ui/file-input": "0.1.0",
41
+ "@yamada-ui/form-control": "0.1.0",
42
+ "@yamada-ui/use-token": "0.1.0"
43
+ },
44
+ "devDependencies": {
45
+ "react": "^18.0.0",
46
+ "clean-package": "2.2.0"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=18"
50
+ },
51
+ "clean-package": "../../../clean-package.config.json",
52
+ "tsup": {
53
+ "clean": true,
54
+ "target": "es2019",
55
+ "format": [
56
+ "cjs",
57
+ "esm"
58
+ ]
59
+ },
60
+ "module": "dist/index.mjs",
61
+ "types": "dist/index.d.ts",
62
+ "exports": {
63
+ ".": {
64
+ "types": "./dist/index.d.ts",
65
+ "import": "./dist/index.mjs",
66
+ "require": "./dist/index.js"
67
+ },
68
+ "./package.json": "./package.json"
69
+ },
70
+ "scripts": {
71
+ "dev": "pnpm build:fast -- --watch",
72
+ "build": "tsup src --dts",
73
+ "build:fast": "tsup src",
74
+ "clean": "rimraf dist .turbo",
75
+ "typecheck": "tsc --noEmit",
76
+ "gen:docs": "tsx ../../../scripts/generate-docs"
77
+ }
78
+ }