Skip to content

Commit 3654648

Browse files
authored
Merge pull request #1056 from Sysvale/fix-dateinput-reset-bug-1088739392285522216
Fix year/month reset bug in DateInput
2 parents 7c4c0cd + 90cf917 commit 3654648

8 files changed

Lines changed: 238 additions & 46 deletions

File tree

docs/.docgen/components-metadata.json

Lines changed: 152 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@
811811
},
812812
"defaultValue": {
813813
"func": false,
814-
"value": "1"
814+
"value": "5"
815815
}
816816
},
817817
{
@@ -822,7 +822,7 @@
822822
},
823823
"defaultValue": {
824824
"func": false,
825-
"value": "false"
825+
"value": "true"
826826
}
827827
}
828828
],
@@ -1144,6 +1144,17 @@
11441144
"func": false,
11451145
"value": "false"
11461146
}
1147+
},
1148+
{
1149+
"name": "ghost",
1150+
"description": "Especifica se o componente deve ser exibido na sua versão ghost.",
1151+
"type": {
1152+
"name": "boolean"
1153+
},
1154+
"defaultValue": {
1155+
"func": false,
1156+
"value": "false"
1157+
}
11471158
}
11481159
],
11491160
"events": [
@@ -1410,6 +1421,17 @@
14101421
"func": false,
14111422
"value": "false"
14121423
}
1424+
},
1425+
{
1426+
"name": "ghost",
1427+
"description": "Especifica se o componente deve ser exibido na sua versão ghost.",
1428+
"type": {
1429+
"name": "boolean"
1430+
},
1431+
"defaultValue": {
1432+
"func": false,
1433+
"value": "false"
1434+
}
14131435
}
14141436
],
14151437
"slots": [
@@ -1637,8 +1659,9 @@
16371659
]
16381660
},
16391661
"CdsButton": {
1640-
"displayName": "CdsButton",
1662+
"name": "CdsButton",
16411663
"exportName": "default",
1664+
"displayName": "Button",
16421665
"description": "",
16431666
"tags": {},
16441667
"props": [
@@ -1740,7 +1763,7 @@
17401763
},
17411764
{
17421765
"name": "loading",
1743-
"description": "Especifica se a versão do Botão é a secundária.",
1766+
"description": "Especifica se o botão deve mostrar spinner de carregamento.\nCaso o botão seja do tipo ghost ou secondary a variante do spinner é a mesma passada na prop variant.",
17441767
"type": {
17451768
"name": "boolean"
17461769
},
@@ -2876,6 +2899,35 @@
28762899
"func": false,
28772900
"value": "[]"
28782901
}
2902+
},
2903+
{
2904+
"name": "state",
2905+
"description": "Especifica o estado do TextInput. As opções são 'default', 'valid', 'loading' e 'invalid'.",
2906+
"tags": {},
2907+
"values": [
2908+
"default",
2909+
"valid",
2910+
"loading",
2911+
"invalid"
2912+
],
2913+
"type": {
2914+
"name": "string"
2915+
},
2916+
"defaultValue": {
2917+
"func": false,
2918+
"value": "'default'"
2919+
}
2920+
},
2921+
{
2922+
"name": "errorMessage",
2923+
"description": "Especifica a mensagem de erro, que será exibida caso o estado seja inválido",
2924+
"type": {
2925+
"name": "string"
2926+
},
2927+
"defaultValue": {
2928+
"func": false,
2929+
"value": "'Valor inválido'"
2930+
}
28792931
}
28802932
],
28812933
"events": [
@@ -4323,8 +4375,9 @@
43234375
]
43244376
},
43254377
"CdsDropdownButton": {
4326-
"displayName": "CdsDropdownButton",
4378+
"name": "CdsDropdownButton",
43274379
"exportName": "default",
4380+
"displayName": "DropdownButton",
43284381
"description": "",
43294382
"tags": {},
43304383
"props": [
@@ -4424,27 +4477,38 @@
44244477
"md",
44254478
"lg"
44264479
]
4427-
}
4428-
],
4429-
"events": [
4480+
},
44304481
{
4431-
"name": "click",
4432-
"description": "Evento que indica que o DropdownButton foi clicado",
4482+
"name": "disabled",
4483+
"description": "Desabilita o input.",
44334484
"type": {
4434-
"names": [
4435-
"Event"
4436-
]
4485+
"name": "boolean"
4486+
},
4487+
"defaultValue": {
4488+
"func": false,
4489+
"value": "false"
44374490
}
44384491
},
44394492
{
4440-
"name": "action-click",
4493+
"name": "tooltipText",
4494+
"description": "Texto a ser exibido como tooltip com o hover do DropdownButton quando a prop disabled estiver ativa.",
44414495
"type": {
4442-
"names": [
4443-
"undefined"
4444-
]
4496+
"name": "string"
4497+
},
4498+
"defaultValue": {
4499+
"func": false,
4500+
"value": "null"
44454501
}
44464502
}
44474503
],
4504+
"events": [
4505+
{
4506+
"name": "button-click"
4507+
},
4508+
{
4509+
"name": "action-click"
4510+
}
4511+
],
44484512
"sourceFiles": [
44494513
"src/components/DropdownButton.vue"
44504514
]
@@ -8390,7 +8454,7 @@
83908454
},
83918455
"defaultValue": {
83928456
"func": false,
8393-
"value": "'https://cuida.framer.wiki/'"
8457+
"value": "null"
83948458
}
83958459
},
83968460
{
@@ -10730,6 +10794,18 @@
1073010794
"value": "false"
1073110795
}
1073210796
},
10797+
{
10798+
"name": "deepSearch",
10799+
"description": "Indica se a busca deve levar em consideração argumentos compostos.\nSó tem efeito se a prop `searchable` for `true`.",
10800+
"type": {
10801+
"name": "boolean"
10802+
},
10803+
"required": false,
10804+
"defaultValue": {
10805+
"func": false,
10806+
"value": "false"
10807+
}
10808+
},
1073310809
{
1073410810
"name": "width",
1073510811
"tags": {
@@ -10927,6 +11003,17 @@
1092711003
"func": false,
1092811004
"value": "false"
1092911005
}
11006+
},
11007+
{
11008+
"name": "ghost",
11009+
"description": "Especifica se o componente deve ser exibido na sua versão ghost.",
11010+
"type": {
11011+
"name": "boolean"
11012+
},
11013+
"defaultValue": {
11014+
"func": false,
11015+
"value": "false"
11016+
}
1093011017
}
1093111018
],
1093211019
"slots": [
@@ -12673,6 +12760,17 @@
1267312760
"func": false,
1267412761
"value": "false"
1267512762
}
12763+
},
12764+
{
12765+
"name": "loading",
12766+
"description": "Ativa o estado de carregamento do componente, exibindo um Skeleton para a tabela.",
12767+
"type": {
12768+
"name": "boolean"
12769+
},
12770+
"defaultValue": {
12771+
"func": false,
12772+
"value": "false"
12773+
}
1267612774
}
1267712775
],
1267812776
"events": [
@@ -13354,7 +13452,7 @@
1335413452
},
1335513453
"defaultValue": {
1335613454
"func": false,
13357-
"value": "'https://cuida.framer.wiki/'"
13455+
"value": "null"
1335813456
}
1335913457
},
1336013458
{
@@ -13442,6 +13540,11 @@
1344213540
}
1344313541
}
1344413542
],
13543+
"slots": [
13544+
{
13545+
"name": "label"
13546+
}
13547+
],
1344513548
"sourceFiles": [
1344613549
"src/components/TextInput.vue"
1344713550
]
@@ -14643,6 +14746,16 @@
1464314746
"func": false,
1464414747
"value": "''"
1464514748
}
14749+
},
14750+
{
14751+
"name": "year",
14752+
"type": {
14753+
"name": "number"
14754+
},
14755+
"defaultValue": {
14756+
"func": false,
14757+
"value": "new Date().getFullYear()"
14758+
}
1464614759
}
1464714760
],
1464814761
"events": [
@@ -14681,6 +14794,26 @@
1468114794
"func": false,
1468214795
"value": "''"
1468314796
}
14797+
},
14798+
{
14799+
"name": "minDate",
14800+
"type": {
14801+
"name": "string"
14802+
},
14803+
"defaultValue": {
14804+
"func": false,
14805+
"value": "''"
14806+
}
14807+
},
14808+
{
14809+
"name": "maxDate",
14810+
"type": {
14811+
"name": "string"
14812+
},
14813+
"defaultValue": {
14814+
"func": false,
14815+
"value": "''"
14816+
}
1468414817
}
1468514818
],
1468614819
"events": [

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sysvale/cuida",
3-
"version": "3.154.1",
3+
"version": "3.154.6",
44
"description": "A design system built by Sysvale, using storybook and Vue components",
55
"repository": {
66
"type": "git",
@@ -20,7 +20,7 @@
2020
},
2121
"unpkg": "dist/@sysvale/cuida.umd.js",
2222
"scripts": {
23-
"build": "vue-tsc --declaration --emitDeclarationOnly && npm run generate:docs && vite build && node buildtokens.js",
23+
"build": "npm run generate:docs && vue-tsc --declaration --emitDeclarationOnly && vite build && node buildtokens.js",
2424
"preview": "vite preview",
2525
"docs:dev": "vitepress dev docs",
2626
"docs:build": "vitepress build docs",

src/components/DateInput.vue

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
<MonthSelectorGrid
125125
v-show="!range && showMonthPicker"
126126
ref="monthPicker"
127-
:selected-date="model"
127+
:selected-date="pickerSelectedDate"
128128
:min-date="minDate"
129129
:max-date="maxDate"
130130
:variant="variant"
@@ -135,7 +135,7 @@
135135
<YearSelectorGrid
136136
v-show="!range && showYearPicker"
137137
ref="monthPicker"
138-
:selected-date="model"
138+
:selected-date="pickerSelectedDate"
139139
:min-date="minDate"
140140
:max-date="maxDate"
141141
:variant="variant"
@@ -368,6 +368,10 @@ const currenYear = computed(() => {
368368
return currentDate.value.setLocale('pt-BR').toFormat('yyyy');
369369
});
370370
371+
const pickerSelectedDate = computed(() => {
372+
return currentDate.value.toFormat('yyyy-MM-dd');
373+
});
374+
371375
const emptyDays = computed(() => {
372376
const firstDayOfMonth = currentDate.value.startOf('month');
373377
return firstDayOfMonth.weekday - 1;
@@ -829,23 +833,13 @@ function toDateTime() {
829833
}
830834
831835
function handleMonthSelection(selectedMonth) {
832-
internalValue.value = internalValue.value ? internalValue.value : DateTime.now().setLocale('pt-BR').toFormat('dd/MM/yyyy');
833836
showMonthPicker.value = !showMonthPicker.value;
834-
let [day, month, year] = internalValue.value.split('/');
835-
month = selectedMonth.index;
836-
let daysInMonth = DateTime.local(+year, +month).daysInMonth;
837-
838-
day = daysInMonth < day ? daysInMonth : day;
839-
840-
currentDate.value = DateTime.fromFormat(`${day}/${month}/${year}`, 'dd/MM/yyyy');
837+
currentDate.value = currentDate.value.set({ month: parseInt(selectedMonth.index) });
841838
}
842839
843840
function handleYearSelection(selectedYear) {
844-
internalValue.value = internalValue.value ? internalValue.value : DateTime.now().setLocale('pt-BR').toFormat('dd/MM/yyyy');
845841
showYearPicker.value = !showYearPicker.value;
846-
let [day, month] = internalValue.value.split('/');
847-
848-
currentDate.value = DateTime.fromFormat(`${day}/${month}/${selectedYear}`, 'dd/MM/yyyy');
842+
currentDate.value = currentDate.value.set({ year: selectedYear });
849843
}
850844
851845
function toggleMonthPickerDisplay() {

src/components/InternalComponents/MonthSelectorGrid.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ const internalMaxDate = ref(props.maxDate);
5858
5959
/* COMPUTED */
6060
const currentMonth = computed(() => {
61-
if (!internalDate.value) return 1;
61+
if (!internalDate.value) return null;
6262
const month = internalDate.value.split('-')[1];
63-
return month ? parseInt(month) : 1;
63+
return month ? parseInt(month) : null;
6464
});
6565
6666
/* WATCHERS */

0 commit comments

Comments
 (0)