v-sistec-features 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.
- package/dist/core.js +2085 -0
- package/dist/iframeCommunicator.js +5 -0
- package/dist/index.js +8 -0
- package/dist/useThemeFromParent-CYvPb79h.js +29 -0
- package/dist/v-sistec-features.css +11 -0
- package/dist/vite.svg +1 -0
- package/package.json +59 -0
- package/src/core/index.ts +3 -0
- package/src/core/plugin.ts +39 -0
- package/src/iframeCommunicator/index.ts +4 -0
- package/src/iframeCommunicator/useIframeCommunicator.ts +39 -0
- package/src/iframeCommunicator/useThemeFromParent.ts +32 -0
- package/src/index.ts +8 -0
- package/src/types/global.d.ts +1 -0
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "v-sistec-features",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "Márlon Bento Azevedo (https://github.com/marlon-bento)",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/marlon-bento/v-sistec-features"
|
|
9
|
+
},
|
|
10
|
+
"description": "Componentes, composables, styles e ferramentas para o Sistec",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./core": {
|
|
19
|
+
"import": "./dist/core.js",
|
|
20
|
+
"types": "./dist/core.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./iframeCommunicator": {
|
|
23
|
+
"import": "./dist/iframeCommunicator.js",
|
|
24
|
+
"types": "./dist/iframeCommunicator.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./style.css": {
|
|
27
|
+
"import": "./dist/v-sistec-features.css",
|
|
28
|
+
"require": "./dist/v-sistec-features.css"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "vite build && tsc"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@tabler/icons-vue": "^3.35.0",
|
|
40
|
+
"vue": "^3.2.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
44
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
45
|
+
"@semantic-release/exec": "^7.1.0",
|
|
46
|
+
"@semantic-release/git": "^10.0.1",
|
|
47
|
+
"@semantic-release/github": "^11.0.6",
|
|
48
|
+
"@semantic-release/npm": "^12.0.2",
|
|
49
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
50
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
51
|
+
"semantic-release": "^24.2.9",
|
|
52
|
+
"typescript": "~5.8.3",
|
|
53
|
+
"vite": "^7.1.7",
|
|
54
|
+
"vue": "^3.4.31"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@tabler/core": "^1.4.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
/*esse é o plugin que vai configurar as partes excenciais de todas as aplicações
|
|
3
|
+
* do sistec
|
|
4
|
+
*
|
|
5
|
+
* Observações:
|
|
6
|
+
* import de tabler-themes deve ser feito depois do tabler.min.css ou não funcionará
|
|
7
|
+
*
|
|
8
|
+
* até o momento as funções são
|
|
9
|
+
* - importar o css e js do tabler
|
|
10
|
+
* - disponibilizar o tabler globalmente como window.bootstrap
|
|
11
|
+
* (as novas versões do tabler não incluem mais o bootstrap, então isso foi necessário)
|
|
12
|
+
*
|
|
13
|
+
* - futuras funções podem ser adicionadas aqui
|
|
14
|
+
* - como adicionar componentes globais
|
|
15
|
+
* - adicionar diretivas globais
|
|
16
|
+
* - adicionar filtros globais
|
|
17
|
+
* - adicionar mixins globais
|
|
18
|
+
* - adicionar propriedades globais
|
|
19
|
+
*
|
|
20
|
+
* para usar o plugin, basta fazer app.use(SistecPlugin) na aplicação vue
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// Configurações do Tabler
|
|
24
|
+
import '@tabler/core/dist/css/tabler.min.css';
|
|
25
|
+
import '@tabler/core/dist/css/tabler-themes.min.css'
|
|
26
|
+
import * as Tabler from '@tabler/core/dist/js/tabler.min.js';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const SistecPlugin = {
|
|
30
|
+
// até o momento não usamos opções nem o app, mas deixei aqui caso precise no futuro
|
|
31
|
+
install: (_app: App, _options?: any) => {
|
|
32
|
+
// Disponibiliza o Tabler globalmente
|
|
33
|
+
(window as any).bootstrap = Tabler;
|
|
34
|
+
|
|
35
|
+
// futuros upgrades podem ser feitos aqui
|
|
36
|
+
// Ex: app.component('MeuComponente', MeuComponente);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export { SistecPlugin };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, readonly, ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Um Composable para gerenciar a comunicação entre um iframe e sua janela pai.
|
|
5
|
+
* @param onMessageReceived - Uma função de callback que será executada quando uma mensagem for recebida do pai.
|
|
6
|
+
*/
|
|
7
|
+
export function useIframeCommunicator(onMessageReceived: (event: MessageEvent) => void) {
|
|
8
|
+
|
|
9
|
+
// Uma ref reativa para saber se o app está rodando dentro de um iframe
|
|
10
|
+
const isInIframe = ref(window.parent !== window);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Envia uma mensagem para a janela pai.
|
|
14
|
+
* @param message - O objeto da mensagem a ser enviado.
|
|
15
|
+
* @param targetOrigin - A origem do pai, para segurança. Padrão é '*'.
|
|
16
|
+
*/
|
|
17
|
+
function sendMessage(message: any, targetOrigin: string = '*') {
|
|
18
|
+
if (isInIframe.value) {
|
|
19
|
+
window.parent.postMessage(message, targetOrigin);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Configura o ouvinte de eventos quando o componente é montado
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
window.addEventListener('message', onMessageReceived);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Remove o ouvinte de eventos quando o componente é desmontado
|
|
29
|
+
onUnmounted(() => {
|
|
30
|
+
window.removeEventListener('message', onMessageReceived);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Retorna os valores e funções que o componente poderá usar
|
|
34
|
+
return {
|
|
35
|
+
isInIframe: readonly(isInIframe), // readonly para evitar modificação externa
|
|
36
|
+
sendMessage
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useIframeCommunicator } from './useIframeCommunicator';
|
|
2
|
+
import { onMounted } from 'vue';
|
|
3
|
+
|
|
4
|
+
function handleThemeMessage(event: MessageEvent) {
|
|
5
|
+
if (event.data.type === 'setTheme') {
|
|
6
|
+
document.documentElement.setAttribute('data-bs-theme', event.data.theme);
|
|
7
|
+
}
|
|
8
|
+
if (event.data.type === 'setThemePrimary') {
|
|
9
|
+
document.documentElement.setAttribute('data-bs-theme-primary', event.data.themePrimary);
|
|
10
|
+
}
|
|
11
|
+
if (event.data.type === 'setThemeBase') {
|
|
12
|
+
document.documentElement.setAttribute('data-bs-theme-base', event.data.themeBase);
|
|
13
|
+
}
|
|
14
|
+
if (event.data.type === 'reload') {
|
|
15
|
+
location.reload();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Um composable "tudo-em-um" que configura a comunicação de temas com a janela pai.
|
|
21
|
+
* para usar, bastar importar e chamar useTheme() na raiz do component app do iframe
|
|
22
|
+
*/
|
|
23
|
+
export function useTheme() {
|
|
24
|
+
// Usa o composable genérico, passando o handler de temas, assim ele já configura
|
|
25
|
+
// o listener e o que é feito quando receber uma mensagem do pai referente a tema
|
|
26
|
+
const { sendMessage } = useIframeCommunicator(handleThemeMessage);
|
|
27
|
+
|
|
28
|
+
// passa uma mensagem para o pai avisando que o iframe está pronto para receber temas
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
sendMessage({ type: 'iframeReady' });
|
|
31
|
+
});
|
|
32
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Re-exporta o plugin que está no módulo 'core'
|
|
2
|
+
export * from './core';
|
|
3
|
+
|
|
4
|
+
// Re-exporta tudo que está no módulo 'iframeCommunicator'
|
|
5
|
+
export * from './iframeCommunicator';
|
|
6
|
+
|
|
7
|
+
// Re-exporta tudo do Tabler Icons Vue para facilitar o uso
|
|
8
|
+
export * from '@tabler/icons-vue';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '@tabler/core/dist/js/tabler.min.js';
|