@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
package/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ # http://editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = lf
10
+ insert_final_newline = true
11
+ trim_trailing_whitespace = true
12
+ max_line_width = 120
13
+
14
+ [*.md]
15
+ insert_final_newline = false
16
+ trim_trailing_whitespace = false
@@ -0,0 +1,42 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ push:
8
+ tags:
9
+ - v*
10
+
11
+ jobs:
12
+ publish-npm:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v4
17
+ - uses: actions/setup-node@v3
18
+ with:
19
+ node-version: 16
20
+ registry-url: https://registry.npmjs.org/
21
+ - run: npm ci
22
+ - name: Publish npm package
23
+ run: npm publish
24
+ env:
25
+ NODE_AUTH_TOKEN: ${{secrets.NPM_API_TOKEN}}
26
+
27
+
28
+ gh-release:
29
+ runs-on: ubuntu-latest
30
+ permissions: write-all
31
+ steps:
32
+ - name: Checkout
33
+ uses: actions/checkout@v4
34
+ - name: debug
35
+ run: |
36
+ echo "${{ contains(github.ref_name, 'dev') }}"
37
+ - name: Release
38
+ uses: softprops/action-gh-release@v1
39
+ # if: "!startsWith(github.ref_name, 'v-test-')"
40
+ with:
41
+ generate_release_notes: true
42
+ prerelease: ${{ contains(github.ref_name, 'dev') }}
package/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "src/style/ignite"]
2
+ path = src/style/ignite
3
+ url = git@github.com:viur-framework/ignite.git
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ViUR
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -6,6 +6,17 @@
6
6
  <a href="LICENSE">
7
7
  <img src="https://img.shields.io/github/license/viur-framework/shop-components" alt="Badge displaying the license" title="License badge">
8
8
  </a>
9
- <br>
10
- A collection of Vue.js components for the <a href="https://www.viur.dev">ViUR</a> <a href="https://github.com/viur-framework/viur-shop">shop</a>.
9
+ <br />
10
+ A collection of Vue.js components for the <a href="https://www.viur.dev">ViUR</a>
11
+ <a href="https://github.com/viur-framework/viur-shop">shop</a>.
11
12
  </div>
13
+
14
+ ### Structure
15
+ * **Main components** have to be exported in `./src/main.js`. Main Components should be in folder `./src/components`.
16
+ * **Ui Elements** for main components should be in `./src/components/ui` so everyone who contributes can see if there is an element/component already for their use.
17
+ * Components should be as small as possible to make the code easier to access and understand, thats why the directory structure has importance.
18
+ * Every logic/function according to articles/items/cart or anything else should be in the `cartStore` in `./src/stores/cart.js` - reason is as follows - all components get their data with so called props which are not "reactive" by nature. We want to trigger a rerender if we change/add/edit... items thats why anything according to that should be in the cartStore. Read the cartStore carefully and use the already existing states to grant a clean rerender/reactive process. The props all get updated as soon as the main states get updated in the `cartStore` -> rerender --> profit...
19
+
20
+ Try to understand this structure and adopt it with new components for easy implementation without much effort.
21
+
22
+ Real documentation is coming soon...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viur/shop-components",
3
- "version": "0.0.1-dev.9",
3
+ "version": "0.1.0",
4
4
  "description": "Frontend Vue components for the shop module of ViUR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,17 +17,29 @@
17
17
  "url": "https://github.com/viur-framework/shop-components/issues"
18
18
  },
19
19
  "homepage": "https://github.com/viur-framework/shop-components#readme",
20
- "devDependencies": {
21
- "postcss-custom-media": "^10.0.0",
22
- "postcss-nesting": "^12.0.0",
23
- "prettier": "^3.2.5"
20
+ "main": "src/main.js",
21
+ "scripts": {
22
+ "build": "vite build",
23
+ "watch": "vite build --watch"
24
24
  },
25
25
  "dependencies": {
26
- "@viur/ignite": "^5.0.2",
27
- "@viur/shoelace": "^1.0.6-v2.15.0",
28
- "@viur/vue-utils": "^1.4.5",
29
- "pinia": "^2.1.7",
30
- "vue": "^3.4.27",
31
- "vue-router": "^4.3.2"
26
+ "@tanstack/vue-table": "^8.20.5",
27
+ "@viur/ignite": "^5.1.2",
28
+ "@viur/shoelace": "^1.0.8-v2.19.0",
29
+ "@viur/vue-utils": "^1.8.2",
30
+ "@vueuse/core": "^11.1.0",
31
+ "pinia": "^2.2.4",
32
+ "primevue": "^4.1.1",
33
+ "vue": "^3.5.12",
34
+ "vue-i18n": "^10.0.4",
35
+ "vue-router": "^4.4.5"
36
+ },
37
+ "devDependencies": {
38
+ "@faker-js/faker": "^9.0.3",
39
+ "@vitejs/plugin-vue": "^5.1.4",
40
+ "postcss-custom-media": "^11.0.3",
41
+ "postcss-nesting": "^13.0.0",
42
+ "prettier": "^3.3.3",
43
+ "vite": "^5.4.9"
32
44
  }
33
45
  }
