@viur/shop-components 0.0.1-dev.9 → 0.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.
Files changed (56) hide show
  1. package/.editorconfig +16 -0
  2. package/.github/workflows/npm-publish.yml +42 -0
  3. package/.gitmodules +3 -0
  4. package/LICENSE +21 -0
  5. package/README.md +13 -2
  6. package/package.json +23 -11
  7. package/src/Shop.vue +232 -0
  8. package/src/ShopOrderStepper.vue +114 -0
  9. package/src/ShopSummary.vue +196 -0
  10. package/src/Steps/ShopCart.vue +57 -0
  11. package/src/Steps/ShopOrderComplete.vue +32 -0
  12. package/src/Steps/ShopOrderConfirm.vue +300 -0
  13. package/src/Steps/ShopPaymentProvider.vue +56 -0
  14. package/src/Steps/ShopShippingMethod.vue +67 -0
  15. package/src/Steps/ShopUserDataGuest.vue +82 -0
  16. package/src/Steps/index.js +15 -0
  17. package/src/components/AddressForm.vue +95 -0
  18. package/src/components/AddressFormLayout.vue +107 -0
  19. package/src/components/CardSelector.vue +68 -0
  20. package/src/components/CartItem.vue +353 -0
  21. package/src/components/CartItemSmall.vue +257 -0
  22. package/src/components/DiscountInput.vue +91 -0
  23. package/src/components/LoadingHandler.vue +76 -0
  24. package/src/components/PaymentOption.vue +78 -0
  25. package/src/components/PaymentProviderUnzer.vue +201 -0
  26. package/src/components/PaymentSelector.vue +55 -0
  27. package/src/components/ShopAlert.vue +30 -0
  28. package/src/components/StepperTab.vue +132 -0
  29. package/src/components/dialogButton.vue +49 -0
  30. package/src/composables/address.js +95 -0
  31. package/src/composables/cart.js +189 -0
  32. package/src/composables/order.js +80 -0
  33. package/src/composables/payment.js +75 -0
  34. package/src/composables/shipping.js +40 -0
  35. package/src/main.js +44 -0
  36. package/src/shop.js +252 -0
  37. package/src/translations/de.js +36 -0
  38. package/src/translations/en.js +5 -0
  39. package/src/utils.js +56 -0
  40. package/vite.config.js +51 -0
  41. package/src/components/cart/CartView.vue +0 -693
  42. package/src/components/cart/ConfirmView.vue +0 -314
  43. package/src/components/order/category/CategoryList.vue +0 -83
  44. package/src/components/order/category/CategoryView.vue +0 -143
  45. package/src/components/order/information/UserInfoMulti.vue +0 -427
  46. package/src/components/order/information/UserInformation.vue +0 -332
  47. package/src/components/order/information/adress/ShippingAdress.vue +0 -143
  48. package/src/components/order/item/ItemCard.vue +0 -168
  49. package/src/components/order/item/ItemView.vue +0 -233
  50. package/src/components/order/process/ExampleUsage.vue +0 -100
  51. package/src/components/order/process/OrderComplete.vue +0 -41
  52. package/src/components/order/process/OrderTabHeader.vue +0 -7
  53. package/src/components/order/process/OrderView.vue +0 -210
  54. package/src/router/index.js +0 -103
  55. package/src/stores/cart.js +0 -119
  56. package/src/views/ViewMissing.vue +0 -20
