@viur/shop-components 0.0.1-dev.6 → 0.0.1-dev.61

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 (131) 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/old/client/HttpClient.js +111 -0
  7. package/old/client/ViURShopClient.js +472 -0
  8. package/old/client/index.js +23 -0
  9. package/old/client/types.js +10 -0
  10. package/old/components/ExampleUsage.vue +95 -0
  11. package/old/components/ShopCart.vue +91 -0
  12. package/old/components/ShopOrderComplete.vue +73 -0
  13. package/old/components/ShopOrderConfirm.vue +311 -0
  14. package/old/components/ShopOrderStepper.vue +352 -0
  15. package/old/components/ShopPaymentProvider.vue +113 -0
  16. package/old/components/ShopShippingMethod.vue +52 -0
  17. package/old/components/ShopSummary.vue +138 -0
  18. package/old/components/ShopUserData.vue +218 -0
  19. package/old/components/cart/CartLeaf.vue +277 -0
  20. package/old/components/cart/CartLeafModel.vue +312 -0
  21. package/old/components/cart/CartNode.vue +26 -0
  22. package/old/components/cart/CartTree.vue +67 -0
  23. package/old/components/cart/CartTreeWrapper.vue +73 -0
  24. package/old/components/cart/CartView.vue +82 -0
  25. package/old/components/cart/Discount.vue +91 -0
  26. package/old/components/generic/loadinghandler.vue +76 -0
  27. package/old/components/paymentProvider/paypalplus.vue +0 -0
  28. package/old/components/paymentProvider/prepayment.vue +0 -0
  29. package/old/components/paymentProvider/unzerPayment.vue +140 -0
  30. package/old/components/simple/ShopUserData.vue +161 -0
  31. package/old/components/simple/SimpleDefaultLayout.vue +116 -0
  32. package/old/components/ui/generic/CardSelector.vue +52 -0
  33. package/old/components/ui/generic/CartList.vue +69 -0
  34. package/old/components/ui/generic/ShippingInfo.vue +56 -0
  35. package/old/components/ui/generic/ShopPriceFormatter.vue +41 -0
  36. package/old/components/ui/generic/alerts/ShopAlert.vue +30 -0
  37. package/old/components/ui/payment/PaymentOption.vue +79 -0
  38. package/old/components/ui/payment/PaymentSelector.vue +158 -0
  39. package/old/components/ui/stepper/StepperItem.vue +90 -0
  40. package/old/components/ui/stepper/StepperTab.vue +161 -0
  41. package/old/components/ui/stepper/StepperTrigger.vue +69 -0
  42. package/old/components/ui/userdata/AddForm.vue +160 -0
  43. package/old/components/ui/userdata/AddressBox.vue +137 -0
  44. package/old/components/ui/userdata/BaseLayout.vue +77 -0
  45. package/old/components/ui/userdata/CustomBooleanBone.vue +58 -0
  46. package/old/components/ui/userdata/CustomSelectBone.vue +91 -0
  47. package/old/components/ui/userdata/CustomStringBone.vue +71 -0
  48. package/old/components/ui/userdata/DefaultLayout.vue +126 -0
  49. package/old/components/ui/userdata/SelectAddress.vue +21 -0
  50. package/old/components/ui/userdata/multi/ActionBar.vue +38 -0
  51. package/old/components/ui/userdata/multi/CartSelection.vue +42 -0
  52. package/old/ignite/.editorconfig +20 -0
  53. package/old/ignite/.github/workflows/ignite.yml +64 -0
  54. package/old/ignite/.github/workflows/node.yml +30 -0
  55. package/old/ignite/.postcssrc.cjs +25 -0
  56. package/old/ignite/CHANGELOG.md +244 -0
  57. package/old/ignite/LICENSE +21 -0
  58. package/old/ignite/README.md +92 -0
  59. package/old/ignite/dist/ignite.css +2019 -0
  60. package/old/ignite/dist/ignite.min.css +4 -0
  61. package/old/ignite/foundation/basic.css +371 -0
  62. package/old/ignite/foundation/color.css +323 -0
  63. package/old/ignite/foundation/config.css +188 -0
  64. package/old/ignite/foundation/grid.css +78 -0
  65. package/old/ignite/foundation/mediaqueries.css +71 -0
  66. package/old/ignite/foundation/reset.css +261 -0
  67. package/old/ignite/ignite.css +29 -0
  68. package/old/ignite/ignite.css.map +1 -0
  69. package/old/ignite/package-lock.json +5530 -0
  70. package/old/ignite/package.json +58 -0
  71. package/old/ignite/shoelace.css +19 -0
  72. package/old/ignite/themes/dark.css +12 -0
  73. package/old/ignite/themes/light.css +11 -0
  74. package/old/ignite/utilities/shoelace.css +537 -0
  75. package/old/ignite/utilities/utilities.css +24 -0
  76. package/old/stores/address.js +122 -0
  77. package/old/stores/cart.js +266 -0
  78. package/old/stores/message.js +21 -0
  79. package/old/stores/order.js +202 -0
  80. package/old/stores/payment.js +79 -0
  81. package/old/stores/shipping.js +78 -0
  82. package/package.json +23 -23
  83. package/src/Shop.vue +212 -0
  84. package/src/ShopOrderStepper.vue +89 -0
  85. package/src/ShopSummary.vue +170 -0
  86. package/src/Steps/ShopCart.vue +60 -0
  87. package/src/Steps/ShopOrderComplete.vue +24 -0
  88. package/src/Steps/ShopOrderConfirm.vue +295 -0
  89. package/src/Steps/ShopPaymentProvider.vue +53 -0
  90. package/src/Steps/ShopShippingMethod.vue +53 -0
  91. package/src/Steps/ShopUserDataGuest.vue +78 -0
  92. package/src/Steps/index.js +15 -0
  93. package/src/components/AddressForm.vue +84 -0
  94. package/src/components/AddressFormLayout.vue +107 -0
  95. package/src/components/CardSelector.vue +68 -0
  96. package/src/components/CartItem.vue +325 -0
  97. package/src/components/CartItemSmall.vue +257 -0
  98. package/src/components/LoadingHandler.vue +76 -0
  99. package/src/components/PaymentOption.vue +78 -0
  100. package/src/components/PaymentProviderUnzer.vue +201 -0
  101. package/src/components/PaymentSelector.vue +55 -0
  102. package/src/components/ShopAlert.vue +30 -0
  103. package/src/components/StepperTab.vue +132 -0
  104. package/src/components/dialogButton.vue +49 -0
  105. package/src/composables/address.js +95 -0
  106. package/src/composables/cart.js +132 -0
  107. package/src/composables/order.js +80 -0
  108. package/src/composables/payment.js +75 -0
  109. package/src/composables/shipping.js +32 -0
  110. package/src/main.js +44 -0
  111. package/src/shop.js +251 -0
  112. package/src/translations/de.js +15 -0
  113. package/src/translations/en.js +5 -0
  114. package/src/utils.js +49 -0
  115. package/vite.config.js +51 -0
  116. package/src/components/cart/CartView.vue +0 -692
  117. package/src/components/cart/ConfirmView.vue +0 -314
  118. package/src/components/order/category/CategoryList.vue +0 -83
  119. package/src/components/order/category/CategoryView.vue +0 -143
  120. package/src/components/order/information/UserInfoMulti.vue +0 -427
  121. package/src/components/order/information/UserInformation.vue +0 -332
  122. package/src/components/order/information/adress/ShippingAdress.vue +0 -143
  123. package/src/components/order/item/ItemCard.vue +0 -168
  124. package/src/components/order/item/ItemView.vue +0 -233
  125. package/src/components/order/process/ExampleUsage.vue +0 -100
  126. package/src/components/order/process/OrderComplete.vue +0 -41
  127. package/src/components/order/process/OrderTabHeader.vue +0 -7
  128. package/src/components/order/process/OrderView.vue +0 -210
  129. package/src/router/index.js +0 -103
  130. package/src/stores/cart.js +0 -111
  131. package/src/views/ViewMissing.vue +0 -20
