@rypen-dev/shared-components 7.0.20 → 8.0.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/dist/rypen-shared-components.umd.js +5 -0
- package/package.json +26 -7
- 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 +1 -2
- 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
- package/vite.config.js +31 -0
|
@@ -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>
|