@@ -1,427 +0,0 @@
1
- <template>
2
- <!-- <slot name="form" v-if="mode === 'form'">
3
- <sl-spinner v-if="!state.isInit"></sl-spinner>
4
- <form @submit.prevent="sendData" v-else>
5
- <h2 class="viur-shop-form-input-headline headline">Nutzterdaten</h2>
6
- <div class="viur-shop-form-wrap">
7
- <sl-input
8
- name="email"
9
- v-model="state.formValues['email']"
10
- placeholder="E-Mail"
11
- class="viur-shop-form-grid-w-4"
12
- >
13
- <label slot="label">E-Mail*</label>
14
- </sl-input>
15
- <sl-input
16
- name="name"
17
- v-model="state.formValues['lastname']"
18
- placeholder="Name"
19
- class="viur-shop-form-grid-w-2"
20
- >
21
- <label slot="label">Name*</label>
22
- </sl-input>
23
- <sl-input
24
- name="firstname"
25
- v-model="state.formValues['firstname']"
26
- placeholder="Vorname"
27
- class="viur-shop-form-grid-w-2"
28
- >
29
- <label slot="label">Vorname*</label>
30
- </sl-input>
31
- </div>
32
- <div class="viur-shop-form-adress-wrapper">
33
- <div class="viur-shop-form-adress-column">
34
- <h2 class="viur-shop-form-input-headline headline">Lieferadresse</h2>
35
- <component
36
- :is="ShippingAdress"
37
- v-bind="{
38
- multiAdress: true,
39
- items: cartStore.state.carts[cartStore.state.basket].items,
40
- }"
41
- v-for="a in state.shippingAdressAmount"
42
- :key="a"
43
- @adressInput="log"
44
- @itemSelection="log"
45
- ></component>
46
-
47
- <div class="viur-shop-form-btn-wrap">
48
-
49
- <sl-button
50
- size="medium"
51
- @click="decreaseAdress"
52
- title="Lieferadresse entfernen"
53
- >
54
- <sl-icon name="x-lg"
55
- slot="prefix"></sl-icon>
56
- </sl-button>
57
- <sl-button
58
- size="medium"
59
- variant="primary"
60
- @click="increaseAdress"
61
- >
62
- <sl-icon name="plus-lg"
63
- slot="prefix"></sl-icon>
64
- Lieferadresse hinzufügen
65
- </sl-button>
66
-
67
- </div>
68
-
69
- <sl-alert
70
- variant="warning"
71
- duration="2000"
72
- ref="shippingWarning"
73
- closable
74
- >
75
- <sl-icon slot="icon" name="exclamation-triangle"></sl-icon>
76
- <strong>{{ state.amountAlert.title }} </strong><br />
77
- {{ state.amountAlert.msg }}
78
- </sl-alert>
79
- </div>
80
-
81
-
82
- <sl-checkbox @sl-change="onCustomAdressChange" checked>
83
- Rechnungsadresse wie Lieferadresse
84
- </sl-checkbox>
85
-
86
- <div class="viur-shop-form-adress-column" v-show="state.isCustomAdress">
87
- <h2 class="viur-shop-form-headline headline">Rechnungsadresse</h2>
88
- <div class="viur-shop-form-wrap">
89
- <sl-input
90
- name="street"
91
- v-model="state.formValues['billing.street']"
92
- placeholder="Straße"
93
- class="viur-shop-form-grid-w-3"
94
- >
95
- <label slot="label">Strasse *</label>
96
- </sl-input>
97
- <sl-input
98
- name="street"
99
- v-model="state.formValues['billing.streetnumber']"
100
- placeholder="Hausnummer"
101
- type="number"
102
- >
103
- <label slot="label">Hausnummer *</label>
104
- </sl-input>
105
- <sl-input
106
- name="street"
107
- v-model="state.formValues['billing.areacode']"
108
- placeholder="Postleitzahl"
109
- type="number"
110
- class="viur-shop-form-grid-w-2"
111
- >
112
- <label slot="label">Postleitzahl *</label>
113
- </sl-input>
114
- <sl-input
115
- name="city"
116
- v-model="state.formValues['billing.city']"
117
- placeholder="Stadt"
118
- class="viur-shop-form-grid-w-2"
119
- >
120
- <label slot="label">Stadt*</label>
121
- </sl-input>
122
- <sl-input
123
- name="province"
124
- v-model="state.formValues['billing.province']"
125
- placeholder="Bundesland"
126
- class="viur-shop-form-grid-w-2"
127
- >
128
- <label slot="label">Bundesland</label>
129
- </sl-input>
130
- </div>
131
- </div>
132
- </div>
133
- </form>
134
- </slot> -->
135
-
136
- <div>
137
- <h2 class="viur-shop-form-headline headline">Nutzterdaten</h2>
138
- <template v-for="item in state.addSkel" :key="item[0]">
139
- <bone
140
- :is="getBoneWidget(item[1].type)"
141
- v-if="item[1].visible && item[1].params.group === 'Customer Info'"
142
- :name="item[0]"
143
- :structure="structToDict(state.addSkel)"
144
- :errors="state.errors[item[0]] ? state.errors[item[0]] : []"
145
- :skel="state.formValues"
146
- @change="changeEvent(item[0], $event)"
147
- class="viur-shop-form-grid-w-2"
148
- >
149
- </bone>
150
- </template>
151
- </div>
152
-
153
- <h2 class="viur-shop-form-headline headline">Lieferadresse</h2>
154
- <div v-for="a in state.shippingAdressAmount" :key="a">
155
- <sl-select
156
- clearable
157
- ref="itemSelection"
158
- @sl-change="onItemSelect($event, a)"
159
- @sl-clear="onItemReset($event, a)"
160
- :label="state.selectedItem[a] ? cartStore.state.carts[state.selectedItem[a]].info.name : 'Warenkorb für Adresse wählen.'"
161
- class="grid-w-4"
162
- >
163
- <sl-option v-for="(v, k) in cartStore.state.carts" :value="k">
164
- {{ v.info.name }}</sl-option
165
- >
166
- </sl-select>
167
- <template v-for="item in state.addSkel" :key="item[0]">
168
- <bone
169
- :is="getBoneWidget(item[1].type)"
170
- v-if="item[1].visible && item[1].params.group === 'Customer Address'"
171
- :name="item[0]"
172
- :structure="structToDict(state.addSkel)"
173
- :errors="state.errors[item[0]] ? state.errors[item[0]] : []"
174
- :skel="state.formValues"
175
- @change="changeEvent(item[0], $event)"
176
- >
177
- </bone>
178
- </template>
179
- </div>
180
-
181
- <div v-if="state.isCustomAdress">
182
- <h2 class="viur-shop-form-headline headline">Rechnungsadresse</h2>
183
- <template v-for="item in state.addSkel" :key="item[0]">
184
- <bone
185
- :is="getBoneWidget(item[1].type)"
186
- v-if="item[1].visible && item[1].params.group === 'Customer Address'"
187
- :name="item[0]"
188
- :structure="structToDict(state.addSkel)"
189
- :errors="state.errors[item[0]] ? state.errors[item[0]] : []"
190
- :skel="state.formValues"
191
- @change="changeEvent(item[0], $event)"
192
- >
193
- </bone>
194
- </template>
195
- </div>
196
-
197
- <div class="viur-shop-form-btn-wrap">
198
- <sl-button
199
- size="medium"
200
- @click="decreaseAdress"
201
- title="Lieferadresse entfernen"
202
- >
203
- <sl-icon name="x-lg" slot="prefix"></sl-icon>
204
- </sl-button>
205
- <sl-button size="medium" variant="primary" @click="increaseAdress">
206
- <sl-icon name="plus-lg" slot="prefix"></sl-icon>
207
- Lieferadresse hinzufügen
208
- </sl-button>
209
- </div>
210
-
211
- <sl-alert variant="warning" duration="2000" ref="shippingWarning" closable>
212
- <sl-icon slot="icon" name="exclamation-triangle"></sl-icon>
213
- <strong>{{ state.amountAlert.title }} </strong><br />
214
- {{ state.amountAlert.msg }}
215
- </sl-alert>
216
-
217
- <sl-checkbox @sl-change="onCustomAdressChange" checked>
218
- Rechnungsadresse wie Lieferadresse
219
- </sl-checkbox>
220
- </template>
221
-
222
- <script setup>
223
- import { getBoneWidget } from "@viur/vue-utils/bones/edit/index";
224
-
225
- import { reactive, computed, watch, ref, onBeforeMount } from "vue";
226
- // import ShippingAdress from "./adress/ShippingAdress.vue";
227
- import { useCartStore } from "../../../stores/cart";
228
-
229
- const props = defineProps({
230
- mode: { type: String, default: "form" },
231
- });
232
-
233
- const cartStore = useCartStore();
234
-
235
- const state = reactive({
236
- formValues: {},
237
- requiredFieldsFilled: computed(() => {
238
- // TODO: automatisierte logik anhand der required felder aus struktur der bones
239
- if (state.isCustomAdress) {
240
- return (
241
- Object.keys(state.formValues).includes("city") &&
242
- Object.keys(state.formValues).includes("street") &&
243
- Object.keys(state.formValues).includes("billing.city") &&
244
- Object.keys(state.formValues).includes("billing.street") &&
245
- Object.keys(state.formValues).includes("email") &&
246
- Object.keys(state.formValues).includes("firstname") &&
247
- Object.keys(state.formValues).includes("lastname")
248
- );
249
- }
250
- if (!state.isCustomAdress) {
251
- return (
252
- Object.keys(state.formValues).includes("city") &&
253
- Object.keys(state.formValues).includes("street") &&
254
- Object.keys(state.formValues).includes("email") &&
255
- Object.keys(state.formValues).includes("firstname") &&
256
- Object.keys(state.formValues).includes("lastname")
257
- );
258
- }
259
- }),
260
- isCustomAdress: false,
261
- shippingAdressAmount: 1,
262
- maxShippingAdress: computed(
263
- () => Object.keys(cartStore.state.carts).length + 2,
264
- ),
265
- amountAlert: { title: "", msg: "" },
266
- items: null,
267
- addSkel: null,
268
- errors: {},
269
- selectedItem: {},
270
- isInit: computed(() => {
271
- if (cartStore.state.carts[cartStore.state.basket]) {
272
- return true;
273
- } else {
274
- return false;
275
- }
276
- }),
277
- });
278
-
279
- const itemSelection = ref(null);
280
- const shippingWarning = ref(null);
281
-
282
- // function updateFormValues(e){
283
- // state.formValues[e.target.name] = e.target.value
284
- // }
285
-
286
- function sendData(e) {
287
- console.log("sende daten...", state.formValues);
288
- }
289
-
290
- function onCustomAdressChange(e) {
291
- if (e.target.checked) state.isCustomAdress = false;
292
- if (!e.target.checked) state.isCustomAdress = true;
293
- }
294
-
295
- function increaseAdress() {
296
- if (state.shippingAdressAmount === state.maxShippingAdress) {
297
- state.amountAlert.title = "Zu viele Lieferadressen";
298
- state.amountAlert.msg = `Sie können nur maximal: "${state.maxShippingAdress}" Lieferadressen verwenden.`;
299
- shippingWarning.value.show();
300
- return;
301
- }
302
- state.shippingAdressAmount += 1;
303
- }
304
-
305
- function changeEvent(boneName, ev) {
306
- for (const [key, value] of Object.entries(ev.value[0])) {
307
- state.formValues[key] = value;
308
- }
309
- }
310
-
311
- function decreaseAdress() {
312
- if (state.shippingAdressAmount === 1) {
313
- state.amountAlert.title = "Zu wenig Lieferadressen";
314
- state.amountAlert.msg =
315
- "Mindestens eine Lieferadresse muss angegeben werden.";
316
- shippingWarning.value.show();
317
- return;
318
- }
319
- state.shippingAdressAmount -= 1;
320
- }
321
-
322
- function log(e) {
323
- console.log("emit hier", e);
324
- Object.assign(state.formValues, e);
325
- }
326
-
327
- function onItemSelect(e, a) {
328
- console.log(e.target.value);
329
- if (!e.target.value.length) {
330
- onItemReset();
331
- return;
332
- }
333
- state.selectedItem[a] = e.target.value;
334
- state.isItemSelected = true;
335
- }
336
-
337
- function onItemReset(e, a) {
338
- console.log("clearing...");
339
- delete state.selectedItem[a]
340
- state.isItemSelected = false;
341
- }
342
-
343
- function getLabel(cart) {
344
- console.log("hier", cart)
345
- if (cart) {
346
- return "Lieferadresse für: " + cartStore.state.carts[cart].info.name;
347
- }
348
- return "Warenkorb für Lieferadresse wählen.";
349
- }
350
-
351
- function structToDict(structure) {
352
- let output = {};
353
-
354
- structure.forEach((bone) => {
355
- let boneName = bone[0];
356
- let boneValues = bone[1];
357
-
358
- output[boneName] = boneValues;
359
- });
360
-
361
- return output;
362
- }
363
-
364
- watch(state.formValues, (newValues) => {
365
- Object.entries(newValues).forEach(([k, v]) => {
366
- if (v === "") {
367
- delete state.formValues[k];
368
- }
369
- });
370
- });
371
-
372
- onBeforeMount(async () => {
373
- await cartStore.getAdressStructure();
374
- state.addSkel = cartStore.state.structure.address;
375
- });
376
- </script>
377
-
378
- <style scoped>
379
- .viur-shop-form-footer {
380
- display: flex;
381
- justify-content: space-between;
382
- margin-top: var(--sl-spacing-large);
383
- }
384
-
385
- .viur-shop-form-adress-wrapper {
386
- display: flex;
387
- flex-direction: column;
388
- gap: 1rem;
389
- width: 100%;
390
- justify-content: space-around;
391
- align-items: flex-start;
392
- }
393
-
394
- .viur-shop-form-adress-column {
395
- align-self: flex-start;
396
- flex-grow: 1;
397
- }
398
-
399
- .viur-shop-form-wrap {
400
- display: grid;
401
- grid-template-columns: repeat(4, minmax(0, 1fr));
402
- gap: 0 var(--sl-spacing-medium);
403
- margin: var(--sl-spacing-large) 0;
404
- }
405
-
406
- .viur-shop-form-grid-w-2 {
407
- grid-column: span 2;
408
- }
409
-
410
- .viur-shop-form-grid-w-3 {
411
- grid-column: span 3;
412
- }
413
-
414
- .viur-shop-form-grid-w-4 {
415
- grid-column: span 4;
416
- }
417
-
418
- .viur-shop-form-btn-wrap {
419
- display: flex;
420
- flex-direction: row;
421
- flex-wrap: nowrap;
422
- justify-content: space-between;
423
- width: 100%;
424
-
425
- margin-top: var(--sl-spacing-x-large);
426
- }
427
- </style>