@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-addon.tsx
21
+ var input_addon_exports = {};
22
+ __export(input_addon_exports, {
23
+ InputLeftAddon: () => InputLeftAddon,
24
+ InputRightAddon: () => InputRightAddon
25
+ });
26
+ module.exports = __toCommonJS(input_addon_exports);
27
+ var import_core4 = require("@yamada-ui/core");
28
+ var import_utils4 = require("@yamada-ui/utils");
29
+
30
+ // src/input.tsx
31
+ var import_core = require("@yamada-ui/core");
32
+ var import_form_control = require("@yamada-ui/form-control");
33
+ var import_utils = require("@yamada-ui/utils");
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var Input = (0, import_core.forwardRef)((props, ref) => {
36
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Input", props);
37
+ let { className, htmlSize, ...rest } = (0, import_core.omitThemeProps)(mergedProps);
38
+ rest = (0, import_form_control.useFormControlProps)(rest);
39
+ const css = { ...styles.field };
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
41
+ import_core.ui.input,
42
+ {
43
+ ref,
44
+ className: (0, import_utils.cx)("ui-input", className),
45
+ size: htmlSize,
46
+ __css: css,
47
+ ...rest
48
+ }
49
+ );
50
+ });
51
+
52
+ // src/input-group.tsx
53
+ var import_core2 = require("@yamada-ui/core");
54
+ var import_file_input = require("@yamada-ui/file-input");
55
+ var import_use_token = require("@yamada-ui/use-token");
56
+ var import_utils2 = require("@yamada-ui/utils");
57
+ var import_react = require("react");
58
+ var import_jsx_runtime2 = require("react/jsx-runtime");
59
+ var [InputGroupProvider, useInputGroup] = (0, import_utils2.createContext)({
60
+ name: "InputGroupContext",
61
+ errorMessage: `useInputGroup returned is 'undefined'. Seems you forgot to wrap the components in "<InputGroup />" `
62
+ });
63
+ var InputGroup = (0, import_core2.forwardRef)((props, ref) => {
64
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
65
+ const [styles] = (0, import_core2.useMultiComponentStyle)("Input", props);
66
+ const { className, children, ...rest } = (0, import_core2.omitThemeProps)(props);
67
+ const css = {
68
+ width: "100%",
69
+ display: "flex",
70
+ position: "relative"
71
+ };
72
+ const groupProps = {};
73
+ 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;
74
+ 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;
75
+ const validChildren = (0, import_utils2.getValidChildren)(children);
76
+ validChildren.forEach((child) => {
77
+ if ((minHeight || height) && child.type === InputLeftElement)
78
+ groupProps.paddingStart = height != null ? height : minHeight;
79
+ if ((minHeight || height) && child.type === InputRightElement)
80
+ groupProps.paddingEnd = height != null ? height : minHeight;
81
+ if (child.type === InputLeftAddon)
82
+ groupProps.roundedLeft = 0;
83
+ if (child.type === InputRightAddon)
84
+ groupProps.roundedRight = 0;
85
+ });
86
+ const cloneChildren = validChildren.map((child) => {
87
+ var _a2, _b2;
88
+ const childProps = (0, import_utils2.filterUndefined)({
89
+ size: ((_a2 = child.props) == null ? void 0 : _a2.size) || props.size,
90
+ variant: ((_b2 = child.props) == null ? void 0 : _b2.variant) || props.variant,
91
+ ...child.props
92
+ });
93
+ 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));
94
+ });
95
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InputGroupProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
96
+ import_core2.ui.div,
97
+ {
98
+ ref,
99
+ className: (0, import_utils2.cx)("ui-input-group", className),
100
+ role: "group",
101
+ __css: css,
102
+ ...rest,
103
+ children: cloneChildren
104
+ }
105
+ ) });
106
+ });
107
+
108
+ // src/input-element.tsx
109
+ var import_core3 = require("@yamada-ui/core");
110
+ var import_utils3 = require("@yamada-ui/utils");
111
+ var import_jsx_runtime3 = require("react/jsx-runtime");
112
+ var InputElement = (0, import_core3.forwardRef)(
113
+ ({ className, isClick = false, placement = "left", ...rest }, ref) => {
114
+ var _a, _b, _c, _d, _e, _f, _g, _h;
115
+ const styles = useInputGroup();
116
+ const css = {
117
+ position: "absolute",
118
+ top: "0",
119
+ [placement === "left" ? "insetStart" : "insetEnd"]: "0",
120
+ zIndex: 2,
121
+ display: "flex",
122
+ alignItems: "center",
123
+ justifyContent: "center",
124
+ 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,
125
+ h: "full",
126
+ fontSize: (_h = styles.field) == null ? void 0 : _h.fontSize,
127
+ pointerEvents: isClick ? "auto" : "none",
128
+ cursor: isClick ? "pointer" : "auto",
129
+ ...styles.element
130
+ };
131
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.div, { ref, className: (0, import_utils3.cx)("ui-input-element", className), __css: css, ...rest });
132
+ }
133
+ );
134
+ var InputLeftElement = (0, import_core3.forwardRef)(
135
+ ({ className, ...rest }, ref) => {
136
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
137
+ InputElement,
138
+ {
139
+ ref,
140
+ className: (0, import_utils3.cx)("ui-input-element-left", className),
141
+ placement: "left",
142
+ ...rest
143
+ }
144
+ );
145
+ }
146
+ );
147
+ var InputRightElement = (0, import_core3.forwardRef)(
148
+ ({ className, ...rest }, ref) => {
149
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
150
+ InputElement,
151
+ {
152
+ ref,
153
+ className: (0, import_utils3.cx)("ui-input-element-right", className),
154
+ placement: "right",
155
+ ...rest
156
+ }
157
+ );
158
+ }
159
+ );
160
+
161
+ // src/input-addon.tsx
162
+ var import_jsx_runtime4 = require("react/jsx-runtime");
163
+ var InputAddon = (0, import_core4.forwardRef)(
164
+ ({ className, placement = "left", ...rest }, ref) => {
165
+ const styles = useInputGroup();
166
+ const placementStyles = {
167
+ left: {
168
+ me: "-1px",
169
+ roundedRight: 0,
170
+ borderEndColor: "transparent"
171
+ },
172
+ right: {
173
+ ms: "-1px",
174
+ roundedLeft: 0,
175
+ borderStartColor: "transparent"
176
+ }
177
+ };
178
+ const css = {
179
+ flex: "0 0 auto",
180
+ w: "auto",
181
+ display: "flex",
182
+ alignItems: "center",
183
+ whiteSpace: "nowrap",
184
+ ...styles.addon,
185
+ ...placementStyles[placement]
186
+ };
187
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.div, { ref, className: (0, import_utils4.cx)("ui-input-addon", className), __css: css, ...rest });
188
+ }
189
+ );
190
+ var InputLeftAddon = (0, import_core4.forwardRef)(({ className, ...rest }, ref) => {
191
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
192
+ InputAddon,
193
+ {
194
+ ref,
195
+ className: (0, import_utils4.cx)("ui-input-addon-left", className),
196
+ placement: "left",
197
+ ...rest
198
+ }
199
+ );
200
+ });
201
+ var InputRightAddon = (0, import_core4.forwardRef)(({ className, ...rest }, ref) => {
202
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
203
+ InputAddon,
204
+ {
205
+ ref,
206
+ className: (0, import_utils4.cx)("ui-input-addon-right", className),
207
+ placement: "right",
208
+ ...rest
209
+ }
210
+ );
211
+ });
212
+ // Annotate the CommonJS export names for ESM import in node:
213
+ 0 && (module.exports = {
214
+ InputLeftAddon,
215
+ InputRightAddon
216
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ InputLeftAddon,
3
+ InputRightAddon
4
+ } from "./chunk-5IBH3I64.mjs";
5
+ import "./chunk-BFONSAR4.mjs";
6
+ export {
7
+ InputLeftAddon,
8
+ InputRightAddon
9
+ };
@@ -0,0 +1,12 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps } from '@yamada-ui/core';
3
+
4
+ type InputElementOptions = {
5
+ isClick?: boolean;
6
+ placement?: 'left' | 'right';
7
+ };
8
+ type InputElementProps = HTMLUIProps<'div'> & InputElementOptions;
9
+ declare const InputLeftElement: _yamada_ui_core.Component<"div", InputElementProps>;
10
+ declare const InputRightElement: _yamada_ui_core.Component<"div", InputElementProps>;
11
+
12
+ export { InputElementProps, InputLeftElement, InputRightElement };
@@ -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-element.tsx
21
+ var input_element_exports = {};
22
+ __export(input_element_exports, {
23
+ InputLeftElement: () => InputLeftElement,
24
+ InputRightElement: () => InputRightElement
25
+ });
26
+ module.exports = __toCommonJS(input_element_exports);
27
+ var import_core4 = require("@yamada-ui/core");
28
+ var import_utils4 = require("@yamada-ui/utils");
29
+
30
+ // src/input.tsx
31
+ var import_core = require("@yamada-ui/core");
32
+ var import_form_control = require("@yamada-ui/form-control");
33
+ var import_utils = require("@yamada-ui/utils");
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var Input = (0, import_core.forwardRef)((props, ref) => {
36
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Input", props);
37
+ let { className, htmlSize, ...rest } = (0, import_core.omitThemeProps)(mergedProps);
38
+ rest = (0, import_form_control.useFormControlProps)(rest);
39
+ const css = { ...styles.field };
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
41
+ import_core.ui.input,
42
+ {
43
+ ref,
44
+ className: (0, import_utils.cx)("ui-input", className),
45
+ size: htmlSize,
46
+ __css: css,
47
+ ...rest
48
+ }
49
+ );
50
+ });
51
+
52
+ // src/input-group.tsx
53
+ var import_core2 = require("@yamada-ui/core");
54
+ var import_file_input = require("@yamada-ui/file-input");
55
+ var import_use_token = require("@yamada-ui/use-token");
56
+ var import_utils2 = require("@yamada-ui/utils");
57
+ var import_react = require("react");
58
+ var import_jsx_runtime2 = require("react/jsx-runtime");
59
+ var [InputGroupProvider, useInputGroup] = (0, import_utils2.createContext)({
60
+ name: "InputGroupContext",
61
+ errorMessage: `useInputGroup returned is 'undefined'. Seems you forgot to wrap the components in "<InputGroup />" `
62
+ });
63
+ var InputGroup = (0, import_core2.forwardRef)((props, ref) => {
64
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
65
+ const [styles] = (0, import_core2.useMultiComponentStyle)("Input", props);
66
+ const { className, children, ...rest } = (0, import_core2.omitThemeProps)(props);
67
+ const css = {
68
+ width: "100%",
69
+ display: "flex",
70
+ position: "relative"
71
+ };
72
+ const groupProps = {};
73
+ 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;
74
+ 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;
75
+ const validChildren = (0, import_utils2.getValidChildren)(children);
76
+ validChildren.forEach((child) => {
77
+ if ((minHeight || height) && child.type === InputLeftElement)
78
+ groupProps.paddingStart = height != null ? height : minHeight;
79
+ if ((minHeight || height) && child.type === InputRightElement)
80
+ groupProps.paddingEnd = height != null ? height : minHeight;
81
+ if (child.type === InputLeftAddon)
82
+ groupProps.roundedLeft = 0;
83
+ if (child.type === InputRightAddon)
84
+ groupProps.roundedRight = 0;
85
+ });
86
+ const cloneChildren = validChildren.map((child) => {
87
+ var _a2, _b2;
88
+ const childProps = (0, import_utils2.filterUndefined)({
89
+ size: ((_a2 = child.props) == null ? void 0 : _a2.size) || props.size,
90
+ variant: ((_b2 = child.props) == null ? void 0 : _b2.variant) || props.variant,
91
+ ...child.props
92
+ });
93
+ 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));
94
+ });
95
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InputGroupProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
96
+ import_core2.ui.div,
97
+ {
98
+ ref,
99
+ className: (0, import_utils2.cx)("ui-input-group", className),
100
+ role: "group",
101
+ __css: css,
102
+ ...rest,
103
+ children: cloneChildren
104
+ }
105
+ ) });
106
+ });
107
+
108
+ // src/input-addon.tsx
109
+ var import_core3 = require("@yamada-ui/core");
110
+ var import_utils3 = require("@yamada-ui/utils");
111
+ var import_jsx_runtime3 = require("react/jsx-runtime");
112
+ var InputAddon = (0, import_core3.forwardRef)(
113
+ ({ className, placement = "left", ...rest }, ref) => {
114
+ const styles = useInputGroup();
115
+ const placementStyles = {
116
+ left: {
117
+ me: "-1px",
118
+ roundedRight: 0,
119
+ borderEndColor: "transparent"
120
+ },
121
+ right: {
122
+ ms: "-1px",
123
+ roundedLeft: 0,
124
+ borderStartColor: "transparent"
125
+ }
126
+ };
127
+ const css = {
128
+ flex: "0 0 auto",
129
+ w: "auto",
130
+ display: "flex",
131
+ alignItems: "center",
132
+ whiteSpace: "nowrap",
133
+ ...styles.addon,
134
+ ...placementStyles[placement]
135
+ };
136
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.div, { ref, className: (0, import_utils3.cx)("ui-input-addon", className), __css: css, ...rest });
137
+ }
138
+ );
139
+ var InputLeftAddon = (0, import_core3.forwardRef)(({ className, ...rest }, ref) => {
140
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
141
+ InputAddon,
142
+ {
143
+ ref,
144
+ className: (0, import_utils3.cx)("ui-input-addon-left", className),
145
+ placement: "left",
146
+ ...rest
147
+ }
148
+ );
149
+ });
150
+ var InputRightAddon = (0, import_core3.forwardRef)(({ className, ...rest }, ref) => {
151
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
152
+ InputAddon,
153
+ {
154
+ ref,
155
+ className: (0, import_utils3.cx)("ui-input-addon-right", className),
156
+ placement: "right",
157
+ ...rest
158
+ }
159
+ );
160
+ });
161
+
162
+ // src/input-element.tsx
163
+ var import_jsx_runtime4 = require("react/jsx-runtime");
164
+ var InputElement = (0, import_core4.forwardRef)(
165
+ ({ className, isClick = false, placement = "left", ...rest }, ref) => {
166
+ var _a, _b, _c, _d, _e, _f, _g, _h;
167
+ const styles = useInputGroup();
168
+ const css = {
169
+ position: "absolute",
170
+ top: "0",
171
+ [placement === "left" ? "insetStart" : "insetEnd"]: "0",
172
+ zIndex: 2,
173
+ display: "flex",
174
+ alignItems: "center",
175
+ justifyContent: "center",
176
+ 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,
177
+ h: "full",
178
+ fontSize: (_h = styles.field) == null ? void 0 : _h.fontSize,
179
+ pointerEvents: isClick ? "auto" : "none",
180
+ cursor: isClick ? "pointer" : "auto",
181
+ ...styles.element
182
+ };
183
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.div, { ref, className: (0, import_utils4.cx)("ui-input-element", className), __css: css, ...rest });
184
+ }
185
+ );
186
+ var InputLeftElement = (0, import_core4.forwardRef)(
187
+ ({ className, ...rest }, ref) => {
188
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
189
+ InputElement,
190
+ {
191
+ ref,
192
+ className: (0, import_utils4.cx)("ui-input-element-left", className),
193
+ placement: "left",
194
+ ...rest
195
+ }
196
+ );
197
+ }
198
+ );
199
+ var InputRightElement = (0, import_core4.forwardRef)(
200
+ ({ className, ...rest }, ref) => {
201
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
202
+ InputElement,
203
+ {
204
+ ref,
205
+ className: (0, import_utils4.cx)("ui-input-element-right", className),
206
+ placement: "right",
207
+ ...rest
208
+ }
209
+ );
210
+ }
211
+ );
212
+ // Annotate the CommonJS export names for ESM import in node:
213
+ 0 && (module.exports = {
214
+ InputLeftElement,
215
+ InputRightElement
216
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ InputLeftElement,
3
+ InputRightElement
4
+ } from "./chunk-5IBH3I64.mjs";
5
+ import "./chunk-BFONSAR4.mjs";
6
+ export {
7
+ InputLeftElement,
8
+ InputRightElement
9
+ };
@@ -0,0 +1,10 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, ThemeProps, CSSUIObject } from '@yamada-ui/core';
3
+
4
+ type InputGroupProps = HTMLUIProps<'div'> & ThemeProps<'Input'>;
5
+ type InputGroupContext = Record<string, CSSUIObject>;
6
+ declare const useInputGroup: () => InputGroupContext;
7
+
8
+ declare const InputGroup: _yamada_ui_core.Component<"div", InputGroupProps>;
9
+
10
+ export { InputGroup, InputGroupProps, useInputGroup };