@pushwoosh/dumb-components 1.1.39 → 1.1.41

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,433 @@
1
+ # Native Components - AI Documentation
2
+
3
+ > Auto-generated AI agent documentation for Native HTML components
4
+ > Part of @pushwoosh/dumb-components library
5
+
6
+ ## Overview
7
+ **Components:** NativeInput, NativeSelect, NativeTextarea
8
+ **Import Path:** `import { NativeInput, NativeSelect, NativeTextarea } from '@pushwoosh/dumb-components'`
9
+ **Files:**
10
+ - `native/Input.tsx` - Styled native input component
11
+ - `native/Select.tsx` - Styled native select component
12
+ - `native/Textarea.tsx` - Styled native textarea component
13
+ - `native/index.ts` - Main exports
14
+ **Type:** Base Form Components / Styled HTML Elements
15
+ **Description:** Styled-components wrappers around native HTML form elements. These provide consistent Pushwoosh Design System styling while maintaining native HTML behavior. Used internally by enhanced components like EnhancedInput.
16
+
17
+ ## TypeScript Interfaces
18
+
19
+ ### NativeInputProps
20
+ ```typescript
21
+ interface NativeInputProps {
22
+ $isErrored?: boolean; // Error state styling (red border)
23
+ }
24
+
25
+ // Extends all standard HTMLInputElement attributes:
26
+ // value, onChange, placeholder, type, disabled, readOnly, etc.
27
+ ```
28
+
29
+ ### NativeSelectProps
30
+ ```typescript
31
+ interface NativeSelectProps {
32
+ $isErrored?: boolean; // Error state styling (red border)
33
+ }
34
+
35
+ // Extends all standard HTMLSelectElement attributes:
36
+ // value, onChange, disabled, multiple, etc.
37
+ ```
38
+
39
+ ### NativeTextareaProps
40
+ ```typescript
41
+ interface NativeTextareaProps {
42
+ $width?: string; // Custom width (default: 100%)
43
+ $isErrored?: boolean; // Error state styling (red border)
44
+ }
45
+
46
+ // Extends all standard HTMLTextAreaElement attributes:
47
+ // value, onChange, placeholder, rows, cols, disabled, etc.
48
+ ```
49
+
50
+ ## Import & Usage
51
+
52
+ ### NativeInput
53
+ ```tsx
54
+ import { NativeInput } from '@pushwoosh/dumb-components';
55
+
56
+ function BasicInput() {
57
+ const [value, setValue] = useState('');
58
+
59
+ return (
60
+ <NativeInput
61
+ type="text"
62
+ value={value}
63
+ onChange={(e) => setValue(e.target.value)}
64
+ placeholder="Enter text..."
65
+ />
66
+ );
67
+ }
68
+ ```
69
+
70
+ ### NativeSelect
71
+ ```tsx
72
+ import { NativeSelect } from '@pushwoosh/dumb-components';
73
+
74
+ function BasicSelect() {
75
+ const [value, setValue] = useState('');
76
+
77
+ return (
78
+ <NativeSelect
79
+ value={value}
80
+ onChange={(e) => setValue(e.target.value)}
81
+ >
82
+ <option value="">Select an option</option>
83
+ <option value="option1">Option 1</option>
84
+ <option value="option2">Option 2</option>
85
+ <option value="option3">Option 3</option>
86
+ </NativeSelect>
87
+ );
88
+ }
89
+ ```
90
+
91
+ ### NativeTextarea
92
+ ```tsx
93
+ import { NativeTextarea } from '@pushwoosh/dumb-components';
94
+
95
+ function BasicTextarea() {
96
+ const [value, setValue] = useState('');
97
+
98
+ return (
99
+ <NativeTextarea
100
+ value={value}
101
+ onChange={(e) => setValue(e.target.value)}
102
+ placeholder="Enter your message..."
103
+ rows={4}
104
+ />
105
+ );
106
+ }
107
+ ```
108
+
109
+ ## Advanced Examples
110
+
111
+ ### Form with Validation
112
+ ```tsx
113
+ import { NativeInput, NativeSelect, NativeTextarea } from '@pushwoosh/dumb-components';
114
+
115
+ function ValidationForm() {
116
+ const [formData, setFormData] = useState({
117
+ name: '',
118
+ category: '',
119
+ message: ''
120
+ });
121
+ const [errors, setErrors] = useState({});
122
+
123
+ const validate = () => {
124
+ const newErrors = {};
125
+ if (!formData.name) newErrors.name = 'Name is required';
126
+ if (!formData.category) newErrors.category = 'Category is required';
127
+ if (!formData.message) newErrors.message = 'Message is required';
128
+
129
+ setErrors(newErrors);
130
+ return Object.keys(newErrors).length === 0;
131
+ };
132
+
133
+ const handleSubmit = (e) => {
134
+ e.preventDefault();
135
+ if (validate()) {
136
+ console.log('Form submitted:', formData);
137
+ }
138
+ };
139
+
140
+ return (
141
+ <form onSubmit={handleSubmit}>
142
+ <div>
143
+ <label>Name:</label>
144
+ <NativeInput
145
+ type="text"
146
+ value={formData.name}
147
+ onChange={(e) => setFormData({ ...formData, name: e.target.value })}
148
+ $isErrored={!!errors.name}
149
+ placeholder="Your name"
150
+ />
151
+ {errors.name && <span style={{ color: 'red' }}>{errors.name}</span>}
152
+ </div>
153
+
154
+ <div>
155
+ <label>Category:</label>
156
+ <NativeSelect
157
+ value={formData.category}
158
+ onChange={(e) => setFormData({ ...formData, category: e.target.value })}
159
+ $isErrored={!!errors.category}
160
+ >
161
+ <option value="">Select category</option>
162
+ <option value="bug">Bug Report</option>
163
+ <option value="feature">Feature Request</option>
164
+ <option value="question">Question</option>
165
+ </NativeSelect>
166
+ {errors.category && <span style={{ color: 'red' }}>{errors.category}</span>}
167
+ </div>
168
+
169
+ <div>
170
+ <label>Message:</label>
171
+ <NativeTextarea
172
+ value={formData.message}
173
+ onChange={(e) => setFormData({ ...formData, message: e.target.value })}
174
+ $isErrored={!!errors.message}
175
+ placeholder="Describe your issue..."
176
+ rows={5}
177
+ />
178
+ {errors.message && <span style={{ color: 'red' }}>{errors.message}</span>}
179
+ </div>
180
+
181
+ <button type="submit">Submit</button>
182
+ </form>
183
+ );
184
+ }
185
+ ```
186
+
187
+ ### Different Input Types
188
+ ```tsx
189
+ import { NativeInput } from '@pushwoosh/dumb-components';
190
+
191
+ function InputTypes() {
192
+ const [formData, setFormData] = useState({
193
+ email: '',
194
+ password: '',
195
+ number: '',
196
+ date: '',
197
+ url: ''
198
+ });
199
+
200
+ return (
201
+ <div>
202
+ <NativeInput
203
+ type="email"
204
+ value={formData.email}
205
+ onChange={(e) => setFormData({ ...formData, email: e.target.value })}
206
+ placeholder="email@example.com"
207
+ />
208
+
209
+ <NativeInput
210
+ type="password"
211
+ value={formData.password}
212
+ onChange={(e) => setFormData({ ...formData, password: e.target.value })}
213
+ placeholder="Password"
214
+ />
215
+
216
+ <NativeInput
217
+ type="number"
218
+ value={formData.number}
219
+ onChange={(e) => setFormData({ ...formData, number: e.target.value })}
220
+ placeholder="Enter number"
221
+ min="0"
222
+ max="100"
223
+ />
224
+
225
+ <NativeInput
226
+ type="date"
227
+ value={formData.date}
228
+ onChange={(e) => setFormData({ ...formData, date: e.target.value })}
229
+ />
230
+
231
+ <NativeInput
232
+ type="url"
233
+ value={formData.url}
234
+ onChange={(e) => setFormData({ ...formData, url: e.target.value })}
235
+ placeholder="https://example.com"
236
+ />
237
+ </div>
238
+ );
239
+ }
240
+ ```
241
+
242
+ ### Custom Textarea Sizes
243
+ ```tsx
244
+ import { NativeTextarea } from '@pushwoosh/dumb-components';
245
+
246
+ function TextareaSizes() {
247
+ return (
248
+ <div style={{ display: 'flex', gap: '20px' }}>
249
+ <NativeTextarea
250
+ placeholder="Small textarea"
251
+ $width="200px"
252
+ rows={3}
253
+ />
254
+
255
+ <NativeTextarea
256
+ placeholder="Medium textarea"
257
+ $width="300px"
258
+ rows={5}
259
+ />
260
+
261
+ <NativeTextarea
262
+ placeholder="Large textarea"
263
+ $width="400px"
264
+ rows={8}
265
+ />
266
+ </div>
267
+ );
268
+ }
269
+ ```
270
+
271
+ ### Select with Grouped Options
272
+ ```tsx
273
+ import { NativeSelect } from '@pushwoosh/dumb-components';
274
+
275
+ function GroupedSelect() {
276
+ const [value, setValue] = useState('');
277
+
278
+ return (
279
+ <NativeSelect
280
+ value={value}
281
+ onChange={(e) => setValue(e.target.value)}
282
+ >
283
+ <option value="">Choose a programming language</option>
284
+
285
+ <optgroup label="Frontend">
286
+ <option value="javascript">JavaScript</option>
287
+ <option value="typescript">TypeScript</option>
288
+ <option value="html">HTML</option>
289
+ <option value="css">CSS</option>
290
+ </optgroup>
291
+
292
+ <optgroup label="Backend">
293
+ <option value="node">Node.js</option>
294
+ <option value="python">Python</option>
295
+ <option value="java">Java</option>
296
+ <option value="csharp">C#</option>
297
+ </optgroup>
298
+
299
+ <optgroup label="Database">
300
+ <option value="mysql">MySQL</option>
301
+ <option value="postgresql">PostgreSQL</option>
302
+ <option value="mongodb">MongoDB</option>
303
+ </optgroup>
304
+ </NativeSelect>
305
+ );
306
+ }
307
+ ```
308
+
309
+ ### Disabled and ReadOnly States
310
+ ```tsx
311
+ import { NativeInput, NativeSelect, NativeTextarea } from '@pushwoosh/dumb-components';
312
+
313
+ function DisabledStates() {
314
+ return (
315
+ <div>
316
+ {/* Disabled inputs */}
317
+ <NativeInput
318
+ value="Disabled input"
319
+ disabled
320
+ placeholder="This is disabled"
321
+ />
322
+
323
+ <NativeSelect disabled>
324
+ <option>Disabled select</option>
325
+ </NativeSelect>
326
+
327
+ <NativeTextarea
328
+ value="Disabled textarea"
329
+ disabled
330
+ rows={3}
331
+ />
332
+
333
+ {/* Read-only inputs */}
334
+ <NativeInput
335
+ value="Read-only input"
336
+ readOnly
337
+ />
338
+
339
+ <NativeTextarea
340
+ value="Read-only textarea content"
341
+ readOnly
342
+ rows={3}
343
+ />
344
+ </div>
345
+ );
346
+ }
347
+ ```
348
+
349
+ ## Props Reference
350
+
351
+ ### Common Props (All Components)
352
+ | Prop | Type | Required | Default | Description |
353
+ |------|------|----------|---------|-------------|
354
+ | `$isErrored` | `boolean` | - | `false` | Show error state (red border) |
355
+ | `value` | `string` | - | - | Input value |
356
+ | `onChange` | `(e: ChangeEvent) => void` | - | - | Change handler |
357
+ | `disabled` | `boolean` | - | `false` | Disable the input |
358
+ | `readOnly` | `boolean` | - | `false` | Make input read-only |
359
+ | `placeholder` | `string` | - | - | Placeholder text |
360
+
361
+ ### NativeInput Specific Props
362
+ | Prop | Type | Required | Default | Description |
363
+ |------|------|----------|---------|-------------|
364
+ | `type` | `string` | - | `'text'` | Input type (text, email, password, number, etc.) |
365
+ | `autoComplete` | `string` | - | - | Browser autocomplete hint |
366
+ | `maxLength` | `number` | - | - | Maximum character length |
367
+ | `pattern` | `string` | - | - | Validation pattern (regex) |
368
+ | `min` | `string \| number` | - | - | Minimum value (for number/date inputs) |
369
+ | `max` | `string \| number` | - | - | Maximum value (for number/date inputs) |
370
+ | `step` | `string \| number` | - | - | Step value (for number inputs) |
371
+
372
+ ### NativeSelect Specific Props
373
+ | Prop | Type | Required | Default | Description |
374
+ |------|------|----------|---------|-------------|
375
+ | `multiple` | `boolean` | - | `false` | Allow multiple selections |
376
+ | `size` | `number` | - | - | Number of visible options |
377
+ | `children` | `ReactNode` | - | - | option and optgroup elements |
378
+
379
+ ### NativeTextarea Specific Props
380
+ | Prop | Type | Required | Default | Description |
381
+ |------|------|----------|---------|-------------|
382
+ | `$width` | `string` | - | `'100%'` | Custom width |
383
+ | `rows` | `number` | - | - | Number of visible rows |
384
+ | `cols` | `number` | - | - | Number of visible columns |
385
+ | `wrap` | `'soft' \| 'hard'` | - | `'soft'` | Text wrapping behavior |
386
+ | `resize` | `string` | - | - | CSS resize property |
387
+
388
+ ## AI Agent Guidelines
389
+
390
+ ### ✅ Recommended Patterns
391
+ - Use native components as building blocks for custom form components
392
+ - Always handle both `value` and `onChange` for controlled components
393
+ - Use `$isErrored` prop consistently for validation feedback
394
+ - Leverage HTML5 input types for better UX (email, number, date, etc.)
395
+ - Provide meaningful placeholder text and labels
396
+ - Use proper form structure with labels and validation messages
397
+ - Consider accessibility with proper ARIA attributes when needed
398
+
399
+ ### ❌ Common Mistakes to Avoid
400
+ - Don't forget the `$` prefix for styled-component props (`$isErrored`, `$width`)
401
+ - Don't mix controlled and uncontrolled patterns
402
+ - Avoid inline styles - use styled-components or CSS classes
403
+ - Don't skip validation feedback when using `$isErrored`
404
+ - Avoid putting complex logic in onChange handlers
405
+ - Don't forget to handle disabled states properly
406
+ - Avoid using these components directly in UI - prefer enhanced versions
407
+
408
+ ### Integration Tips
409
+ - These are **base components** - typically used internally by other components
410
+ - All components use Pushwoosh Design System tokens for consistent styling
411
+ - Error states automatically change border color to red
412
+ - Focus states are styled with bright blue border
413
+ - Disabled states use frozen background color
414
+ - NativeSelect includes custom dropdown arrow styling
415
+ - Components automatically inherit font family from design system
416
+ - Use EnhancedInput, Select, etc. for user-facing forms instead
417
+
418
+ ### Styling Notes
419
+ - Components use `styled-components` with design system constants
420
+ - Border radius uses `ShapeRadius.CONTROL`
421
+ - Colors are from Pushwoosh color palette
422
+ - Font sizes and line heights are from typography scale
423
+ - Input height is standardized using `UnitSize.FIELD_HEIGHT`
424
+ - Focus outline is removed in favor of border styling
425
+
426
+ ## Related Components
427
+ - **EnhancedInput** - Uses NativeInput internally with icons and clear functionality
428
+ - **Select** - Advanced select component built on react-select
429
+ - **Radio** - For single choice selections
430
+ - **Checkbox** - For boolean/multiple choice inputs
431
+ - **Switch** - For boolean toggle inputs
432
+ - **DateTimePicker** - For date/time selections
433
+ - **InputFile** - For file uploads
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -8,7 +8,8 @@
8
8
  "sideEffects": false,
