@kkkarsss/ui 1.0.0

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 (246) hide show
  1. package/dist/.storybook/main.d.ts +3 -0
  2. package/dist/.storybook/main.js +34 -0
  3. package/dist/.storybook/preview.d.ts +4 -0
  4. package/dist/.storybook/preview.js +19 -0
  5. package/dist/index.css +238 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.js +4 -0
  8. package/dist/providers/alert/alert-context.d.ts +16 -0
  9. package/dist/providers/alert/alert-context.js +2 -0
  10. package/dist/providers/alert/alert-provider.d.ts +6 -0
  11. package/dist/providers/alert/alert-provider.js +50 -0
  12. package/dist/providers/alert/use-alerts.d.ts +1 -0
  13. package/dist/providers/alert/use-alerts.js +9 -0
  14. package/dist/providers/index.d.ts +9 -0
  15. package/dist/providers/index.js +9 -0
  16. package/dist/providers/theme/index.d.ts +3 -0
  17. package/dist/providers/theme/index.js +3 -0
  18. package/dist/providers/theme/theme-context.d.ts +7 -0
  19. package/dist/providers/theme/theme-context.js +6 -0
  20. package/dist/providers/theme/theme-provider.d.ts +9 -0
  21. package/dist/providers/theme/theme-provider.js +27 -0
  22. package/dist/providers/theme/use-theme.d.ts +4 -0
  23. package/dist/providers/theme/use-theme.js +8 -0
  24. package/dist/providers/widget/index.d.ts +3 -0
  25. package/dist/providers/widget/index.js +3 -0
  26. package/dist/providers/widget/use-widgets.d.ts +4 -0
  27. package/dist/providers/widget/use-widgets.js +8 -0
  28. package/dist/providers/widget/widget-context.d.ts +12 -0
  29. package/dist/providers/widget/widget-context.js +6 -0
  30. package/dist/providers/widget/widget-provider.d.ts +6 -0
  31. package/dist/providers/widget/widget-provider.js +13 -0
  32. package/dist/src/index.d.ts +4 -0
  33. package/dist/src/index.js +4 -0
  34. package/dist/src/providers/alert/alert-context.d.ts +16 -0
  35. package/dist/src/providers/alert/alert-context.js +2 -0
  36. package/dist/src/providers/alert/alert-provider.d.ts +6 -0
  37. package/dist/src/providers/alert/alert-provider.js +50 -0
  38. package/dist/src/providers/alert/use-alerts.d.ts +1 -0
  39. package/dist/src/providers/alert/use-alerts.js +9 -0
  40. package/dist/src/providers/index.d.ts +9 -0
  41. package/dist/src/providers/index.js +9 -0
  42. package/dist/src/providers/theme/theme-context.d.ts +7 -0
  43. package/dist/src/providers/theme/theme-context.js +6 -0
  44. package/dist/src/providers/theme/theme-provider.d.ts +9 -0
  45. package/dist/src/providers/theme/theme-provider.js +27 -0
  46. package/dist/src/providers/theme/use-theme.d.ts +4 -0
  47. package/dist/src/providers/theme/use-theme.js +8 -0
  48. package/dist/src/providers/widget/use-widgets.d.ts +4 -0
  49. package/dist/src/providers/widget/use-widgets.js +8 -0
  50. package/dist/src/providers/widget/widget-context.d.ts +12 -0
  51. package/dist/src/providers/widget/widget-context.js +6 -0
  52. package/dist/src/providers/widget/widget-provider.d.ts +6 -0
  53. package/dist/src/providers/widget/widget-provider.js +15 -0
  54. package/dist/src/ui/controls/button/button.d.ts +10 -0
  55. package/dist/src/ui/controls/button/button.js +11 -0
  56. package/dist/src/ui/controls/button/button.stories.d.ts +9 -0
  57. package/dist/src/ui/controls/button/button.stories.js +38 -0
  58. package/dist/src/ui/controls/chip/chip.d.ts +12 -0
  59. package/dist/src/ui/controls/chip/chip.js +11 -0
  60. package/dist/src/ui/controls/chip/chip.stories.d.ts +9 -0
  61. package/dist/src/ui/controls/chip/chip.stories.js +42 -0
  62. package/dist/src/ui/controls/color-picker/color-picker.d.ts +8 -0
  63. package/dist/src/ui/controls/color-picker/color-picker.js +21 -0
  64. package/dist/src/ui/controls/color-picker/color-picker.stories.d.ts +7 -0
  65. package/dist/src/ui/controls/color-picker/color-picker.stories.js +21 -0
  66. package/dist/src/ui/controls/copy/copy.d.ts +6 -0
  67. package/dist/src/ui/controls/copy/copy.js +20 -0
  68. package/dist/src/ui/controls/copy/copy.stories.d.ts +7 -0
  69. package/dist/src/ui/controls/copy/copy.stories.js +20 -0
  70. package/dist/src/ui/controls/index.d.ts +7 -0
  71. package/dist/src/ui/controls/index.js +7 -0
  72. package/dist/src/ui/controls/input/input.d.ts +14 -0
  73. package/dist/src/ui/controls/input/input.js +12 -0
  74. package/dist/src/ui/controls/input/input.stories.d.ts +9 -0
  75. package/dist/src/ui/controls/input/input.stories.js +46 -0
  76. package/dist/src/ui/controls/select/select.d.ts +14 -0
  77. package/dist/src/ui/controls/select/select.js +80 -0
  78. package/dist/src/ui/controls/select/select.stories.d.ts +8 -0
  79. package/dist/src/ui/controls/select/select.stories.js +40 -0
  80. package/dist/src/ui/controls/textarea/textarea.d.ts +11 -0
  81. package/dist/src/ui/controls/textarea/textarea.js +20 -0
  82. package/dist/src/ui/controls/textarea/textarea.stories.d.ts +8 -0
  83. package/dist/src/ui/controls/textarea/textarea.stories.js +35 -0
  84. package/dist/src/ui/index.d.ts +3 -0
  85. package/dist/src/ui/index.js +3 -0
  86. package/dist/src/ui/information/block/block.d.ts +10 -0
  87. package/dist/src/ui/information/block/block.js +10 -0
  88. package/dist/src/ui/information/block/block.stories.d.ts +8 -0
  89. package/dist/src/ui/information/block/block.stories.js +38 -0
  90. package/dist/src/ui/information/cell/cell.d.ts +26 -0
  91. package/dist/src/ui/information/cell/cell.js +31 -0
  92. package/dist/src/ui/information/cell/cell.stories.d.ts +11 -0
  93. package/dist/src/ui/information/cell/cell.stories.js +62 -0
  94. package/dist/src/ui/information/cell/cells-block.d.ts +9 -0
  95. package/dist/src/ui/information/cell/cells-block.js +5 -0
  96. package/dist/src/ui/information/cell/cells-block.stories.d.ts +6 -0
  97. package/dist/src/ui/information/cell/cells-block.stories.js +20 -0
  98. package/dist/src/ui/information/index.d.ts +6 -0
  99. package/dist/src/ui/information/index.js +6 -0
  100. package/dist/src/ui/information/spinner/spinner.d.ts +2 -0
  101. package/dist/src/ui/information/spinner/spinner.js +5 -0
  102. package/dist/src/ui/information/spinner/spinner.stories.d.ts +6 -0
  103. package/dist/src/ui/information/spinner/spinner.stories.js +8 -0
  104. package/dist/src/ui/information/tag/tag.d.ts +6 -0
  105. package/dist/src/ui/information/tag/tag.js +7 -0
  106. package/dist/src/ui/information/tag/tag.stories.d.ts +8 -0
  107. package/dist/src/ui/information/tag/tag.stories.js +25 -0
  108. package/dist/src/ui/information/text/typo.d.ts +12 -0
  109. package/dist/src/ui/information/text/typo.js +41 -0
  110. package/dist/src/ui/information/text/typo.stories.d.ts +10 -0
  111. package/dist/src/ui/information/text/typo.stories.js +60 -0
  112. package/dist/src/ui/layout/dropdown/dropdown.d.ts +11 -0
  113. package/dist/src/ui/layout/dropdown/dropdown.js +59 -0
  114. package/dist/src/ui/layout/dropdown/dropdown.stories.d.ts +6 -0
  115. package/dist/src/ui/layout/dropdown/dropdown.stories.js +24 -0
  116. package/dist/src/ui/layout/flex/flex.d.ts +12 -0
  117. package/dist/src/ui/layout/flex/flex.js +36 -0
  118. package/dist/src/ui/layout/flex/flex.stories.d.ts +8 -0
  119. package/dist/src/ui/layout/flex/flex.stories.js +53 -0
  120. package/dist/src/ui/layout/icon-action/icon-action.d.ts +9 -0
  121. package/dist/src/ui/layout/icon-action/icon-action.js +11 -0
  122. package/dist/src/ui/layout/icon-action/icon-action.stories.d.ts +7 -0
  123. package/dist/src/ui/layout/icon-action/icon-action.stories.js +23 -0
  124. package/dist/src/ui/layout/index.d.ts +5 -0
  125. package/dist/src/ui/layout/index.js +5 -0
  126. package/dist/src/ui/layout/main-page-layout/main-page-layout.d.ts +7 -0
  127. package/dist/src/ui/layout/main-page-layout/main-page-layout.js +8 -0
  128. package/dist/src/ui/layout/main-page-layout/main-page-layout.stories.d.ts +6 -0
  129. package/dist/src/ui/layout/main-page-layout/main-page-layout.stories.js +19 -0
  130. package/dist/src/ui/layout/offset/offset.d.ts +6 -0
  131. package/dist/src/ui/layout/offset/offset.js +10 -0
  132. package/dist/src/ui/layout/offset/offset.stories.d.ts +8 -0
  133. package/dist/src/ui/layout/offset/offset.stories.js +33 -0
  134. package/dist/src/utils/classes.d.ts +1 -0
  135. package/dist/src/utils/classes.js +1 -0
  136. package/dist/src/utils/index.d.ts +1 -0
  137. package/dist/src/utils/index.js +1 -0
  138. package/dist/stories/Button.d.ts +15 -0
  139. package/dist/stories/Button.js +7 -0
  140. package/dist/stories/Button.stories.d.ts +23 -0
  141. package/dist/stories/Button.stories.js +44 -0
  142. package/dist/stories/Header.d.ts +12 -0
  143. package/dist/stories/Header.js +4 -0
  144. package/dist/stories/Header.stories.d.ts +18 -0
  145. package/dist/stories/Header.stories.js +26 -0
  146. package/dist/stories/Page.d.ts +3 -0
  147. package/dist/stories/Page.js +8 -0
  148. package/dist/stories/Page.stories.d.ts +12 -0
  149. package/dist/stories/Page.stories.js +24 -0
  150. package/dist/ui/controls/button/button.d.ts +10 -0
  151. package/dist/ui/controls/button/button.js +11 -0
  152. package/dist/ui/controls/button/button.stories.d.ts +9 -0
  153. package/dist/ui/controls/button/button.stories.js +38 -0
  154. package/dist/ui/controls/chip/chip.d.ts +12 -0
  155. package/dist/ui/controls/chip/chip.js +11 -0
  156. package/dist/ui/controls/chip/chip.stories.d.ts +9 -0
  157. package/dist/ui/controls/chip/chip.stories.js +42 -0
  158. package/dist/ui/controls/color-picker/color-picker.d.ts +8 -0
  159. package/dist/ui/controls/color-picker/color-picker.js +21 -0
  160. package/dist/ui/controls/color-picker/color-picker.stories.d.ts +7 -0
  161. package/dist/ui/controls/color-picker/color-picker.stories.js +21 -0
  162. package/dist/ui/controls/copy/copy.d.ts +6 -0
  163. package/dist/ui/controls/copy/copy.js +20 -0
  164. package/dist/ui/controls/copy/copy.stories.d.ts +7 -0
  165. package/dist/ui/controls/copy/copy.stories.js +20 -0
  166. package/dist/ui/controls/date-input/date-input.d.ts +10 -0
  167. package/dist/ui/controls/date-input/date-input.js +25 -0
  168. package/dist/ui/controls/date-picker/date-picker.d.ts +7 -0
  169. package/dist/ui/controls/date-picker/date-picker.js +32 -0
  170. package/dist/ui/controls/index.d.ts +9 -0
  171. package/dist/ui/controls/index.js +9 -0
  172. package/dist/ui/controls/input/input.d.ts +15 -0
  173. package/dist/ui/controls/input/input.js +12 -0
  174. package/dist/ui/controls/input/input.stories.d.ts +9 -0
  175. package/dist/ui/controls/input/input.stories.js +46 -0
  176. package/dist/ui/controls/select/select.d.ts +14 -0
  177. package/dist/ui/controls/select/select.js +80 -0
  178. package/dist/ui/controls/select/select.stories.d.ts +8 -0
  179. package/dist/ui/controls/select/select.stories.js +40 -0
  180. package/dist/ui/controls/textarea/textarea.d.ts +11 -0
  181. package/dist/ui/controls/textarea/textarea.js +20 -0
  182. package/dist/ui/controls/textarea/textarea.stories.d.ts +8 -0
  183. package/dist/ui/controls/textarea/textarea.stories.js +35 -0
  184. package/dist/ui/controls/theme-toggle/theme-toggle.d.ts +2 -0
  185. package/dist/ui/controls/theme-toggle/theme-toggle.js +10 -0
  186. package/dist/ui/index.d.ts +3 -0
  187. package/dist/ui/index.js +3 -0
  188. package/dist/ui/information/block/block.d.ts +13 -0
  189. package/dist/ui/information/block/block.js +10 -0
  190. package/dist/ui/information/block/block.stories.d.ts +9 -0
  191. package/dist/ui/information/block/block.stories.js +47 -0
  192. package/dist/ui/information/calendar-like/calendar-like.d.ts +24 -0
  193. package/dist/ui/information/calendar-like/calendar-like.js +71 -0
  194. package/dist/ui/information/cell/cell.d.ts +26 -0
  195. package/dist/ui/information/cell/cell.js +31 -0
  196. package/dist/ui/information/cell/cell.stories.d.ts +11 -0
  197. package/dist/ui/information/cell/cell.stories.js +62 -0
  198. package/dist/ui/information/cell/cells-block.d.ts +9 -0
  199. package/dist/ui/information/cell/cells-block.js +5 -0
  200. package/dist/ui/information/cell/cells-block.stories.d.ts +6 -0
  201. package/dist/ui/information/cell/cells-block.stories.js +20 -0
  202. package/dist/ui/information/index.d.ts +8 -0
  203. package/dist/ui/information/index.js +8 -0
  204. package/dist/ui/information/not-found/not-found.d.ts +2 -0
  205. package/dist/ui/information/not-found/not-found.js +6 -0
  206. package/dist/ui/information/spinner/spinner.d.ts +2 -0
  207. package/dist/ui/information/spinner/spinner.js +5 -0
  208. package/dist/ui/information/spinner/spinner.stories.d.ts +6 -0
  209. package/dist/ui/information/spinner/spinner.stories.js +8 -0
  210. package/dist/ui/information/tag/tag.d.ts +6 -0
  211. package/dist/ui/information/tag/tag.js +7 -0
  212. package/dist/ui/information/tag/tag.stories.d.ts +8 -0
  213. package/dist/ui/information/tag/tag.stories.js +25 -0
  214. package/dist/ui/information/text/typo.d.ts +13 -0
  215. package/dist/ui/information/text/typo.js +41 -0
  216. package/dist/ui/information/text/typo.stories.d.ts +10 -0
  217. package/dist/ui/information/text/typo.stories.js +60 -0
  218. package/dist/ui/information/typo.d.ts +12 -0
  219. package/dist/ui/information/typo.js +41 -0
  220. package/dist/ui/layout/dropdown/dropdown.d.ts +11 -0
  221. package/dist/ui/layout/dropdown/dropdown.js +44 -0
  222. package/dist/ui/layout/dropdown/dropdown.stories.d.ts +6 -0
  223. package/dist/ui/layout/dropdown/dropdown.stories.js +24 -0
  224. package/dist/ui/layout/flex/flex.d.ts +13 -0
  225. package/dist/ui/layout/flex/flex.js +36 -0
  226. package/dist/ui/layout/flex/flex.stories.d.ts +8 -0
  227. package/dist/ui/layout/flex/flex.stories.js +53 -0
  228. package/dist/ui/layout/icon-action/icon-action.d.ts +9 -0
  229. package/dist/ui/layout/icon-action/icon-action.js +11 -0
  230. package/dist/ui/layout/icon-action/icon-action.stories.d.ts +7 -0
  231. package/dist/ui/layout/icon-action/icon-action.stories.js +23 -0
  232. package/dist/ui/layout/index.d.ts +5 -0
  233. package/dist/ui/layout/index.js +5 -0
  234. package/dist/ui/layout/main-page-layout/main-page-layout.d.ts +7 -0
  235. package/dist/ui/layout/main-page-layout/main-page-layout.js +8 -0
  236. package/dist/ui/layout/main-page-layout/main-page-layout.stories.d.ts +6 -0
  237. package/dist/ui/layout/main-page-layout/main-page-layout.stories.js +19 -0
  238. package/dist/ui/layout/offset/offset.d.ts +7 -0
  239. package/dist/ui/layout/offset/offset.js +10 -0
  240. package/dist/ui/layout/offset/offset.stories.d.ts +8 -0
  241. package/dist/ui/layout/offset/offset.stories.js +33 -0
  242. package/dist/utils/classes.d.ts +1 -0
  243. package/dist/utils/classes.js +1 -0
  244. package/dist/utils/index.d.ts +1 -0
  245. package/dist/utils/index.js +1 -0
  246. package/package.json +67 -0
