@muenchen/muc-patternlab-vue 1.8.0-beta.6 → 1.8.0-beta.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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shorthand notation of all seven days in german.
3
+ *
4
+ * @typedef {"Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So"} WeekDays
5
+ */
6
+ type WeekDays = "Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So";
7
+ /**
8
+ * @typedef {Object} OpeningHour
9
+ * @property {string} from - The start time of the opening period (in 'HH:mm' format).
10
+ * @property {string} to - The end time of the opening period (in 'HH:mm' format).
11
+ */
12
+ type OpeningHour = {
13
+ from: string;
14
+ to: string;
15
+ };
16
+ /**
17
+ * @typedef {Object} BusinessHourType
18
+ * @property {WeekDays} weekDay - The day of the week for which the opening hours apply.
19
+ * @property {OpeningHour[]} openingHours - A list of opening hours for the specified day of the week.
20
+ */
21
+ type BusinessHourType = {
22
+ weekDay: WeekDays;
23
+ openingHours: OpeningHour[];
24
+ };
25
+ export type { BusinessHourType, OpeningHour, WeekDays };
@@ -0,0 +1,116 @@
1
+ declare const _default: {
2
+ component: {
3
+ new (...args: any[]): import('vue').CreateComponentPublicInstance<Readonly<import('vue').ExtractPropTypes<{
4
+ icon: {
5
+ type: import('vue').PropType<string>;
6
+ default: string;
7
+ };
8
+ businessHours: {
9
+ type: import('vue').PropType<import('./BusinessHourType').BusinessHourType[]>;
10
+ required: true;
11
+ };
12
+ toggleable: {
13
+ type: import('vue').PropType<boolean>;
14
+ default: boolean;
15
+ };
16
+ }>>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<import('vue').ExtractPropTypes<{
17
+ icon: {
18
+ type: import('vue').PropType<string>;
19
+ default: string;
20
+ };
21
+ businessHours: {
22
+ type: import('vue').PropType<import('./BusinessHourType').BusinessHourType[]>;
23
+ required: true;
24
+ };
25
+ toggleable: {
26
+ type: import('vue').PropType<boolean>;
27
+ default: boolean;
28
+ };
29
+ }>>, {
30
+ icon: string;
31
+ toggleable: boolean;
32
+ }, true, {}, {}, {
33
+ P: {};
34
+ B: {};
35
+ D: {};
36
+ C: {};
37
+ M: {};
38
+ Defaults: {};
39
+ }, Readonly<import('vue').ExtractPropTypes<{
40
+ icon: {
41
+ type: import('vue').PropType<string>;
42
+ default: string;
43
+ };
44
+ businessHours: {
45
+ type: import('vue').PropType<import('./BusinessHourType').BusinessHourType[]>;
46
+ required: true;
47
+ };
48
+ toggleable: {
49
+ type: import('vue').PropType<boolean>;
50
+ default: boolean;
51
+ };
52
+ }>>, {}, {}, {}, {}, {
53
+ icon: string;
54
+ toggleable: boolean;
55
+ }>;
56
+ __isFragment?: undefined;
57
+ __isTeleport?: undefined;
58
+ __isSuspense?: undefined;
59
+ } & import('vue').ComponentOptionsBase<Readonly<import('vue').ExtractPropTypes<{
60
+ icon: {
61
+ type: import('vue').PropType<string>;
62
+ default: string;
63
+ };
64
+ businessHours: {
65
+ type: import('vue').PropType<import('./BusinessHourType').BusinessHourType[]>;
66
+ required: true;
67
+ };
68
+ toggleable: {
69
+ type: import('vue').PropType<boolean>;
70
+ default: boolean;
71
+ };
72
+ }>>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
73
+ icon: string;
74
+ toggleable: boolean;
75
+ }, {}, string, {}> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
76
+ $slots: Readonly<{
77
+ hint(): any;
78
+ }> & {
79
+ hint(): any;
80
+ };
81
+ });
82
+ title: string;
83
+ tags: string[];
84
+ parameters: {
85
+ docs: {
86
+ description: {
87
+ component: string;
88
+ };
89
+ };
90
+ };
91
+ };
92
+ export default _default;
93
+ export declare const Default: {
94
+ args: {
95
+ businessHours: {
96
+ weekDay: string;
97
+ openingHours: {
98
+ from: string;
99
+ to: string;
100
+ }[];
101
+ }[];
102
+ toggleable: boolean;
103
+ };
104
+ };
105
+ export declare const Fixed: {
106
+ args: {
107
+ toggleable: boolean;
108
+ businessHours: {
109
+ weekDay: string;
110
+ openingHours: {
111
+ from: string;
112
+ to: string;
113
+ }[];
114
+ }[];
115
+ };
116
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shorthand notation of all seven days in german.
3
+ *
4
+ * @typedef {"Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So"} WeekDays
5
+ */
6
+ type WeekDays = "Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So";
7
+ /**
8
+ * @typedef {Object} OpeningHour
9
+ * @property {string} from - The start time of the opening period (in 'HH:mm' format).
10
+ * @property {string} to - The end time of the opening period (in 'HH:mm' format).
11
+ */
12
+ type OpeningHour = {
13
+ from: string;
14
+ to: string;
15
+ };
16
+ /**
17
+ * @typedef {Object} BusinessHourType
18
+ * @property {WeekDays} weekDay - The day of the week for which the opening hours apply.
19
+ * @property {OpeningHour[]} openingHours - A list of opening hours for the specified day of the week.
20
+ */
21
+ type BusinessHourType = {
22
+ weekDay: WeekDays;
23
+ openingHours: OpeningHour[];
24
+ };
25
+ export type { BusinessHourType, OpeningHour, WeekDays };
@@ -0,0 +1,116 @@
1
+ declare const _default: {
2
+ component: {
3
+ new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
4
+ icon: {
5
+ type: import("vue").PropType<string>;
6
+ default: string;
7
+ };
8
+ businessHours: {
9
+ type: import("vue").PropType<import("./BusinessHourType.js").BusinessHourType[]>;
10
+ required: true;
11
+ };
12
+ toggleable: {
13
+ type: import("vue").PropType<boolean>;
14
+ default: boolean;
15
+ };
16
+ }>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
17
+ icon: {
18
+ type: import("vue").PropType<string>;
19
+ default: string;
20
+ };
21
+ businessHours: {
22
+ type: import("vue").PropType<import("./BusinessHourType.js").BusinessHourType[]>;
23
+ required: true;
24
+ };
25
+ toggleable: {
26
+ type: import("vue").PropType<boolean>;
27
+ default: boolean;
28
+ };
29
+ }>>, {
30
+ icon: string;
31
+ toggleable: boolean;
32
+ }, true, {}, {}, {
33
+ P: {};
34
+ B: {};
35
+ D: {};
36
+ C: {};
37
+ M: {};
38
+ Defaults: {};
39
+ }, Readonly<import("vue").ExtractPropTypes<{
40
+ icon: {
41
+ type: import("vue").PropType<string>;
42
+ default: string;
43
+ };
44
+ businessHours: {
45
+ type: import("vue").PropType<import("./BusinessHourType.js").BusinessHourType[]>;
46
+ required: true;
47
+ };
48
+ toggleable: {
49
+ type: import("vue").PropType<boolean>;
50
+ default: boolean;
51
+ };
52
+ }>>, {}, {}, {}, {}, {
53
+ icon: string;
54
+ toggleable: boolean;
55
+ }>;
56
+ __isFragment?: undefined;
57
+ __isTeleport?: undefined;
58
+ __isSuspense?: undefined;
59
+ } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
60
+ icon: {
61
+ type: import("vue").PropType<string>;
62
+ default: string;
63
+ };
64
+ businessHours: {
65
+ type: import("vue").PropType<import("./BusinessHourType.js").BusinessHourType[]>;
66
+ required: true;
67
+ };
68
+ toggleable: {
69
+ type: import("vue").PropType<boolean>;
70
+ default: boolean;
71
+ };
72
+ }>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
73
+ icon: string;
74
+ toggleable: boolean;
75
+ }, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
76
+ $slots: Readonly<{
77
+ hint(): any;
78
+ }> & {
79
+ hint(): any;
80
+ };
81
+ });
82
+ title: string;
83
+ tags: string[];
84
+ parameters: {
85
+ docs: {
86
+ description: {
87
+ component: string;
88
+ };
89
+ };
90
+ };
91
+ };
92
+ export default _default;
93
+ export declare const Default: {
94
+ args: {
95
+ businessHours: {
96
+ weekDay: string;
97
+ openingHours: {
98
+ from: string;
99
+ to: string;
100
+ }[];
101
+ }[];
102
+ toggleable: boolean;
103
+ };
104
+ };
105
+ export declare const Fixed: {
106
+ args: {
107
+ toggleable: boolean;
108
+ businessHours: {
109
+ weekDay: string;
110
+ openingHours: {
111
+ from: string;
112
+ to: string;
113
+ }[];
114
+ }[];
115
+ };
116
+ };
@@ -0,0 +1,72 @@
1
+ import { BusinessHourType } from "./BusinessHourType";
2
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
3
+ /**
4
+ * This array includes all the opening hours for all days of the week.
5
+ */
6
+ businessHours: BusinessHourType[];
7
+ /**
8
+ * Lets you choose between the toggleable and fixed state of the component.
9
+ * In the fixed state, no toggle button will be shown.
10
+ */
11
+ toggleable?: boolean | undefined;
12
+ /**
13
+ * Choose an icon for the toggle button. The default if none is given is the time icon.
14
+ */
15
+ icon?: string | undefined;
16
+ }>, {
17
+ icon: string;
18
+ toggleable: boolean;
19
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
20
+ /**
21
+ * This array includes all the opening hours for all days of the week.
22
+ */
23
+ businessHours: BusinessHourType[];
24
+ /**
25
+ * Lets you choose between the toggleable and fixed state of the component.
26
+ * In the fixed state, no toggle button will be shown.
27
+ */
28
+ toggleable?: boolean | undefined;
29
+ /**
30
+ * Choose an icon for the toggle button. The default if none is given is the time icon.
31
+ */
32
+ icon?: string | undefined;
33
+ }>, {
34
+ icon: string;
35
+ toggleable: boolean;
36
+ }>>>, {
37
+ icon: string;
38
+ toggleable: boolean;
39
+ }, {}>, Readonly<{
40
+ /**
41
+ * Display a hint beneath all the opening hours.
42
+ */
43
+ hint(): any;
44
+ }> & {
45
+ /**
46
+ * Display a hint beneath all the opening hours.
47
+ */
48
+ hint(): any;
49
+ }>;
50
+ export default _default;
51
+ type __VLS_WithDefaults<P, D> = {
52
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
53
+ default: D[K];
54
+ }> : P[K];
55
+ };
56
+ type __VLS_Prettify<T> = {
57
+ [K in keyof T]: T[K];
58
+ } & {};
59
+ type __VLS_WithTemplateSlots<T, S> = T & {
60
+ new (): {
61
+ $slots: S;
62
+ };
63
+ };
64
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
65
+ type __VLS_TypePropsToOption<T> = {
66
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
67
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
68
+ } : {
69
+ type: import('vue').PropType<T[K]>;
70
+ required: true;
71
+ };
72
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "FabianWilms",
4
4
  "description": "A vue component library of some of the components available from https://patternlab.muenchen.space",
