zenput 1.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.
Files changed (148) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +271 -0
  3. package/dist/cjs/index.js +1126 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/cjs/types/components/AutoComplete/AutoComplete.d.ts +3 -0
  6. package/dist/cjs/types/components/AutoComplete/AutoComplete.types.d.ts +27 -0
  7. package/dist/cjs/types/components/AutoComplete/index.d.ts +2 -0
  8. package/dist/cjs/types/components/Checkbox/Checkbox.d.ts +3 -0
  9. package/dist/cjs/types/components/Checkbox/Checkbox.types.d.ts +6 -0
  10. package/dist/cjs/types/components/Checkbox/index.d.ts +2 -0
  11. package/dist/cjs/types/components/CheckboxGroup/CheckboxGroup.d.ts +3 -0
  12. package/dist/cjs/types/components/CheckboxGroup/CheckboxGroup.types.d.ts +20 -0
  13. package/dist/cjs/types/components/CheckboxGroup/index.d.ts +2 -0
  14. package/dist/cjs/types/components/ColorInput/ColorInput.d.ts +3 -0
  15. package/dist/cjs/types/components/ColorInput/ColorInput.types.d.ts +6 -0
  16. package/dist/cjs/types/components/ColorInput/index.d.ts +2 -0
  17. package/dist/cjs/types/components/DataTable/DataTable.d.ts +5 -0
  18. package/dist/cjs/types/components/DataTable/DataTable.types.d.ts +31 -0
  19. package/dist/cjs/types/components/DataTable/index.d.ts +2 -0
  20. package/dist/cjs/types/components/DateInput/DateInput.d.ts +3 -0
  21. package/dist/cjs/types/components/DateInput/DateInput.types.d.ts +8 -0
  22. package/dist/cjs/types/components/DateInput/index.d.ts +2 -0
  23. package/dist/cjs/types/components/FileInput/FileInput.d.ts +3 -0
  24. package/dist/cjs/types/components/FileInput/FileInput.types.d.ts +10 -0
  25. package/dist/cjs/types/components/FileInput/index.d.ts +2 -0
  26. package/dist/cjs/types/components/NumberInput/NumberInput.d.ts +3 -0
  27. package/dist/cjs/types/components/NumberInput/NumberInput.types.d.ts +18 -0
  28. package/dist/cjs/types/components/NumberInput/index.d.ts +2 -0
  29. package/dist/cjs/types/components/OTPInput/OTPInput.d.ts +3 -0
  30. package/dist/cjs/types/components/OTPInput/OTPInput.types.d.ts +20 -0
  31. package/dist/cjs/types/components/OTPInput/index.d.ts +2 -0
  32. package/dist/cjs/types/components/PasswordInput/PasswordInput.d.ts +3 -0
  33. package/dist/cjs/types/components/PasswordInput/PasswordInput.types.d.ts +10 -0
  34. package/dist/cjs/types/components/PasswordInput/index.d.ts +2 -0
  35. package/dist/cjs/types/components/PhoneInput/PhoneInput.d.ts +3 -0
  36. package/dist/cjs/types/components/PhoneInput/PhoneInput.types.d.ts +20 -0
  37. package/dist/cjs/types/components/PhoneInput/index.d.ts +2 -0
  38. package/dist/cjs/types/components/RadioGroup/RadioGroup.d.ts +3 -0
  39. package/dist/cjs/types/components/RadioGroup/RadioGroup.types.d.ts +22 -0
  40. package/dist/cjs/types/components/RadioGroup/index.d.ts +2 -0
  41. package/dist/cjs/types/components/RangeInput/RangeInput.d.ts +3 -0
  42. package/dist/cjs/types/components/RangeInput/RangeInput.types.d.ts +14 -0
  43. package/dist/cjs/types/components/RangeInput/index.d.ts +2 -0
  44. package/dist/cjs/types/components/SearchInput/SearchInput.d.ts +3 -0
  45. package/dist/cjs/types/components/SearchInput/SearchInput.types.d.ts +10 -0
  46. package/dist/cjs/types/components/SearchInput/index.d.ts +2 -0
  47. package/dist/cjs/types/components/SelectInput/SelectInput.d.ts +3 -0
  48. package/dist/cjs/types/components/SelectInput/SelectInput.types.d.ts +13 -0
  49. package/dist/cjs/types/components/SelectInput/index.d.ts +2 -0
  50. package/dist/cjs/types/components/TextArea/TextArea.d.ts +3 -0
  51. package/dist/cjs/types/components/TextArea/TextArea.types.d.ts +8 -0
  52. package/dist/cjs/types/components/TextArea/index.d.ts +2 -0
  53. package/dist/cjs/types/components/TextInput/TextInput.d.ts +3 -0
  54. package/dist/cjs/types/components/TextInput/TextInput.types.d.ts +4 -0
  55. package/dist/cjs/types/components/TextInput/index.d.ts +2 -0
  56. package/dist/cjs/types/components/TimeInput/TimeInput.d.ts +3 -0
  57. package/dist/cjs/types/components/TimeInput/TimeInput.types.d.ts +8 -0
  58. package/dist/cjs/types/components/TimeInput/index.d.ts +2 -0
  59. package/dist/cjs/types/components/Toggle/Toggle.d.ts +3 -0
  60. package/dist/cjs/types/components/Toggle/Toggle.types.d.ts +6 -0
  61. package/dist/cjs/types/components/Toggle/index.d.ts +2 -0
  62. package/dist/cjs/types/components/index.d.ts +19 -0
  63. package/dist/cjs/types/context/ThemeProvider.d.ts +27 -0
  64. package/dist/cjs/types/context/index.d.ts +1 -0
  65. package/dist/cjs/types/hooks/index.d.ts +2 -0
  66. package/dist/cjs/types/hooks/useControllable.d.ts +7 -0
  67. package/dist/cjs/types/hooks/useFormField.d.ts +25 -0
  68. package/dist/cjs/types/index.d.ts +4 -0
  69. package/dist/cjs/types/types/common.d.ts +52 -0
  70. package/dist/cjs/types/types/index.d.ts +1 -0
  71. package/dist/cjs/types/utils/classNames.d.ts +3 -0
  72. package/dist/cjs/types/utils/constants.d.ts +9 -0
  73. package/dist/cjs/types/utils/index.d.ts +3 -0
  74. package/dist/cjs/types/utils/validation.d.ts +23 -0
  75. package/dist/esm/index.js +1102 -0
  76. package/dist/esm/index.js.map +1 -0
  77. package/dist/esm/types/components/AutoComplete/AutoComplete.d.ts +3 -0
  78. package/dist/esm/types/components/AutoComplete/AutoComplete.types.d.ts +27 -0
  79. package/dist/esm/types/components/AutoComplete/index.d.ts +2 -0
  80. package/dist/esm/types/components/Checkbox/Checkbox.d.ts +3 -0
  81. package/dist/esm/types/components/Checkbox/Checkbox.types.d.ts +6 -0
  82. package/dist/esm/types/components/Checkbox/index.d.ts +2 -0
  83. package/dist/esm/types/components/CheckboxGroup/CheckboxGroup.d.ts +3 -0
  84. package/dist/esm/types/components/CheckboxGroup/CheckboxGroup.types.d.ts +20 -0
  85. package/dist/esm/types/components/CheckboxGroup/index.d.ts +2 -0
  86. package/dist/esm/types/components/ColorInput/ColorInput.d.ts +3 -0
  87. package/dist/esm/types/components/ColorInput/ColorInput.types.d.ts +6 -0
  88. package/dist/esm/types/components/ColorInput/index.d.ts +2 -0
  89. package/dist/esm/types/components/DataTable/DataTable.d.ts +5 -0
  90. package/dist/esm/types/components/DataTable/DataTable.types.d.ts +31 -0
  91. package/dist/esm/types/components/DataTable/index.d.ts +2 -0
  92. package/dist/esm/types/components/DateInput/DateInput.d.ts +3 -0
  93. package/dist/esm/types/components/DateInput/DateInput.types.d.ts +8 -0
  94. package/dist/esm/types/components/DateInput/index.d.ts +2 -0
  95. package/dist/esm/types/components/FileInput/FileInput.d.ts +3 -0
  96. package/dist/esm/types/components/FileInput/FileInput.types.d.ts +10 -0
  97. package/dist/esm/types/components/FileInput/index.d.ts +2 -0
  98. package/dist/esm/types/components/NumberInput/NumberInput.d.ts +3 -0
  99. package/dist/esm/types/components/NumberInput/NumberInput.types.d.ts +18 -0
  100. package/dist/esm/types/components/NumberInput/index.d.ts +2 -0
  101. package/dist/esm/types/components/OTPInput/OTPInput.d.ts +3 -0
  102. package/dist/esm/types/components/OTPInput/OTPInput.types.d.ts +20 -0
  103. package/dist/esm/types/components/OTPInput/index.d.ts +2 -0
  104. package/dist/esm/types/components/PasswordInput/PasswordInput.d.ts +3 -0
  105. package/dist/esm/types/components/PasswordInput/PasswordInput.types.d.ts +10 -0
  106. package/dist/esm/types/components/PasswordInput/index.d.ts +2 -0
  107. package/dist/esm/types/components/PhoneInput/PhoneInput.d.ts +3 -0
  108. package/dist/esm/types/components/PhoneInput/PhoneInput.types.d.ts +20 -0
  109. package/dist/esm/types/components/PhoneInput/index.d.ts +2 -0
  110. package/dist/esm/types/components/RadioGroup/RadioGroup.d.ts +3 -0
  111. package/dist/esm/types/components/RadioGroup/RadioGroup.types.d.ts +22 -0
  112. package/dist/esm/types/components/RadioGroup/index.d.ts +2 -0
  113. package/dist/esm/types/components/RangeInput/RangeInput.d.ts +3 -0
  114. package/dist/esm/types/components/RangeInput/RangeInput.types.d.ts +14 -0
  115. package/dist/esm/types/components/RangeInput/index.d.ts +2 -0
  116. package/dist/esm/types/components/SearchInput/SearchInput.d.ts +3 -0
  117. package/dist/esm/types/components/SearchInput/SearchInput.types.d.ts +10 -0
  118. package/dist/esm/types/components/SearchInput/index.d.ts +2 -0
  119. package/dist/esm/types/components/SelectInput/SelectInput.d.ts +3 -0
  120. package/dist/esm/types/components/SelectInput/SelectInput.types.d.ts +13 -0
  121. package/dist/esm/types/components/SelectInput/index.d.ts +2 -0
  122. package/dist/esm/types/components/TextArea/TextArea.d.ts +3 -0
  123. package/dist/esm/types/components/TextArea/TextArea.types.d.ts +8 -0
  124. package/dist/esm/types/components/TextArea/index.d.ts +2 -0
  125. package/dist/esm/types/components/TextInput/TextInput.d.ts +3 -0
  126. package/dist/esm/types/components/TextInput/TextInput.types.d.ts +4 -0
  127. package/dist/esm/types/components/TextInput/index.d.ts +2 -0
  128. package/dist/esm/types/components/TimeInput/TimeInput.d.ts +3 -0
  129. package/dist/esm/types/components/TimeInput/TimeInput.types.d.ts +8 -0
  130. package/dist/esm/types/components/TimeInput/index.d.ts +2 -0
  131. package/dist/esm/types/components/Toggle/Toggle.d.ts +3 -0
  132. package/dist/esm/types/components/Toggle/Toggle.types.d.ts +6 -0
  133. package/dist/esm/types/components/Toggle/index.d.ts +2 -0
  134. package/dist/esm/types/components/index.d.ts +19 -0
  135. package/dist/esm/types/context/ThemeProvider.d.ts +27 -0
  136. package/dist/esm/types/context/index.d.ts +1 -0
  137. package/dist/esm/types/hooks/index.d.ts +2 -0
  138. package/dist/esm/types/hooks/useControllable.d.ts +7 -0
  139. package/dist/esm/types/hooks/useFormField.d.ts +25 -0
  140. package/dist/esm/types/index.d.ts +4 -0
  141. package/dist/esm/types/types/common.d.ts +52 -0
  142. package/dist/esm/types/types/index.d.ts +1 -0
  143. package/dist/esm/types/utils/classNames.d.ts +3 -0
  144. package/dist/esm/types/utils/constants.d.ts +9 -0
  145. package/dist/esm/types/utils/index.d.ts +3 -0
  146. package/dist/esm/types/utils/validation.d.ts +23 -0
  147. package/dist/index.d.ts +401 -0
  148. package/package.json +69 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 konarsubhojit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,271 @@
