@wikala/spmkt 3.0.0-beta.0 → 3.0.0-beta.1
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/MIGRATION_GUIDE.md +50 -1
- package/api/request.js +3 -2
- package/components/Cart/Store/mutations.js +2 -2
- package/components/Cart/Store/state.js +2 -2
- package/components/DobInput.vue +1 -1
- package/components/MobileMenu/icons/LeftArrowIcon.vue +1 -1
- package/components/MobileMenu/icons/MenuIcon.vue +1 -1
- package/components/MobileMenu/icons/RightArrowIcon.vue +1 -1
- package/components/ModalContainer/ModalContainer.vue +8 -4
- package/components/ModalContainer/index.js +3 -2
- package/components/Product/Compare.vue +32 -10
- package/components/Product/Variants.vue +1 -1
- package/install.js +17 -4
- package/package.json +8 -9
- package/utils/animate.css +50 -0
- package/utils/animate.js +1 -1
- package/utils/buefy.js +62 -0
- package/utils/format-date.js +17 -0
- package/utils/random-id.js +10 -0
package/MIGRATION_GUIDE.md
CHANGED
|
@@ -11,7 +11,7 @@ This document outlines the changes made and remaining work needed to complete th
|
|
|
11
11
|
| `vue@^2.6.14` | `vue@^3.4.0` |
|
|
12
12
|
| `vuex@^3.6.2` | `vuex@^4.1.0` |
|
|
13
13
|
| `buefy@^0.9.10` | `buefy@^3.0.3` (Vue 3 compatible) |
|
|
14
|
-
| `vue-mq@^1.0.1` |
|
|
14
|
+
| `vue-mq@^1.0.1` | removed: the host provides `$mq` |
|
|
15
15
|
| `vue-template-compiler` | `@vue/compiler-sfc` |
|
|
16
16
|
| `@vue/test-utils@^1.3.6` | `@vue/test-utils@^2.4.3` |
|
|
17
17
|
|
|
@@ -192,6 +192,55 @@ the same `setAddressList` / `setCountryList` mutations, which would collide.
|
|
|
192
192
|
longer calls `Vue.use(Buefy)`, `registerFilters(Vue)` or `registerDirectives(Vue)`
|
|
193
193
|
itself; pass Buefy and modal container options through `installSpmkt` instead.
|
|
194
194
|
|
|
195
|
+
Of Buefy, `installSpmkt` installs only the components spmkt uses (`buefyPlugins`
|
|
196
|
+
in `utils/buefy.js`), not all of it, so the unused ones stay out of the host's
|
|
197
|
+
bundle. A host whose own templates use another Buefy component installs that
|
|
198
|
+
plugin itself after `installSpmkt`:
|
|
199
|
+
|
|
200
|
+
```javascript
|
|
201
|
+
import { Tooltip } from 'buefy'
|
|
202
|
+
|
|
203
|
+
app.use(installSpmkt, { buefy: { defaultIconPack: 'fas' } })
|
|
204
|
+
app.use(Tooltip)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Buefy's `module` entry is one file that bundlers can't tree-shake well, so even
|
|
208
|
+
that subset costs ~82 KB gzipped. Alias `buefy` to its per-component build and it
|
|
209
|
+
drops to ~47 KB. Alias the bare `buefy` import only (CSS imports like
|
|
210
|
+
`buefy/dist/css/buefy.css` stay as they are), and set it in the host's config so the
|
|
211
|
+
host and spmkt share one Buefy, and with it one config:
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
// vite.config.js
|
|
215
|
+
resolve: {
|
|
216
|
+
alias: [{ find: /^buefy$/, replacement: 'buefy/dist/esm/index.js' }]
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// webpack.config.js
|
|
220
|
+
resolve: {
|
|
221
|
+
alias: { buefy$: 'buefy/dist/esm/index.js' }
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Bundle size
|
|
226
|
+
|
|
227
|
+
`package.json` marks spmkt's modules side-effect free (`"sideEffects"`), so the
|
|
228
|
+
host's bundler keeps only the components a page imports and their dependencies:
|
|
229
|
+
a page using just `Price` no longer bundles axios, underscore or the Cart. Don't
|
|
230
|
+
rely on spmkt's imports for anything a page doesn't import itself:
|
|
231
|
+
|
|
232
|
+
- `animate.css` is no longer a dependency. spmkt ships only the `pulse` and
|
|
233
|
+
`slideInUp` animations it uses (`utils/animate.css`); a host whose templates
|
|
234
|
+
use other `animate__*` classes installs and imports `animate.css` itself.
|
|
235
|
+
- `window._post` / `window._get` are set by `installSpmkt`, not on import, and
|
|
236
|
+
load the request module on their first call.
|
|
237
|
+
- `window.customEventBus` and `window.GoogleAnalyticsEEC` are still set on
|
|
238
|
+
every page that imports `installSpmkt`.
|
|
239
|
+
- `bulma-divider`, `shortid`, `intl-dateformat` and `scrollmonitor` are no longer
|
|
240
|
+
dependencies. A host theme that `@import`s `bulma-divider` (for Login's
|
|
241
|
+
`.is-divider`) installs it itself.
|
|
242
|
+
- No spmkt component uses Sass, so the host no longer needs `sass` to compile them.
|
|
243
|
+
|
|
195
244
|
## Host Application Requirements
|
|
196
245
|
|
|
197
246
|
spmkt components rely on things the host app provides. In the Vue 2 host these
|
package/api/request.js
CHANGED
|
@@ -53,7 +53,8 @@ service.interceptors.response.use(
|
|
|
53
53
|
}
|
|
54
54
|
)
|
|
55
55
|
|
|
56
|
-
window._post
|
|
56
|
+
// The host's inline scripts call these as window._post / window._get; installSpmkt sets them
|
|
57
|
+
export const _post = (url, params, callback) => {
|
|
57
58
|
service({
|
|
58
59
|
baseURL: config.BASE_URL,
|
|
59
60
|
url: url,
|
|
@@ -72,7 +73,7 @@ window._post = (url, params, callback) => {
|
|
|
72
73
|
return true
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
export const _get = (url, params, callback) => {
|
|
76
77
|
let queryString = ''
|
|
77
78
|
if (params) {
|
|
78
79
|
queryString = Object.keys(params)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// noinspection DuplicatedCode
|
|
3
3
|
|
|
4
4
|
import _ from 'underscore'
|
|
5
|
-
import
|
|
5
|
+
import randomId from '../../../utils/random-id'
|
|
6
6
|
import GoogleAnalyticsEEC from '../../../utils/google/google-analytics-eec'
|
|
7
7
|
import { addressSchema } from '../../Address/address.schema'
|
|
8
8
|
import { Address } from '../../../api'
|
|
@@ -142,7 +142,7 @@ export default {
|
|
|
142
142
|
},
|
|
143
143
|
|
|
144
144
|
setIdempotencyKey(state) {
|
|
145
|
-
state.checkoutRequestData.idempotency_key =
|
|
145
|
+
state.checkoutRequestData.idempotency_key = randomId()
|
|
146
146
|
},
|
|
147
147
|
|
|
148
148
|
setDateOfBirth(state, date_of_birth) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { User } from '../../../api'
|
|
3
3
|
import { addressSchema } from '../../Address/address.schema'
|
|
4
|
-
import
|
|
4
|
+
import randomId from '../../../utils/random-id'
|
|
5
5
|
|
|
6
6
|
export default () => ({
|
|
7
7
|
cart: {
|
|
@@ -71,7 +71,7 @@ export default () => ({
|
|
|
71
71
|
card_postal_code: '',
|
|
72
72
|
recaptcha_token: '',
|
|
73
73
|
date_of_birth: '',
|
|
74
|
-
idempotency_key:
|
|
74
|
+
idempotency_key: randomId(),
|
|
75
75
|
reservation_slot: '',
|
|
76
76
|
note: '',
|
|
77
77
|
affiliate: {}
|
package/components/DobInput.vue
CHANGED
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
|
|
14
14
|
<script>
|
|
15
15
|
import { markRaw } from 'vue'
|
|
16
|
-
import
|
|
16
|
+
import { ConfigProgrammatic } from 'buefy'
|
|
17
|
+
|
|
18
|
+
// Buefy's own config, which installSpmkt's buefy options set. Read it on each use:
|
|
19
|
+
// setOptions() replaces the object rather than mutating it.
|
|
20
|
+
const config = () => ConfigProgrammatic.getOptions()
|
|
17
21
|
|
|
18
22
|
export default {
|
|
19
23
|
name: 'ModalContainer',
|
|
@@ -38,7 +42,7 @@ export default {
|
|
|
38
42
|
canCancel: {
|
|
39
43
|
type: [Array, Boolean],
|
|
40
44
|
default: () => {
|
|
41
|
-
return config.defaultModalCanCancel
|
|
45
|
+
return config().defaultModalCanCancel
|
|
42
46
|
}
|
|
43
47
|
},
|
|
44
48
|
onCancel: {
|
|
@@ -48,7 +52,7 @@ export default {
|
|
|
48
52
|
scroll: {
|
|
49
53
|
type: String,
|
|
50
54
|
default: () => {
|
|
51
|
-
return config.defaultModalScroll ? config.defaultModalScroll : 'clip'
|
|
55
|
+
return config().defaultModalScroll ? config().defaultModalScroll : 'clip'
|
|
52
56
|
},
|
|
53
57
|
validator: (value) => {
|
|
54
58
|
return ['clip', 'keep'].indexOf(value) >= 0
|
|
@@ -66,7 +70,7 @@ export default {
|
|
|
66
70
|
},
|
|
67
71
|
computed: {
|
|
68
72
|
cancelOptions() {
|
|
69
|
-
return typeof this.canCancel === 'boolean' ? (this.canCancel ? config.defaultModalCanCancel : []) : this.canCancel
|
|
73
|
+
return typeof this.canCancel === 'boolean' ? (this.canCancel ? config().defaultModalCanCancel : []) : this.canCancel
|
|
70
74
|
},
|
|
71
75
|
showX() {
|
|
72
76
|
return this.cancelOptions.indexOf('x') >= 0
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { createApp, h, ref } from 'vue'
|
|
7
7
|
import Modal from './ModalContainer.vue'
|
|
8
|
-
import
|
|
8
|
+
import { copyAppContext } from 'buefy'
|
|
9
|
+
import { installBuefy } from '../../utils/buefy'
|
|
9
10
|
|
|
10
11
|
const ModalContainer = {
|
|
11
12
|
instance: null,
|
|
@@ -65,7 +66,7 @@ const ModalContainer = {
|
|
|
65
66
|
copyAppContext(this.parentApp, app)
|
|
66
67
|
} else {
|
|
67
68
|
// Install Buefy in the modal app instance so components like b-autocomplete work
|
|
68
|
-
app
|
|
69
|
+
installBuefy(app)
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
app.mount(container)
|
|
@@ -56,9 +56,8 @@
|
|
|
56
56
|
</template>
|
|
57
57
|
|
|
58
58
|
<script setup>
|
|
59
|
-
import { ref, onMounted, getCurrentInstance } from 'vue'
|
|
59
|
+
import { ref, onMounted, onUnmounted, getCurrentInstance } from 'vue'
|
|
60
60
|
import Lookup from './Lookup.vue'
|
|
61
|
-
import scrollMonitor from 'scrollmonitor'
|
|
62
61
|
|
|
63
62
|
defineOptions({ name: 'ComparePage' })
|
|
64
63
|
|
|
@@ -92,18 +91,33 @@ const stringFilter = (value) => {
|
|
|
92
91
|
return value
|
|
93
92
|
}
|
|
94
93
|
|
|
94
|
+
let onScroll = null
|
|
95
|
+
|
|
96
|
+
// Adds .scrolled to the product name headers while the first one is out of view. Its
|
|
97
|
+
// position is read once, since .scrolled makes the headers fixed, which moves them.
|
|
95
98
|
const initScrollMonitor = () => {
|
|
96
99
|
const elToWatch = document.querySelectorAll('.fixedContent')
|
|
100
|
+
if (!elToWatch.length) return
|
|
101
|
+
|
|
102
|
+
const rect = elToWatch[0].getBoundingClientRect()
|
|
103
|
+
const top = rect.top + window.scrollY
|
|
104
|
+
const bottom = rect.bottom + window.scrollY
|
|
105
|
+
const isInViewport = () => top < window.scrollY + window.innerHeight && bottom > window.scrollY
|
|
106
|
+
const setScrolled = (scrolled) => elToWatch.forEach((el) => el.classList.toggle('scrolled', scrolled))
|
|
97
107
|
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
let inViewport = isInViewport()
|
|
109
|
+
if (!inViewport && top < window.scrollY) {
|
|
110
|
+
setScrolled(true)
|
|
111
|
+
}
|
|
100
112
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
113
|
+
onScroll = () => {
|
|
114
|
+
if (isInViewport() !== inViewport) {
|
|
115
|
+
inViewport = !inViewport
|
|
116
|
+
setScrolled(!inViewport)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
window.addEventListener('scroll', onScroll, { passive: true })
|
|
120
|
+
window.addEventListener('resize', onScroll, { passive: true })
|
|
107
121
|
}
|
|
108
122
|
|
|
109
123
|
// Lifecycle hooks
|
|
@@ -125,4 +139,12 @@ onMounted(() => {
|
|
|
125
139
|
|
|
126
140
|
window.addEventListener('load', initScrollMonitor, false)
|
|
127
141
|
})
|
|
142
|
+
|
|
143
|
+
onUnmounted(() => {
|
|
144
|
+
window.removeEventListener('load', initScrollMonitor, false)
|
|
145
|
+
if (onScroll) {
|
|
146
|
+
window.removeEventListener('scroll', onScroll)
|
|
147
|
+
window.removeEventListener('resize', onScroll)
|
|
148
|
+
}
|
|
149
|
+
})
|
|
128
150
|
</script>
|
|
@@ -37,7 +37,7 @@ import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick }
|
|
|
37
37
|
import { formatMoney } from '../../utils/filters'
|
|
38
38
|
import { useBus } from '../../composables/globals'
|
|
39
39
|
import _ from 'underscore'
|
|
40
|
-
import formatDate from '
|
|
40
|
+
import formatDate from '../../utils/format-date'
|
|
41
41
|
|
|
42
42
|
const props = defineProps({
|
|
43
43
|
product: {
|
package/install.js
CHANGED
|
@@ -41,17 +41,27 @@
|
|
|
41
41
|
* See .storybook/preview.js for minimal stand-ins.
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
|
-
import
|
|
45
|
-
|
|
44
|
+
import { installBuefy } from './utils/buefy'
|
|
46
45
|
import { EventBusPlugin } from './utils/event-bus'
|
|
47
46
|
import registerDirectives from './utils/directives'
|
|
48
47
|
import registerFilters from './utils/filters'
|
|
49
48
|
import ModalContainerPlugin from './components/ModalContainer'
|
|
49
|
+
// window.customEventBus and window.GoogleAnalyticsEEC, which host scripts may use on
|
|
50
|
+
// pages whose components don't import them
|
|
51
|
+
import './utils/custom-event-bus'
|
|
52
|
+
import './utils/google/google-analytics-eec'
|
|
53
|
+
|
|
54
|
+
// window._post / window._get for the host's inline scripts. request.js (and axios) loads
|
|
55
|
+
// on the first call, so pages whose components make no API calls don't bundle it.
|
|
56
|
+
const lazyRequest = (name) => (...args) => {
|
|
57
|
+
import('./api/request').then((request) => request[name](...args))
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
50
60
|
|
|
51
61
|
export const installSpmkt = {
|
|
52
62
|
install(app, options = {}) {
|
|
53
|
-
// Install Buefy 3
|
|
54
|
-
app
|
|
63
|
+
// Install the Buefy 3 components spmkt uses (see utils/buefy.js)
|
|
64
|
+
installBuefy(app, options.buefy)
|
|
55
65
|
|
|
56
66
|
// Install event bus ($bus)
|
|
57
67
|
app.use(EventBusPlugin)
|
|
@@ -65,6 +75,9 @@ export const installSpmkt = {
|
|
|
65
75
|
// Register global filters as $filters
|
|
66
76
|
registerFilters(app)
|
|
67
77
|
|
|
78
|
+
window._post = lazyRequest('_post')
|
|
79
|
+
window._get = lazyRequest('_get')
|
|
80
|
+
|
|
68
81
|
// Store config in global properties if provided
|
|
69
82
|
if (options.config) {
|
|
70
83
|
app.config.globalProperties.$spmktConfig = options.config
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wikala/spmkt",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "supermarket",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
"build-storybook": "storybook build"
|
|
11
11
|
},
|
|
12
12
|
"main": "index.js",
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"*.css",
|
|
15
|
+
"*.scss",
|
|
16
|
+
"./utils/custom-event-bus.js",
|
|
17
|
+
"./utils/google/google-analytics-eec.js"
|
|
18
|
+
],
|
|
13
19
|
"files": [
|
|
14
20
|
"index.js",
|
|
15
21
|
"install.js",
|
|
@@ -25,18 +31,12 @@
|
|
|
25
31
|
],
|
|
26
32
|
"dependencies": {
|
|
27
33
|
"@googlemaps/js-api-loader": "^1.12.2",
|
|
28
|
-
"animate.css": "^4.1.1",
|
|
29
34
|
"axios": "^1.20.0",
|
|
30
|
-
"bulma-divider": "^0.2.0",
|
|
31
35
|
"currency.js": "^2.0.4",
|
|
32
36
|
"embedo": "^1.14.0",
|
|
33
|
-
"intl-dateformat": "^0.1.4",
|
|
34
37
|
"js-cookie": "^3.0.1",
|
|
35
38
|
"mitt": "^3.0.1",
|
|
36
|
-
"
|
|
37
|
-
"shortid": "^2.2.16",
|
|
38
|
-
"underscore": "^1.13.1",
|
|
39
|
-
"vue3-mq": "^3.1.3"
|
|
39
|
+
"underscore": "^1.13.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@storybook/addon-docs": "^10.1.11",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"msw": "2.12.7",
|
|
49
49
|
"prettier": "^2.3.1",
|
|
50
50
|
"pretty-quick": "^3.1.0",
|
|
51
|
-
"sass": "^1.39.0",
|
|
52
51
|
"storybook": "^10.1.11",
|
|
53
52
|
"vite": "^6.0.0",
|
|
54
53
|
"vitest": "^4.1.11",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The two animate.css (https://animate.style/, MIT) animations animateCSS() is called
|
|
3
|
+
* with, under animate.css's class names. A host that uses others imports animate.css.
|
|
4
|
+
*/
|
|
5
|
+
.animate__animated {
|
|
6
|
+
animation-duration: var(--animate-duration, 1s);
|
|
7
|
+
animation-fill-mode: both;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@keyframes pulse {
|
|
11
|
+
from {
|
|
12
|
+
transform: scale3d(1, 1, 1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
50% {
|
|
16
|
+
transform: scale3d(1.05, 1.05, 1.05);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
to {
|
|
20
|
+
transform: scale3d(1, 1, 1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.animate__pulse {
|
|
25
|
+
animation-name: pulse;
|
|
26
|
+
animation-timing-function: ease-in-out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@keyframes slideInUp {
|
|
30
|
+
from {
|
|
31
|
+
transform: translate3d(0, 100%, 0);
|
|
32
|
+
visibility: visible;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
to {
|
|
36
|
+
transform: translate3d(0, 0, 0);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.animate__slideInUp {
|
|
41
|
+
animation-name: slideInUp;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media print, (prefers-reduced-motion: reduce) {
|
|
45
|
+
.animate__animated {
|
|
46
|
+
animation-duration: 1ms !important;
|
|
47
|
+
transition-duration: 1ms !important;
|
|
48
|
+
animation-iteration-count: 1 !important;
|
|
49
|
+
}
|
|
50
|
+
}
|
package/utils/animate.js
CHANGED
package/utils/buefy.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigProgrammatic,
|
|
3
|
+
Autocomplete,
|
|
4
|
+
Button,
|
|
5
|
+
Carousel,
|
|
6
|
+
Checkbox,
|
|
7
|
+
Dialog,
|
|
8
|
+
Field,
|
|
9
|
+
Icon,
|
|
10
|
+
Input,
|
|
11
|
+
Loading,
|
|
12
|
+
Modal,
|
|
13
|
+
Pagination,
|
|
14
|
+
Progress,
|
|
15
|
+
Radio,
|
|
16
|
+
Select,
|
|
17
|
+
Slider,
|
|
18
|
+
Snackbar,
|
|
19
|
+
Table,
|
|
20
|
+
Tabs,
|
|
21
|
+
Toast,
|
|
22
|
+
Upload
|
|
23
|
+
} from 'buefy'
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The Buefy plugins spmkt's components use (<b-*> tags and $buefy.dialog/toast/
|
|
27
|
+
* loading/snackbar). Installing these instead of all of Buefy keeps the ~25 unused
|
|
28
|
+
* components (pickers, taginput, steps, ...) out of the host's bundle. A host whose
|
|
29
|
+
* own templates use another one installs it itself: app.use(Tooltip).
|
|
30
|
+
*/
|
|
31
|
+
export const buefyPlugins = [
|
|
32
|
+
Autocomplete,
|
|
33
|
+
Button,
|
|
34
|
+
Carousel,
|
|
35
|
+
Checkbox,
|
|
36
|
+
Dialog,
|
|
37
|
+
Field,
|
|
38
|
+
Icon,
|
|
39
|
+
Input,
|
|
40
|
+
Loading,
|
|
41
|
+
Modal,
|
|
42
|
+
Pagination,
|
|
43
|
+
Progress,
|
|
44
|
+
Radio,
|
|
45
|
+
Select,
|
|
46
|
+
Slider,
|
|
47
|
+
Snackbar,
|
|
48
|
+
Table,
|
|
49
|
+
Tabs,
|
|
50
|
+
Toast,
|
|
51
|
+
Upload
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
// What app.use(Buefy, options) does, for buefyPlugins only
|
|
55
|
+
export function installBuefy(app, options = {}) {
|
|
56
|
+
ConfigProgrammatic.setOptions(options)
|
|
57
|
+
buefyPlugins.forEach((plugin) => app.use(plugin))
|
|
58
|
+
|
|
59
|
+
const buefy = app.config.globalProperties.$buefy
|
|
60
|
+
buefy.config = ConfigProgrammatic
|
|
61
|
+
buefy.globalNoticeInterval = undefined
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Formats a date in local time, e.g. formatDate(date, 'DD.MM.YYYY HH:mm').
|
|
5
|
+
* Tokens: YYYY, MM, DD, HH, mm. Digits are Latin whatever the browser's locale,
|
|
6
|
+
* so 'YYYY-MM-DD' is safe to send to the server.
|
|
7
|
+
*/
|
|
8
|
+
export default function formatDate(date, format) {
|
|
9
|
+
const parts = {
|
|
10
|
+
YYYY: date.getFullYear(),
|
|
11
|
+
MM: pad(date.getMonth() + 1),
|
|
12
|
+
DD: pad(date.getDate()),
|
|
13
|
+
HH: pad(date.getHours()),
|
|
14
|
+
mm: pad(date.getMinutes())
|
|
15
|
+
}
|
|
16
|
+
return format.replace(/YYYY|MM|DD|HH|mm/g, (token) => parts[token])
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A random id from shortid's alphabet, no longer than its 14-character ids, so it fits
|
|
5
|
+
* wherever the backend stored those (the checkout idempotency key). 64 symbols, so
|
|
6
|
+
* masking each random byte to 6 bits keeps it unbiased.
|
|
7
|
+
*/
|
|
8
|
+
export default function randomId(length = 14) {
|
|
9
|
+
return Array.from(crypto.getRandomValues(new Uint8Array(length)), (byte) => ALPHABET[byte & 63]).join('')
|
|
10
|
+
}
|