@maas/vue-equipment 0.9.8 → 0.10.0
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/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +7 -0
- package/dist/plugins/MagicConsent/index.d.ts +6 -0
- package/dist/plugins/MagicConsent/index.mjs +9 -0
- package/dist/plugins/MagicConsent/nuxt.d.ts +0 -0
- package/dist/plugins/MagicConsent/nuxt.mjs +27 -0
- package/dist/plugins/MagicConsent/src/components/MagicConsent.vue +305 -0
- package/dist/plugins/MagicConsent/src/components/MagicConsent.vue.d.ts +33 -0
- package/dist/plugins/MagicConsent/src/composables/private/defineConsentApi.d.ts +12 -0
- package/dist/plugins/MagicConsent/src/composables/private/defineConsentApi.mjs +20 -0
- package/dist/plugins/MagicConsent/src/composables/useConsentApi.d.ts +15 -0
- package/dist/plugins/MagicConsent/src/composables/useConsentApi.mjs +86 -0
- package/dist/plugins/MagicConsent/src/composables/useConsentEmitter.d.ts +15 -0
- package/dist/plugins/MagicConsent/src/composables/useConsentEmitter.mjs +9 -0
- package/dist/plugins/MagicConsent/src/types/index.d.ts +20 -0
- package/dist/plugins/MagicConsent/src/types/index.mjs +0 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +9 -9
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +1 -1
- package/dist/plugins/MagicScroll/src/composables/useScrollApi.mjs +10 -10
- package/dist/plugins/MagicToast/demo/DemoToast.vue.d.ts +3 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/utils/index.d.mts +10 -1
- package/dist/utils/index.d.ts +10 -1
- package/dist/utils/index.js +39 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +38 -0
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/nuxt/module.json
CHANGED
package/dist/nuxt/module.mjs
CHANGED
|
@@ -15,6 +15,13 @@ const packages = {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
const functions = [
|
|
18
|
+
{
|
|
19
|
+
name: "MagicConsent",
|
|
20
|
+
"package": "plugins",
|
|
21
|
+
lastUpdated: 1696320008000,
|
|
22
|
+
docs: "https://maas.egineering/vue-equipment/plugins/MagicConsent/",
|
|
23
|
+
description: "consent"
|
|
24
|
+
},
|
|
18
25
|
{
|
|
19
26
|
name: "MagicMarquee",
|
|
20
27
|
"package": "plugins",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Plugin } from 'vue';
|
|
2
|
+
import MagicConsent from './src/components/MagicConsent.vue.js';
|
|
3
|
+
import { useConsentApi } from './src/composables/useConsentApi.js';
|
|
4
|
+
import { useConsentEmitter } from './src/composables/useConsentEmitter.js';
|
|
5
|
+
declare const MagicConsentPlugin: Plugin;
|
|
6
|
+
export { MagicConsentPlugin, MagicConsent, useConsentApi, useConsentEmitter };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import MagicConsent from "./src/components/MagicConsent.vue";
|
|
2
|
+
import { useConsentApi } from "./src/composables/useConsentApi.mjs";
|
|
3
|
+
import { useConsentEmitter } from "./src/composables/useConsentEmitter.mjs";
|
|
4
|
+
const MagicConsentPlugin = {
|
|
5
|
+
install: (app) => {
|
|
6
|
+
app.component("MagicConsent", MagicConsent);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export { MagicConsentPlugin, MagicConsent, useConsentApi, useConsentEmitter };
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineNuxtModule,
|
|
3
|
+
createResolver,
|
|
4
|
+
addComponentsDir,
|
|
5
|
+
addImports
|
|
6
|
+
} from "@nuxt/kit";
|
|
7
|
+
export default defineNuxtModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "@maas/vue-equipment/MagicConsent"
|
|
10
|
+
},
|
|
11
|
+
setup() {
|
|
12
|
+
const resolver = createResolver(import.meta.url);
|
|
13
|
+
addComponentsDir({
|
|
14
|
+
path: resolver.resolve("src/components"),
|
|
15
|
+
global: true,
|
|
16
|
+
pathPrefix: false
|
|
17
|
+
});
|
|
18
|
+
addImports({
|
|
19
|
+
from: "@maas/vue-equipment/plugins/MagicConsent",
|
|
20
|
+
name: "useConsentApi"
|
|
21
|
+
});
|
|
22
|
+
addImports({
|
|
23
|
+
from: "@maas/vue-equipment/plugins/MagicConsent",
|
|
24
|
+
name: "useConsentEmitter"
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<client-only>
|
|
3
|
+
<div class="magic-consent">
|
|
4
|
+
<div class="magic-consent__container">
|
|
5
|
+
<div class="magic-consent__body">
|
|
6
|
+
<slot />
|
|
7
|
+
<div v-show="preferencesVisible" class="magic-consent__preferences">
|
|
8
|
+
<ul class="magic-consent__cookies">
|
|
9
|
+
<li
|
|
10
|
+
v-for="cookie in cookies"
|
|
11
|
+
:key="cookie.key"
|
|
12
|
+
class="magic-consent__cookie"
|
|
13
|
+
>
|
|
14
|
+
<div class="magic-consent-checkbox">
|
|
15
|
+
<input
|
|
16
|
+
:id="cookie.key"
|
|
17
|
+
type="checkbox"
|
|
18
|
+
:checked="
|
|
19
|
+
cookie.optional === false
|
|
20
|
+
? true
|
|
21
|
+
: selectedCookies[cookie.key]
|
|
22
|
+
"
|
|
23
|
+
@change="toggleSelection(cookie.key)"
|
|
24
|
+
:disabled="cookie.optional === false"
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
<div>
|
|
28
|
+
<slot :name="cookie.key" :cookie="cookie">
|
|
29
|
+
<div class="magic-consent__cookie__content">
|
|
30
|
+
<div class="magic-consent__cookie__title">
|
|
31
|
+
<span v-text="cookie.title" />
|
|
32
|
+
</div>
|
|
33
|
+
<div
|
|
34
|
+
v-if="cookie.text"
|
|
35
|
+
class="magic-consent__cookie__text"
|
|
36
|
+
v-html="cookie.text"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</slot>
|
|
40
|
+
</div>
|
|
41
|
+
</li>
|
|
42
|
+
</ul>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="magic-consent__footer">
|
|
46
|
+
<slot name="actions">
|
|
47
|
+
<div class="magic-consent__actions">
|
|
48
|
+
<template v-if="preferencesVisible">
|
|
49
|
+
<button
|
|
50
|
+
class="magic-consent-button -secondary"
|
|
51
|
+
@click="preferencesVisible = !preferencesVisible"
|
|
52
|
+
>
|
|
53
|
+
Close
|
|
54
|
+
</button>
|
|
55
|
+
<button
|
|
56
|
+
class="magic-consent-button -secondary"
|
|
57
|
+
@click="acceptSelected"
|
|
58
|
+
>
|
|
59
|
+
Accept selected
|
|
60
|
+
</button>
|
|
61
|
+
</template>
|
|
62
|
+
<template v-else>
|
|
63
|
+
<button
|
|
64
|
+
class="magic-consent-button -secondary"
|
|
65
|
+
@click="preferencesVisible = true"
|
|
66
|
+
>
|
|
67
|
+
Preferences
|
|
68
|
+
</button>
|
|
69
|
+
<button class="magic-consent-button -secondary" @click="reject">
|
|
70
|
+
Reject
|
|
71
|
+
</button>
|
|
72
|
+
</template>
|
|
73
|
+
<button class="magic-consent-button -primary" @click="accept">
|
|
74
|
+
Accept
|
|
75
|
+
</button>
|
|
76
|
+
</div>
|
|
77
|
+
</slot>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</client-only>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<script lang="ts" setup>
|
|
85
|
+
import { defineConsentApi } from '../composables/private/defineConsentApi'
|
|
86
|
+
import { useConsentApi } from '../composables/useConsentApi'
|
|
87
|
+
import type { ConsentCookieRecord } from '../types'
|
|
88
|
+
|
|
89
|
+
// Define the props and their default values
|
|
90
|
+
type Props = {
|
|
91
|
+
cookies: ConsentCookieRecord[]
|
|
92
|
+
maxAge?: number
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
96
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// Initialize the Consent API
|
|
100
|
+
defineConsentApi({
|
|
101
|
+
cookies: props.cookies,
|
|
102
|
+
maxAge: props.maxAge,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// Use the Consent API
|
|
106
|
+
const {
|
|
107
|
+
preferencesVisible,
|
|
108
|
+
selectedCookies,
|
|
109
|
+
accept,
|
|
110
|
+
acceptSelected,
|
|
111
|
+
reject,
|
|
112
|
+
toggleSelection,
|
|
113
|
+
} = useConsentApi()
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<style lang="css">
|
|
117
|
+
:root {
|
|
118
|
+
--magic-consent-max-width: 480px;
|
|
119
|
+
--magic-consent-max-height: calc(100vh - 2rem);
|
|
120
|
+
--magic-consent-background-color: rgba(75, 75, 75, 0.5);
|
|
121
|
+
--magic-consent-backdrop-filter: blur(32px);
|
|
122
|
+
--magic-consent-color: rgba(255, 255, 255);
|
|
123
|
+
--magic-consent-border-radius: 0;
|
|
124
|
+
--magic-consent-box-shadow: none;
|
|
125
|
+
--magic-consent-preferences-mask: linear-gradient(
|
|
126
|
+
to top,
|
|
127
|
+
rgb(255 255 255 / 0%),
|
|
128
|
+
rgb(255 255 255 / 100%) 1.5rem
|
|
129
|
+
);
|
|
130
|
+
--magic-consent-checkbox-size: 0.875rem;
|
|
131
|
+
--magic-consent-checkbox-border-width: 1px;
|
|
132
|
+
--magic-consent-checkbox-border-color: currentColor;
|
|
133
|
+
--magic-consent-checkbox-border-radius: 0;
|
|
134
|
+
|
|
135
|
+
--magic-consent-button-width: auto;
|
|
136
|
+
--magic-consent-button-height: 2.5rem;
|
|
137
|
+
--magic-consent-button-spacing: 1rem;
|
|
138
|
+
--magic-consent-button-border-width: 1px;
|
|
139
|
+
--magic-consent-button-border-radius: 0.25rem;
|
|
140
|
+
--magic-consent-button-backdrop-filter: none;
|
|
141
|
+
|
|
142
|
+
--magic-consent-button-primary-color: rgb(0, 0, 0);
|
|
143
|
+
--magic-consent-button-primary-background-color: rgb(255 255 255);
|
|
144
|
+
--magic-consent-button-primary-border-color: transparent;
|
|
145
|
+
|
|
146
|
+
--magic-consent-button-secondary-color: rgb(255, 255, 255);
|
|
147
|
+
--magic-consent-button-secondary-background-color: transparent;
|
|
148
|
+
--magic-consent-button-secondary-border-color: transparent;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.magic-consent {
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
width: 100%;
|
|
155
|
+
max-width: var(--magic-consent-max-width);
|
|
156
|
+
border-radius: var(--magic-consent-border-radius);
|
|
157
|
+
background-color: var(--magic-consent-background-color);
|
|
158
|
+
color: var(--magic-consent-color);
|
|
159
|
+
box-shadow: var(--magic-consent-box-shadow);
|
|
160
|
+
backdrop-filter: var(--magic-consent-backdrop-filter);
|
|
161
|
+
-webkit-backdrop-filter: var(--magic-consent-backdrop-filter);
|
|
162
|
+
overflow: hidden;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.magic-consent__container {
|
|
166
|
+
width: 100%;
|
|
167
|
+
max-height: var(--magic-consent-max-height);
|
|
168
|
+
display: flex;
|
|
169
|
+
flex-direction: column;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.magic-consent__body {
|
|
173
|
+
width: 100%;
|
|
174
|
+
height: 100%;
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-direction: column;
|
|
177
|
+
gap: 1rem;
|
|
178
|
+
padding: 1rem;
|
|
179
|
+
mask: var(--magic-consent-preferences-mask);
|
|
180
|
+
-webkit-mask: var(--magic-consent-preferences-mask);
|
|
181
|
+
overflow-y: scroll;
|
|
182
|
+
-webkit-overflow-scrolling: touch;
|
|
183
|
+
scroll-behavior: smooth;
|
|
184
|
+
-ms-overflow-style: none;
|
|
185
|
+
scrollbar-width: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.magic-consent__body::-webkit-scrollbar {
|
|
189
|
+
display: none;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.magic-consent__footer {
|
|
193
|
+
width: 100%;
|
|
194
|
+
padding: 1rem;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.magic-consent__preferences {
|
|
198
|
+
width: 100%;
|
|
199
|
+
height: 100%;
|
|
200
|
+
display: flex;
|
|
201
|
+
flex-direction: column;
|
|
202
|
+
gap: 1rem;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.magic-consent__actions {
|
|
206
|
+
width: 100%;
|
|
207
|
+
display: flex;
|
|
208
|
+
gap: 1rem;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
ul.magic-consent__cookies {
|
|
212
|
+
padding: 0;
|
|
213
|
+
margin: 0;
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
216
|
+
gap: 1rem;
|
|
217
|
+
list-style: none;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
li.magic-consent__cookie {
|
|
221
|
+
padding: 0;
|
|
222
|
+
margin: 0;
|
|
223
|
+
display: flex;
|
|
224
|
+
gap: 1rem;
|
|
225
|
+
align-items: flex-start;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.magic-consent__cookie__content {
|
|
229
|
+
display: flex;
|
|
230
|
+
flex-direction: column;
|
|
231
|
+
gap: 0.25rem;
|
|
232
|
+
align-items: flex-start;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.magic-consent__cookie__title {
|
|
236
|
+
display: inline-flex;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.magic-consent__cookie__text {
|
|
240
|
+
white-space: pre-line;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.magic-consent-checkbox {
|
|
244
|
+
display: flex;
|
|
245
|
+
gap: 0.625rem;
|
|
246
|
+
align-items: center;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.magic-consent-checkbox input[type='checkbox'] {
|
|
250
|
+
position: relative;
|
|
251
|
+
flex-shrink: 0;
|
|
252
|
+
width: var(--magic-consent-checkbox-size);
|
|
253
|
+
height: var(--magic-consent-checkbox-size);
|
|
254
|
+
background-color: transparent;
|
|
255
|
+
border: var(--magic-consent-checkbox-border-width)
|
|
256
|
+
var(--magic-consent-checkbox-border-color) solid;
|
|
257
|
+
vertical-align: middle;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
appearance: none;
|
|
260
|
+
border-radius: var(--magic-consent-checkbox-border-radius);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.magic-consent-checkbox input[type='checkbox']:checked::after {
|
|
264
|
+
content: '';
|
|
265
|
+
display: block;
|
|
266
|
+
position: absolute;
|
|
267
|
+
width: calc(var(--magic-consent-checkbox-size) / 2);
|
|
268
|
+
height: calc(var(--magic-consent-checkbox-size) / 2);
|
|
269
|
+
top: 50%;
|
|
270
|
+
left: 50%;
|
|
271
|
+
transform: translate(-50%, -50%);
|
|
272
|
+
background-color: var(--magic-consent-checkbox-border-color);
|
|
273
|
+
border-radius: var(--magic-consent-checkbox-border-radius);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.magic-consent-checkbox:disabled {
|
|
277
|
+
cursor: not-allowed;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.magic-consent-button {
|
|
281
|
+
display: inline-flex;
|
|
282
|
+
align-items: center;
|
|
283
|
+
justify-content: center;
|
|
284
|
+
width: var(--magic-consent-button-width);
|
|
285
|
+
height: var(--magic-consent-button-height);
|
|
286
|
+
border: var(--magic-consent-button-border-width) solid currentColor;
|
|
287
|
+
padding: 0 var(--magic-consent-button-spacing);
|
|
288
|
+
gap: var(--magic-consent-button-spacing);
|
|
289
|
+
border-radius: var(--magic-consent-button-border-radius);
|
|
290
|
+
backdrop-filter: var(--magic-consent-button-backdrop-filter);
|
|
291
|
+
-webkit-backdrop-filter: var(--magic-consent-button-backdrop-filter);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.magic-consent-button.-primary {
|
|
295
|
+
color: var(--magic-consent-button-primary-color);
|
|
296
|
+
background-color: var(--magic-consent-button-primary-background-color);
|
|
297
|
+
border-color: var(--magic-consent-button-primary-border-color);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.magic-consent-button.-secondary {
|
|
301
|
+
color: var(--magic-consent-button-secondary-color);
|
|
302
|
+
background-color: var(--magic-consent-button-secondary-background-color);
|
|
303
|
+
border-color: var(--magic-consent-button-secondary-border-color);
|
|
304
|
+
}
|
|
305
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ConsentCookieRecord } from '../types';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
3
|
+
cookies: {
|
|
4
|
+
type: import("vue").PropType<ConsentCookieRecord[]>;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
maxAge: {
|
|
8
|
+
type: import("vue").PropType<number>;
|
|
9
|
+
default: number;
|
|
10
|
+
};
|
|
11
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
|
+
cookies: {
|
|
13
|
+
type: import("vue").PropType<ConsentCookieRecord[]>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
maxAge: {
|
|
17
|
+
type: import("vue").PropType<number>;
|
|
18
|
+
default: number;
|
|
19
|
+
};
|
|
20
|
+
}>>, {
|
|
21
|
+
maxAge: number;
|
|
22
|
+
}, {}>, Partial<Record<string, (_: {
|
|
23
|
+
cookie: ConsentCookieRecord;
|
|
24
|
+
}) => any>> & {
|
|
25
|
+
default?(_: {}): any;
|
|
26
|
+
actions?(_: {}): any;
|
|
27
|
+
}>;
|
|
28
|
+
export default _default;
|
|
29
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
30
|
+
new (): {
|
|
31
|
+
$slots: S;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConsentApiDefinition } from '../../types.js';
|
|
2
|
+
export declare const globalApiState: import("vue").Ref<{
|
|
3
|
+
cookies: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
key: string;
|
|
6
|
+
optional?: boolean | undefined;
|
|
7
|
+
title?: string | undefined;
|
|
8
|
+
text?: string | undefined;
|
|
9
|
+
}[];
|
|
10
|
+
maxAge: number | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function defineConsentApi({ cookies, maxAge }: ConsentApiDefinition): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { slugify } from "@maas/vue-equipment/utils";
|
|
3
|
+
export const globalApiState = ref({
|
|
4
|
+
cookies: {},
|
|
5
|
+
maxAge: void 0
|
|
6
|
+
});
|
|
7
|
+
export function defineConsentApi({ cookies, maxAge }) {
|
|
8
|
+
if (!Array.isArray(cookies)) {
|
|
9
|
+
console.warn('Invalid configuration. "cookies" must be an array.');
|
|
10
|
+
}
|
|
11
|
+
globalApiState.value.cookies = cookies?.map((cookie) => ({
|
|
12
|
+
...cookie,
|
|
13
|
+
key: slugify(cookie.key, {
|
|
14
|
+
separator: "_",
|
|
15
|
+
lowercase: true,
|
|
16
|
+
strict: true
|
|
17
|
+
})
|
|
18
|
+
}));
|
|
19
|
+
globalApiState.value.maxAge = maxAge;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CookieConsentData } from '../types.js';
|
|
2
|
+
export declare function useConsentApi(): {
|
|
3
|
+
preferencesVisible: import("vue").Ref<boolean>;
|
|
4
|
+
selectedCookies: import("vue").Ref<{
|
|
5
|
+
[key: string]: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
cookieConsentData: import("vue").WritableComputedRef<CookieConsentData>;
|
|
8
|
+
toggleSelection: (key: string) => void;
|
|
9
|
+
accept: () => void;
|
|
10
|
+
acceptSelected: () => void;
|
|
11
|
+
reject: () => void;
|
|
12
|
+
onAccept: (handler: (args: CookieConsentData) => void) => void;
|
|
13
|
+
onAcceptSelected: (handler: (args: CookieConsentData) => void) => void;
|
|
14
|
+
onReject: (handler: (args: CookieConsentData) => void) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
import { useCookies } from "@vueuse/integrations/useCookies";
|
|
3
|
+
import { toValue } from "@vueuse/core";
|
|
4
|
+
import { globalApiState } from "./private/defineConsentApi.mjs";
|
|
5
|
+
import { useConsentEmitter } from "./useConsentEmitter.mjs";
|
|
6
|
+
const universalCookies = useCookies(["cookie_consent"]);
|
|
7
|
+
const preferencesVisible = ref(false);
|
|
8
|
+
const selectedCookies = ref({});
|
|
9
|
+
const cookieConsentData = computed({
|
|
10
|
+
get: () => {
|
|
11
|
+
return universalCookies.get("cookie_consent");
|
|
12
|
+
},
|
|
13
|
+
set: (value) => {
|
|
14
|
+
universalCookies.set("cookie_consent", value, {
|
|
15
|
+
maxAge: globalApiState.value?.maxAge
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export function useConsentApi() {
|
|
20
|
+
const emitter = useConsentEmitter();
|
|
21
|
+
selectedCookies.value = cookieConsentData.value?.cookies || {};
|
|
22
|
+
function toggleSelection(key) {
|
|
23
|
+
selectedCookies.value = {
|
|
24
|
+
...selectedCookies.value,
|
|
25
|
+
[key]: !selectedCookies.value[key]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function accept() {
|
|
29
|
+
const cookies = globalApiState.value?.cookies?.reduce(
|
|
30
|
+
(result, cookie) => {
|
|
31
|
+
result[cookie.key] = true;
|
|
32
|
+
return result;
|
|
33
|
+
},
|
|
34
|
+
{}
|
|
35
|
+
);
|
|
36
|
+
selectedCookies.value = cookies;
|
|
37
|
+
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
38
|
+
cookieConsentData.value = { timestamp, cookies };
|
|
39
|
+
emitter.emit("accept", cookieConsentData.value);
|
|
40
|
+
}
|
|
41
|
+
function acceptSelected() {
|
|
42
|
+
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
43
|
+
cookieConsentData.value = {
|
|
44
|
+
timestamp,
|
|
45
|
+
cookies: selectedCookies.value
|
|
46
|
+
};
|
|
47
|
+
emitter.emit("acceptSelected", cookieConsentData.value);
|
|
48
|
+
}
|
|
49
|
+
function reject() {
|
|
50
|
+
const cookies = globalApiState.value?.cookies?.reduce(
|
|
51
|
+
(result, cookie) => {
|
|
52
|
+
result[cookie.key] = cookie.optional === false ? true : false;
|
|
53
|
+
return result;
|
|
54
|
+
},
|
|
55
|
+
{}
|
|
56
|
+
);
|
|
57
|
+
selectedCookies.value = cookies;
|
|
58
|
+
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
59
|
+
cookieConsentData.value = { timestamp, cookies };
|
|
60
|
+
emitter.emit("reject", cookieConsentData.value);
|
|
61
|
+
}
|
|
62
|
+
function onAccept(handler) {
|
|
63
|
+
emitter.on("accept", (args) => handler(toValue(args)));
|
|
64
|
+
}
|
|
65
|
+
function onAcceptSelected(handler) {
|
|
66
|
+
emitter.on(
|
|
67
|
+
"acceptSelected",
|
|
68
|
+
(args) => handler(toValue(args))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
function onReject(handler) {
|
|
72
|
+
emitter.on("reject", (args) => handler(toValue(args)));
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
preferencesVisible,
|
|
76
|
+
selectedCookies,
|
|
77
|
+
cookieConsentData,
|
|
78
|
+
toggleSelection,
|
|
79
|
+
accept,
|
|
80
|
+
acceptSelected,
|
|
81
|
+
reject,
|
|
82
|
+
onAccept,
|
|
83
|
+
onAcceptSelected,
|
|
84
|
+
onReject
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConsentEvents } from '../types.js';
|
|
2
|
+
export declare function useConsentEmitter(): {
|
|
3
|
+
on: {
|
|
4
|
+
<Key extends keyof ConsentEvents>(type: Key, handler: import("mitt").Handler<ConsentEvents[Key]>): void;
|
|
5
|
+
(type: "*", handler: import("mitt").WildcardHandler<ConsentEvents>): void;
|
|
6
|
+
};
|
|
7
|
+
off: {
|
|
8
|
+
<Key_1 extends keyof ConsentEvents>(type: Key_1, handler?: import("mitt").Handler<ConsentEvents[Key_1]> | undefined): void;
|
|
9
|
+
(type: "*", handler: import("mitt").WildcardHandler<ConsentEvents>): void;
|
|
10
|
+
};
|
|
11
|
+
emit: {
|
|
12
|
+
<Key_2 extends keyof ConsentEvents>(type: Key_2, event: ConsentEvents[Key_2]): void;
|
|
13
|
+
<Key_3 extends keyof ConsentEvents>(type: undefined extends ConsentEvents[Key_3] ? Key_3 : never): void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ConsentApiDefinition = {
|
|
2
|
+
cookies: ConsentCookieRecord[];
|
|
3
|
+
maxAge?: number;
|
|
4
|
+
};
|
|
5
|
+
export type ConsentCookieRecord = {
|
|
6
|
+
key: string;
|
|
7
|
+
optional?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
export type CookieConsentData = {
|
|
13
|
+
timestamp: number | undefined;
|
|
14
|
+
cookies: Record<string, boolean>;
|
|
15
|
+
};
|
|
16
|
+
export type ConsentEvents = {
|
|
17
|
+
accept: CookieConsentData;
|
|
18
|
+
reject: CookieConsentData;
|
|
19
|
+
acceptSelected: CookieConsentData;
|
|
20
|
+
};
|
|
File without changes
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { type Easing } from 'motion';
|
|
2
2
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
3
|
-
offset: {
|
|
4
|
-
type: import("vue").PropType<number[]>;
|
|
5
|
-
default: undefined;
|
|
6
|
-
};
|
|
7
3
|
keyframes: {
|
|
8
4
|
type: import("vue").PropType<Record<string, any> | null | undefined>;
|
|
9
5
|
required: true;
|
|
10
6
|
default: undefined;
|
|
11
7
|
};
|
|
8
|
+
offset: {
|
|
9
|
+
type: import("vue").PropType<number[]>;
|
|
10
|
+
default: undefined;
|
|
11
|
+
};
|
|
12
12
|
easing: {
|
|
13
13
|
type: import("vue").PropType<Easing>;
|
|
14
14
|
default: string;
|
|
15
15
|
};
|
|
16
16
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
|
-
offset: {
|
|
18
|
-
type: import("vue").PropType<number[]>;
|
|
19
|
-
default: undefined;
|
|
20
|
-
};
|
|
21
17
|
keyframes: {
|
|
22
18
|
type: import("vue").PropType<Record<string, any> | null | undefined>;
|
|
23
19
|
required: true;
|
|
24
20
|
default: undefined;
|
|
25
21
|
};
|
|
22
|
+
offset: {
|
|
23
|
+
type: import("vue").PropType<number[]>;
|
|
24
|
+
default: undefined;
|
|
25
|
+
};
|
|
26
26
|
easing: {
|
|
27
27
|
type: import("vue").PropType<Easing>;
|
|
28
28
|
default: string;
|
|
29
29
|
};
|
|
30
30
|
}>>, {
|
|
31
|
-
offset: number[];
|
|
32
31
|
keyframes: Record<string, any> | null | undefined;
|
|
32
|
+
offset: number[];
|
|
33
33
|
easing: Easing;
|
|
34
34
|
}, {}>, {
|
|
35
35
|
default?(_: {}): any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, inject, toValue } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { useWindowSize } from "@vueuse/core";
|
|
3
3
|
import { ScrollPositionKey } from "../symbols/index.mjs";
|
|
4
4
|
import { clampValue } from "@maas/vue-equipment/utils";
|
|
5
5
|
export function useScrollApi(params) {
|
|
@@ -9,13 +9,13 @@ export function useScrollApi(params) {
|
|
|
9
9
|
const parentRect = ref();
|
|
10
10
|
const start = ref(0);
|
|
11
11
|
const end = ref(0);
|
|
12
|
-
|
|
12
|
+
function splitLocation(location) {
|
|
13
13
|
return {
|
|
14
14
|
child: location.match(/^[a-z]+/)[0],
|
|
15
15
|
parent: location.match(/[a-z]+$/)[0]
|
|
16
16
|
};
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
function getOffsetTop(points) {
|
|
19
19
|
let y = 0;
|
|
20
20
|
if (!childRect.value)
|
|
21
21
|
return y;
|
|
@@ -53,18 +53,18 @@ export function useScrollApi(params) {
|
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
55
|
return y;
|
|
56
|
-
}
|
|
57
|
-
|
|
56
|
+
}
|
|
57
|
+
function getCalculations() {
|
|
58
58
|
childRect.value = toValue(child)?.getBoundingClientRect();
|
|
59
|
-
parentRect.value = toValue(parent) ?
|
|
59
|
+
parentRect.value = toValue(parent) ? toValue(parent)?.getBoundingClientRect() : { ...useWindowSize(), top: 0 };
|
|
60
60
|
start.value = getOffsetTop(splitLocation(from));
|
|
61
61
|
end.value = getOffsetTop(splitLocation(to));
|
|
62
|
-
}
|
|
63
|
-
|
|
62
|
+
}
|
|
63
|
+
function getProgress() {
|
|
64
64
|
const scrollY = toValue(scrollPosition?.y) || 0;
|
|
65
65
|
const total = Math.abs(end.value - start.value);
|
|
66
66
|
const current = scrollY - start.value;
|
|
67
67
|
return clampValue(current / total, 0, 1);
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
return { getCalculations, getProgress };
|
|
70
70
|
}
|
|
@@ -3,7 +3,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
3
3
|
type: import("vue").PropType<string>;
|
|
4
4
|
required: true;
|
|
5
5
|
};
|
|
6
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin,
|
|
6
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
|
+
close: (...args: any[]) => void;
|
|
8
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7
9
|
message: {
|
|
8
10
|
type: import("vue").PropType<string>;
|
|
9
11
|
required: true;
|
package/dist/plugins/index.d.ts
CHANGED
package/dist/plugins/index.mjs
CHANGED
package/dist/utils/index.d.mts
CHANGED
|
@@ -8,4 +8,13 @@ declare function uuid(): string;
|
|
|
8
8
|
|
|
9
9
|
declare function uniq<T extends any[]>(a: T): any[];
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface SlugifyOptions {
|
|
12
|
+
separator?: string;
|
|
13
|
+
trim?: boolean;
|
|
14
|
+
remove?: RegExp;
|
|
15
|
+
strict?: boolean;
|
|
16
|
+
lowercase?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare function slugify(string: string, options?: SlugifyOptions): string;
|
|
19
|
+
|
|
20
|
+
export { SlugifyOptions, clampValue, isIOS, mapValue, slugify, uniq, uuid };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -8,4 +8,13 @@ declare function uuid(): string;
|
|
|
8
8
|
|
|
9
9
|
declare function uniq<T extends any[]>(a: T): any[];
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface SlugifyOptions {
|
|
12
|
+
separator?: string;
|
|
13
|
+
trim?: boolean;
|
|
14
|
+
remove?: RegExp;
|
|
15
|
+
strict?: boolean;
|
|
16
|
+
lowercase?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare function slugify(string: string, options?: SlugifyOptions): string;
|
|
19
|
+
|
|
20
|
+
export { SlugifyOptions, clampValue, isIOS, mapValue, slugify, uniq, uuid };
|
package/dist/utils/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(utils_exports, {
|
|
|
23
23
|
clampValue: () => clampValue,
|
|
24
24
|
isIOS: () => isIOS,
|
|
25
25
|
mapValue: () => mapValue,
|
|
26
|
+
slugify: () => slugify,
|
|
26
27
|
uniq: () => uniq,
|
|
27
28
|
uuid: () => uuid
|
|
28
29
|
});
|
|
@@ -57,11 +58,49 @@ function uuid() {
|
|
|
57
58
|
function uniq(a) {
|
|
58
59
|
return Array.from(new Set(a));
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
// src/functions/slugify.ts
|
|
63
|
+
var defaultOptions = {
|
|
64
|
+
separator: "-",
|
|
65
|
+
trim: true,
|
|
66
|
+
remove: void 0,
|
|
67
|
+
strict: true,
|
|
68
|
+
lowercase: true
|
|
69
|
+
};
|
|
70
|
+
function slugify(string, options) {
|
|
71
|
+
if (typeof string !== "string") {
|
|
72
|
+
throw new Error("slugify: string argument expected");
|
|
73
|
+
}
|
|
74
|
+
const _options = { ...defaultOptions, ...options };
|
|
75
|
+
const charMap = {};
|
|
76
|
+
let slug = string.normalize().split("").reduce(function(result, ch) {
|
|
77
|
+
let appendChar = charMap[ch];
|
|
78
|
+
if (appendChar === void 0)
|
|
79
|
+
appendChar = ch;
|
|
80
|
+
if (appendChar === _options?.separator)
|
|
81
|
+
appendChar = " ";
|
|
82
|
+
return result + appendChar.replace(_options?.remove || /[^\w\s$*_+~.()'"!\-:@]+/g, "");
|
|
83
|
+
}, "");
|
|
84
|
+
if (_options.strict) {
|
|
85
|
+
slug = slug.replace(/[^A-Za-z0-9\s]/g, "");
|
|
86
|
+
}
|
|
87
|
+
if (_options.trim) {
|
|
88
|
+
slug = slug.trim();
|
|
89
|
+
}
|
|
90
|
+
if (_options.separator) {
|
|
91
|
+
slug = slug.replace(/ +/g, _options.separator);
|
|
92
|
+
}
|
|
93
|
+
if (_options.lowercase) {
|
|
94
|
+
slug = slug.toLocaleLowerCase();
|
|
95
|
+
}
|
|
96
|
+
return slug;
|
|
97
|
+
}
|
|
60
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
99
|
0 && (module.exports = {
|
|
62
100
|
clampValue,
|
|
63
101
|
isIOS,
|
|
64
102
|
mapValue,
|
|
103
|
+
slugify,
|
|
65
104
|
uniq,
|
|
66
105
|
uuid
|
|
67
106
|
});
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/utils/index.ts","../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/uuid.ts","../../packages/utils/src/functions/uniq.ts"],"sourcesContent":["export * from './src/functions/clampValue'\nexport * from './src/functions/isIOS'\nexport * from './src/functions/mapValue'\nexport * from './src/functions/uuid'\nexport * from './src/functions/uniq'\n","export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","// This implementation is meant for internal use only.\n// It is only used to generate a unique IDs for the `key` props.\n// It should not replace crypto.randomUUID() or window.crypto.randomUUID().\n\nexport function uuid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'\n .split('')\n .reduce(\n (c, i) =>\n c +\n (i === 'x'\n ? Math.floor(Math.random() * 0xf).toString(16)\n : i === 'y'\n ? Math.floor(Math.random() * 4 + 8).toString(16)\n : i),\n '',\n )\n}\n","export function uniq<T extends any[]>(a: T) {\n return Array.from(new Set(a))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACJO,SAAS,OAAO;AACrB,SAAO,uCACJ,MAAM,EAAE,EACR;AAAA,IACC,CAAC,GAAG,MACF,KACC,MAAM,MACH,KAAK,MAAM,KAAK,OAAO,IAAI,EAAG,EAAE,SAAS,EAAE,IAC3C,MAAM,MACN,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,EAAE,SAAS,EAAE,IAC7C;AAAA,IACN;AAAA,EACF;AACJ;;;ACjBO,SAAS,KAAsB,GAAM;AAC1C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../packages/utils/index.ts","../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/uuid.ts","../../packages/utils/src/functions/uniq.ts","../../packages/utils/src/functions/slugify.ts"],"sourcesContent":["export * from './src/functions/clampValue'\nexport * from './src/functions/isIOS'\nexport * from './src/functions/mapValue'\nexport * from './src/functions/uuid'\nexport * from './src/functions/uniq'\nexport * from './src/functions/slugify'\n","export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","// This implementation is meant for internal use only.\n// It is only used to generate a unique IDs for the `key` props.\n// It should not replace crypto.randomUUID() or window.crypto.randomUUID().\n\nexport function uuid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'\n .split('')\n .reduce(\n (c, i) =>\n c +\n (i === 'x'\n ? Math.floor(Math.random() * 0xf).toString(16)\n : i === 'y'\n ? Math.floor(Math.random() * 4 + 8).toString(16)\n : i),\n '',\n )\n}\n","export function uniq<T extends any[]>(a: T) {\n return Array.from(new Set(a))\n}\n","export interface SlugifyOptions {\n separator?: string\n trim?: boolean\n remove?: RegExp\n strict?: boolean\n lowercase?: boolean\n}\n\nconst defaultOptions: SlugifyOptions = {\n separator: '-',\n trim: true,\n remove: undefined,\n strict: true,\n lowercase: true,\n}\n\nexport function slugify(string: string, options?: SlugifyOptions): string {\n if (typeof string !== 'string') {\n throw new Error('slugify: string argument expected')\n }\n\n // Merge provided options with default options\n const _options = { ...defaultOptions, ...options }\n\n const charMap: { [key: string]: string } = {}\n\n let slug = string\n .normalize()\n .split('')\n .reduce(function (result, ch) {\n let appendChar = charMap[ch]\n if (appendChar === undefined) appendChar = ch\n if (appendChar === _options?.separator) appendChar = ' '\n return (\n result +\n appendChar.replace(_options?.remove || /[^\\w\\s$*_+~.()'\"!\\-:@]+/g, '')\n )\n }, '')\n\n if (_options.strict) {\n slug = slug.replace(/[^A-Za-z0-9\\s]/g, '')\n }\n\n if (_options.trim) {\n slug = slug.trim()\n }\n\n if (_options.separator) {\n slug = slug.replace(/ +/g, _options.separator)\n }\n\n if (_options.lowercase) {\n slug = slug.toLocaleLowerCase()\n }\n\n return slug\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACJO,SAAS,OAAO;AACrB,SAAO,uCACJ,MAAM,EAAE,EACR;AAAA,IACC,CAAC,GAAG,MACF,KACC,MAAM,MACH,KAAK,MAAM,KAAK,OAAO,IAAI,EAAG,EAAE,SAAS,EAAE,IAC3C,MAAM,MACN,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,EAAE,SAAS,EAAE,IAC7C;AAAA,IACN;AAAA,EACF;AACJ;;;ACjBO,SAAS,KAAsB,GAAM;AAC1C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;;;ACMA,IAAM,iBAAiC;AAAA,EACrC,WAAW;AAAA,EACX,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AACb;AAEO,SAAS,QAAQ,QAAgB,SAAkC;AACxE,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAGA,QAAM,WAAW,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAEjD,QAAM,UAAqC,CAAC;AAE5C,MAAI,OAAO,OACR,UAAU,EACV,MAAM,EAAE,EACR,OAAO,SAAU,QAAQ,IAAI;AAC5B,QAAI,aAAa,QAAQ,EAAE;AAC3B,QAAI,eAAe;AAAW,mBAAa;AAC3C,QAAI,eAAe,UAAU;AAAW,mBAAa;AACrD,WACE,SACA,WAAW,QAAQ,UAAU,UAAU,4BAA4B,EAAE;AAAA,EAEzE,GAAG,EAAE;AAEP,MAAI,SAAS,QAAQ;AACnB,WAAO,KAAK,QAAQ,mBAAmB,EAAE;AAAA,EAC3C;AAEA,MAAI,SAAS,MAAM;AACjB,WAAO,KAAK,KAAK;AAAA,EACnB;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,QAAQ,OAAO,SAAS,SAAS;AAAA,EAC/C;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,kBAAkB;AAAA,EAChC;AAEA,SAAO;AACT;","names":[]}
|
package/dist/utils/index.mjs
CHANGED
|
@@ -27,10 +27,48 @@ function uuid() {
|
|
|
27
27
|
function uniq(a) {
|
|
28
28
|
return Array.from(new Set(a));
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
// src/functions/slugify.ts
|
|
32
|
+
var defaultOptions = {
|
|
33
|
+
separator: "-",
|
|
34
|
+
trim: true,
|
|
35
|
+
remove: void 0,
|
|
36
|
+
strict: true,
|
|
37
|
+
lowercase: true
|
|
38
|
+
};
|
|
39
|
+
function slugify(string, options) {
|
|
40
|
+
if (typeof string !== "string") {
|
|
41
|
+
throw new Error("slugify: string argument expected");
|
|
42
|
+
}
|
|
43
|
+
const _options = { ...defaultOptions, ...options };
|
|
44
|
+
const charMap = {};
|
|
45
|
+
let slug = string.normalize().split("").reduce(function(result, ch) {
|
|
46
|
+
let appendChar = charMap[ch];
|
|
47
|
+
if (appendChar === void 0)
|
|
48
|
+
appendChar = ch;
|
|
49
|
+
if (appendChar === _options?.separator)
|
|
50
|
+
appendChar = " ";
|
|
51
|
+
return result + appendChar.replace(_options?.remove || /[^\w\s$*_+~.()'"!\-:@]+/g, "");
|
|
52
|
+
}, "");
|
|
53
|
+
if (_options.strict) {
|
|
54
|
+
slug = slug.replace(/[^A-Za-z0-9\s]/g, "");
|
|
55
|
+
}
|
|
56
|
+
if (_options.trim) {
|
|
57
|
+
slug = slug.trim();
|
|
58
|
+
}
|
|
59
|
+
if (_options.separator) {
|
|
60
|
+
slug = slug.replace(/ +/g, _options.separator);
|
|
61
|
+
}
|
|
62
|
+
if (_options.lowercase) {
|
|
63
|
+
slug = slug.toLocaleLowerCase();
|
|
64
|
+
}
|
|
65
|
+
return slug;
|
|
66
|
+
}
|
|
30
67
|
export {
|
|
31
68
|
clampValue,
|
|
32
69
|
isIOS,
|
|
33
70
|
mapValue,
|
|
71
|
+
slugify,
|
|
34
72
|
uniq,
|
|
35
73
|
uuid
|
|
36
74
|
};
|
package/dist/utils/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/uuid.ts","../../packages/utils/src/functions/uniq.ts"],"sourcesContent":["export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","// This implementation is meant for internal use only.\n// It is only used to generate a unique IDs for the `key` props.\n// It should not replace crypto.randomUUID() or window.crypto.randomUUID().\n\nexport function uuid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'\n .split('')\n .reduce(\n (c, i) =>\n c +\n (i === 'x'\n ? Math.floor(Math.random() * 0xf).toString(16)\n : i === 'y'\n ? Math.floor(Math.random() * 4 + 8).toString(16)\n : i),\n '',\n )\n}\n","export function uniq<T extends any[]>(a: T) {\n return Array.from(new Set(a))\n}\n"],"mappings":";AAAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACJO,SAAS,OAAO;AACrB,SAAO,uCACJ,MAAM,EAAE,EACR;AAAA,IACC,CAAC,GAAG,MACF,KACC,MAAM,MACH,KAAK,MAAM,KAAK,OAAO,IAAI,EAAG,EAAE,SAAS,EAAE,IAC3C,MAAM,MACN,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,EAAE,SAAS,EAAE,IAC7C;AAAA,IACN;AAAA,EACF;AACJ;;;ACjBO,SAAS,KAAsB,GAAM;AAC1C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/uuid.ts","../../packages/utils/src/functions/uniq.ts","../../packages/utils/src/functions/slugify.ts"],"sourcesContent":["export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","// This implementation is meant for internal use only.\n// It is only used to generate a unique IDs for the `key` props.\n// It should not replace crypto.randomUUID() or window.crypto.randomUUID().\n\nexport function uuid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'\n .split('')\n .reduce(\n (c, i) =>\n c +\n (i === 'x'\n ? Math.floor(Math.random() * 0xf).toString(16)\n : i === 'y'\n ? Math.floor(Math.random() * 4 + 8).toString(16)\n : i),\n '',\n )\n}\n","export function uniq<T extends any[]>(a: T) {\n return Array.from(new Set(a))\n}\n","export interface SlugifyOptions {\n separator?: string\n trim?: boolean\n remove?: RegExp\n strict?: boolean\n lowercase?: boolean\n}\n\nconst defaultOptions: SlugifyOptions = {\n separator: '-',\n trim: true,\n remove: undefined,\n strict: true,\n lowercase: true,\n}\n\nexport function slugify(string: string, options?: SlugifyOptions): string {\n if (typeof string !== 'string') {\n throw new Error('slugify: string argument expected')\n }\n\n // Merge provided options with default options\n const _options = { ...defaultOptions, ...options }\n\n const charMap: { [key: string]: string } = {}\n\n let slug = string\n .normalize()\n .split('')\n .reduce(function (result, ch) {\n let appendChar = charMap[ch]\n if (appendChar === undefined) appendChar = ch\n if (appendChar === _options?.separator) appendChar = ' '\n return (\n result +\n appendChar.replace(_options?.remove || /[^\\w\\s$*_+~.()'\"!\\-:@]+/g, '')\n )\n }, '')\n\n if (_options.strict) {\n slug = slug.replace(/[^A-Za-z0-9\\s]/g, '')\n }\n\n if (_options.trim) {\n slug = slug.trim()\n }\n\n if (_options.separator) {\n slug = slug.replace(/ +/g, _options.separator)\n }\n\n if (_options.lowercase) {\n slug = slug.toLocaleLowerCase()\n }\n\n return slug\n}\n"],"mappings":";AAAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACJO,SAAS,OAAO;AACrB,SAAO,uCACJ,MAAM,EAAE,EACR;AAAA,IACC,CAAC,GAAG,MACF,KACC,MAAM,MACH,KAAK,MAAM,KAAK,OAAO,IAAI,EAAG,EAAE,SAAS,EAAE,IAC3C,MAAM,MACN,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,EAAE,SAAS,EAAE,IAC7C;AAAA,IACN;AAAA,EACF;AACJ;;;ACjBO,SAAS,KAAsB,GAAM;AAC1C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;;;ACMA,IAAM,iBAAiC;AAAA,EACrC,WAAW;AAAA,EACX,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AACb;AAEO,SAAS,QAAQ,QAAgB,SAAkC;AACxE,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAGA,QAAM,WAAW,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAEjD,QAAM,UAAqC,CAAC;AAE5C,MAAI,OAAO,OACR,UAAU,EACV,MAAM,EAAE,EACR,OAAO,SAAU,QAAQ,IAAI;AAC5B,QAAI,aAAa,QAAQ,EAAE;AAC3B,QAAI,eAAe;AAAW,mBAAa;AAC3C,QAAI,eAAe,UAAU;AAAW,mBAAa;AACrD,WACE,SACA,WAAW,QAAQ,UAAU,UAAU,4BAA4B,EAAE;AAAA,EAEzE,GAAG,EAAE;AAEP,MAAI,SAAS,QAAQ;AACnB,WAAO,KAAK,QAAQ,mBAAmB,EAAE;AAAA,EAC3C;AAEA,MAAI,SAAS,MAAM;AACjB,WAAO,KAAK,KAAK;AAAA,EACnB;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,QAAQ,OAAO,SAAS,SAAS;AAAA,EAC/C;AAEA,MAAI,SAAS,WAAW;AACtB,WAAO,KAAK,kBAAkB;AAAA,EAChC;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maas/vue-equipment",
|
|
3
3
|
"description": "A magic collection of Vue composables, plugins, components and directives",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@antfu/ni": "^0.21.5",
|
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
"luxon": "^3.4.2",
|
|
68
68
|
"mitt": "^3.0.1",
|
|
69
69
|
"motion": "^10.16.2",
|
|
70
|
-
"nuxt": "^3.5.1"
|
|
70
|
+
"nuxt": "^3.5.1",
|
|
71
|
+
"universal-cookie": "^6.1.1"
|
|
71
72
|
},
|
|
72
73
|
"peerDependenciesMeta": {
|
|
73
74
|
"@maas/magic-timer": {
|
|
@@ -93,6 +94,9 @@
|
|
|
93
94
|
},
|
|
94
95
|
"nuxt": {
|
|
95
96
|
"optional": false
|
|
97
|
+
},
|
|
98
|
+
"universal-cookie": {
|
|
99
|
+
"optional": false
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
102
|
"scripts": {
|