@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.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/chunk-5IBH3I64.mjs +182 -0
- package/dist/chunk-BFONSAR4.mjs +30 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +226 -0
- package/dist/index.mjs +20 -0
- package/dist/input-addon.d.ts +11 -0
- package/dist/input-addon.js +216 -0
- package/dist/input-addon.mjs +9 -0
- package/dist/input-element.d.ts +12 -0
- package/dist/input-element.js +216 -0
- package/dist/input-element.mjs +9 -0
- package/dist/input-group.d.ts +10 -0
- package/dist/input-group.js +216 -0
- package/dist/input-group.mjs +9 -0
- package/dist/input.d.ts +13 -0
- package/dist/input.js +49 -0
- package/dist/input.mjs +6 -0
- package/package.json +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Hirotomo Yamada
|
|
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,28 @@
|
|
|
1
|
+
# @yamada-ui/input
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
$ pnpm add @yamada-ui/input
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
$ yarn add @yamada-ui/input
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
$ npm install @yamada-ui/input
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Contribution
|
|
22
|
+
|
|
23
|
+
Wouldn't you like to contribute? That's amazing! We have prepared a [contribution guide](https://github.com/hirotomoyamada/yamada-ui/blob/main/CONTRIBUTING.md) to assist you.
|
|
24
|
+
|
|
25
|
+
## Licence
|
|
26
|
+
|
|
27
|
+
This package is licensed under the terms of the
|
|
28
|
+
[MIT license](https://github.com/hirotomoyamada/yamada-ui/blob/main/LICENSE).
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Input
|
|
3
|
+
} from "./chunk-BFONSAR4.mjs";
|
|
4
|
+
|
|
5
|
+
// src/input-group.tsx
|
|
6
|
+
import {
|
|
7
|
+
ui as ui3,
|
|
8
|
+
forwardRef as forwardRef3,
|
|
9
|
+
useMultiComponentStyle,
|
|
10
|
+
omitThemeProps
|
|
11
|
+
} from "@yamada-ui/core";
|
|
12
|
+
import { FileInput } from "@yamada-ui/file-input";
|
|
13
|
+
import { useToken } from "@yamada-ui/use-token";
|
|
14
|
+
import { createContext, cx as cx3, filterUndefined, getValidChildren } from "@yamada-ui/utils";
|
|
15
|
+
import { cloneElement } from "react";
|
|
16
|
+
|
|
17
|
+
// src/input-addon.tsx
|
|
18
|
+
import { ui, forwardRef } from "@yamada-ui/core";
|
|
19
|
+
import { cx } from "@yamada-ui/utils";
|
|
20
|
+
import { jsx } from "react/jsx-runtime";
|
|
21
|
+
var InputAddon = forwardRef(
|
|
22
|
+
({ className, placement = "left", ...rest }, ref) => {
|
|
23
|
+
const styles = useInputGroup();
|
|
24
|
+
const placementStyles = {
|
|
25
|
+
left: {
|
|
26
|
+
me: "-1px",
|
|
27
|
+
roundedRight: 0,
|
|
28
|
+
borderEndColor: "transparent"
|
|
29
|
+
},
|
|
30
|
+
right: {
|
|
31
|
+
ms: "-1px",
|
|
32
|
+
roundedLeft: 0,
|
|
33
|
+
borderStartColor: "transparent"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const css = {
|
|
37
|
+
flex: "0 0 auto",
|
|
38
|
+
w: "auto",
|
|
39
|
+
display: "flex",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
whiteSpace: "nowrap",
|
|
42
|
+
...styles.addon,
|
|
43
|
+
...placementStyles[placement]
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ jsx(ui.div, { ref, className: cx("ui-input-addon", className), __css: css, ...rest });
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
var InputLeftAddon = forwardRef(({ className, ...rest }, ref) => {
|
|
49
|
+
return /* @__PURE__ */ jsx(
|
|
50
|
+
InputAddon,
|
|
51
|
+
{
|
|
52
|
+
ref,
|
|
53
|
+
className: cx("ui-input-addon-left", className),
|
|
54
|
+
placement: "left",
|
|
55
|
+
...rest
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
var InputRightAddon = forwardRef(({ className, ...rest }, ref) => {
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
InputAddon,
|
|
62
|
+
{
|
|
63
|
+
ref,
|
|
64
|
+
className: cx("ui-input-addon-right", className),
|
|
65
|
+
placement: "right",
|
|
66
|
+
...rest
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// src/input-element.tsx
|
|
72
|
+
import { ui as ui2, forwardRef as forwardRef2 } from "@yamada-ui/core";
|
|
73
|
+
import { cx as cx2 } from "@yamada-ui/utils";
|
|
74
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
75
|
+
var InputElement = forwardRef2(
|
|
76
|
+
({ className, isClick = false, placement = "left", ...rest }, ref) => {
|
|
77
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
78
|
+
const styles = useInputGroup();
|
|
79
|
+
const css = {
|
|
80
|
+
position: "absolute",
|
|
81
|
+
top: "0",
|
|
82
|
+
[placement === "left" ? "insetStart" : "insetEnd"]: "0",
|
|
83
|
+
zIndex: 2,
|
|
84
|
+
display: "flex",
|
|
85
|
+
alignItems: "center",
|
|
86
|
+
justifyContent: "center",
|
|
87
|
+
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,
|
|
88
|
+
h: "full",
|
|
89
|
+
fontSize: (_h = styles.field) == null ? void 0 : _h.fontSize,
|
|
90
|
+
pointerEvents: isClick ? "auto" : "none",
|
|
91
|
+
cursor: isClick ? "pointer" : "auto",
|
|
92
|
+
...styles.element
|
|
93
|
+
};
|
|
94
|
+
return /* @__PURE__ */ jsx2(ui2.div, { ref, className: cx2("ui-input-element", className), __css: css, ...rest });
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
var InputLeftElement = forwardRef2(
|
|
98
|
+
({ className, ...rest }, ref) => {
|
|
99
|
+
return /* @__PURE__ */ jsx2(
|
|
100
|
+
InputElement,
|
|
101
|
+
{
|
|
102
|
+
ref,
|
|
103
|
+
className: cx2("ui-input-element-left", className),
|
|
104
|
+
placement: "left",
|
|
105
|
+
...rest
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
var InputRightElement = forwardRef2(
|
|
111
|
+
({ className, ...rest }, ref) => {
|
|
112
|
+
return /* @__PURE__ */ jsx2(
|
|
113
|
+
InputElement,
|
|
114
|
+
{
|
|
115
|
+
ref,
|
|
116
|
+
className: cx2("ui-input-element-right", className),
|
|
117
|
+
placement: "right",
|
|
118
|
+
...rest
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// src/input-group.tsx
|
|
125
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
126
|
+
var [InputGroupProvider, useInputGroup] = createContext({
|
|
127
|
+
name: "InputGroupContext",
|
|
128
|
+
errorMessage: `useInputGroup returned is 'undefined'. Seems you forgot to wrap the components in "<InputGroup />" `
|
|
129
|
+
});
|
|
130
|
+
var InputGroup = forwardRef3((props, ref) => {
|
|
131
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
132
|
+
const [styles] = useMultiComponentStyle("Input", props);
|
|
133
|
+
const { className, children, ...rest } = omitThemeProps(props);
|
|
134
|
+
const css = {
|
|
135
|
+
width: "100%",
|
|
136
|
+
display: "flex",
|
|
137
|
+
position: "relative"
|
|
138
|
+
};
|
|
139
|
+
const groupProps = {};
|
|
140
|
+
const minHeight = (_g = (_e = 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;
|
|
141
|
+
const height = (_n = (_l = 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;
|
|
142
|
+
const validChildren = getValidChildren(children);
|
|
143
|
+
validChildren.forEach((child) => {
|
|
144
|
+
if ((minHeight || height) && child.type === InputLeftElement)
|
|
145
|
+
groupProps.paddingStart = height != null ? height : minHeight;
|
|
146
|
+
if ((minHeight || height) && child.type === InputRightElement)
|
|
147
|
+
groupProps.paddingEnd = height != null ? height : minHeight;
|
|
148
|
+
if (child.type === InputLeftAddon)
|
|
149
|
+
groupProps.roundedLeft = 0;
|
|
150
|
+
if (child.type === InputRightAddon)
|
|
151
|
+
groupProps.roundedRight = 0;
|
|
152
|
+
});
|
|
153
|
+
const cloneChildren = validChildren.map((child) => {
|
|
154
|
+
var _a2, _b2;
|
|
155
|
+
const childProps = filterUndefined({
|
|
156
|
+
size: ((_a2 = child.props) == null ? void 0 : _a2.size) || props.size,
|
|
157
|
+
variant: ((_b2 = child.props) == null ? void 0 : _b2.variant) || props.variant,
|
|
158
|
+
...child.props
|
|
159
|
+
});
|
|
160
|
+
return child.type !== Input && child.type !== FileInput ? cloneElement(child, childProps) : cloneElement(child, Object.assign(childProps, groupProps));
|
|
161
|
+
});
|
|
162
|
+
return /* @__PURE__ */ jsx3(InputGroupProvider, { value: styles, children: /* @__PURE__ */ jsx3(
|
|
163
|
+
ui3.div,
|
|
164
|
+
{
|
|
165
|
+
ref,
|
|
166
|
+
className: cx3("ui-input-group", className),
|
|
167
|
+
role: "group",
|
|
168
|
+
__css: css,
|
|
169
|
+
...rest,
|
|
170
|
+
children: cloneChildren
|
|
171
|
+
}
|
|
172
|
+
) });
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
useInputGroup,
|
|
177
|
+
InputGroup,
|
|
178
|
+
InputLeftAddon,
|
|
179
|
+
InputRightAddon,
|
|
180
|
+
InputLeftElement,
|
|
181
|
+
InputRightElement
|
|
182
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/input.tsx
|
|
2
|
+
import {
|
|
3
|
+
ui,
|
|
4
|
+
forwardRef,
|
|
5
|
+
omitThemeProps,
|
|
6
|
+
useMultiComponentStyle
|
|
7
|
+
} from "@yamada-ui/core";
|
|
8
|
+
import { useFormControlProps } from "@yamada-ui/form-control";
|
|
9
|
+
import { cx } from "@yamada-ui/utils";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var Input = forwardRef((props, ref) => {
|
|
12
|
+
const [styles, mergedProps] = useMultiComponentStyle("Input", props);
|
|
13
|
+
let { className, htmlSize, ...rest } = omitThemeProps(mergedProps);
|
|
14
|
+
rest = useFormControlProps(rest);
|
|
15
|
+
const css = { ...styles.field };
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
ui.input,
|
|
18
|
+
{
|
|
19
|
+
ref,
|
|
20
|
+
className: cx("ui-input", className),
|
|
21
|
+
size: htmlSize,
|
|
22
|
+
__css: css,
|
|
23
|
+
...rest
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
Input
|
|
30
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Input, InputProps } from './input.js';
|
|
2
|
+
export { InputGroup, InputGroupProps, useInputGroup } from './input-group.js';
|
|
3
|
+
export { InputAddonProps, InputLeftAddon, InputRightAddon } from './input-addon.js';
|
|
4
|
+
export { InputElementProps, InputLeftElement, InputRightElement } from './input-element.js';
|
|
5
|
+
import '@yamada-ui/core';
|
|
6
|
+
import '@yamada-ui/form-control';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
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/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Input: () => Input,
|
|
24
|
+
InputGroup: () => InputGroup,
|
|
25
|
+
InputLeftAddon: () => InputLeftAddon,
|
|
26
|
+
InputLeftElement: () => InputLeftElement,
|
|
27
|
+
InputRightAddon: () => InputRightAddon,
|
|
28
|
+
InputRightElement: () => InputRightElement,
|
|
29
|
+
useInputGroup: () => useInputGroup
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
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-group.tsx
|
|
56
|
+
var import_core2 = require("@yamada-ui/core");
|
|
57
|
+
var import_file_input = require("@yamada-ui/file-input");
|
|
58
|
+
var import_use_token = require("@yamada-ui/use-token");
|
|
59
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
60
|
+
var import_react = require("react");
|
|
61
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
62
|
+
var [InputGroupProvider, useInputGroup] = (0, import_utils2.createContext)({
|
|
63
|
+
name: "InputGroupContext",
|
|
64
|
+
errorMessage: `useInputGroup returned is 'undefined'. Seems you forgot to wrap the components in "<InputGroup />" `
|
|
65
|
+
});
|
|
66
|
+
var InputGroup = (0, import_core2.forwardRef)((props, ref) => {
|
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
68
|
+
const [styles] = (0, import_core2.useMultiComponentStyle)("Input", props);
|
|
69
|
+
const { className, children, ...rest } = (0, import_core2.omitThemeProps)(props);
|
|
70
|
+
const css = {
|
|
71
|
+
width: "100%",
|
|
72
|
+
display: "flex",
|
|
73
|
+
position: "relative"
|
|
74
|
+
};
|
|
75
|
+
const groupProps = {};
|
|
76
|
+
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;
|
|
77
|
+
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;
|
|
78
|
+
const validChildren = (0, import_utils2.getValidChildren)(children);
|
|
79
|
+
validChildren.forEach((child) => {
|
|
80
|
+
if ((minHeight || height) && child.type === InputLeftElement)
|
|
81
|
+
groupProps.paddingStart = height != null ? height : minHeight;
|
|
82
|
+
if ((minHeight || height) && child.type === InputRightElement)
|
|
83
|
+
groupProps.paddingEnd = height != null ? height : minHeight;
|
|
84
|
+
if (child.type === InputLeftAddon)
|
|
85
|
+
groupProps.roundedLeft = 0;
|
|
86
|
+
if (child.type === InputRightAddon)
|
|
87
|
+
groupProps.roundedRight = 0;
|
|
88
|
+
});
|
|
89
|
+
const cloneChildren = validChildren.map((child) => {
|
|
90
|
+
var _a2, _b2;
|
|
91
|
+
const childProps = (0, import_utils2.filterUndefined)({
|
|
92
|
+
size: ((_a2 = child.props) == null ? void 0 : _a2.size) || props.size,
|
|
93
|
+
variant: ((_b2 = child.props) == null ? void 0 : _b2.variant) || props.variant,
|
|
94
|
+
...child.props
|
|
95
|
+
});
|
|
96
|
+
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));
|
|
97
|
+
});
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InputGroupProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
99
|
+
import_core2.ui.div,
|
|
100
|
+
{
|
|
101
|
+
ref,
|
|
102
|
+
className: (0, import_utils2.cx)("ui-input-group", className),
|
|
103
|
+
role: "group",
|
|
104
|
+
__css: css,
|
|
105
|
+
...rest,
|
|
106
|
+
children: cloneChildren
|
|
107
|
+
}
|
|
108
|
+
) });
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// src/input-addon.tsx
|
|
112
|
+
var import_core3 = require("@yamada-ui/core");
|
|
113
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
114
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
115
|
+
var InputAddon = (0, import_core3.forwardRef)(
|
|
116
|
+
({ className, placement = "left", ...rest }, ref) => {
|
|
117
|
+
const styles = useInputGroup();
|
|
118
|
+
const placementStyles = {
|
|
119
|
+
left: {
|
|
120
|
+
me: "-1px",
|
|
121
|
+
roundedRight: 0,
|
|
122
|
+
borderEndColor: "transparent"
|
|
123
|
+
},
|
|
124
|
+
right: {
|
|
125
|
+
ms: "-1px",
|
|
126
|
+
roundedLeft: 0,
|
|
127
|
+
borderStartColor: "transparent"
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const css = {
|
|
131
|
+
flex: "0 0 auto",
|
|
132
|
+
w: "auto",
|
|
133
|
+
display: "flex",
|
|
134
|
+
alignItems: "center",
|
|
135
|
+
whiteSpace: "nowrap",
|
|
136
|
+
...styles.addon,
|
|
137
|
+
...placementStyles[placement]
|
|
138
|
+
};
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.div, { ref, className: (0, import_utils3.cx)("ui-input-addon", className), __css: css, ...rest });
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
var InputLeftAddon = (0, import_core3.forwardRef)(({ className, ...rest }, ref) => {
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
144
|
+
InputAddon,
|
|
145
|
+
{
|
|
146
|
+
ref,
|
|
147
|
+
className: (0, import_utils3.cx)("ui-input-addon-left", className),
|
|
148
|
+
placement: "left",
|
|
149
|
+
...rest
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
var InputRightAddon = (0, import_core3.forwardRef)(({ className, ...rest }, ref) => {
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
155
|
+
InputAddon,
|
|
156
|
+
{
|
|
157
|
+
ref,
|
|
158
|
+
className: (0, import_utils3.cx)("ui-input-addon-right", className),
|
|
159
|
+
placement: "right",
|
|
160
|
+
...rest
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// src/input-element.tsx
|
|
166
|
+
var import_core4 = require("@yamada-ui/core");
|
|
167
|
+
var import_utils4 = require("@yamada-ui/utils");
|
|
168
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
169
|
+
var InputElement = (0, import_core4.forwardRef)(
|
|
170
|
+
({ className, isClick = false, placement = "left", ...rest }, ref) => {
|
|
171
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
172
|
+
const styles = useInputGroup();
|
|
173
|
+
const css = {
|
|
174
|
+
position: "absolute",
|
|
175
|
+
top: "0",
|
|
176
|
+
[placement === "left" ? "insetStart" : "insetEnd"]: "0",
|
|
177
|
+
zIndex: 2,
|
|
178
|
+
display: "flex",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
justifyContent: "center",
|
|
181
|
+
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,
|
|
182
|
+
h: "full",
|
|
183
|
+
fontSize: (_h = styles.field) == null ? void 0 : _h.fontSize,
|
|
184
|
+
pointerEvents: isClick ? "auto" : "none",
|
|
185
|
+
cursor: isClick ? "pointer" : "auto",
|
|
186
|
+
...styles.element
|
|
187
|
+
};
|
|
188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.div, { ref, className: (0, import_utils4.cx)("ui-input-element", className), __css: css, ...rest });
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
var InputLeftElement = (0, import_core4.forwardRef)(
|
|
192
|
+
({ className, ...rest }, ref) => {
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
194
|
+
InputElement,
|
|
195
|
+
{
|
|
196
|
+
ref,
|
|
197
|
+
className: (0, import_utils4.cx)("ui-input-element-left", className),
|
|
198
|
+
placement: "left",
|
|
199
|
+
...rest
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
var InputRightElement = (0, import_core4.forwardRef)(
|
|
205
|
+
({ className, ...rest }, ref) => {
|
|
206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
207
|
+
InputElement,
|
|
208
|
+
{
|
|
209
|
+
ref,
|
|
210
|
+
className: (0, import_utils4.cx)("ui-input-element-right", className),
|
|
211
|
+
placement: "right",
|
|
212
|
+
...rest
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
218
|
+
0 && (module.exports = {
|
|
219
|
+
Input,
|
|
220
|
+
InputGroup,
|
|
221
|
+
InputLeftAddon,
|
|
222
|
+
InputLeftElement,
|
|
223
|
+
InputRightAddon,
|
|
224
|
+
InputRightElement,
|
|
225
|
+
useInputGroup
|
|
226
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputGroup,
|
|
3
|
+
InputLeftAddon,
|
|
4
|
+
InputLeftElement,
|
|
5
|
+
InputRightAddon,
|
|
6
|
+
InputRightElement,
|
|
7
|
+
useInputGroup
|
|
8
|
+
} from "./chunk-5IBH3I64.mjs";
|
|
9
|
+
import {
|
|
10
|
+
Input
|
|
11
|
+
} from "./chunk-BFONSAR4.mjs";
|
|
12
|
+
export {
|
|
13
|
+
Input,
|
|
14
|
+
InputGroup,
|
|
15
|
+
InputLeftAddon,
|
|
16
|
+
InputLeftElement,
|
|
17
|
+
InputRightAddon,
|
|
18
|
+
InputRightElement,
|
|
19
|
+
useInputGroup
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
|
|
4
|
+
type InputAddonOptions = {
|
|
5
|
+
placement?: 'left' | 'right';
|
|
6
|
+
};
|
|
7
|
+
type InputAddonProps = HTMLUIProps<'div'> & InputAddonOptions;
|
|
8
|
+
declare const InputLeftAddon: _yamada_ui_core.Component<"div", InputAddonProps>;
|
|
9
|
+
declare const InputRightAddon: _yamada_ui_core.Component<"div", InputAddonProps>;
|
|
10
|
+
|
|
11
|
+
export { InputAddonProps, InputLeftAddon, InputRightAddon };
|