@rypen-dev/shared-components 7.0.19 → 7.1.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/index.js +1 -1
- package/package.json +1 -1
- package/src/components/FileDropzone.vue +91 -87
- package/src/components/FileUpload.vue +61 -63
- package/src/components/GenericLoader.vue +4 -7
- package/src/components/Loader.vue +1 -10
- package/src/components/LookupTextBox.vue +117 -109
- package/src/components/ModalWrapper.vue +27 -36
- package/src/components/NumberInput.vue +34 -25
- package/src/components/Pagination.vue +90 -92
- package/src/components/ProductImageSelector.vue +139 -140
- package/src/components/SearchableDropdownInput.vue +120 -115
- package/src/components/Slideshow.vue +96 -89
- package/src/components/TimespanInput.vue +87 -88
- package/src/components/icons/IconApprove.vue +3 -1
- package/src/components/icons/IconBase.vue +22 -21
- package/src/components/icons/IconCaret.vue +3 -1
- package/src/components/icons/IconClose.vue +3 -1
- package/src/components/icons/IconQrCode.vue +3 -1
- package/src/components/icons/IconSave.vue +3 -1
- package/src/components/icons/IconShare.vue +3 -1
|
@@ -23,48 +23,39 @@
|
|
|
23
23
|
</transition>
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
|
-
<script>
|
|
26
|
+
<script setup>
|
|
27
27
|
import IconBase from "./icons/IconBase.vue";
|
|
28
28
|
import IconClose from "./icons/IconClose.vue";
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
default: '',
|
|
40
|
-
},
|
|
41
|
-
closeable: {
|
|
42
|
-
type: Boolean,
|
|
43
|
-
default: true,
|
|
44
|
-
},
|
|
45
|
-
cssClass: String,
|
|
46
|
-
maskCssClass: String,
|
|
47
|
-
},
|
|
48
|
-
data: () => {
|
|
49
|
-
return {
|
|
50
|
-
|
|
51
|
-
}
|
|
30
|
+
import { computed, useSlots } from "vue";
|
|
31
|
+
|
|
32
|
+
const slots = useSlots();
|
|
33
|
+
const emit = defineEmits(['close']);
|
|
34
|
+
|
|
35
|
+
const props = defineProps({
|
|
36
|
+
header: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: ' ',
|
|
52
39
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
subheader: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: '',
|
|
56
43
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.$emit('close');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
44
|
+
closeable: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true,
|
|
63
47
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
cssClass: String,
|
|
49
|
+
maskCssClass: String,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const hasFooter = computed(() => {
|
|
53
|
+
return !!slots.footer;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function closeIfCloseable(e) {
|
|
57
|
+
if (props.closeable && e.target === e.currentTarget) {
|
|
58
|
+
emit('close');
|
|
68
59
|
}
|
|
69
60
|
}
|
|
70
61
|
</script>
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
ref="inputref"
|
|
9
9
|
@keydown.up.prevent="increment"
|
|
10
10
|
@keydown.down.prevent="decrement"
|
|
11
|
-
@keydown.enter="
|
|
12
|
-
@
|
|
13
|
-
@
|
|
14
|
-
@
|
|
15
|
-
@
|
|
11
|
+
@keydown.enter="change"
|
|
12
|
+
@input="updateValue"
|
|
13
|
+
@blur="change"
|
|
14
|
+
@focus="focus"
|
|
15
|
+
@paste="paste" />
|
|
16
16
|
</template>
|
|
17
17
|
<script setup>
|
|
18
18
|
import { ref, watch } from "vue";
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
const REGEXP_NUMBER = /^-?(?:\d+|\d+\.\d+|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
21
21
|
|
|
22
22
|
const props = defineProps({
|
|
23
|
-
|
|
23
|
+
value: Number,
|
|
24
24
|
min: {
|
|
25
25
|
type: Number,
|
|
26
26
|
default: 0,
|
|
@@ -46,26 +46,28 @@
|
|
|
46
46
|
type: Boolean,
|
|
47
47
|
default: false,
|
|
48
48
|
},
|
|
49
|
+
emitOnInput: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
49
53
|
});
|
|
50
|
-
|
|
51
54
|
const emit = defineEmits(['change']);
|
|
52
55
|
|
|
53
56
|
const inputref = ref(null);
|
|
54
57
|
|
|
55
|
-
const internalValue = ref(props.
|
|
58
|
+
const internalValue = ref(props.value);
|
|
59
|
+
const previousValue = ref(props.value);
|
|
56
60
|
|
|
57
61
|
// methods
|
|
58
|
-
function
|
|
59
|
-
|
|
62
|
+
function updateValue(e) {
|
|
63
|
+
if (props.emitOnInput) {
|
|
64
|
+
setValue(e.target.value, true);
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
|
|
68
|
+
// called on blur
|
|
62
69
|
function change(e) {
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function blur(e) {
|
|
67
|
-
let val = between(props.min, e.target.value, props.max);
|
|
68
|
-
if (internalValue.value !== val) {
|
|
70
|
+
if (!props.emitOnInput) {
|
|
69
71
|
setValue(e.target.value);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -90,8 +92,7 @@
|
|
|
90
92
|
return val;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
function setValue(value) {
|
|
94
|
-
const oldValue = internalValue.value;
|
|
95
|
+
function setValue(value, inputEvent = false) {
|
|
95
96
|
let newValue = Math.round(value);
|
|
96
97
|
|
|
97
98
|
if (props.min <= props.max) {
|
|
@@ -100,11 +101,13 @@
|
|
|
100
101
|
|
|
101
102
|
internalValue.value = newValue;
|
|
102
103
|
|
|
103
|
-
if (
|
|
104
|
+
if (inputref.value.value != newValue) {
|
|
104
105
|
inputref.value.value = newValue;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
+
if (!inputEvent || props.emitOnInput) {
|
|
109
|
+
emitChange();
|
|
110
|
+
}
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
function crement(up = true) {
|
|
@@ -114,6 +117,9 @@
|
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
internalValue.value += step;
|
|
120
|
+
if (props.emitOnInput) {
|
|
121
|
+
emitChange();
|
|
122
|
+
}
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
function increment(e) {
|
|
@@ -128,14 +134,17 @@
|
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
136
|
|
|
131
|
-
|
|
137
|
+
function emitChange() {
|
|
138
|
+
if (internalValue.value != previousValue.value) {
|
|
139
|
+
previousValue.value = internalValue.value;
|
|
140
|
+
emit('change', internalValue.value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
watch(() => props.value, (newValue) => {
|
|
132
145
|
const value = parseInt(newValue);
|
|
133
146
|
if (!isNaN(value) && value !== internalValue.value) {
|
|
134
147
|
setValue(value);
|
|
135
148
|
}
|
|
136
149
|
}, { immediate: true });
|
|
137
|
-
|
|
138
|
-
defineExpose({
|
|
139
|
-
triggerChange,
|
|
140
|
-
});
|
|
141
150
|
</script>
|
|
@@ -29,107 +29,105 @@
|
|
|
29
29
|
</ul>
|
|
30
30
|
</nav>
|
|
31
31
|
</template>
|
|
32
|
-
<script>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type: Number,
|
|
40
|
-
default: 7,
|
|
41
|
-
},
|
|
42
|
-
hasPreviousPage: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
default: false,
|
|
45
|
-
},
|
|
46
|
-
hasNextPage: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
default: false,
|
|
49
|
-
},
|
|
50
|
-
loading: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false,
|
|
53
|
-
},
|
|
32
|
+
<script setup>
|
|
33
|
+
import { reactive, ref, watch } from 'vue';
|
|
34
|
+
|
|
35
|
+
const props = defineProps({
|
|
36
|
+
pageIndex: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 0,
|
|
54
39
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
showInitialEllipse: false,
|
|
59
|
-
mainPageset: [],
|
|
60
|
-
subsequentPageset: [],
|
|
61
|
-
showSubsequentEllipse: false,
|
|
62
|
-
};
|
|
40
|
+
totalPages: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 0,
|
|
63
43
|
},
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
maxVisiblePages: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 7,
|
|
66
47
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
},
|
|
48
|
+
hasPreviousPage: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false,
|
|
51
|
+
},
|
|
52
|
+
hasNextPage: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false,
|
|
55
|
+
},
|
|
56
|
+
loading: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const emit = defineEmits(['navigate', 'top']);
|
|
84
63
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.subsequentPageset.splice(0);
|
|
64
|
+
const initialPageset = reactive([]);
|
|
65
|
+
const showInitialEllipse = ref(false);
|
|
66
|
+
const mainPageset = reactive([]);
|
|
67
|
+
const subsequentPageset = reactive([]);
|
|
68
|
+
const showSubsequentEllipse = ref(false);
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
70
|
+
function navigateToNext() {
|
|
71
|
+
if (props.hasNextPage) {
|
|
72
|
+
navigateToPage(props.pageIndex + 1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
96
75
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
76
|
+
function navigateToPrev() {
|
|
77
|
+
if (props.hasPreviousPage) {
|
|
78
|
+
navigateToPage(props.pageIndex - 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
102
81
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
82
|
+
function navigateToPage(page) {
|
|
83
|
+
if (page !== props.pageIndex) {
|
|
84
|
+
emit('navigate', page);
|
|
85
|
+
emit('top');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
107
88
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
89
|
+
function recalculateVisiblePages() {
|
|
90
|
+
initialPageset.splice(0);
|
|
91
|
+
showInitialEllipse.value = false;
|
|
92
|
+
mainPageset.splice(0);
|
|
93
|
+
showSubsequentEllipse.value = false;
|
|
94
|
+
subsequentPageset.splice(0);
|
|
111
95
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
96
|
+
if (props.totalPages > 0) {
|
|
97
|
+
if (props.totalPages > props.maxVisiblePages) {
|
|
98
|
+
let start = 0;
|
|
99
|
+
const middle = Math.floor(props.maxVisiblePages / 2);
|
|
100
|
+
|
|
101
|
+
if (props.pageIndex > (props.totalPages - middle - 1)) {
|
|
102
|
+
start = props.totalPages - props.maxVisiblePages;
|
|
103
|
+
} else if (props.pageIndex > middle) {
|
|
104
|
+
start = props.pageIndex - middle;
|
|
121
105
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
watch: {
|
|
128
|
-
loading(value, prev) {
|
|
129
|
-
if (!value && prev) {
|
|
130
|
-
this.recalculateVisiblePages();
|
|
106
|
+
|
|
107
|
+
if (start > 0) {
|
|
108
|
+
initialPageset.push(0);
|
|
109
|
+
showInitialEllipse.value = true;
|
|
131
110
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
111
|
+
|
|
112
|
+
for (let i = start; i < (start + props.maxVisiblePages); i++) {
|
|
113
|
+
mainPageset.push(i);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (start < props.totalPages - props.maxVisiblePages) {
|
|
117
|
+
showSubsequentEllipse.value = true;
|
|
118
|
+
subsequentPageset.push(props.totalPages - 1);
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
for (let i = 0; i < props.totalPages; i++) {
|
|
122
|
+
mainPageset.push(i);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
watch(() => props.loading, (newValue, oldValue) => {
|
|
129
|
+
if (!newValue && oldValue) {
|
|
130
|
+
recalculateVisiblePages();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
135
133
|
</script>
|
|
@@ -26,154 +26,153 @@
|
|
|
26
26
|
</nav>
|
|
27
27
|
</div>
|
|
28
28
|
</template>
|
|
29
|
-
<script>
|
|
29
|
+
<script setup>
|
|
30
30
|
import IconBase from "./icons/IconBase.vue";
|
|
31
31
|
import IconCaret from "./icons/IconCaret.vue";
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
product: Object,
|
|
42
|
-
variant: Object,
|
|
43
|
-
hasVariants: {
|
|
44
|
-
type: Boolean,
|
|
45
|
-
default: true,
|
|
46
|
-
},
|
|
47
|
-
selectedImage: String,
|
|
48
|
-
disabled: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: false,
|
|
51
|
-
},
|
|
52
|
-
showEmpty: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: false,
|
|
55
|
-
},
|
|
56
|
-
usePathPrefix: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: true,
|
|
59
|
-
},
|
|
60
|
-
forceNav: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
default: false,
|
|
63
|
-
},
|
|
33
|
+
import { ref, computed } from 'vue';
|
|
34
|
+
|
|
35
|
+
const props = defineProps({
|
|
36
|
+
imageBasePath: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: '', //IMAGE_BASE_PATH
|
|
64
39
|
},
|
|
65
|
-
data: () => {
|
|
66
|
-
return {
|
|
67
|
-
error: null,
|
|
68
40
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
product: Object,
|
|
42
|
+
variant: Object,
|
|
43
|
+
hasVariants: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: true,
|
|
72
46
|
},
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
selectedImage: String,
|
|
48
|
+
disabled: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false,
|
|
75
51
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return pathCompare === item.ImageUrl;
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
selectImage(item) {
|
|
84
|
-
if (!this.disabled) {
|
|
85
|
-
this.$emit('update', item);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
selectVariantImage() {
|
|
89
|
-
if (!this.disabled) {
|
|
90
|
-
if (this.variant) {
|
|
91
|
-
this.$emit('update', this.variant);
|
|
92
|
-
} else {
|
|
93
|
-
this.$emit('update', this.product.PrimaryImage);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
imagePath(item) {
|
|
98
|
-
if (item && item.ImageUrl) {
|
|
99
|
-
return this.imageBasePath + item.ImageUrl + ';width=100;height=100';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return null;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
previous() {
|
|
106
|
-
this.moveCarousel(-1);
|
|
107
|
-
},
|
|
108
|
-
next() {
|
|
109
|
-
this.moveCarousel(1);
|
|
110
|
-
},
|
|
111
|
-
moveCarousel(number) {
|
|
112
|
-
let newIndex = this.carouselIndex + number;
|
|
113
|
-
if (newIndex < 0) {
|
|
114
|
-
newIndex = 0;
|
|
115
|
-
} else if (newIndex > this.carouselSlideCount) {
|
|
116
|
-
newIndex = this.carouselSlideCount;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
this.carouselIndex = newIndex;
|
|
120
|
-
},
|
|
52
|
+
showEmpty: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false,
|
|
121
55
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
totalImageCount() {
|
|
127
|
-
return this.nonVariantImageCount + (this.hasVariants ? 1 : 0);
|
|
128
|
-
},
|
|
129
|
-
showArrows() {
|
|
130
|
-
return this.totalImageCount > this.maxImagesShown;
|
|
131
|
-
},
|
|
132
|
-
carouselSlideCount() {
|
|
133
|
-
return this.totalImageCount - this.maxImagesShown; //number of spaces past the default state we can move
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
currentImageUrl() {
|
|
137
|
-
if (this.selectedImage) {
|
|
138
|
-
return (this.usePathPrefix ? this.imageBasePath : '') + this.selectedImage;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return null;
|
|
142
|
-
},
|
|
143
|
-
currentImageStyle() {
|
|
144
|
-
if (this.currentImageUrl) {
|
|
145
|
-
return { 'background-image': 'url("' + this.currentImageUrl + (this.usePathPrefix ? ';width=1200;height=1200' : '') + '")' };
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return null;
|
|
149
|
-
},
|
|
150
|
-
variantImageSelected() {
|
|
151
|
-
const pathCompare = this.selectedImage.replace(this.imageBasePath, '');
|
|
152
|
-
|
|
153
|
-
return (this.selectedImage && ((this.variant && this.variant.ImageUrl === pathCompare) || (this.product && this.product.PrimaryImage && this.product.PrimaryImage.ImageUrl === pathCompare)));
|
|
154
|
-
},
|
|
155
|
-
variantImagePath() {
|
|
156
|
-
if (this.variant && this.variant.ImageUrl) {
|
|
157
|
-
return this.imageBasePath + this.variant.ImageUrl + ';width=100;height=100';
|
|
158
|
-
} else if (this.product) {
|
|
159
|
-
return this.imageBasePath + this.product.PrimaryImage.ImageUrl + ';width=100;height=100';
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return null;
|
|
163
|
-
},
|
|
164
|
-
substitutedImage() {
|
|
165
|
-
return this.variantImageSelected && this.variant && this.variant.SubstitutedImage;
|
|
166
|
-
},
|
|
167
|
-
imageListClass() {
|
|
168
|
-
return 'up-' + Math.min(this.totalImageCount, this.maxImagesShown);
|
|
169
|
-
},
|
|
170
|
-
shiftStyle() {
|
|
171
|
-
return { left: '-' + this.carouselIndex * (100 / this.maxImagesShown) + '%' };
|
|
172
|
-
},
|
|
56
|
+
usePathPrefix: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: true,
|
|
173
59
|
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
60
|
+
forceNav: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const emit = defineEmits(['update']);
|
|
66
|
+
|
|
67
|
+
const carouselIndex = ref(0);
|
|
68
|
+
const maxImagesShown = ref(6);
|
|
69
|
+
|
|
70
|
+
// selecting images
|
|
71
|
+
function imageSelected(item) {
|
|
72
|
+
const pathCompare = props.selectedImage.replace(props.imageBasePath, '');
|
|
73
|
+
return pathCompare === item.ImageUrl;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function selectImage(item) {
|
|
77
|
+
if (!props.disabled) {
|
|
78
|
+
emit('update', item);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function selectVariantImage() {
|
|
83
|
+
if (!props.disabled) {
|
|
84
|
+
if (props.variant) {
|
|
85
|
+
emit('update', props.variant);
|
|
86
|
+
} else {
|
|
87
|
+
emit('update', props.product.PrimaryImage);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const variantImageSelected = computed(() => {
|
|
93
|
+
const pathCompare = props.selectedImage.replace(props.imageBasePath, '');
|
|
94
|
+
return (props.selectedImage && ((props.variant && props.variant.ImageUrl === pathCompare) || (props.product && props.product.PrimaryImage && props.product.PrimaryImage.ImageUrl === pathCompare)));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// moving carousel
|
|
98
|
+
function previous() {
|
|
99
|
+
moveCarousel(-1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function next() {
|
|
103
|
+
moveCarousel(1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function moveCarousel(number) {
|
|
107
|
+
let newIndex = carouselIndex.value + number;
|
|
108
|
+
if (newIndex < 0) {
|
|
109
|
+
newIndex = 0;
|
|
110
|
+
} else if (newIndex > carouselSlideCount.value) {
|
|
111
|
+
newIndex = carouselSlideCount.value;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
carouselIndex.value = newIndex;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// image counts
|
|
118
|
+
const nonVariantImageCount = computed(() => {
|
|
119
|
+
return props.product ? (props.product.AdditionalImages.length + props.product.LifeStyleImages.length) : 0;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const totalImageCount = computed(() => {
|
|
123
|
+
return nonVariantImageCount.value + (props.hasVariants ? 1 : 0);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const showArrows = computed(() => {
|
|
127
|
+
return totalImageCount.value > maxImagesShown.value;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const carouselSlideCount = computed(() => {
|
|
131
|
+
return totalImageCount.value - maxImagesShown.value; //number of spaces past the default state we can move
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// image paths and styles
|
|
136
|
+
function imagePath(item) {
|
|
137
|
+
if (item && item.ImageUrl) {
|
|
138
|
+
return props.imageBasePath + item.ImageUrl + ';width=100;height=100';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const currentImageUrl = computed(() => {
|
|
145
|
+
if (props.selectedImage) {
|
|
146
|
+
return (props.usePathPrefix ? props.imageBasePath : '') + props.selectedImage;
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const currentImageStyle = computed(() => {
|
|
152
|
+
if (currentImageUrl.value) {
|
|
153
|
+
return { 'background-image': 'url("' + currentImageUrl.value + (props.usePathPrefix ? ';width=1200;height=1200' : '') + '")' };
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const variantImagePath = computed(() => {
|
|
159
|
+
if (props.variant && props.variant.ImageUrl) {
|
|
160
|
+
return props.imageBasePath + props.variant.ImageUrl + ';width=100;height=100';
|
|
161
|
+
} else if (props.product) {
|
|
162
|
+
return props.imageBasePath + props.product.PrimaryImage.ImageUrl + ';width=100;height=100';
|
|
177
163
|
}
|
|
178
|
-
|
|
164
|
+
return null;
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const imageListClass = computed(() => {
|
|
168
|
+
return 'up-' + Math.min(totalImageCount.value, maxImagesShown.value);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const shiftStyle = computed(() => {
|
|
172
|
+
return { left: '-' + carouselIndex.value * (100 / maxImagesShown.value) + '%' };
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const substitutedImage = computed(() => {
|
|
176
|
+
return variantImageSelected.value && props.variant && props.variant.SubstitutedImage;
|
|
177
|
+
});
|
|
179
178
|
</script>
|