@makroz/web 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +33 -0
- package/README.md +22 -0
- package/dist/auth/MkAuthContext.d.ts +43 -0
- package/dist/auth/MkAuthContext.d.ts.map +1 -0
- package/dist/auth/MkAuthContext.js +3 -0
- package/dist/auth/MkAuthContext.js.map +1 -0
- package/dist/auth/MkAuthForm.d.ts +42 -0
- package/dist/auth/MkAuthForm.d.ts.map +1 -0
- package/dist/auth/MkAuthForm.js +53 -0
- package/dist/auth/MkAuthForm.js.map +1 -0
- package/dist/auth/MkAuthProvider.d.ts +30 -0
- package/dist/auth/MkAuthProvider.d.ts.map +1 -0
- package/dist/auth/MkAuthProvider.js +319 -0
- package/dist/auth/MkAuthProvider.js.map +1 -0
- package/dist/auth/auth/MkAuthContext.d.ts +42 -0
- package/dist/auth/auth/MkAuthForm.d.ts +41 -0
- package/dist/auth/auth/MkAuthProvider.d.ts +29 -0
- package/dist/auth/auth/types.d.ts +62 -0
- package/dist/auth/auth/useMkAuth.d.ts +18 -0
- package/dist/auth/components/MkButton.d.ts +10 -0
- package/dist/auth/components/MkInput.d.ts +12 -0
- package/dist/auth/types.d.ts +63 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +20 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/auth/useMkAuth.d.ts +19 -0
- package/dist/auth/useMkAuth.d.ts.map +1 -0
- package/dist/auth/useMkAuth.js +26 -0
- package/dist/auth/useMkAuth.js.map +1 -0
- package/dist/components/MkAccordion.d.ts +36 -0
- package/dist/components/MkAccordion.d.ts.map +1 -0
- package/dist/components/MkAccordion.js +25 -0
- package/dist/components/MkAccordion.js.map +1 -0
- package/dist/components/MkAccordion.module.css +79 -0
- package/dist/components/MkAlert.d.ts +25 -0
- package/dist/components/MkAlert.d.ts.map +1 -0
- package/dist/components/MkAlert.js +23 -0
- package/dist/components/MkAlert.js.map +1 -0
- package/dist/components/MkAlert.module.css +103 -0
- package/dist/components/MkAvatar.d.ts +16 -0
- package/dist/components/MkAvatar.d.ts.map +1 -0
- package/dist/components/MkAvatar.js +25 -0
- package/dist/components/MkAvatar.js.map +1 -0
- package/dist/components/MkAvatar.module.css +62 -0
- package/dist/components/MkBadge.d.ts +15 -0
- package/dist/components/MkBadge.d.ts.map +1 -0
- package/dist/components/MkBadge.js +9 -0
- package/dist/components/MkBadge.js.map +1 -0
- package/dist/components/MkBadge.module.css +74 -0
- package/dist/components/MkButton.d.ts +11 -0
- package/dist/components/MkButton.d.ts.map +1 -0
- package/dist/components/MkButton.js +20 -0
- package/dist/components/MkButton.js.map +1 -0
- package/dist/components/MkButton.module.css +85 -0
- package/dist/components/MkButton.test.d.ts +2 -0
- package/dist/components/MkButton.test.d.ts.map +1 -0
- package/dist/components/MkButton.test.js +58 -0
- package/dist/components/MkButton.test.js.map +1 -0
- package/dist/components/MkCard.d.ts +18 -0
- package/dist/components/MkCard.d.ts.map +1 -0
- package/dist/components/MkCard.js +8 -0
- package/dist/components/MkCard.js.map +1 -0
- package/dist/components/MkCard.module.css +63 -0
- package/dist/components/MkCheck.d.ts +32 -0
- package/dist/components/MkCheck.d.ts.map +1 -0
- package/dist/components/MkCheck.js +14 -0
- package/dist/components/MkCheck.js.map +1 -0
- package/dist/components/MkCheck.module.css +87 -0
- package/dist/components/MkDatePicker.d.ts +29 -0
- package/dist/components/MkDatePicker.d.ts.map +1 -0
- package/dist/components/MkDatePicker.js +12 -0
- package/dist/components/MkDatePicker.js.map +1 -0
- package/dist/components/MkDatePicker.module.css +77 -0
- package/dist/components/MkDivider.d.ts +14 -0
- package/dist/components/MkDivider.d.ts.map +1 -0
- package/dist/components/MkDivider.js +14 -0
- package/dist/components/MkDivider.js.map +1 -0
- package/dist/components/MkDivider.module.css +39 -0
- package/dist/components/MkDropDown.d.ts +22 -0
- package/dist/components/MkDropDown.d.ts.map +1 -0
- package/dist/components/MkDropDown.js +26 -0
- package/dist/components/MkDropDown.js.map +1 -0
- package/dist/components/MkDropDown.module.css +108 -0
- package/dist/components/MkEmptyState.d.ts +14 -0
- package/dist/components/MkEmptyState.d.ts.map +1 -0
- package/dist/components/MkEmptyState.js +8 -0
- package/dist/components/MkEmptyState.js.map +1 -0
- package/dist/components/MkEmptyState.module.css +35 -0
- package/dist/components/MkFileUpload.d.ts +36 -0
- package/dist/components/MkFileUpload.d.ts.map +1 -0
- package/dist/components/MkFileUpload.js +52 -0
- package/dist/components/MkFileUpload.js.map +1 -0
- package/dist/components/MkFileUpload.module.css +74 -0
- package/dist/components/MkIcons.d.ts +14 -0
- package/dist/components/MkIcons.d.ts.map +1 -0
- package/dist/components/MkIcons.js +38 -0
- package/dist/components/MkIcons.js.map +1 -0
- package/dist/components/MkInfiniteList.d.ts +15 -0
- package/dist/components/MkInfiniteList.d.ts.map +1 -0
- package/dist/components/MkInfiniteList.js +31 -0
- package/dist/components/MkInfiniteList.js.map +1 -0
- package/dist/components/MkInfiniteList.module.css +69 -0
- package/dist/components/MkInput.d.ts +13 -0
- package/dist/components/MkInput.d.ts.map +1 -0
- package/dist/components/MkInput.js +23 -0
- package/dist/components/MkInput.js.map +1 -0
- package/dist/components/MkInput.module.css +94 -0
- package/dist/components/MkLoading.d.ts +20 -0
- package/dist/components/MkLoading.d.ts.map +1 -0
- package/dist/components/MkLoading.js +16 -0
- package/dist/components/MkLoading.js.map +1 -0
- package/dist/components/MkLoading.module.css +39 -0
- package/dist/components/MkModal.d.ts +20 -0
- package/dist/components/MkModal.d.ts.map +1 -0
- package/dist/components/MkModal.js +33 -0
- package/dist/components/MkModal.js.map +1 -0
- package/dist/components/MkModal.module.css +107 -0
- package/dist/components/MkProgressBar.d.ts +17 -0
- package/dist/components/MkProgressBar.d.ts.map +1 -0
- package/dist/components/MkProgressBar.js +9 -0
- package/dist/components/MkProgressBar.js.map +1 -0
- package/dist/components/MkProgressBar.module.css +48 -0
- package/dist/components/MkRadio.d.ts +34 -0
- package/dist/components/MkRadio.d.ts.map +1 -0
- package/dist/components/MkRadio.js +21 -0
- package/dist/components/MkRadio.js.map +1 -0
- package/dist/components/MkRadio.module.css +74 -0
- package/dist/components/MkSearchInput.d.ts +30 -0
- package/dist/components/MkSearchInput.d.ts.map +1 -0
- package/dist/components/MkSearchInput.js +29 -0
- package/dist/components/MkSearchInput.js.map +1 -0
- package/dist/components/MkSearchInput.module.css +80 -0
- package/dist/components/MkSelect.d.ts +23 -0
- package/dist/components/MkSelect.d.ts.map +1 -0
- package/dist/components/MkSelect.js +61 -0
- package/dist/components/MkSelect.js.map +1 -0
- package/dist/components/MkSelect.module.css +177 -0
- package/dist/components/MkSkeleton.d.ts +22 -0
- package/dist/components/MkSkeleton.d.ts.map +1 -0
- package/dist/components/MkSkeleton.js +23 -0
- package/dist/components/MkSkeleton.js.map +1 -0
- package/dist/components/MkSkeleton.module.css +28 -0
- package/dist/components/MkSwitch.d.ts +22 -0
- package/dist/components/MkSwitch.d.ts.map +1 -0
- package/dist/components/MkSwitch.js +16 -0
- package/dist/components/MkSwitch.js.map +1 -0
- package/dist/components/MkSwitch.module.css +108 -0
- package/dist/components/MkTable.d.ts +27 -0
- package/dist/components/MkTable.d.ts.map +1 -0
- package/dist/components/MkTable.js +13 -0
- package/dist/components/MkTable.js.map +1 -0
- package/dist/components/MkTable.module.css +163 -0
- package/dist/components/MkTabs.d.ts +22 -0
- package/dist/components/MkTabs.d.ts.map +1 -0
- package/dist/components/MkTabs.js +19 -0
- package/dist/components/MkTabs.js.map +1 -0
- package/dist/components/MkTabs.module.css +117 -0
- package/dist/components/MkTextArea.d.ts +21 -0
- package/dist/components/MkTextArea.d.ts.map +1 -0
- package/dist/components/MkTextArea.js +10 -0
- package/dist/components/MkTextArea.js.map +1 -0
- package/dist/components/MkThemeEditor.d.ts +8 -0
- package/dist/components/MkThemeEditor.d.ts.map +1 -0
- package/dist/components/MkThemeEditor.js +45 -0
- package/dist/components/MkThemeEditor.js.map +1 -0
- package/dist/components/MkThemeEditor.module.css +177 -0
- package/dist/components/MkToastContainer.d.ts +3 -0
- package/dist/components/MkToastContainer.d.ts.map +1 -0
- package/dist/components/MkToastContainer.js +81 -0
- package/dist/components/MkToastContainer.js.map +1 -0
- package/dist/components/MkToastContainer.module.css +95 -0
- package/dist/components/MkTooltip.d.ts +14 -0
- package/dist/components/MkTooltip.d.ts.map +1 -0
- package/dist/components/MkTooltip.js +19 -0
- package/dist/components/MkTooltip.js.map +1 -0
- package/dist/components/MkTooltip.module.css +43 -0
- package/dist/components/MkWindowList.d.ts +20 -0
- package/dist/components/MkWindowList.d.ts.map +1 -0
- package/dist/components/MkWindowList.js +61 -0
- package/dist/components/MkWindowList.js.map +1 -0
- package/dist/components/MkWindowList.module.css +59 -0
- package/dist/components/index.d.ts +31 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +34 -0
- package/dist/components/index.js.map +1 -0
- package/dist/context/MkApiContext.d.ts +15 -0
- package/dist/context/MkApiContext.d.ts.map +1 -0
- package/dist/context/MkApiContext.js +30 -0
- package/dist/context/MkApiContext.js.map +1 -0
- package/dist/context/MkAuthContext.d.ts +20 -0
- package/dist/context/MkAuthContext.d.ts.map +1 -0
- package/dist/context/MkAuthContext.js +90 -0
- package/dist/context/MkAuthContext.js.map +1 -0
- package/dist/context/MkConfirmContext.d.ts +8 -0
- package/dist/context/MkConfirmContext.d.ts.map +1 -0
- package/dist/context/MkConfirmContext.js +39 -0
- package/dist/context/MkConfirmContext.js.map +1 -0
- package/dist/context/MkToastContext.d.ts +8 -0
- package/dist/context/MkToastContext.d.ts.map +1 -0
- package/dist/context/MkToastContext.js +64 -0
- package/dist/context/MkToastContext.js.map +1 -0
- package/dist/hooks/useApi.d.ts +19 -0
- package/dist/hooks/useApi.d.ts.map +1 -0
- package/dist/hooks/useApi.js +82 -0
- package/dist/hooks/useApi.js.map +1 -0
- package/dist/hooks/useApi.test.d.ts +2 -0
- package/dist/hooks/useApi.test.d.ts.map +1 -0
- package/dist/hooks/useApi.test.js +186 -0
- package/dist/hooks/useApi.test.js.map +1 -0
- package/dist/hooks/useMkClickOutside.d.ts +8 -0
- package/dist/hooks/useMkClickOutside.d.ts.map +1 -0
- package/dist/hooks/useMkClickOutside.js +26 -0
- package/dist/hooks/useMkClickOutside.js.map +1 -0
- package/dist/hooks/useMkCrud.d.ts +39 -0
- package/dist/hooks/useMkCrud.d.ts.map +1 -0
- package/dist/hooks/useMkCrud.js +121 -0
- package/dist/hooks/useMkCrud.js.map +1 -0
- package/dist/hooks/useMkCrud.test.d.ts +2 -0
- package/dist/hooks/useMkCrud.test.d.ts.map +1 -0
- package/dist/hooks/useMkCrud.test.js +89 -0
- package/dist/hooks/useMkCrud.test.js.map +1 -0
- package/dist/hooks/useMkDebounce.d.ts +24 -0
- package/dist/hooks/useMkDebounce.d.ts.map +1 -0
- package/dist/hooks/useMkDebounce.js +38 -0
- package/dist/hooks/useMkDebounce.js.map +1 -0
- package/dist/hooks/useMkEffectDebug.d.ts +7 -0
- package/dist/hooks/useMkEffectDebug.d.ts.map +1 -0
- package/dist/hooks/useMkEffectDebug.js +26 -0
- package/dist/hooks/useMkEffectDebug.js.map +1 -0
- package/dist/hooks/useMkEvent.d.ts +31 -0
- package/dist/hooks/useMkEvent.d.ts.map +1 -0
- package/dist/hooks/useMkEvent.js +56 -0
- package/dist/hooks/useMkEvent.js.map +1 -0
- package/dist/hooks/useMkForm.d.ts +43 -0
- package/dist/hooks/useMkForm.d.ts.map +1 -0
- package/dist/hooks/useMkForm.js +115 -0
- package/dist/hooks/useMkForm.js.map +1 -0
- package/dist/hooks/useMkForm.test.d.ts +2 -0
- package/dist/hooks/useMkForm.test.d.ts.map +1 -0
- package/dist/hooks/useMkForm.test.js +81 -0
- package/dist/hooks/useMkForm.test.js.map +1 -0
- package/dist/hooks/useMkInViewPort.d.ts +14 -0
- package/dist/hooks/useMkInViewPort.d.ts.map +1 -0
- package/dist/hooks/useMkInViewPort.js +31 -0
- package/dist/hooks/useMkInViewPort.js.map +1 -0
- package/dist/hooks/useMkInfiniteList.d.ts +15 -0
- package/dist/hooks/useMkInfiniteList.d.ts.map +1 -0
- package/dist/hooks/useMkInfiniteList.js +47 -0
- package/dist/hooks/useMkInfiniteList.js.map +1 -0
- package/dist/hooks/useMkList.d.ts +61 -0
- package/dist/hooks/useMkList.d.ts.map +1 -0
- package/dist/hooks/useMkList.js +54 -0
- package/dist/hooks/useMkList.js.map +1 -0
- package/dist/hooks/useMkLocalStorage.d.ts +6 -0
- package/dist/hooks/useMkLocalStorage.d.ts.map +1 -0
- package/dist/hooks/useMkLocalStorage.js +33 -0
- package/dist/hooks/useMkLocalStorage.js.map +1 -0
- package/dist/hooks/useMkLongPress.d.ts +37 -0
- package/dist/hooks/useMkLongPress.d.ts.map +1 -0
- package/dist/hooks/useMkLongPress.js +59 -0
- package/dist/hooks/useMkLongPress.js.map +1 -0
- package/dist/hooks/useMkMediaQuery.d.ts +14 -0
- package/dist/hooks/useMkMediaQuery.d.ts.map +1 -0
- package/dist/hooks/useMkMediaQuery.js +31 -0
- package/dist/hooks/useMkMediaQuery.js.map +1 -0
- package/dist/hooks/useMkPrevious.d.ts +7 -0
- package/dist/hooks/useMkPrevious.d.ts.map +1 -0
- package/dist/hooks/useMkPrevious.js +14 -0
- package/dist/hooks/useMkPrevious.js.map +1 -0
- package/dist/hooks/useMkScreenSize.d.ts +25 -0
- package/dist/hooks/useMkScreenSize.d.ts.map +1 -0
- package/dist/hooks/useMkScreenSize.js +43 -0
- package/dist/hooks/useMkScreenSize.js.map +1 -0
- package/dist/hooks/useMkStore.d.ts +22 -0
- package/dist/hooks/useMkStore.d.ts.map +1 -0
- package/dist/hooks/useMkStore.js +58 -0
- package/dist/hooks/useMkStore.js.map +1 -0
- package/dist/hooks/useMkToggle.d.ts +6 -0
- package/dist/hooks/useMkToggle.d.ts.map +1 -0
- package/dist/hooks/useMkToggle.js +13 -0
- package/dist/hooks/useMkToggle.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/styles/index.css +124 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +2 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/theme/MkThemeProvider.d.ts +20 -0
- package/dist/theme/MkThemeProvider.d.ts.map +1 -0
- package/dist/theme/MkThemeProvider.js +91 -0
- package/dist/theme/MkThemeProvider.js.map +1 -0
- package/dist/utils/images.d.ts +9 -0
- package/dist/utils/images.d.ts.map +1 -0
- package/dist/utils/images.js +50 -0
- package/dist/utils/images.js.map +1 -0
- package/eslint-plugin-mk/__tests__/no-cross-module-import.test.js +66 -0
- package/eslint-plugin-mk/index.js +29 -0
- package/eslint-plugin-mk/rules/no-cross-module-import.js +71 -0
- package/package.json +62 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MkTheme } from '@mk/core';
|
|
3
|
+
interface ThemeContextType {
|
|
4
|
+
theme: MkTheme;
|
|
5
|
+
isDark: boolean;
|
|
6
|
+
toggleTheme: () => void;
|
|
7
|
+
setDark: (dark: boolean) => void;
|
|
8
|
+
customOverrides: Partial<Record<string, string>>;
|
|
9
|
+
updateOverride: (key: string, value: string) => void;
|
|
10
|
+
resetOverrides: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function MkThemeProvider({ children, initialDark, defaultTheme, }: {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
initialDark?: boolean;
|
|
15
|
+
defaultTheme?: MkTheme;
|
|
16
|
+
}): React.JSX.Element;
|
|
17
|
+
export declare const useMkTheme: () => ThemeContextType;
|
|
18
|
+
export { tokens } from '@mk/core';
|
|
19
|
+
export type { MkTheme } from '@mk/core';
|
|
20
|
+
//# sourceMappingURL=MkThemeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/MkThemeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkE,MAAM,OAAO,CAAC;AACvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,UAAU,gBAAgB;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEjC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAID,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,WAAmB,EACnB,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAiFpB;AAED,eAAO,MAAM,UAAU,wBAMtB,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useMemo, useEffect } from 'react';
|
|
4
|
+
import { tokens } from '@mk/core';
|
|
5
|
+
const ThemeContext = createContext(undefined);
|
|
6
|
+
export function MkThemeProvider({ children, initialDark = false, defaultTheme, }) {
|
|
7
|
+
const [isDark, setIsDark] = useState(initialDark);
|
|
8
|
+
const [customOverrides, setCustomOverrides] = useState({});
|
|
9
|
+
// Initial Sync from LocalStorage
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (typeof window !== 'undefined') {
|
|
12
|
+
const savedDark = localStorage.getItem('mk-theme-dark');
|
|
13
|
+
if (savedDark !== null) {
|
|
14
|
+
setIsDark(savedDark === 'true');
|
|
15
|
+
}
|
|
16
|
+
const savedOverrides = localStorage.getItem('mk-theme-custom');
|
|
17
|
+
if (savedOverrides) {
|
|
18
|
+
try {
|
|
19
|
+
setCustomOverrides(JSON.parse(savedOverrides));
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.error('Failed to load custom theme', e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
const theme = useMemo(() => {
|
|
28
|
+
if (defaultTheme)
|
|
29
|
+
return defaultTheme;
|
|
30
|
+
const baseTheme = isDark ? tokens.dark : tokens.light;
|
|
31
|
+
// Apply overrides on top of base theme
|
|
32
|
+
return Object.assign(Object.assign({}, baseTheme), customOverrides);
|
|
33
|
+
}, [isDark, defaultTheme, customOverrides]);
|
|
34
|
+
const value = {
|
|
35
|
+
theme,
|
|
36
|
+
isDark,
|
|
37
|
+
toggleTheme: () => {
|
|
38
|
+
const next = !isDark;
|
|
39
|
+
setIsDark(next);
|
|
40
|
+
if (typeof window !== 'undefined') {
|
|
41
|
+
localStorage.setItem('mk-theme-dark', String(next));
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
setDark: (dark) => {
|
|
45
|
+
setIsDark(dark);
|
|
46
|
+
if (typeof window !== 'undefined') {
|
|
47
|
+
localStorage.setItem('mk-theme-dark', String(dark));
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
customOverrides,
|
|
51
|
+
updateOverride: (key, value) => {
|
|
52
|
+
setCustomOverrides(prev => {
|
|
53
|
+
const next = Object.assign(Object.assign({}, prev), { [key]: value });
|
|
54
|
+
if (typeof window !== 'undefined') {
|
|
55
|
+
localStorage.setItem('mk-theme-custom', JSON.stringify(next));
|
|
56
|
+
}
|
|
57
|
+
return next;
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
resetOverrides: () => {
|
|
61
|
+
setCustomOverrides({});
|
|
62
|
+
if (typeof window !== 'undefined') {
|
|
63
|
+
localStorage.removeItem('mk-theme-custom');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const root = document.documentElement;
|
|
69
|
+
// Helper to convert camelCase to kebab-case
|
|
70
|
+
const toKebab = (str) => str.replace(/[A-Z]/g, m => '-' + m.toLowerCase());
|
|
71
|
+
// Apply entire theme
|
|
72
|
+
Object.entries(theme).forEach(([key, value]) => {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
root.style.setProperty(`--mk-${toKebab(key)}`, value);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// Add data-theme for extra styling flexibility
|
|
78
|
+
root.setAttribute('data-theme', isDark ? 'dark' : 'light');
|
|
79
|
+
}, [theme, isDark]);
|
|
80
|
+
return _jsx(ThemeContext.Provider, { value: value, children: children });
|
|
81
|
+
}
|
|
82
|
+
;
|
|
83
|
+
export const useMkTheme = () => {
|
|
84
|
+
const context = useContext(ThemeContext);
|
|
85
|
+
if (!context) {
|
|
86
|
+
throw new Error('useMkTheme must be used within a MkThemeProvider');
|
|
87
|
+
}
|
|
88
|
+
return context;
|
|
89
|
+
};
|
|
90
|
+
export { tokens } from '@mk/core';
|
|
91
|
+
//# sourceMappingURL=MkThemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkThemeProvider.js","sourceRoot":"","sources":["../../src/theme/MkThemeProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,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ates a WebP version of the image with the specified constraints.
|
|
6
|
+
* 🚀 Performance-first: Reduces upload payload size.
|
|
7
|
+
*/
|
|
8
|
+
export declare const mkResizeImage: (file: File | Blob, maxWidth?: number, maxHeight?: number, quality?: number) => Promise<string>;
|
|
9
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/utils/images.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACtB,MAAM,IAAI,GAAG,IAAI,EACjB,WAAU,MAAa,EACvB,YAAW,MAAa,EACxB,UAAS,MAAY,KACtB,OAAO,CAAC,MAAM,CAgDhB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mkResizeImage
|
|
3
|
+
*
|
|
4
|
+
* Frontend image resizer using Canvas.
|
|
5
|
+
* Generates a WebP version of the image with the specified constraints.
|
|
6
|
+
* 🚀 Performance-first: Reduces upload payload size.
|
|
7
|
+
*/
|
|
8
|
+
export const mkResizeImage = async (file, maxWidth = 1024, maxHeight = 1024, quality = 0.8) => {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
if (typeof window === 'undefined') {
|
|
11
|
+
return reject(new Error('mkResizeImage solo puede usarse en el navegador.'));
|
|
12
|
+
}
|
|
13
|
+
const reader = new FileReader();
|
|
14
|
+
reader.onload = (event) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const img = new Image();
|
|
17
|
+
img.src = (_a = event.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
18
|
+
img.onload = () => {
|
|
19
|
+
let width = img.width;
|
|
20
|
+
let height = img.height;
|
|
21
|
+
// Adjust based on constraints
|
|
22
|
+
if (width > maxWidth || height > maxHeight) {
|
|
23
|
+
const aspectRatio = width / height;
|
|
24
|
+
if (width > height) {
|
|
25
|
+
width = maxWidth;
|
|
26
|
+
height = maxWidth / aspectRatio;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
height = maxHeight;
|
|
30
|
+
width = maxHeight * aspectRatio;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const canvas = document.createElement('canvas');
|
|
34
|
+
canvas.width = width;
|
|
35
|
+
canvas.height = height;
|
|
36
|
+
const ctx = canvas.getContext('2d');
|
|
37
|
+
if (!ctx)
|
|
38
|
+
return reject(new Error('No se pudo obtener el contexto 2d del canvas.'));
|
|
39
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
40
|
+
// Convert to WebP for modern performance
|
|
41
|
+
const resizedImage = canvas.toDataURL('image/webp', quality);
|
|
42
|
+
resolve(resizedImage);
|
|
43
|
+
};
|
|
44
|
+
img.onerror = () => reject(new Error('Error al cargar la imagen en el motor de renderizado.'));
|
|
45
|
+
};
|
|
46
|
+
reader.onerror = () => reject(new Error('Error al leer el archivo de origen.'));
|
|
47
|
+
reader.readAsDataURL(file);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../src/utils/images.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAC9B,IAAiB,EACjB,WAAmB,IAAI,EACvB,YAAoB,IAAI,EACxB,UAAkB,GAAG,EACN,EAAE;IACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAEhC,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE;;YACtB,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE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C,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC,CAAC;QACnG,CAAC,CAAC;QAEF,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAChF,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vitest-environment node
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { RuleTester } from 'eslint';
|
|
6
|
+
import rule from '../rules/no-cross-module-import.js';
|
|
7
|
+
|
|
8
|
+
const ruleTester = new RuleTester({
|
|
9
|
+
languageOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('no-cross-module-import', () => {
|
|
16
|
+
ruleTester.run('no-cross-module-import', rule, {
|
|
17
|
+
valid: [
|
|
18
|
+
// Same module, deep import — OK
|
|
19
|
+
{
|
|
20
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
21
|
+
code: "import { usePaymentForm } from '@/modules/payments/components/PaymentForm';",
|
|
22
|
+
},
|
|
23
|
+
// Cross module, but using the public index — OK
|
|
24
|
+
{
|
|
25
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
26
|
+
code: "import { AdminListPage } from '@/modules/admin';",
|
|
27
|
+
},
|
|
28
|
+
// File outside any module — OK
|
|
29
|
+
{
|
|
30
|
+
filename: '/app/src/app/admin/page.tsx',
|
|
31
|
+
code: "import { AdminListPage } from '@/modules/admin/pages/AdminListPage';",
|
|
32
|
+
},
|
|
33
|
+
// Non-aliased relative import is ignored (not under @/modules/)
|
|
34
|
+
{
|
|
35
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
36
|
+
code: "import { foo } from './useFoo';",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
|
|
40
|
+
invalid: [
|
|
41
|
+
// Cross-module deep import — should fail
|
|
42
|
+
{
|
|
43
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
44
|
+
code: "import { AdminForm } from '@/modules/admin/components/AdminForm';",
|
|
45
|
+
errors: [{ messageId: 'forbidden' }],
|
|
46
|
+
},
|
|
47
|
+
// Cross-module re-export — should fail
|
|
48
|
+
{
|
|
49
|
+
filename: '/app/src/modules/payments/index.ts',
|
|
50
|
+
code: "export { AdminForm } from '@/modules/admin/components/AdminForm';",
|
|
51
|
+
errors: [{ messageId: 'forbidden' }],
|
|
52
|
+
},
|
|
53
|
+
// Cross-module star re-export — should fail
|
|
54
|
+
{
|
|
55
|
+
filename: '/app/src/modules/payments/index.ts',
|
|
56
|
+
code: "export * from '@/modules/admin/components/AdminForm';",
|
|
57
|
+
errors: [{ messageId: 'forbidden' }],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('has expected meta', () => {
|
|
63
|
+
expect(rule.meta.type).toBe('problem');
|
|
64
|
+
expect(rule.meta.messages.forbidden).toContain('@/modules/{{source}}');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mk/eslint-plugin-mk — package root
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the MME rule (R-MK-001) for JavaScript/TypeScript:
|
|
5
|
+
* blocks cross-module imports; only `@/modules/{name}` (the public
|
|
6
|
+
* index) is allowed from other modules.
|
|
7
|
+
*
|
|
8
|
+
* Consumers enable it in their eslint.config.mjs:
|
|
9
|
+
*
|
|
10
|
+
* import mkPlugin from '@makroz/web/eslint-plugin-mk';
|
|
11
|
+
* export default [
|
|
12
|
+
* ...nextConfig,
|
|
13
|
+
* { plugins: { mk: mkPlugin }, rules: { '@mk/no-cross-module-import': 'error' } },
|
|
14
|
+
* ];
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import noCrossModuleImport from './rules/no-cross-module-import.js';
|
|
18
|
+
|
|
19
|
+
const plugin = {
|
|
20
|
+
meta: {
|
|
21
|
+
name: '@mk/eslint-plugin-mk',
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
'no-cross-module-import': noCrossModuleImport,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default plugin;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule: no-cross-module-import
|
|
3
|
+
*
|
|
4
|
+
* Forbids files inside `src/modules/{X}/` from importing deep paths
|
|
5
|
+
* inside another module. Only `@/modules/{X}` (the index/public API)
|
|
6
|
+
* is allowed.
|
|
7
|
+
*
|
|
8
|
+
* Scenarios:
|
|
9
|
+
* Given file src/modules/payments/hooks/usePayment.ts
|
|
10
|
+
* When it imports '@/modules/admin/components/AdminForm'
|
|
11
|
+
* Then the lint fails:
|
|
12
|
+
* "Cross-module import is forbidden. Use '@/modules/admin' public API instead."
|
|
13
|
+
*
|
|
14
|
+
* Given the same file imports '@/modules/admin'
|
|
15
|
+
* Then the lint passes.
|
|
16
|
+
*
|
|
17
|
+
* Given a file OUTSIDE any module (e.g. src/app/admin/page.tsx)
|
|
18
|
+
* When it imports '@/modules/admin/...'
|
|
19
|
+
* Then the lint passes — the app is the consumer of the public API.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const MODULE_PATH_RE = /[\\/]modules[\\/]([\w-]+)(?:[\\/](.*))?/;
|
|
23
|
+
|
|
24
|
+
const MESSAGE = "Cross-module import is forbidden. Use '@/modules/{{source}}' public API instead. Got: '{{imported}}'.";
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
meta: {
|
|
28
|
+
type: 'problem',
|
|
29
|
+
docs: {
|
|
30
|
+
description:
|
|
31
|
+
'Forbid deep cross-module imports in favor of the public module index.',
|
|
32
|
+
},
|
|
33
|
+
schema: [],
|
|
34
|
+
messages: {
|
|
35
|
+
forbidden: MESSAGE,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
create(context) {
|
|
40
|
+
const filename = context.getFilename();
|
|
41
|
+
const moduleMatch = filename.match(MODULE_PATH_RE);
|
|
42
|
+
if (!moduleMatch) {
|
|
43
|
+
// File is outside any module — app-level code, ignore.
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
const sourceModule = moduleMatch[1];
|
|
47
|
+
|
|
48
|
+
function checkImport(node) {
|
|
49
|
+
const importPath = node.source?.value;
|
|
50
|
+
if (typeof importPath !== 'string') return;
|
|
51
|
+
const importMatch = importPath.match(/^@\/modules\/([\w-]+)(?:\/(.+))?$/);
|
|
52
|
+
if (!importMatch) return;
|
|
53
|
+
const [, targetModule, subPath] = importMatch;
|
|
54
|
+
if (targetModule === sourceModule) return; // same module, OK
|
|
55
|
+
if (!subPath) return; // bare '@/modules/admin' (the index), OK
|
|
56
|
+
|
|
57
|
+
context.report({
|
|
58
|
+
node,
|
|
59
|
+
messageId: 'forbidden',
|
|
60
|
+
data: { source: targetModule, imported: importPath },
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
ImportDeclaration: checkImport,
|
|
66
|
+
// Also catch `export ... from '...'` re-exports.
|
|
67
|
+
ExportNamedDeclaration: checkImport,
|
|
68
|
+
ExportAllDeclaration: checkImport,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@makroz/web",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "React UI components and hooks for MK-Director web applications",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./styles/*": "./dist/styles/*",
|
|
14
|
+
"./styles/*.css": "./dist/styles/*.css",
|
|
15
|
+
"./eslint-plugin-mk": "./eslint-plugin-mk/index.js",
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"eslint-plugin-mk"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/condaty/mk-director.git",
|
|
28
|
+
"directory": "packages/mk-web"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@tanstack/react-query": "^5.62.0",
|
|
32
|
+
"@makroz/core": "1.0.1"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": "19.2.3",
|
|
36
|
+
"react-dom": "19.2.3",
|
|
37
|
+
"next": "^16.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
41
|
+
"@testing-library/react": "^16.0.0",
|
|
42
|
+
"@types/react": "19.2.3",
|
|
43
|
+
"@types/react-dom": "19.2.3",
|
|
44
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
45
|
+
"eslint": "^9.20.0",
|
|
46
|
+
"jsdom": "^24.0.0",
|
|
47
|
+
"react": "^19.0.0",
|
|
48
|
+
"react-dom": "^19.0.0",
|
|
49
|
+
"typescript": "^5.7.0",
|
|
50
|
+
"vitest": "^3.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc && rm -f dist/**/*.test.* && cp -r src/components/*.css dist/components/ && cp -r src/styles dist/",
|
|
54
|
+
"lint": "eslint src/",
|
|
55
|
+
"lint:fix": "eslint src/ --fix",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest",
|
|
58
|
+
"test:coverage": "vitest run --coverage",
|
|
59
|
+
"type-check": "tsc --noEmit",
|
|
60
|
+
"clean": "rm -rf dist"
|
|
61
|
+
}
|
|
62
|
+
}
|