@valerius_petrini/corekit-ui 0.1.66 → 0.1.69

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 (182) hide show
  1. package/dist/actions/toast.svelte.d.ts +1 -1
  2. package/dist/actions/toast.svelte.js +1 -1
  3. package/dist/components/display/Card/index.stories.svelte +35 -0
  4. package/dist/components/display/Card/index.stories.svelte.d.ts +18 -0
  5. package/dist/components/{Card.svelte → display/Card/index.svelte} +4 -3
  6. package/dist/components/display/Card/index.svelte.d.ts +4 -0
  7. package/dist/{types/Card.d.ts → components/display/Card/types.d.ts} +2 -3
  8. package/dist/components/display/Card/variant.d.ts +2 -0
  9. package/dist/components/display/KBD/index.stories.svelte +13 -0
  10. package/dist/components/display/KBD/index.stories.svelte.d.ts +18 -0
  11. package/dist/components/display/KBD/index.svelte.d.ts +3 -0
  12. package/dist/components/{Skeleton.svelte → display/Skeleton/index.svelte} +2 -2
  13. package/dist/components/display/Skeleton/index.svelte.d.ts +4 -0
  14. package/dist/{types/Skeleton.d.ts → components/display/Skeleton/types.d.ts} +1 -1
  15. package/dist/components/{Table.svelte → display/Table/index.svelte} +1 -1
  16. package/dist/components/display/Table/index.svelte.d.ts +4 -0
  17. package/dist/{types/Table.d.ts → components/display/Table/types.d.ts} +2 -2
  18. package/dist/components/display/index.d.ts +7 -0
  19. package/dist/components/display/index.js +4 -0
  20. package/dist/components/{Loader.svelte → feedback/Loader/index.svelte} +3 -3
  21. package/dist/components/feedback/Loader/index.svelte.d.ts +4 -0
  22. package/dist/components/feedback/Loader/types.d.ts +7 -0
  23. package/dist/components/{Modal.svelte → feedback/Modal/index.svelte} +3 -3
  24. package/dist/components/feedback/Modal/index.svelte.d.ts +4 -0
  25. package/dist/components/feedback/Modal/types.d.ts +6 -0
  26. package/dist/components/{Progress.svelte → feedback/Progress/index.svelte} +3 -3
  27. package/dist/components/feedback/Progress/index.svelte.d.ts +4 -0
  28. package/dist/{types/Progress.d.ts → components/feedback/Progress/types.d.ts} +3 -3
  29. package/dist/components/{Toast.svelte → feedback/Toast/index.svelte} +6 -6
  30. package/dist/components/feedback/Toast/index.svelte.d.ts +5 -0
  31. package/dist/{types/Toast.d.ts → components/feedback/Toast/types.d.ts} +3 -3
  32. package/dist/components/{Toaster.svelte → feedback/Toaster/index.svelte} +3 -3
  33. package/dist/components/feedback/Toaster/index.svelte.d.ts +3 -0
  34. package/dist/components/feedback/index.d.ts +9 -0
  35. package/dist/components/feedback/index.js +5 -0
  36. package/dist/components/inputs/Button/index.stories.svelte +53 -0
  37. package/dist/components/inputs/Button/index.stories.svelte.d.ts +18 -0
  38. package/dist/components/inputs/Button/index.svelte +98 -0
  39. package/dist/components/inputs/Button/index.svelte.d.ts +4 -0
  40. package/dist/components/inputs/Button/size.d.ts +3 -0
  41. package/dist/components/inputs/Button/size.js +28 -0
  42. package/dist/{types/Button.d.ts → components/inputs/Button/types.d.ts} +4 -4
  43. package/dist/components/{Checkbox.svelte → inputs/Checkbox/index.svelte} +2 -2
  44. package/dist/components/inputs/Checkbox/index.svelte.d.ts +4 -0
  45. package/dist/{types/Checkbox.d.ts → components/inputs/Checkbox/types.d.ts} +1 -1
  46. package/dist/components/inputs/ColorInput/index.stories.svelte +23 -0
  47. package/dist/components/inputs/ColorInput/index.stories.svelte.d.ts +18 -0
  48. package/dist/components/inputs/ColorInput/index.svelte +384 -0
  49. package/dist/components/inputs/ColorInput/index.svelte.d.ts +4 -0
  50. package/dist/components/inputs/ColorInput/types.d.ts +16 -0
  51. package/dist/components/inputs/Combobox/index.stories.svelte +34 -0
  52. package/dist/components/inputs/Combobox/index.stories.svelte.d.ts +18 -0
  53. package/dist/components/{Combobox.svelte → inputs/Combobox/index.svelte} +67 -10
  54. package/dist/components/inputs/Combobox/index.svelte.d.ts +4 -0
  55. package/dist/components/inputs/Combobox/types.d.ts +8 -0
  56. package/dist/components/{FileInput.svelte → inputs/FileInput/index.svelte} +4 -4
  57. package/dist/components/inputs/FileInput/index.svelte.d.ts +4 -0
  58. package/dist/components/inputs/FileInput/types.d.ts +14 -0
  59. package/dist/components/inputs/Input/index.stories.svelte +27 -0
  60. package/dist/components/inputs/Input/index.stories.svelte.d.ts +18 -0
  61. package/dist/components/{Input.svelte → inputs/Input/index.svelte} +8 -11
  62. package/dist/components/inputs/Input/index.svelte.d.ts +5 -0
  63. package/dist/components/inputs/Input/types.d.ts +15 -0
  64. package/dist/components/inputs/Input/types.js +3 -0
  65. package/dist/components/{Select.svelte → inputs/Select/index.svelte} +3 -4
  66. package/dist/components/inputs/Select/index.svelte.d.ts +3 -0
  67. package/dist/components/inputs/Select/types.d.ts +7 -0
  68. package/dist/components/inputs/Select/types.js +2 -0
  69. package/dist/components/{helper → inputs/helper}/BaseInput.svelte +14 -8
  70. package/dist/components/{helper → inputs/helper}/BaseInput.svelte.d.ts +2 -2
  71. package/dist/components/{helper → inputs/helper}/NumberInput.svelte +8 -7
  72. package/dist/components/{helper → inputs/helper}/NumberInput.svelte.d.ts +1 -2
  73. package/dist/components/inputs/index.d.ts +12 -0
  74. package/dist/components/inputs/index.js +6 -0
  75. package/dist/components/navigation/Breadcrumb/BreadcrumbItem.svelte +37 -0
  76. package/dist/components/navigation/Breadcrumb/BreadcrumbItem.svelte.d.ts +4 -0
  77. package/dist/components/navigation/Breadcrumb/index.stories.svelte +19 -0
  78. package/dist/components/navigation/Breadcrumb/index.stories.svelte.d.ts +18 -0
  79. package/dist/components/navigation/Breadcrumb/index.svelte +21 -0
  80. package/dist/components/navigation/Breadcrumb/index.svelte.d.ts +4 -0
  81. package/dist/components/navigation/Breadcrumb/types.d.ts +6 -0
  82. package/dist/components/{NavbarDropdown.svelte → navigation/Navbar/NavbarDropdown.svelte} +1 -1
  83. package/dist/components/{NavbarDropdown.svelte.d.ts → navigation/Navbar/NavbarDropdown.svelte.d.ts} +1 -1
  84. package/dist/components/{NavbarElement.svelte → navigation/Navbar/NavbarElement.svelte} +2 -2
  85. package/dist/components/{NavbarElement.svelte.d.ts → navigation/Navbar/NavbarElement.svelte.d.ts} +1 -1
  86. package/dist/components/{NavbarSeparator.svelte → navigation/Navbar/NavbarSeparator.svelte} +1 -1
  87. package/dist/components/{NavbarSeparator.svelte.d.ts → navigation/Navbar/NavbarSeparator.svelte.d.ts} +1 -1
  88. package/dist/components/{Navbar.svelte → navigation/Navbar/index.svelte} +1 -2
  89. package/dist/components/navigation/Navbar/index.svelte.d.ts +4 -0
  90. package/dist/{types/Navbar.d.ts → components/navigation/Navbar/types.d.ts} +2 -10
  91. package/dist/{types/Navbar.js → components/navigation/Navbar/types.js} +0 -1
  92. package/dist/components/{SideNavbar.svelte → navigation/SideNavbar/index.svelte} +3 -3
  93. package/dist/components/navigation/SideNavbar/index.svelte.d.ts +4 -0
  94. package/dist/components/navigation/SideNavbar/types.d.ts +10 -0
  95. package/dist/components/navigation/SideNavbar/types.js +2 -0
  96. package/dist/components/navigation/index.d.ts +10 -0
  97. package/dist/components/navigation/index.js +7 -0
  98. package/dist/components/overlay/Tooltip/index.stories.svelte +20 -0
  99. package/dist/components/overlay/Tooltip/index.stories.svelte.d.ts +18 -0
  100. package/dist/components/overlay/Tooltip/index.svelte +193 -0
  101. package/dist/components/overlay/Tooltip/index.svelte.d.ts +4 -0
  102. package/dist/components/overlay/Tooltip/types.d.ts +9 -0
  103. package/dist/components/overlay/Tooltip/types.js +1 -0
  104. package/dist/components/overlay/index.d.ts +2 -0
  105. package/dist/components/overlay/index.js +1 -0
  106. package/dist/components/typography/Text/index.stories.svelte +16 -0
  107. package/dist/components/typography/Text/index.stories.svelte.d.ts +18 -0
  108. package/dist/components/{Text.svelte → typography/Text/index.svelte} +10 -10
  109. package/dist/components/typography/Text/index.svelte.d.ts +4 -0
  110. package/dist/{types/Text.d.ts → components/typography/Text/types.d.ts} +2 -2
  111. package/dist/components/typography/Text/types.js +2 -0
  112. package/dist/components/{Typewriter.svelte → typography/Typewriter/index.svelte} +2 -2
  113. package/dist/components/typography/Typewriter/index.svelte.d.ts +4 -0
  114. package/dist/{types/Typewriter.d.ts → components/typography/Typewriter/types.d.ts} +1 -1
  115. package/dist/components/typography/Typewriter/types.js +2 -0
  116. package/dist/components/typography/index.d.ts +4 -0
  117. package/dist/components/typography/index.js +2 -0
  118. package/dist/components/{Analytics.svelte → utility/Analytics/index.svelte} +1 -1
  119. package/dist/components/utility/Analytics/index.svelte.d.ts +4 -0
  120. package/dist/components/utility/Analytics/types.js +1 -0
  121. package/dist/components/{SEO.svelte → utility/SEO/index.svelte} +1 -1
  122. package/dist/components/utility/SEO/index.svelte.d.ts +4 -0
  123. package/dist/components/utility/SEO/types.js +1 -0
  124. package/dist/components/utility/index.d.ts +4 -0
  125. package/dist/components/utility/index.js +2 -0
  126. package/dist/index.d.ts +8 -25
  127. package/dist/index.js +8 -24
  128. package/dist/styles/color.d.ts +4 -1
  129. package/dist/styles/color.js +175 -166
  130. package/dist/styles/layout.css +38 -2
  131. package/dist/styles/size.d.ts +3 -1
  132. package/dist/styles/size.js +19 -39
  133. package/dist/types/BaseComponent.d.ts +18 -0
  134. package/dist/utils/color.d.ts +16 -0
  135. package/dist/utils/color.js +70 -0
  136. package/package.json +23 -11
  137. package/dist/components/Analytics.svelte.d.ts +0 -4
  138. package/dist/components/Button.svelte +0 -66
  139. package/dist/components/Button.svelte.d.ts +0 -4
  140. package/dist/components/Card.svelte.d.ts +0 -4
  141. package/dist/components/Checkbox.svelte.d.ts +0 -4
  142. package/dist/components/Combobox.svelte.d.ts +0 -4
  143. package/dist/components/FileInput.svelte.d.ts +0 -4
  144. package/dist/components/Input.svelte.d.ts +0 -5
  145. package/dist/components/KBD.svelte.d.ts +0 -3
  146. package/dist/components/Loader.svelte.d.ts +0 -4
  147. package/dist/components/Modal.svelte.d.ts +0 -4
  148. package/dist/components/Navbar.svelte.d.ts +0 -4
  149. package/dist/components/Progress.svelte.d.ts +0 -4
  150. package/dist/components/SEO.svelte.d.ts +0 -4
  151. package/dist/components/Select.svelte.d.ts +0 -4
  152. package/dist/components/SideNavbar.svelte.d.ts +0 -4
  153. package/dist/components/Skeleton.svelte.d.ts +0 -4
  154. package/dist/components/Table.svelte.d.ts +0 -4
  155. package/dist/components/Text.svelte.d.ts +0 -4
  156. package/dist/components/Toast.svelte.d.ts +0 -5
  157. package/dist/components/Toaster.svelte.d.ts +0 -3
  158. package/dist/components/Tooltip.svelte +0 -123
  159. package/dist/components/Tooltip.svelte.d.ts +0 -4
  160. package/dist/components/Typewriter.svelte.d.ts +0 -4
  161. package/dist/types/Input.d.ts +0 -57
  162. package/dist/types/Input.js +0 -5
  163. package/dist/types/Loader.d.ts +0 -5
  164. package/dist/types/Modal.d.ts +0 -6
  165. package/dist/types/Tooltip.d.ts +0 -7
  166. /package/dist/{types/Analytics.js → components/display/Card/types.js} +0 -0
  167. /package/dist/{types/Card.js → components/display/Card/variant.js} +0 -0
  168. /package/dist/components/{KBD.svelte → display/KBD/index.svelte} +0 -0
  169. /package/dist/{types/Button.js → components/display/Skeleton/types.js} +0 -0
  170. /package/dist/{types/Table.js → components/display/Table/types.js} +0 -0
  171. /package/dist/{types/Loader.js → components/feedback/Loader/types.js} +0 -0
  172. /package/dist/{types/Modal.js → components/feedback/Modal/types.js} +0 -0
  173. /package/dist/{types/Checkbox.js → components/feedback/Progress/types.js} +0 -0
  174. /package/dist/{types/SEO.js → components/feedback/Toast/types.js} +0 -0
  175. /package/dist/{types/Skeleton.js → components/inputs/Button/types.js} +0 -0
  176. /package/dist/{types/Progress.js → components/inputs/Checkbox/types.js} +0 -0
  177. /package/dist/{types/Text.js → components/inputs/ColorInput/types.js} +0 -0
  178. /package/dist/{types/Toast.js → components/inputs/Combobox/types.js} +0 -0
  179. /package/dist/{types/Typewriter.js → components/inputs/FileInput/types.js} +0 -0
  180. /package/dist/{types/Tooltip.js → components/navigation/Breadcrumb/types.js} +0 -0
  181. /package/dist/{types/Analytics.d.ts → components/utility/Analytics/types.d.ts} +0 -0
  182. /package/dist/{types/SEO.d.ts → components/utility/SEO/types.d.ts} +0 -0
