@farm-investimentos/front-mfe-components-vue3 0.0.5 → 0.0.7
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/README.md +9 -3
- package/dist/front-mfe-components.common.js +4968 -4948
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +1 -1
- package/dist/front-mfe-components.umd.js +4968 -4948
- 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 +19 -16
- package/src/components/AlertBox/AlertBox.vue +3 -2
- package/src/components/AlertBox/__tests__/AlertBox.spec.js +2 -1
- package/src/components/AlertBox/__tests__/valueWatcher.spec.js +1 -0
- package/src/components/AlertReload/__tests__/AlertReload.spec.js +1 -0
- package/src/components/ButtonToggle/ButtonToggle.vue +4 -3
- package/src/components/ButtonToggle/__tests__/ButtonToggle.spec.js +2 -1
- package/src/components/Buttons/ConfirmButton/__tests__/ConfirmButton.spec.js +1 -0
- package/src/components/Buttons/DangerButton/__tests__/DangerButton.spec.js +1 -0
- package/src/components/Buttons/DefaultButton/DefaultButton.scss +10 -9
- package/src/components/Buttons/DefaultButton/DefaultButton.stories.js +3 -1
- package/src/components/Buttons/DefaultButton/DefaultButton.vue +32 -22
- package/src/components/Buttons/DefaultButton/__tests__/DefaultButton.spec.js +6 -1
- package/src/components/Buttons/ExportButton/__tests__/ExportButton.spec.js +1 -0
- package/src/components/Buttons/ImportButton/__tests__/ImportButton.spec.js +1 -0
- package/src/components/Buttons/MultiImportButton/__tests__/MultiImportButton.spec.js +1 -0
- package/src/components/Buttons/RemoveButton/__tests__/RemoveButton.spec.js +1 -0
- package/src/components/Buttons/ToggleButton/__tests__/ToggleButton.spec.js +1 -0
- package/src/components/Card/CardContent/__tests__/CardContent.spec.js +2 -1
- package/src/components/Card/__tests__/Card.spec.js +2 -1
- package/src/components/Card/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.stories.js +2 -0
- package/src/components/Checkbox/Checkbox.vue +6 -3
- package/src/components/Checkbox/__tests__/Checkbox.spec.js +2 -1
- package/src/components/Checkbox/__tests__/modelValueWatcher.spec.js +1 -0
- package/src/components/Chip/Chip.stories.js +2 -0
- package/src/components/Chip/__tests__/Chip.spec.js +2 -1
- package/src/components/ChipInviteStatus/__tests__/ChipInviteStatus.spec.js +2 -1
- package/src/components/Collapsible/Collapsible.stories.js +2 -0
- package/src/components/Collapsible/Collapsible.vue +34 -8
- package/src/components/ContextMenu/ContextMenu.vue +1 -0
- package/src/components/ContextMenu/__tests__/ContextMenu.spec.js +2 -1
- package/src/components/CopyToClipboard/CopyToClipboard.vue +1 -0
- package/src/components/CopyToClipboard/__tests__/CopyToClipboard.spec.js +2 -1
- package/src/components/DataTableEmptyWrapper/__tests__/DataTableEmptyWrapper.spec.js +2 -1
- package/src/components/DataTableHeader/__tests__/DataTableHeader.spec.js +2 -1
- package/src/components/DataTablePaginator/__tests__/DataTablePaginator.spec.js +2 -1
- package/src/components/DatePicker/DatePicker.vue +2 -1
- package/src/components/DatePicker/__tests__/DatePicker.spec.js +2 -1
- package/src/components/DialogFooter/DialogFooter.vue +1 -0
- package/src/components/DialogFooter/__tests__/DialogFooter.spec.js +2 -1
- package/src/components/DialogHeader/DialogHeader.scss +1 -1
- package/src/components/DialogHeader/__tests__/DialogHeader.spec.js +2 -1
- package/src/components/DialogPrompt/index.ts +3 -1
- package/src/components/DialogPrompt/utils/index.ts +1 -1
- package/src/components/Form/Form.stories.js +118 -159
- package/src/components/Form/Form.vue +11 -20
- package/src/components/Form/__tests__/Form.spec.js +1 -0
- package/src/components/Icon/Icon.stories.js +4 -2
- package/src/components/Icon/__tests__/Icon.spec.js +1 -0
- package/src/components/IconBox/IconBox.stories.js +1 -0
- package/src/components/IconBox/__tests__/IconBox.spec.js +2 -1
- package/src/components/IdCaption/__tests__/IdCaption.spec.js +1 -0
- package/src/components/Label/__tests__/Label.spec.js +2 -1
- package/src/components/List/List.vue +1 -0
- package/src/components/List/__tests__/List.spec.js +2 -1
- package/src/components/ListItem/ListItem.stories.js +2 -0
- package/src/components/ListItem/__tests__/ListItem.spec.js +2 -1
- package/src/components/Loader/Loader.vue +1 -0
- package/src/components/Loader/__tests__/Loader.spec.js +2 -1
- package/src/components/Logger/Logger.vue +1 -0
- package/src/components/Logger/LoggerItem/LoggerItem.vue +1 -0
- package/src/components/Logger/LoggerItem/__tests__/LoggerItem.spec.js +1 -0
- package/src/components/Logger/__tests__/Logger.spec.js +1 -0
- package/src/components/MainFilter/__tests__/MainFilter.spec.js +1 -0
- package/src/components/ManagersList/__tests__/ManagersList.spec.js +1 -0
- package/src/components/Modal/Modal.vue +2 -1
- package/src/components/ModalPromptUser/__tests__/ModalPromptUser.spec.js +3 -2
- package/src/components/MultipleFilePicker/MultipleFilePicker.vue +1 -0
- package/src/components/MultipleSelectShortener/__tests__/MultipleSelectShortener.spec.js +1 -0
- package/src/components/ProgressBar/__tests__/ProgressBar.spec.js +2 -1
- package/src/components/PromptUserToConfirm/PromptUserToConfirm.vue +12 -7
- package/src/components/PromptUserToConfirm/__tests__/PromptUserToConfirm.spec.js +3 -2
- package/src/components/Radio/Radio.stories.js +3 -1
- package/src/components/RadioGroup/RadioGroup.vue +3 -2
- package/src/components/RadioGroup/__tests__/RadioGroup.spec.js +2 -1
- package/src/components/RangeDatePicker/RangeDatePicker.vue +1 -1
- package/src/components/RangeDatePicker/__tests__/RangeDatePicker.spec.js +2 -1
- package/src/components/ResetTableRowSelection/__tests__/ResetTableRowSelection.spec.js +2 -1
- package/src/components/ResourceMetaInfo/__tests__/ResourceMetaInfo.spec.js +2 -1
- package/src/components/Select/Select.vue +6 -3
- package/src/components/Select/__tests__/Select.spec.js +2 -1
- package/src/components/SelectAutoComplete/SelectAutoComplete.vue +6 -3
- package/src/components/SelectAutoComplete/__tests__/SelectAutoComplete.spec.js +2 -1
- package/src/components/SelectModalOptions/SelectModalOptions.vue +3 -3
- package/src/components/SelectModalOptions/__tests__/SelectModalOptions.spec.js +7 -5
- package/src/components/Stepper/StepperHeader/StepperHeader.vue +1 -0
- package/src/components/Stepper/StepperHeader/__tests__/StepperHeader.spec.js +1 -0
- package/src/components/Switcher/Switcher.stories.js +2 -0
- package/src/components/Switcher/__tests__/Switcher.spec.js +1 -0
- package/src/components/TableContextMenu/__tests__/TableContextMenu.spec.js +2 -1
- package/src/components/Tabs/__tests__/Tabs.spec.js +1 -0
- package/src/components/TextArea/TextArea.vue +3 -2
- package/src/components/TextArea/__tests__/TextArea.spec.js +2 -1
- package/src/components/TextFieldV2/TextFieldV2.stories.js +2 -1
- package/src/components/TextFieldV2/TextFieldV2.vue +6 -5
- package/src/components/TextFieldV2/__tests__/TextFieldV2.spec.js +2 -1
- package/src/components/Tooltip/Tooltip.vue +4 -3
- package/src/components/Tooltip/__tests__/Tooltip.spec.js +2 -1
- package/src/components/Typography/BodyText/BodyText.stories.js +0 -1
- package/src/components/Typography/BodyText/BodyText.vue +1 -0
- package/src/components/Typography/BodyText/__tests__/BodyText.spec.js +2 -1
- package/src/components/Typography/Caption/__tests__/Caption.spec.js +2 -1
- package/src/components/Typography/Heading/__tests__/Heading.spec.js +2 -1
- package/src/components/Typography/OverlayText/__tests__/OverlayText.spec.js +2 -1
- package/src/components/Typography/Small/__tests__/Small.spec.js +2 -1
- package/src/components/Typography/Subtitle/__tests__/Subtitle.spec.js +2 -1
- package/src/components/Typography/Typography.stories.js +3 -1
- package/src/components/Typography/Typography.vue +1 -0
- package/src/components/Typography/__tests__/Typography.spec.js +2 -1
- package/src/components/Typography/index.ts +3 -2
- package/src/components/ValueCaption/ValueCaption.stories.js +2 -0
- package/src/components/ValueCaption/__tests__/ValueCaption.spec.js +1 -0
- package/src/components/layout/Box/Box.stories.js +2 -0
- package/src/components/layout/Box/__tests__/Box.spec.js +2 -1
- package/src/components/layout/Col/Col.stories.js +2 -0
- package/src/components/layout/Col/__tests__/Col.spec.js +2 -1
- package/src/components/layout/Line/Line.stories.js +2 -0
- package/src/components/layout/Line/__tests__/Line.spec.js +2 -1
- package/src/components/layout/Row/Row.stories.js +2 -0
- package/src/components/layout/Row/__tests__/Row.spec.js +2 -1
- package/src/examples/Colors.stories.js +3 -3
- package/src/helpers/walk.ts +19 -0
- package/src/main.ts +13 -15
- package/src/plugins/DialogPrompt/utils/__tests__/modalFooter.spec.js +18 -0
- package/src/plugins/DialogPrompt/utils/__tests__/modalHeader.spec.js +15 -0
- package/src/plugins/DialogPrompt/utils/index.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import DataTableEmptyWrapper from '../DataTableEmptyWrapper';
|
|
3
4
|
|
|
4
5
|
describe('DataTableEmptyWrapper component', () => {
|
|
@@ -14,7 +15,7 @@ describe('DataTableEmptyWrapper component', () => {
|
|
|
14
15
|
|
|
15
16
|
describe('mount component', () => {
|
|
16
17
|
it('renders correctly', () => {
|
|
17
|
-
expect(wrapper.element).
|
|
18
|
+
expect(wrapper.element).toBeDefined();
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import DataTableHeader from '../DataTableHeader';
|
|
3
4
|
|
|
4
5
|
describe('DataTableHeader component', () => {
|
|
@@ -37,7 +38,7 @@ describe('DataTableHeader component', () => {
|
|
|
37
38
|
|
|
38
39
|
describe('mount component', () => {
|
|
39
40
|
it('renders correctly', () => {
|
|
40
|
-
expect(wrapper.element).
|
|
41
|
+
expect(wrapper.element).toBeDefined();
|
|
41
42
|
});
|
|
42
43
|
});
|
|
43
44
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import DataTablePaginator from '../DataTablePaginator';
|
|
3
4
|
|
|
4
5
|
describe('DataTablePaginator component', () => {
|
|
@@ -20,7 +21,7 @@ describe('DataTablePaginator component', () => {
|
|
|
20
21
|
|
|
21
22
|
describe('mount component', () => {
|
|
22
23
|
it('renders correctly', () => {
|
|
23
|
-
expect(wrapper.element).
|
|
24
|
+
expect(wrapper.element).toBeDefined();
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
27
|
|
|
@@ -67,8 +67,9 @@
|
|
|
67
67
|
</template>
|
|
68
68
|
<script lang="ts">
|
|
69
69
|
import { PropType } from 'vue';
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
import { formatDatePickerHeader } from '../../helpers';
|
|
72
|
+
import { convertDate, checkDateValid, revertDate } from '../../helpers/date';
|
|
72
73
|
/**
|
|
73
74
|
* Componente de input com datepicker para data
|
|
74
75
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import DatePicker from '../DatePicker';
|
|
3
4
|
|
|
4
5
|
describe('DatePicker component', () => {
|
|
@@ -20,7 +21,7 @@ describe('DatePicker component', () => {
|
|
|
20
21
|
|
|
21
22
|
describe('mount component', () => {
|
|
22
23
|
it('renders correctly', () => {
|
|
23
|
-
expect(wrapper.element).
|
|
24
|
+
expect(wrapper.element).toBeDefined();
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
27
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import DialogFooter from '../DialogFooter';
|
|
3
4
|
|
|
4
5
|
describe('DialogFooter component', () => {
|
|
@@ -14,7 +15,7 @@ describe('DialogFooter component', () => {
|
|
|
14
15
|
|
|
15
16
|
describe('mount component', () => {
|
|
16
17
|
it('renders correctly', () => {
|
|
17
|
-
expect(wrapper.element).
|
|
18
|
+
expect(wrapper.element).toBeDefined();
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import DialogHeader from '../DialogHeader';
|
|
3
4
|
|
|
4
5
|
describe('DialogHeader component', () => {
|
|
@@ -18,7 +19,7 @@ describe('DialogHeader component', () => {
|
|
|
18
19
|
|
|
19
20
|
describe('mount component', () => {
|
|
20
21
|
it('renders correctly', () => {
|
|
21
|
-
expect(wrapper.element).
|
|
22
|
+
expect(wrapper.element).toBeDefined();
|
|
22
23
|
});
|
|
23
24
|
});
|
|
24
25
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getCurrentInstance, ref } from 'vue';
|
|
2
|
+
|
|
1
3
|
import Form from './Form.vue';
|
|
2
4
|
|
|
3
5
|
export default {
|
|
@@ -16,16 +18,6 @@ export default {
|
|
|
16
18
|
},
|
|
17
19
|
};
|
|
18
20
|
|
|
19
|
-
const styles = {
|
|
20
|
-
vForm: {
|
|
21
|
-
maxWidth: '480px',
|
|
22
|
-
},
|
|
23
|
-
footer: {
|
|
24
|
-
display: 'flex',
|
|
25
|
-
justifyContent: 'end',
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
21
|
export const Primary = () => ({
|
|
30
22
|
data() {
|
|
31
23
|
return {
|
|
@@ -33,7 +25,7 @@ export const Primary = () => ({
|
|
|
33
25
|
document: 'Document',
|
|
34
26
|
name: '',
|
|
35
27
|
checkbox: '2',
|
|
36
|
-
birthDate:
|
|
28
|
+
birthDate: '1980-09-20',
|
|
37
29
|
selectId: 1,
|
|
38
30
|
rangeDate: [],
|
|
39
31
|
cityName: null,
|
|
@@ -48,49 +40,137 @@ export const Primary = () => ({
|
|
|
48
40
|
{ value: 1, text: 'label 1' },
|
|
49
41
|
{ value: 2, text: 'label 2' },
|
|
50
42
|
],
|
|
51
|
-
styles,
|
|
52
43
|
};
|
|
53
44
|
},
|
|
54
45
|
template: `
|
|
55
|
-
|
|
46
|
+
<farm-row>
|
|
47
|
+
<farm-col md="3">
|
|
48
|
+
<farm-form v-model="validForm" ref="form" autocomplete="off">
|
|
49
|
+
<div>
|
|
50
|
+
<farm-label :required="true">Documento</farm-label>
|
|
51
|
+
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
52
|
+
</div>
|
|
53
|
+
<farm-label :required="true">Nome</farm-label>
|
|
54
|
+
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" hint="Seu nome igual ao do RG" />
|
|
55
|
+
|
|
56
|
+
<farm-label :required="true">True/false</farm-label>
|
|
57
|
+
<farm-checkbox v-model="form.checkbox" value="1" :rules="[rules.checked]" />
|
|
58
|
+
|
|
59
|
+
<farm-label :required="true">Select</farm-label>
|
|
60
|
+
<farm-select :rules="[rules.required]" :items="items" v-model="form.selectId"/>
|
|
61
|
+
|
|
62
|
+
<farm-label :required="true">Birthdate:</farm-label>
|
|
63
|
+
<farm-input-datepicker
|
|
64
|
+
ref="birthDate"
|
|
65
|
+
inputId="form-pf-birthDate"
|
|
66
|
+
v-model="form.birthDate"
|
|
67
|
+
:readonly="true"
|
|
68
|
+
:required="true"
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
<farm-label :required="true">Range date:</farm-label>
|
|
72
|
+
<farm-input-rangedatepicker
|
|
73
|
+
ref="rangeDate"
|
|
74
|
+
inputId="form-pf-rangeDate"
|
|
75
|
+
v-model="form.rangeDate"
|
|
76
|
+
:required="true"
|
|
77
|
+
/>
|
|
78
|
+
<div class="footer">
|
|
79
|
+
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
80
|
+
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
81
|
+
</div>
|
|
82
|
+
form: {{ form }}
|
|
83
|
+
</farm-form>
|
|
84
|
+
</farm-col>
|
|
85
|
+
</farm-row>`,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const CompositionAPI = () => ({
|
|
89
|
+
setup() {
|
|
90
|
+
const formValues = ref({ name: '' });
|
|
91
|
+
const validForm = ref(false);
|
|
92
|
+
const formEl = (ref < HTMLDivElement) | (null > null);
|
|
93
|
+
|
|
94
|
+
const rules = { required: value => !!value || 'Campo obrigatório' };
|
|
95
|
+
|
|
96
|
+
const internalInstance = getCurrentInstance().proxy;
|
|
97
|
+
|
|
98
|
+
const onReset = () => {
|
|
99
|
+
internalInstance.formEl.reset();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
formEl,
|
|
104
|
+
formValues,
|
|
105
|
+
validForm,
|
|
106
|
+
rules,
|
|
107
|
+
onReset,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
template: `<div>
|
|
111
|
+
<farm-form v-model="validForm" ref="formEl" autocomplete="off">
|
|
112
|
+
<farm-box>
|
|
113
|
+
<farm-row>
|
|
114
|
+
<farm-col md="4">
|
|
115
|
+
<farm-label :required="true">Documento</farm-label>
|
|
116
|
+
<farm-textfield-v2 v-model="formValues.name" :rules=[rules.required] />
|
|
117
|
+
</farm-col>
|
|
118
|
+
</farm-row>
|
|
119
|
+
</farm-box>
|
|
120
|
+
</farm-form>
|
|
121
|
+
<farm-btn outlined @click="onReset" class="mr-3">Reset</farm-btn>
|
|
122
|
+
form: {{ formValues }} {{ validForm }}
|
|
123
|
+
</div>
|
|
124
|
+
`,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const RestartValidation = () => ({
|
|
128
|
+
data() {
|
|
129
|
+
return {
|
|
130
|
+
form: {
|
|
131
|
+
document: null,
|
|
132
|
+
name: null,
|
|
133
|
+
checkbox: null,
|
|
134
|
+
birthDate: '',
|
|
135
|
+
selectId: null,
|
|
136
|
+
rangeDate: [],
|
|
137
|
+
},
|
|
138
|
+
validForm: true,
|
|
139
|
+
rules: {
|
|
140
|
+
required: value => !!value || 'Campo obrigatório',
|
|
141
|
+
checked: value => !!value || 'Deve estar marcado',
|
|
142
|
+
},
|
|
143
|
+
items: [
|
|
144
|
+
{ value: null, text: '' },
|
|
145
|
+
{ value: 1, text: 'label 1' },
|
|
146
|
+
{ value: 2, text: 'label 2' },
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
template: `
|
|
151
|
+
<farm-form v-model="validForm" ref="form">
|
|
152
|
+
Is valid form: {{ validForm }}
|
|
153
|
+
|
|
154
|
+
<farm-label :required="true">Nome</farm-label>
|
|
155
|
+
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
|
|
156
|
+
|
|
56
157
|
<div>
|
|
57
158
|
<farm-label :required="true">Documento</farm-label>
|
|
58
159
|
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
59
160
|
</div>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
161
|
+
|
|
162
|
+
|
|
63
163
|
<farm-label :required="true">True/false</farm-label>
|
|
64
164
|
<farm-checkbox v-model="form.checkbox" value="1" :rules="[rules.checked]" />
|
|
65
165
|
|
|
66
166
|
<farm-label :required="true">Select</farm-label>
|
|
67
167
|
<farm-select :rules="[rules.required]" :items="items" v-model="form.selectId"/>
|
|
68
|
-
|
|
69
|
-
<farm-label :required="true">Birthdate:</farm-label>
|
|
70
|
-
<farm-input-datepicker
|
|
71
|
-
ref="birthDate"
|
|
72
|
-
inputId="form-pf-birthDate"
|
|
73
|
-
class="mt-4"
|
|
74
|
-
v-model="form.birthDate"
|
|
75
|
-
:readonly="true"
|
|
76
|
-
:required="true"
|
|
77
|
-
/>
|
|
78
|
-
|
|
79
|
-
<farm-label :required="true">Range date:</farm-label>
|
|
80
|
-
<farm-input-rangedatepicker
|
|
81
|
-
ref="rangeDate"
|
|
82
|
-
inputId="form-pf-rangeDate"
|
|
83
|
-
class="mt-4"
|
|
84
|
-
v-model="form.rangeDate"
|
|
85
|
-
:required="true"
|
|
86
|
-
/>
|
|
87
|
-
|
|
88
168
|
|
|
89
|
-
<div class="footer"
|
|
169
|
+
<div class="footer">
|
|
170
|
+
<farm-btn outlined @click="$refs.form.restartValidation()" class="mr-3">Restart Validation</farm-btn>
|
|
90
171
|
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
91
172
|
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
92
173
|
</div>
|
|
93
|
-
form: {{ form }}
|
|
94
174
|
</farm-form>
|
|
95
175
|
`,
|
|
96
176
|
});
|
|
@@ -238,77 +318,6 @@ export const Grid = () => ({
|
|
|
238
318
|
`,
|
|
239
319
|
});
|
|
240
320
|
|
|
241
|
-
export const MigrateTextVieldV2 = () => ({
|
|
242
|
-
data() {
|
|
243
|
-
return {
|
|
244
|
-
form: {
|
|
245
|
-
document: 'Document',
|
|
246
|
-
name: 'Name',
|
|
247
|
-
},
|
|
248
|
-
validForm: false,
|
|
249
|
-
rules: {
|
|
250
|
-
required: value => !!value || 'Campo obrigatório',
|
|
251
|
-
},
|
|
252
|
-
items: [
|
|
253
|
-
{ value: null, text: '' },
|
|
254
|
-
{ value: 1, text: 'label 1' },
|
|
255
|
-
{ value: 2, text: 'label 2' },
|
|
256
|
-
],
|
|
257
|
-
styles,
|
|
258
|
-
};
|
|
259
|
-
},
|
|
260
|
-
template: `
|
|
261
|
-
<farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
|
|
262
|
-
<div>
|
|
263
|
-
<farm-label :required="true">Documento</farm-label>
|
|
264
|
-
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
265
|
-
</div>
|
|
266
|
-
<farm-label :required="true">Nome</farm-label>
|
|
267
|
-
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
|
|
268
|
-
|
|
269
|
-
<div class="footer" :style="[styles.footer]">
|
|
270
|
-
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
271
|
-
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
272
|
-
</div>
|
|
273
|
-
form: {{ form }}
|
|
274
|
-
</farm-form>
|
|
275
|
-
`,
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
export const MigrateSelectV2 = () => ({
|
|
279
|
-
data() {
|
|
280
|
-
return {
|
|
281
|
-
form: {
|
|
282
|
-
document: '',
|
|
283
|
-
},
|
|
284
|
-
validForm: false,
|
|
285
|
-
rules: {
|
|
286
|
-
required: value => !!value || 'Campo obrigatório',
|
|
287
|
-
},
|
|
288
|
-
items: [
|
|
289
|
-
{ value: null, text: '' },
|
|
290
|
-
{ value: 1, text: 'label 1' },
|
|
291
|
-
{ value: 2, text: 'label 2' },
|
|
292
|
-
],
|
|
293
|
-
styles,
|
|
294
|
-
};
|
|
295
|
-
},
|
|
296
|
-
template: `
|
|
297
|
-
<farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
|
|
298
|
-
<div>
|
|
299
|
-
<farm-label :required="true">Documento</farm-label>
|
|
300
|
-
<farm-select v-model="form.document" :items="items" :rules="[rules.required]" />
|
|
301
|
-
</div>
|
|
302
|
-
|
|
303
|
-
<div class="footer" :style="[styles.footer]">
|
|
304
|
-
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
305
|
-
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
306
|
-
</div>
|
|
307
|
-
form: {{ form }}
|
|
308
|
-
</farm-form>
|
|
309
|
-
`,
|
|
310
|
-
});
|
|
311
|
-
|
|
312
321
|
export const ValidateRadioGroup = () => ({
|
|
313
322
|
data() {
|
|
314
323
|
return {
|
|
@@ -336,55 +345,5 @@ export const ValidateRadioGroup = () => ({
|
|
|
336
345
|
`,
|
|
337
346
|
});
|
|
338
347
|
|
|
339
|
-
export const RestartValidation = () => ({
|
|
340
|
-
data() {
|
|
341
|
-
return {
|
|
342
|
-
form: {
|
|
343
|
-
document: null,
|
|
344
|
-
name: null,
|
|
345
|
-
checkbox: null,
|
|
346
|
-
birthDate: '',
|
|
347
|
-
selectId: null,
|
|
348
|
-
rangeDate: [],
|
|
349
|
-
},
|
|
350
|
-
validForm: true,
|
|
351
|
-
rules: {
|
|
352
|
-
required: value => !!value || 'Campo obrigatório',
|
|
353
|
-
checked: value => !!value || 'Deve estar marcado',
|
|
354
|
-
},
|
|
355
|
-
items: [
|
|
356
|
-
{ value: null, text: '' },
|
|
357
|
-
{ value: 1, text: 'label 1' },
|
|
358
|
-
{ value: 2, text: 'label 2' },
|
|
359
|
-
],
|
|
360
|
-
styles,
|
|
361
|
-
};
|
|
362
|
-
},
|
|
363
|
-
template: `
|
|
364
|
-
<farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
|
|
365
|
-
Is valid form: {{ validForm }}
|
|
366
348
|
|
|
367
|
-
<farm-label :required="true">Nome</farm-label>
|
|
368
|
-
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
|
|
369
|
-
|
|
370
|
-
<div>
|
|
371
|
-
<farm-label :required="true">Documento</farm-label>
|
|
372
|
-
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
373
|
-
</div>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
<farm-label :required="true">True/false</farm-label>
|
|
377
|
-
<farm-checkbox v-model="form.checkbox" value="1" :rules="[rules.checked]" />
|
|
378
|
-
|
|
379
|
-
<farm-label :required="true">Select</farm-label>
|
|
380
|
-
<farm-select :rules="[rules.required]" :items="items" v-model="form.selectId"/>
|
|
381
|
-
|
|
382
|
-
<div class="footer" :style="[styles.footer]">
|
|
383
|
-
<farm-btn outlined @click="$refs.form.restartValidation()" class="mr-3">Restart Validation</farm-btn>
|
|
384
|
-
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
385
|
-
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
386
|
-
</div>
|
|
387
|
-
</farm-form>
|
|
388
|
-
`,
|
|
389
|
-
});
|
|
390
349
|
*/
|
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
<script lang="ts">
|
|
5
5
|
import { onMounted, reactive, ref, getCurrentInstance } from 'vue';
|
|
6
6
|
|
|
7
|
+
import walk from '../../helpers/walk';
|
|
8
|
+
|
|
7
9
|
type ErrorsBag = Record<number, boolean>;
|
|
8
10
|
|
|
9
11
|
export default {
|
|
10
12
|
name: 'farm-form',
|
|
11
13
|
props: {
|
|
12
|
-
|
|
14
|
+
modelValue: { type: [Boolean] },
|
|
13
15
|
},
|
|
14
16
|
inheritAttrs: true,
|
|
15
17
|
setup(props, { emit }) {
|
|
16
|
-
const innerValue = ref(props.
|
|
18
|
+
const innerValue = ref(props.modelValue);
|
|
17
19
|
let errorsBag = reactive({} as ErrorsBag);
|
|
18
20
|
let validationFields = [];
|
|
19
21
|
const instance = getCurrentInstance();
|
|
@@ -21,14 +23,14 @@ export default {
|
|
|
21
23
|
const dispatchError = () => {
|
|
22
24
|
const keys = Object.keys(errorsBag);
|
|
23
25
|
const errorsIds = keys.filter(key => !errorsBag[key]);
|
|
24
|
-
emit('
|
|
26
|
+
emit('update:modelValue', errorsIds.length === 0);
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
const watchInput = (field: any) => {
|
|
28
30
|
field.$watch(
|
|
29
31
|
'hasError',
|
|
30
32
|
() => {
|
|
31
|
-
errorsBag[field.
|
|
33
|
+
errorsBag[field.customId] = field.valid;
|
|
32
34
|
dispatchError();
|
|
33
35
|
},
|
|
34
36
|
{ immediate: true }
|
|
@@ -42,20 +44,9 @@ export default {
|
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
const recursiveFormField = $node => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
$node.children.forEach($leaf => {
|
|
49
|
-
if ($leaf.component?.ctx?.validate) {
|
|
50
|
-
validationFields.push($leaf.component?.ctx);
|
|
51
|
-
} else if ($leaf.children && $leaf.children.length > 1) {
|
|
52
|
-
recursiveFormField($leaf);
|
|
53
|
-
} else if ($leaf.children && $leaf.children[0] && $leaf.children[0].validate) {
|
|
54
|
-
validationFields.push($leaf.children[0]);
|
|
55
|
-
} else if ($leaf.validatable) {
|
|
56
|
-
validationFields.push($leaf);
|
|
57
|
-
} else {
|
|
58
|
-
recursiveFormField($leaf);
|
|
47
|
+
walk($node, item => {
|
|
48
|
+
if (item.validate) {
|
|
49
|
+
validationFields.push(item);
|
|
59
50
|
}
|
|
60
51
|
});
|
|
61
52
|
};
|
|
@@ -71,7 +62,7 @@ export default {
|
|
|
71
62
|
const restartValidation = () => {
|
|
72
63
|
validationFields = [];
|
|
73
64
|
errorsBag = {};
|
|
74
|
-
recursiveFormField(instance);
|
|
65
|
+
recursiveFormField(instance.subTree);
|
|
75
66
|
validationFields.forEach(field => {
|
|
76
67
|
watchInput(field);
|
|
77
68
|
field.validate(field.value);
|
|
@@ -82,7 +73,7 @@ export default {
|
|
|
82
73
|
const restart = () => {
|
|
83
74
|
validationFields = [];
|
|
84
75
|
errorsBag = {};
|
|
85
|
-
recursiveFormField(instance);
|
|
76
|
+
recursiveFormField(instance.subTree);
|
|
86
77
|
validationFields.forEach(field => {
|
|
87
78
|
watchInput(field);
|
|
88
79
|
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// import { withDesign } from 'storybook-addon-designs';
|
|
2
2
|
import Icon from './Icon.vue';
|
|
3
|
-
import
|
|
3
|
+
import iconsList from './icons_list';
|
|
4
|
+
|
|
4
5
|
import baseThemeColors from '../../configurations/_theme-colors-base.module.scss';
|
|
5
6
|
import bwThemeColors from '../../configurations/_theme-colors-bw.module.scss';
|
|
6
|
-
import
|
|
7
|
+
import sizes from '../../configurations/sizes';
|
|
8
|
+
|
|
7
9
|
const colors = Object.keys(baseThemeColors);
|
|
8
10
|
|
|
9
11
|
import('./Icons.stories.scss');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// import { withDesign } from 'storybook-addon-designs';
|
|
2
2
|
import IconBox from './IconBox.vue';
|
|
3
|
+
|
|
3
4
|
import baseThemeColors from '../../configurations/_theme-colors-base.module.scss';
|
|
4
5
|
const colors = Object.keys(baseThemeColors);
|
|
5
6
|
import sizes from '../../configurations/sizes';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import IconBox from '../IconBox';
|
|
3
4
|
|
|
4
5
|
describe('IconBox component', () => {
|
|
@@ -20,7 +21,7 @@ describe('IconBox component', () => {
|
|
|
20
21
|
|
|
21
22
|
describe('mount component', () => {
|
|
22
23
|
it('renders correctly', () => {
|
|
23
|
-
expect(wrapper.element).
|
|
24
|
+
expect(wrapper.element).toBeDefined();
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
27
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import Label from '../Label';
|
|
3
4
|
|
|
4
5
|
describe('Label component', () => {
|
|
@@ -14,7 +15,7 @@ describe('Label component', () => {
|
|
|
14
15
|
|
|
15
16
|
describe('mount component', () => {
|
|
16
17
|
it('renders correctly', () => {
|
|
17
|
-
expect(wrapper.element).
|
|
18
|
+
expect(wrapper.element).toBeDefined();
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import List from '../List';
|
|
3
4
|
|
|
4
5
|
describe('List component', () => {
|
|
@@ -16,7 +17,7 @@ describe('List component', () => {
|
|
|
16
17
|
|
|
17
18
|
describe('mount component', () => {
|
|
18
19
|
it('renders correctly', () => {
|
|
19
|
-
expect(wrapper.element).
|
|
20
|
+
expect(wrapper.element).toBeDefined();
|
|
20
21
|
});
|
|
21
22
|
});
|
|
22
23
|
describe('Methods', () => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
2
3
|
import ListItem from '../ListItem';
|
|
3
4
|
|
|
4
5
|
describe('ListItem component', () => {
|
|
@@ -14,7 +15,7 @@ describe('ListItem component', () => {
|
|
|
14
15
|
|
|
15
16
|
describe('mount component', () => {
|
|
16
17
|
it('renders correctly', () => {
|
|
17
|
-
expect(wrapper.element).
|
|
18
|
+
expect(wrapper.element).toBeDefined();
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
});
|