pure-react-ui 1.5.1 → 1.5.3
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/README.md +217 -0
- package/lib/components/Form/Checkbox.d.ts +11 -0
- package/lib/components/Form/Checkbox.d.ts.map +1 -0
- package/lib/components/Form/Checkbox.js +25 -0
- package/lib/components/Form/Checkbox.js.map +1 -0
- package/lib/components/Form/Form.css +733 -0
- package/lib/components/Form/Form.d.ts +13 -0
- package/lib/components/Form/Form.d.ts.map +1 -0
- package/lib/components/Form/Form.js +36 -0
- package/lib/components/Form/Form.js.map +1 -0
- package/lib/components/Form/FormContext.d.ts +25 -0
- package/lib/components/Form/FormContext.d.ts.map +1 -0
- package/lib/components/Form/FormContext.js +70 -0
- package/lib/components/Form/FormContext.js.map +1 -0
- package/lib/components/Form/FormGroup.d.ts +12 -0
- package/lib/components/Form/FormGroup.d.ts.map +1 -0
- package/lib/components/Form/FormGroup.js +21 -0
- package/lib/components/Form/FormGroup.js.map +1 -0
- package/lib/components/Form/FormItem.d.ts +19 -0
- package/lib/components/Form/FormItem.d.ts.map +1 -0
- package/lib/components/Form/FormItem.js +84 -0
- package/lib/components/Form/FormItem.js.map +1 -0
- package/lib/components/Form/FormRow.d.ts +9 -0
- package/lib/components/Form/FormRow.d.ts.map +1 -0
- package/lib/components/Form/FormRow.js +17 -0
- package/lib/components/Form/FormRow.js.map +1 -0
- package/lib/components/Form/Input.d.ts +13 -0
- package/lib/components/Form/Input.d.ts.map +1 -0
- package/lib/components/Form/Input.js +28 -0
- package/lib/components/Form/Input.js.map +1 -0
- package/lib/components/Form/Radio.d.ts +11 -0
- package/lib/components/Form/Radio.d.ts.map +1 -0
- package/lib/components/Form/Radio.js +25 -0
- package/lib/components/Form/Radio.js.map +1 -0
- package/lib/components/Form/Select.d.ts +18 -0
- package/lib/components/Form/Select.d.ts.map +1 -0
- package/lib/components/Form/Select.js +25 -0
- package/lib/components/Form/Select.js.map +1 -0
- package/lib/components/Form/Switch.d.ts +11 -0
- package/lib/components/Form/Switch.d.ts.map +1 -0
- package/lib/components/Form/Switch.js +25 -0
- package/lib/components/Form/Switch.js.map +1 -0
- package/lib/components/Form/Textarea.d.ts +13 -0
- package/lib/components/Form/Textarea.d.ts.map +1 -0
- package/lib/components/Form/Textarea.js +29 -0
- package/lib/components/Form/Textarea.js.map +1 -0
- package/lib/components/Form/index.d.ts +24 -0
- package/lib/components/Form/index.d.ts.map +1 -0
- package/lib/components/Form/index.js +13 -0
- package/lib/components/Form/index.js.map +1 -0
- package/lib/components/Form/useForm.d.ts +3 -0
- package/lib/components/Form/useForm.d.ts.map +1 -0
- package/lib/components/Form/useForm.js +17 -0
- package/lib/components/Form/useForm.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -245,6 +245,215 @@ import { Text } from 'pure-react-ui';
|
|
|
245
245
|
- `truncate`: boolean (default: false) - Truncate text with ellipsis
|
|
246
246
|
- `className`: string (optional) - Additional CSS classes
|
|
247
247
|
|
|
248
|
+
### Form Components
|
|
249
|
+
|
|
250
|
+
A comprehensive form component system with all form elements.
|
|
251
|
+
|
|
252
|
+
#### Form
|
|
253
|
+
|
|
254
|
+
The main form container component.
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
import { Form } from 'pure-react-ui';
|
|
258
|
+
|
|
259
|
+
<Form layout="vertical" onSubmit={handleSubmit}>
|
|
260
|
+
{/* Form fields */}
|
|
261
|
+
</Form>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Props:**
|
|
265
|
+
- `layout`: 'vertical' | 'horizontal' | 'inline' (default: 'vertical')
|
|
266
|
+
- `size`: 'small' | 'medium' | 'large' (default: 'medium')
|
|
267
|
+
- `onSubmit`: (e: React.FormEvent) => void (optional)
|
|
268
|
+
- All standard form HTML attributes
|
|
269
|
+
|
|
270
|
+
#### Input
|
|
271
|
+
|
|
272
|
+
Text input field with validation and icons.
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { Input } from 'pure-react-ui';
|
|
276
|
+
|
|
277
|
+
<Input
|
|
278
|
+
label="Email"
|
|
279
|
+
type="email"
|
|
280
|
+
placeholder="Enter email"
|
|
281
|
+
error={errors.email}
|
|
282
|
+
helpText="We'll never share your email"
|
|
283
|
+
leftIcon={<Icon name="Mail" />}
|
|
284
|
+
fullWidth
|
|
285
|
+
/>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Props:**
|
|
289
|
+
- `label`: string (optional)
|
|
290
|
+
- `error`: string (optional) - Error message
|
|
291
|
+
- `helpText`: string (optional) - Help text
|
|
292
|
+
- `leftIcon`: React.ReactNode (optional)
|
|
293
|
+
- `rightIcon`: React.ReactNode (optional)
|
|
294
|
+
- `fullWidth`: boolean (default: false)
|
|
295
|
+
- `size`: 'small' | 'medium' | 'large' (default: 'medium')
|
|
296
|
+
- All standard input HTML attributes
|
|
297
|
+
|
|
298
|
+
#### Textarea
|
|
299
|
+
|
|
300
|
+
Multi-line text input.
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
import { Textarea } from 'pure-react-ui';
|
|
304
|
+
|
|
305
|
+
<Textarea
|
|
306
|
+
label="Message"
|
|
307
|
+
placeholder="Enter your message"
|
|
308
|
+
rows={4}
|
|
309
|
+
resize="vertical"
|
|
310
|
+
fullWidth
|
|
311
|
+
/>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Props:**
|
|
315
|
+
- `label`: string (optional)
|
|
316
|
+
- `error`: string (optional)
|
|
317
|
+
- `helpText`: string (optional)
|
|
318
|
+
- `fullWidth`: boolean (default: false)
|
|
319
|
+
- `size`: 'small' | 'medium' | 'large' (default: 'medium')
|
|
320
|
+
- `rows`: number (default: 4)
|
|
321
|
+
- `resize`: 'none' | 'both' | 'horizontal' | 'vertical' (default: 'vertical')
|
|
322
|
+
- All standard textarea HTML attributes
|
|
323
|
+
|
|
324
|
+
#### Select
|
|
325
|
+
|
|
326
|
+
Dropdown select component.
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import { Select } from 'pure-react-ui';
|
|
330
|
+
|
|
331
|
+
<Select
|
|
332
|
+
label="Country"
|
|
333
|
+
options={[
|
|
334
|
+
{ value: 'us', label: 'United States' },
|
|
335
|
+
{ value: 'uk', label: 'United Kingdom' }
|
|
336
|
+
]}
|
|
337
|
+
placeholder="Choose a country"
|
|
338
|
+
fullWidth
|
|
339
|
+
/>
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Props:**
|
|
343
|
+
- `label`: string (optional)
|
|
344
|
+
- `error`: string (optional)
|
|
345
|
+
- `helpText`: string (optional)
|
|
346
|
+
- `options`: SelectOption[] (required)
|
|
347
|
+
- `placeholder`: string (optional)
|
|
348
|
+
- `fullWidth`: boolean (default: false)
|
|
349
|
+
- `size`: 'small' | 'medium' | 'large' (default: 'medium')
|
|
350
|
+
- All standard select HTML attributes
|
|
351
|
+
|
|
352
|
+
#### Checkbox
|
|
353
|
+
|
|
354
|
+
Checkbox input with custom styling.
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { Checkbox } from 'pure-react-ui';
|
|
358
|
+
|
|
359
|
+
<Checkbox
|
|
360
|
+
label="I agree to terms"
|
|
361
|
+
checked={checked}
|
|
362
|
+
onChange={(e) => setChecked(e.target.checked)}
|
|
363
|
+
/>
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Props:**
|
|
367
|
+
- `label`: string (optional)
|
|
368
|
+
- `error`: string (optional)
|
|
369
|
+
- `helpText`: string (optional)
|
|
370
|
+
- `fullWidth`: boolean (default: false)
|
|
371
|
+
- `size`: 'small' | 'medium' | 'large' (default: 'medium')
|
|
372
|
+
- All standard checkbox HTML attributes
|
|
373
|
+
|
|
374
|
+
#### Radio
|
|
375
|
+
|
|
376
|
+
Radio button input.
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
import { Radio } from 'pure-react-ui';
|
|
380
|
+
|
|
381
|
+
<Radio
|
|
382
|
+
label="Option 1"
|
|
383
|
+
name="option"
|
|
384
|
+
value="1"
|
|
385
|
+
checked={selected === '1'}
|
|
386
|
+
onChange={(e) => setSelected(e.target.value)}
|
|
387
|
+
/>
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Props:**
|
|
391
|
+
- `label`: string (optional)
|
|
392
|
+
- `error`: string (optional)
|
|
393
|
+
- `helpText`: string (optional)
|
|
394
|
+
- `fullWidth`: boolean (default: false)
|
|
395
|
+
- `size`: 'small' | 'medium' | 'large' (default: 'medium')
|
|
396
|
+
- All standard radio HTML attributes
|
|
397
|
+
|
|
398
|
+
#### Switch
|
|
399
|
+
|
|
400
|
+
Toggle switch component.
|
|
401
|
+
|
|
402
|
+
```tsx
|
|
403
|
+
import { Switch } from 'pure-react-ui';
|
|
404
|
+
|
|
405
|
+
<Switch
|
|
406
|
+
label="Enable notifications"
|
|
407
|
+
checked={enabled}
|
|
408
|
+
onChange={(e) => setEnabled(e.target.checked)}
|
|
409
|
+
/>
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
**Props:**
|
|
413
|
+
- `label`: string (optional)
|
|
414
|
+
- `error`: string (optional)
|
|
415
|
+
- `helpText`: string (optional)
|
|
416
|
+
- `fullWidth`: boolean (default: false)
|
|
417
|
+
- `size`: 'small' | 'medium' | 'large' (default: 'medium')
|
|
418
|
+
- All standard checkbox HTML attributes (used as switch)
|
|
419
|
+
|
|
420
|
+
#### FormGroup
|
|
421
|
+
|
|
422
|
+
Container for grouping form fields.
|
|
423
|
+
|
|
424
|
+
```tsx
|
|
425
|
+
import { FormGroup } from 'pure-react-ui';
|
|
426
|
+
|
|
427
|
+
<FormGroup label="Personal Information" required>
|
|
428
|
+
<Input label="Name" />
|
|
429
|
+
<Input label="Email" />
|
|
430
|
+
</FormGroup>
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**Props:**
|
|
434
|
+
- `label`: string (optional)
|
|
435
|
+
- `error`: string (optional)
|
|
436
|
+
- `helpText`: string (optional)
|
|
437
|
+
- `required`: boolean (default: false)
|
|
438
|
+
- `className`: string (optional)
|
|
439
|
+
|
|
440
|
+
#### FormRow
|
|
441
|
+
|
|
442
|
+
Horizontal row for form fields.
|
|
443
|
+
|
|
444
|
+
```tsx
|
|
445
|
+
import { FormRow } from 'pure-react-ui';
|
|
446
|
+
|
|
447
|
+
<FormRow gap="medium">
|
|
448
|
+
<Input label="First Name" fullWidth />
|
|
449
|
+
<Input label="Last Name" fullWidth />
|
|
450
|
+
</FormRow>
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
**Props:**
|
|
454
|
+
- `gap`: 'small' | 'medium' | 'large' | number (default: 'medium')
|
|
455
|
+
- `className`: string (optional)
|
|
456
|
+
|
|
248
457
|
## Styling
|
|
249
458
|
|
|
250
459
|
All components include their own CSS files and use CSS classes with the `pure-` prefix. The CSS files are automatically imported with each component. You can also style them by targeting these classes:
|
|
@@ -256,6 +465,13 @@ All components include their own CSS files and use CSS classes with the `pure-`
|
|
|
256
465
|
- **Space**: `pure-space`, `pure-space--horizontal`, `pure-space--vertical`, etc.
|
|
257
466
|
- **Flex**: `pure-flex`, `pure-flex--row`, `pure-flex--column`, etc.
|
|
258
467
|
- **Text**: `pure-text`, `pure-text--lg`, `pure-text--bold`, etc.
|
|
468
|
+
- **Form**: `pure-form`, `pure-form--vertical`, `pure-form--horizontal`, etc.
|
|
469
|
+
- **Input**: `pure-input`, `pure-input--error`, `pure-input--small`, etc.
|
|
470
|
+
- **Textarea**: `pure-textarea`, `pure-textarea--error`, etc.
|
|
471
|
+
- **Select**: `pure-select`, `pure-select--error`, etc.
|
|
472
|
+
- **Checkbox**: `pure-checkbox`, `pure-checkbox--error`, etc.
|
|
473
|
+
- **Radio**: `pure-radio`, `pure-radio--error`, etc.
|
|
474
|
+
- **Switch**: `pure-switch`, `pure-switch--error`, etc.
|
|
259
475
|
|
|
260
476
|
Each component has its own CSS file located in:
|
|
261
477
|
- `lib/components/Button/Button.css`
|
|
@@ -265,6 +481,7 @@ Each component has its own CSS file located in:
|
|
|
265
481
|
- `lib/components/Space/Space.css`
|
|
266
482
|
- `lib/components/Flex/Flex.css`
|
|
267
483
|
- `lib/components/Text/Text.css`
|
|
484
|
+
- `lib/components/Form/Form.css`
|
|
268
485
|
|
|
269
486
|
## Examples
|
|
270
487
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './Form.css';
|
|
3
|
+
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
|
|
4
|
+
label?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
helpText?: string;
|
|
7
|
+
fullWidth?: boolean;
|
|
8
|
+
size?: 'small' | 'medium' | 'large';
|
|
9
|
+
}
|
|
10
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
11
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AAED,eAAO,MAAM,QAAQ,wFA6CnB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import './Form.css';
|
|
3
|
+
export const Checkbox = forwardRef(({ label, error, helpText, fullWidth = false, size = 'medium', className = '', id, ...props }, ref) => {
|
|
4
|
+
const checkboxId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
|
|
5
|
+
const baseClass = 'pure-checkbox';
|
|
6
|
+
const sizeClass = `pure-checkbox--${size}`;
|
|
7
|
+
const errorClass = error ? 'pure-checkbox--error' : '';
|
|
8
|
+
const fullWidthClass = fullWidth ? 'pure-checkbox--full-width' : '';
|
|
9
|
+
const combinedClassName = [
|
|
10
|
+
baseClass,
|
|
11
|
+
sizeClass,
|
|
12
|
+
errorClass,
|
|
13
|
+
fullWidthClass,
|
|
14
|
+
className
|
|
15
|
+
].filter(Boolean).join(' ');
|
|
16
|
+
return (React.createElement("div", { className: `pure-checkbox-wrapper ${fullWidth ? 'pure-checkbox-wrapper--full-width' : ''}` },
|
|
17
|
+
React.createElement("label", { htmlFor: checkboxId, className: "pure-checkbox-label" },
|
|
18
|
+
React.createElement("input", { ref: ref, type: "checkbox", id: checkboxId, className: combinedClassName, ...props }),
|
|
19
|
+
React.createElement("span", { className: "pure-checkbox-custom" }),
|
|
20
|
+
label && React.createElement("span", { className: "pure-checkbox-text" }, label)),
|
|
21
|
+
error && (React.createElement("span", { className: "pure-checkbox-error" }, error)),
|
|
22
|
+
helpText && !error && (React.createElement("span", { className: "pure-checkbox-help" }, helpText))));
|
|
23
|
+
});
|
|
24
|
+
Checkbox.displayName = 'Checkbox';
|
|
25
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Form/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,YAAY,CAAC;AAUp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