hemfixarna-web-components 0.3.1 → 0.9.2
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/cjs/hemfixarna-address_16.cjs.entry.js +1753 -0
- package/dist/cjs/hemfixarna-address_16.cjs.entry.js.map +1 -0
- package/dist/cjs/hemfixarna-components.cjs.js +28 -0
- package/dist/cjs/hemfixarna-components.cjs.js.map +1 -0
- package/dist/cjs/index-d9e286dc.js +1652 -0
- package/dist/cjs/index-d9e286dc.js.map +1 -0
- package/dist/cjs/index.cjs.js +4 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +24 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/collection/assets/back.svg +3 -0
- package/dist/collection/assets/cart.svg +10 -0
- package/dist/collection/assets/checked.svg +10 -0
- package/dist/collection/assets/close.svg +5 -0
- package/dist/collection/assets/copy.png +0 -0
- package/dist/collection/assets/date.svg +6 -0
- package/dist/collection/assets/down.svg +3 -0
- package/dist/collection/assets/hemfixarna.svg +11 -0
- package/dist/collection/assets/info.svg +5 -0
- package/dist/collection/assets/minus.svg +4 -0
- package/dist/collection/assets/plus.svg +5 -0
- package/dist/collection/collection-manifest.json +27 -0
- package/dist/collection/components/hemfixarna-address/hemfixarna-address.js +67 -0
- package/dist/collection/components/hemfixarna-address/hemfixarna-address.js.map +1 -0
- package/dist/collection/components/hemfixarna-box/hemfixarna-box.js +97 -0
- package/dist/collection/components/hemfixarna-box/hemfixarna-box.js.map +1 -0
- package/dist/{hemfixarna-components/hemfixarna-breadcrumbs.entry.js → collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js} +46 -11
- package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +1 -0
- package/dist/collection/components/hemfixarna-byggmax/hemfixarna-byggmax.css +0 -0
- package/dist/collection/components/hemfixarna-byggmax/hemfixarna-byggmax.js +50 -0
- package/dist/collection/components/hemfixarna-byggmax/hemfixarna-byggmax.js.map +1 -0
- package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js +41 -0
- package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +1 -0
- package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js +18 -0
- package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js.map +1 -0
- package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js +92 -0
- package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js.map +1 -0
- package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +221 -0
- package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +1 -0
- package/dist/collection/components/hemfixarna-component/hemfixarna.css +752 -0
- package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.css +118 -0
- package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js +76 -0
- package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +1 -0
- package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js +84 -0
- package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js.map +1 -0
- package/dist/{hemfixarna-components/hemfixarna-info.entry.js → collection/components/hemfixarna-info/hemfixarna-info.js} +27 -11
- package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +1 -0
- package/dist/collection/components/hemfixarna-order/hemfixarna-order.js +50 -0
- package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +1 -0
- package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js +80 -0
- package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +1 -0
- package/dist/{hemfixarna-components/hemfixarna-product.entry.js → collection/components/hemfixarna-product/hemfixarna-product.js} +15 -16
- package/dist/collection/components/hemfixarna-product/hemfixarna-product.js.map +1 -0
- package/dist/collection/components/hemfixarna-service/hemfixarna-service.js +18 -0
- package/dist/collection/components/hemfixarna-service/hemfixarna-service.js.map +1 -0
- package/dist/collection/components/hemfixarna-start/hemfixarna-start.js +41 -0
- package/dist/collection/components/hemfixarna-start/hemfixarna-start.js.map +1 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/store/index.js +25 -0
- package/dist/collection/store/index.js.map +1 -0
- package/dist/{hemfixarna-components/index-2bf8566c.js → collection/types/index.js} +3 -6
- package/dist/collection/types/index.js.map +1 -0
- package/dist/collection/utils/api.js +41 -0
- package/dist/collection/utils/api.js.map +1 -0
- package/dist/{hemfixarna-components/calc-a9ece205.js → collection/utils/calc.js} +36 -6
- package/dist/collection/utils/calc.js.map +1 -0
- package/dist/collection/utils/creditSafe.js +18 -0
- package/dist/collection/utils/creditSafe.js.map +1 -0
- package/dist/collection/utils/felixFunctions.js +189 -0
- package/dist/collection/utils/felixFunctions.js.map +1 -0
- package/dist/collection/utils/form.js +7 -0
- package/dist/collection/utils/form.js.map +1 -0
- package/dist/esm/hemfixarna-address_16.entry.js +1734 -0
- package/dist/esm/hemfixarna-address_16.entry.js.map +1 -0
- package/dist/esm/hemfixarna-components.js +23 -0
- package/dist/esm/hemfixarna-components.js.map +1 -0
- package/dist/esm/index-ca1aada9.js +1621 -0
- package/dist/esm/index-ca1aada9.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +20 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/hemfixarna-components/hemfixarna-components.esm.js +1 -162
- package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
- package/dist/hemfixarna-components/index.esm.js +0 -1
- package/dist/hemfixarna-components/index.esm.js.map +1 -1
- package/dist/hemfixarna-components/p-8829e98e.js +3 -0
- package/dist/hemfixarna-components/p-8829e98e.js.map +1 -0
- package/dist/hemfixarna-components/p-c05e2af1.entry.js +2 -0
- package/dist/hemfixarna-components/p-c05e2af1.entry.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/components/hemfixarna-address/hemfixarna-address.d.ts +1 -0
- package/dist/types/components/hemfixarna-cart/hemfixarna-cart.d.ts +1 -9
- package/dist/types/components/hemfixarna-checkout/hemfixarna-checkout.d.ts +3 -1
- package/dist/types/components/hemfixarna-getuser/hemfixarna-getuser.d.ts +1 -1
- package/dist/types/components/hemfixarna-order/hemfixarna-order.d.ts +3 -0
- package/dist/types/components/hemfixarna-orderrows/hemfixarna-orderrows.d.ts +8 -0
- package/dist/types/components.d.ts +19 -0
- package/dist/types/store/index.d.ts +2 -6
- package/dist/types/types/index.d.ts +18 -7
- package/dist/types/utils/api.d.ts +20 -2
- package/dist/types/utils/calc.d.ts +5 -1
- package/dist/types/utils/creditSafe.d.ts +3 -0
- package/dist/types/utils/form.d.ts +2 -0
- package/package.json +2 -1
- package/dist/hemfixarna-components/api-3228fe30.js +0 -28
- package/dist/hemfixarna-components/api-3228fe30.js.map +0 -1
- package/dist/hemfixarna-components/app-globals-0f993ce5.js +0 -5
- package/dist/hemfixarna-components/app-globals-0f993ce5.js.map +0 -1
- package/dist/hemfixarna-components/calc-a9ece205.js.map +0 -1
- package/dist/hemfixarna-components/css-shim-62d2171c.js +0 -6
- package/dist/hemfixarna-components/css-shim-62d2171c.js.map +0 -1
- package/dist/hemfixarna-components/dom-46a68c9b.js +0 -75
- package/dist/hemfixarna-components/dom-46a68c9b.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-address.entry.js +0 -52
- package/dist/hemfixarna-components/hemfixarna-address.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-box.entry.js +0 -35
- package/dist/hemfixarna-components/hemfixarna-box.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-breadcrumbs.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js +0 -20
- package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-cart.entry.js +0 -82
- package/dist/hemfixarna-components/hemfixarna-cart.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-category.entry.js +0 -21
- package/dist/hemfixarna-components/hemfixarna-category.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-checkout.entry.js +0 -54
- package/dist/hemfixarna-components/hemfixarna-checkout.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-component.entry.js +0 -133
- package/dist/hemfixarna-components/hemfixarna-component.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-demo.entry.js +0 -65
- package/dist/hemfixarna-components/hemfixarna-demo.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-getuser.entry.js +0 -410
- package/dist/hemfixarna-components/hemfixarna-getuser.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-info.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-order.entry.js +0 -24
- package/dist/hemfixarna-components/hemfixarna-order.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-product.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-service.entry.js +0 -21
- package/dist/hemfixarna-components/hemfixarna-service.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-start.entry.js +0 -18
- package/dist/hemfixarna-components/hemfixarna-start.entry.js.map +0 -1
- package/dist/hemfixarna-components/index-2bf8566c.js.map +0 -1
- package/dist/hemfixarna-components/index-59ed730c.js +0 -3397
- package/dist/hemfixarna-components/index-59ed730c.js.map +0 -1
- package/dist/hemfixarna-components/index-75ed3bb8.js +0 -216
- package/dist/hemfixarna-components/index-75ed3bb8.js.map +0 -1
- package/dist/hemfixarna-components/shadow-css-05e0c1f4.js +0 -389
- package/dist/hemfixarna-components/shadow-css-05e0c1f4.js.map +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap");
|
|
2
|
+
:host {
|
|
3
|
+
font-family: "Inter", sans-serif;
|
|
4
|
+
}
|
|
5
|
+
:host .hemfixarna_example {
|
|
6
|
+
margin-bottom: 1rem;
|
|
7
|
+
background: #000;
|
|
8
|
+
padding: 1rem;
|
|
9
|
+
color: #fff;
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
max-width: 500px;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
position: relative;
|
|
16
|
+
}
|
|
17
|
+
:host .hemfixarna_example--tooltip {
|
|
18
|
+
background: #000;
|
|
19
|
+
top: -3rem;
|
|
20
|
+
font-size: 16px;
|
|
21
|
+
left: 40%;
|
|
22
|
+
color: white;
|
|
23
|
+
padding: 0.5rem;
|
|
24
|
+
position: absolute;
|
|
25
|
+
opacity: 0;
|
|
26
|
+
}
|
|
27
|
+
:host .hemfixarna_example--tooltip::after {
|
|
28
|
+
content: "";
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 100%;
|
|
31
|
+
left: 50%;
|
|
32
|
+
margin-left: -5px;
|
|
33
|
+
border-width: 5px;
|
|
34
|
+
border-style: solid;
|
|
35
|
+
border-color: #000 transparent transparent transparent;
|
|
36
|
+
}
|
|
37
|
+
:host .hemfixarna_example:hover .hemfixarna_example--tooltip {
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
:host .hemfixarna_example p {
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
}
|
|
43
|
+
:host .hemfixarna_example img {
|
|
44
|
+
filter: invert(1);
|
|
45
|
+
}
|
|
46
|
+
:host .hemfixarna_install {
|
|
47
|
+
display: grid;
|
|
48
|
+
gap: 0.5rem;
|
|
49
|
+
margin-top: 1rem;
|
|
50
|
+
}
|
|
51
|
+
:host .hemfixarna_categories {
|
|
52
|
+
max-height: 100%;
|
|
53
|
+
overflow: auto;
|
|
54
|
+
position: relative;
|
|
55
|
+
}
|
|
56
|
+
:host .hemfixarna_categories--label {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
padding: 0.5rem;
|
|
61
|
+
}
|
|
62
|
+
:host .hemfixarna_categories--label button {
|
|
63
|
+
background: #3f3a92;
|
|
64
|
+
border: none;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
padding: 0.2rem 0.6rem;
|
|
67
|
+
border-radius: 10px;
|
|
68
|
+
margin-right: 0.5rem;
|
|
69
|
+
color: #ece8e8;
|
|
70
|
+
}
|
|
71
|
+
:host .hemfixarna_categories--label button:active {
|
|
72
|
+
transform: scale(0.95);
|
|
73
|
+
}
|
|
74
|
+
:host .hemfixarna_categories--label--big {
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
background: #9f9da9;
|
|
77
|
+
}
|
|
78
|
+
:host p {
|
|
79
|
+
margin: 0;
|
|
80
|
+
}
|
|
81
|
+
:host span {
|
|
82
|
+
color: darkolivegreen;
|
|
83
|
+
font-size: 10px;
|
|
84
|
+
}
|
|
85
|
+
:host button {
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
}
|
|
88
|
+
:host > div {
|
|
89
|
+
display: grid;
|
|
90
|
+
gap: 2rem;
|
|
91
|
+
width: 100%;
|
|
92
|
+
grid-template-columns: 1fr 1fr;
|
|
93
|
+
height: 100vh;
|
|
94
|
+
place-items: center;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
padding: 1rem 2rem;
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
}
|
|
99
|
+
:host > div > * {
|
|
100
|
+
width: 100%;
|
|
101
|
+
}
|
|
102
|
+
:host > div > div {
|
|
103
|
+
max-width: 500px;
|
|
104
|
+
}
|
|
105
|
+
:host > div ul {
|
|
106
|
+
margin: 0;
|
|
107
|
+
padding: 0;
|
|
108
|
+
list-style: none;
|
|
109
|
+
}
|
|
110
|
+
:host > div ul ul {
|
|
111
|
+
background: #000;
|
|
112
|
+
gap: 1px;
|
|
113
|
+
display: grid;
|
|
114
|
+
}
|
|
115
|
+
:host > div ul li {
|
|
116
|
+
padding-left: 1rem;
|
|
117
|
+
background: #fff;
|
|
118
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getAssetPath, h } from '@stencil/core';
|
|
2
|
+
import { Business, TopCategory } from '../../types';
|
|
3
|
+
import { getTaxonomy } from '../../utils/api';
|
|
4
|
+
export class MyComponent {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.cdnLink = '<script type="module" src="https://cdn.jsdelivr.net/npm//hemfixarna-web-components@latest/dist/hemfixarna-components/hemfixarna-components.esm.js"></script>';
|
|
7
|
+
this.selectedSlug = undefined;
|
|
8
|
+
this.tooltipText = 'Kopiera till urklipp';
|
|
9
|
+
this.tree = null;
|
|
10
|
+
}
|
|
11
|
+
getTopLevelCategory() {
|
|
12
|
+
switch (process.env.BUSINESS) {
|
|
13
|
+
case Business.byggmax:
|
|
14
|
+
return TopCategory.byggmax;
|
|
15
|
+
default:
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async componentWillLoad() {
|
|
20
|
+
const tree = await getTaxonomy(this.getTopLevelCategory());
|
|
21
|
+
if ((tree === null || tree === void 0 ? void 0 : tree.code) === 'not_found') {
|
|
22
|
+
console.warn('tree not found');
|
|
23
|
+
}
|
|
24
|
+
else if (tree) {
|
|
25
|
+
this.tree = tree;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
getExample() {
|
|
29
|
+
return `<hemfixarna-${process.env.BUSINESS}${this.selectedSlug ? ` slug="${this.selectedSlug}" ` : ''}></hemfixarna-${process.env.BUSINESS}>`;
|
|
30
|
+
}
|
|
31
|
+
copyExample() {
|
|
32
|
+
navigator.clipboard.writeText(this.getExample());
|
|
33
|
+
this.tooltipText = 'Snippet kopierad';
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
this.tooltipText = 'Kopiera till urklipp';
|
|
36
|
+
}, 2000);
|
|
37
|
+
}
|
|
38
|
+
copyCdn() {
|
|
39
|
+
navigator.clipboard.writeText(this.cdnLink);
|
|
40
|
+
this.tooltipText = 'Text kopierad';
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
this.tooltipText = 'Kopiera till urklipp';
|
|
43
|
+
}, 2000);
|
|
44
|
+
}
|
|
45
|
+
copyNpmInstall() {
|
|
46
|
+
navigator.clipboard.writeText('npm i hemfixarna-web-components');
|
|
47
|
+
this.tooltipText = 'Text kopierad';
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
this.tooltipText = 'Kopiera till urklipp';
|
|
50
|
+
}, 2000);
|
|
51
|
+
}
|
|
52
|
+
render() {
|
|
53
|
+
const copy = getAssetPath(`./assets/copy.png`);
|
|
54
|
+
return (h("div", null, h("div", null, h("div", { onClick: () => this.copyExample(), class: "hemfixarna_example" }, h("p", null, this.getExample()), h("img", { src: copy, height: 20 }), h("span", { class: "hemfixarna_example--tooltip" }, this.tooltipText)), process.env.BUSINESS === Business.byggmax && h("hemfixarna-byggmax", { slug: this.selectedSlug }), h("div", { class: "hemfixarna_install" }, h("div", null, h("a", { target: "_blank", href: "https://www.npmjs.com/package/hemfixarna-web-components" }, "Install with npm")), h("div", { onClick: () => this.copyNpmInstall(), class: "hemfixarna_example" }, h("p", null, "npm i hemfixarna-web-components"), h("span", { class: "hemfixarna_example--tooltip" }, this.tooltipText), h("img", { src: copy, height: 20 })), h("p", null, "Or use cdn"), h("div", { onClick: () => this.copyCdn(), class: "hemfixarna_example" }, h("p", null, this.cdnLink), h("span", { class: "hemfixarna_example--tooltip" }, this.tooltipText), h("img", { src: copy, height: 20 })))), h("ul", { class: "hemfixarna_categories" }, this.tree.sub_cats.map(c => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_categories--label--big" }, h("div", null, h("p", null, c.name), h("span", null, `category/${c.slug}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`category/${c.slug}`) }, "Kopiera slug"), h("button", { onClick: () => (this.selectedSlug = `category/${c.slug}`) }, "Ladda kategori"))), h("ul", null, c.services.map(sc => (h("li", null, h("div", { class: "hemfixarna_categories--label" }, h("div", null, h("p", null, sc.post_title), h("span", null, `service/${sc.post_name}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`service/${sc.post_name}`) }, "Kopiera slug"), h("button", { onClick: () => (this.selectedSlug = `service/${sc.post_name}`) }, "Ladda kategori"))), h("ul", null, sc.products.map(sc => (h("li", null, h("div", { class: "hemfixarna_categories--label" }, h("div", null, h("p", null, sc.post_title), h("span", null, `product/${sc.post_name}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`product/${sc.post_name}`) }, "Kopiera slug"), h("button", { onClick: () => (this.selectedSlug = `product/${sc.post_name}`) }, "Ladda kategori")))))))))))))))));
|
|
55
|
+
}
|
|
56
|
+
static get is() { return "hemfixarna-demo"; }
|
|
57
|
+
static get encapsulation() { return "shadow"; }
|
|
58
|
+
static get originalStyleUrls() {
|
|
59
|
+
return {
|
|
60
|
+
"$": ["hemfixarna-demo.scss"]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
static get styleUrls() {
|
|
64
|
+
return {
|
|
65
|
+
"$": ["hemfixarna-demo.css"]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
static get states() {
|
|
69
|
+
return {
|
|
70
|
+
"selectedSlug": {},
|
|
71
|
+
"tooltipText": {},
|
|
72
|
+
"tree": {}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=hemfixarna-demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hemfixarna-demo.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-demo/hemfixarna-demo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KA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AAE,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,WAAW,EAAE,CAAC,SAAS,EAAE,CAAC,qBAAyB,CAC3F,CACF;UACN,cACG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CACrB;YACE,WAAK,KAAK,EAAC,8BAA8B;cACvC;gBACE,aAAI,EAAE,CAAC,UAAU,CAAK;gBACtB,gBAAO,WAAW,EAAE,CAAC,SAAS,EAAE,CAAQ,CACpC;cACN;gBACE,cAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,EAAE,CAAC,mBAAuB;gBACtG,cAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,WAAW,EAAE,CAAC,SAAS,EAAE,CAAC,qBAAyB,CAC3F,CACF,CACH,CACN,CAAC,CACC,CACF,CACN,CAAC,CACC,CACF,CACN,CAAC,CACC,CACD,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, State, getAssetPath, h } from '@stencil/core';\nimport { Business, Category, TopCategory } from '../../types';\nimport { getTaxonomy } from '../../utils/api';\n\n@Component({\n tag: 'hemfixarna-demo',\n styleUrl: 'hemfixarna-demo.scss',\n shadow: true,\n})\nexport class MyComponent {\n @State() selectedSlug: string;\n @State() tooltipText: string = 'Kopiera till urklipp';\n @State() tree: Category | null = null;\n\n getTopLevelCategory() {\n switch (process.env.BUSINESS as Business) {\n case Business.byggmax:\n return TopCategory.byggmax;\n default:\n return '';\n }\n }\n\n async componentWillLoad() {\n const tree = await getTaxonomy(this.getTopLevelCategory());\n if (tree?.code === 'not_found') {\n console.warn('tree not found');\n } else if (tree) {\n this.tree = tree;\n }\n }\n\n getExample() {\n return `<hemfixarna-${process.env.BUSINESS}${this.selectedSlug ? ` slug=\"${this.selectedSlug}\" ` : ''}></hemfixarna-${process.env.BUSINESS}>`;\n }\n\n copyExample() {\n navigator.clipboard.writeText(this.getExample());\n this.tooltipText = 'Snippet kopierad';\n setTimeout(() => {\n this.tooltipText = 'Kopiera till urklipp';\n }, 2000);\n }\n\n cdnLink = '<script type=\"module\" src=\"https://cdn.jsdelivr.net/npm//hemfixarna-web-components@latest/dist/hemfixarna-components/hemfixarna-components.esm.js\"></script>';\n\n copyCdn() {\n navigator.clipboard.writeText(this.cdnLink);\n this.tooltipText = 'Text kopierad';\n setTimeout(() => {\n this.tooltipText = 'Kopiera till urklipp';\n }, 2000);\n }\n\n copyNpmInstall() {\n navigator.clipboard.writeText('npm i hemfixarna-web-components');\n this.tooltipText = 'Text kopierad';\n setTimeout(() => {\n this.tooltipText = 'Kopiera till urklipp';\n }, 2000);\n }\n\n render() {\n const copy = getAssetPath(`./assets/copy.png`);\n\n return (\n <div>\n <div>\n <div onClick={() => this.copyExample()} class=\"hemfixarna_example\">\n <p>{this.getExample()}</p>\n <img src={copy} height={20} />\n <span class=\"hemfixarna_example--tooltip\">{this.tooltipText}</span>\n </div>\n {(process.env.BUSINESS as Business) === Business.byggmax && <hemfixarna-byggmax slug={this.selectedSlug} />}\n <div class=\"hemfixarna_install\">\n <div>\n <a target=\"_blank\" href=\"https://www.npmjs.com/package/hemfixarna-web-components\">\n Install with npm\n </a>\n </div>\n <div onClick={() => this.copyNpmInstall()} class=\"hemfixarna_example\">\n <p>npm i hemfixarna-web-components</p>\n <span class=\"hemfixarna_example--tooltip\">{this.tooltipText}</span>\n <img src={copy} height={20} />\n </div>\n <p>Or use cdn</p>\n <div onClick={() => this.copyCdn()} class=\"hemfixarna_example\">\n <p>{this.cdnLink}</p>\n <span class=\"hemfixarna_example--tooltip\">{this.tooltipText}</span>\n <img src={copy} height={20} />\n </div>\n </div>\n </div>\n <ul class=\"hemfixarna_categories\">\n {this.tree.sub_cats.map(c => (\n <li>\n <div class=\"hemfixarna_categories--label hemfixarna_categories--label--big\">\n <div>\n <p>{c.name}</p>\n <span>{`category/${c.slug}`}</span>\n </div>\n <div>\n <button onClick={() => navigator.clipboard.writeText(`category/${c.slug}`)}>Kopiera slug</button>\n <button onClick={() => (this.selectedSlug = `category/${c.slug}`)}>Ladda kategori</button>\n </div>\n </div>\n <ul>\n {c.services.map(sc => (\n <li>\n <div class=\"hemfixarna_categories--label\">\n <div>\n <p>{sc.post_title}</p>\n <span>{`service/${sc.post_name}`}</span>\n </div>\n <div>\n <button onClick={() => navigator.clipboard.writeText(`service/${sc.post_name}`)}>Kopiera slug</button>\n <button onClick={() => (this.selectedSlug = `service/${sc.post_name}`)}>Ladda kategori</button>\n </div>\n </div>\n <ul>\n {sc.products.map(sc => (\n <li>\n <div class=\"hemfixarna_categories--label\">\n <div>\n <p>{sc.post_title}</p>\n <span>{`product/${sc.post_name}`}</span>\n </div>\n <div>\n <button onClick={() => navigator.clipboard.writeText(`product/${sc.post_name}`)}>Kopiera slug</button>\n <button onClick={() => (this.selectedSlug = `product/${sc.post_name}`)}>Ladda kategori</button>\n </div>\n </div>\n </li>\n ))}\n </ul>\n </li>\n ))}\n </ul>\n </li>\n ))}\n </ul>\n </div>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import Personnummer from 'personnummer';
|
|
3
|
+
import state from '../../store';
|
|
4
|
+
import apiSearch from '../../utils/creditSafe';
|
|
5
|
+
export class HemfixarnaGetuser {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.handleChangeEmail = (e) => {
|
|
8
|
+
this.emailError = null;
|
|
9
|
+
this.email = e.target.value;
|
|
10
|
+
};
|
|
11
|
+
this.handleChangePhone = (e) => {
|
|
12
|
+
this.phoneError = null;
|
|
13
|
+
this.phone = e.target.value;
|
|
14
|
+
};
|
|
15
|
+
this.handleChangessn = (e) => {
|
|
16
|
+
this.ssnError = null;
|
|
17
|
+
this.ssn = e.target.value;
|
|
18
|
+
};
|
|
19
|
+
this.handleSubmit = async (e) => {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
const emailRegex = new RegExp(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
|
|
22
|
+
const validEmail = emailRegex.test(this.email);
|
|
23
|
+
if (!validEmail) {
|
|
24
|
+
this.emailError = 'Ange en giltig e-postadress';
|
|
25
|
+
}
|
|
26
|
+
const validPhone = this.phone.length > 6;
|
|
27
|
+
if (!validPhone) {
|
|
28
|
+
this.phoneError = 'Ange ett giltigt telefonnummer';
|
|
29
|
+
}
|
|
30
|
+
const validssn = Personnummer.valid(this.ssn);
|
|
31
|
+
if (!validssn) {
|
|
32
|
+
this.ssnError = 'Ange ett giltigt personnummer';
|
|
33
|
+
}
|
|
34
|
+
else if (validssn) {
|
|
35
|
+
const pn = Personnummer.parse(this.ssn).format(true);
|
|
36
|
+
this.ssn = [pn.slice(0, 8), '-', pn.slice(8)].join('');
|
|
37
|
+
}
|
|
38
|
+
if (validEmail && validPhone && validssn) {
|
|
39
|
+
try {
|
|
40
|
+
const user = await apiSearch(this.ssn);
|
|
41
|
+
if (user) {
|
|
42
|
+
state.checkoutStep = 2;
|
|
43
|
+
state.user = Object.assign(Object.assign({}, user), { email: this.email, phone: this.phone, ssn: this.ssn });
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
|
|
51
|
+
console.log(e);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
this.render = () => {
|
|
56
|
+
return (h("form", { class: "mb-2", onSubmit: e => this.handleSubmit(e) }, h("div", null, h("input", { class: `${this.email.length ? 'input_active' : ''}`, onChange: e => this.handleChangeEmail(e), type: "email", name: "email", value: this.email }), h("label", { htmlFor: "email" }, "E-post ")), this.emailError && h("span", null, this.emailError), h("div", null, h("input", { class: `${this.phone.length ? 'input_active' : ''}`, onChange: e => this.handleChangePhone(e), type: "tel", name: "phone", value: this.phone }), h("label", { htmlFor: "phone" }, "Mobiltelefon ")), this.phoneError && h("span", null, this.phoneError), h("div", null, h("input", { class: `${this.ssn.length ? 'input_active' : ''}`, onChange: e => this.handleChangessn(e), type: "tel", name: "ssn", value: this.ssn }), h("label", { htmlFor: "phone" }, "Personnummer*")), this.ssnError && h("span", null, this.ssnError), h("input", { type: "submit", value: "Forts\u00E4tt och Boka*" }), h("p", null, "*Vi h\u00E4mtar din adress")));
|
|
57
|
+
};
|
|
58
|
+
this.email = '';
|
|
59
|
+
this.emailError = null;
|
|
60
|
+
this.phone = '';
|
|
61
|
+
this.phoneError = null;
|
|
62
|
+
this.ssn = '';
|
|
63
|
+
this.ssnError = null;
|
|
64
|
+
}
|
|
65
|
+
componentWillLoad() {
|
|
66
|
+
if (state.user) {
|
|
67
|
+
this.email = state.user.email;
|
|
68
|
+
this.phone = state.user.phone;
|
|
69
|
+
this.ssn = state.user.ssn;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
static get is() { return "hemfixarna-getuser"; }
|
|
73
|
+
static get states() {
|
|
74
|
+
return {
|
|
75
|
+
"email": {},
|
|
76
|
+
"emailError": {},
|
|
77
|
+
"phone": {},
|
|
78
|
+
"phoneError": {},
|
|
79
|
+
"ssn": {},
|
|
80
|
+
"ssnError": {}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=hemfixarna-getuser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hemfixarna-getuser.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-getuser/hemfixarna-getuser.tsx"],"names":[],"mappings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CAAC;iBA7FuB,EAAE;sBACU,IAAI;iBAChB,EAAE;sBACU,IAAI;eAClB,EAAE;oBACU,IAAI;;EAEvC,iBAAiB;IACf,IAAI,KAAK,CAAC,IAAI,EAAE;MACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;MAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;MAC9B,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;KAC3B;EACH,CAAC;;;;;;;;;;CAiFF","sourcesContent":["import { Component, State, h } from '@stencil/core';\nimport Personnummer from 'personnummer';\nimport state from '../../store';\nimport apiSearch from '../../utils/creditSafe';\nimport { User } from '../../types';\n\n@Component({\n tag: 'hemfixarna-getuser',\n shadow: false,\n})\nexport class HemfixarnaGetuser {\n @State() email: string = '';\n @State() emailError: string | null = null;\n @State() phone: string = '';\n @State() phoneError: string | null = null;\n @State() ssn: string = '';\n @State() ssnError: string | null = null;\n\n componentWillLoad() {\n if (state.user) {\n this.email = state.user.email;\n this.phone = state.user.phone;\n this.ssn = state.user.ssn;\n }\n }\n\n handleChangeEmail = (e: Event) => {\n this.emailError = null;\n this.email = (e.target as HTMLInputElement).value;\n };\n\n handleChangePhone = (e: Event) => {\n this.phoneError = null;\n this.phone = (e.target as HTMLInputElement).value;\n };\n\n handleChangessn = (e: Event) => {\n this.ssnError = null;\n this.ssn = (e.target as HTMLInputElement).value;\n };\n\n handleSubmit = async (e: Event) => {\n e.preventDefault();\n const emailRegex = new RegExp(\n /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n );\n const validEmail = emailRegex.test(this.email);\n if (!validEmail) {\n this.emailError = 'Ange en giltig e-postadress';\n }\n const validPhone = this.phone.length > 6;\n if (!validPhone) {\n this.phoneError = 'Ange ett giltigt telefonnummer';\n }\n const validssn = Personnummer.valid(this.ssn);\n if (!validssn) {\n this.ssnError = 'Ange ett giltigt personnummer';\n } else if (validssn) {\n const pn = Personnummer.parse(this.ssn).format(true);\n this.ssn = [pn.slice(0, 8), '-', pn.slice(8)].join('');\n }\n if (validEmail && validPhone && validssn) {\n try {\n const user: Partial<User> = await apiSearch(this.ssn);\n if (user) {\n state.checkoutStep = 2;\n state.user = {\n ...user,\n email: this.email,\n phone: this.phone,\n ssn: this.ssn,\n };\n } else {\n this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';\n }\n } catch (e) {\n this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';\n console.log(e);\n }\n }\n };\n\n render = () => {\n return (\n <form class=\"mb-2\" onSubmit={e => this.handleSubmit(e)}>\n <div>\n <input class={`${this.email.length ? 'input_active' : ''}`} onChange={e => this.handleChangeEmail(e)} type=\"email\" name=\"email\" value={this.email} />\n <label htmlFor=\"email\">E-post </label>\n </div>\n {this.emailError && <span>{this.emailError}</span>}\n <div>\n <input class={`${this.phone.length ? 'input_active' : ''}`} onChange={e => this.handleChangePhone(e)} type=\"tel\" name=\"phone\" value={this.phone} />\n <label htmlFor=\"phone\">Mobiltelefon </label>\n </div>\n {this.phoneError && <span>{this.phoneError}</span>}\n <div>\n <input class={`${this.ssn.length ? 'input_active' : ''}`} onChange={e => this.handleChangessn(e)} type=\"tel\" name=\"ssn\" value={this.ssn} />\n <label htmlFor=\"phone\">Personnummer*</label>\n </div>\n {this.ssnError && <span>{this.ssnError}</span>}\n <input type=\"submit\" value=\"Fortsätt och Boka*\" />\n <p>*Vi hämtar din adress</p>\n </form>\n );\n };\n}\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(hostRef) {
|
|
6
|
-
registerInstance(this, hostRef);
|
|
1
|
+
import { Fragment, getAssetPath, h } from '@stencil/core';
|
|
2
|
+
import state from '../../store';
|
|
3
|
+
export class HemfixarnaInfo {
|
|
4
|
+
constructor() {
|
|
7
5
|
this.logo = getAssetPath(`./assets/hemfixarna.svg`);
|
|
8
6
|
this.checkoutList = [
|
|
9
7
|
{ trust_badge: 'Efter att du fyllt i formuläret blir du kontaktad av en Hemfixare för bokning av tid.' },
|
|
@@ -18,8 +16,26 @@ const HemfixarnaInfo = class {
|
|
|
18
16
|
const checked = getAssetPath(`./assets/checked.svg`);
|
|
19
17
|
return (h("div", { class: "hemfixarna_info" }, state.step < 5 ? (h(Fragment, null, h("h2", null, "Vilka \u00E4r Hemfixarna?"), h("p", null, "Vi fixar allt fr\u00E5n kr\u00E5ngliga datorer till montering av m\u00F6bler. Vi finns i hela Sverige och \u00E4r alltid redo att rycka ut."))) : (h("h2", null, "Vad h\u00E4nder nu?")), h("ul", { class: "hemfixarna_features" }, this.getList().map(l => (h("li", { key: l.trust_badge }, h("img", { src: checked, alt: "checked" }), h("p", null, l.trust_badge))))), h("img", { src: this.logo, width: 200, alt: "hemfixarna" }), h("a", { class: "hemfixarna_product--link", target: "_blank", href: state.options.link.url }, state.options.link.title)));
|
|
20
18
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
static get is() { return "hemfixarna-info"; }
|
|
20
|
+
static get properties() {
|
|
21
|
+
return {
|
|
22
|
+
"list": {
|
|
23
|
+
"type": "unknown",
|
|
24
|
+
"mutable": false,
|
|
25
|
+
"complexType": {
|
|
26
|
+
"original": "{ trust_badge: string }[]",
|
|
27
|
+
"resolved": "{ trust_badge: string; }[]",
|
|
28
|
+
"references": {}
|
|
29
|
+
},
|
|
30
|
+
"required": false,
|
|
31
|
+
"optional": true,
|
|
32
|
+
"docs": {
|
|
33
|
+
"tags": [],
|
|
34
|
+
"text": ""
|
|
35
|
+
},
|
|
36
|
+
"defaultValue": "null"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=hemfixarna-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hemfixarna-info.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-info/hemfixarna-info.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,KAAK,MAAM,aAAa,CAAC;AAMhC,MAAM,OAAO,cAAc;;IACzB,SAAI,GAAG,YAAY,CAAC,yBAAyB,CAAC,CAAC;IAG/C,iBAAY,GAAG;MACb,EAAE,WAAW,EAAE,uFAAuF,EAAE;MACxG,EAAE,WAAW,EAAE,iEAAiE,EAAE;KACnF,CAAC;gBALyC,IAAI;;EAO/C,OAAO;IACL,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;EACnD,CAAC;EAED,MAAM;IACJ,MAAM,OAAO,GAAG,YAAY,CAAC,sBAAsB,CAAC,CAAC;IACrD,OAAO,CACL,WAAK,KAAK,EAAC,iBAAiB;MACzB,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAChB,EAAC,QAAQ;QACP,0CAA6B;QAC7B,2JAA8H,CACrH,CACZ,CAAC,CAAC,CAAC,CACF,oCAAuB,CACxB;MACD,UAAI,KAAK,EAAC,qBAAqB,IAC5B,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACvB,UAAI,GAAG,EAAE,CAAC,CAAC,WAAW;QACpB,WAAK,GAAG,EAAE,OAAO,EAAE,GAAG,EAAC,SAAS,GAAG;QACnC,aAAI,CAAC,CAAC,WAAW,CAAK,CACnB,CACN,CAAC,CACC;MACL,WAAK,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAC,YAAY,GAAG;MACpD,SAAG,KAAK,EAAC,0BAA0B,EAAC,MAAM,EAAC,QAAQ,EAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAC7E,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CACvB,CACA,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Fragment, Prop, getAssetPath, h } from '@stencil/core';\nimport state from '../../store';\n\n@Component({\n tag: 'hemfixarna-info',\n shadow: false,\n})\nexport class HemfixarnaInfo {\n logo = getAssetPath(`./assets/hemfixarna.svg`);\n @Prop() list?: { trust_badge: string }[] = null;\n\n checkoutList = [\n { trust_badge: 'Efter att du fyllt i formuläret blir du kontaktad av en Hemfixare för bokning av tid.' },\n { trust_badge: 'När jobbet är klart kommer du få en faktura med RUT/ROT-avdrag.' },\n ];\n\n getList() {\n return this.list ? this.list : this.checkoutList;\n }\n\n render() {\n const checked = getAssetPath(`./assets/checked.svg`);\n return (\n <div class=\"hemfixarna_info\">\n {state.step < 5 ? (\n <Fragment>\n <h2>Vilka är Hemfixarna?</h2>\n <p>Vi fixar allt från krångliga datorer till montering av möbler. Vi finns i hela Sverige och är alltid redo att rycka ut.</p>\n </Fragment>\n ) : (\n <h2>Vad händer nu?</h2>\n )}\n <ul class=\"hemfixarna_features\">\n {this.getList().map(l => (\n <li key={l.trust_badge}>\n <img src={checked} alt=\"checked\" />\n <p>{l.trust_badge}</p>\n </li>\n ))}\n </ul>\n <img src={this.logo} width={200} alt=\"hemfixarna\" />\n <a class=\"hemfixarna_product--link\" target=\"_blank\" href={state.options.link.url}>\n {state.options.link.title}\n </a>\n </div>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import state from '../../store';
|
|
3
|
+
export class HemfixarnaOrder {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.render = () => {
|
|
6
|
+
return (h("div", { style: { background: `url(${state.options.thank_you_image})` }, class: "hemfixarna_order" }, h("div", null), h("div", null, h("h2", null, "Tack f\u00F6r din bokning"), h("hemfixarna-orderrows", { tree: this.tree, cart: false }), h("span", { onClick: () => this.resetShop() }, h("button", null, "G\u00F6r en ny bokning")), h("hemfixarna-info", { list: [
|
|
7
|
+
{ trust_badge: 'Du kommer bli kontaktad av en Hemfixare för bokning av tid.' },
|
|
8
|
+
{ trust_badge: 'När jobbet är klart kommer du få en faktura med RUT/ROT-avdrag.' },
|
|
9
|
+
] }))));
|
|
10
|
+
};
|
|
11
|
+
this.tree = undefined;
|
|
12
|
+
}
|
|
13
|
+
resetShop() {
|
|
14
|
+
state.step = 1;
|
|
15
|
+
state.cart = [];
|
|
16
|
+
state.selectedCategory = null;
|
|
17
|
+
state.selectedService = null;
|
|
18
|
+
state.selectedProduct = null;
|
|
19
|
+
state.checkoutStep = 1;
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
this.resetShop();
|
|
23
|
+
}
|
|
24
|
+
static get is() { return "hemfixarna-order"; }
|
|
25
|
+
static get properties() {
|
|
26
|
+
return {
|
|
27
|
+
"tree": {
|
|
28
|
+
"type": "unknown",
|
|
29
|
+
"mutable": false,
|
|
30
|
+
"complexType": {
|
|
31
|
+
"original": "Category",
|
|
32
|
+
"resolved": "Category",
|
|
33
|
+
"references": {
|
|
34
|
+
"Category": {
|
|
35
|
+
"location": "import",
|
|
36
|
+
"path": "../../types"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": false,
|
|
41
|
+
"optional": false,
|
|
42
|
+
"docs": {
|
|
43
|
+
"tags": [],
|
|
44
|
+
"text": ""
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=hemfixarna-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hemfixarna-order.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-order/hemfixarna-order.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,MAAM,aAAa,CAAC;AAOhC,MAAM,OAAO,eAAe;;IAgB1B,WAAM,GAAG,GAAG,EAAE;MACZ,OAAO,CACL,WAAK,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC,eAAe,GAAG,EAAE,EAAE,KAAK,EAAC,kBAAkB;QAC3F,cAAW;QACX;UACE,0CAA6B;UAC7B,4BAAsB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,GAAyB;UAC3E,YAAM,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE;YACnC,2CAAkC,CAC7B;UACP,uBACE,IAAI,EAAE;cACJ,EAAE,WAAW,EAAE,6DAA6D,EAAE;cAC9E,EAAE,WAAW,EAAE,iEAAiE,EAAE;aACnF,GACD,CACE,CACF,CACP,CAAC;IACJ,CAAC,CAAC;;;EAhCF,SAAS;IACP,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC;EACzB,CAAC;EAED,oBAAoB;IAClB,IAAI,CAAC,SAAS,EAAE,CAAC;EACnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;CAsBF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\nimport state from '../../store';\nimport { Category } from '../../types';\n\n@Component({\n tag: 'hemfixarna-order',\n shadow: false,\n})\nexport class HemfixarnaOrder {\n @Prop() tree: Category;\n\n resetShop() {\n state.step = 1;\n state.cart = [];\n state.selectedCategory = null;\n state.selectedService = null;\n state.selectedProduct = null;\n state.checkoutStep = 1;\n }\n\n disconnectedCallback() {\n this.resetShop();\n }\n\n render = () => {\n return (\n <div style={{ background: `url(${state.options.thank_you_image})` }} class=\"hemfixarna_order\">\n <div></div>\n <div>\n <h2>Tack för din bokning</h2>\n <hemfixarna-orderrows tree={this.tree} cart={false}></hemfixarna-orderrows>\n <span onClick={() => this.resetShop()}>\n <button>Gör en ny bokning</button>\n </span>\n <hemfixarna-info\n list={[\n { trust_badge: 'Du kommer bli kontaktad av en Hemfixare för bokning av tid.' },\n { trust_badge: 'När jobbet är klart kommer du få en faktura med RUT/ROT-avdrag.' },\n ]}\n />\n </div>\n </div>\n );\n };\n}\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Fragment, getAssetPath, h } from '@stencil/core';
|
|
2
|
+
import state from '../../store';
|
|
3
|
+
import { calculateRot, calculateRut, getPartPrice, getProductPrice, getStartFee, getTotalPrice } from '../../utils/calc';
|
|
4
|
+
export class HemfixarnaOrderrows {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.cart = true;
|
|
7
|
+
this.tree = undefined;
|
|
8
|
+
}
|
|
9
|
+
goToProduct(id) {
|
|
10
|
+
const services = this.tree.sub_cats.map((c) => c.services).flat();
|
|
11
|
+
const products = services.map((s) => s.products).flat();
|
|
12
|
+
const product = products.find((p) => p.ID === id);
|
|
13
|
+
const service = services.find((s) => s.products.find((p) => p.ID === id));
|
|
14
|
+
const category = this.tree.sub_cats.find((c) => c.services.find((s) => s.products.find((p) => p.ID === id)));
|
|
15
|
+
state.selectedCategory = category;
|
|
16
|
+
state.selectedService = service;
|
|
17
|
+
state.selectedProduct = product;
|
|
18
|
+
state.step = 4;
|
|
19
|
+
}
|
|
20
|
+
openMontering() {
|
|
21
|
+
state.modal = {
|
|
22
|
+
title: 'Monteringsavgift',
|
|
23
|
+
text: [
|
|
24
|
+
'Monteringsavgiften är en fast avgift som läggs på din beställning. Avgiften täcker kostnader för att montera produkterna du beställer.',
|
|
25
|
+
'Monteringsavgiften debiteras per påbörjat nytt uppdrag. Om du bokar ett uppdrag som både innehåller RUT- och ROT-avdrag så kommer uppdraget att delas upp och således kommer två monteringsavgifter att debiteras och två fakturor att utställas.',
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
const info = getAssetPath(`./assets/info.svg`);
|
|
31
|
+
return (h(Fragment, null, h("ul", { class: "hemfixarna_cart--items" }, state.cart.map(item => {
|
|
32
|
+
var _a;
|
|
33
|
+
return (h("li", { class: "hemfixarna_cart--item" }, h("div", null, h("div", null, item.icon && h("img", { width: 30, src: (_a = item.icon.url) !== null && _a !== void 0 ? _a : item.icon, alt: item.name }), h("p", null, h("strong", null, item.amount, "x "), item.name)), this.cart && h("button", { onClick: () => this.goToProduct(item.id) }, "\u00C4ndra")), h("p", null, h("strong", null, getProductPrice(item, item.price, item.amount), "kr")), item.parts.length > 0 && (h("ul", null, item.parts.map(part => (h("li", null, h("p", null, h("strong", null, part.amount, "x "), part.name), h("p", null, h("strong", null, getPartPrice(part, item, part.amount), "kr")))))))));
|
|
34
|
+
})), h("div", { class: "hemfixarna_cart--additional" }, getStartFee().length > 0 && (h("div", { class: "hemfixarna_cart--startfee" }, h("p", null, getStartFee().length, "x", ' ', h("strong", { onClick: () => this.openMontering() }, "Monteringsavgift", h("img", { height: 16, src: info, alt: "info monteringsavgift" }))), h("p", null, getStartFee().rot + getStartFee().rut, "kr"))), state.cart.find((item) => item.rot) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, this.cart && (h("label", { class: "switch" }, h("input", { checked: state.rot, onChange: () => (state.rot = !state.rot), type: "checkbox" }), h("span", { class: "slider" }))), h("p", null, "ROT-avdrag")), h("p", null, "(-", state.rot ? calculateRot() : 0, "kr)"))), state.cart.find((item) => item.rut) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, h("label", { class: "switch" }, h("input", { onChange: () => (state.rut = !state.rut), checked: state.rut, type: "checkbox" }), h("span", { class: "slider" })), h("p", null, "RUT-avdrag")), h("p", null, "(-", state.rut ? calculateRut() : 0, "kr)")))), h("div", { class: "hemfixarna_cart--price" }, h("h2", null, "Totalbelopp: "), h("h2", null, getTotalPrice(), "kr"))));
|
|
35
|
+
}
|
|
36
|
+
static get is() { return "hemfixarna-orderrows"; }
|
|
37
|
+
static get properties() {
|
|
38
|
+
return {
|
|
39
|
+
"cart": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"mutable": false,
|
|
42
|
+
"complexType": {
|
|
43
|
+
"original": "boolean",
|
|
44
|
+
"resolved": "boolean",
|
|
45
|
+
"references": {}
|
|
46
|
+
},
|
|
47
|
+
"required": false,
|
|
48
|
+
"optional": false,
|
|
49
|
+
"docs": {
|
|
50
|
+
"tags": [],
|
|
51
|
+
"text": ""
|
|
52
|
+
},
|
|
53
|
+
"attribute": "cart",
|
|
54
|
+
"reflect": false,
|
|
55
|
+
"defaultValue": "true"
|
|
56
|
+
},
|
|
57
|
+
"tree": {
|
|
58
|
+
"type": "unknown",
|
|
59
|
+
"mutable": false,
|
|
60
|
+
"complexType": {
|
|
61
|
+
"original": "Category",
|
|
62
|
+
"resolved": "Category",
|
|
63
|
+
"references": {
|
|
64
|
+
"Category": {
|
|
65
|
+
"location": "import",
|
|
66
|
+
"path": "../../types"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"required": false,
|
|
71
|
+
"optional": false,
|
|
72
|
+
"docs": {
|
|
73
|
+
"tags": [],
|
|
74
|
+
"text": ""
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80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AC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;kBAAQ,CACxC,CACP;QACA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAChD,WAAK,KAAK,EAAC,yBAAyB;UAClC;YACE,aAAO,KAAK,EAAC,QAAQ;cACnB,aAAO,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAC,UAAU,GAAG;cACvF,YAAM,KAAK,EAAC,QAAQ,GAAQ,CACtB;YACR,0BAAiB,CACb;UACN;;YAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;kBAAQ,CACxC,CACP,CACG;MACN,WAAK,KAAK,EAAC,wBAAwB;QACjC,8BAAsB;QACtB;UAAK,aAAa,EAAE;eAAQ,CACxB,CACG,CACZ,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Fragment, Prop, getAssetPath, h } from '@stencil/core';\nimport state from '../../store';\nimport { calculateRot, calculateRut, getPartPrice, getProductPrice, getStartFee, getTotalPrice } from '../../utils/calc';\nimport { CartItem, Category, Icon } from '../../types';\n\n@Component({\n tag: 'hemfixarna-orderrows',\n shadow: false,\n})\nexport class HemfixarnaOrderrows {\n @Prop() cart: boolean = true;\n @Prop() tree: Category;\n\n goToProduct(id: number) {\n const services = this.tree.sub_cats.map((c: Category) => c.services).flat();\n const products = services.map((s: any) => s.products).flat();\n const product = products.find((p: any) => p.ID === id);\n const service = services.find((s: any) => s.products.find((p: any) => p.ID === id));\n const category = this.tree.sub_cats.find((c: any) => c.services.find((s: any) => s.products.find((p: any) => p.ID === id)));\n state.selectedCategory = category;\n state.selectedService = service;\n state.selectedProduct = product;\n state.step = 4;\n }\n\n openMontering() {\n state.modal = {\n title: 'Monteringsavgift',\n text: [\n 'Monteringsavgiften är en fast avgift som läggs på din beställning. Avgiften täcker kostnader för att montera produkterna du beställer.',\n 'Monteringsavgiften debiteras per påbörjat nytt uppdrag. Om du bokar ett uppdrag som både innehåller RUT- och ROT-avdrag så kommer uppdraget att delas upp och således kommer två monteringsavgifter att debiteras och två fakturor att utställas.',\n ],\n };\n }\n\n render() {\n const info = getAssetPath(`./assets/info.svg`);\n\n return (\n <Fragment>\n <ul class=\"hemfixarna_cart--items\">\n {state.cart.map(item => (\n <li class=\"hemfixarna_cart--item\">\n <div>\n <div>\n {item.icon && <img width={30} src={(item.icon as Icon).url ?? (item.icon as string)} alt={item.name} />}\n <p>\n <strong>{item.amount}x </strong>\n {item.name}\n </p>\n </div>\n {this.cart && <button onClick={() => this.goToProduct(item.id)}>Ändra</button>}\n </div>\n <p>\n <strong>{getProductPrice(item, item.price, item.amount)}kr</strong>\n </p>\n {item.parts.length > 0 && (\n <ul>\n {item.parts.map(part => (\n <li>\n <p>\n <strong>{part.amount}x </strong>\n {part.name}\n </p>\n <p>\n <strong>{getPartPrice(part, item, part.amount)}kr</strong>\n </p>\n </li>\n ))}\n </ul>\n )}\n </li>\n ))}\n </ul>\n <div class=\"hemfixarna_cart--additional\">\n {getStartFee().length > 0 && (\n <div class=\"hemfixarna_cart--startfee\">\n <p>\n {getStartFee().length}x{' '}\n <strong onClick={() => this.openMontering()}>\n Monteringsavgift\n <img height={16} src={info} alt=\"info monteringsavgift\" />\n </strong>\n </p>\n <p>{getStartFee().rot + getStartFee().rut}kr</p>\n </div>\n )}\n {state.cart.find((item: CartItem) => item.rot) && (\n <div class=\"hemfixarna_cart--rutrot\">\n <div>\n {this.cart && (\n <label class=\"switch\">\n <input checked={state.rot} onChange={() => (state.rot = !state.rot)} type=\"checkbox\" />\n <span class=\"slider\"></span>\n </label>\n )}\n <p>ROT-avdrag</p>\n </div>\n <p>(-{state.rot ? calculateRot() : 0}kr)</p>\n </div>\n )}\n {state.cart.find((item: CartItem) => item.rut) && (\n <div class=\"hemfixarna_cart--rutrot\">\n <div>\n <label class=\"switch\">\n <input onChange={() => (state.rut = !state.rut)} checked={state.rut} type=\"checkbox\" />\n <span class=\"slider\"></span>\n </label>\n <p>RUT-avdrag</p>\n </div>\n <p>(-{state.rut ? calculateRut() : 0}kr)</p>\n </div>\n )}\n </div>\n <div class=\"hemfixarna_cart--price\">\n <h2>Totalbelopp: </h2>\n <h2>{getTotalPrice()}kr</h2>\n </div>\n </Fragment>\n );\n }\n}\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor(hostRef) {
|
|
7
|
-
registerInstance(this, hostRef);
|
|
1
|
+
import { getAssetPath, h } from '@stencil/core';
|
|
2
|
+
import state from '../../store';
|
|
3
|
+
import { getPartPrice, getProductPrice } from '../../utils/calc';
|
|
4
|
+
export class HemfixarnaProduct {
|
|
5
|
+
constructor() {
|
|
8
6
|
this.amount = 0;
|
|
9
7
|
}
|
|
10
8
|
addProduct() {
|
|
@@ -47,7 +45,6 @@ const HemfixarnaProduct = class {
|
|
|
47
45
|
const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
|
|
48
46
|
if (productInCart) {
|
|
49
47
|
const partInCart = productInCart.parts.find(sp => sp.id === part.ID);
|
|
50
|
-
console.log(partInCart);
|
|
51
48
|
if (partInCart) {
|
|
52
49
|
partInCart.amount++;
|
|
53
50
|
productInCart.parts = [...productInCart.parts];
|
|
@@ -106,16 +103,18 @@ const HemfixarnaProduct = class {
|
|
|
106
103
|
return getProductPrice(state.selectedProduct, price);
|
|
107
104
|
}
|
|
108
105
|
render() {
|
|
109
|
-
var _a, _b;
|
|
106
|
+
var _a, _b, _c;
|
|
110
107
|
const checked = getAssetPath(`./assets/checked.svg`);
|
|
111
108
|
const plus = getAssetPath(`./assets/plus.svg`);
|
|
112
109
|
const minus = getAssetPath(`./assets/minus.svg`);
|
|
113
|
-
|
|
114
|
-
return (h("div", { class: "hemfixarna_product" }, h("div", { class: "hemfixarna_product--top" }, state.selectedProduct.icon && h("img", { width: 80, src: state.selectedProduct.icon, alt: state.selectedProduct.post_title }), h("div", null, h("h1", null, state.selectedProduct.post_title), h("h2", null, "Fr\u00E5n: ", getProductPrice(state.selectedProduct), " kr"))), h("div", { class: "hemfixarna_product--grid" }, h("div", { class: "hemfixarna_product--left" }, ((_a = state.selectedProduct.list) === null || _a === void 0 ? void 0 : _a.length) && (h("ul", { class: "hemfixarna_features" }, state.selectedProduct.list.map(l => (h("li", { key: l.bullet }, h("img", { src: checked, alt: "checked" }), h("p", null, l.bullet)))))), h("p", { class: "hemfixarna_terms" }, h("strong", null, "OBS! "), h("span", { innerHTML: state.selectedProduct.terms }))), h("div", { class: "hemfixarna_product--right" }, h("ul", null, h("li", { class: "hemfixarna_product--item" }, h("div", null, h("p", null, "Antal ", state.selectedProduct.post_title), h("p", { class: "hemfixarna_product--price" }, getProductPrice(state.selectedProduct), "kr/st")), h("div", { class: "hemfixarna_counter" }, h("img", { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removeProduct() }), h("span", null, this.getAmount()), h("img", { src: plus, onClick: () => this.addProduct() }))), ((_b = state.selectedProduct.parts) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
110
|
+
return (h("div", { class: "hemfixarna_product" }, h("div", { class: "hemfixarna_product--top" }, state.selectedProduct.icon && (h("img", { width: 80, src: (_a = state.selectedProduct.icon.url) !== null && _a !== void 0 ? _a : state.selectedProduct.icon, alt: state.selectedProduct.post_title })), h("div", null, h("h1", null, state.selectedProduct.post_title), h("h2", null, "Fr\u00E5n: ", getProductPrice(state.selectedProduct), " kr"))), h("div", { class: "hemfixarna_product--grid" }, h("div", { class: "hemfixarna_product--left" }, ((_b = state.selectedProduct.list) === null || _b === void 0 ? void 0 : _b.length) && (h("ul", { class: "hemfixarna_features" }, state.selectedProduct.list.map(l => (h("li", { key: l.bullet }, h("img", { src: checked, alt: "checked" }), h("p", null, l.bullet)))))), h("p", { class: "hemfixarna_terms" }, h("strong", null, "OBS! "), h("span", { innerHTML: state.selectedProduct.terms }))), h("div", { class: "hemfixarna_product--right" }, h("ul", null, h("li", { class: "hemfixarna_product--item" }, h("div", null, h("p", null, "Antal ", state.selectedProduct.post_title), h("p", { class: "hemfixarna_product--price" }, getProductPrice(state.selectedProduct), "kr/st")), h("div", { class: "hemfixarna_counter" }, h("img", { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removeProduct() }), h("span", null, this.getAmount()), h("img", { src: plus, onClick: () => this.addProduct() }))), ((_c = state.selectedProduct.parts) === null || _c === void 0 ? void 0 : _c.length) &&
|
|
115
111
|
state.selectedProduct.parts.map(p => (h("li", { class: "hemfixarna_part" }, h("div", null, h("p", null, p.post_title), h("p", { class: "hemfixarna_product--price" }, getPartPrice(p, state.selectedProduct), "kr/st")), h("div", { class: "hemfixarna_counter" }, h("img", { class: `${this.getPartAmount(p.ID) === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removePart(p) }), h("span", null, this.getPartAmount(p.ID)), h("img", { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: plus, onClick: () => this.addPart(p) })))))), h("h4", { class: "hemfixarna_product--total" }, "Totalt ", this.getTotalPrice(), " kr"), h("button", { onClick: () => this.goToCart(), class: `hemfixarna_buy ${this.getAmount() === 0 ? 'disabled' : ''}` }, "Boka"), state.options && h("hemfixarna-info", { list: state.options.trust })))));
|
|
116
112
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
static get is() { return "hemfixarna-product"; }
|
|
114
|
+
static get states() {
|
|
115
|
+
return {
|
|
116
|
+
"amount": {}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=hemfixarna-product.js.map
|