@gridui/input 0.0.0-stage → 0.0.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/README.md +13 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +203 -0
- package/dist/index.js.map +7 -0
- package/dist/input/input.d.ts +12 -0
- package/dist/label/label.d.ts +9 -0
- package/dist/label/style.d.ts +7 -0
- package/dist/shared/style.d.ts +12 -0
- package/dist/styles.css +95 -0
- package/dist/textarea/textarea.d.ts +14 -0
- package/dist/textarea/use-textarea-autosize.d.ts +8 -0
- package/package.json +48 -3
package/README.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gridui/input
|
|
2
|
+
|
|
3
|
+
Core family. Public API: `Input`, `InputProps`, `Label`, `LabelProps`, `Textarea`, `TextareaProps`, `controlVariants`.
|
|
4
|
+
|
|
5
|
+
Import components from `@gridui/input` and load `@gridui/input/styles.css` after Theme.
|
|
6
|
+
Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
|
|
7
|
+
|
|
8
|
+
See [component ownership](../../docs/component-ownership.md) and [release history](.changeset/history/).
|
|
9
|
+
|
|
10
|
+
## Native multiline input and point menus
|
|
11
|
+
|
|
12
|
+
See [Textarea](docs/textarea.md) for multiline input contracts and
|
|
13
|
+
[ContextMenu](../dropdown-menu/docs/context-menu.md) for controlled viewport-point menus.
|
|
2
14
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Input
|
|
4
|
+
* @namespace Root
|
|
5
|
+
* @description Index
|
|
6
|
+
*/
|
|
7
|
+
export type { InputProps } from "./input/input";
|
|
8
|
+
export { Input } from "./input/input";
|
|
9
|
+
export type { LabelProps } from "./label/label";
|
|
10
|
+
export { Label } from "./label/label";
|
|
11
|
+
export { controlVariants } from "./shared/style";
|
|
12
|
+
export type { TextareaProps } from "./textarea/textarea";
|
|
13
|
+
export { Textarea } from "./textarea/textarea";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// src/shared/style.ts
|
|
2
|
+
import { cn } from "@gridui/style-utils";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
var controlStyles = cva(cn(
|
|
5
|
+
"gridui-control",
|
|
6
|
+
"min-w-0 w-full box-border border border-solid border-border rounded-control text-foreground bg-background type-input",
|
|
7
|
+
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
8
|
+
"aria-invalid:border-danger-foreground"
|
|
9
|
+
));
|
|
10
|
+
var controlStandardStyles = cva(cn(
|
|
11
|
+
"gridui-control-standard",
|
|
12
|
+
"p-gridui-8 min-h-11"
|
|
13
|
+
));
|
|
14
|
+
var controlSmallStyles = cva(cn(
|
|
15
|
+
"gridui-control-small",
|
|
16
|
+
"py-gridui-4 px-gridui-8 min-h-9"
|
|
17
|
+
));
|
|
18
|
+
var controlVariants = cva(controlStyles(), {
|
|
19
|
+
variants: {
|
|
20
|
+
size: {
|
|
21
|
+
standard: controlStandardStyles(),
|
|
22
|
+
small: controlSmallStyles()
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: { size: "standard" }
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// src/input/input.tsx
|
|
29
|
+
import { cn as cn2 } from "@gridui/style-utils";
|
|
30
|
+
import { jsx } from "react/jsx-runtime";
|
|
31
|
+
var Input = (props) => {
|
|
32
|
+
const {
|
|
33
|
+
size,
|
|
34
|
+
controlSize = "standard",
|
|
35
|
+
className,
|
|
36
|
+
onChange,
|
|
37
|
+
onValueChange,
|
|
38
|
+
...restProps
|
|
39
|
+
} = props;
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
"input",
|
|
42
|
+
{
|
|
43
|
+
...restProps,
|
|
44
|
+
size,
|
|
45
|
+
onChange: (event) => {
|
|
46
|
+
onChange?.(event);
|
|
47
|
+
onValueChange?.(event.currentTarget.value);
|
|
48
|
+
},
|
|
49
|
+
className: cn2(controlVariants({ size: controlSize }), className)
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/label/style.ts
|
|
55
|
+
import { cn as cn3 } from "@gridui/style-utils";
|
|
56
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
57
|
+
var labelStyles = cva2(cn3(
|
|
58
|
+
"gridui-label",
|
|
59
|
+
"type-ui"
|
|
60
|
+
));
|
|
61
|
+
|
|
62
|
+
// src/label/label.tsx
|
|
63
|
+
import { cn as cn4 } from "@gridui/style-utils";
|
|
64
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
65
|
+
var Label = (props) => {
|
|
66
|
+
const { className, ...restProps } = props;
|
|
67
|
+
return /* @__PURE__ */ jsx2(
|
|
68
|
+
"label",
|
|
69
|
+
{
|
|
70
|
+
...restProps,
|
|
71
|
+
className: cn4(labelStyles(), className)
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/textarea/use-textarea-autosize.ts
|
|
77
|
+
import { useCallback, useEffect, useLayoutEffect } from "react";
|
|
78
|
+
var useTextareaAutosize = (ref, enabled, maxHeight) => {
|
|
79
|
+
if (maxHeight !== void 0 && (!Number.isFinite(maxHeight) || maxHeight <= 0)) {
|
|
80
|
+
throw new Error("Textarea maxHeight must be finite and positive.");
|
|
81
|
+
}
|
|
82
|
+
const resize = useCallback(() => {
|
|
83
|
+
const element = ref.current;
|
|
84
|
+
if (!enabled || !element || element.clientWidth === 0) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const style = getComputedStyle(element);
|
|
88
|
+
const borders = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
89
|
+
const padding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
|
|
90
|
+
element.style.height = "auto";
|
|
91
|
+
const contentHeight = element.scrollHeight;
|
|
92
|
+
const height = style.boxSizing === "border-box" ? contentHeight + borders : contentHeight - padding;
|
|
93
|
+
const boundedHeight = Math.min(height, maxHeight ?? Number.POSITIVE_INFINITY);
|
|
94
|
+
element.style.height = `${boundedHeight}px`;
|
|
95
|
+
element.style.overflowY = height > boundedHeight ? "auto" : "hidden";
|
|
96
|
+
}, [
|
|
97
|
+
ref,
|
|
98
|
+
enabled,
|
|
99
|
+
maxHeight
|
|
100
|
+
]);
|
|
101
|
+
useLayoutEffect(() => {
|
|
102
|
+
const element = ref.current;
|
|
103
|
+
if (!enabled || !element) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const originalHeight = element.style.height;
|
|
107
|
+
const originalOverflow = element.style.overflowY;
|
|
108
|
+
return () => {
|
|
109
|
+
element.style.height = originalHeight;
|
|
110
|
+
element.style.overflowY = originalOverflow;
|
|
111
|
+
};
|
|
112
|
+
}, [
|
|
113
|
+
ref,
|
|
114
|
+
enabled
|
|
115
|
+
]);
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
resize();
|
|
118
|
+
});
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const element = ref.current;
|
|
121
|
+
if (!enabled || !element) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
let frame = 0;
|
|
125
|
+
let width = element.clientWidth;
|
|
126
|
+
const schedule = () => {
|
|
127
|
+
cancelAnimationFrame(frame);
|
|
128
|
+
frame = requestAnimationFrame(resize);
|
|
129
|
+
};
|
|
130
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(() => {
|
|
131
|
+
if (element.clientWidth !== width) {
|
|
132
|
+
width = element.clientWidth;
|
|
133
|
+
schedule();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
observer?.observe(element);
|
|
137
|
+
const reset = (event) => {
|
|
138
|
+
if (event.target === element.form) {
|
|
139
|
+
schedule();
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const document = element.ownerDocument;
|
|
143
|
+
document.addEventListener("reset", reset, true);
|
|
144
|
+
return () => {
|
|
145
|
+
cancelAnimationFrame(frame);
|
|
146
|
+
observer?.disconnect();
|
|
147
|
+
document.removeEventListener("reset", reset, true);
|
|
148
|
+
};
|
|
149
|
+
}, [
|
|
150
|
+
ref,
|
|
151
|
+
enabled,
|
|
152
|
+
resize
|
|
153
|
+
]);
|
|
154
|
+
return resize;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/textarea/textarea.tsx
|
|
158
|
+
import { cn as cn5 } from "@gridui/style-utils";
|
|
159
|
+
import { useImperativeHandle, useRef } from "react";
|
|
160
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
161
|
+
var Textarea = (props) => {
|
|
162
|
+
const {
|
|
163
|
+
controlSize = "standard",
|
|
164
|
+
className,
|
|
165
|
+
onChange,
|
|
166
|
+
onInput,
|
|
167
|
+
onValueChange,
|
|
168
|
+
ref,
|
|
169
|
+
autoSize = false,
|
|
170
|
+
maxHeight,
|
|
171
|
+
style,
|
|
172
|
+
...restProps
|
|
173
|
+
} = props;
|
|
174
|
+
const element = useRef(null);
|
|
175
|
+
useImperativeHandle(ref, () => {
|
|
176
|
+
return element.current;
|
|
177
|
+
});
|
|
178
|
+
const resize = useTextareaAutosize(element, autoSize, maxHeight);
|
|
179
|
+
return /* @__PURE__ */ jsx3(
|
|
180
|
+
"textarea",
|
|
181
|
+
{
|
|
182
|
+
...restProps,
|
|
183
|
+
ref: element,
|
|
184
|
+
style,
|
|
185
|
+
onInput: (event) => {
|
|
186
|
+
resize();
|
|
187
|
+
onInput?.(event);
|
|
188
|
+
},
|
|
189
|
+
onChange: (event) => {
|
|
190
|
+
onChange?.(event);
|
|
191
|
+
onValueChange?.(event.currentTarget.value);
|
|
192
|
+
},
|
|
193
|
+
className: cn5(controlVariants({ size: controlSize }), autoSize ? "resize-none" : "resize-y", className)
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
export {
|
|
198
|
+
Input,
|
|
199
|
+
Label,
|
|
200
|
+
Textarea,
|
|
201
|
+
controlVariants
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/shared/style.ts", "../src/input/input.tsx", "../src/label/style.ts", "../src/label/label.tsx", "../src/textarea/use-textarea-autosize.ts", "../src/textarea/textarea.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Input\n * @namespace Shared\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const controlStyles = cva(cn(\n \"gridui-control\",\n \"min-w-0 w-full box-border border border-solid border-border rounded-control text-foreground bg-background type-input\",\n \"disabled:opacity-50 disabled:cursor-not-allowed\",\n \"aria-invalid:border-danger-foreground\",\n));\n\nexport const controlStandardStyles = cva(cn(\n \"gridui-control-standard\",\n \"p-gridui-8 min-h-11\",\n));\n\nexport const controlSmallStyles = cva(cn(\n \"gridui-control-small\",\n \"py-gridui-4 px-gridui-8 min-h-9\",\n));\n\nexport const controlVariants = cva(controlStyles(), {\n variants: {\n size: {\n standard: controlStandardStyles(),\n small: controlSmallStyles(),\n },\n },\n defaultVariants: { size: \"standard\" },\n});\n", "/**\n * @author WMXPY\n * @package Input\n * @namespace Input\n * @description Input\n */\n\nimport { controlVariants } from \"../shared/style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type InputProps = ComponentPropsWithRef<\"input\"> & {\n readonly controlSize?: \"standard\" | \"small\";\n readonly onValueChange?: (value: string) => void;\n};\n\nexport const Input: FC<InputProps> = (props: InputProps) => {\n const {\n size,\n controlSize = \"standard\",\n className,\n onChange,\n onValueChange,\n ...restProps\n } = props;\n return (<input\n {...restProps}\n size={size}\n onChange={(event) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n }}\n className={cn(controlVariants({ size: controlSize }), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Input\n * @namespace Label\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const labelStyles = cva(cn(\n \"gridui-label\",\n \"type-ui\",\n));\n", "/**\n * @author WMXPY\n * @package Input\n * @namespace Label\n * @description Label\n */\n\nimport { labelStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type LabelProps = ComponentPropsWithRef<\"label\">;\n\nexport const Label: FC<LabelProps> = (props: LabelProps) => {\n const { className, ...restProps } = props;\n return (<label\n {...restProps}\n className={cn(labelStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Input\n * @namespace Textarea\n * @description Use Textarea Autosize\n */\n\nimport { type RefObject, useCallback, useEffect, useLayoutEffect } from \"react\";\n\nexport const useTextareaAutosize = (ref: RefObject<HTMLTextAreaElement | null>, enabled: boolean, maxHeight?: number) => {\n if (maxHeight !== undefined && (!Number.isFinite(maxHeight) || maxHeight <= 0)) {\n throw new Error(\"Textarea maxHeight must be finite and positive.\");\n }\n const resize = useCallback(() => {\n const element = ref.current;\n if (!enabled || !element || element.clientWidth === 0) {\n return;\n }\n const style = getComputedStyle(element);\n const borders = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);\n const padding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);\n element.style.height = \"auto\";\n const contentHeight = element.scrollHeight;\n const height = style.boxSizing === \"border-box\" ? contentHeight + borders : contentHeight - padding;\n const boundedHeight = Math.min(height, maxHeight ?? Number.POSITIVE_INFINITY);\n element.style.height = `${boundedHeight}px`;\n element.style.overflowY = height > boundedHeight ? \"auto\" : \"hidden\";\n }, [\n ref,\n enabled,\n maxHeight,\n ]);\n useLayoutEffect(() => {\n const element = ref.current;\n if (!enabled || !element) {\n return;\n }\n const originalHeight = element.style.height;\n const originalOverflow = element.style.overflowY;\n return () => {\n element.style.height = originalHeight;\n element.style.overflowY = originalOverflow;\n };\n }, [\n ref,\n enabled,\n ]);\n useLayoutEffect(() => {\n resize();\n });\n useEffect(() => {\n const element = ref.current;\n if (!enabled || !element) {\n return;\n }\n let frame = 0;\n let width = element.clientWidth;\n const schedule = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(resize);\n };\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(() => {\n if (element.clientWidth !== width) {\n width = element.clientWidth;\n schedule();\n }\n });\n observer?.observe(element);\n // A capture listener follows the live form owner, including DOM reassociation.\n const reset = (event: Event): void => {\n if (event.target === element.form) {\n schedule();\n }\n };\n const document = element.ownerDocument;\n document.addEventListener(\"reset\", reset, true);\n return () => {\n cancelAnimationFrame(frame);\n observer?.disconnect();\n document.removeEventListener(\"reset\", reset, true);\n };\n }, [\n ref,\n enabled,\n resize,\n ]);\n return resize;\n};\n", "/**\n * @author WMXPY\n * @package Input\n * @namespace Textarea\n * @description Textarea\n */\n\nimport { controlVariants } from \"../shared/style\";\nimport { useTextareaAutosize } from \"./use-textarea-autosize\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, useImperativeHandle, useRef } from \"react\";\n\nexport type TextareaProps = ComponentPropsWithRef<\"textarea\"> & {\n readonly autoSize?: boolean;\n readonly maxHeight?: number;\n readonly controlSize?: \"standard\" | \"small\";\n readonly onValueChange?: (value: string) => void;\n};\n\nexport const Textarea: FC<TextareaProps> = (props: TextareaProps) => {\n const {\n controlSize = \"standard\",\n className,\n onChange,\n onInput,\n onValueChange,\n ref,\n autoSize = false,\n maxHeight,\n style,\n ...restProps\n } = props;\n const element = useRef<HTMLTextAreaElement>(null);\n // React attaches the native element before assigning imperative handles.\n useImperativeHandle(ref, () => {\n return element.current!;\n });\n const resize = useTextareaAutosize(element, autoSize, maxHeight);\n return (<textarea\n {...restProps}\n ref={element}\n style={style}\n onInput={(event) => {\n resize();\n onInput?.(event);\n }}\n onChange={(event) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n }}\n className={cn(controlVariants({ size: controlSize }), autoSize ? \"resize-none\" : \"resize-y\", className)}\n />);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,gBAAgB,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,wBAAwB,IAAI;AAAA,EACrC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,qBAAqB,IAAI;AAAA,EAClC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,kBAAkB,IAAI,cAAc,GAAG;AAAA,EAChD,UAAU;AAAA,IACN,MAAM;AAAA,MACF,UAAU,sBAAsB;AAAA,MAChC,OAAO,mBAAmB;AAAA,IAC9B;AAAA,EACJ;AAAA,EACA,iBAAiB,EAAE,MAAM,WAAW;AACxC,CAAC;;;AC3BD,SAAS,MAAAA,WAAU;AAiBP;AATL,IAAM,QAAwB,CAAC,UAAsB;AACxD,QAAM;AAAA,IACF;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACP,IAAI;AACJ,SAAQ;AAAA,IAAC;AAAA;AAAA,MACJ,GAAG;AAAA,MACJ;AAAA,MACA,UAAU,CAAC,UAAU;AACjB,mBAAW,KAAK;AAChB,wBAAgB,MAAM,cAAc,KAAK;AAAA,MAC7C;AAAA,MACA,WAAWA,IAAG,gBAAgB,EAAE,MAAM,YAAY,CAAC,GAAG,SAAS;AAAA;AAAA,EACnE;AACJ;;;AC3BA,SAAS,MAAAC,WAAU;AACnB,SAAS,OAAAC,YAAW;AAEb,IAAM,cAAcA,KAAID;AAAA,EAC3B;AAAA,EACA;AACJ,CAAC;;;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AAU,OAA4B,IAAI;AAEhD,sBAAoB,KAAK,MAAM;AAC3B,WAAO,QAAQ;AAAA,EACnB,CAAC;AACD,QAAM,SAAS,oBAAoB,SAAS,UAAU,SAAS;AAC/D,SAAQ,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACJ,GAAG;AAAA,MACJ,KAAK;AAAA,MACL;AAAA,MACA,SAAS,CAAC,UAAU;AAChB,eAAO;AACP,kBAAU,KAAK;AAAA,MACnB;AAAA,MACA,UAAU,CAAC,UAAU;AACjB,mBAAW,KAAK;AAChB,wBAAgB,MAAM,cAAc,KAAK;AAAA,MAC7C;AAAA,MACA,WAAWD,IAAG,gBAAgB,EAAE,MAAM,YAAY,CAAC,GAAG,WAAW,gBAAgB,YAAY,SAAS;AAAA;AAAA,EAC1G;AACJ;",
|
|
6
|
+
"names": ["cn", "cn", "cva", "cn", "jsx", "cn", "jsx"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Input
|
|
4
|
+
* @namespace Input
|
|
5
|
+
* @description Input
|
|
6
|
+
*/
|
|
7
|
+
import type { ComponentPropsWithRef, FC } from "react";
|
|
8
|
+
export type InputProps = ComponentPropsWithRef<"input"> & {
|
|
9
|
+
readonly controlSize?: "standard" | "small";
|
|
10
|
+
readonly onValueChange?: (value: string) => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const Input: FC<InputProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Input
|
|
4
|
+
* @namespace Shared
|
|
5
|
+
* @description Style
|
|
6
|
+
*/
|
|
7
|
+
export declare const controlStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
8
|
+
export declare const controlStandardStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
9
|
+
export declare const controlSmallStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
10
|
+
export declare const controlVariants: (props?: ({
|
|
11
|
+
size?: "standard" | "small" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@layer properties;
|
|
3
|
+
@layer theme, base, components, utilities;
|
|
4
|
+
@layer theme {
|
|
5
|
+
:root, :host {
|
|
6
|
+
--spacing: 0.25rem;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
@layer utilities {
|
|
10
|
+
.box-border {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
.hidden {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
.min-h-9 {
|
|
17
|
+
min-height: calc(var(--spacing) * 9);
|
|
18
|
+
}
|
|
19
|
+
.min-h-11 {
|
|
20
|
+
min-height: calc(var(--spacing) * 11);
|
|
21
|
+
}
|
|
22
|
+
.w-full {
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
.min-w-0 {
|
|
26
|
+
min-width: 0px;
|
|
27
|
+
}
|
|
28
|
+
.resize {
|
|
29
|
+
resize: both;
|
|
30
|
+
}
|
|
31
|
+
.resize-none {
|
|
32
|
+
resize: none;
|
|
33
|
+
}
|
|
34
|
+
.resize-y {
|
|
35
|
+
resize: vertical;
|
|
36
|
+
}
|
|
37
|
+
.rounded-control {
|
|
38
|
+
border-radius: var(--gridui-control-radius);
|
|
39
|
+
}
|
|
40
|
+
.border {
|
|
41
|
+
border-style: var(--tw-border-style);
|
|
42
|
+
border-width: 1px;
|
|
43
|
+
}
|
|
44
|
+
.border-solid {
|
|
45
|
+
--tw-border-style: solid;
|
|
46
|
+
border-style: solid;
|
|
47
|
+
}
|
|
48
|
+
.border-border {
|
|
49
|
+
border-color: var(--gridui-border);
|
|
50
|
+
}
|
|
51
|
+
.bg-background {
|
|
52
|
+
background-color: var(--gridui-background);
|
|
53
|
+
}
|
|
54
|
+
.p-gridui-8 {
|
|
55
|
+
padding: var(--gridui-space-8);
|
|
56
|
+
}
|
|
57
|
+
.px-gridui-8 {
|
|
58
|
+
padding-inline: var(--gridui-space-8);
|
|
59
|
+
}
|
|
60
|
+
.py-gridui-4 {
|
|
61
|
+
padding-block: var(--gridui-space-4);
|
|
62
|
+
}
|
|
63
|
+
.type-input {
|
|
64
|
+
font: var(--gridui-type-input);
|
|
65
|
+
letter-spacing: normal;
|
|
66
|
+
}
|
|
67
|
+
.type-ui {
|
|
68
|
+
font: var(--gridui-type-ui);
|
|
69
|
+
letter-spacing: normal;
|
|
70
|
+
}
|
|
71
|
+
.text-foreground {
|
|
72
|
+
color: var(--gridui-foreground);
|
|
73
|
+
}
|
|
74
|
+
.disabled\:cursor-not-allowed:disabled {
|
|
75
|
+
cursor: not-allowed;
|
|
76
|
+
}
|
|
77
|
+
.disabled\:opacity-50:disabled {
|
|
78
|
+
opacity: 50%;
|
|
79
|
+
}
|
|
80
|
+
.aria-invalid\:border-danger-foreground[aria-invalid="true"] {
|
|
81
|
+
border-color: var(--gridui-danger-foreground);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
@property --tw-border-style {
|
|
85
|
+
syntax: "*";
|
|
86
|
+
inherits: false;
|
|
87
|
+
initial-value: solid;
|
|
88
|
+
}
|
|
89
|
+
@layer properties {
|
|
90
|
+
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
91
|
+
*, ::before, ::after, ::backdrop {
|
|
92
|
+
--tw-border-style: solid;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Input
|
|
4
|
+
* @namespace Textarea
|
|
5
|
+
* @description Textarea
|
|
6
|
+
*/
|
|
7
|
+
import { type ComponentPropsWithRef, type FC } from "react";
|
|
8
|
+
export type TextareaProps = ComponentPropsWithRef<"textarea"> & {
|
|
9
|
+
readonly autoSize?: boolean;
|
|
10
|
+
readonly maxHeight?: number;
|
|
11
|
+
readonly controlSize?: "standard" | "small";
|
|
12
|
+
readonly onValueChange?: (value: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const Textarea: FC<TextareaProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Input
|
|
4
|
+
* @namespace Textarea
|
|
5
|
+
* @description Use Textarea Autosize
|
|
6
|
+
*/
|
|
7
|
+
import { type RefObject } from "react";
|
|
8
|
+
export declare const useTextareaAutosize: (ref: RefObject<HTMLTextAreaElement | null>, enabled: boolean, maxHeight?: number) => () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/input",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "GridUI React input",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"**/*.css"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./styles.css": "./dist/styles.css"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^19.2.0",
|
|
26
|
+
"react-dom": "^19.2.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@gridui/style-utils": "^2.1.2",
|
|
30
|
+
"@gridui/theme": "^2.1.2",
|
|
31
|
+
"class-variance-authority": "0.7.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@gridui-internal/configuration": "0.0.0",
|
|
35
|
+
"@jest/globals": "30.5.2",
|
|
36
|
+
"@types/jest": "30.0.0",
|
|
37
|
+
"@types/node": "26.6.5",
|
|
38
|
+
"@types/react": "19.3.0",
|
|
39
|
+
"@types/react-dom": "19.3.0",
|
|
40
|
+
"jest": "30.5.2",
|
|
41
|
+
"react": "19.3.1",
|
|
42
|
+
"react-dom": "19.3.1",
|
|
43
|
+
"typescript": "6.0.3"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "node ../../scripts/compilation/package.ts",
|
|
47
|
+
"compile": "tsc --project tsconfig.json",
|
|
48
|
+
"test": "jest --passWithNoTests",
|
|
49
|
+
"coverage": "jest --coverage --passWithNoTests"
|
|
50
|
+
}
|
|
6
51
|
}
|