@farm-investimentos/front-mfe-components-vue3 0.0.1 → 0.0.2
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/front-mfe-components.common.js +28 -28
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.umd.js +28 -28
- package/dist/front-mfe-components.umd.js.map +1 -1
- package/dist/front-mfe-components.umd.min.js +1 -1
- package/dist/front-mfe-components.umd.min.js.map +1 -1
- package/package.json +3 -3
- package/src/components/DialogPrompt/index.ts +77 -0
- package/src/components/DialogPrompt/utils/bootstrap.ts +20 -0
- package/src/components/DialogPrompt/utils/index.ts +5 -0
- package/src/components/DialogPrompt/utils/modalFooter.ts +41 -0
- package/src/components/DialogPrompt/utils/modalHeader.ts +21 -0
- package/src/examples/Colors.stories.js +4 -4
- package/src/examples/{VuetifyDialog.stories.js → Dialog.stories.js} +2 -3
- package/src/scss/VuejsDialog.scss +6 -1
- /package/src/configurations/{_theme-colors-background.scss → _theme-colors-background.module.scss} +0 -0
- /package/src/configurations/{_theme-colors-stroke.scss → _theme-colors-stroke.module.scss} +0 -0
- /package/src/configurations/{_theme-colors-text.scss → _theme-colors-text.module.scss} +0 -0
- /package/src/configurations/{_theme-colors-variations.scss → _theme-colors-variations.module.scss} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm-investimentos/front-mfe-components-vue3",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"author": "farm investimentos",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/front-mfe-components.common.js",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"husky": "^8.0.0",
|
|
64
64
|
"jest": "^29.0.0",
|
|
65
65
|
"jest-environment-jsdom": "^29.0.0",
|
|
66
|
+
"promise-polyfill": "^8.3.0",
|
|
66
67
|
"sass": "~1.32.0",
|
|
67
68
|
"sass-loader": "^10.0.0",
|
|
68
69
|
"storybook": "^7.0.6",
|
|
@@ -70,8 +71,7 @@
|
|
|
70
71
|
"ts-jest": "^29.0.0",
|
|
71
72
|
"typescript": "~4.1.5",
|
|
72
73
|
"v-mask": "^2.3.0",
|
|
73
|
-
"vue-loader": "^16.8.3"
|
|
74
|
-
"vuejs-dialog": "^1.4.2"
|
|
74
|
+
"vue-loader": "^16.8.3"
|
|
75
75
|
},
|
|
76
76
|
"browserslist": [
|
|
77
77
|
"> 1%",
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import Icon from '../Icon';
|
|
2
|
+
import { bootstrap, modalFooter, modalHeader } from './utils';
|
|
3
|
+
|
|
4
|
+
export interface IDialogPromptOptions {
|
|
5
|
+
title: string;
|
|
6
|
+
body: string;
|
|
7
|
+
alert: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IDialogPromptConfiguration {
|
|
11
|
+
html?: boolean;
|
|
12
|
+
okText?: string;
|
|
13
|
+
cancelText?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const dialog = {
|
|
17
|
+
container: null,
|
|
18
|
+
confirm: (options: IDialogPromptOptions, configuration: IDialogPromptConfiguration) => {
|
|
19
|
+
const { container, modal } = bootstrap();
|
|
20
|
+
dialog.container = container;
|
|
21
|
+
|
|
22
|
+
modalHeader(modal, options, () => {
|
|
23
|
+
dialog.destroy();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const content = document.createElement('div');
|
|
27
|
+
content.className = 'farm-modal--content';
|
|
28
|
+
content.innerHTML = `<div style="margin-top: 64px; margin-bottom: 84px; max-height: calc(100vh - 164px);">
|
|
29
|
+
<div style="font-size: 12px;
|
|
30
|
+
line-height: 20px;
|
|
31
|
+
word-break: break-word;">
|
|
32
|
+
${options.body}
|
|
33
|
+
</div>
|
|
34
|
+
</div>`;
|
|
35
|
+
modal.appendChild(content);
|
|
36
|
+
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
modalFooter(
|
|
39
|
+
modal,
|
|
40
|
+
options,
|
|
41
|
+
configuration,
|
|
42
|
+
() => {
|
|
43
|
+
resolve(true);
|
|
44
|
+
dialog.destroy();
|
|
45
|
+
},
|
|
46
|
+
() => {
|
|
47
|
+
reject(true);
|
|
48
|
+
dialog.destroy();
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
// alert(2);
|
|
52
|
+
/*
|
|
53
|
+
okButton.onclick = () => {
|
|
54
|
+
alert(2);
|
|
55
|
+
resolve(true);
|
|
56
|
+
dialog.destroy();
|
|
57
|
+
};
|
|
58
|
+
*/
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
alert: (options: IDialogPromptOptions, configuration: IDialogPromptConfiguration) => {
|
|
63
|
+
return dialog.confirm({ ...options, alert: true }, configuration);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
destroy: () => {
|
|
67
|
+
if (dialog.container) document.body.removeChild(dialog.container);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
install: app => {
|
|
73
|
+
// app.component('DialogPrompt', DialogPrompt);
|
|
74
|
+
app.config.globalProperties.$dialog = dialog;
|
|
75
|
+
app.provide('$dialog', dialog);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default function (): { container: HTMLElement; backdrop: HTMLElement; modal: HTMLElement } {
|
|
2
|
+
const container = document.createElement('div');
|
|
3
|
+
container.className = 'farm-modal';
|
|
4
|
+
|
|
5
|
+
const backdrop = document.createElement('div');
|
|
6
|
+
backdrop.className = 'farm-modal--overlay';
|
|
7
|
+
|
|
8
|
+
const modal = document.createElement('div');
|
|
9
|
+
modal.className = 'farm-modal--container';
|
|
10
|
+
|
|
11
|
+
modal.style.width = '98%';
|
|
12
|
+
modal.style.maxWidth = '400px';
|
|
13
|
+
|
|
14
|
+
container.appendChild(modal);
|
|
15
|
+
container.appendChild(backdrop);
|
|
16
|
+
|
|
17
|
+
document.body.appendChild(container);
|
|
18
|
+
|
|
19
|
+
return { container, backdrop, modal };
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IDialogPromptConfiguration, IDialogPromptOptions } from '..';
|
|
2
|
+
|
|
3
|
+
export default function (
|
|
4
|
+
modal: HTMLElement,
|
|
5
|
+
options: IDialogPromptOptions,
|
|
6
|
+
configuration: IDialogPromptConfiguration,
|
|
7
|
+
callbackConfirm: Function,
|
|
8
|
+
callbackCancel: Function
|
|
9
|
+
) {
|
|
10
|
+
const footer = document.createElement('footer');
|
|
11
|
+
footer.className = 'farm-modal--footer';
|
|
12
|
+
footer.innerHTML = `<div class="farm-dialog__footer">
|
|
13
|
+
${
|
|
14
|
+
configuration.cancelText
|
|
15
|
+
? `<button type="button" size="default" class="farm-btn farm-btn--primary farm-btn--variation-base farm-btn--plain farm-btn__cancel">
|
|
16
|
+
<span class="farm-btn__content">
|
|
17
|
+
${configuration.cancelText || 'Confirmar'}
|
|
18
|
+
</span>
|
|
19
|
+
</button> `
|
|
20
|
+
: ''
|
|
21
|
+
}
|
|
22
|
+
<button type="button" size="default" title="Confirmar" class="farm-btn farm-btn--${
|
|
23
|
+
options.alert ? 'error' : 'primary'
|
|
24
|
+
} farm-btn--variation-base farm-btn__confirm">
|
|
25
|
+
<span class="farm-btn__content">
|
|
26
|
+
${configuration.okText || 'Confirmar'}
|
|
27
|
+
</span>
|
|
28
|
+
</button>
|
|
29
|
+
</div>`;
|
|
30
|
+
modal.appendChild(footer);
|
|
31
|
+
|
|
32
|
+
const okButton = footer.querySelector('.farm-btn__confirm');
|
|
33
|
+
okButton.addEventListener('click', callbackConfirm as EventListenerOrEventListenerObject);
|
|
34
|
+
|
|
35
|
+
const cancelButton = footer.querySelector('.farm-btn__cancel');
|
|
36
|
+
if (cancelButton)
|
|
37
|
+
cancelButton.addEventListener(
|
|
38
|
+
'click',
|
|
39
|
+
callbackCancel as EventListenerOrEventListenerObject
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IDialogPromptOptions } from '..';
|
|
2
|
+
|
|
3
|
+
export default function (modal: HTMLElement, options: IDialogPromptOptions, callback: Function) {
|
|
4
|
+
const style = options.alert ? 'color: var(--farm-error-base)!important' : '';
|
|
5
|
+
const header = document.createElement('div');
|
|
6
|
+
header.className = 'farm-modal--header';
|
|
7
|
+
header.innerHTML = `<header>
|
|
8
|
+
<p class="farm-typography farm-typography--sm farm-typography--weight-600 farm-caption farm-caption--semiBold" style="${style}">
|
|
9
|
+
${options.title}
|
|
10
|
+
</p>
|
|
11
|
+
<button type="button" size="default" title="Fechar" class="farm-dialog-header__close farm-btn farm-btn--round farm-btn--icon farm-btn--primary farm-btn--variation-base">
|
|
12
|
+
<span class="farm-btn__content">
|
|
13
|
+
<i size="24px" role="button" class="farm-icon farm-icon--primary mdi mdi-window-close" style="font-size: 24px;"></i>
|
|
14
|
+
</span>
|
|
15
|
+
</button>
|
|
16
|
+
</header>`;
|
|
17
|
+
modal.appendChild(header);
|
|
18
|
+
|
|
19
|
+
const closeButton = header.querySelector('.farm-dialog-header__close');
|
|
20
|
+
closeButton.addEventListener('click', callback as EventListenerOrEventListenerObject);
|
|
21
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import baseThemeColors from '../configurations/_theme-colors-base.module.scss';
|
|
2
|
-
import textThemeColors from '../configurations/_theme-colors-text.scss';
|
|
3
|
-
import strokeThemeColors from '../configurations/_theme-colors-stroke.scss';
|
|
2
|
+
import textThemeColors from '../configurations/_theme-colors-text.module.scss';
|
|
3
|
+
import strokeThemeColors from '../configurations/_theme-colors-stroke.module.scss';
|
|
4
4
|
import bwThemeColors from '../configurations/_theme-colors-bw.module.scss';
|
|
5
|
-
import backgroundThemeColors from '../configurations/_theme-colors-background.scss';
|
|
6
|
-
import variationThemeColors from '../configurations/_theme-colors-variations.scss';
|
|
5
|
+
import backgroundThemeColors from '../configurations/_theme-colors-background.module.scss';
|
|
6
|
+
import variationThemeColors from '../configurations/_theme-colors-variations.module.scss';
|
|
7
7
|
import('./Colors.stories.scss');
|
|
8
8
|
|
|
9
9
|
export default {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// import { withDesign } from 'storybook-addon-designs';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
title: 'Display/Dialog/
|
|
4
|
+
title: 'Display/Dialog/Prompt',
|
|
5
5
|
// decorators: [withDesign],
|
|
6
6
|
parameters: {
|
|
7
7
|
viewMode: 'docs',
|
|
@@ -55,7 +55,6 @@ export const ErrorColor = () => ({
|
|
|
55
55
|
{
|
|
56
56
|
html: true,
|
|
57
57
|
okText: 'OK',
|
|
58
|
-
customClass: 'dg-parent-error',
|
|
59
58
|
}
|
|
60
59
|
)
|
|
61
60
|
.then(() => {
|
|
@@ -126,4 +125,4 @@ export const CustomHtml = () => ({
|
|
|
126
125
|
Open
|
|
127
126
|
</farm-btn>
|
|
128
127
|
</div>`,
|
|
129
|
-
});
|
|
128
|
+
});
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
@import '
|
|
1
|
+
@import '../components/Modal/Modal.scss';
|
|
2
|
+
@import '../components/DialogHeader/DialogHeader.scss';
|
|
3
|
+
@import '../components/DialogFooter/DialogFooter.scss';
|
|
4
|
+
@import '../components/Typography/Typography.scss';
|
|
2
5
|
@import '../components/Buttons/DefaultButton/DefaultButton.scss';
|
|
3
6
|
|
|
7
|
+
/*
|
|
4
8
|
.dg-main-content {
|
|
5
9
|
font-family: 'Manrope', sans-serif !important;
|
|
6
10
|
}
|
|
@@ -91,3 +95,4 @@
|
|
|
91
95
|
color: var(--farm-error-base);
|
|
92
96
|
}
|
|
93
97
|
}
|
|
98
|
+
*/
|
/package/src/configurations/{_theme-colors-background.scss → _theme-colors-background.module.scss}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/configurations/{_theme-colors-variations.scss → _theme-colors-variations.module.scss}
RENAMED
|
File without changes
|