package/src/Shop.vue ADDED
@@ -0,0 +1,232 @@
1
+ <template>
2
+ <div class="bind viur-shop-wrap" v-bind="$attrs" v-if="shopStore.state.cartReady && shopStore.state.orderReady">
3
+ <div class="viur-shop-stepper-wrap"
4
+ :class="{ 'full-width': (!summary || summary==='bottom' || shopStore.state.currentTab==='complete') }"
5
+ >
6
+ <shop-order-stepper >
7
+ <template #template_cart>
8
+ <slot name="template_cart"></slot>
9
+ </template>
10
+ <template #template_userdata>
11
+ <slot name="template_userdata"></slot>
12
+ </template>
13
+ <template #template_shippingmethod>
14
+ <slot name="template_shippingmethod"></slot>
15
+ </template>
16
+ <template #template_paymentprovider>
17
+ <slot name="template_paymentprovider"></slot>
18
+ </template>
19
+ <template #template_confirm>
20
+ <slot name="template_confirm"></slot>
21
+ </template>
22
+ <template #template_complete>
23
+ <slot name="template_complete"></slot>
24
+ </template>
25
+ </shop-order-stepper>
26
+ </div>
27
+
28
+ <div class="viur-shop-sidebar-wrap" :class="{ bottom: (summary==='bottom') }" v-if="shopStore.state.currentTab!=='complete'">
29
+ <shop-summary ></shop-summary>
30
+ </div>
31
+ </div>
32
+ <template v-if="shopStore.state.debug">
33
+ <sl-details summary="Debug">
34
+ order: {{ shopStore.state.orderKey }}<br>
35
+ cart: {{ shopStore.state.cartRoot?.['key'] }}<br><br>
36
+
37
+ shippingaddress: {{shopStore.state.cartRoot?.['shipping_address']}}<br>
38
+ billingaddress: {{shopStore.state.order?.['billing_address']}}<br><br>
39
+
40
+ shipping: {{shopStore.state.cartRoot?.['shipping']}}<br><br>
41
+ Payment: {{shopStore.state.order?.['payment_provider']}}<br><br>
42
+
43
+ Order Status<br>
44
+ ------<br>
45
+ canCheckout: {{ shopStore.state.canCheckout }}<br>
46
+ canOrder: {{ shopStore.state.canOrder }}<br>
47
+ CheckoutStarted: {{ shopStore.state.order?.['is_checkout_in_progress'] }}<br><br>
48
+
49
+ ordered: {{ shopStore.state.order?.['is_ordered'] }}<br>
50
+ readytoship: {{ shopStore.state.order?.['is_rts'] }}<br>
51
+ paid: {{ shopStore.state.order?.['is_paid'] }}<br><br>
52
+
53
+ OrderObject: {{shopStore.state.order}}
54
+
55
+
56
+ </sl-details>
57
+ </template>
58
+ <div id="dialogs"></div>
59
+ </template>
60
+
61
+
62
+ <script setup>
63
+ import { onBeforeMount } from 'vue';
64
+ import ShopOrderStepper from './ShopOrderStepper.vue'
65
+ import ShopSummary from "./ShopSummary.vue"
66
+ import {useViurShopStore} from './shop'
67
+ import { useUrlSearchParams } from '@vueuse/core'
68
+ import { useOrder } from './composables/order';
69
+ import { useCart } from './composables/cart';
70
+
71
+
72
+ const shopStore = useViurShopStore()
73
+ const {fetchOrder} = useOrder()
74
+ const {fetchCart} = useCart()
75
+
76
+ const props = defineProps({
77
+ summary:{
78
+ default:false
79
+ }, // bottom, sidebar
80
+ initTab:{
81
+ default:'cart'
82
+ },
83
+ modulename:{
84
+ default:'shop'
85
+ },
86
+ debug:false,
87
+ showCartNodes:false
88
+ })
89
+
90
+
91
+ onBeforeMount(()=>{
92
+ shopStore.state.showNodes = props.showCartNodes
93
+ shopStore.state.debug = props.debug
94
+ if(props.tabs){
95
+ shopStore.state.tabs = props.tabs
96
+ }
97
+
98
+ shopStore.state.moduleName= props.modulename
99
+ fetchCart()
100
+ shopStore.fetchMetaData()
101
+ const params = useUrlSearchParams('hash')
102
+ if (Object.keys(params).includes('order')){
103
+ shopStore.state.orderKey = params['order']
104
+ fetchOrder(shopStore.state.orderKey).then(()=>{
105
+ shopStore.state.orderReady = true
106
+ // navigate to order state
107
+ if(shopStore.state.order?.['is_ordered']){
108
+ shopStore.navigateToTab('complete')
109
+ } else if (shopStore.state.order?.['is_checkout_in_progress']){
110
+ shopStore.navigateToTab('confirm')
111
+ }
112
+ })
113
+ }else{
114
+ shopStore.state.orderReady = true
115
+ }
116
+
117
+
118
+ if (Object.keys(params).includes('step')){
119
+ shopStore.navigateToTab(params['step'])
120
+ }else{
121
+ shopStore.navigateToTab('cart')
122
+ }
123
+
124
+
125
+
126
+
127
+ })
128
+
129
+
130
+
131
+ </script>
132
+
133
+ <style scoped>
134
+
135
+ * {
136
+ box-sizing: border-box;
137
+ }
138
+
139
+ .viur-shop-wrap {
140
+ --shop-sidebar-background: var(--sl-color-neutral-100);
141
+ --shop-sidebar-columns: 4;
142
+ --shop-main-columns: 8;
143
+ --shop-tab-color: var(--sl-color-neutral-400);
144
+ --shop-tab-color-active: var(--ignt-color-primary);
145
+
146
+ --shop-form-headline-size: 1.5em;
147
+ --shop-success-headline-size: var(--shop-form-headline-size);
148
+
149
+ display: grid;
150
+ grid-template-columns: repeat(12, minmax(0, 1fr));
151
+ grid-template-rows: 1fr max-content;
152
+ grid-gap: var(--ignt-spacing-2x-large);
153
+
154
+ width: 100%;
155
+ border: 0 white solid;
156
+ }
157
+
158
+ @layer foundation.shop {
159
+ :root{
160
+ --viur-shop-sidebar-height-offset:0;
161
+ }
162
+ .viur-shop-sidebar-wrap {
163
+ --padding: var(--sl-spacing-large);
164
+
165
+ display: flex;
166
+ flex-direction: column;
167
+ background-color: var(--shop-sidebar-background);
168
+ padding: var(--sl-spacing-medium);
169
+ overflow: hidden;
170
+ border-radius: var(--sl-border-radius-medium);
171
+ grid-column: auto / span var(--shop-sidebar-columns);
172
+ /* height has to be set or sidebar grows until infinity... */
173
+ height: min-content;
174
+ @media (min-width: 1024px) {
175
+ position: sticky;
176
+ max-height: calc(100vh - var(--viur-shop-sidebar-height-offset) - 2 * var(--padding));
177
+ top: var(--padding);
178
+ bottom: var(--padding);
179
+ }
180
+ }
181
+
182
+ .viur-shop-stepper-wrap {
183
+ display: flex;
184
+ flex-direction: column;
185
+ grid-column: auto / span var(--shop-main-columns);
186
+
187
+ @media (max-width: 1024px) {
188
+ grid-column: auto / span 12;
189
+ }
190
+
191
+ @media (max-width: 600px) {
192
+ &::part(active-tab-indicator) {
193
+ display: none;
194
+ }
195
+ }
196
+ }
197
+
198
+ .viur-shop-form-footer {
199
+ height: fit-content;
200
+
201
+ /* TODO: sticky Trigger yes no? */
202
+ /* position: sticky;
203
+ bottom: 2rem; */
204
+ }
205
+
206
+ :deep(.viur-shop-form-footer) {
207
+ display: flex;
208
+ justify-content: space-between;
209
+ margin-top: var(--sl-spacing-large);
210
+ }
211
+
212
+ .flex-end {
213
+ justify-content: flex-end;
214
+ }
215
+
216
+ .bottom {
217
+ grid-column: auto / span 12;
218
+ grid-row-start: 2;
219
+ }
220
+
221
+ .full-width {
222
+ grid-column: auto / span 12;
223
+ }
224
+
225
+ .last-row {
226
+ grid-row-start: 3;
227
+ }
228
+ }
229
+
230
+
231
+
232
+ </style>
@@ -0,0 +1,114 @@
1
+ <template>
2
+ <sl-tab-group
3
+ class="viur-shop-order-tabgroup"
4
+ noScrollControls
5
+ ref="stepper"
6
+ >
7
+ <template v-for="(tab,name) in shopStore.state.tabs">
8
+ <StepperTab
9
+ :tab="name"
10
+ >
11
+ </StepperTab>
12
+
13
+ <sl-tab-panel :name="name">
14
+ <template v-if="tab?.['loaded']">
15
+
16
+
17
+ <component :is="tab['component']">
18
+ <template #['template_'+name]>
19
+ <slot :name="'template_'+name"></slot>
20
+ </template>
21
+
22
+ <template v-slot="slotProps">
23
+ <sl-bar>
24
+ <div slot="right">
25
+ <span v-if="slotProps.hint" class="hint">{{ slotProps.hint }}</span>
26
+ <sl-button
27
+ :class="{'action-button-hint':slotProps.hint}"
28
+ variant="primary"
29
+ :disabled="active(slotProps)"
30
+ @click="nextStep(slotProps)"
31
+ :loading="tab['validating']"
32
+ >
33
+ {{slotProps.nextName}}
34
+ </sl-button>
35
+ </div>
36
+ </sl-bar>
37
+ </template>
38
+ </component>
39
+ </template>
40
+ </sl-tab-panel>
41
+ </template>
42
+ </sl-tab-group>
43
+ </template>
44
+
45
+ <script setup>
46
+ import {reactive, shallowRef, watch, ref, onBeforeMount, onMounted} from 'vue'
47
+ import {useViurShopStore} from './shop'
48
+ import StepperTab from './components/StepperTab.vue'
49
+ import { useTimeoutFn } from '@vueuse/core'
50
+
51
+ const shopStore = useViurShopStore()
52
+ const stepper = ref()
53
+
54
+
55
+ // Activate Tab if currentTab changes
56
+ watch(()=>shopStore.state.currentTab, (newVal, oldVal)=>{
57
+ stepper.value.show(shopStore.state.currentTab)
58
+ shopStore.state.tabs[shopStore.state.currentTab]['loaded'] = true
59
+ })
60
+
61
+ onMounted(()=>{
62
+ // wait shoelace component is ready
63
+ stepper.value.updateComplete.then(() => {
64
+ shopStore.state.tabs[shopStore.state.currentTab]['loaded'] = true
65
+ stepper.value.show(shopStore.state.currentTab)
66
+ })
67
+ })
68
+
69
+ function nextStep(obj){
70
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
71
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=true
72
+ //validate step, like send forms or something like this
73
+ Promise.resolve(obj.nextfunction()).then((resp)=>{
74
+ if (resp){
75
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=true
76
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
77
+ useTimeoutFn(() => {
78
+ shopStore.navigateToNext()
79
+ }, 300)
80
+
81
+ }else{
82
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
83
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
84
+ }
85
+ }).catch(error=>{
86
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
87
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
88
+ })
89
+ console.log("----")
90
+ }
91
+
92
+ function active(obj){
93
+ return !obj.activefunction()
94
+ }
95
+
96
+ </script>
97
+
98
+ <style scoped>
99
+
100
+ .hint{
101
+ border:1px solid var(--sl-color-neutral-200);
102
+ border-top-left-radius: var(--sl-input-border-radius-medium);
103
+ border-bottom-left-radius: var(--sl-input-border-radius-medium);
104
+ background-color: var(--sl-color-neutral-100);
105
+ color:var(--sl-color-neutral-800);
106
+ padding: 0 var(--sl-spacing-small);
107
+ height: var(--ignt-basic-line-height);
108
+
109
+ }
110
+ .action-button-hint::part(base){
111
+ border-top-left-radius: 0;
112
+ border-bottom-left-radius: 0;
113
+ }
114
+ </style>