@@ -0,0 +1,41 @@
1
+ import { createElement } from 'react';
2
+ import { jc } from '../../../utils';
3
+ const SIZE_TO_TAG_CONFIG = {
4
+ inherit: 'span',
5
+ xs: 'p',
6
+ s: 'p',
7
+ m: 'p',
8
+ l: 'h2',
9
+ xl: 'h1',
10
+ };
11
+ const sizeMap = {
12
+ inherit: 'text-inherit',
13
+ xs: 'text-xs',
14
+ s: 'text-s',
15
+ m: 'text-m',
16
+ l: 'text-l',
17
+ xl: 'text-xl',
18
+ };
19
+ const weightMap = {
20
+ '300': 'font-light',
21
+ '400': 'font-normal',
22
+ '500': 'font-medium',
23
+ };
24
+ const colorMap = {
25
+ default: 'text-foreground',
26
+ secondary: 'text-secondary-foreground',
27
+ accent: 'text-accent',
28
+ error: 'text-error',
29
+ };
30
+ export const Typo = ({ children, size = 'm', color = 'default', weight = '400', textDecoration = 'none', className, }) => {
31
+ const tag = SIZE_TO_TAG_CONFIG[size];
32
+ const colorClass = colorMap[color] || '';
33
+ const inlineColor = !colorMap[color] ? color : undefined;
34
+ return createElement(tag, {
35
+ className: jc(sizeMap[size], colorClass, weightMap[weight], className),
36
+ style: {
37
+ color: inlineColor,
38
+ textDecoration: textDecoration,
39
+ },
40
+ }, children);
41
+ };
@@ -0,0 +1,10 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Typo } from './typo';
3
+ declare const meta: Meta<typeof Typo>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const LargeHeading: Story;
8
+ export declare const AccentText: Story;
9
+ export declare const ErrorText: Story;
10
+ export declare const CustomColor: Story;
@@ -0,0 +1,60 @@
1
+ import { Typo } from './typo';
2
+ const meta = {
3
+ title: 'Information/Typo',
4
+ component: Typo,
5
+ tags: ['autodocs'],
6
+ argTypes: {
7
+ size: {
8
+ control: 'select',
9
+ options: ['inherit', 'xs', 's', 'm', 'l', 'xl'],
10
+ },
11
+ weight: {
12
+ control: 'select',
13
+ options: ['300', '400', '500'],
14
+ },
15
+ color: {
16
+ control: 'text',
17
+ },
18
+ },
19
+ };
20
+ export default meta;
21
+ export const Default = {
22
+ args: {
23
+ children: 'This is a default typography example.',
24
+ size: 'm',
25
+ weight: '400',
26
+ color: 'default',
27
+ },
28
+ };
29
+ export const LargeHeading = {
30
+ args: {
31
+ children: 'Large Heading (XL)',
32
+ size: 'xl',
33
+ weight: '500',
34
+ color: 'default',
35
+ },
36
+ };
37
+ export const AccentText = {
38
+ args: {
39
+ children: 'Accentuated text',
40
+ size: 'm',
41
+ weight: '500',
42
+ color: 'accent',
43
+ },
44
+ };
45
+ export const ErrorText = {
46
+ args: {
47
+ children: 'This is an error message',
48
+ size: 's',
49
+ weight: '400',
50
+ color: 'error',
51
+ },
52
+ };
53
+ export const CustomColor = {
54
+ args: {
55
+ children: 'Text with custom hex color',
56
+ size: 'm',
57
+ weight: '400',
58
+ color: '#8b5cf6',
59
+ },
60
+ };
@@ -0,0 +1,12 @@
1
+ import { type CSSProperties, type FC, type PropsWithChildren } from 'react';
2
+ type TypoSize = 'inherit' | 'xs' | 's' | 'm' | 'l' | 'xl';
3
+ export type TUIColor = 'accent' | 'secondary' | 'default' | 'error' | string;
4
+ type TypoWeight = '300' | '400' | '500';
5
+ export type TTypoProps = PropsWithChildren<{
6
+ size?: TypoSize;
7
+ color?: TUIColor;
8
+ weight?: TypoWeight;
9
+ textDecoration?: CSSProperties['textDecoration'];
10
+ }>;
11
+ export declare const Typo: FC<TTypoProps>;
12
+ export {};
@@ -0,0 +1,41 @@
1
+ import { jc } from '@kars/utils';
2
+ import { createElement } from 'react';
3
+ const SIZE_TO_TAG_CONFIG = {
4
+ inherit: 'span',
5
+ xs: 'p',
6
+ s: 'p',
7
+ m: 'p',
8
+ l: 'h2',
9
+ xl: 'h1',
10
+ };
11
+ const sizeMap = {
12
+ inherit: 'text-inherit',
13
+ xs: 'text-xs',
14
+ s: 'text-s',
15
+ m: 'text-m',
16
+ l: 'text-l',
17
+ xl: 'text-xl',
18
+ };
19
+ const weightMap = {
20
+ '300': 'font-light',
21
+ '400': 'font-normal',
22
+ '500': 'font-medium',
23
+ };
24
+ const colorMap = {
25
+ default: 'text-foreground',
26
+ secondary: 'text-secondary-foreground',
27
+ accent: 'text-accent',
28
+ error: 'text-error',
29
+ };
30
+ export const Typo = ({ children, size = 'm', color = 'default', weight = '400', textDecoration = 'none', }) => {
31
+ const tag = SIZE_TO_TAG_CONFIG[size];
32
+ const colorClass = colorMap[color] || '';
33
+ const inlineColor = !colorMap[color] ? color : undefined;
34
+ return createElement(tag, {
35
+ className: jc(sizeMap[size], colorClass, weightMap[weight]),
36
+ style: {
37
+ color: inlineColor,
38
+ textDecoration: textDecoration,
39
+ },
40
+ }, children);
41
+ };
@@ -0,0 +1,11 @@
1
+ import { ReactNode, RefObject } from 'react';
2
+ type DropdownProps = {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ anchorRef: RefObject<HTMLElement | null>;
6
+ children: ReactNode;
7
+ className?: string;
8
+ matchWidth?: boolean;
9
+ };
10
+ export declare const Dropdown: ({ isOpen, onClose, anchorRef, children, className, matchWidth }: DropdownProps) => import("react").ReactPortal | null;
11
+ export {};
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { jc } from '../../../utils';
5
+ export const Dropdown = ({ isOpen, onClose, anchorRef, children, className, matchWidth = true }) => {
6
+ const [coords, setCoords] = useState({ top: 0, left: 0, width: 0 });
7
+ const dropdownRef = useRef(null);
8
+ const updatePosition = useCallback(() => {
9
+ if (!anchorRef.current)
10
+ return;
11
+ const rect = anchorRef.current.getBoundingClientRect();
12
+ setCoords({
13
+ top: rect.bottom + window.scrollY,
14
+ left: rect.left + window.scrollX,
15
+ width: rect.width,
16
+ });
17
+ }, [anchorRef]);
18
+ useLayoutEffect(() => {
19
+ if (isOpen)
20
+ updatePosition();
21
+ }, [isOpen, updatePosition]);
22
+ useEffect(() => {
23
+ if (!isOpen)
24
+ return;
25
+ const handleResize = () => updatePosition();
26
+ const handleKeyDown = (e) => e.key === 'Escape' && onClose();
27
+ window.addEventListener('resize', handleResize);
28
+ window.addEventListener('scroll', handleResize, true);
29
+ document.addEventListener('keydown', handleKeyDown);
30
+ return () => {
31
+ window.removeEventListener('resize', handleResize);
32
+ window.removeEventListener('scroll', handleResize, true);
33
+ document.removeEventListener('keydown', handleKeyDown);
34
+ };
35
+ }, [isOpen, onClose, updatePosition]);
36
+ if (!isOpen)
37
+ return null;
38
+ return createPortal(_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 bg-black/20 z-[999]", onClick: onClose }), _jsx("div", { ref: dropdownRef, style: {
39
+ position: 'absolute',
40
+ top: coords.top + 4,
41
+ left: coords.left,
42
+ width: matchWidth ? coords.width : 'auto',
43
+ }, className: jc('z-[1000] py-m overflow-hidden rounded border-x-2 border-secondary bg-background-accent shadow-lg', className), children: children })] }), document.body);
44
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Dropdown } from './dropdown';
3
+ declare const meta: Meta<typeof Dropdown>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useRef, useState } from 'react';
3
+ import { Dropdown } from './dropdown';
4
+ import { Typo } from '../../information';
5
+ const meta = {
6
+ title: 'Layout/Dropdown',
7
+ component: Dropdown,
8
+ tags: ['autodocs'],
9
+ decorators: [
10
+ (Story) => (_jsx("div", { style: { height: '200px', padding: '20px' }, children: _jsx(Story, {}) })),
11
+ ],
12
+ };
13
+ export default meta;
14
+ const DropdownWithTrigger = (args) => {
15
+ const [isOpen, setIsOpen] = useState(false);
16
+ const anchorRef = useRef(null);
17
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ref: anchorRef, onClick: () => setIsOpen(!isOpen), className: "px-4 py-2 bg-primary text-white rounded", children: "Toggle Dropdown" }), _jsx(Dropdown, { ...args, isOpen: isOpen, onClose: () => setIsOpen(false), anchorRef: anchorRef, children: _jsxs("div", { className: "p-2", children: [_jsx(Typo, { children: "Dropdown Content" }), _jsx(Typo, { size: "s", color: "secondary", children: "More details here..." })] }) })] }));
18
+ };
19
+ export const Default = {
20
+ render: (args) => _jsx(DropdownWithTrigger, { ...args }),
21
+ args: {
22
+ matchWidth: true,
23
+ },
24
+ };
@@ -0,0 +1,13 @@
1
+ import type { FC, PropsWithChildren, RefObject } from 'react';
2
+ type TProps = {
3
+ direction?: 'row' | 'column';
4
+ type?: 'hug' | 'fill';
5
+ justify?: 'start' | 'center' | 'end' | 'space-between';
6
+ align?: 'start' | 'center' | 'end';
7
+ gap?: '0' | '4px' | '8px' | '16px';
8
+ ref?: RefObject<HTMLDivElement | null>;
9
+ offset?: '0' | '4px' | '8px' | '16px';
10
+ className?: string;
11
+ };
12
+ export declare const Flex: FC<PropsWithChildren<TProps>>;
13
+ export {};
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jc } from '../../../utils';
3
+ const directionMap = {
4
+ row: 'flex-row',
5
+ column: 'flex-col',
6
+ };
7
+ const typeMap = {
8
+ hug: 'w-auto h-auto',
9
+ fill: 'w-full h-auto',
10
+ };
11
+ const justifyMap = {
12
+ start: 'justify-start',
13
+ center: 'justify-center',
14
+ end: 'justify-end',
15
+ 'space-between': 'justify-between',
16
+ };
17
+ const alignMap = {
18
+ start: 'items-start',
19
+ center: 'items-center',
20
+ end: 'items-end',
21
+ };
22
+ const gapMap = {
23
+ '0': 'gap-0',
24
+ '4px': 'gap-s',
25
+ '8px': 'gap-m',
26
+ '16px': 'gap-l',
27
+ };
28
+ const offsetMap = {
29
+ '0': 'p-0',
30
+ '4px': 'p-s',
31
+ '8px': 'p-m',
32
+ '16px': 'p-l',
33
+ };
34
+ export const Flex = ({ children, justify, align, direction = 'row', type = 'hug', gap = '4px', ref, offset = '0', className, }) => {
35
+ return (_jsx("div", { className: jc('flex', 'scrollbar-none', 'overflow-hidden', 'overflow-x-auto', directionMap[direction], typeMap[type], gapMap[gap], offsetMap[offset], align && alignMap[align], justify && justifyMap[justify], className), ref: ref, children: children }));
36
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Flex } from './flex';
3
+ declare const meta: Meta<typeof Flex>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Row: Story;
7
+ export declare const Column: Story;
8
+ export declare const SpaceBetween: Story;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Flex } from './flex';
3
+ const meta = {
4
+ title: 'Layout/Flex',
5
+ component: Flex,
6
+ tags: ['autodocs'],
7
+ argTypes: {
8
+ direction: {
9
+ control: 'select',
10
+ options: ['row', 'column'],
11
+ },
12
+ justify: {
13
+ control: 'select',
14
+ options: ['start', 'center', 'end', 'space-between'],
15
+ },
16
+ align: {
17
+ control: 'select',
18
+ options: ['start', 'center', 'end'],
19
+ },
20
+ gap: {
21
+ control: 'select',
22
+ options: ['0', '4px', '8px', '16px'],
23
+ },
24
+ offset: {
25
+ control: 'select',
26
+ options: ['0', '4px', '8px', '16px'],
27
+ },
28
+ },
29
+ };
30
+ export default meta;
31
+ const Box = ({ children }) => _jsx("div", { className: "bg-accent p-4 text-white rounded", children: children });
32
+ export const Row = {
33
+ args: {
34
+ direction: 'row',
35
+ gap: '8px',
36
+ children: [_jsx(Box, { children: "Box 1" }, "1"), _jsx(Box, { children: "Box 2" }, "2"), _jsx(Box, { children: "Box 3" }, "3")],
37
+ },
38
+ };
39
+ export const Column = {
40
+ args: {
41
+ direction: 'column',
42
+ gap: '16px',
43
+ children: [_jsx(Box, { children: "Row 1" }, "1"), _jsx(Box, { children: "Row 2" }, "2"), _jsx(Box, { children: "Row 3" }, "3")],
44
+ },
45
+ };
46
+ export const SpaceBetween = {
47
+ args: {
48
+ direction: 'row',
49
+ justify: 'space-between',
50
+ type: 'fill',
51
+ children: [_jsx(Box, { children: "Left" }, "1"), _jsx(Box, { children: "Right" }, "2")],
52
+ },
53
+ };
@@ -0,0 +1,9 @@
1
+ import type { LucideProps } from 'lucide-react';
2
+ import type { FC, ReactElement } from 'react';
3
+ type TIconActionProps = {
4
+ icon: ReactElement<LucideProps>;
5
+ onClick?: VoidFunction;
6
+ bgc?: CSSStyleDeclaration['backgroundColor'];
7
+ };
8
+ export declare const IconAction: FC<TIconActionProps>;
9
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jc } from '../../../utils';
3
+ export const IconAction = ({ onClick, icon, bgc }) => {
4
+ const onClickHandler = (e) => {
5
+ e.stopPropagation();
6
+ if (onClick) {
7
+ onClick();
8
+ }
9
+ };
10
+ return (_jsx("div", { className: jc('relative z-10 flex h-8 w-8 items-center justify-center rounded transition-all duration-200 ease-in-out', onClick ? 'hover:bg-[var(--shadow)] cursor-pointer' : undefined), onClick: onClickHandler, children: _jsx("span", { className: "absolute left-1/2 top-1/2 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full", style: { backgroundColor: bgc }, children: icon }) }));
11
+ };
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { IconAction } from './icon-action';
3
+ declare const meta: Meta<typeof IconAction>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const WithBackground: Story;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Settings } from 'lucide-react';
3
+ import { IconAction } from './icon-action';
4
+ const meta = {
5
+ title: 'Layout/IconAction',
6
+ component: IconAction,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ onClick: { action: 'clicked' },
10
+ },
11
+ };
12
+ export default meta;
13
+ export const Default = {
14
+ args: {
15
+ icon: _jsx(Settings, { size: 16 }),
16
+ },
17
+ };
18
+ export const WithBackground = {
19
+ args: {
20
+ icon: _jsx(Settings, { size: 16, color: "white" }),
21
+ bgc: '#ef4444',
22
+ },
23
+ };
@@ -0,0 +1,5 @@
1
+ export * from './dropdown/dropdown';
2
+ export * from './flex/flex';
3
+ export * from './icon-action/icon-action';
4
+ export * from './main-page-layout/main-page-layout';
5
+ export * from './offset/offset';
@@ -0,0 +1,5 @@
1
+ export * from './dropdown/dropdown';
2
+ export * from './flex/flex';
3
+ export * from './icon-action/icon-action';
4
+ export * from './main-page-layout/main-page-layout';
5
+ export * from './offset/offset';
@@ -0,0 +1,7 @@
1
+ import { type FC, type PropsWithChildren, type ReactNode } from 'react';
2
+ type TProps = {
3
+ leftPanel?: ReactNode;
4
+ rightPanel?: ReactNode;
5
+ };
6
+ export declare const MainPageLayout: FC<PropsWithChildren<TProps>>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from 'react';
3
+ import { useWidget } from '../../../providers';
4
+ import { Flex } from '../flex/flex';
5
+ export const MainPageLayout = ({ children, leftPanel, rightPanel }) => {
6
+ const { widget } = useWidget();
7
+ return (_jsxs("main", { className: "grid h-[100dvh] w-full grid-cols-[300px_1fr_300px] py-xl px-l gap-l", children: [_jsx("aside", { className: "h-full w-full", children: leftPanel }), _jsxs(Flex, { justify: 'center', gap: '16px', type: 'fill', children: [children, widget && _jsx(Fragment, { children: widget.ui }, widget.id)] }), _jsx("aside", { className: "h-full w-full", children: rightPanel })] }));
8
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { MainPageLayout } from './main-page-layout';
3
+ declare const meta: Meta<typeof MainPageLayout>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { MainPageLayout } from './main-page-layout';
3
+ import { Typo } from '../../information';
4
+ const meta = {
5
+ title: 'Layout/MainPageLayout',
6
+ component: MainPageLayout,
7
+ tags: ['autodocs'],
8
+ parameters: {
9
+ layout: 'fullscreen',
10
+ },
11
+ };
12
+ export default meta;
13
+ export const Default = {
14
+ args: {
15
+ leftPanel: (_jsxs("div", { className: "h-full bg-secondary/20 p-4 border-r border-border", children: [_jsx(Typo, { weight: "500", children: "Left Panel" }), _jsx(Typo, { size: "s", children: "Navigation or filters" })] })),
16
+ rightPanel: (_jsxs("div", { className: "h-full bg-secondary/20 p-4 border-l border-border", children: [_jsx(Typo, { weight: "500", children: "Right Panel" }), _jsx(Typo, { size: "s", children: "Additional info" })] })),
17
+ children: (_jsxs("div", { className: "w-full h-full bg-background-accent p-4 rounded-xl shadow-sm", children: [_jsx(Typo, { size: "xl", weight: "500", children: "Main Content Area" }), _jsxs("div", { className: "mt-4 space-y-2", children: [_jsx(Typo, { children: "This is where the main application content goes." }), _jsx(Typo, { color: "secondary", children: "It is centered and has a gap between panels." })] })] })),
18
+ },
19
+ };
@@ -0,0 +1,7 @@
1
+ import { type FC, type PropsWithChildren } from 'react';
2
+ type TProps = {
3
+ type?: 'horizontal' | 'vertical' | 'both';
4
+ className?: string;
5
+ };
6
+ export declare const Offset: FC<PropsWithChildren<TProps>>;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jc } from '../../../utils';
3
+ const typeMap = {
4
+ horizontal: 'mx-l',
5
+ vertical: 'my-l',
6
+ both: 'm-l',
7
+ };
8
+ export const Offset = ({ children, type = 'horizontal', className }) => {
9
+ return _jsx("div", { className: jc(typeMap[type], className), children: children });
10
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Offset } from './offset';
3
+ declare const meta: Meta<typeof Offset>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Horizontal: Story;
7
+ export declare const Vertical: Story;
8
+ export declare const Both: Story;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Offset } from './offset';
3
+ import { Typo } from '../../information';
4
+ const meta = {
5
+ title: 'Layout/Offset',
6
+ component: Offset,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ type: {
10
+ control: 'select',
11
+ options: ['horizontal', 'vertical', 'both'],
12
+ },
13
+ },
14
+ };
15
+ export default meta;
16
+ export const Horizontal = {
17
+ args: {
18
+ type: 'horizontal',
19
+ children: (_jsx("div", { className: "bg-accent-secondary p-2", children: _jsx(Typo, { children: "Horizontal Offset (mx-l)" }) })),
20
+ },
21
+ };
22
+ export const Vertical = {
23
+ args: {
24
+ type: 'vertical',
25
+ children: (_jsx("div", { className: "bg-accent-secondary p-2", children: _jsx(Typo, { children: "Vertical Offset (my-l)" }) })),
26
+ },
27
+ };
28
+ export const Both = {
29
+ args: {
30
+ type: 'both',
31
+ children: (_jsx("div", { className: "bg-accent-secondary p-2", children: _jsx(Typo, { children: "Both Offset (m-l)" }) })),
32
+ },
33
+ };
@@ -0,0 +1 @@
1
+ export declare const jc: (...classes: (string | undefined | boolean)[]) => string;
@@ -0,0 +1 @@
1
+ export const jc = (...classes) => classes.filter(Boolean).join(' ').trim();
@@ -0,0 +1 @@
1
+ export { jc } from './classes';
@@ -0,0 +1 @@
1
+ export { jc } from './classes';
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@kkkarsss/ui",
3
+ "version": "1.0.0",
4
+ "description": "UI Kit for kkkarsss projects",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc && copy src\\index.css dist\\index.css",
13
+ "prepare": "npm run build",
14
+ "lint": "eslint .",
15
+ "format": "prettier --write .",
16
+ "storybook": "storybook dev -p 6006",
17
+ "build-storybook": "storybook build"
18
+ },
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "MIT",
22
+ "peerDependencies": {
23
+ "react": ">=18",
24
+ "react-dom": ">=18"
25
+ },
26
+ "devDependencies": {
27
+ "@chromatic-com/storybook": "^5.0.0",
28
+ "@eslint/js": "^9.39.2",
29
+ "@storybook/addon-a11y": "^10.2.1",
30
+ "@storybook/addon-docs": "^10.2.1",
31
+ "@storybook/addon-onboarding": "^10.2.1",
32
+ "@storybook/addon-vitest": "^10.2.1",
33
+ "@storybook/react": "^10.2.1",
34
+ "@storybook/react-vite": "^10.2.1",
35
+ "@types/node": "^25.0.10",
36
+ "@types/react": "^19.2.9",
37
+ "@types/react-dom": "^19.2.3",
38
+ "@vitest/browser-playwright": "^4.0.18",
39
+ "@vitest/coverage-v8": "^4.0.18",
40
+ "autoprefixer": "^10.4.23",
41
+ "eslint": "^9.39.1",
42
+ "eslint-config-prettier": "^10.1.8",
43
+ "eslint-import-resolver-typescript": "^4.4.4",
44
+ "eslint-plugin-import": "^2.32.0",
45
+ "eslint-plugin-react-hooks": "^7.0.1",
46
+ "eslint-plugin-react-refresh": "^0.4.26",
47
+ "eslint-plugin-storybook": "^10.2.1",
48
+ "globals": "^16.5.0",
49
+ "lucide-react": "^0.563.0",
50
+ "playwright": "^1.58.0",
51
+ "postcss": "^8.5.6",
52
+ "prettier": "^3.8.1",
53
+ "react": "^19.2.3",
54
+ "react-dom": "^19.2.3",
55
+ "storybook": "^10.2.1",
56
+ "tailwindcss": "^3.4.19",
57
+ "typescript": "5.9.3",
58
+ "typescript-eslint": "^8.53.1",
59
+ "vite": "^7.3.1",
60
+ "vitest": "^4.0.18"
61
+ },
62
+ "dependencies": {
63
+ "date-fns": "^4.1.0",
64
+ "react-datepicker": "^9.1.0",
65
+ "react-day-picker": "^9.13.0"
66
+ }
67
+ }