@stackshift-ui/input 6.0.2 → 6.0.4

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 @@
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};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var V=Object.create;var o=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var a in t)o(e,a,{get:t[a],enumerable:!0})},d=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of M(t))!z.call(e,n)&&n!==a&&o(e,n,{get:()=>t[n],enumerable:!(s=H(t,n))||s.enumerable});return e};var k=(e,t,a)=>(a=e!=null?V(P(e)):{},d(t||!e||!e.__esModule?o(a,"default",{value:e,enumerable:!0}):a,e)),q=e=>d(o({},"__esModule",{value:!0}),e);var w={};$(w,{Input:()=>u});module.exports=q(w);var l=require("@stackshift-ui/system"),y=k(require("classnames")),r=require("react/jsx-runtime"),p="Input",u=({noLabel:e,label:t,ariaLabel:a,required:s=!1,name:n,labelClass:x,placeholder:g,type:b="text",variant:T="primary",onChange:f,textSize:h="md",children:F,className:C,as:I="input",...S})=>{var c;let{[p]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="w-full rounded px-4 py-2 leading-loose",m=`${i}`,v=`${i} bg-gray-100 p-4 text-xs outline-none`,L=`${i} text-xs py-3 border border-slate-300`,E={sm:"text-xs",md:"text-base",lg:"text-lg"}[h],R=(c={primary:m,secondary:v,outline:L}[T])!=null?c:m;return(0,r.jsxs)(r.Fragment,{children:[!e&&(0,r.jsx)("label",{className:x,htmlFor:n,children:t||n}),(0,r.jsx)(N,{name:n,id:n,placeholder:g,required:s,"aria-label":a||n,type:b,as:I,className:(0,y.default)(R,E,C),onChange:f,...S,"data-testid":p})]})};u.displayName=p;0&&(module.exports={Input});
2
+ "use strict";var V=Object.create;var o=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var a in t)o(e,a,{get:t[a],enumerable:!0})},d=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of M(t))!z.call(e,n)&&n!==a&&o(e,n,{get:()=>t[n],enumerable:!(s=H(t,n))||s.enumerable});return e};var k=(e,t,a)=>(a=e!=null?V(P(e)):{},d(t||!e||!e.__esModule?o(a,"default",{value:e,enumerable:!0}):a,e)),q=e=>d(o({},"__esModule",{value:!0}),e);var w={};$(w,{Input:()=>u});module.exports=q(w);var l=require("@stackshift-ui/system"),y=k(require("classnames")),r=require("react/jsx-runtime"),p="Input",u=({noLabel:e,label:t,ariaLabel:a,required:s=!1,name:n,labelClass:g,placeholder:x,type:b="text",variant:T="primary",onChange:f,textSize:h="md",children:F,className:C,as:I="input",...S})=>{var c;let{[p]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="w-full rounded-global px-4 py-2 leading-loose",m=`${i}`,v=`${i} bg-gray-100 p-4 text-xs outline-none`,L=`${i} text-xs py-3 border border-slate-300`,E={sm:"text-xs",md:"text-base",lg:"text-lg"}[h],R=(c={primary:m,secondary:v,outline:L}[T])!=null?c:m;return(0,r.jsxs)(r.Fragment,{children:[!e&&(0,r.jsx)("label",{className:g,htmlFor:n,children:t||n}),(0,r.jsx)(N,{name:n,id:n,placeholder:x,required:s,"aria-label":a||n,type:b,as:I,className:(0,y.default)(R,E,C),onChange:f,...S,"data-testid":p})]})};u.displayName=p;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-ZZTG2VMD.mjs";export{e as Input};
2
+ "use strict";import{a as e}from"./chunk-7VREZAQM.mjs";export{e as Input};
package/dist/input.js CHANGED
@@ -1 +1 @@
1
- "use strict";var V=Object.create;var o=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var a in t)o(e,a,{get:t[a],enumerable:!0})},d=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of M(t))!z.call(e,n)&&n!==a&&o(e,n,{get:()=>t[n],enumerable:!(s=H(t,n))||s.enumerable});return e};var k=(e,t,a)=>(a=e!=null?V(P(e)):{},d(t||!e||!e.__esModule?o(a,"default",{value:e,enumerable:!0}):a,e)),q=e=>d(o({},"__esModule",{value:!0}),e);var w={};$(w,{Input:()=>u});module.exports=q(w);var l=require("@stackshift-ui/system"),y=k(require("classnames")),r=require("react/jsx-runtime"),p="Input",u=({noLabel:e,label:t,ariaLabel:a,required:s=!1,name:n,labelClass:g,placeholder:x,type:b="text",variant:T="primary",onChange:h,textSize:C="md",children:F,className:I,as:f="input",...S})=>{var c;let{[p]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="w-full rounded px-4 py-2 leading-loose",m=`${i}`,v=`${i} bg-gray-100 p-4 text-xs outline-none`,L=`${i} text-xs py-3 border border-slate-300`,E={sm:"text-xs",md:"text-base",lg:"text-lg"}[C],R=(c={primary:m,secondary:v,outline:L}[T])!=null?c:m;return(0,r.jsxs)(r.Fragment,{children:[!e&&(0,r.jsx)("label",{className:g,htmlFor:n,children:t||n}),(0,r.jsx)(N,{name:n,id:n,placeholder:x,required:s,"aria-label":a||n,type:b,as:f,className:(0,y.default)(R,E,I),onChange:h,...S,"data-testid":p})]})};u.displayName=p;0&&(module.exports={Input});
1
+ "use strict";var V=Object.create;var o=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of M(t))!z.call(e,a)&&a!==n&&o(e,a,{get:()=>t[a],enumerable:!(s=H(t,a))||s.enumerable});return e};var k=(e,t,n)=>(n=e!=null?V(P(e)):{},d(t||!e||!e.__esModule?o(n,"default",{value:e,enumerable:!0}):n,e)),q=e=>d(o({},"__esModule",{value:!0}),e);var w={};$(w,{Input:()=>g});module.exports=q(w);var l=require("@stackshift-ui/system"),y=k(require("classnames")),r=require("react/jsx-runtime"),p="Input",g=({noLabel:e,label:t,ariaLabel:n,required:s=!1,name:a,labelClass:u,placeholder:x,type:b="text",variant:T="primary",onChange:h,textSize:C="md",children:F,className:I,as:f="input",...S})=>{var c;let{[p]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="w-full rounded-global px-4 py-2 leading-loose",m=`${i}`,v=`${i} bg-gray-100 p-4 text-xs outline-none`,L=`${i} text-xs py-3 border border-slate-300`,E={sm:"text-xs",md:"text-base",lg:"text-lg"}[C],R=(c={primary:m,secondary:v,outline:L}[T])!=null?c:m;return(0,r.jsxs)(r.Fragment,{children:[!e&&(0,r.jsx)("label",{className:u,htmlFor:a,children:t||a}),(0,r.jsx)(N,{name:a,id:a,placeholder:x,required:s,"aria-label":n||a,type:b,as:f,className:(0,y.default)(R,E,I),onChange:h,...S,"data-testid":p})]})};g.displayName=p;0&&(module.exports={Input});
package/dist/input.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-ZZTG2VMD.mjs";export{a as Input};
1
+ import{a}from"./chunk-7VREZAQM.mjs";export{a as Input};
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@stackshift-ui/input",
3
3
  "description": "",
4
- "version": "6.0.2",
4
+ "version": "6.0.4",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
10
10
  "files": [
11
- "dist/**"
11
+ "dist/**",
12
+ "src"
12
13
  ],
13
14
  "author": "WebriQ <info@webriq.com>",
14
15
  "devDependencies": {
@@ -34,7 +35,7 @@
34
35
  "dependencies": {
35
36
  "classnames": "^2.5.1",
36
37
  "@stackshift-ui/scripts": "6.0.2",
37
- "@stackshift-ui/system": "6.0.2"
38
+ "@stackshift-ui/system": "6.0.3"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "@types/react": "16.8 - 19",
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./input";
@@ -0,0 +1,13 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import { afterEach, describe, test } from "vitest";
3
+ import { Input } from "./input";
4
+
5
+ describe.concurrent("input", () => {
6
+ afterEach(cleanup);
7
+
8
+ test("Common: Input - test if renders without errors", ({ expect }) => {
9
+ const clx = "input-class";
10
+ render(<Input className={clx} />);
11
+ expect(screen.getByTestId("input").classList).toContain(clx);
12
+ });
13
+ });
package/src/input.tsx ADDED
@@ -0,0 +1,92 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import cn from "classnames";
3
+ import type { ElementType, HTMLProps, ReactNode } from "react";
4
+
5
+ type StyleVariants<T extends string> = Record<T, string>;
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
+ }
27
+
28
+ const displayName = "Input";
29
+
30
+ export const Input: React.FC<InputProps> = ({
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
+ }) => {
47
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
48
+
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
+ return (
69
+ <>
70
+ {!noLabel && (
71
+ <label className={labelClass} htmlFor={name}>
72
+ {label || name}
73
+ </label>
74
+ )}
75
+ <Component
76
+ name={name}
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
+ </>
89
+ );
90
+ };
91
+
92
+ Input.displayName = displayName;
@@ -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 n="Input",E=({noLabel:o,label:l,ariaLabel:i,required:p=!1,name:e,labelClass:m,placeholder:c,type:d="text",variant:y="primary",onChange:u,textSize:g="md",children:H,className:x,as:b="input",...T})=>{var r;let{[n]:h=N}=v(),t="w-full rounded px-4 py-2 leading-loose",a=`${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"}[g],S=(r={primary:a,secondary:C,outline:I}[y])!=null?r:a;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:u,...T,"data-testid":n})]})};E.displayName=n;export{E as a};