@stackshift-ui/form-field 6.0.13 → 6.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stackshift-ui/form-field",
3
3
  "description": "",
4
- "version": "6.0.13",
4
+ "version": "6.1.0",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -13,7 +13,9 @@
13
13
  ],
14
14
  "author": "WebriQ <info@webriq.com>",
15
15
  "devDependencies": {
16
+ "@testing-library/jest-dom": "^6.5.0",
16
17
  "@testing-library/react": "^16.0.1",
18
+ "@testing-library/user-event": "^14.6.1",
17
19
  "@types/node": "^22.7.0",
18
20
  "@types/react": "^18.3.9",
19
21
  "@types/react-dom": "^18.3.0",
@@ -33,32 +35,31 @@
33
35
  "@stackshift-ui/typescript-config": "6.0.10"
34
36
  },
35
37
  "dependencies": {
36
- "@stackshift-ui/checkbox": "6.0.11",
37
- "@stackshift-ui/input-file": "6.0.12",
38
- "@stackshift-ui/radio": "6.0.11",
39
- "@stackshift-ui/input": "6.0.12",
40
- "@stackshift-ui/scripts": "6.0.10",
41
- "@stackshift-ui/checkbox-group": "6.0.11",
42
- "@stackshift-ui/select": "6.0.12",
43
- "@stackshift-ui/radio-group": "6.0.11",
44
- "@stackshift-ui/system": "6.0.11",
45
- "@stackshift-ui/textarea": "6.0.12"
38
+ "@stackshift-ui/checkbox": "6.1.0",
39
+ "@stackshift-ui/input": "6.1.0",
40
+ "@stackshift-ui/label": "1.0.0",
41
+ "@stackshift-ui/checkbox-group": "6.1.0",
42
+ "@stackshift-ui/scripts": "6.1.0",
43
+ "@stackshift-ui/select": "6.1.0",
44
+ "@stackshift-ui/system": "6.1.0",
45
+ "@stackshift-ui/radio-group": "6.1.0",
46
+ "@stackshift-ui/radio": "6.1.0",
47
+ "@stackshift-ui/textarea": "6.1.0"
46
48
  },
47
49
  "peerDependencies": {
50
+ "@stackshift-ui/checkbox": ">=7.0.0",
51
+ "@stackshift-ui/checkbox-group": ">=7.0.0",
52
+ "@stackshift-ui/input": ">=7.0.0",
53
+ "@stackshift-ui/radio": ">=7.0.0",
54
+ "@stackshift-ui/radio-group": ">=7.0.0",
55
+ "@stackshift-ui/scripts": ">=7.0.0",
56
+ "@stackshift-ui/select": ">=7.0.0",
57
+ "@stackshift-ui/system": ">=7.0.0",
58
+ "@stackshift-ui/textarea": ">=7.0.0",
48
59
  "@types/react": "16.8 - 19",
49
60
  "next": "10 - 14",
50
61
  "react": "16.8 - 19",
51
- "react-dom": "16.8 - 19",
52
- "@stackshift-ui/scripts": ">=6.0.10",
53
- "@stackshift-ui/system": ">=6.0.11",
54
- "@stackshift-ui/checkbox": ">=6.0.11",
55
- "@stackshift-ui/checkbox-group": ">=6.0.11",
56
- "@stackshift-ui/input": ">=6.0.12",
57
- "@stackshift-ui/input-file": ">=6.0.12",
58
- "@stackshift-ui/radio": ">=6.0.11",
59
- "@stackshift-ui/radio-group": ">=6.0.11",
60
- "@stackshift-ui/select": ">=6.0.12",
61
- "@stackshift-ui/textarea": ">=6.0.12"
62
+ "react-dom": "16.8 - 19"
62
63
  },
