@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,50 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState, useCallback, useRef } from 'react';
3
+ import { AlertContext } from './alert-context';
4
+ export function AlertProvider({ children }) {
5
+ const [currentAlert, setCurrentAlert] = useState(null);
6
+ const [history, setHistory] = useState([]);
7
+ const timerRef = useRef(null);
8
+ const dismissCurrentAlert = useCallback((isRead = false) => {
9
+ if (timerRef.current) {
10
+ clearTimeout(timerRef.current);
11
+ timerRef.current = null;
12
+ }
13
+ if (isRead && currentAlert) {
14
+ setHistory((prev) => prev.map((a) => (a.id === currentAlert.id ? { ...a, isRead: true } : a)));
15
+ }
16
+ setCurrentAlert(null);
17
+ }, [currentAlert]);
18
+ const addAlert = useCallback((alertData) => {
19
+ const newAlert = {
20
+ ...alertData,
21
+ id: Math.random().toString(36).substring(2, 9),
22
+ timestamp: new Date(),
23
+ isRead: false,
24
+ };
25
+ setHistory((prev) => [newAlert, ...prev]);
26
+ setCurrentAlert(newAlert);
27
+ if (timerRef.current) {
28
+ clearTimeout(timerRef.current);
29
+ }
30
+ timerRef.current = setTimeout(() => {
31
+ setCurrentAlert(null);
32
+ timerRef.current = null;
33
+ }, 5000);
34
+ }, []);
35
+ const clearHistory = useCallback(() => {
36
+ setHistory([]);
37
+ }, []);
38
+ const markAllAsRead = useCallback(() => {
39
+ setHistory((prev) => prev.map((a) => ({ ...a, isRead: true })));
40
+ }, []);
41
+ const value = {
42
+ currentAlert,
43
+ history,
44
+ addAlert,
45
+ clearHistory,
46
+ dismissCurrentAlert,
47
+ markAllAsRead,
48
+ };
49
+ return _jsx(AlertContext.Provider, { value: value, children: children });
50
+ }
@@ -0,0 +1 @@
1
+ export declare const useAlerts: () => import("./alert-context").TAlertContext;
@@ -0,0 +1,9 @@
1
+ import { useContext } from 'react';
2
+ import { AlertContext } from './alert-context';
3
+ export const useAlerts = () => {
4
+ const context = useContext(AlertContext);
5
+ if (context === undefined) {
6
+ throw new Error('useAlerts must be used within an AlertProvider');
7
+ }
8
+ return context;
9
+ };
@@ -0,0 +1,9 @@
1
+ export { WidgetsProviderContext } from './widget/widget-context';
2
+ export { WidgetProvider } from './widget/widget-provider';
3
+ export { useWidget } from './widget/use-widgets';
4
+ export { type TTheme, ThemeProviderContext } from './theme/theme-context';
5
+ export { useTheme } from './theme/use-theme';
6
+ export { ThemeProvider } from './theme/theme-provider';
7
+ export { AlertContext, type TAlert } from './alert/alert-context';
8
+ export { AlertProvider } from './alert/alert-provider';
9
+ export { useAlerts } from './alert/use-alerts';
@@ -0,0 +1,9 @@
1
+ export { WidgetsProviderContext } from './widget/widget-context';
2
+ export { WidgetProvider } from './widget/widget-provider';
3
+ export { useWidget } from './widget/use-widgets';
4
+ export { ThemeProviderContext } from './theme/theme-context';
5
+ export { useTheme } from './theme/use-theme';
6
+ export { ThemeProvider } from './theme/theme-provider';
7
+ export { AlertContext } from './alert/alert-context';
8
+ export { AlertProvider } from './alert/alert-provider';
9
+ export { useAlerts } from './alert/use-alerts';
@@ -0,0 +1,7 @@
1
+ export type TTheme = 'dark' | 'light' | 'system';
2
+ type ThemeProviderState = {
3
+ theme: TTheme;
4
+ setTheme: (theme: TTheme) => void;
5
+ };
6
+ export declare const ThemeProviderContext: import("react").Context<ThemeProviderState>;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { createContext } from 'react';
2
+ const initialState = {
3
+ theme: 'system',
4
+ setTheme: () => null,
5
+ };
6
+ export const ThemeProviderContext = createContext(initialState);
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type TTheme } from './theme-context';
3
+ type TThemeProviderProps = {
4
+ children: ReactNode;
5
+ defaultTheme?: TTheme;
6
+ storageKey?: string;
7
+ };
8
+ export declare function ThemeProvider({ children, defaultTheme, storageKey, ...props }: TThemeProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { ThemeProviderContext } from './theme-context';
4
+ export function ThemeProvider({ children, defaultTheme = 'system', storageKey = 'theme', ...props }) {
5
+ const [theme, setTheme] = useState(() => localStorage.getItem(storageKey) || defaultTheme);
6
+ useEffect(() => {
7
+ const root = window.document.documentElement;
8
+ root.classList.remove('light', 'dark');
9
+ if (theme === 'system') {
10
+ const systemTheme = window.matchMedia('(prefers-color-scheme: dark)')
11
+ .matches
12
+ ? 'dark'
13
+ : 'light';
14
+ root.classList.add(systemTheme);
15
+ return;
16
+ }
17
+ root.classList.add(theme);
18
+ }, [theme]);
19
+ const value = {
20
+ theme,
21
+ setTheme: (theme) => {
22
+ localStorage.setItem(storageKey, theme);
23
+ setTheme(theme);
24
+ },
25
+ };
26
+ return (_jsx(ThemeProviderContext.Provider, { ...props, value: value, children: children }));
27
+ }
@@ -0,0 +1,4 @@
1
+ export declare const useTheme: () => {
2
+ theme: import("./theme-context").TTheme;
3
+ setTheme: (theme: import("./theme-context").TTheme) => void;
4
+ };
@@ -0,0 +1,8 @@
1
+ import { useContext } from 'react';
2
+ import { ThemeProviderContext } from './theme-context';
3
+ export const useTheme = () => {
4
+ const context = useContext(ThemeProviderContext);
5
+ if (context === undefined)
6
+ throw new Error('useTheme must be used within a ThemeProvider');
7
+ return context;
8
+ };
@@ -0,0 +1,4 @@
1
+ export declare const useWidget: () => {
2
+ widget: import("./widget-context").TWidget | null;
3
+ setWidget: (widgets: import("./widget-context").TWidget | null) => void;
4
+ };
@@ -0,0 +1,8 @@
1
+ import { useContext } from 'react';
2
+ import { WidgetsProviderContext } from './widget-context';
3
+ export const useWidget = () => {
4
+ const context = useContext(WidgetsProviderContext);
5
+ if (context === undefined)
6
+ throw new Error('useWidget must be used within a WidgetsProvider');
7
+ return context;
8
+ };
@@ -0,0 +1,12 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { TBlockProps } from '../../ui';
3
+ export type TWidget = {
4
+ ui: ReactElement<TBlockProps>;
5
+ id: string;
6
+ };
7
+ type TWidgetProviderState = {
8
+ widget: TWidget | null;
9
+ setWidget: (widgets: TWidget | null) => void;
10
+ };
11
+ export declare const WidgetsProviderContext: import("react").Context<TWidgetProviderState>;
12
+ export {};
@@ -0,0 +1,6 @@
1
+ import { createContext } from 'react';
2
+ const initialState = {
3
+ widget: null,
4
+ setWidget: () => null,
5
+ };
6
+ export const WidgetsProviderContext = createContext(initialState);
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from 'react';
2
+ type TWidgetProviderProps = {
3
+ children: ReactNode;
4
+ };
5
+ export declare function WidgetProvider({ children }: TWidgetProviderProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import { WidgetsProviderContext } from './widget-context';
4
+ export function WidgetProvider({ children }) {
5
+ const [widget, setWidget] = useState(null);
6
+ const value = useMemo(() => ({
7
+ widget,
8
+ setWidget: (newWidget) => {
9
+ if (newWidget?.id === widget?.id) {
10
+ setWidget(newWidget);
11
+ }
12
+ },
13
+ }), [widget]);
14
+ return _jsx(WidgetsProviderContext.Provider, { value: value, children: children });
15
+ }
@@ -0,0 +1,10 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ type ButtonVariant = 'active' | 'secondary' | 'selling';
3
+ type ButtonProps = {
4
+ children: ReactNode;
5
+ onClick?: VoidFunction;
6
+ variant?: ButtonVariant;
7
+ disabled?: boolean;
8
+ };
9
+ export declare const Button: FC<ButtonProps>;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jc } from '../../../utils';
3
+ import { Typo } from '../../information';
4
+ const variantMap = {
5
+ active: 'bg-[var(--primary)] text-[var(--primary-foreground)]',
6
+ secondary: 'bg-secondary text-secondary-foreground border border-[var(--border)]',
7
+ selling: 'bg-accent text-accent-foreground',
8
+ };
9
+ export const Button = ({ children, onClick, variant = 'active', disabled = false }) => {
10
+ return (_jsx("button", { className: jc('w-auto px-4 py-2 text-[14px] font-medium border border-transparent cursor-pointer outline-none transition-opacity duration-200', 'disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none hover:not-disabled:opacity-90', variantMap[variant]), onClick: onClick, disabled: disabled, children: _jsx(Typo, { size: 'm', children: children }) }));
11
+ };
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Button } from './button';
3
+ declare const meta: Meta<typeof Button>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Active: Story;
7
+ export declare const Secondary: Story;
8
+ export declare const Selling: Story;
9
+ export declare const Disabled: Story;
@@ -0,0 +1,38 @@
1
+ import { Button } from './button';
2
+ const meta = {
3
+ title: 'Controls/Button',
4
+ component: Button,
5
+ tags: ['autodocs'],
6
+ argTypes: {
7
+ onClick: { action: 'clicked' },
8
+ variant: {
9
+ control: 'select',
10
+ options: ['active', 'secondary', 'selling'],
11
+ },
12
+ },
13
+ };
14
+ export default meta;
15
+ export const Active = {
16
+ args: {
17
+ children: 'Активная кнопка',
18
+ variant: 'active',
19
+ },
20
+ };
21
+ export const Secondary = {
22
+ args: {
23
+ children: 'Вторичная кнопка',
24
+ variant: 'secondary',
25
+ },
26
+ };
27
+ export const Selling = {
28
+ args: {
29
+ children: 'Продающая кнопка',
30
+ variant: 'selling',
31
+ },
32
+ };
33
+ export const Disabled = {
34
+ args: {
35
+ children: 'Отключенная кнопка',
36
+ disabled: true,
37
+ },
38
+ };
@@ -0,0 +1,12 @@
1
+ import type { LucideProps } from 'lucide-react';
2
+ import { type FC, type ReactElement } from 'react';
3
+ import { type TTypoProps } from '../../information';
4
+ type TVariant = 'default' | 'secondary' | 'accent';
5
+ type TProps = {
6
+ variant?: TVariant;
7
+ onClick?: VoidFunction;
8
+ accLeft?: FC<LucideProps>;
9
+ children: ReactElement<TTypoProps>;
10
+ };
11
+ export declare const Chip: FC<TProps>;
12
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Activity, createElement } from 'react';
3
+ import { jc } from '../../../utils';
4
+ const variantMap = {
5
+ default: 'bg-secondary text-secondary-foreground',
6
+ accent: 'bg-accent text-accent-foreground',
7
+ secondary: 'bg-transparent text-secondary-foreground border border-secondary-foreground',
8
+ };
9
+ export const Chip = ({ children, onClick, accLeft, variant = 'default' }) => {
10
+ return (_jsxs("button", { onClick: onClick, className: jc('flex items-center text-nowrap gap-[5px] w-min px-2 py-1 rounded-2xl outline-none border-none cursor-pointer text-[14px]', variantMap[variant]), children: [_jsx(Activity, { mode: accLeft ? 'visible' : 'hidden', children: accLeft ? createElement(accLeft, { size: 14, color: 'white', strokeWidth: 3 }) : null }), children] }));
11
+ };
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Chip } from './chip';
3
+ declare const meta: Meta<typeof Chip>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const Accent: Story;
8
+ export declare const Secondary: Story;
9
+ export declare const WithIcon: Story;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Mail } from 'lucide-react';
3
+ import { Chip } from './chip';
4
+ import { Typo } from '../../information';
5
+ const meta = {
6
+ title: 'Controls/Chip',
7
+ component: Chip,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ onClick: { action: 'clicked' },
11
+ variant: {
12
+ control: 'select',
13
+ options: ['default', 'secondary', 'accent'],
14
+ },
15
+ },
16
+ };
17
+ export default meta;
18
+ export const Default = {
19
+ args: {
20
+ children: _jsx(Typo, { children: "Chip Content" }),
21
+ variant: 'default',
22
+ },
23
+ };
24
+ export const Accent = {
25
+ args: {
26
+ children: _jsx(Typo, { children: "Accent Chip" }),
27
+ variant: 'accent',
28
+ },
29
+ };
30
+ export const Secondary = {
31
+ args: {
32
+ children: _jsx(Typo, { children: "Secondary Chip" }),
33
+ variant: 'secondary',
34
+ },
35
+ };
36
+ export const WithIcon = {
37
+ args: {
38
+ children: _jsx(Typo, { children: "Email" }),
39
+ accLeft: Mail,
40
+ variant: 'accent',
41
+ },
42
+ };
@@ -0,0 +1,8 @@
1
+ import { type FC } from 'react';
2
+ type TColorPickerProps = {
3
+ value: string;
4
+ onChange: (color: string) => void;
5
+ label?: string;
6
+ };
7
+ export declare const ColorPicker: FC<TColorPickerProps>;
8
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTheme } from '../../../providers';
3
+ import { jc } from '../../../utils';
4
+ import { Typo } from '../../information';
5
+ import { Flex, Offset } from '../../layout';
6
+ const COLORS = [
7
+ '#3b82f6', // blue
8
+ '#ef4444', // red
9
+ '#10b981', // green
10
+ '#f59e0b', // amber
11
+ '#6366f1', // indigo
12
+ '#8b5cf6', // violet
13
+ '#ec4899', // pink
14
+ '#14b8a6', // teal
15
+ '#f97316', // orange
16
+ '#71717a', // zinc
17
+ ];
18
+ export const ColorPicker = ({ value, onChange, label }) => {
19
+ const { theme } = useTheme();
20
+ return (_jsxs("div", { className: "flex flex-col gap-[2px]", children: [label && (_jsx(Offset, { children: _jsx(Typo, { size: 's', color: 'secondary', weight: '500', children: label }) })), _jsx(Offset, { children: _jsx(Flex, { direction: 'row', gap: '8px', offset: '4px', children: COLORS.map((color) => (_jsx("button", { type: "button", className: jc('h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 active:scale-95', value === color ? (theme === 'light' ? 'border-foreground' : `border-white`) : 'border-transparent'), style: { backgroundColor: color }, onClick: () => onChange(color), title: color }, color))) }) })] }));
21
+ };
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { ColorPicker } from './color-picker';
3
+ declare const meta: Meta<typeof ColorPicker>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const WithoutLabel: Story;
@@ -0,0 +1,21 @@
1
+ import { ColorPicker } from './color-picker';
2
+ const meta = {
3
+ title: 'Controls/ColorPicker',
4
+ component: ColorPicker,
5
+ tags: ['autodocs'],
6
+ argTypes: {
7
+ onChange: { action: 'changed' },
8
+ },
9
+ };
10
+ export default meta;
11
+ export const Default = {
12
+ args: {
13
+ value: '#3b82f6',
14
+ label: 'Выберите цвет',
15
+ },
16
+ };
17
+ export const WithoutLabel = {
18
+ args: {
19
+ value: '#ef4444',
20
+ },
21
+ };
@@ -0,0 +1,6 @@
1
+ import { type FC, type PropsWithChildren } from 'react';
2
+ type CopyProps = PropsWithChildren<{
3
+ toCopy: string;
4
+ }>;
5
+ export declare const Copy: FC<CopyProps>;
6
+ export {};
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ export const Copy = ({ toCopy, children }) => {
4
+ const [active, setActive] = useState(false);
5
+ const handleCopy = async () => {
6
+ try {
7
+ await navigator.clipboard.writeText(toCopy);
8
+ setActive(true);
9
+ setTimeout(() => setActive(false), 150);
10
+ }
11
+ catch (e) {
12
+ console.error('Failed to copy:', e);
13
+ }
14
+ };
15
+ return (_jsx("span", { onClick: handleCopy, className: `
16
+ cursor-pointer select-none
17
+ transition-opacity duration-150
18
+ ${active ? 'opacity-70' : 'opacity-100'}
19
+ `, children: children ?? toCopy }));
20
+ };
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Copy } from './copy';
3
+ declare const meta: Meta<typeof Copy>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const JustText: Story;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Copy } from './copy';
3
+ import { Typo } from '../../information';
4
+ const meta = {
5
+ title: 'Controls/Copy',
6
+ component: Copy,
7
+ tags: ['autodocs'],
8
+ };
9
+ export default meta;
10
+ export const Default = {
11
+ args: {
12
+ toCopy: 'Hello World',
13
+ children: _jsx(Typo, { children: "Click to copy \"Hello World\"" }),
14
+ },
15
+ };
16
+ export const JustText = {
17
+ args: {
18
+ toCopy: 'Plain text copy',
19
+ },
20
+ };
@@ -0,0 +1,7 @@
1
+ export * from './button/button';
2
+ export * from './chip/chip';
3
+ export * from './color-picker/color-picker';
4
+ export * from './copy/copy';
5
+ export * from './input/input';
6
+ export * from './select/select';
7
+ export * from './textarea/textarea';
@@ -0,0 +1,7 @@
1
+ export * from './button/button';
2
+ export * from './chip/chip';
3
+ export * from './color-picker/color-picker';
4
+ export * from './copy/copy';
5
+ export * from './input/input';
6
+ export * from './select/select';
7
+ export * from './textarea/textarea';
@@ -0,0 +1,14 @@
1
+ import type { ChangeEvent, FC } from 'react';
2
+ export type TInputProps = {
3
+ value: string;
4
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
5
+ onClick?: (e: ChangeEvent<HTMLInputElement>) => void;
6
+ label?: string;
7
+ placeholder?: string;
8
+ required?: boolean;
9
+ disabled?: boolean;
10
+ size?: 's' | 'm' | 'l';
11
+ autoFocus?: boolean;
12
+ type?: 'text' | 'date' | 'number' | 'password';
13
+ };
14
+ export declare const Input: FC<TInputProps>;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jc } from '../../../utils';
3
+ import { Typo } from '../../information';
4
+ import { Offset } from '../../layout';
5
+ const sizeMap = {
6
+ s: 'text-[12px] font-normal placeholder:text-[12px] placeholder:font-normal',
7
+ m: 'text-[14px] font-medium placeholder:text-[14px] placeholder:font-medium',
8
+ l: 'text-[16px] font-medium placeholder:text-[16px] placeholder:font-medium',
9
+ };
10
+ export const Input = ({ onChange, label, value, required, disabled, placeholder, size = 's', autoFocus, type = 'text', }) => {
11
+ return (_jsxs("label", { className: "flex w-full cursor-pointer flex-col gap-[2px]", children: [_jsx(Offset, { children: _jsx(Typo, { size: 's', color: 'secondary', weight: '500', children: label }) }), _jsx("input", { className: jc('w-full cursor-text rounded-sm border-none bg-inherit px-4 pb-2 pt-1 outline-none transition-all duration-200 placeholder:text-secondary-foreground', sizeMap[size]), type: type, placeholder: placeholder, value: value, onChange: onChange, disabled: disabled, required: required, autoFocus: autoFocus })] }));
12
+ };
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Input } from './input';
3
+ declare const meta: Meta<typeof Input>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const WithValue: Story;
8
+ export declare const Password: Story;
9
+ export declare const Disabled: Story;
@@ -0,0 +1,46 @@
1
+ import { Input } from './input';
2
+ const meta = {
3
+ title: 'Controls/Input',
4
+ component: Input,
5
+ tags: ['autodocs'],
6
+ argTypes: {
7
+ onChange: { action: 'changed' },
8
+ size: {
9
+ control: 'select',
10
+ options: ['s', 'm', 'l'],
11
+ },
12
+ type: {
13
+ control: 'select',
14
+ options: ['text', 'date', 'number', 'password'],
15
+ },
16
+ },
17
+ };
18
+ export default meta;
19
+ export const Default = {
20
+ args: {
21
+ label: 'Label',
22
+ value: '',
23
+ placeholder: 'Placeholder...',
24
+ },
25
+ };
26
+ export const WithValue = {
27
+ args: {
28
+ label: 'Username',
29
+ value: 'JohnDoe',
30
+ placeholder: 'Enter username',
31
+ },
32
+ };
33
+ export const Password = {
34
+ args: {
35
+ label: 'Password',
36
+ value: 'secret',
37
+ type: 'password',
38
+ },
39
+ };
40
+ export const Disabled = {
41
+ args: {
42
+ label: 'Disabled Input',
43
+ value: 'Cannot edit this',
44
+ disabled: true,
45
+ },
46
+ };
@@ -0,0 +1,14 @@
1
+ import { type ReactElement } from 'react';
2
+ export type TSelectOption<T> = {
3
+ value: T;
4
+ label: string;
5
+ };
6
+ export type TSelectProps<T> = {
7
+ options: TSelectOption<T>[];
8
+ value: T;
9
+ onChange: (value: T) => void;
10
+ label?: string;
11
+ placeholder?: string;
12
+ disabled?: boolean;
13
+ };
14
+ export declare function Select<T = string>({ options, value, onChange, label, placeholder, disabled, }: TSelectProps<T>): ReactElement;