1
+ # Zenput
2
+
3
+ A production-ready, accessible React TypeScript input components library with 18 fully-featured components.
4
+
5
+ ## Features
6
+
7
+ - 🎯 **18 input components** — TextInput, TextArea, NumberInput, PasswordInput, SelectInput, Checkbox, CheckboxGroup, RadioGroup, Toggle, DateInput, TimeInput, FileInput, RangeInput, ColorInput, SearchInput, PhoneInput, OTPInput, AutoComplete
8
+ - ♿ **Fully accessible** — ARIA attributes, keyboard navigation, screen reader support
9
+ - 🎨 **Themeable** — CSS custom properties with `ThemeProvider`
10
+ - 📐 **3 sizes** — `sm`, `md`, `lg`
11
+ - 🖼️ **3 variants** — `outlined`, `filled`, `underlined`
12
+ - ✅ **Validation states** — `default`, `error`, `success`, `warning`
13
+ - 🔒 **TypeScript strict** — No `any` types, full type safety
14
+ - 📦 **Tree-shakeable** — ESM + CJS dual output
15
+ - 🧪 **Tested** — comprehensive test coverage with React Testing Library
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install zenput
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```tsx
26
+ import { TextInput, ThemeProvider } from 'zenput';
27
+
28
+ function App() {
29
+ return (
30
+ <ThemeProvider theme={{ primaryColor: '#6366f1' }}>
31
+ <TextInput
32
+ label="Email"
33
+ placeholder="you@example.com"
34
+ required
35
+ fullWidth
36
+ />
37
+ </ThemeProvider>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ## Components
43
+
44
+ ### TextInput
45
+ ```tsx
46
+ <TextInput
47
+ label="Username"
48
+ placeholder="Enter username"
49
+ size="md"
50
+ variant="outlined"
51
+ validationState="error"
52
+ errorMessage="Username is required"
53
+ required
54
+ fullWidth
55
+ />
56
+ ```
57
+
58
+ ### TextArea
59
+ ```tsx
60
+ <TextArea
61
+ label="Bio"
62
+ placeholder="Tell us about yourself"
63
+ autoResize
64
+ showCharCount
65
+ maxLength={500}
66
+ rows={4}
67
+ />
68
+ ```
69
+
70
+ ### NumberInput
71
+ ```tsx
72
+ <NumberInput
73
+ label="Quantity"
74
+ min={0}
75
+ max={100}
76
+ step={1}
77
+ defaultValue={1}
78
+ />
79
+ ```
80
+
81
+ ### PasswordInput
82
+ ```tsx
83
+ <PasswordInput
84
+ label="Password"
85
+ showStrengthIndicator
86
+ />
87
+ ```
88
+
89
+ ### SelectInput
90
+ ```tsx
91
+ <SelectInput
92
+ label="Country"
93
+ options={[
94
+ { value: 'us', label: 'United States' },
95
+ { value: 'uk', label: 'United Kingdom' },
96
+ ]}
97
+ placeholder="Select a country"
98
+ />
99
+ ```
100
+
101
+ ### Checkbox
102
+ ```tsx
103
+ <Checkbox label="I agree to the terms" required />
104
+ ```
105
+
106
+ ### CheckboxGroup
107
+ ```tsx
108
+ <CheckboxGroup
109
+ label="Interests"
110
+ options={[
111
+ { value: 'react', label: 'React' },
112
+ { value: 'typescript', label: 'TypeScript' },
113
+ { value: 'node', label: 'Node.js' },
114
+ ]}
115
+ value={['react']}
116
+ onChange={(values) => console.log(values)}
117
+ />
118
+ ```
119
+
120
+ ### RadioGroup
121
+ ```tsx
122
+ <RadioGroup
123
+ label="Plan"
124
+ options={[
125
+ { value: 'free', label: 'Free' },
126
+ { value: 'pro', label: 'Pro' },
127
+ { value: 'enterprise', label: 'Enterprise' },
128
+ ]}
129
+ value="free"
130
+ onChange={(value) => console.log(value)}
131
+ />
132
+ ```
133
+
134
+ ### Toggle
135
+ ```tsx
136
+ <Toggle label="Enable notifications" defaultChecked />
137
+ ```
138
+
139
+ ### DateInput
140
+ ```tsx
141
+ <DateInput label="Date of birth" min="1900-01-01" max="2024-12-31" />
142
+ ```
143
+
144
+ ### TimeInput
145
+ ```tsx
146
+ <TimeInput label="Meeting time" />
147
+ ```
148
+
149
+ ### FileInput
150
+ ```tsx
151
+ <FileInput label="Upload avatar" accept="image/*" />
152
+ ```
153
+
154
+ ### RangeInput
155
+ ```tsx
156
+ <RangeInput label="Volume" min={0} max={100} defaultValue={50} showValue />
157
+ ```
158
+
159
+ ### ColorInput
160
+ ```tsx
161
+ <ColorInput label="Brand color" defaultValue="#3b82f6" />
162
+ ```
163
+
164
+ ### SearchInput
165
+ ```tsx
166
+ <SearchInput
167
+ label="Search"
168
+ placeholder="Search..."
169
+ onSearch={(q) => console.log(q)}
170
+ />
171
+ ```
172
+
173
+ ### PhoneInput
174
+ ```tsx
175
+ <PhoneInput
176
+ label="Phone number"
177
+ defaultDialCode="+1"
178
+ />
179
+ ```
180
+
181
+ ### OTPInput
182
+ ```tsx
183
+ <OTPInput
184
+ label="Verification code"
185
+ length={6}
186
+ onChange={(value) => console.log(value)}
187
+ />
188
+ ```
189
+
190
+ ### AutoComplete
191
+ ```tsx
192
+ <AutoComplete
193
+ label="City"
194
+ options={[
195
+ { value: 'nyc', label: 'New York' },
196
+ { value: 'la', label: 'Los Angeles' },
197
+ { value: 'chi', label: 'Chicago' },
198
+ ]}
199
+ onSearch={(q) => console.log(q)}
200
+ />
201
+ ```
202
+
203
+ ## Theming
204
+
205
+ Use `ThemeProvider` to customise the design tokens:
206
+
207
+ ```tsx
208
+ import { ThemeProvider } from 'zenput';
209
+
210
+ <ThemeProvider
211
+ theme={{
212
+ primaryColor: '#6366f1',
213
+ errorColor: '#dc2626',
214
+ successColor: '#16a34a',
215
+ warningColor: '#d97706',
216
+ borderRadius: '8px',
217
+ fontFamily: 'Inter, sans-serif',
218
+ }}
219
+ >
220
+ {/* your app */}
221
+ </ThemeProvider>
222
+ ```
223
+
224
+ ## Props
225
+
226
+ ### Common props (all components inherit `BaseInputProps`)
227
+
228
+ | Prop | Type | Default | Description |
229
+ |------|------|---------|-------------|
230
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Visual size |
231
+ | `variant` | `'outlined' \| 'filled' \| 'underlined'` | `'outlined'` | Visual variant |
232
+ | `validationState` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Validation state |
233
+ | `label` | `string` | — | Label text |
234
+ | `helperText` | `string` | — | Helper text below input |
235
+ | `errorMessage` | `string` | — | Error message (shown when `validationState='error'`) |
236
+ | `successMessage` | `string` | — | Success message |
237
+ | `warningMessage` | `string` | — | Warning message |
238
+ | `required` | `boolean` | `false` | Mark field as required |
239
+ | `disabled` | `boolean` | `false` | Disable the input |
240
+ | `readOnly` | `boolean` | `false` | Make the input read-only |
241
+ | `prefixIcon` | `React.ReactNode` | — | Icon/element before the input |
242
+ | `suffixIcon` | `React.ReactNode` | — | Icon/element after the input |
243
+ | `fullWidth` | `boolean` | `false` | Expand to full container width |
244
+ | `wrapperClassName` | `string` | — | Class for the wrapper element |
245
+ | `inputClassName` | `string` | — | Class for the input element |
246
+
247
+ ## Development
248
+
249
+ ```bash
250
+ # Install dependencies
251
+ npm install
252
+
253
+ # Run tests
254
+ npm test
255
+
256
+ # Run tests with coverage
257
+ npm run test:coverage
258
+
259
+ # Build the library
260
+ npm run build
261
+
262
+ # Lint
263
+ npm run lint
264
+
265
+ # Type check
266
+ npm run type-check
267
+ ```
268
+
269
+ ## License
270
+
271
+ MIT © konarsubhojit