5
5
  "license": "MIT",
6
- "version": "1.8.0-beta.6",
6
+ "version": "1.8.0-beta.7",
7
7
  "private": false,
8
8
  "module": "./dist/muc-patternlab-vue.es.js",
9
9
  "types": "./dist/types/index.d.ts",
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Shorthand notation of all seven days in german.
3
+ *
4
+ * @typedef {"Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So"} WeekDays
5
+ */
6
+ type WeekDays = "Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So";
7
+
8
+ /**
9
+ * @typedef {Object} OpeningHour
10
+ * @property {string} from - The start time of the opening period (in 'HH:mm' format).
11
+ * @property {string} to - The end time of the opening period (in 'HH:mm' format).
12
+ */
13
+ type OpeningHour = {
14
+ from: string;
15
+ to: string;
16
+ };
17
+
18
+ /**
19
+ * @typedef {Object} BusinessHourType
20
+ * @property {WeekDays} weekDay - The day of the week for which the opening hours apply.
21
+ * @property {OpeningHour[]} openingHours - A list of opening hours for the specified day of the week.
22
+ */
23
+ type BusinessHourType = {
24
+ weekDay: WeekDays;
25
+ openingHours: OpeningHour[];
26
+ };
27
+
28
+ export type { BusinessHourType, OpeningHour, WeekDays };
@@ -0,0 +1,108 @@
1
+ import MucBusinessHours from "./MucBusinessHours.vue";
2
+
3
+ export default {
4
+ component: MucBusinessHours,
5
+ title: "MucBusinessHours",
6
+ tags: ["autodocs"],
7
+ // 👇 Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component: `
12
+ The businessHours component is used to display the business hours for each day of the week.
13
+ The current day is highlighted as well as the days that are closed.
14
+ In the toggleable variant, the current day and the opening hours are also displayed on the toggle button.
15
+
16
+ [🔗 Patternlab-Docs](https://patternlab.muenchen.space/?p=viewall-components-business-hours)
17
+ `,
18
+ },
19
+ },
20
+ },
21
+ };
22
+
23
+ const businessHours = [
24
+ {
25
+ weekDay: "Mo",
26
+ openingHours: [
27
+ {
28
+ from: "08:00",
29
+ to: "12:00",
30
+ },
31
+ {
32
+ from: "14:00",
33
+ to: "18:00",
34
+ },
35
+ ],
36
+ },
37
+ {
38
+ weekDay: "Di",
39
+ openingHours: [
40
+ {
41
+ from: "09:00",
42
+ to: "13:00",
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ weekDay: "Mi",
48
+ openingHours: [
49
+ {
50
+ from: "10:00",
51
+ to: "14:00",
52
+ },
53
+ ],
54
+ },
55
+ {
56
+ weekDay: "Do",
57
+ openingHours: [
58
+ {
59
+ from: "08:00",
60
+ to: "12:00",
61
+ },
62
+ {
63
+ from: "15:00",
64
+ to: "19:00",
65
+ },
66
+ ],
67
+ },
68
+ {
69
+ weekDay: "Fr",
70
+ openingHours: [
71
+ {
72
+ from: "08:00",
73
+ to: "12:00",
74
+ },
75
+ {
76
+ from: "13:00",
77
+ to: "17:00",
78
+ },
79
+ ],
80
+ },
81
+ {
82
+ weekDay: "Sa",
83
+ openingHours: [
84
+ {
85
+ from: "10:00",
86
+ to: "13:00",
87
+ },
88
+ ],
89
+ },
90
+ {
91
+ weekDay: "So",
92
+ openingHours: [],
93
+ },
94
+ ];
95
+
96
+ export const Default = {
97
+ args: {
98
+ businessHours: businessHours,
99
+ toggleable: true,
100
+ },
101
+ };
102
+
103
+ export const Fixed = {
104
+ args: {
105
+ ...Default.args,
106
+ toggleable: false,
107
+ },
108
+ };
@@ -0,0 +1,166 @@
1
+ <template>
2
+ <div class="m-business-hours-toggle">
3
+ <h3 class="m-business-hours-toggle__title visually-hidden">
4
+ Öffnungszeiten
5
+ </h3>
6
+ <button
7
+ v-if="toggleable"
8
+ @click="toggleCollapsable"
9
+ class="m-business-hours-toggle__trigger is-open"
10
+ :class="collapsedClass"
11
+ type="button"
12
+ data-bs-toggle="collapse"
13
+ :aria-expanded="!collapsed"
14
+ >
15
+ <svg
16
+ aria-hidden="true"
17
+ class="icon icon--before"
18
+ >
19
+ <use :xlink:href="'#icon-' + icon"></use>
20
+ </svg>
21
+ <div v-if="todaysBusinessHours">
22
+ <span> {{ todaysBusinessHours.weekDay }} geöffnet </span>
23
+ <span
24
+ v-for="(time, index) in todaysBusinessHours.openingHours"
25
+ :key="index"
26
+ >
27
+ {{ time.from }} bis {{ time.to }}
28
+ <span v-if="index < todaysBusinessHours.openingHours.length - 1">
29
+ und
30
+ </span>
31
+ </span>
32
+ </div>
33
+
34
+ <svg
35
+ aria-hidden="true"
36
+ class="icon icon--after"
37
+ >
38
+ <use xlink:href="#icon-chevron-down"></use>
39
+ </svg>
40
+ </button>
41
+ <div
42
+ class="m-business-hours-toggle__content"
43
+ :class="collapseClass"
44
+ >
45
+ <ul class="ml-0">
46
+ <li
47
+ v-for="day in businessHours"
48
+ :key="day.weekDay"
49
+ :class="highlightBusinessDay(day)"
50
+ >
51
+ <span class="weekday">{{ day.weekDay }}</span>
52
+ <span class="hours">
53
+ <div v-if="day.openingHours.length === 0">geschlossen</div>
54
+ <div
55
+ v-else
56
+ v-for="time in day.openingHours"
57
+ :key="time.from"
58
+ >
59
+ {{ time.from }} - {{ time.to }}
60
+ </div>
61
+ </span>
62
+ </li>
63
+ </ul>
64
+ <div
65
+ v-if="slots['hint']"
66
+ class="hint"
67
+ >
68
+ <slot name="hint" />
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </template>
73
+
74
+ <script setup lang="ts">
75
+ import { computed, ref } from "vue";
76
+
77
+ import { BusinessHourType } from "./BusinessHourType";
78
+
79
+ const LOCALES = "de-DE";
80
+
81
+ const props = withDefaults(
82
+ defineProps<{
83
+ /**
84
+ * This array includes all the opening hours for all days of the week.
85
+ */
86
+ businessHours: BusinessHourType[];
87
+
88
+ /**
89
+ * Lets you choose between the toggleable and fixed state of the component.
90
+ * In the fixed state, no toggle button will be shown.
91
+ */
92
+ toggleable?: boolean;
93
+
94
+ /**
95
+ * Choose an icon for the toggle button. The default if none is given is the time icon.
96
+ */
97
+ icon?: string;
98
+ }>(),
99
+ {
100
+ icon: "time",
101
+ toggleable: false,
102
+ }
103
+ );
104
+
105
+ let collapsed = ref(props.toggleable);
106
+
107
+ const slots = defineSlots<{
108
+ /**
109
+ * Display a hint beneath all the opening hours.
110
+ */
111
+ hint(): any;
112
+ }>();
113
+
114
+ /**
115
+ * Toggles the collapsed state of the business hours section.
116
+ */
117
+ const toggleCollapsable = () => {
118
+ collapsed.value = !collapsed.value;
119
+ };
120
+
121
+ /**
122
+ * Computes the CSS class for the collapse state.
123
+ *
124
+ * @returns {string} The CSS class for the collapse state.
125
+ */
126
+ const collapseClass = computed(() => (collapsed.value ? "collapse" : ""));
127
+
128
+ /**
129
+ * Computes the CSS class for the collapsed state.
130
+ *
131
+ * @returns {string} The CSS class for the collapsed state.
132
+ */
133
+ const collapsedClass = computed(() => (collapsed.value ? "collapsed" : ""));
134
+
135
+ /**
136
+ * Computes the short name of today's day.
137
+ *
138
+ * @returns {string} The short name of today's day (e.g., "Mo", "Di").
139
+ */
140
+ const todaysDayShortName = computed(() => {
141
+ const today = new Date();
142
+ return today.toLocaleDateString(LOCALES, { weekday: "short" });
143
+ });
144
+
145
+ /**
146
+ * Highlights the business day based on whether it has opening hours and if it is today's day.
147
+ *
148
+ * @param {BusinessHourType} businessHour - The business hour object to check.
149
+ * @returns {string} The CSS class indicating if the business is open or closed.
150
+ */
151
+ const highlightBusinessDay = (businessHour: BusinessHourType) => {
152
+ if (businessHour.openingHours.length === 0) return "is-closed";
153
+ if (businessHour.weekDay === todaysDayShortName.value) return "is-open";
154
+ };
155
+
156
+ /**
157
+ * Computes today's business hours from the provided business hours.
158
+ *
159
+ * @returns {BusinessHourType | undefined} The business hours for today, if available.
160
+ */
161
+ const todaysBusinessHours = computed(() =>
162
+ props.businessHours.find((curr) => curr.weekDay === todaysDayShortName.value)
163
+ );
164
+ </script>
165
+
166
+ <style scoped></style>