@stackshift-ui/input 6.0.12 → 7.0.0-beta.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/chunk-UKYDCVEP.mjs +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/input.d.ts +5 -22
- package/dist/input.js +1 -1
- package/dist/input.mjs +1 -1
- package/package.json +4 -4
- package/src/input.test.tsx +44 -2
- package/src/input.tsx +17 -82
- package/dist/chunk-7VREZAQM.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cn as r,DefaultComponent as a,useStackShiftUIComponents as s}from"@stackshift-ui/system";import{jsx as l}from"react/jsx-runtime";var e="Input";function d({className:i,type:t,...n}){let{[e]:o=a}=s();return l(o,{as:"input",type:t,"data-slot":"input",className:r("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-10 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",i),...n})}d.displayName=e;export{d as a};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)a(t,i,{get:e[i],enumerable:!0})},c=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of u(e))!f.call(t,o)&&o!==i&&a(t,o,{get:()=>e[o],enumerable:!(r=p(e,o))||r.enumerable});return t};var b=t=>c(a({},"__esModule",{value:!0}),t);var g={};m(g,{Input:()=>d});module.exports=b(g);var n=require("@stackshift-ui/system"),l=require("react/jsx-runtime"),s="Input";function d({className:t,type:e,...i}){let{[s]:r=n.DefaultComponent}=(0,n.useStackShiftUIComponents)();return(0,l.jsx)(r,{as:"input",type:e,"data-slot":"input",className:(0,n.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-10 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...i})}d.displayName=s;0&&(module.exports={Input});
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";import{a as e}from"./chunk-
|
|
2
|
+
"use strict";import{a as e}from"./chunk-UKYDCVEP.mjs";export{e as Input};
|
package/dist/input.d.ts
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export interface InputProps extends Omit<HTMLProps<HTMLInputElement>, "as"> {
|
|
6
|
-
noLabel?: boolean;
|
|
7
|
-
label?: string;
|
|
8
|
-
ariaLabel?: string;
|
|
9
|
-
required?: boolean;
|
|
10
|
-
name?: string;
|
|
11
|
-
labelClass?: string;
|
|
12
|
-
placeholder?: string;
|
|
13
|
-
type?: InputType;
|
|
14
|
-
variant?: Variant;
|
|
15
|
-
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
16
|
-
textSize?: TextSize;
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
children?: ReactNode;
|
|
19
|
-
className?: string;
|
|
20
|
-
as?: ElementType;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare function Input({ className, type, ...props }: React.ComponentProps<"input">): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare namespace Input {
|
|
4
|
+
var displayName: string;
|
|
21
5
|
}
|
|
22
|
-
export
|
|
23
|
-
export {};
|
|
6
|
+
export { Input };
|
package/dist/input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var m=(i,e)=>{for(var t in e)a(i,t,{get:e[t],enumerable:!0})},c=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of u(e))!f.call(i,o)&&o!==t&&a(i,o,{get:()=>e[o],enumerable:!(r=p(e,o))||r.enumerable});return i};var b=i=>c(a({},"__esModule",{value:!0}),i);var g={};m(g,{Input:()=>d});module.exports=b(g);var n=require("@stackshift-ui/system"),l=require("react/jsx-runtime"),s="Input";function d({className:i,type:e,...t}){let{[s]:r=n.DefaultComponent}=(0,n.useStackShiftUIComponents)();return(0,l.jsx)(r,{as:"input",type:e,"data-slot":"input",className:(0,n.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-10 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",i),...t})}d.displayName=s;0&&(module.exports={Input});
|
package/dist/input.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-UKYDCVEP.mjs";export{a as Input};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/input",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0-beta.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"classnames": "^2.5.1",
|
|
37
|
-
"@stackshift-ui/scripts": "6.0.
|
|
38
|
-
"@stackshift-ui/system": "6.0.
|
|
37
|
+
"@stackshift-ui/scripts": "6.1.0-beta.0",
|
|
38
|
+
"@stackshift-ui/system": "6.1.0-beta.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@types/react": "16.8 - 19",
|
|
42
42
|
"next": "10 - 14",
|
|
43
43
|
"react": "16.8 - 19",
|
|
44
44
|
"react-dom": "16.8 - 19",
|
|
45
|
-
"@stackshift-ui/system": ">=6.0.
|
|
45
|
+
"@stackshift-ui/system": ">=6.1.0-beta.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"next": {
|
package/src/input.test.tsx
CHANGED
|
@@ -7,7 +7,49 @@ describe.concurrent("input", () => {
|
|
|
7
7
|
|
|
8
8
|
test("Common: Input - test if renders without errors", ({ expect }) => {
|
|
9
9
|
const clx = "input-class";
|
|
10
|
-
render(<Input className={clx} />);
|
|
11
|
-
|
|
10
|
+
const { unmount } = render(<Input className={clx} placeholder="Test input" />);
|
|
11
|
+
const input = screen.getByPlaceholderText("Test input");
|
|
12
|
+
expect(input.classList).toContain(clx);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("Common: Input - test with aria-label", ({ expect }) => {
|
|
16
|
+
const { unmount } = render(<Input aria-label="Test input" />);
|
|
17
|
+
const input = screen.getByLabelText("Test input");
|
|
18
|
+
expect(input.tagName.toLowerCase()).toBe("input");
|
|
19
|
+
unmount();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("Common: Input - test with different types", ({ expect }) => {
|
|
23
|
+
const { unmount: unmountEmail } = render(<Input type="email" placeholder="Enter your email" />);
|
|
24
|
+
const input = screen.getByPlaceholderText("Enter your email");
|
|
25
|
+
expect(input.getAttribute("type")).toBe("email");
|
|
26
|
+
|
|
27
|
+
const { unmount: unmountPassword } = render(
|
|
28
|
+
<Input type="password" placeholder="Enter your password" />,
|
|
29
|
+
);
|
|
30
|
+
const passwordInput = screen.getByPlaceholderText("Enter your password");
|
|
31
|
+
expect(passwordInput.getAttribute("type")).toBe("password");
|
|
32
|
+
|
|
33
|
+
const { unmount: unmountNumber } = render(<Input type="number" placeholder="Enter your age" />);
|
|
34
|
+
const numberInput = screen.getByPlaceholderText("Enter your age");
|
|
35
|
+
expect(numberInput.getAttribute("type")).toBe("number");
|
|
36
|
+
|
|
37
|
+
const { unmount: unmountTel } = render(
|
|
38
|
+
<Input type="tel" placeholder="Enter your phone number" />,
|
|
39
|
+
);
|
|
40
|
+
const telInput = screen.getByPlaceholderText("Enter your phone number");
|
|
41
|
+
expect(telInput.getAttribute("type")).toBe("tel");
|
|
42
|
+
|
|
43
|
+
unmountEmail();
|
|
44
|
+
unmountPassword();
|
|
45
|
+
unmountNumber();
|
|
46
|
+
unmountTel();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("Common: Input - test with required attribute", ({ expect }) => {
|
|
50
|
+
const { unmount } = render(<Input type="text" placeholder="Enter your name" required />);
|
|
51
|
+
const input = screen.getByPlaceholderText("Enter your name");
|
|
52
|
+
expect(input.getAttribute("required")).toBe("");
|
|
53
|
+
unmount();
|
|
12
54
|
});
|
|
13
55
|
});
|
package/src/input.tsx
CHANGED
|
@@ -1,92 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import cn from "classnames";
|
|
3
|
-
import type { ElementType, HTMLProps, ReactNode } from "react";
|
|
1
|
+
import * as React from "react";
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
type Variant = "primary" | "outline" | "secondary";
|
|
7
|
-
type InputType = "number" | "password" | "email" | "text";
|
|
8
|
-
type TextSize = "sm" | "md" | "lg";
|
|
9
|
-
|
|
10
|
-
export interface InputProps extends Omit<HTMLProps<HTMLInputElement>, "as"> {
|
|
11
|
-
noLabel?: boolean;
|
|
12
|
-
label?: string;
|
|
13
|
-
ariaLabel?: string;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
name?: string;
|
|
16
|
-
labelClass?: string;
|
|
17
|
-
placeholder?: string;
|
|
18
|
-
type?: InputType;
|
|
19
|
-
variant?: Variant;
|
|
20
|
-
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
21
|
-
textSize?: TextSize;
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
children?: ReactNode;
|
|
24
|
-
className?: string;
|
|
25
|
-
as?: ElementType;
|
|
26
|
-
}
|
|
3
|
+
import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
27
4
|
|
|
28
5
|
const displayName = "Input";
|
|
29
6
|
|
|
30
|
-
|
|
31
|
-
noLabel,
|
|
32
|
-
label,
|
|
33
|
-
ariaLabel,
|
|
34
|
-
required = false,
|
|
35
|
-
name,
|
|
36
|
-
labelClass,
|
|
37
|
-
placeholder,
|
|
38
|
-
type = "text",
|
|
39
|
-
variant = "primary",
|
|
40
|
-
onChange,
|
|
41
|
-
textSize = "md",
|
|
42
|
-
children,
|
|
43
|
-
className,
|
|
44
|
-
as = "input",
|
|
45
|
-
...props
|
|
46
|
-
}) => {
|
|
7
|
+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
47
8
|
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
48
9
|
|
|
49
|
-
const commonStyle = "w-full rounded-global px-4 py-2 leading-loose";
|
|
50
|
-
const primary = `${commonStyle}`;
|
|
51
|
-
const secondary = `${commonStyle} bg-gray-100 p-4 text-xs outline-none`;
|
|
52
|
-
const outline = `${commonStyle} text-xs py-3 border border-slate-300`;
|
|
53
|
-
|
|
54
|
-
const text = {
|
|
55
|
-
sm: "text-xs",
|
|
56
|
-
md: "text-base",
|
|
57
|
-
lg: "text-lg",
|
|
58
|
-
}[textSize];
|
|
59
|
-
|
|
60
|
-
const variants: StyleVariants<Variant> = {
|
|
61
|
-
primary,
|
|
62
|
-
secondary,
|
|
63
|
-
outline,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const variantClass = variants[variant] ?? primary;
|
|
67
|
-
|
|
68
10
|
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
11
|
+
<Component
|
|
12
|
+
as="input"
|
|
13
|
+
type={type}
|
|
14
|
+
data-slot="input"
|
|
15
|
+
className={cn(
|
|
16
|
+
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-10 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
17
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
18
|
+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
19
|
+
className,
|
|
74
20
|
)}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
id={name}
|
|
78
|
-
placeholder={placeholder}
|
|
79
|
-
required={required}
|
|
80
|
-
aria-label={ariaLabel || name}
|
|
81
|
-
type={type}
|
|
82
|
-
as={as}
|
|
83
|
-
className={cn(variantClass, text, className)}
|
|
84
|
-
onChange={onChange}
|
|
85
|
-
{...props}
|
|
86
|
-
data-testid={displayName}
|
|
87
|
-
/>
|
|
88
|
-
</>
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
89
23
|
);
|
|
90
|
-
}
|
|
91
|
-
|
|
24
|
+
}
|
|
92
25
|
Input.displayName = displayName;
|
|
26
|
+
|
|
27
|
+
export { Input };
|
package/dist/chunk-7VREZAQM.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{DefaultComponent as N,useStackShiftUIComponents as v}from"@stackshift-ui/system";import L from"classnames";import{Fragment as R,jsx as s,jsxs as V}from"react/jsx-runtime";var a="Input",E=({noLabel:o,label:l,ariaLabel:i,required:p=!1,name:e,labelClass:m,placeholder:c,type:d="text",variant:y="primary",onChange:g,textSize:u="md",children:H,className:x,as:b="input",...T})=>{var r;let{[a]:h=N}=v(),t="w-full rounded-global px-4 py-2 leading-loose",n=`${t}`,C=`${t} bg-gray-100 p-4 text-xs outline-none`,I=`${t} text-xs py-3 border border-slate-300`,f={sm:"text-xs",md:"text-base",lg:"text-lg"}[u],S=(r={primary:n,secondary:C,outline:I}[y])!=null?r:n;return V(R,{children:[!o&&s("label",{className:m,htmlFor:e,children:l||e}),s(h,{name:e,id:e,placeholder:c,required:p,"aria-label":i||e,type:d,as:b,className:L(S,f,x),onChange:g,...T,"data-testid":a})]})};E.displayName=a;export{E as a};
|