@wikala/spmkt 3.0.0-beta.0 → 3.0.0-beta.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/MIGRATION_GUIDE.md +50 -1
- package/api/request.js +3 -2
- package/components/Address/Edit.vue +8 -28
- package/components/Address/address.schema.js +4 -4
- package/components/Cart/CreditCard/Everyware.vue +2 -2
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +2 -2
- package/components/Cart/CreditCard/StandardCreditCard.vue +2 -2
- package/components/Cart/Delivery/Delivery.vue +2 -2
- package/components/Cart/Delivery/ReservationSlots.vue +3 -3
- package/components/Cart/Payment/Payment.vue +2 -2
- package/components/Cart/ShoppingCart.vue +2 -2
- package/components/Cart/Store/getters.js +5 -3
- package/components/Cart/Store/mutations.js +10 -8
- package/components/Cart/Store/state.js +2 -2
- package/components/Cart/UserIdentity.vue +2 -2
- package/components/Category/CategoryFilter.vue +37 -34
- package/components/DobInput.vue +1 -1
- package/components/Gmaps/GmapsAutocomplete.vue +2 -2
- package/components/Gmaps/GmapsLocations.vue +2 -2
- 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/AddToCart.vue +10 -7
- package/components/Product/Compare.vue +32 -10
- package/components/Product/CompareBox.vue +6 -4
- package/components/Product/Lookup.vue +2 -2
- package/components/Product/ProductAutocomplete.vue +2 -2
- package/components/Product/Variants.vue +17 -17
- package/components/Product/reviews-questions/ReviewImages.vue +4 -4
- package/components/QuantityInput.vue +2 -2
- 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/filters.js +54 -3
- package/utils/format-date.js +17 -0
- package/utils/google/gmaps.js +2 -2
- package/utils/parse-url-filters.js +19 -0
- package/utils/random-id.js +10 -0
- package/components/Category/FilterMixin.js +0 -70
package/utils/filters.js
CHANGED
|
@@ -81,10 +81,61 @@ export const hidecc = function (value) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// 'Y-m-d', 'Y-m-d H:i', 'Y-m-d H:i:s.u', optionally with 'T' and a zone ('Z', '+00', '+05:30').
|
|
85
|
+
// Safari < 16 can't parse the space-separated forms, and native parsing reads a bare 'Y-m-d' as UTC,
|
|
86
|
+
// so these are built from their parts: local time unless a zone is given.
|
|
87
|
+
const YMD_HIS = /^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:\s*(Z|[+-]\d{2}(?::?\d{2})?))?)?$/i
|
|
88
|
+
|
|
89
|
+
const parseYmdHis = function (str) {
|
|
90
|
+
const m = str.match(YMD_HIS)
|
|
91
|
+
if (!m) {
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
const [y, mo, d, h, mi, s] = m.slice(1, 7).map((v) => +(v || 0))
|
|
95
|
+
const ms = +(m[7] || '0').slice(0, 3).padEnd(3, '0')
|
|
96
|
+
if (h > 23 || mi > 59 || s > 59) {
|
|
97
|
+
return new Date(NaN)
|
|
98
|
+
}
|
|
99
|
+
// setUTCFullYear/setFullYear instead of the Date constructor, which maps years 0-99 to 19xx
|
|
100
|
+
const data = new Date(0)
|
|
101
|
+
data.setUTCFullYear(y, mo - 1, d)
|
|
102
|
+
// Out-of-range parts roll over (Feb 30 -> Mar 1) instead of failing, so reject those
|
|
103
|
+
if (data.getUTCFullYear() !== y || data.getUTCMonth() !== mo - 1 || data.getUTCDate() !== d) {
|
|
104
|
+
return new Date(NaN)
|
|
105
|
+
}
|
|
106
|
+
const zone = m[8]
|
|
107
|
+
if (!zone) {
|
|
108
|
+
const local = new Date(0)
|
|
109
|
+
local.setFullYear(y, mo - 1, d)
|
|
110
|
+
local.setHours(h, mi, s, ms)
|
|
111
|
+
return local
|
|
112
|
+
}
|
|
113
|
+
data.setUTCHours(h, mi, s, ms)
|
|
114
|
+
if (zone.toUpperCase() !== 'Z') {
|
|
115
|
+
const [, sign, zh, zm = '0'] = zone.match(/([+-])(\d{2}):?(\d{2})?/)
|
|
116
|
+
if (zh > 23 || zm > 59) {
|
|
117
|
+
return new Date(NaN)
|
|
118
|
+
}
|
|
119
|
+
data.setTime(data.getTime() - (sign === '-' ? -1 : 1) * (zh * 60 + +zm) * 60000)
|
|
120
|
+
}
|
|
121
|
+
return data
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Built on first use so importing the filters has no side effects
|
|
125
|
+
let dateFormat
|
|
126
|
+
|
|
84
127
|
export const date = function (date) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
128
|
+
if (typeof date !== 'string' && typeof date !== 'number' && !(date instanceof Date)) {
|
|
129
|
+
// new Date(null) would be the 1970 epoch
|
|
130
|
+
return date
|
|
131
|
+
}
|
|
132
|
+
const data = (typeof date === 'string' && parseYmdHis(date)) || new Date(date)
|
|
133
|
+
if (isNaN(data)) {
|
|
134
|
+
// Intl throws a RangeError on an invalid date
|
|
135
|
+
return date
|
|
136
|
+
}
|
|
137
|
+
dateFormat = dateFormat || new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' })
|
|
138
|
+
return dateFormat.format(data)
|
|
88
139
|
}
|
|
89
140
|
|
|
90
141
|
export const nl2p = function (str) {
|
|
@@ -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
|
+
}
|
package/utils/google/gmaps.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Loader } from '@googlemaps/js-api-loader'
|
|
2
|
-
import
|
|
2
|
+
import sortBy from 'underscore/modules/sortBy.js'
|
|
3
3
|
|
|
4
4
|
let API_KEY = ''
|
|
5
5
|
let MAP_OPTIONS = {
|
|
@@ -187,7 +187,7 @@ function findNearest(coordinates, locations) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
let nearestLocations =
|
|
190
|
+
let nearestLocations = sortBy(locations, 'distance')
|
|
191
191
|
//console.log(nearest, nearestLocations)
|
|
192
192
|
return nearestLocations
|
|
193
193
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses the category ?f= param, e.g. '12:red,blue;7:10,20' -> { 12: ['red', 'blue'], 7: ['10', '20'] }.
|
|
3
|
+
* The param comes from the address bar, so segments without an 'id:' prefix are skipped instead of throwing,
|
|
4
|
+
* and the result has no prototype so ids like '__proto__' stay plain keys.
|
|
5
|
+
*/
|
|
6
|
+
export default function parseUrlFilters(urlFilters) {
|
|
7
|
+
let filtersStruct = Object.create(null)
|
|
8
|
+
if (!urlFilters) {
|
|
9
|
+
return filtersStruct
|
|
10
|
+
}
|
|
11
|
+
urlFilters.split(';').forEach((filter) => {
|
|
12
|
+
let sep = filter.indexOf(':')
|
|
13
|
+
if (sep <= 0) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
filtersStruct[filter.slice(0, sep)] = filter.slice(sep + 1).split(',')
|
|
17
|
+
})
|
|
18
|
+
return filtersStruct
|
|
19
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import _ from "underscore";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
|
|
5
|
-
methods: {
|
|
6
|
-
|
|
7
|
-
filterMethod() {
|
|
8
|
-
console.log('filter mixin method called')
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
filterClick(e) {
|
|
12
|
-
//console.log(window.location.search)
|
|
13
|
-
let categoryUrl = new URL(window.location.href)
|
|
14
|
-
let urlFilters = categoryUrl.searchParams.get('f')
|
|
15
|
-
let filtersStruct = {}
|
|
16
|
-
urlFilters.split(';').forEach(
|
|
17
|
-
(filter) => {
|
|
18
|
-
let fvalues = filter.split(':')
|
|
19
|
-
filtersStruct[fvalues[0]] = fvalues[1].split(',')
|
|
20
|
-
}
|
|
21
|
-
)
|
|
22
|
-
console.log(e.target.dataset)
|
|
23
|
-
console.log(filtersStruct)
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
checkedFilters() {
|
|
27
|
-
let checked = document.querySelector('div.side-bar').querySelectorAll('input.checkbox:checked')
|
|
28
|
-
|
|
29
|
-
let checkedValues = Object.entries(_.groupBy(_.pluck(checked, 'dataset'), 'att'))
|
|
30
|
-
|
|
31
|
-
let checkedFlatten = []
|
|
32
|
-
checkedValues.forEach(
|
|
33
|
-
([attid, values]) => {
|
|
34
|
-
checkedFlatten.push(attid + ':' + _.pluck(values, 'val').join(','))
|
|
35
|
-
}
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
return checkedFlatten.join(';')
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
sortOrder() {
|
|
42
|
-
return document.getElementById('sort').value
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
getSearchString() {
|
|
46
|
-
let filters = checkedFilters()
|
|
47
|
-
if (filters === ''){
|
|
48
|
-
return '?sort='+sortOrder()
|
|
49
|
-
} else {
|
|
50
|
-
return '?f='+filters+'&sort='+sortOrder()
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
document.querySelector('div.side-bar').querySelectorAll('input.checkbox').forEach(
|
|
61
|
-
(input) => {
|
|
62
|
-
input.addEventListener('click', () => {
|
|
63
|
-
window.location.search = getSearchString()
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
document.querySelector('#sort').addEventListener('change', () => {
|
|
69
|
-
window.location.search = getSearchString()
|
|
70
|
-
})
|