@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.
Files changed (45) hide show
  1. package/README.md +33 -1
  2. package/custom-elements.json +2022 -172
  3. package/dist/chunks/FormAssociated-Cx5D8YQA.js +1 -0
  4. package/dist/components/kg-button.js +2 -2
  5. package/dist/components/kg-checkbox.js +22 -3
  6. package/dist/components/kg-colorpicker.js +26 -6
  7. package/dist/components/kg-datepicker.js +3 -2
  8. package/dist/components/kg-file-upload.js +22 -8
  9. package/dist/components/kg-input.js +17 -2
  10. package/dist/components/kg-radio-group.js +18 -3
  11. package/dist/components/kg-radio.js +1 -1
  12. package/dist/components/kg-select.js +33 -13
  13. package/dist/components/kg-slider.js +30 -3
  14. package/dist/components/kg-switch.js +23 -6
  15. package/dist/components/kg-textarea.js +18 -3
  16. package/dist/react/KgBreadcrumbItem.js +1 -0
  17. package/dist/react/KgCheckbox.js +1 -1
  18. package/dist/react/KgColorPicker.js +1 -1
  19. package/dist/react/KgDatePicker.js +1 -1
  20. package/dist/react/KgInput.js +1 -1
  21. package/dist/react/KgListItem.js +1 -0
  22. package/dist/react/KgRadio.js +1 -1
  23. package/dist/react/KgRadioGroup.js +1 -1
  24. package/dist/react/KgSelect.js +1 -1
  25. package/dist/react/KgSlider.js +1 -1
  26. package/dist/react/KgSwitch.js +1 -1
  27. package/dist/react/KgTextarea.js +1 -1
  28. package/dist/react/KgTree.js +1 -1
  29. package/dist/react/KgTreeItem.js +1 -0
  30. package/dist/react/index.js +1 -1
  31. package/package.json +2 -2
  32. package/types/components/kg-button.d.ts +18 -0
  33. package/types/components/kg-checkbox.d.ts +20 -2
  34. package/types/components/kg-colorpicker.d.ts +21 -3
  35. package/types/components/kg-datepicker.d.ts +20 -5
  36. package/types/components/kg-file-upload.d.ts +21 -0
  37. package/types/components/kg-input.d.ts +21 -0
  38. package/types/components/kg-radio-group.d.ts +20 -2
  39. package/types/components/kg-radio.d.ts +21 -0
  40. package/types/components/kg-select.d.ts +21 -3
  41. package/types/components/kg-slider.d.ts +21 -3
  42. package/types/components/kg-switch.d.ts +20 -2
  43. package/types/components/kg-textarea.d.ts +21 -0
  44. package/types/index.d.ts +83 -8
  45. 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: