@foundrykit/primitives 2.0.0 → 2.0.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/.turbo/turbo-build.log +39 -77
- package/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/src/components/input-group/config.ts +209 -0
- package/src/components/input-group/index.tsx +156 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @foundrykit/primitives@
|
|
3
|
+
> @foundrykit/primitives@2.0.0 build /Users/isj/Desktop/work/projects/foundry/packages/primitives
|
|
4
4
|
> tsup --dts --format esm,cjs --clean
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/index.ts, src/components/avatar/index.tsx, src/components/badge/index.tsx, src/components/breadcrumb/index.tsx, src/components/button/index.tsx, src/components/card/index.tsx, src/components/checkbox/index.tsx, src/components/dropdown/index.tsx, src/components/input/index.tsx, src/components/label/index.tsx, src/components/popover/index.tsx, src/components/radio-group/index.tsx, src/components/scroll-area/index.tsx, src/components/select/index.tsx, src/components/separator/index.tsx, src/components/skeleton/index.tsx, src/components/switch/index.tsx, src/components/tabs/index.tsx, src/components/textarea/index.tsx
|
|
@@ -11,101 +11,63 @@
|
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mESM[39m Build start
|
|
13
13
|
[34mCJS[39m Build start
|
|
14
|
-
[32mCJS[39m [1mdist/components/badge/index.cjs [22m[32m2.69 KB[39m
|
|
15
14
|
[32mCJS[39m [1mdist/index.cjs [22m[32m55.41 KB[39m
|
|
16
|
-
[32mCJS[39m [1mdist/components/
|
|
17
|
-
[32mCJS[39m [1mdist/components/
|
|
18
|
-
[32mCJS[39m [1mdist/components/avatar/index.cjs [22m[32m2.84 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/components/badge/index.cjs [22m[32m2.69 KB[39m
|
|
16
|
+
[32mCJS[39m [1mdist/components/button/index.cjs [22m[32m3.16 KB[39m
|
|
19
17
|
[32mCJS[39m [1mdist/components/checkbox/index.cjs [22m[32m2.99 KB[39m
|
|
20
18
|
[32mCJS[39m [1mdist/components/breadcrumb/index.cjs [22m[32m4.12 KB[39m
|
|
21
|
-
[32mCJS[39m [1mdist/components/
|
|
22
|
-
[32mCJS[39m [1mdist/components/card/index.cjs [22m[32m3.61 KB[39m
|
|
19
|
+
[32mCJS[39m [1mdist/components/label/index.cjs [22m[32m2.26 KB[39m
|
|
23
20
|
[32mCJS[39m [1mdist/components/popover/index.cjs [22m[32m3.35 KB[39m
|
|
24
|
-
[32mCJS[39m [1mdist/components/textarea/index.cjs [22m[32m1.84 KB[39m
|
|
25
21
|
[32mCJS[39m [1mdist/components/dropdown/index.cjs [22m[32m10.58 KB[39m
|
|
26
|
-
[32mCJS[39m [1mdist/components/
|
|
27
|
-
[32mCJS[39m [1mdist/components/
|
|
22
|
+
[32mCJS[39m [1mdist/components/input/index.cjs [22m[32m2.42 KB[39m
|
|
23
|
+
[32mCJS[39m [1mdist/components/radio-group/index.cjs [22m[32m3.28 KB[39m
|
|
28
24
|
[32mCJS[39m [1mdist/components/scroll-area/index.cjs [22m[32m3.50 KB[39m
|
|
29
|
-
[32mCJS[39m [1mdist/components/tabs/index.cjs [22m[32m3.73 KB[39m
|
|
30
|
-
[32mCJS[39m [1mdist/components/separator/index.cjs [22m[32m2.34 KB[39m
|
|
31
|
-
[32mCJS[39m [1mdist/components/switch/index.cjs [22m[32m2.90 KB[39m
|
|
32
25
|
[32mCJS[39m [1mdist/components/select/index.cjs [22m[32m8.56 KB[39m
|
|
33
|
-
[32mCJS[39m
|
|
26
|
+
[32mCJS[39m [1mdist/components/switch/index.cjs [22m[32m2.90 KB[39m
|
|
27
|
+
[32mCJS[39m [1mdist/components/skeleton/index.cjs [22m[32m1.41 KB[39m
|
|
28
|
+
[32mCJS[39m [1mdist/components/separator/index.cjs [22m[32m2.34 KB[39m
|
|
29
|
+
[32mCJS[39m [1mdist/components/tabs/index.cjs [22m[32m3.73 KB[39m
|
|
30
|
+
[32mCJS[39m [1mdist/components/textarea/index.cjs [22m[32m1.84 KB[39m
|
|
31
|
+
[32mCJS[39m [1mdist/components/avatar/index.cjs [22m[32m2.84 KB[39m
|
|
32
|
+
[32mCJS[39m [1mdist/components/card/index.cjs [22m[32m3.61 KB[39m
|
|
33
|
+
[32mCJS[39m ⚡️ Build success in 35ms
|
|
34
34
|
[32mESM[39m [1mdist/components/switch/index.js [22m[32m87.00 B[39m
|
|
35
|
-
[32mESM[39m [1mdist/components/label/index.js [22m[32m85.00 B[39m
|
|
36
|
-
[32mESM[39m [1mdist/components/input/index.js [22m[32m71.00 B[39m
|
|
37
|
-
[32mESM[39m [1mdist/components/popover/index.js [22m[32m195.00 B[39m
|
|
38
|
-
[32mESM[39m [1mdist/components/radio-group/index.js [22m[32m131.00 B[39m
|
|
39
35
|
[32mESM[39m [1mdist/components/textarea/index.js [22m[32m77.00 B[39m
|
|
40
|
-
[32mESM[39m [1mdist/components/select/index.js [22m[32m411.00 B[39m
|
|
41
36
|
[32mESM[39m [1mdist/components/scroll-area/index.js [22m[32m121.00 B[39m
|
|
42
|
-
[32mESM[39m [1mdist/components/
|
|
43
|
-
[32mESM[39m [1mdist/
|
|
44
|
-
[32mESM[39m [1mdist/
|
|
37
|
+
[32mESM[39m [1mdist/components/tabs/index.js [22m[32m167.00 B[39m
|
|
38
|
+
[32mESM[39m [1mdist/components/radio-group/index.js [22m[32m131.00 B[39m
|
|
39
|
+
[32mESM[39m [1mdist/components/label/index.js [22m[32m85.00 B[39m
|
|
40
|
+
[32mESM[39m [1mdist/components/popover/index.js [22m[32m195.00 B[39m
|
|
41
|
+
[32mESM[39m [1mdist/components/input/index.js [22m[32m71.00 B[39m
|
|
45
42
|
[32mESM[39m [1mdist/index.js [22m[32m13.82 KB[39m
|
|
46
|
-
[32mESM[39m [1mdist/chunk-I44GXEPN.js [22m[32m809.00 B[39m
|
|
47
|
-
[32mESM[39m [1mdist/chunk-KZMSLRLW.js [22m[32m806.00 B[39m
|
|
48
43
|
[32mESM[39m [1mdist/components/separator/index.js [22m[32m93.00 B[39m
|
|
49
|
-
[32mESM[39m [1mdist/
|
|
44
|
+
[32mESM[39m [1mdist/chunk-U2EIVYWP.js [22m[32m1.21 KB[39m
|
|
45
|
+
[32mESM[39m [1mdist/chunk-FYCANIVJ.js [22m[32m1.87 KB[39m
|
|
50
46
|
[32mESM[39m [1mdist/chunk-J4CRGO2P.js [22m[32m1.49 KB[39m
|
|
51
|
-
[32mESM[39m [1mdist/
|
|
47
|
+
[32mESM[39m [1mdist/components/skeleton/index.js [22m[32m77.00 B[39m
|
|
48
|
+
[32mESM[39m [1mdist/chunk-XQAJQKO7.js [22m[32m1.46 KB[39m
|
|
49
|
+
[32mESM[39m [1mdist/components/select/index.js [22m[32m411.00 B[39m
|
|
50
|
+
[32mESM[39m [1mdist/chunk-KZMSLRLW.js [22m[32m806.00 B[39m
|
|
52
51
|
[32mESM[39m [1mdist/chunk-4GPFVBO2.js [22m[32m1.66 KB[39m
|
|
53
|
-
[32mESM[39m [1mdist/
|
|
54
|
-
[32mESM[39m [1mdist/chunk-
|
|
52
|
+
[32mESM[39m [1mdist/components/avatar/index.js [22m[32m153.00 B[39m
|
|
53
|
+
[32mESM[39m [1mdist/chunk-QL4XJD7Y.js [22m[32m627.00 B[39m
|
|
55
54
|
[32mESM[39m [1mdist/chunk-VVNIYCKH.js [22m[32m1.04 KB[39m
|
|
55
|
+
[32mESM[39m [1mdist/chunk-FUWID6MC.js [22m[32m1.52 KB[39m
|
|
56
|
+
[32mESM[39m [1mdist/chunk-I44GXEPN.js [22m[32m809.00 B[39m
|
|
56
57
|
[32mESM[39m [1mdist/components/badge/index.js [22m[32m105.00 B[39m
|
|
57
|
-
[32mESM[39m [1mdist/
|
|
58
|
-
[32mESM[39m [1mdist/chunk-SKR3J46C.js [22m[32m363.00 B[39m
|
|
59
|
-
[32mESM[39m [1mdist/components/breadcrumb/index.js [22m[32m315.00 B[39m
|
|
58
|
+
[32mESM[39m [1mdist/chunk-J57CV3VT.js [22m[32m690.00 B[39m
|
|
60
59
|
[32mESM[39m [1mdist/chunk-VSXKLSEP.js [22m[32m2.45 KB[39m
|
|
61
|
-
[32mESM[39m [1mdist/chunk-UZIMC7AQ.js [22m[32m1.61 KB[39m
|
|
62
60
|
[32mESM[39m [1mdist/chunk-YTUI6MCB.js [22m[32m1.98 KB[39m
|
|
63
|
-
[32mESM[39m [1mdist/chunk-A3U73FA7.js [22m[32m1.25 KB[39m
|
|
64
61
|
[32mESM[39m [1mdist/components/card/index.js [22m[32m219.00 B[39m
|
|
65
|
-
[32mESM[39m [1mdist/components/
|
|
62
|
+
[32mESM[39m [1mdist/components/breadcrumb/index.js [22m[32m315.00 B[39m
|
|
66
63
|
[32mESM[39m [1mdist/components/dropdown/index.js [22m[32m757.00 B[39m
|
|
67
|
-
[32mESM[39m [1mdist/chunk-
|
|
68
|
-
[32mESM[39m [1mdist/chunk-
|
|
69
|
-
[32mESM[39m [1mdist/
|
|
64
|
+
[32mESM[39m [1mdist/chunk-AADRFFPH.js [22m[32m5.89 KB[39m
|
|
65
|
+
[32mESM[39m [1mdist/chunk-UZIMC7AQ.js [22m[32m1.61 KB[39m
|
|
66
|
+
[32mESM[39m [1mdist/components/button/index.js [22m[32m109.00 B[39m
|
|
70
67
|
[32mESM[39m [1mdist/components/checkbox/index.js [22m[32m91.00 B[39m
|
|
71
|
-
[32mESM[39m
|
|
68
|
+
[32mESM[39m [1mdist/chunk-SKR3J46C.js [22m[32m363.00 B[39m
|
|
69
|
+
[32mESM[39m [1mdist/chunk-PHMEWMFS.js [22m[32m7.52 KB[39m
|
|
70
|
+
[32mESM[39m [1mdist/chunk-A3U73FA7.js [22m[32m1.25 KB[39m
|
|
71
|
+
[32mESM[39m ⚡️ Build success in 35ms
|
|
72
72
|
DTS Build start
|
|
73
|
-
|
|
74
|
-
DTS dist/index.d.ts 6.00 KB
|
|
75
|
-
DTS dist/components/avatar/index.d.ts 611.00 B
|
|
76
|
-
DTS dist/components/badge/index.d.ts 653.00 B
|
|
77
|
-
DTS dist/components/breadcrumb/index.d.ts 1.06 KB
|
|
78
|
-
DTS dist/components/button/index.d.ts 806.00 B
|
|
79
|
-
DTS dist/components/card/index.d.ts 947.00 B
|
|
80
|
-
DTS dist/components/checkbox/index.d.ts 310.00 B
|
|
81
|
-
DTS dist/components/dropdown/index.d.ts 2.84 KB
|
|
82
|
-
DTS dist/components/input/index.d.ts 252.00 B
|
|
83
|
-
DTS dist/components/label/index.d.ts 295.00 B
|
|
84
|
-
DTS dist/components/popover/index.d.ts 768.00 B
|
|
85
|
-
DTS dist/components/radio-group/index.d.ts 481.00 B
|
|
86
|
-
DTS dist/components/scroll-area/index.d.ts 509.00 B
|
|
87
|
-
DTS dist/components/select/index.d.ts 1.75 KB
|
|
88
|
-
DTS dist/components/separator/index.d.ts 340.00 B
|
|
89
|
-
DTS dist/components/skeleton/index.d.ts 191.00 B
|
|
90
|
-
DTS dist/components/switch/index.d.ts 300.00 B
|
|
91
|
-
DTS dist/components/tabs/index.d.ts 734.00 B
|
|
92
|
-
DTS dist/components/textarea/index.d.ts 228.00 B
|
|
93
|
-
DTS dist/index.d.cts 6.02 KB
|
|
94
|
-
DTS dist/components/avatar/index.d.cts 611.00 B
|
|
95
|
-
DTS dist/components/badge/index.d.cts 653.00 B
|
|
96
|
-
DTS dist/components/breadcrumb/index.d.cts 1.06 KB
|
|
97
|
-
DTS dist/components/button/index.d.cts 806.00 B
|
|
98
|
-
DTS dist/components/card/index.d.cts 947.00 B
|
|
99
|
-
DTS dist/components/checkbox/index.d.cts 310.00 B
|
|
100
|
-
DTS dist/components/dropdown/index.d.cts 2.84 KB
|
|
101
|
-
DTS dist/components/input/index.d.cts 252.00 B
|
|
102
|
-
DTS dist/components/label/index.d.cts 295.00 B
|
|
103
|
-
DTS dist/components/popover/index.d.cts 768.00 B
|
|
104
|
-
DTS dist/components/radio-group/index.d.cts 481.00 B
|
|
105
|
-
DTS dist/components/scroll-area/index.d.cts 509.00 B
|
|
106
|
-
DTS dist/components/select/index.d.cts 1.75 KB
|
|
107
|
-
DTS dist/components/separator/index.d.cts 340.00 B
|
|
108
|
-
DTS dist/components/skeleton/index.d.cts 191.00 B
|
|
109
|
-
DTS dist/components/switch/index.d.cts 300.00 B
|
|
110
|
-
DTS dist/components/tabs/index.d.cts 734.00 B
|
|
111
|
-
DTS dist/components/textarea/index.d.cts 228.00 B
|
|
73
|
+
[41m[30m ELIFECYCLE [39m[49m [31mCommand failed.[39m
|
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundrykit/primitives",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-dom": "^19.1.1",
|
|
44
44
|
"tailwind-merge": "^3.3.1",
|
|
45
45
|
"zod": "^3.25.76",
|
|
46
|
-
"@foundrykit/types": "2.0.
|
|
46
|
+
"@foundrykit/types": "2.0.1",
|
|
47
47
|
"@foundrykit/utils": "1.0.6"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const inputGroupConfig: ComponentConfig = {
|
|
4
|
+
name: 'Input Group',
|
|
5
|
+
description:
|
|
6
|
+
'Composable input group with addons, buttons, text, inputs, and textareas',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['form', 'input', 'interactive'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="flex h-12 w-full items-center justify-center rounded-md bg-gray-200"><div class="flex h-8 w-full max-w-sm items-center rounded-lg border border-gray-300 bg-white"><div class="px-2 text-sm text-gray-500">@</div><div class="h-2 flex-1 rounded bg-gray-300"></div><div class="px-2 text-xs text-gray-500">.com</div></div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Default',
|
|
16
|
+
description: 'Input group with a leading text addon',
|
|
17
|
+
code: `<InputGroup>
|
|
18
|
+
<InputGroupAddon>
|
|
19
|
+
<InputGroupText>@</InputGroupText>
|
|
20
|
+
</InputGroupAddon>
|
|
21
|
+
<InputGroupInput placeholder="Username" />
|
|
22
|
+
</InputGroup>`,
|
|
23
|
+
preview: {
|
|
24
|
+
type: 'component',
|
|
25
|
+
component: 'InputGroup',
|
|
26
|
+
props: {
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
type: 'InputGroupAddon',
|
|
30
|
+
props: {
|
|
31
|
+
children: {
|
|
32
|
+
type: 'InputGroupText',
|
|
33
|
+
props: { children: '@' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'InputGroupInput',
|
|
39
|
+
props: { placeholder: 'Username' },
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'With End Addon',
|
|
47
|
+
description: 'Input group with trailing helper text',
|
|
48
|
+
code: `<InputGroup>
|
|
49
|
+
<InputGroupInput placeholder="company" />
|
|
50
|
+
<InputGroupAddon align="inline-end">
|
|
51
|
+
<InputGroupText>.com</InputGroupText>
|
|
52
|
+
</InputGroupAddon>
|
|
53
|
+
</InputGroup>`,
|
|
54
|
+
preview: {
|
|
55
|
+
type: 'component',
|
|
56
|
+
component: 'InputGroup',
|
|
57
|
+
props: {
|
|
58
|
+
children: [
|
|
59
|
+
{
|
|
60
|
+
type: 'InputGroupInput',
|
|
61
|
+
props: { placeholder: 'company' },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: 'InputGroupAddon',
|
|
65
|
+
props: {
|
|
66
|
+
align: 'inline-end',
|
|
67
|
+
children: {
|
|
68
|
+
type: 'InputGroupText',
|
|
69
|
+
props: { children: '.com' },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'With Button',
|
|
79
|
+
description: 'Input group with an inline action button',
|
|
80
|
+
code: `<InputGroup>
|
|
81
|
+
<InputGroupInput type="search" placeholder="Search docs..." />
|
|
82
|
+
<InputGroupAddon align="inline-end">
|
|
83
|
+
<InputGroupButton>Search</InputGroupButton>
|
|
84
|
+
</InputGroupAddon>
|
|
85
|
+
</InputGroup>`,
|
|
86
|
+
preview: {
|
|
87
|
+
type: 'component',
|
|
88
|
+
component: 'InputGroup',
|
|
89
|
+
props: {
|
|
90
|
+
children: [
|
|
91
|
+
{
|
|
92
|
+
type: 'InputGroupInput',
|
|
93
|
+
props: { type: 'search', placeholder: 'Search docs...' },
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'InputGroupAddon',
|
|
97
|
+
props: {
|
|
98
|
+
align: 'inline-end',
|
|
99
|
+
children: {
|
|
100
|
+
type: 'InputGroupButton',
|
|
101
|
+
props: { children: 'Search' },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'Block Addon',
|
|
111
|
+
description: 'Input group with an addon above the control',
|
|
112
|
+
code: `<InputGroup>
|
|
113
|
+
<InputGroupAddon align="block-start">
|
|
114
|
+
<InputGroupText>Amount</InputGroupText>
|
|
115
|
+
</InputGroupAddon>
|
|
116
|
+
<InputGroupInput type="number" placeholder="0.00" />
|
|
117
|
+
</InputGroup>`,
|
|
118
|
+
preview: {
|
|
119
|
+
type: 'component',
|
|
120
|
+
component: 'InputGroup',
|
|
121
|
+
props: {
|
|
122
|
+
children: [
|
|
123
|
+
{
|
|
124
|
+
type: 'InputGroupAddon',
|
|
125
|
+
props: {
|
|
126
|
+
align: 'block-start',
|
|
127
|
+
children: {
|
|
128
|
+
type: 'InputGroupText',
|
|
129
|
+
props: { children: 'Amount' },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: 'InputGroupInput',
|
|
135
|
+
props: { type: 'number', placeholder: '0.00' },
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'With Textarea',
|
|
143
|
+
description: 'Input group using the textarea control',
|
|
144
|
+
code: `<InputGroup>
|
|
145
|
+
<InputGroupTextarea placeholder="Write a note..." />
|
|
146
|
+
<InputGroupAddon align="block-end">
|
|
147
|
+
<InputGroupText>Markdown supported</InputGroupText>
|
|
148
|
+
</InputGroupAddon>
|
|
149
|
+
</InputGroup>`,
|
|
150
|
+
preview: {
|
|
151
|
+
type: 'component',
|
|
152
|
+
component: 'InputGroup',
|
|
153
|
+
props: {
|
|
154
|
+
children: [
|
|
155
|
+
{
|
|
156
|
+
type: 'InputGroupTextarea',
|
|
157
|
+
props: { placeholder: 'Write a note...' },
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: 'InputGroupAddon',
|
|
161
|
+
props: {
|
|
162
|
+
align: 'block-end',
|
|
163
|
+
children: {
|
|
164
|
+
type: 'InputGroupText',
|
|
165
|
+
props: { children: 'Markdown supported' },
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'Invalid',
|
|
175
|
+
description: 'Input group with an invalid control state',
|
|
176
|
+
code: `<InputGroup>
|
|
177
|
+
<InputGroupInput aria-invalid placeholder="Invalid email" />
|
|
178
|
+
<InputGroupAddon align="inline-end">
|
|
179
|
+
<InputGroupText>Error</InputGroupText>
|
|
180
|
+
</InputGroupAddon>
|
|
181
|
+
</InputGroup>`,
|
|
182
|
+
preview: {
|
|
183
|
+
type: 'component',
|
|
184
|
+
component: 'InputGroup',
|
|
185
|
+
props: {
|
|
186
|
+
children: [
|
|
187
|
+
{
|
|
188
|
+
type: 'InputGroupInput',
|
|
189
|
+
props: { 'aria-invalid': true, placeholder: 'Invalid email' },
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
type: 'InputGroupAddon',
|
|
193
|
+
props: {
|
|
194
|
+
align: 'inline-end',
|
|
195
|
+
children: {
|
|
196
|
+
type: 'InputGroupText',
|
|
197
|
+
props: { children: 'Error' },
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
dependencies: ['utils', 'button', 'input', 'textarea'],
|
|
207
|
+
packageDependencies: ['class-variance-authority'],
|
|
208
|
+
files: ['components/primitives/input-group/index.tsx'],
|
|
209
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type * as React from 'react';
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@foundrykit/utils';
|
|
7
|
+
import { Button } from '@foundrykit/primitives';
|
|
8
|
+
import { Input } from '@foundrykit/primitives';
|
|
9
|
+
import { Textarea } from '@foundrykit/primitives';
|
|
10
|
+
|
|
11
|
+
function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
data-slot='input-group'
|
|
15
|
+
role='group'
|
|
16
|
+
className={cn(
|
|
17
|
+
'group/input-group border-input in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 relative flex h-8 w-full min-w-0 items-center rounded-lg border outline-none transition-colors has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-start]]:h-auto has-[>textarea]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5',
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const inputGroupAddonVariants = cva(
|
|
26
|
+
"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
|
27
|
+
{
|
|
28
|
+
variants: {
|
|
29
|
+
align: {
|
|
30
|
+
'inline-start':
|
|
31
|
+
'order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]',
|
|
32
|
+
'inline-end':
|
|
33
|
+
'order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]',
|
|
34
|
+
'block-start':
|
|
35
|
+
'order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2',
|
|
36
|
+
'block-end':
|
|
37
|
+
'order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
align: 'inline-start',
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
function InputGroupAddon({
|
|
47
|
+
className,
|
|
48
|
+
align = 'inline-start',
|
|
49
|
+
...props
|
|
50
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
role='group'
|
|
54
|
+
data-slot='input-group-addon'
|
|
55
|
+
data-align={align}
|
|
56
|
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
57
|
+
onClick={e => {
|
|
58
|
+
if ((e.target as HTMLElement).closest('button')) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
e.currentTarget.parentElement?.querySelector('input')?.focus();
|
|
62
|
+
}}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const inputGroupButtonVariants = cva(
|
|
69
|
+
'flex items-center gap-2 text-sm shadow-none',
|
|
70
|
+
{
|
|
71
|
+
variants: {
|
|
72
|
+
size: {
|
|
73
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
|
74
|
+
sm: '',
|
|
75
|
+
'icon-xs':
|
|
76
|
+
'size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0',
|
|
77
|
+
'icon-sm': 'size-8 p-0 has-[>svg]:p-0',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: {
|
|
81
|
+
size: 'xs',
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
function InputGroupButton({
|
|
87
|
+
className,
|
|
88
|
+
type = 'button',
|
|
89
|
+
variant = 'ghost',
|
|
90
|
+
size = 'xs',
|
|
91
|
+
...props
|
|
92
|
+
}: Omit<React.ComponentProps<typeof Button>, 'size'> &
|
|
93
|
+
VariantProps<typeof inputGroupButtonVariants>) {
|
|
94
|
+
return (
|
|
95
|
+
<Button
|
|
96
|
+
type={type}
|
|
97
|
+
data-size={size}
|
|
98
|
+
variant={variant}
|
|
99
|
+
className={cn(inputGroupButtonVariants({ size }), className)}
|
|
100
|
+
{...props}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {
|
|
106
|
+
return (
|
|
107
|
+
<span
|
|
108
|
+
className={cn(
|
|
109
|
+
"text-muted-foreground flex items-center gap-2 text-sm [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
|
|
110
|
+
className
|
|
111
|
+
)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function InputGroupInput({
|
|
118
|
+
className,
|
|
119
|
+
...props
|
|
120
|
+
}: React.ComponentProps<'input'>) {
|
|
121
|
+
return (
|
|
122
|
+
<Input
|
|
123
|
+
data-slot='input-group-control'
|
|
124
|
+
className={cn(
|
|
125
|
+
'aria-invalid:ring-0 flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent dark:bg-transparent dark:disabled:bg-transparent',
|
|
126
|
+
className
|
|
127
|
+
)}
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function InputGroupTextarea({
|
|
134
|
+
className,
|
|
135
|
+
...props
|
|
136
|
+
}: React.ComponentProps<'textarea'>) {
|
|
137
|
+
return (
|
|
138
|
+
<Textarea
|
|
139
|
+
data-slot='input-group-control'
|
|
140
|
+
className={cn(
|
|
141
|
+
'aria-invalid:ring-0 flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent dark:bg-transparent dark:disabled:bg-transparent',
|
|
142
|
+
className
|
|
143
|
+
)}
|
|
144
|
+
{...props}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
InputGroup,
|
|
151
|
+
InputGroupAddon,
|
|
152
|
+
InputGroupButton,
|
|
153
|
+
InputGroupText,
|
|
154
|
+
InputGroupInput,
|
|
155
|
+
InputGroupTextarea,
|
|
156
|
+
};
|