@lazhus/kg-ui 0.7.3 → 0.7.5
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 +33 -1
- package/custom-elements.json +2022 -172
- package/dist/chunks/FormAssociated-Cx5D8YQA.js +1 -0
- package/dist/components/kg-button.js +2 -2
- package/dist/components/kg-checkbox.js +22 -3
- package/dist/components/kg-colorpicker.js +26 -6
- package/dist/components/kg-datepicker.js +3 -2
- package/dist/components/kg-file-upload.js +22 -8
- package/dist/components/kg-input.js +17 -2
- package/dist/components/kg-radio-group.js +18 -3
- package/dist/components/kg-radio.js +1 -1
- package/dist/components/kg-select.js +33 -13
- package/dist/components/kg-slider.js +30 -3
- package/dist/components/kg-switch.js +23 -6
- package/dist/components/kg-textarea.js +18 -3
- package/dist/react/KgBreadcrumbItem.js +1 -0
- package/dist/react/KgCheckbox.js +1 -1
- package/dist/react/KgColorPicker.js +1 -1
- package/dist/react/KgDatePicker.js +1 -1
- package/dist/react/KgInput.js +1 -1
- package/dist/react/KgListItem.js +1 -0
- package/dist/react/KgRadio.js +1 -1
- package/dist/react/KgRadioGroup.js +1 -1
- package/dist/react/KgSelect.js +1 -1
- package/dist/react/KgSlider.js +1 -1
- package/dist/react/KgSwitch.js +1 -1
- package/dist/react/KgTextarea.js +1 -1
- package/dist/react/KgTree.js +1 -1
- package/dist/react/KgTreeItem.js +1 -0
- package/dist/react/index.js +1 -1
- package/package.json +2 -2
- package/types/components/kg-button.d.ts +18 -0
- package/types/components/kg-checkbox.d.ts +20 -2
- package/types/components/kg-colorpicker.d.ts +21 -3
- package/types/components/kg-datepicker.d.ts +20 -5
- package/types/components/kg-file-upload.d.ts +21 -0
- package/types/components/kg-input.d.ts +21 -0
- package/types/components/kg-radio-group.d.ts +20 -2
- package/types/components/kg-radio.d.ts +21 -0
- package/types/components/kg-select.d.ts +21 -3
- package/types/components/kg-slider.d.ts +21 -3
- package/types/components/kg-switch.d.ts +20 -2
- package/types/components/kg-textarea.d.ts +21 -0
- package/types/index.d.ts +83 -8
- package/dist/chunks/FormAssociated-DT543PBW.js +0 -1
package/README.md
CHANGED
|
@@ -51,10 +51,42 @@ import '@lazhus/kg-ui/style.css';
|
|
|
51
51
|
|
|
52
52
|
```html
|
|
53
53
|
<kg-button color="primary">Click Me</kg-button>
|
|
54
|
-
<kg-input label="Username" placeholder="Enter your name"></kg-input>
|
|
54
|
+
<kg-input label="Username" placeholder="Enter your name" error-text="This field is required"></kg-input>
|
|
55
55
|
<kg-avatar name="John Doe" color="secondary"></kg-avatar>
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
## 📝 Form Integration & Validation
|
|
59
|
+
|
|
60
|
+
KG UI components are built using `ElementInternals`, making them natively compatible with standard `<form>` elements.
|
|
61
|
+
|
|
62
|
+
### Form Submission
|
|
63
|
+
Buttons with `type="submit"` or `type="reset"` will trigger the corresponding form action:
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<form id="login-form">
|
|
67
|
+
<kg-input name="email" type="email" label="Email" required></kg-input>
|
|
68
|
+
<kg-input name="password" type="password" label="Password" required></kg-input>
|
|
69
|
+
|
|
70
|
+
<kg-button type="submit" color="primary">Sign In</kg-button>
|
|
71
|
+
<kg-button type="reset" basic>Clear</kg-button>
|
|
72
|
+
</form>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Validation & Error Handling
|
|
76
|
+
All input-based components support the `error-text` property. Setting this property will display an error message below the component and apply error styling.
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<kg-input
|
|
80
|
+
label="Username"
|
|
81
|
+
error-text="Username already exists"
|
|
82
|
+
></kg-input>
|
|
83
|
+
|
|
84
|
+
<kg-select
|
|
85
|
+
label="Country"
|
|
86
|
+
error-text="Please select your country"
|
|
87
|
+
></kg-select>
|
|
88
|
+
```
|
|
89
|
+
|
|
58
90
|
## 🛠 Programmatic Access
|
|
59
91
|
|
|
60
92
|
Some components can be called via JavaScript for ease of use:
|