package/src/shop.js ADDED
@@ -0,0 +1,251 @@
1
+
2
+ import { reactive, computed, watch, shallowRef } from "vue";
3
+ import {ShopCart, ShopUserDataGuest, ShopShippingMethod, ShopPaymentProvider, ShopOrderComplete, ShopOrderConfirm} from './Steps/index'
4
+ import { defineStore } from "pinia";
5
+ import { useUrlSearchParams } from '@vueuse/core'
6
+
7
+ import { Request } from "@viur/vue-utils";
8
+
9
+ export const useViurShopStore = defineStore("viurshopStore", () => {
10
+ const state = reactive({
11
+ //shop module name
12
+ language:"de",
13
+ moduleName:'shop',
14
+ hostUrl: computed(()=>(import.meta.env.VITE_API_URL ? import.meta.env.VITE_API_URL : window.location.origin)),
15
+ shopUrl:computed(()=>{
16
+ return `${state.hostUrl}/json/${state.moduleName}`
17
+ }),
18
+ shopApiUrl:computed(()=>{
19
+ return `${state.hostUrl}/json/${state.moduleName}/api`
20
+ }),
21
+ //default Tabs
22
+ tabs:{
23
+ cart: {
24
+ component: shallowRef(ShopCart),
25
+ displayName: "Warenkorb",
26
+ icon: { name: "cart3" },
27
+ active:computed(()=>!state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered']), //active if no orderkey or checkout not startet
28
+ validating:false,
29
+ valid:false
30
+ },
31
+ userdata: {
32
+ component: shallowRef(ShopUserDataGuest),
33
+ displayName: "Daten Eingeben",
34
+ icon: { name: "card-list" },
35
+ active:computed(()=>!state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered'] && state.cartList.length>0), //active if checkout not startet and cart is not empty
36
+ validating:false,
37
+ valid:false
38
+ },
39
+ shippingmethod: {
40
+ component: shallowRef(ShopShippingMethod),
41
+ displayName: "Versandart",
42
+ icon: { name: "truck" },
43
+ active:computed(()=>!state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered'] && state.cartRoot?.['shipping_address']), // we need a shipping country
44
+ validating:false,
45
+ valid:false
46
+ },
47
+ paymentprovider: {
48
+ component: shallowRef(ShopPaymentProvider),
49
+ displayName: "Zahlungsart auswählen",
50
+ icon: { name: "credit-card" },
51
+ active:computed(()=>!state.order?.['is_checkout_in_progress'] && state.order), // we need a active order
52
+ validating:false,
53
+ valid:false
54
+ },
55
+ confirm: {
56
+ component: shallowRef(ShopOrderConfirm),
57
+ displayName: "Bestellung prüfen",
58
+ icon: { name: "clipboard-check" },
59
+ active:computed(()=>!state.order?.['is_paid'] && state.canCheckout?.['status']), // active if canCheckout and not already paid
60
+ validating:false,
61
+ valid:false
62
+ },
63
+ complete: {
64
+ component: shallowRef(ShopOrderComplete),
65
+ displayName: "Bestellung Abgeschlossen",
66
+ icon: { name: "bag-check" },
67
+ active:computed(()=>state.order?.['is_ordered']), // active if ordered
68
+ validating:false,
69
+ valid:false
70
+ },
71
+ },
72
+ // active Tab
73
+ currentTab: "cart", // set cart as default to avoid console errors
74
+ // tabname to index mapping
75
+ tabIndexMap: computed(()=>{
76
+ let map = {}
77
+ for (const [index, item] of Object.entries(Object.keys(state.tabs))){
78
+ map[[item]] = parseInt(index)
79
+ }
80
+ return map
81
+ }),
82
+ // index to tabname mapping
83
+ indexTabMap: computed(()=>{
84
+ let map = {}
85
+ for (const [index, item] of Object.entries(Object.keys(state.tabs))){
86
+ map[[index]] = item
87
+ }
88
+ return map
89
+ }),
90
+ // length of stepper
91
+ stepperLength:computed(()=>{
92
+ return Object.keys(state.tabs).length
93
+ }),
94
+
95
+ // SHOP DATA
96
+ cartList:[], //articles in cart
97
+ cartRoot:null, //actual cart rootnode entry ( used for shipping etc)
98
+ order:null, // actual order entry ( used for billing etc.)
99
+ orderKey:null, // key of the order, maybe injected from ?order param
100
+
101
+ //CART READY
102
+ cartReady:false,
103
+ orderReady:false,
104
+ canCheckout:null,
105
+ canOrder:null,
106
+
107
+ //Address Structure
108
+ addressStructure:null,
109
+ paymentMeta:null,
110
+
111
+
112
+ //checkout
113
+ paymentProviderData:null
114
+
115
+ })
116
+
117
+ function addTab({name, component, displayname, iconname, iconlibrary,active})
118
+ {
119
+ if(Object.keys(state.tabs).includes(name)){
120
+ state.tabs[name] = {
121
+ component: component?shallowRef(component):state.tabs[name].component,
122
+ displayName: displayname?displayname:state.tabs[name].displayName,
123
+ icon: {
124
+ name: iconname?iconname:state.tabs[name].iconname,
125
+ library:iconlibrary?iconlibrary:state.tabs[name].iconlibrary
126
+ },
127
+ active:active?active:state.tabs[name].active
128
+ }
129
+ }else{
130
+ state.tabs[name] = {
131
+ component: shallowRef(component),
132
+ displayName: displayname,
133
+ icon: { name: iconname, library:iconlibrary},
134
+ active:active
135
+ }
136
+ }
137
+
138
+
139
+ }
140
+
141
+ function removeTab(name){
142
+ delete state.tabs[name]
143
+ }
144
+
145
+
146
+
147
+ function navigateToTab(name){
148
+ // navigate to Tab
149
+ state.currentTab = name
150
+
151
+ const params = useUrlSearchParams('hash')
152
+ params['step'] = state.currentTab
153
+ }
154
+
155
+ function navigateToNext(){
156
+ // shorthand for next Tab
157
+ if (state.tabIndexMap[state.currentTab] === state.stepperLength-1) return false
158
+ navigateToTab(state.indexTabMap[state.tabIndexMap[state.currentTab]+1])
159
+ }
160
+
161
+ function navigateToPrevious(){
162
+ // shorthand for previous Tab
163
+ if (state.tabIndexMap[state.currentTab] === 0) return false
164
+ navigateToTab(state.indexTabMap[state.tabIndexMap[state.currentTab]-1])
165
+ }
166
+
167
+ function fetchAddressStructure(){
168
+ Request.get(`${state.shopUrl}/address/add`).then(async (resp)=>{
169
+ let data = await resp.json()
170
+ state.addressStructure = data['structure']
171
+ })
172
+ }
173
+
174
+ function fetchPaymentMeta(){
175
+ Request.get(`${state.shopUrl}/order/payment_providers_list`).then(async (resp)=>{
176
+ let data = await resp.json()
177
+ state.paymentMeta = data
178
+ })
179
+ }
180
+
181
+ function fetchMetaData(){
182
+ fetchAddressStructure()
183
+ fetchPaymentMeta()
184
+ }
185
+
186
+ function checkout(){
187
+ //request Payment
188
+ return new Promise((resolve,reject)=>{
189
+ Request.post(`${state.shopUrl}/order/checkout_start`,{dataObj:{
190
+ order_key:state.orderKey
191
+ }}).then(async (resp)=>{
192
+ let data = await resp.json()
193
+ state.paymentProviderData = data['payment']
194
+
195
+ if (!data['payment']){
196
+ try{
197
+ await checkoutOrder() // direct Checkout
198
+ resolve()
199
+ } catch(error){
200
+ reject(error)
201
+ }
202
+ }else{
203
+ resolve()
204
+ }
205
+ }).catch(error=>{
206
+ reject(error)
207
+ })
208
+ })
209
+ }
210
+
211
+ function checkoutOrder(){
212
+ //payment is finished
213
+ return new Promise((resolve,reject)=>{
214
+ Request.post(`${state.shopUrl}/order/checkout_order`,{dataObj:{
215
+ order_key:state.orderKey
216
+ }}).then(async (resp)=>{
217
+ let data = await resp.json()
218
+ if (!resp.ok){
219
+ reject(data)
220
+ } else {
221
+ state.order = data['skel']
222
+ state.paymentProviderData = data['payment']
223
+
224
+ if(state.order?.['is_ordered']){
225
+ // order is finished
226
+ navigateToTab('complete')
227
+ }
228
+ resolve(data)
229
+ }
230
+
231
+
232
+ }).catch(error=>{
233
+ reject(error)
234
+ })
235
+ })
236
+ }
237
+
238
+ return {
239
+ state,
240
+ navigateToTab,
241
+ navigateToNext,
242
+ navigateToPrevious,
243
+ fetchMetaData,
244
+ checkout,
245
+ checkoutOrder,
246
+
247
+ addTab,
248
+ removeTab
249
+
250
+ }
251
+ })
@@ -0,0 +1,15 @@
1
+ export default {
2
+ actions:{
3
+ add: "Hinzufügen"
4
+ },
5
+ shop:{
6
+ "check_order":"Bestellung prüfen",
7
+ "order_pay":"Zahlungspflichtig bestellen",
8
+ "order_number":"Ihre Bestellnummer",
9
+ "order_thanks":"Vielen Dank für Ihre Bestellung",
10
+ "order_message":"Wir haben Ihre Bestellung erhalten und werden diese schenllstmöglich bearbeiten.<br /> Sie erhalten in wenigen Minuten eine Bestätigung per E-Mail.",
11
+ "order_paid":"Ihre Zahlung ist bei uns eingegangen.",
12
+ "order_ready_to_ship":"Ihre Bestellung ist fertig für den Versand.",
13
+ "cart_empty":"Der Warenkorb ist leer."
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ export default {
2
+ actions:{
3
+ add: "Add"
4
+ }
5
+ }
package/src/utils.js ADDED
@@ -0,0 +1,49 @@
1
+ import {Request} from '@viur/vue-utils'
2
+
3
+ export function uuid() {
4
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) =>
5
+ (
6
+ +c ^
7
+ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))
8
+ ).toString(16),
9
+ );
10
+ }
11
+
12
+ export function struct2dict(structure) {
13
+ if (!Array.isArray(structure)) {
14
+ return structure;
15
+ }
16
+
17
+ let result = {};
18
+ structure.forEach((bone) => (result[bone[0]] = bone[1]));
19
+
20
+ return result;
21
+ }
22
+
23
+ export async function getTranslations(languages=["de"]){
24
+ // fetch translations from server
25
+ let retVal = languages.reduce((acc,item)=>{acc[item]={}; return acc;},{})
26
+ try {
27
+ let translations = await Request.get("/json/_translation/get_public",{dataObj:{
28
+ languages:languages
29
+ }})
30
+ const data = await translations.json()
31
+ retVal = data
32
+ }catch(error){
33
+ console.log("No Translation from server", error)
34
+ }
35
+ return retVal
36
+ }
37
+
38
+ export function getImage(image) {
39
+ if (image !== undefined) return Request.downloadUrlFor(image);
40
+
41
+ return 'PLACEHOLDER';
42
+ }
43
+
44
+ export function removeUndefinedValues(obj) {
45
+ return Object.fromEntries(
46
+ Object.entries(obj)
47
+ .filter(([key, value]) => value !== undefined && value !== null),
48
+ );
49
+ }
package/vite.config.js ADDED
@@ -0,0 +1,51 @@
1
+ import { defineConfig } from "vite";
2
+ import vue from "@vitejs/plugin-vue";
3
+
4
+ export default defineConfig({
5
+ plugins: [
6
+ vue({
7
+ template: {
8
+ compilerOptions: {
9
+ isCustomElement: (tag) => tag.startsWith("sl-"),
10
+ },
11
+ },
12
+ }),
13
+ ],
14
+ build: {
15
+ lib: {
16
+ entry: "./src/main.js", // Adjust the entry point as needed
17
+ name: "ViurShopComponents",
18
+ fileName: (format) => `viur-shop-components.${format}.js`,
19
+ },
20
+ cssCodeSplit: false,
21
+ rollupOptions: {
22
+ external: [
23
+ "vue",
24
+ "pinia",
25
+ "@viur/shoelace",
26
+ "@viur/ignite",
27
+ "@viur/vue-utils",
28
+ "vue-router",
29
+ "@ckeditor/ckeditor5-vue",
30
+ "@ckeditor/ckeditor5-build-classic",
31
+ "@viur/ckeditor5-build-classic",
32
+ ],
33
+ output: {
34
+ assetFileNames: (assetInfo) => {
35
+ return assetInfo.name;
36
+ },
37
+ globals: {
38
+ vue: "Vue",
39
+ pinia: "Pinia",
40
+ "@viur/shoelace": "ViurShoelace",
41
+ "@viur/ignite": "ViurIgnite",
42
+ "vue-router": "VueRouter",
43
+ "@ckeditor/ckeditor5-vue": "CKEditor5Vue",
44
+ "@ckeditor/ckeditor5-build-classic": "ClassicEditor",
45
+ "@viur/ckeditor5-build-classic": "ViurCkeditor",
46
+ "@viur/vue-utils": "ViurVueUtils",
47
+ },
48
+ },
49
+ },
50
+ },
51
+ });