63
64
  "peerDependenciesMeta": {
64
65
  "next": {
@@ -1,4 +1,5 @@
1
- import { cleanup, render, screen } from "@testing-library/react";
1
+ import { cleanup, render, screen, waitFor } from "@testing-library/react";
2
+ import userEvent from "@testing-library/user-event";
2
3
  import { afterEach, describe, test } from "vitest";
3
4
  import { FormField } from "./form-field";
4
5
 
@@ -7,7 +8,44 @@ describe.concurrent("form-field", () => {
7
8
 
8
9
  test("Common: Form Field - test if renders without errors", ({ expect }) => {
9
10
  const clx = "formfield-class";
10
- render(<FormField className={clx} name="stackshift-formfield" />);
11
+ const { unmount } = render(
12
+ <FormField data-testid="textarea" className={clx} name="stackshift-formfield" />,
13
+ );
11
14
  expect(screen.getByTestId("textarea").classList).toContain(clx);
15
+ unmount();
16
+ });
17
+
18
+ test("Common: Form Field - test if renders with correct type", ({ expect }) => {
19
+ const { unmount } = render(
20
+ <FormField data-testid="inputText" type="inputText" name="stackshift-inputtext" />,
21
+ );
22
+ expect(screen.getByTestId("inputText").tagName.toLowerCase()).toBe("input");
23
+ unmount();
24
+ });
25
+
26
+ test("Common: Form Field - test if renders with correct label", ({ expect }) => {
27
+ const { unmount } = render(
28
+ <FormField
29
+ data-testid="inputText"
30
+ type="inputText"
31
+ name="stackshift-inputtext"
32
+ label="Stackshift Input Text"
33
+ />,
34
+ );
35
+ expect(screen.getByText("Stackshift Input Text")).toBeInTheDocument();
36
+ unmount();
37
+ });
38
+
39
+ test("Common: Form Field - test if renders with correct placeholder", ({ expect }) => {
40
+ const { unmount } = render(
41
+ <FormField
42
+ data-testid="inputText"
43
+ type="inputText"
44
+ name="stackshift-inputtext"
45
+ placeholder="Stackshift Input Text"
46
+ />,
47
+ );
48
+ expect(screen.getByPlaceholderText("Stackshift Input Text")).toBeInTheDocument();
49
+ unmount();
12
50
  });
13
51
  });
@@ -1,10 +1,15 @@
1
1
  import { Checkbox } from "@stackshift-ui/checkbox";
2
2
  import { CheckboxGroup } from "@stackshift-ui/checkbox-group";
3
3
  import { Input } from "@stackshift-ui/input";
4
- import { InputFile } from "@stackshift-ui/input-file";
5
- import { Radio } from "@stackshift-ui/radio";
6
- import { RadioGroup } from "@stackshift-ui/radio-group";
7
- import { Select } from "@stackshift-ui/select";
4
+ import { Label } from "@stackshift-ui/label";
5
+ import { RadioGroup, RadioGroupItem } from "@stackshift-ui/radio-group";
6
+ import {
7
+ Select,
8
+ SelectContent,
9
+ SelectItem,
10
+ SelectTrigger,
11
+ SelectValue,
12
+ } from "@stackshift-ui/select";
8
13
  import { Textarea } from "@stackshift-ui/textarea";
9
14
  import { FormTypes, Variant } from "./types";
10
15
 
@@ -49,66 +54,92 @@ export const FormField = ({
49
54
  switch (type) {
50
55
  case "inputRadio":
51
56
  return (
52
- <RadioGroup noLabel={noLabel} label={label} name={name}>
57
+ <RadioGroup name={name} {...props}>
58
+ <Label>{label}</Label>
53
59
  {items?.map(item => (
54
- <Radio key={item} ariaLabel={name} name={name} item={item} {...props} />
60
+ <div className="flex items-center gap-3">
61
+ {/* // <Radio key={item} ariaLabel={name} name={name} item={item} {...props} /> */}
62
+ <RadioGroupItem id={item} key={item} value={item} />
63
+ <Label htmlFor={item}>{item}</Label>
64
+ </div>
55
65
  ))}
56
66
  </RadioGroup>
57
67
  );
58
68
 
59
69
  case "inputSelect":
60
70
  return (
61
- <Select
62
- items={items}
63
- label={label}
64
- ariaLabel={label}
65
- name={name}
66
- required={required}
67
- noLabel={noLabel}
68
- {...props}
69
- />
71
+ <Select name={name} {...props}>
72
+ <SelectTrigger>
73
+ <SelectValue placeholder={placeholder} />
74
+ </SelectTrigger>
75
+ <SelectContent>
76
+ {items?.map(item => (
77
+ <SelectItem key={item} value={item}>
78
+ {item}
79
+ </SelectItem>
80
+ ))}
81
+ </SelectContent>
82
+ </Select>
70
83
  );
71
84
 
72
85
  case "inputCheckbox":
73
86
  return (
74
- <CheckboxGroup noLabel={noLabel} name={name} label={label}>
87
+ <CheckboxGroup noLabel={noLabel} name={name} label={label} {...props}>
75
88
  {items?.map(item => (
76
- <Checkbox key={item} label={item} ariaLabel={name} name={name} item={item} {...props} />
89
+ <div className="flex flex-row gap-2 items-start">
90
+ <Checkbox id={item} key={item} name={item} {...props} />
91
+ <Label htmlFor={item}>{label}</Label>
92
+ </div>
77
93
  ))}
78
94
  </CheckboxGroup>
79
95
  );
80
96
 
81
97
  case "inputFile":
82
- return <InputFile ariaLabel={name} name={name} required={required} {...props} />;
98
+ return <Input type="file" aria-label={name} name={name} required={required} {...props} />;
83
99
 
84
100
  case "textarea":
85
101
  return (
86
- <Textarea
87
- noLabel={noLabel}
88
- ariaLabel={placeholder ?? name}
89
- placeholder={placeholder}
90
- name={name}
91
- variant={variant}
92
- required={required}
93
- label={label}
94
- {...props}
95
- />
102
+ // <Textarea
103
+ // noLabel={noLabel}
104
+ // ariaLabel={placeholder ?? name}
105
+ // placeholder={placeholder}
106
+ // name={name}
107
+ // variant={variant}
108
+ // required={required}
109
+ // label={label}
110
+ // {...props}
111
+ // />
112
+ <div>
113
+ {!noLabel ? <Label htmlFor={name}>{label}</Label> : null}
114
+ <Textarea id={name} name={name} placeholder={placeholder} {...props}></Textarea>
115
+ </div>
96
116
  );
97
117
 
98
118
  default:
99
119
  return (
100
- <Input
101
- noLabel={noLabel}
102
- textSize={textSize}
103
- label={label || name}
104
- ariaLabel={label || name}
105
- required={required}
106
- name={name}
107
- placeholder={placeholder}
108
- type={formType as "number" | "text" | "email" | "password"}
109
- variant={variant}
110
- {...props}
111
- />
120
+ <div className="flex flex-col gap-2 items-start">
121
+ {!noLabel ? <Label htmlFor={name}>{label}</Label> : null}
122
+ <Input
123
+ id={name}
124
+ name={name}
125
+ placeholder={placeholder}
126
+ type={formType as "number" | "text" | "email" | "password"}
127
+ required={required}
128
+ {...props}
129
+ />
130
+ </div>
131
+ // <Input
132
+ // noLabel={noLabel}
133
+ // textSize={textSize}
134
+ // label={label || name}
135
+ // ariaLabel={label || name}
136
+ // required={required}
137
+ // name={name}
138
+ // placeholder={placeholder}
139
+ // type={formType as "number" | "text" | "email" | "password"}
140
+ // variant={variant}
141
+ // {...props}
142
+ // />
112
143
  );
113
144
  }
114
145
  };
@@ -0,0 +1,4 @@
1
+ import '@testing-library/jest-dom';
2
+
3
+ export { };
4
+
@@ -1 +0,0 @@
1
- import{Checkbox as x}from"@stackshift-ui/checkbox";import{CheckboxGroup as s}from"@stackshift-ui/checkbox-group";import{Input as d}from"@stackshift-ui/input";import{InputFile as f}from"@stackshift-ui/input-file";import{Radio as F}from"@stackshift-ui/radio";import{RadioGroup as k}from"@stackshift-ui/radio-group";import{Select as y}from"@stackshift-ui/select";import{Textarea as L}from"@stackshift-ui/textarea";import{jsx as e}from"react/jsx-runtime";var P=({type:l="textarea",items:a=[],name:r,label:t="",required:p,placeholder:n,textSize:b,noLabel:u,variant:m,...i})=>{let c={inputText:"text",inputEmail:"email",inputPassword:"password",inputNumber:"number",textarea:"textarea",inputFile:"file",inputRadio:"radio",inputCheckbox:"checkbox",inputSelect:"select"}[l];switch(l){case"inputRadio":return e(k,{noLabel:u,label:t,name:r,children:a==null?void 0:a.map(o=>e(F,{ariaLabel:r,name:r,item:o,...i},o))});case"inputSelect":return e(y,{items:a,label:t,ariaLabel:t,name:r,required:p,noLabel:u,...i});case"inputCheckbox":return e(s,{noLabel:u,name:r,label:t,children:a==null?void 0:a.map(o=>e(x,{label:o,ariaLabel:r,name:r,item:o,...i},o))});case"inputFile":return e(f,{ariaLabel:r,name:r,required:p,...i});case"textarea":return e(L,{noLabel:u,ariaLabel:n!=null?n:r,placeholder:n,name:r,variant:m,required:p,label:t,...i});default:return e(d,{noLabel:u,textSize:b,label:t||r,ariaLabel:t||r,required:p,name:r,placeholder:n,type:c,variant:m,...i})}};export{P as a};