fds-vue-core 6.2.0 → 6.2.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/fds-vue-core.cjs.js +19 -21
- package/dist/fds-vue-core.cjs.js.map +1 -1
- package/dist/fds-vue-core.css +1 -1
- package/dist/fds-vue-core.es.js +19 -21
- package/dist/fds-vue-core.es.js.map +1 -1
- package/package.json +41 -24
- package/src/components/FdsWeekCalendar/FdsWeekCalendar.vue +19 -18
- package/src/components/FdsWeekCalendar/WeekDay.vue +3 -3
- package/src/components/FdsWeekCalendar/types.ts +2 -1
- package/src/components/FdsWeekCalendar/weekCalendar.utils.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fds-vue-core",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"description": "FDS Vue Core Component Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -51,6 +51,29 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": "^20.19.0 || >=22.12.0"
|
|
53
53
|
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"serve": "vite",
|
|
56
|
+
"build": "vite build && npm run build:types && cp ./src/tokens.css ./dist/tokens.css && cp ./src/slot-styles.css ./dist/slot-styles.css && cp ./src/apply.css ./dist/apply.css && cp ./src/fonts.css ./dist/fonts.css && cp -r ./public/assets ./dist/assets && mkdir -p ./dist/assets/img/logos && cp -r ./src/assets/img/logos/* ./dist/assets/img/logos/",
|
|
57
|
+
"build:types": "vue-tsc --project tsconfig.build.json",
|
|
58
|
+
"preview": "vite preview",
|
|
59
|
+
"lint": "eslint . --fix",
|
|
60
|
+
"lint:ts": "vue-tsc --noEmit --project tsconfig.app.json && vue-tsc --noEmit --project tsconfig.node.json",
|
|
61
|
+
"lint:all": "pnpm lint && pnpm lint:ts",
|
|
62
|
+
"format": "prettier --write src/",
|
|
63
|
+
"prepublishOnly": "npm run build",
|
|
64
|
+
"storybook": "STORYBOOK=true storybook dev -p 6006",
|
|
65
|
+
"build-storybook": "STORYBOOK=true storybook build",
|
|
66
|
+
"sync:peers": "node scripts/sync-peers-from-dev.mjs",
|
|
67
|
+
"postinstall": "test -f scripts/sync-peers-from-dev.mjs && node scripts/sync-peers-from-dev.mjs || true",
|
|
68
|
+
"yalc:publish": "npm run build && yalc publish",
|
|
69
|
+
"yalc:push": "npm run build && yalc push",
|
|
70
|
+
"serve:playground": "pnpm --dir playground-consumer dev",
|
|
71
|
+
"create:release": "bash ./scripts/release.sh",
|
|
72
|
+
"commit": "git-cz",
|
|
73
|
+
"commit:vuln": "node scripts/vuln-commit.mjs",
|
|
74
|
+
"vuln-commit": "node scripts/vuln-commit.mjs",
|
|
75
|
+
"cz:config": "node -e \"console.log(require('./scripts/cz/.cz-config.cjs'))\""
|
|
76
|
+
},
|
|
54
77
|
"config": {
|
|
55
78
|
"commitizen": {
|
|
56
79
|
"path": "./scripts/cz/cz-adapter.cjs"
|
|
@@ -108,26 +131,20 @@
|
|
|
108
131
|
"src/apply.css"
|
|
109
132
|
]
|
|
110
133
|
},
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"commit": "git-cz",
|
|
129
|
-
"commit:vuln": "node scripts/vuln-commit.mjs",
|
|
130
|
-
"vuln-commit": "node scripts/vuln-commit.mjs",
|
|
131
|
-
"cz:config": "node -e \"console.log(require('./scripts/cz/.cz-config.cjs'))\""
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
+
"pnpm": {
|
|
135
|
+
"overrides": {
|
|
136
|
+
"minimatch": "^10.2.3",
|
|
137
|
+
"flatted": "^3.4.2",
|
|
138
|
+
"lodash": ">=4.18.0",
|
|
139
|
+
"tmp": "^0.2.4",
|
|
140
|
+
"follow-redirects@<=1.15.11": ">=1.16.0"
|
|
141
|
+
},
|
|
142
|
+
"onlyBuiltDependencies": [
|
|
143
|
+
"@parcel/watcher",
|
|
144
|
+
"core-js-pure",
|
|
145
|
+
"esbuild",
|
|
146
|
+
"vue-demi"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
"packageManager": "pnpm@10.17.1"
|
|
150
|
+
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
addWeeks,
|
|
4
|
+
format,
|
|
5
|
+
getISODay,
|
|
6
|
+
getISOWeek,
|
|
7
|
+
isBefore,
|
|
8
|
+
isSameDay,
|
|
9
|
+
isSameWeek,
|
|
10
|
+
startOfISOWeek,
|
|
11
|
+
subWeeks,
|
|
12
|
+
} from 'date-fns'
|
|
3
13
|
import { computed, ref, watch } from 'vue'
|
|
4
14
|
import FdsButtonIcon from '../Buttons/FdsButtonIcon/FdsButtonIcon.vue'
|
|
5
15
|
import FdsSpinner from '../FdsSpinner/FdsSpinner.vue'
|
|
@@ -10,7 +20,6 @@ import {
|
|
|
10
20
|
checkIfDateIsEnabled,
|
|
11
21
|
getDaysInWeek,
|
|
12
22
|
getDaysOfLastWeek,
|
|
13
|
-
getDaysOfNextWeek,
|
|
14
23
|
getOverlappingMonths,
|
|
15
24
|
getStartAndEndRangeFromWeek,
|
|
16
25
|
} from './weekCalendar.utils'
|
|
@@ -21,7 +30,7 @@ const props = withDefaults(defineProps<FdsWeekCalendarProps>(), {
|
|
|
21
30
|
disablePreviousWeek: false,
|
|
22
31
|
disableNextWeek: false,
|
|
23
32
|
enableHorizontalAnimation: true,
|
|
24
|
-
|
|
33
|
+
minWeek: undefined,
|
|
25
34
|
maxDate: undefined,
|
|
26
35
|
previewOtherDays: false,
|
|
27
36
|
selected: null,
|
|
@@ -35,12 +44,12 @@ const emit = defineEmits<{
|
|
|
35
44
|
(e: 'increment-week'): void
|
|
36
45
|
}>()
|
|
37
46
|
|
|
38
|
-
const currentWeek = ref(props.
|
|
47
|
+
const currentWeek = ref(props.minWeek ?? startOfISOWeek(new Date()))
|
|
39
48
|
const selectedDay = ref<Date | null>(props.selected ?? null)
|
|
40
49
|
const slideDirection = ref<'left' | 'right'>('left')
|
|
41
50
|
|
|
42
51
|
const weekToRender = computed(() => getDaysInWeek(currentWeek.value))
|
|
43
|
-
const
|
|
52
|
+
const visibleWeekDays = computed(() => weekToRender.value.filter((day) => getISODay(day) <= 5))
|
|
44
53
|
const lastWeek = computed(() => getDaysOfLastWeek(subWeeks(currentWeek.value, 1)))
|
|
45
54
|
|
|
46
55
|
const weekText = computed(() => `${getOverlappingMonths(currentWeek.value)} (vecka ${getISOWeek(currentWeek.value)})`)
|
|
@@ -49,13 +58,13 @@ const lastDayOfPreviousWeek = computed(() => lastWeek.value[lastWeek.value.lengt
|
|
|
49
58
|
const disableLastWeekInteraction = computed(
|
|
50
59
|
() =>
|
|
51
60
|
!!props.disablePreviousWeek ||
|
|
52
|
-
(!!lastDayOfPreviousWeek.value && checkIfDateIsBeforeToday(lastDayOfPreviousWeek.value))
|
|
61
|
+
(!!lastDayOfPreviousWeek.value && checkIfDateIsBeforeToday(lastDayOfPreviousWeek.value)) ||
|
|
62
|
+
(!!props.minWeek && isBefore(subWeeks(currentWeek.value, 1), startOfISOWeek(props.minWeek))),
|
|
53
63
|
)
|
|
54
64
|
const disableNextWeekInteraction = computed(
|
|
55
65
|
() =>
|
|
56
66
|
!!props.disableNextWeek || (!!props.maxDate && isSameWeek(currentWeek.value, props.maxDate, { weekStartsOn: 1 })),
|
|
57
67
|
)
|
|
58
|
-
const trailingPreviewDay = computed(() => nextWeek.value[0])
|
|
59
68
|
const transitionClasses = computed(() => {
|
|
60
69
|
if (!props.enableHorizontalAnimation) {
|
|
61
70
|
return {
|
|
@@ -85,7 +94,7 @@ const transitionClasses = computed(() => {
|
|
|
85
94
|
})
|
|
86
95
|
|
|
87
96
|
watch(
|
|
88
|
-
|
|
97
|
+
visibleWeekDays,
|
|
89
98
|
(week) => {
|
|
90
99
|
const { endDate, startDate } = getStartAndEndRangeFromWeek(week)
|
|
91
100
|
if (!startDate || !endDate) return
|
|
@@ -95,7 +104,7 @@ watch(
|
|
|
95
104
|
)
|
|
96
105
|
|
|
97
106
|
watch(
|
|
98
|
-
() => props.
|
|
107
|
+
() => props.minWeek,
|
|
99
108
|
(newWeek) => {
|
|
100
109
|
if (!newWeek) {
|
|
101
110
|
currentWeek.value = startOfISOWeek(new Date())
|
|
@@ -174,7 +183,7 @@ const isTodayDate = (weekDay: Date) => isSameDay(weekDay, new Date())
|
|
|
174
183
|
:leave-to-class="transitionClasses.leaveToClass"
|
|
175
184
|
>
|
|
176
185
|
<div :key="currentWeek.toISOString()" class="flex flex-row flex-nowrap items-center justify-start gap-x-px">
|
|
177
|
-
<template v-for="(weekDay, index) in
|
|
186
|
+
<template v-for="(weekDay, index) in visibleWeekDays" :key="`current-${weekDay.toISOString()}-${index}`">
|
|
178
187
|
<WeekDay
|
|
179
188
|
:date="weekDay"
|
|
180
189
|
:disabled="isWeekDayDisabled(weekDay)"
|
|
@@ -183,14 +192,6 @@ const isTodayDate = (weekDay: Date) => isSameDay(weekDay, new Date())
|
|
|
183
192
|
@select-date="onHandleSelectedDay"
|
|
184
193
|
/>
|
|
185
194
|
</template>
|
|
186
|
-
<WeekDay
|
|
187
|
-
v-if="trailingPreviewDay"
|
|
188
|
-
:date="trailingPreviewDay"
|
|
189
|
-
:disabled="isWeekDayDisabled(trailingPreviewDay)"
|
|
190
|
-
:selected="!!selectedDay && isSameDay(trailingPreviewDay, selectedDay)"
|
|
191
|
-
:is-today="isTodayDate(trailingPreviewDay)"
|
|
192
|
-
@select-date="onHandleSelectedDay"
|
|
193
|
-
/>
|
|
194
195
|
</div>
|
|
195
196
|
</Transition>
|
|
196
197
|
</div>
|
|
@@ -19,11 +19,11 @@ const props = withDefaults(
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
const emit = defineEmits<{
|
|
22
|
-
(e: 'select-date', date: Date): void
|
|
22
|
+
(e: 'select-date', date: Date | null): void
|
|
23
23
|
}>()
|
|
24
24
|
|
|
25
25
|
const classes = computed(() => [
|
|
26
|
-
'box-border flex h-[64px] w-[
|
|
26
|
+
'box-border flex h-[64px] w-full max-w-[100px] flex-1 basis-0 flex-col items-center justify-center border-2 border-transparent px-1 py-1 transition-colors cursor-pointer',
|
|
27
27
|
props.disabled ? '' : 'hover:border-2 hover:border-blue-500 border-solid',
|
|
28
28
|
props.disabled ? '' : 'active:bg-blue_t-100 border-transparent',
|
|
29
29
|
props.disabled ? '' : 'focus:outline-none',
|
|
@@ -43,7 +43,7 @@ const weekdayLabelClasses = computed(() => [
|
|
|
43
43
|
|
|
44
44
|
const onClick = () => {
|
|
45
45
|
if (props.disabled) return
|
|
46
|
-
emit('select-date', props.date)
|
|
46
|
+
emit('select-date', props.selected ? null : props.date)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const weekdayLabel = computed(() => {
|
|
@@ -16,7 +16,7 @@ export interface FdsWeekCalendarProps extends /* @vue-ignore */ HTMLAttributes {
|
|
|
16
16
|
disablePreviousWeek?: boolean
|
|
17
17
|
disableNextWeek?: boolean
|
|
18
18
|
enableHorizontalAnimation?: boolean
|
|
19
|
-
|
|
19
|
+
minWeek?: Date
|
|
20
20
|
maxDate?: Date
|
|
21
21
|
previewOtherDays?: boolean
|
|
22
22
|
selected?: Date | null
|
|
@@ -24,4 +24,5 @@ export interface FdsWeekCalendarProps extends /* @vue-ignore */ HTMLAttributes {
|
|
|
24
24
|
onDecrementWeek?: () => void
|
|
25
25
|
onIncrementWeek?: () => void
|
|
26
26
|
onSelectDate?: (date: string | null) => void
|
|
27
|
+
onChangeDateRange?: (dateRange: WeekDateRange, week?: Date) => void
|
|
27
28
|
}
|
|
@@ -42,8 +42,6 @@ export const getDaysInWeek = (weekStart: Date): Date[] => {
|
|
|
42
42
|
|
|
43
43
|
export const getDaysOfLastWeek = (week: Date): Date[] => getDaysInWeek(week)
|
|
44
44
|
|
|
45
|
-
export const getDaysOfNextWeek = (week: Date): Date[] => getDaysInWeek(week)
|
|
46
|
-
|
|
47
45
|
export const getStartAndEndRangeFromWeek = (week: Date[]): Partial<WeekDateRange> => {
|
|
48
46
|
const lastDay = week.at(-1)
|
|
49
47
|
const firstDay = week.at(0)
|