@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,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useMemo } from 'react';
|
|
4
|
+
import styles from './MkThemeEditor.module.css';
|
|
5
|
+
import { useMkTheme } from '../theme/MkThemeProvider';
|
|
6
|
+
import { tokens } from '@mk/core';
|
|
7
|
+
/**
|
|
8
|
+
* @module MkThemeEditor
|
|
9
|
+
* @description Real-time Theme Editor for MK-Director.
|
|
10
|
+
* Allows visual modification of CSS variables during development.
|
|
11
|
+
*/
|
|
12
|
+
export function MkThemeEditor() {
|
|
13
|
+
const { theme, updateOverride, resetOverrides, isDark, toggleTheme } = useMkTheme();
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const [isExporting, setIsExporting] = useState(false);
|
|
16
|
+
// Group relevant tokens for editing
|
|
17
|
+
const colorTokens = useMemo(() => {
|
|
18
|
+
const base = isDark ? tokens.dark : tokens.light;
|
|
19
|
+
return Object.entries(base)
|
|
20
|
+
.filter(([_key, val]) => typeof val === 'string' && val.startsWith('#'))
|
|
21
|
+
.map(([key, _]) => key);
|
|
22
|
+
}, [isDark]);
|
|
23
|
+
const uiTokens = ['radius', 'transition', 'cardShadow'];
|
|
24
|
+
const handleCopyJson = () => {
|
|
25
|
+
setIsExporting(true);
|
|
26
|
+
const currentTheme = Object.assign({}, theme);
|
|
27
|
+
void navigator.clipboard.writeText(JSON.stringify(currentTheme, null, 2));
|
|
28
|
+
setTimeout(() => setIsExporting(false), 2000);
|
|
29
|
+
};
|
|
30
|
+
if (!isOpen) {
|
|
31
|
+
return (_jsx("button", { className: styles.minimized, onClick: () => setIsOpen(true), title: "Open Theme Editor", children: "\uD83C\uDFA8" }));
|
|
32
|
+
}
|
|
33
|
+
return (_jsxs("div", { className: styles.container, children: [_jsxs("div", { className: styles.header, children: [_jsx("h4", { className: styles.title, children: "\uD83C\uDFDB\uFE0F MK THEME EDITOR" }), _jsxs("div", { style: { display: 'flex', gap: '4px' }, children: [_jsx("button", { className: styles.controlButton, style: { padding: '4px 8px' }, onClick: toggleTheme, children: isDark ? '☀️' : '🌙' }), _jsx("button", { className: styles.controlButton, style: { padding: '4px 8px' }, onClick: () => setIsOpen(false), children: "\u2715" })] })] }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.section, children: [_jsx("p", { className: styles.sectionTitle, children: "\uD83C\uDF08 Essential Colors" }), colorTokens.map((token) => (_jsxs("div", { className: styles.tokenRow, children: [_jsxs("div", { className: styles.tokenInfo, children: [_jsx("span", { className: styles.tokenLabel, children: token.charAt(0).toUpperCase() + token.slice(1).replace(/[A-Z]/g, ' $&') }), _jsxs("span", { className: styles.tokenValue, children: ["--mk-", token.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase())] })] }), _jsx("input", { type: "color", className: styles.colorInput, value: theme[token], onChange: (e) => updateOverride(token, e.target.value) })] }, token)))] }), _jsxs("div", { className: styles.section, children: [_jsx("p", { className: styles.sectionTitle, children: "\uD83D\uDCD0 UI Shape & Effects" }), uiTokens.map((token) => {
|
|
34
|
+
const val = theme[token];
|
|
35
|
+
const isNumberLike = val && (val.includes('px') || val.includes('rem'));
|
|
36
|
+
return (_jsxs("div", { className: styles.tokenRow, children: [_jsxs("div", { className: styles.tokenInfo, children: [_jsx("span", { className: styles.tokenLabel, children: token.charAt(0).toUpperCase() + token.slice(1) }), _jsx("span", { className: styles.tokenValue, children: val })] }), _jsx("input", { style: {
|
|
37
|
+
width: '80px',
|
|
38
|
+
fontSize: '0.75rem',
|
|
39
|
+
padding: '2px 4px',
|
|
40
|
+
borderRadius: '4px',
|
|
41
|
+
border: '1px solid var(--mk-border)',
|
|
42
|
+
}, type: "text", value: val, onChange: (e) => updateOverride(token, e.target.value) })] }, token));
|
|
43
|
+
})] })] }), _jsxs("div", { className: styles.footer, children: [_jsx("button", { className: styles.controlButton, onClick: resetOverrides, children: "\uD83D\uDD04 Reset" }), _jsx("button", { className: styles.controlButton, onClick: handleCopyJson, children: isExporting ? '✅ Copied!' : '📋 Export JSON' })] })] }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=MkThemeEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkThemeEditor.js","sourceRoot":"","sources":["../../src/components/MkThemeEditor.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;GAIG;AAEH,MAAM,UAAU,aAAa;IACzB,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,CAAC;IACpF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,W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C,CAAC,IACA,IACJ,EAEN,eAAK,SAAS,EAAE,MAAM,CAAC,MAAM,aACzB,iBAAQ,SAAS,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,EAAE,cAAc,mCAEvD,EACT,iBAAQ,SAAS,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,EAAE,cAAc,YAC3D,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,GACxC,IACP,IACJ,CACT,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
--mk-theme-editor-bg: var(--mk-card);
|
|
3
|
+
--mk-theme-editor-border: var(--mk-border);
|
|
4
|
+
--mk-theme-editor-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
|
|
5
|
+
|
|
6
|
+
position: fixed;
|
|
7
|
+
bottom: 1.5rem;
|
|
8
|
+
right: 1.5rem;
|
|
9
|
+
width: 320px;
|
|
10
|
+
max-height: 500px;
|
|
11
|
+
background-color: var(--mk-theme-editor-bg);
|
|
12
|
+
border: 1px solid var(--mk-theme-editor-border);
|
|
13
|
+
border-radius: var(--mk-radius, 12px);
|
|
14
|
+
box-shadow: var(--mk-theme-editor-shadow);
|
|
15
|
+
z-index: 10000;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:global([data-theme='dark']) .container {
|
|
23
|
+
--mk-theme-editor-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@keyframes slideUp {
|
|
27
|
+
from {
|
|
28
|
+
opacity: 0;
|
|
29
|
+
transform: translateY(20px) scale(0.95);
|
|
30
|
+
}
|
|
31
|
+
to {
|
|
32
|
+
opacity: 1;
|
|
33
|
+
transform: translateY(0) scale(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.header {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: space-between;
|
|
41
|
+
padding: 0.85rem 1rem;
|
|
42
|
+
background-color: var(--mk-muted);
|
|
43
|
+
border-bottom: 1px solid var(--mk-theme-editor-border);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.title {
|
|
47
|
+
font-size: 0.875rem;
|
|
48
|
+
font-weight: 700;
|
|
49
|
+
text-transform: uppercase;
|
|
50
|
+
letter-spacing: 0.05em;
|
|
51
|
+
color: var(--mk-foreground);
|
|
52
|
+
margin: 0;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
gap: 0.5rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.content {
|
|
59
|
+
flex: 1;
|
|
60
|
+
overflow-y: auto;
|
|
61
|
+
padding: 1rem;
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
gap: 1.25rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.section {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: 0.75rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sectionTitle {
|
|
74
|
+
font-size: 0.75rem;
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
color: var(--mk-muted-foreground);
|
|
77
|
+
text-transform: uppercase;
|
|
78
|
+
letter-spacing: 0.025em;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.tokenRow {
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: space-between;
|
|
85
|
+
gap: 0.75rem;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.tokenInfo {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
gap: 0.125rem;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.tokenLabel {
|
|
95
|
+
font-size: 0.8125rem;
|
|
96
|
+
font-weight: 500;
|
|
97
|
+
color: var(--mk-foreground);
|
|
98
|
+
font-family: inherit;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.tokenValue {
|
|
102
|
+
font-size: 0.7rem;
|
|
103
|
+
color: var(--mk-muted-foreground);
|
|
104
|
+
font-family: var(--mk-font-mono, monospace);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.colorInput {
|
|
108
|
+
width: 28px;
|
|
109
|
+
height: 28px;
|
|
110
|
+
padding: 0;
|
|
111
|
+
border: 2px solid var(--mk-theme-editor-border);
|
|
112
|
+
border-radius: 4px;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
background: none;
|
|
115
|
+
flex-shrink: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.colorInput::-webkit-color-swatch-wrapper {
|
|
119
|
+
padding: 0;
|
|
120
|
+
}
|
|
121
|
+
.colorInput::-webkit-color-swatch {
|
|
122
|
+
border: none;
|
|
123
|
+
border-radius: 2px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.footer {
|
|
127
|
+
padding: 0.75rem 1rem;
|
|
128
|
+
border-top: 1px solid var(--mk-theme-editor-border);
|
|
129
|
+
display: flex;
|
|
130
|
+
gap: 0.5rem;
|
|
131
|
+
background-color: var(--mk-muted);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.controlButton {
|
|
135
|
+
flex: 1;
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
gap: 0.375rem;
|
|
140
|
+
padding: 0.5rem;
|
|
141
|
+
border-radius: 6px;
|
|
142
|
+
font-size: 0.75rem;
|
|
143
|
+
font-weight: 600;
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
transition: all 0.2s ease;
|
|
146
|
+
border: 1px solid var(--mk-theme-editor-border);
|
|
147
|
+
background-color: var(--mk-background);
|
|
148
|
+
color: var(--mk-foreground);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.controlButton:hover {
|
|
152
|
+
background-color: var(--mk-primary);
|
|
153
|
+
color: var(--mk-primary-foreground);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.minimized {
|
|
157
|
+
position: fixed;
|
|
158
|
+
bottom: 1.5rem;
|
|
159
|
+
right: 1.5rem;
|
|
160
|
+
width: 44px;
|
|
161
|
+
height: 44px;
|
|
162
|
+
border-radius: 50%;
|
|
163
|
+
background-color: var(--mk-primary);
|
|
164
|
+
color: white;
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
justify-content: center;
|
|
168
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
z-index: 10000;
|
|
171
|
+
transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
172
|
+
border: none;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.minimized:hover {
|
|
176
|
+
transform: scale(1.1);
|
|
177
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkToastContainer.d.ts","sourceRoot":"","sources":["../../src/components/MkToastContainer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAexE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EA8BpC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
use;
|
|
3
|
+
client;
|
|
4
|
+
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
import { useMkToast } from '../context/MkToastContext';
|
|
7
|
+
import styles from './MkToastContainer.module.css';
|
|
8
|
+
const POSITION_MAP = {
|
|
9
|
+
'top-left': { top: 16, left: 16 },
|
|
10
|
+
'top-right': { top: 16, right: 16 },
|
|
11
|
+
'bottom-left': { bottom: 16, left: 16 },
|
|
12
|
+
'bottom-right': { bottom: 16, right: 16 },
|
|
13
|
+
'top-center': { top: 16, left: '50%', transform: 'translateX(-50%)' },
|
|
14
|
+
'bottom-center': { bottom: 16, left: '50%', transform: 'translateX(-50%)' },
|
|
15
|
+
};
|
|
16
|
+
export const MkToastContainer = () => {
|
|
17
|
+
const { toasts, dismissToast } = useMkToast();
|
|
18
|
+
const [mounted, setMounted] = useState(false);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setMounted(true);
|
|
21
|
+
return () => setMounted(false);
|
|
22
|
+
}, []);
|
|
23
|
+
if (!mounted)
|
|
24
|
+
return null;
|
|
25
|
+
const groupedToasts = toasts.reduce((acc, toast) => {
|
|
26
|
+
const pos = toast.options.position || 'top-right';
|
|
27
|
+
acc[pos] = acc[pos] || [];
|
|
28
|
+
acc[pos].push(toast);
|
|
29
|
+
return acc;
|
|
30
|
+
}, {});
|
|
31
|
+
return createPortal(_jsx(_Fragment, { children: Object.entries(groupedToasts).map(([pos, list]) => (_jsx("div", { className: styles.container, style: POSITION_MAP[pos], children: (list).map((toast) => (_jsx(ToastItem, { toast: toast, onDismiss: dismissToast }, toast.id))) }, pos))) }), document.body);
|
|
32
|
+
};
|
|
33
|
+
const ToastItem = React.memo(({ toast, onDismiss }) => {
|
|
34
|
+
const [isExiting, setIsExiting] = useState(false);
|
|
35
|
+
const [progress, setProgress] = useState(0);
|
|
36
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
37
|
+
const startTimeRef = useRef(Date.now());
|
|
38
|
+
const remainingTimeRef = useRef(toast.options.timeout || 4000);
|
|
39
|
+
const timerRef = useRef(null);
|
|
40
|
+
const handleClose = useCallback(() => {
|
|
41
|
+
setIsExiting(true);
|
|
42
|
+
setTimeout(() => onDismiss(toast.id), 300);
|
|
43
|
+
}, [toast.id, onDismiss]);
|
|
44
|
+
const startTimer = useCallback(() => {
|
|
45
|
+
if (!toast.options.timeout || toast.options.timeout <= 0)
|
|
46
|
+
return;
|
|
47
|
+
const step = () => {
|
|
48
|
+
const elapsed = Date.now() - startTimeRef.current;
|
|
49
|
+
const newProgress = Math.min((elapsed / (toast.options.timeout || 4000)) * 100, 100);
|
|
50
|
+
setProgress(newProgress);
|
|
51
|
+
if (newProgress < 100) {
|
|
52
|
+
timerRef.current = window.requestAnimationFrame(step);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
handleClose();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
timerRef.current = window.requestAnimationFrame(step);
|
|
59
|
+
}, [toast.options.timeout, handleClose]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!isHovered) {
|
|
62
|
+
startTimeRef.current = Date.now() - (progress / 100) * (toast.options.timeout || 4000);
|
|
63
|
+
startTimer();
|
|
64
|
+
}
|
|
65
|
+
return () => {
|
|
66
|
+
if (timerRef.current)
|
|
67
|
+
window.cancelAnimationFrame(timerRef.current);
|
|
68
|
+
};
|
|
69
|
+
}, [isHovered, startTimer, progress, toast.options.timeout]);
|
|
70
|
+
return (_jsxs("div", { className: `${styles.toast} ${styles[toast.options.animation || 'slide']} ${isExiting ? styles.exiting : ''}`, style: Object.assign({ borderLeft: `4px solid var(--mk-${toast.options.type === 'default' ? 'primary' : toast.options.type})` }, toast.options.customStyles), onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: [_jsxs("div", { className: styles.content, children: [_jsx("div", { className: styles.icon, children: getIcon(toast.options.type) }), _jsx("div", { className: styles.text, children: toast.content }), _jsx("button", { className: styles.close, onClick: handleClose, children: "\u00D7" })] }), toast.options.timeout && (_jsx("div", { className: styles.progress, style: { width: `${100 - progress}%`, backgroundColor: `var(--mk-${toast.options.type === 'default' ? 'primary' : toast.options.type})` } }))] }));
|
|
71
|
+
});
|
|
72
|
+
function getIcon(type) {
|
|
73
|
+
switch (type) {
|
|
74
|
+
case 'success': return '✅';
|
|
75
|
+
case 'error': return '❌';
|
|
76
|
+
case 'warning': return '⚠️';
|
|
77
|
+
case 'info': return 'ℹ️';
|
|
78
|
+
default: return '🔔';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=MkToastContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkToastContainer.js","sourceRoot":"","sources":["../../src/components/MkToastContainer.tsx"],"names":[],"mappings":";AAAA,GAAG,CAAA;AAAC,MAAM,CAAA;AACV,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAGnD,MAAM,YAAY,GAAwC;IACtD,UAAU,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IACjC,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IACnC,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IACvC,cAAc,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IACzC,YAAY,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE;IACrE,eAAe,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE;CAC9E,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC3C,MAA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|
3
|
+
z-index: 9999;
|
|
4
|
+
padding: 1rem;
|
|
5
|
+
pointer-events: none;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: 0.75rem;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.toast {
|
|
12
|
+
--mk-toast-bg: var(--mk-popover);
|
|
13
|
+
--mk-toast-fg: var(--mk-popover-foreground);
|
|
14
|
+
--mk-toast-border: var(--mk-border);
|
|
15
|
+
--mk-toast-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
16
|
+
--mk-toast-color: var(--mk-foreground);
|
|
17
|
+
--mk-toast-radius: var(--mk-radius, 8px);
|
|
18
|
+
|
|
19
|
+
background-color: var(--mk-toast-bg);
|
|
20
|
+
color: var(--mk-toast-fg);
|
|
21
|
+
border: 1px solid var(--mk-toast-border);
|
|
22
|
+
border-radius: var(--mk-toast-radius);
|
|
23
|
+
padding: 0.85rem 1rem;
|
|
24
|
+
min-width: 280px;
|
|
25
|
+
max-width: 420px;
|
|
26
|
+
box-shadow: var(--mk-toast-shadow);
|
|
27
|
+
pointer-events: auto;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
position: relative;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
animation: mk-fade-in 0.3s var(--mk-ease-out) backwards;
|
|
33
|
+
transition: all 0.3s var(--mk-ease-out);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:global([data-theme='dark']) .toast {
|
|
37
|
+
--mk-toast-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.toast.exiting {
|
|
41
|
+
opacity: 0;
|
|
42
|
+
transform: scale(0.95);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.content {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: 0.75rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.icon {
|
|
52
|
+
font-size: 1.2rem;
|
|
53
|
+
flex-shrink: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.text {
|
|
57
|
+
flex-grow: 1;
|
|
58
|
+
font-size: 0.95rem;
|
|
59
|
+
font-weight: 500;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.close {
|
|
63
|
+
background: none;
|
|
64
|
+
border: none;
|
|
65
|
+
font-size: 1.5rem;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
color: var(--mk-muted-foreground);
|
|
68
|
+
line-height: 1;
|
|
69
|
+
padding: 0;
|
|
70
|
+
transition: color 0.15s ease;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.close:hover {
|
|
74
|
+
color: var(--mk-foreground);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.progress {
|
|
78
|
+
position: absolute;
|
|
79
|
+
bottom: 0;
|
|
80
|
+
left: 0;
|
|
81
|
+
height: 3px;
|
|
82
|
+
opacity: 0.5;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Animations */
|
|
86
|
+
@keyframes slideIn {
|
|
87
|
+
from {
|
|
88
|
+
opacity: 0;
|
|
89
|
+
transform: translateY(10px) scale(0.95);
|
|
90
|
+
}
|
|
91
|
+
to {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
transform: translateY(0) scale(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @module MkTooltip
|
|
4
|
+
* @description Hover/focus tooltip for web. Shows contextual info on hover.
|
|
5
|
+
*/
|
|
6
|
+
export interface MkTooltipProps {
|
|
7
|
+
content: string | React.ReactNode;
|
|
8
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
9
|
+
delay?: number;
|
|
10
|
+
children: React.ReactElement;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const MkTooltip: React.FC<MkTooltipProps>;
|
|
14
|
+
//# sourceMappingURL=MkTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkTooltip.d.ts","sourceRoot":"","sources":["../../src/components/MkTooltip.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAGhD;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoC9C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
use;
|
|
3
|
+
client;
|
|
4
|
+
import { useState, useRef } from 'react';
|
|
5
|
+
import styles from './MkTooltip.module.css';
|
|
6
|
+
export const MkTooltip = ({ content, position = 'top', delay = 200, children, className, }) => {
|
|
7
|
+
const [visible, setVisible] = useState(false);
|
|
8
|
+
const timerRef = useRef(null);
|
|
9
|
+
const show = () => {
|
|
10
|
+
timerRef.current = setTimeout(() => setVisible(true), delay);
|
|
11
|
+
};
|
|
12
|
+
const hide = () => {
|
|
13
|
+
if (timerRef.current)
|
|
14
|
+
clearTimeout(timerRef.current);
|
|
15
|
+
setVisible(false);
|
|
16
|
+
};
|
|
17
|
+
return (_jsxs("div", { className: `${styles.wrapper} ${className || ''}`, onMouseEnter: show, onMouseLeave: hide, onFocus: show, onBlur: hide, children: [children, visible && (_jsxs("div", { className: `${styles.tooltip} ${styles[position]}`, role: "tooltip", children: [content, _jsx("div", { className: `${styles.arrow} ${styles[`arrow-${position}`]}` })] }))] }));
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=MkTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkTooltip.js","sourceRoot":"","sources":["../../src/components/MkTooltip.tsx"],"names":[],"mappings":";AAAA,GAAG,CAAA;AAAC,MAAM,CAAA;AACV,OAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAe5C,MAAM,CAAC,MAAM,SAAS,GAA6B,CAAC,EAChD,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,GAAG,EACX,QAAQ,EACR,SAAS,GACZ,EAAE,EAAE;IACD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;IAEpE,MAAM,IAAI,GAAG,GAAG,EAAE;QACd,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,GAAG,EAAE;QACd,IAAI,QAAQ,CAAC,OAAO;YAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrD,UAAU,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,CACH,eACI,SAAS,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,SAAS,IAAI,EAAE,EAAE,EACjD,YAAY,EAAE,IAAI,EAClB,YAAY,EAAE,IAAI,EAClB,OAAO,EAAE,IAAI,EACb,MAAM,EAAE,IAAI,aAEX,QAAQ,EACR,OAAO,IAAI,CACR,eAAK,SAAS,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAC,SAAS,aAClE,OAAO,EACR,cAAK,SAAS,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,QAAQ,EAAE,CAAC,EAAE,GAAI,IAClE,CACT,IACC,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.wrapper { position: relative; display: inline-flex; }
|
|
2
|
+
|
|
3
|
+
.tooltip {
|
|
4
|
+
--mk-tooltip-bg: var(--mk-foreground);
|
|
5
|
+
--mk-tooltip-color: var(--mk-background);
|
|
6
|
+
--mk-tooltip-radius: 6px;
|
|
7
|
+
--mk-tooltip-shadow: 0 4px 12px rgba(0,0,0,0.12);
|
|
8
|
+
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: 100;
|
|
11
|
+
padding: 0.5rem 0.75rem;
|
|
12
|
+
background-color: var(--mk-tooltip-bg);
|
|
13
|
+
color: var(--mk-tooltip-color);
|
|
14
|
+
font-size: 0.8125rem;
|
|
15
|
+
border-radius: var(--mk-tooltip-radius);
|
|
16
|
+
white-space: nowrap;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
animation: mk-fade-in 0.1s ease;
|
|
19
|
+
box-shadow: var(--mk-tooltip-shadow);
|
|
20
|
+
line-height: 1.4;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:global([data-theme='dark']) .tooltip {
|
|
24
|
+
--mk-tooltip-shadow: 0 4px 12px rgba(0,0,0,0.4);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.top { bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
|
|
28
|
+
.bottom { top: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
|
|
29
|
+
.left { right: calc(100% + 8px); top: 50%; transform: translateY(-50%); }
|
|
30
|
+
.right { left: calc(100% + 8px); top: 50%; transform: translateY(-50%); }
|
|
31
|
+
|
|
32
|
+
.arrow {
|
|
33
|
+
position: absolute;
|
|
34
|
+
width: 8px;
|
|
35
|
+
height: 8px;
|
|
36
|
+
background: inherit;
|
|
37
|
+
transform: rotate(45deg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.arrowTop { bottom: -4px; left: 50%; margin-left: -4px; }
|
|
41
|
+
.arrowBottom { top: -4px; left: 50%; margin-left: -4px; }
|
|
42
|
+
.arrowLeft { right: -4px; top: 50%; margin-top: -4px; }
|
|
43
|
+
.arrowRight { left: -4px; top: 50%; margin-top: -4px; }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MkWindowListProps<T> {
|
|
3
|
+
items: T[];
|
|
4
|
+
renderItem: (item: T, index: number) => React.ReactNode;
|
|
5
|
+
itemHeight: number;
|
|
6
|
+
containerHeight?: number | string;
|
|
7
|
+
overscan?: number;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
hasMore?: boolean;
|
|
10
|
+
onLoadMore?: () => void;
|
|
11
|
+
emptyMessage?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* MkWindowList (Web)
|
|
16
|
+
* 🚀 High-performance Virtualized List.
|
|
17
|
+
* Renders only the visible portion of a massive list to keep the DOM light.
|
|
18
|
+
*/
|
|
19
|
+
export declare function MkWindowList<T>({ items, renderItem, itemHeight, containerHeight, overscan, loading, hasMore, onLoadMore, emptyMessage, className }: MkWindowListProps<T>): React.JSX.Element;
|
|
20
|
+
//# sourceMappingURL=MkWindowList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkWindowList.d.ts","sourceRoot":"","sources":["../../src/components/MkWindowList.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC5B,KAAK,EACL,UAAU,EACV,UAAU,EACV,eAAyB,EACzB,QAAY,EACZ,OAAO,EACP,OAAO,EACP,UAAU,EACV,YAAyC,EACzC,SAAc,EACjB,EAAE,iBAAiB,CAAC,CAAC,CAAC,qBAoGtB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
use;
|
|
3
|
+
client;
|
|
4
|
+
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
5
|
+
import styles from './MkWindowList.module.css';
|
|
6
|
+
/**
|
|
7
|
+
* MkWindowList (Web)
|
|
8
|
+
* 🚀 High-performance Virtualized List.
|
|
9
|
+
* Renders only the visible portion of a massive list to keep the DOM light.
|
|
10
|
+
*/
|
|
11
|
+
export function MkWindowList({ items, renderItem, itemHeight, containerHeight = '500px', overscan = 5, loading, hasMore, onLoadMore, emptyMessage = "No se encontraron datos.", className = "" }) {
|
|
12
|
+
const containerRef = useRef(null);
|
|
13
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
14
|
+
const [viewportHeight, setViewportHeight] = useState(0);
|
|
15
|
+
// Initial and resize height tracking
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (containerRef.current) {
|
|
18
|
+
setViewportHeight(containerRef.current.clientHeight);
|
|
19
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
setViewportHeight(entry.contentRect.height);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
resizeObserver.observe(containerRef.current);
|
|
25
|
+
return () => resizeObserver.disconnect();
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
const onScroll = (e) => {
|
|
29
|
+
const target = e.currentTarget;
|
|
30
|
+
setScrollTop(target.scrollTop);
|
|
31
|
+
// Check if we reached the bottom for infinite loading
|
|
32
|
+
if (onLoadMore && hasMore && !loading) {
|
|
33
|
+
const isBottom = target.scrollHeight - target.scrollTop <= target.clientHeight * 1.5;
|
|
34
|
+
if (isBottom) {
|
|
35
|
+
onLoadMore();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// Calculate window range
|
|
40
|
+
const { startIndex, endIndex, totalHeight } = useMemo(() => {
|
|
41
|
+
const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
|
|
42
|
+
const end = Math.min(items.length, Math.ceil((scrollTop + viewportHeight) / itemHeight) + overscan);
|
|
43
|
+
return {
|
|
44
|
+
startIndex: start,
|
|
45
|
+
endIndex: end,
|
|
46
|
+
totalHeight: items.length * itemHeight
|
|
47
|
+
};
|
|
48
|
+
}, [scrollTop, viewportHeight, items.length, itemHeight, overscan]);
|
|
49
|
+
// Slice data to render
|
|
50
|
+
const visibleItems = useMemo(() => {
|
|
51
|
+
return items.slice(startIndex, endIndex).map((item, index) => {
|
|
52
|
+
const absoluteIndex = startIndex + index;
|
|
53
|
+
return (_jsx("div", { className: styles.itemWrapper, style: {
|
|
54
|
+
height: itemHeight,
|
|
55
|
+
transform: `translateY(${absoluteIndex * itemHeight}px)`
|
|
56
|
+
}, children: renderItem(item, absoluteIndex) }, absoluteIndex));
|
|
57
|
+
});
|
|
58
|
+
}, [items, startIndex, endIndex, itemHeight, renderItem]);
|
|
59
|
+
return (_jsxs("div", { ref: containerRef, className: `${styles.container} ${className}`, onScroll: onScroll, style: { height: containerHeight }, children: [items.length > 0 ? (_jsxs("div", { className: styles.scrollArea, style: { height: totalHeight }, children: [visibleItems, loading && (_jsx("div", { className: styles.loader, style: { transform: `translateY(${items.length * itemHeight}px)` }, children: "Cargando m\u00E1s..." }))] })) : (!loading && (_jsx("div", { className: styles.empty, children: emptyMessage }))), loading && items.length === 0 && (_jsx("div", { className: styles.initialLoader, children: "Cargando..." }))] }));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=MkWindowList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MkWindowList.js","sourceRoot":"","sources":["../../src/components/MkWindowList.tsx"],"names":[],"mappings":";AAAA,GAAG,CAAA;AAAC,MAAM,CAAA;AACV,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAe,OAAO,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAe/C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAI,EAC5B,KAAK,EACL,UAAU,EACV,UAAU,EACV,eAAe,GAAG,OAAO,EACzB,QAAQ,GAAG,CAAC,EACZ,OAAO,EACP,OAAO,EACP,UAAU,EACV,YAAY,GAAG,0BAA0B,EACzC,SAAS,GAAG,EAAE,EACK;IACnB,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExD,qCAAqC;IACrC,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,iBAAiB,CAAC,YAAY,CAAC,OA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