hemfixarna-web-components 1.8.22 → 1.8.24
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_15.cjs.entry.js +25 -7
- package/dist/cjs/hemfixarna-address_15.cjs.entry.js.map +1 -1
- package/dist/cjs/hemfixarna-byggmax.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-components.cjs.js +1 -1
- package/dist/cjs/hemfixarna-doro.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-elfa.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-fargvaruhuset.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-flyttsmart.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-forebygg.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-hornbach.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-kbygg.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-klint.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-kund.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-norrgavel.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-power.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-skanska.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-sparfonster.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-string-furniture.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-superfront.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-tesla.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-traningspartner.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-zaptec.cjs.entry.js +1 -1
- package/dist/cjs/{index-29d438c7.js → index-53d1843b.js} +2 -1
- package/dist/cjs/index-53d1843b.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.css +6 -2
- package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js +5 -2
- package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js.map +1 -1
- package/dist/collection/types/index.js +1 -0
- package/dist/collection/types/index.js.map +1 -1
- package/dist/collection/utils/api.js +1 -1
- package/dist/collection/utils/api.js.map +1 -1
- package/dist/collection/utils/calc.js +19 -3
- package/dist/collection/utils/calc.js.map +1 -1
- package/dist/esm/hemfixarna-address_15.entry.js +25 -7
- package/dist/esm/hemfixarna-address_15.entry.js.map +1 -1
- package/dist/esm/hemfixarna-byggmax.entry.js +1 -1
- package/dist/esm/hemfixarna-components.js +1 -1
- package/dist/esm/hemfixarna-doro.entry.js +1 -1
- package/dist/esm/hemfixarna-elfa.entry.js +1 -1
- package/dist/esm/hemfixarna-fargvaruhuset.entry.js +1 -1
- package/dist/esm/hemfixarna-flyttsmart.entry.js +1 -1
- package/dist/esm/hemfixarna-forebygg.entry.js +1 -1
- package/dist/esm/hemfixarna-hornbach.entry.js +1 -1
- package/dist/esm/hemfixarna-kbygg.entry.js +1 -1
- package/dist/esm/hemfixarna-klint.entry.js +1 -1
- package/dist/esm/hemfixarna-kund.entry.js +1 -1
- package/dist/esm/hemfixarna-norrgavel.entry.js +1 -1
- package/dist/esm/hemfixarna-power.entry.js +1 -1
- package/dist/esm/hemfixarna-skanska.entry.js +1 -1
- package/dist/esm/hemfixarna-sparfonster.entry.js +1 -1
- package/dist/esm/hemfixarna-string-furniture.entry.js +1 -1
- package/dist/esm/hemfixarna-superfront.entry.js +1 -1
- package/dist/esm/hemfixarna-tesla.entry.js +1 -1
- package/dist/esm/hemfixarna-traningspartner.entry.js +1 -1
- package/dist/esm/hemfixarna-zaptec.entry.js +1 -1
- package/dist/esm/{index-a5584e27.js → index-8fbc0f86.js} +2 -1
- package/dist/esm/index-8fbc0f86.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/hemfixarna-components/hemfixarna-components.esm.js +1 -1
- package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
- package/dist/hemfixarna-components/{p-4b5cc044.entry.js → p-0b7fd505.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-8608fc99.entry.js → p-1782498a.entry.js} +2 -2
- package/dist/hemfixarna-components/p-194c73fc.entry.js +2 -0
- package/dist/hemfixarna-components/p-194c73fc.entry.js.map +1 -0
- package/dist/hemfixarna-components/{p-43b9bc83.entry.js → p-228010e3.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-fc04a8cd.js → p-2fb4a299.js} +2 -2
- package/dist/hemfixarna-components/p-2fb4a299.js.map +1 -0
- package/dist/hemfixarna-components/{p-b9ea1d82.entry.js → p-38e47d7a.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-cd1f6d8b.entry.js → p-3e409fec.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-5ca86ec7.entry.js → p-5f8148bd.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-6412e81d.entry.js → p-829ad2ad.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-33424b64.entry.js → p-91c5a8e6.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-6782a3de.entry.js → p-a2616751.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-4c80b470.entry.js → p-a5c8a4c2.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-47e183cd.entry.js → p-aaf00ed2.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-6d943088.entry.js → p-b218a4ef.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-db1bb72e.entry.js → p-bddffb3d.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-0406c2c2.entry.js → p-bec531db.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-5495cb2c.entry.js → p-c644c702.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-efbff89c.entry.js → p-caacc12c.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-e0ad480b.entry.js → p-d2c9f6dc.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-4d461ed9.entry.js → p-d6b176a1.entry.js} +2 -2
- package/dist/hemfixarna-components/{p-c0c26b18.entry.js → p-de15b378.entry.js} +2 -2
- package/dist/types/components/hemfixarna-invoice/hemfixarna-invoice.d.ts +1 -0
- package/dist/types/types/index.d.ts +5 -1
- package/dist/types/utils/api.d.ts +2 -2
- package/package.json +1 -1
- package/dist/cjs/index-29d438c7.js.map +0 -1
- package/dist/esm/index-a5584e27.js.map +0 -1
- package/dist/hemfixarna-components/p-3c749334.entry.js +0 -2
- package/dist/hemfixarna-components/p-3c749334.entry.js.map +0 -1
- package/dist/hemfixarna-components/p-fc04a8cd.js.map +0 -1
- /package/dist/hemfixarna-components/{p-4b5cc044.entry.js.map → p-0b7fd505.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-8608fc99.entry.js.map → p-1782498a.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-43b9bc83.entry.js.map → p-228010e3.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-b9ea1d82.entry.js.map → p-38e47d7a.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-cd1f6d8b.entry.js.map → p-3e409fec.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-5ca86ec7.entry.js.map → p-5f8148bd.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-6412e81d.entry.js.map → p-829ad2ad.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-33424b64.entry.js.map → p-91c5a8e6.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-6782a3de.entry.js.map → p-a2616751.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-4c80b470.entry.js.map → p-a5c8a4c2.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-47e183cd.entry.js.map → p-aaf00ed2.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-6d943088.entry.js.map → p-b218a4ef.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-db1bb72e.entry.js.map → p-bddffb3d.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-0406c2c2.entry.js.map → p-bec531db.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-5495cb2c.entry.js.map → p-c644c702.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-efbff89c.entry.js.map → p-caacc12c.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-e0ad480b.entry.js.map → p-d2c9f6dc.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-4d461ed9.entry.js.map → p-d6b176a1.entry.js.map} +0 -0
- /package/dist/hemfixarna-components/{p-c0c26b18.entry.js.map → p-de15b378.entry.js.map} +0 -0
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-e6926623.js');
|
|
6
6
|
const index$1 = require('./index-6cce99a1.js');
|
|
7
|
-
const index$2 = require('./index-
|
|
7
|
+
const index$2 = require('./index-53d1843b.js');
|
|
8
8
|
|
|
9
9
|
const hideField = (field) => {
|
|
10
10
|
return field.split(' ').reduce((acc, curr) => {
|
|
@@ -87,14 +87,30 @@ const HemfixarnaAddress = class {
|
|
|
87
87
|
get el() { return index.getElement(this); }
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
const DEFAULT_RUT_DISCOUNT_PERCENT = 50;
|
|
91
|
+
const DEFAULT_ROT_DISCOUNT_PERCENT = 30;
|
|
92
|
+
const DEFAULT_GREEN_DISCOUNT_PERCENT = 48.5;
|
|
93
|
+
const getDiscountPercentage = (type) => {
|
|
94
|
+
var _a, _b, _c, _d, _e, _f;
|
|
95
|
+
if (type === 'rut') {
|
|
96
|
+
return (_b = (_a = index$1.state.rutOptions) === null || _a === void 0 ? void 0 : _a.percentage) !== null && _b !== void 0 ? _b : DEFAULT_RUT_DISCOUNT_PERCENT;
|
|
97
|
+
}
|
|
98
|
+
if (type === 'rot') {
|
|
99
|
+
return (_d = (_c = index$1.state.rotOptions) === null || _c === void 0 ? void 0 : _c.percentage) !== null && _d !== void 0 ? _d : DEFAULT_ROT_DISCOUNT_PERCENT;
|
|
100
|
+
}
|
|
101
|
+
return (_f = (_e = index$1.state.greenOptions) === null || _e === void 0 ? void 0 : _e.percentage) !== null && _f !== void 0 ? _f : DEFAULT_GREEN_DISCOUNT_PERCENT;
|
|
102
|
+
};
|
|
103
|
+
const getDiscountedPrice = (price, percentage) => {
|
|
104
|
+
return Math.ceil(price * (100 - percentage) / 100);
|
|
105
|
+
};
|
|
90
106
|
const getRutPrice = (price) => {
|
|
91
|
-
return
|
|
107
|
+
return getDiscountedPrice(price, getDiscountPercentage('rut'));
|
|
92
108
|
};
|
|
93
109
|
const getRotPrice = (price) => {
|
|
94
|
-
return
|
|
110
|
+
return getDiscountedPrice(price, getDiscountPercentage('rot'));
|
|
95
111
|
};
|
|
96
112
|
const getGreenPrice = (price) => {
|
|
97
|
-
return
|
|
113
|
+
return getDiscountedPrice(price, getDiscountPercentage('green'));
|
|
98
114
|
};
|
|
99
115
|
const getProductPrice = (product, price, amount = 1) => {
|
|
100
116
|
if (product.rot && index$1.state.rot) {
|
|
@@ -461,7 +477,7 @@ const getRot = async () => {
|
|
|
461
477
|
const getGreenDiscount = async () => {
|
|
462
478
|
try {
|
|
463
479
|
const res = await fetch(`${base$2}/green-discount`);
|
|
464
|
-
return await res.json();
|
|
480
|
+
return (await res.json());
|
|
465
481
|
}
|
|
466
482
|
catch (error) {
|
|
467
483
|
console.log(error);
|
|
@@ -1747,9 +1763,10 @@ const HemfixarnaInfo = class {
|
|
|
1747
1763
|
}
|
|
1748
1764
|
};
|
|
1749
1765
|
|
|
1750
|
-
const hemfixarnaInvoiceCss = ":host .invoice{gap:16px;display:grid}:host .invoice form>span{text-align:
|
|
1766
|
+
const hemfixarnaInvoiceCss = ":host .invoice{gap:16px;display:grid}:host .invoice form>span{text-align:right}:host .invoice img{right:unset;left:unset;position:initial;transform:none}:host .invoice label{cursor:pointer;font-size:14px;display:flex;align-items:flex-start;padding:16px 0}:host .invoice label input{margin:0 5px 0 0;accent-color:#ea662c}:host .invoice-preview{display:flex;gap:4px}:host .invoice-preview div{position:relative}:host .invoice-preview div button{position:absolute;top:0;right:0;padding:0}:host .invoice-preview div button img{width:24px;height:24px}:host .invoice-preview div>img{width:100px;height:80px;object-fit:cover}:host .invoice input[type=email],:host .invoice input[type=tel],:host .invoice textarea{padding:16px;border:1px solid #fcd9c9;font-size:16px}:host .invoice textarea{resize:none;height:200px;font-family:\"Inter\", sans-serif}:host .invoice-description-counter{text-align:right;font-size:12px;color:#888}:host .invoice div:has(>input[type=file]){display:flex;align-items:center;justify-content:center;cursor:pointer;background:#fff;border:1px solid #fcd9c9;padding:32px 16px;gap:16px}:host .invoice div:has(>input[type=file]) span{color:#000;font-size:12px}:host .invoice input[type=file]{display:none}";
|
|
1751
1767
|
|
|
1752
1768
|
const base = `${getApiUrl()}/wp-json/headless`;
|
|
1769
|
+
const DESCRIPTION_MAX_LENGTH = 600;
|
|
1753
1770
|
const HemfixarnaInvoice = class {
|
|
1754
1771
|
constructor(hostRef) {
|
|
1755
1772
|
index.registerInstance(this, hostRef);
|
|
@@ -1757,6 +1774,7 @@ const HemfixarnaInvoice = class {
|
|
|
1757
1774
|
this.displayImages = [];
|
|
1758
1775
|
this.formImages = [];
|
|
1759
1776
|
this.formState = 'initial';
|
|
1777
|
+
this.descriptionLength = 0;
|
|
1760
1778
|
}
|
|
1761
1779
|
isValidEmail(email) {
|
|
1762
1780
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -1890,7 +1908,7 @@ const HemfixarnaInvoice = class {
|
|
|
1890
1908
|
render() {
|
|
1891
1909
|
var _a;
|
|
1892
1910
|
const upload = index.getAssetPath(`./assets/drag-drop.svg`);
|
|
1893
|
-
return (index.h("div", { class: "invoice" }, ((_a = index$1.state.selectedProduct) === null || _a === void 0 ? void 0 : _a.invoice_description) ? index.h("p", null, index$1.state.selectedProduct.invoice_description) : null, index.h("form", { onSubmit: e => this.submit(e) }, index.h("textarea", { name: "descriptionInput", placeholder: "Beskriv ditt \u00E4rende" }), index.h("div", { role: "button", "aria-label": "upload image", onDragOver: e => this.preventDragOver(e), onDrop: e => this.handleImageDrop(e), onClick: () => this.handleImageClick() }, index.h("img", { src: upload, alt: "hemfixarna_logo", width: 24 }), index.h("div", null, index.h("p", null, "Bifoga ev bilder"), index.h("span", null, "(dra bilder hit)")), index.h("input", { onChange: e => this.handleFileInputChange(e), class: "hemfixarna-file-upload", accept: "image/*", type: "file", multiple: true, name: "fileInput" })), index.h("div", { class: "invoice-preview" }, this.displayImages.map((img, i) => (index.h("div", { key: i }, index.h("img", { src: img, alt: "uploaded image" }), index.h("button", { onClick: () => this.removeImage(i) }, index.h("img", { src: index.getAssetPath(`./assets/close.svg`), alt: "close" })))))), index.h("input", { placeholder: "E-post", type: "email", name: "emailInput" }), index.h("input", { placeholder: "Telefonnummer", type: "tel", name: "telInput" }), index$1.state.selectedProduct.terms_show_checkbox ? (index.h("label", null, index.h("input", { type: "checkbox", name: "termsInput" }), index$1.state.selectedProduct.terms)) : null, this.formError ? index.h("span", null, this.formError) : null, index.h("input", { type: "submit", value: this.formState === 'loading' ? 'Skickar' : 'Kontakta mig', disabled: this.formState === 'loading' }))));
|
|
1911
|
+
return (index.h("div", { class: "invoice" }, ((_a = index$1.state.selectedProduct) === null || _a === void 0 ? void 0 : _a.invoice_description) ? index.h("p", null, index$1.state.selectedProduct.invoice_description) : null, index.h("form", { onSubmit: e => this.submit(e) }, index.h("textarea", { name: "descriptionInput", placeholder: "Beskriv ditt \u00E4rende", maxLength: DESCRIPTION_MAX_LENGTH, onInput: e => (this.descriptionLength = e.target.value.length) }), index.h("span", { class: "invoice-description-counter" }, this.descriptionLength, "/", DESCRIPTION_MAX_LENGTH), index.h("div", { role: "button", "aria-label": "upload image", onDragOver: e => this.preventDragOver(e), onDrop: e => this.handleImageDrop(e), onClick: () => this.handleImageClick() }, index.h("img", { src: upload, alt: "hemfixarna_logo", width: 24 }), index.h("div", null, index.h("p", null, "Bifoga ev bilder"), index.h("span", null, "(dra bilder hit)")), index.h("input", { onChange: e => this.handleFileInputChange(e), class: "hemfixarna-file-upload", accept: "image/*", type: "file", multiple: true, name: "fileInput" })), index.h("div", { class: "invoice-preview" }, this.displayImages.map((img, i) => (index.h("div", { key: i }, index.h("img", { src: img, alt: "uploaded image" }), index.h("button", { onClick: () => this.removeImage(i) }, index.h("img", { src: index.getAssetPath(`./assets/close.svg`), alt: "close" })))))), index.h("input", { placeholder: "E-post", type: "email", name: "emailInput" }), index.h("input", { placeholder: "Telefonnummer", type: "tel", name: "telInput" }), index$1.state.selectedProduct.terms_show_checkbox ? (index.h("label", null, index.h("input", { type: "checkbox", name: "termsInput" }), index$1.state.selectedProduct.terms)) : null, this.formError ? index.h("span", null, this.formError) : null, index.h("input", { type: "submit", value: this.formState === 'loading' ? 'Skickar' : 'Kontakta mig', disabled: this.formState === 'loading' }))));
|
|
1894
1912
|
}
|
|
1895
1913
|
get el() { return index.getElement(this); }
|
|
1896
1914
|
};
|