9
9
  "scripts": {
10
10
  "start": "npm --prefix ./storybook run storybook",
11
- "build": "pushwoosh-engine lib:build",
11
+ "build": "pushwoosh-engine lib:build && npm run copy-docs",
12
+ "copy-docs": "node scripts/copy-docs.js",
12
13
  "check": "npm run check:lint && npm run check:types",
13
14
  "check:lint": "echo \"Run check:lint\" && eslint src",
14
15
  "check:types": "echo \"Run check:types\" && pushwoosh-engine lib:check-types"
@@ -26,6 +27,7 @@
26
27
  "@types/react-dom": "^18.2.22",
27
28
  "@types/react-transition-group": "^4.4.12",
28
29
  "@types/styled-components": "^5.1.34",
30
+ "glob": "^11.0.3",
29
31
  "pre-commit": "^1.2.2",
30
32
  "react": "^18.2.0",
31
33
  "react-dom": "^18.2.0",
@@ -37,10 +39,10 @@
37
39
  "@codemirror/lang-liquid": "^6.2.2",
38
40
  "@floating-ui/react-dom": "^2.1.2",
39
41
  "@lezer/highlight": "^1.2.1",
40
- "@pushwoosh/kit-constants": "^1.6.9",
41
- "@pushwoosh/kit-helpers": "^4.8.2",
42
- "@pushwoosh/kit-icons": "^2.1.2",
43
- "@pushwoosh/kit-typography": "^1.7.3",
42
+ "@pushwoosh/kit-constants": "^1.6.12",
43
+ "@pushwoosh/kit-helpers": "^4.8.5",
44
+ "@pushwoosh/kit-icons": "^2.1.8",
45
+ "@pushwoosh/kit-typography": "^1.7.4",
44
46
  "@tippyjs/react": "^4.2.6",
45
47
  "@uiw/codemirror-themes": "^4.23.8",
46
48
  "@uiw/react-codemirror": "^4.23.8",