@@ -1,10 +1,11 @@
1
+ export const sizeStyles = [
2
+ "xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "full", "none"
3
+ ];
1
4
  export const sizeStyleParts = {
2
5
  xs: {
3
- button: "text-xs h-4 px-1 py-0.5",
4
- buttonIcon: "text-xs h-4 w-4 p-0.5",
5
6
  radius: "rounded-xs",
6
7
  text: "text-xs",
7
- card: "w-xs",
8
+ card: "max-w-xs",
8
9
  form: "h-5 pt-1 pb-0.25",
9
10
  formLabel: "text-[8px]",
10
11
  formLabelSelected: "text-[6px] top-1",
@@ -13,11 +14,9 @@ export const sizeStyleParts = {
13
14
  buttonLoader: "h-2 w-2"
14
15
  },
15
16
  sm: {
16
- button: "text-sm h-6 px-2 py-1",
17
- buttonIcon: "text-sm h-6 w-6 p-1",
18
17
  radius: "rounded-sm",
19
18
  text: "text-sm",
20
- card: "w-sm",
19
+ card: "max-w-sm",
21
20
  form: "h-7 pt-3 pb-0.5",
22
21
  formLabel: "text-[10px]",
23
22
  formLabelSelected: "text-[8px] top-1.5",
@@ -26,11 +25,9 @@ export const sizeStyleParts = {
26
25
  buttonLoader: "h-3 w-3"
27
26
  },
28
27
  md: {
29
- button: "text-base h-8 px-3 py-1.5",
30
- buttonIcon: "text-base h-8 w-8 p-1.5",
31
28
  radius: "rounded-md",
32
29
  text: "text-base",
33
- card: "w-md",
30
+ card: "max-w-md",
34
31
  form: "h-9 pt-4 pb-1",
35
32
  formLabel: "text-xs",
36
33
  formLabelSelected: "text-[10px] top-2",
@@ -39,11 +36,9 @@ export const sizeStyleParts = {
39
36
  buttonLoader: "h-4 w-4"
40
37
  },
41
38
  lg: {
42
- button: "text-lg h-10 px-4 py-2",
43
- buttonIcon: "text-lg h-10 w-10 p-2",
44
39
  radius: "rounded-lg",
45
40
  text: "text-lg",
46
- card: "w-lg",
41
+ card: "max-w-lg",
47
42
  form: "h-[44px] pt-5 pb-2",
48
43
  formLabel: "text-sm",
49
44
  formLabelSelected: "text-xs top-2.5",
@@ -52,11 +47,9 @@ export const sizeStyleParts = {
52
47
  buttonLoader: "h-5 w-5"
53
48
  },
54
49
  xl: {
55
- button: "text-xl h-12 px-5 py-2.5",
56
- buttonIcon: "text-xl h-12 w-12 p-2.5",
57
50
  radius: "rounded-xl",
58
51
  text: "text-xl",
59
- card: "w-xl",
52
+ card: "max-w-xl",
60
53
  form: "h-[52px] pt-6 pb-3",
61
54
  formLabel: "text-base",
62
55
  formLabelSelected: "text-sm top-3",
@@ -65,11 +58,9 @@ export const sizeStyleParts = {
65
58
  buttonLoader: "h-6 w-6"
66
59
  },
67
60
  "2xl": {
68
- button: "text-2xl h-14 px-6 py-3",
69
- buttonIcon: "text-2xl h-14 w-14 p-3",
70
61
  radius: "rounded-2xl",
71
62
  text: "text-2xl",
72
- card: "w-2xl",
63
+ card: "max-w-2xl",
73
64
  form: "h-[60px] pt-7 pb-4",
74
65
  formLabel: "text-lg",
75
66
  formLabelSelected: "text-base top-3.5",
@@ -78,11 +69,9 @@ export const sizeStyleParts = {
78
69
  buttonLoader: "h-7 w-7"
79
70
  },
80
71
  "3xl": {
81
- button: "text-3xl h-16 px-7 py-3.5",
82
- buttonIcon: "text-3xl h-16 w-16 p-3.5",
83
72
  radius: "rounded-3xl",
84
73
  text: "text-3xl",
85
- card: "w-3xl",
74
+ card: "max-w-3xl",
86
75
  form: "h-[68px] pt-8 pb-5",
87
76
  formLabel: "text-xl",
88
77
  formLabelSelected: "text-lg top-4",
@@ -91,11 +80,9 @@ export const sizeStyleParts = {
91
80
  buttonLoader: "h-8 w-8"
92
81
  },
93
82
  "4xl": {
94
- button: "text-4xl h-18 px-8 py-4",
95
- buttonIcon: "text-4xl h-18 w-18 p-4",
96
83
  radius: "rounded-4xl",
97
84
  text: "text-4xl",
98
- card: "w-4xl",
85
+ card: "max-w-4xl",
99
86
  form: "h-[76px] pt-9 pb-6",
100
87
  formLabel: "text-2xl",
101
88
  formLabelSelected: "text-xl top-4.5",
@@ -104,11 +91,9 @@ export const sizeStyleParts = {
104
91
  buttonLoader: "h-9 w-9"
105
92
  },
106
93
  "5xl": {
107
- button: "text-5xl h-20 px-9 py-4.5",
108
- buttonIcon: "text-5xl h-20 w-20 p-4.5",
109
94
  radius: "rounded-[2.5rem]",
110
95
  text: "text-5xl",
111
- card: "w-5xl",
96
+ card: "max-w-5xl",
112
97
  form: "h-[84px] pt-10 pb-5",
113
98
  formLabel: "text-3xl",
114
99
  formLabelSelected: "text-2xl top-5",
@@ -117,11 +102,9 @@ export const sizeStyleParts = {
117
102
  buttonLoader: "h-10 w-10"
118
103
  },
119
104
  "6xl": {
120
- button: "text-6xl h-24 px-10 py-5",
121
- buttonIcon: "text-6xl h-24 w-24 p-5",
122
105
  radius: "rounded-[3rem]",
123
106
  text: "text-6xl",
124
- card: "w-6xl",
107
+ card: "max-w-6xl",
125
108
  form: "h-[92px] pt-12 pb-6",
126
109
  formLabel: "text-4xl",
127
110
  formLabelSelected: "text-3xl top-[22px]",
@@ -130,11 +113,9 @@ export const sizeStyleParts = {
130
113
  buttonLoader: "h-11 w-11"
131
114
  },
132
115
  full: {
133
- button: "w-full text-base h-8 px-3 py-1",
134
- buttonIcon: "w-full aspect-square text-base p-1",
135
116
  radius: "rounded-full",
136
117
  text: "w-full text-base",
137
- card: "w-full",
118
+ card: "max-w-full",
138
119
  form: "h-9 pt-4 pb-1",
139
120
  formLabel: "text-xs",
140
121
  formLabelSelected: "text-[10px] top-2",
@@ -143,8 +124,6 @@ export const sizeStyleParts = {
143
124
  buttonLoader: "h-4 w-4"
144
125
  },
145
126
  none: {
146
- button: "p-0 h-auto text-base",
147
- buttonIcon: "p-0 h-auto w-auto text-base",
148
127
  radius: "rounded-none",
149
128
  text: "",
150
129
  card: "",
@@ -161,13 +140,14 @@ export function getSizeStyleClass(size, type) {
161
140
  return sizeStyleParts[size][type];
162
141
  return "";
163
142
  }
143
+ export function getSizeStyleClassRecord(size, record) {
144
+ if (typeof size === "string")
145
+ return record[size];
146
+ return "";
147
+ }
164
148
  export function getSizeStyle(size, type) {
165
149
  if (typeof size === "number") {
166
150
  switch (type) {
167
- case "button":
168
- return `height: ${size}px; padding: ${size / 4}px ${size / 8}px`;
169
- case "buttonIcon":
170
- return `height: ${size}px; width: ${size}px; padding: ${size / 4}px`;
171
151
  case "card":
172
152
  return `width: ${size}px`;
173
153
  case "radius":
@@ -1,5 +1,23 @@
1
+ import type { SizeStyle } from "$styles/size";
2
+ import type { Component } from "svelte";
1
3
  export interface BaseComponentProps {
2
4
  children?: any;
3
5
  class?: string;
4
6
  [key: string]: any;
5
7
  }
8
+ export type InputVariant = "default" | "floating";
9
+ export interface BaseInputProps extends BaseComponentProps {
10
+ label?: string;
11
+ labelClass?: string;
12
+ divClass?: string;
13
+ outerDivClass?: string;
14
+ value?: any;
15
+ required?: boolean;
16
+ disabled?: boolean;
17
+ variant?: InputVariant;
18
+ size?: SizeStyle;
19
+ radius?: SizeStyle;
20
+ icon?: Component;
21
+ wrapper?: HTMLElement;
22
+ id?: `${string}-${string}-${string}-${string}-${string}`;
23
+ }
@@ -0,0 +1,16 @@
1
+ export declare function hslToHex(h: number, s: number, l: number): string;
2
+ export declare function hexToRgb(hex: string): {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ };
7
+ export declare function hexToHsv(hex: string): {
8
+ h: number;
9
+ s: number;
10
+ v: number;
11
+ };
12
+ export declare function hexToHsl(hex: string): {
13
+ h: number;
14
+ s: number;
15
+ l: number;
16
+ };
@@ -0,0 +1,70 @@
1
+ export function hslToHex(h, s, l) {
2
+ s /= 100;
3
+ l /= 100;
4
+ const k = (n) => (n + h / 30) % 12;
5
+ const a = s * Math.min(l, 1 - l);
6
+ const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
7
+ const r = Math.round(f(0) * 255);
8
+ const g = Math.round(f(8) * 255);
9
+ const b = Math.round(f(4) * 255);
10
+ return '#' + [r, g, b]
11
+ .map(v => v.toString(16).padStart(2, '0'))
12
+ .join('');
13
+ }
14
+ export function hexToRgb(hex) {
15
+ const bigint = parseInt(hex.replace('#', ''), 16);
16
+ const r = (bigint >> 16) & 255;
17
+ const g = (bigint >> 8) & 255;
18
+ const b = bigint & 255;
19
+ return { r, g, b };
20
+ }
21
+ export function hexToHsv(hex) {
22
+ const { r, g, b } = hexToRgb(hex);
23
+ const rNorm = r / 255;
24
+ const gNorm = g / 255;
25
+ const bNorm = b / 255;
26
+ const max = Math.max(rNorm, gNorm, bNorm);
27
+ const min = Math.min(rNorm, gNorm, bNorm);
28
+ let h = 0, s = 0, v = max;
29
+ if (max !== min) {
30
+ s = (max - min) / max;
31
+ switch (max) {
32
+ case rNorm:
33
+ h = (gNorm - bNorm) / (max - min) + (gNorm < bNorm ? 6 : 0);
34
+ break;
35
+ case gNorm:
36
+ h = (bNorm - rNorm) / (max - min) + 2;
37
+ break;
38
+ case bNorm:
39
+ h = (rNorm - gNorm) / (max - min) + 4;
40
+ break;
41
+ }
42
+ h *= 60;
43
+ }
44
+ return { h, s: s * 100, v: v * 100 };
45
+ }
46
+ export function hexToHsl(hex) {
47
+ const { r, g, b } = hexToRgb(hex);
48
+ const rNorm = r / 255;
49
+ const gNorm = g / 255;
50
+ const bNorm = b / 255;
51
+ const max = Math.max(rNorm, gNorm, bNorm);
52
+ const min = Math.min(rNorm, gNorm, bNorm);
53
+ let h = 0, s = 0, l = (max + min) / 2;
54
+ if (max !== min) {
55
+ s = l > 0.5 ? (max - min) / (2 - max - min) : (max - min) / (max + min);
56
+ switch (max) {
57
+ case rNorm:
58
+ h = (gNorm - bNorm) / (max - min) + (gNorm < bNorm ? 6 : 0);
59
+ break;
60
+ case gNorm:
61
+ h = (bNorm - rNorm) / (max - min) + 2;
62
+ break;
63
+ case bNorm:
64
+ h = (rNorm - gNorm) / (max - min) + 4;
65
+ break;
66
+ }
67
+ h *= 60;
68
+ }
69
+ return { h, s: s * 100, l: l * 100 };
70
+ }
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@valerius_petrini/corekit-ui",
3
- "version": "0.1.66",
3
+ "version": "0.1.69",
4
4
  "description": "Component Library used across all my projects",
5
5
  "author": "Valerius Petrini Jr.",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
- "dev": "vite dev",
9
- "build": "vite build && npm run prepack",
10
- "preview": "vite preview",
11
- "prepare": "svelte-kit sync || echo ''",
12
- "prepack": "svelte-kit sync && svelte-package && publint",
13
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
14
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
8
+ "dev": "storybook dev -p 6006",
9
+ "build": "svelte-package -i src/lib && publint",
10
+ "prepack": "svelte-package -i src/lib && publint",
11
+ "check": "svelte-check --tsconfig ./tsconfig.json",
12
+ "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
13
+ "storybook": "storybook dev -p 6006",
14
+ "build-storybook": "storybook build"
15
15
  },
16
16
  "files": [
17
17
  "dist",
@@ -35,26 +35,38 @@
35
35
  "svelte": "^5.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@sveltejs/adapter-auto": "^7.0.0",
39
- "@sveltejs/kit": "^2.50.2",
38
+ "@chromatic-com/storybook": "^5.1.2",
39
+ "@storybook/addon-a11y": "^10.3.6",
40
+ "@storybook/addon-docs": "^10.3.6",
41
+ "@storybook/addon-svelte-csf": "^5.1.2",
42
+ "@storybook/addon-vitest": "^10.3.6",
43
+ "@storybook/svelte-vite": "^10.3.6",
40
44
  "@sveltejs/package": "^2.5.7",
41
45
  "@sveltejs/vite-plugin-svelte": "^6.2.4",
42
46
  "@tailwindcss/forms": "^0.5.11",
43
47
  "@tailwindcss/typography": "^0.5.19",
44
48
  "@tailwindcss/vite": "^4.1.18",
45
49
  "@types/bytes": "^3.1.5",
50
+ "@types/node": "^25.6.0",
51
+ "@vitest/browser-playwright": "^4.1.5",
52
+ "@vitest/coverage-v8": "^4.1.5",
53
+ "playwright": "^1.59.1",
46
54
  "publint": "^0.3.17",
55
+ "storybook": "^10.3.6",
56
+ "storybook-dark-mode": "^5.0.0",
47
57
  "svelte": "^5.51.0",
48
58
  "svelte-check": "^4.4.2",
49
59
  "tailwindcss": "^4.1.18",
50
60
  "typescript": "^5.9.3",
51
- "vite": "^7.3.1"
61
+ "vite": "^7.3.1",
62
+ "vitest": "^4.1.5"
52
63
  },
53
64
  "keywords": [
54
65
  "components",
55
66
  "svelte"
56
67
  ],
57
68
  "dependencies": {
69
+ "@floating-ui/dom": "^1.7.6",
58
70
  "@lucide/svelte": "^1.3.0",
59
71
  "@valerius_petrini/corekit-scripts": "^1.0.0",
60
72
  "bytes": "^3.1.2",
@@ -1,4 +0,0 @@
1
- import type { AnalyticsProps } from '../types/Analytics.ts';
2
- declare const Analytics: import("svelte").Component<AnalyticsProps, {}, "">;
3
- type Analytics = ReturnType<typeof Analytics>;
4
- export default Analytics;
@@ -1,66 +0,0 @@
1
- <script lang="ts">
2
- import { generateColorStyle } from "../styles/color.js";
3
- import { getSizeStyle, getSizeStyleClass, sizeStyleParts, type SizeStyleTheme } from "../styles/size.js";
4
- import type { ButtonProps } from "../types/Button.js";
5
- import { twMerge } from "tailwind-merge";
6
- import { getLinkProps } from "../utils/link.js";
7
- import Loader from "./Loader.svelte";
8
-
9
- let {
10
- children = undefined,
11
- class: className = "",
12
- pill = false,
13
- icon = false,
14
- square = false,
15
- href = undefined,
16
- color = "none",
17
- variant = "full",
18
- disabled = false,
19
- external = false,
20
- size = "md",
21
- radius = "md",
22
- loading = false,
23
- ...restProps
24
- }: ButtonProps = $props();
25
-
26
- const defaultClass = "inline-flex items-center justify-center gap-2 transition-colors duration-300 ease-in-out text-white whitespace-nowrap";
27
- const disabledClass = $derived(disabled || loading ? "opacity-50 pointer-events-none" : "cursor-pointer");
28
- const iconClass = $derived(icon ? "p-0 flex-none" : "h-fit");
29
- const pillClass = $derived((pill || icon) && "rounded-full");
30
- const squareClass = $derived(square && "aspect-square rounded-none");
31
-
32
- const mergedClass = $derived(twMerge(
33
- defaultClass,
34
- generateColorStyle(color, variant),
35
- disabledClass,
36
- getSizeStyleClass(size, icon ? "buttonIcon" : "button"),
37
- getSizeStyleClass(radius, "radius"),
38
- iconClass,
39
- pillClass,
40
- squareClass,
41
- className
42
- ));
43
-
44
- const mergedStyle = $derived([
45
- getSizeStyle(size, icon ? "buttonIcon" : "button"),
46
- getSizeStyle(radius, "radius"),
47
- restProps.style
48
- ].filter(Boolean).join("; "));
49
-
50
- const anchorProps = $derived(getLinkProps(href, external, disabled || loading));
51
- </script>
52
-
53
- <svelte:element
54
- this={href ? "a" : "button"}
55
- class={mergedClass}
56
- disabled={disabled || loading}
57
- aria-disabled={disabled || loading}
58
- type={href ? undefined : (restProps.type || "button")}
59
- style={mergedStyle}
60
- {...anchorProps}
61
- {...restProps}>
62
- {#if loading}
63
- <Loader color="white" class="border-2 border-loader-btn-color {getSizeStyleClass(size, "buttonLoader")}"/>
64
- {/if}
65
- {@render children?.()}
66
- </svelte:element>
@@ -1,4 +0,0 @@
1
- import type { ButtonProps } from "../types/Button.ts";
2
- declare const Button: import("svelte").Component<ButtonProps, {}, "">;
3
- type Button = ReturnType<typeof Button>;
4
- export default Button;
@@ -1,4 +0,0 @@
1
- import { type CardProps } from "../types/Card.ts";
2
- declare const Card: import("svelte").Component<CardProps, {}, "">;
3
- type Card = ReturnType<typeof Card>;
4
- export default Card;
@@ -1,4 +0,0 @@
1
- import type { CheckboxProps } from "../types/Checkbox.ts";
2
- declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "checked">;
3
- type Checkbox = ReturnType<typeof Checkbox>;
4
- export default Checkbox;
@@ -1,4 +0,0 @@
1
- import type { ComboboxProps } from "../types/Input.ts";
2
- declare const Combobox: import("svelte").Component<ComboboxProps, {}, "value">;
3
- type Combobox = ReturnType<typeof Combobox>;
4
- export default Combobox;
@@ -1,4 +0,0 @@
1
- import type { FileInputProps } from "../types/Input.js";
2
- declare const FileInput: import("svelte").Component<FileInputProps, {}, "files">;
3
- type FileInput = ReturnType<typeof FileInput>;
4
- export default FileInput;
@@ -1,5 +0,0 @@
1
- import type { InputProps } from "../types/Input.ts";
2
- import { type Component } from "svelte";
3
- declare const Input: Component<InputProps, {}, "value" | "valid">;
4
- type Input = ReturnType<typeof Input>;
5
- export default Input;
@@ -1,3 +0,0 @@
1
- declare const KBD: import("svelte").Component<any, {}, "">;
2
- type KBD = ReturnType<typeof KBD>;
3
- export default KBD;
@@ -1,4 +0,0 @@
1
- import type { LoaderProps } from "../types/Loader.ts";
2
- declare const Loader: import("svelte").Component<LoaderProps, {}, "">;
3
- type Loader = ReturnType<typeof Loader>;
4
- export default Loader;
@@ -1,4 +0,0 @@
1
- import type { ModalProps } from "../types/Modal.js";
2
- declare const Modal: import("svelte").Component<ModalProps, {}, "open">;
3
- type Modal = ReturnType<typeof Modal>;
4
- export default Modal;
@@ -1,4 +0,0 @@
1
- import type { NavbarProps } from "../types/Navbar.ts";
2
- declare const Navbar: import("svelte").Component<NavbarProps, {}, "">;
3
- type Navbar = ReturnType<typeof Navbar>;
4
- export default Navbar;
@@ -1,4 +0,0 @@
1
- import type { ProgressProps } from "../types/Progress.ts";
2
- declare const Progress: import("svelte").Component<ProgressProps, {}, "">;
3
- type Progress = ReturnType<typeof Progress>;
4
- export default Progress;
@@ -1,4 +0,0 @@
1
- import type { SEOProps } from '../types/SEO.ts';
2
- declare const SEO: import("svelte").Component<SEOProps, {}, "">;
3
- type SEO = ReturnType<typeof SEO>;
4
- export default SEO;
@@ -1,4 +0,0 @@
1
- import type { SelectProps } from "../types/Input.js";
2
- declare const Select: import("svelte").Component<SelectProps, {}, "value">;
3
- type Select = ReturnType<typeof Select>;
4
- export default Select;
@@ -1,4 +0,0 @@
1
- import type { SideNavbarProps } from "../types/Navbar.ts";
2
- declare const SideNavbar: import("svelte").Component<SideNavbarProps, {}, "">;
3
- type SideNavbar = ReturnType<typeof SideNavbar>;
4
- export default SideNavbar;
@@ -1,4 +0,0 @@
1
- import type { SkeletonProps } from "../types/Skeleton.js";
2
- declare const Skeleton: import("svelte").Component<SkeletonProps, {}, "">;
3
- type Skeleton = ReturnType<typeof Skeleton>;
4
- export default Skeleton;
@@ -1,4 +0,0 @@
1
- import type { TableProps } from "../types/Table.ts";
2
- declare const Table: import("svelte").Component<TableProps, {}, "">;
3
- type Table = ReturnType<typeof Table>;
4
- export default Table;
@@ -1,4 +0,0 @@
1
- import type { TextProps } from "../types/Text.ts";
2
- declare const Text: import("svelte").Component<TextProps, {}, "">;
3
- type Text = ReturnType<typeof Text>;
4
- export default Text;
@@ -1,5 +0,0 @@
1
- import type { ToastProps } from "../types/Toast.ts";
2
- import type { Component } from "svelte";
3
- declare const Toast: Component<ToastProps, {}, "">;
4
- type Toast = ReturnType<typeof Toast>;
5
- export default Toast;
@@ -1,3 +0,0 @@
1
- declare const Toaster: import("svelte").Component<Record<string, never>, {}, "">;
2
- type Toaster = ReturnType<typeof Toaster>;
3
- export default Toaster;
@@ -1,123 +0,0 @@
1
- <script lang="ts">
2
- import type { TooltipComponent } from "../types/Tooltip.js";
3
- import { type Snippet } from "svelte";
4
- import { fly } from "svelte/transition";
5
-
6
- let {
7
- text,
8
- position = "top",
9
- delay = 0,
10
- children
11
- }: TooltipComponent = $props();
12
-
13
- let visible = $state(false);
14
- let resolvedPosition: string | null = $state(null);
15
- let offsetX = $state(0);
16
- let trigger: HTMLDivElement;
17
- let tooltip: HTMLDivElement | null = $state(null);
18
- let timeout: ReturnType<typeof setTimeout>;
19
- let arrowX = $derived(-offsetX);
20
-
21
- function calculatePosition() {
22
- resolvedPosition = position;
23
- if (!trigger) return;
24
-
25
- const rect = trigger.getBoundingClientRect();
26
- const vw = window.innerWidth;
27
- const vh = window.innerHeight;
28
-
29
- if (position === "top" && rect.top < 40) resolvedPosition = "bottom";
30
- else if (position === "bottom" && rect.bottom > vh - 40) resolvedPosition = "top";
31
- else if (position === "left" && rect.left < 120) resolvedPosition = "right";
32
- else if (position === "right" && rect.right > vw - 120) resolvedPosition = "left";
33
- else resolvedPosition = position;
34
- }
35
-
36
- function calculateOverflow() {
37
- if (!tooltip || !trigger) return;
38
-
39
- const triggerRect = trigger.getBoundingClientRect();
40
- const tooltipRect = tooltip.getBoundingClientRect();
41
- const vw = window.innerWidth;
42
-
43
- const triggerCenter = triggerRect.left + triggerRect.width / 2;
44
-
45
- const tooltipLeft = triggerCenter - tooltipRect.width / 2;
46
- const tooltipRight = triggerCenter + tooltipRect.width / 2;
47
-
48
- const padding = 8;
49
-
50
- if (tooltipRight > vw - padding)
51
- offsetX = -(tooltipRight - (vw - padding));
52
- else if (tooltipLeft < padding)
53
- offsetX = padding - tooltipLeft;
54
- else
55
- offsetX = 0;
56
- }
57
-
58
- function show() {
59
- calculatePosition();
60
- timeout = setTimeout(() => {
61
- visible = true;
62
- requestAnimationFrame(calculateOverflow);
63
- }, delay);
64
- }
65
-
66
- function hide() {
67
- clearTimeout(timeout);
68
- visible = false;
69
- }
70
-
71
- const positionClasses: Record<string, string> = {
72
- top: "bottom-full left-1/2 -translate-x-1/2 mb-2",
73
- bottom: "top-full left-1/2 -translate-x-1/2 mt-2",
74
- left: "right-full top-1/2 -translate-y-1/2 mr-2",
75
- right: "left-full top-1/2 -translate-y-1/2 ml-2"
76
- };
77
-
78
- const arrowClasses: Record<string, string> = {
79
- top: "top-full left-1/2 -translate-x-1/2 border-t-form-background",
80
- bottom: "bottom-full left-1/2 -translate-x-1/2 border-b-form-background",
81
- left: "left-full top-1/2 -translate-y-1/2 border-l-form-background",
82
- right: "right-full top-1/2 -translate-y-1/2 border-r-form-background"
83
- };
84
-
85
- const flyParams = $derived.by(() => {
86
- const pos = resolvedPosition || position;
87
-
88
- const duration = 100;
89
- const distance = 8;
90
- if (pos == "top")
91
- return { y: distance, duration };
92
- else if (pos == "bottom")
93
- return { y: -distance, duration };
94
- const x = pos == "right" ? -distance : distance;
95
- return { x, duration };
96
- });
97
- </script>
98
-
99
- <div
100
- bind:this={trigger}
101
- class="relative inline-flex w-fit h-fit"
102
- onmouseenter={show}
103
- onmouseleave={hide}
104
- role="tooltip">
105
- {@render children()}
106
-
107
- {#if visible}
108
- <div
109
- bind:this={tooltip}
110
- style="transform: translateX(calc(-50% + {offsetX}px));"
111
- class="absolute z-999999 {positionClasses[resolvedPosition || position]} translate-x-0! pointer-events-none">
112
-
113
- <div class="absolute {arrowClasses[resolvedPosition || position]} border-4 border-transparent w-0 h-0"
114
- style="transform: translateX(calc(-50% + {arrowX}px));"></div>
115
-
116
- <div
117
- transition:fly={flyParams}
118
- class="px-2 py-1 text-xs text-main-text bg-form-background rounded whitespace-nowrap">
119
- {text}
120
- </div>
121
- </div>
122
- {/if}
123
- </div>