@myparcel-dev/pdk-checkout-tax-fields 1.7.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.
- package/CHANGELOG.md +150 -0
- package/dist/constants.d.ts +4 -0
- package/dist/index.d.ts +6 -0
- package/dist/types.d.ts +2 -0
- package/dist/utils/hasTaxFields.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/toggleTaxFields.d.ts +1 -0
- package/package.json +49 -0
- package/src/__tests__/__snapshots__/exports.spec.ts.snap +8 -0
- package/src/__tests__/exports.spec.ts +8 -0
- package/src/constants.ts +4 -0
- package/src/index.ts +17 -0
- package/src/types.ts +3 -0
- package/src/utils/hasTaxFields.ts +19 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/toggleTaxFields.ts +23 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!-- MONOWEAVE:BELOW -->
|
|
4
|
+
|
|
5
|
+
## [1.7.0](https://github.com/myparcelnl/js-pdk/compare/@myparcel-dev/pdk-checkout-tax-fields@1.6.0...@myparcel-dev/pdk-checkout-tax-fields@1.7.0) "@myparcel-dev/pdk-checkout-tax-fields" (2025-12-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* migrate to [@myparcel-dev](https://github.com/myparcel-dev) scope ([#289](https://github.com/myparcelnl/js-pdk/issues/289)) ([ca169be](https://github.com/myparcelnl/js-pdk/commit/ca169bec42dcf7174ce20b1bfb392ae620b6c7fd))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.6.0](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.5.0...@myparcel-pdk/checkout-tax-fields@1.6.0) "@myparcel-pdk/checkout-tax-fields" (2025-11-10)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [1.2.0](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.1.5...@myparcel-pdk/checkout-tax-fields@1.2.0) "@myparcel-pdk/checkout-tax-fields" (2024-11-06)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **checkout:** export more variables ([82e843c](https://github.com/myparcelnl/js-pdk/commit/82e843c442198268661881ac1cd1c8a0e7a9f449))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [1.1.5](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.7...@myparcel-pdk/checkout-tax-fields@1.1.5) "@myparcel-pdk/checkout-tax-fields" (2024-10-24)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## [1.0.7](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.6...@myparcel-pdk/checkout-tax-fields@1.0.7) "@myparcel-pdk/checkout-tax-fields" (2024-10-24)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [1.0.5](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.4...@myparcel-pdk/checkout-tax-fields@1.0.5) "@myparcel-pdk/checkout-tax-fields" (2024-10-04)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## [1.0.0](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.29...@myparcel-pdk/checkout-tax-fields@1.0.0) "@myparcel-pdk/checkout-tax-fields" (2024-04-11)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### ⚠ BREAKING CHANGES
|
|
49
|
+
|
|
50
|
+
* update node requirement to 20
|
|
51
|
+
|
|
52
|
+
### Miscellaneous Chores
|
|
53
|
+
|
|
54
|
+
* update node requirement to 20 ([e3f867f](https://github.com/myparcelnl/js-pdk/commit/e3f867fd3e19245154748a6858dbad4b56673fa3))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## [1.0.0-beta.3](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-beta.2...@myparcel-pdk/checkout-tax-fields@1.0.0-beta.3) "@myparcel-pdk/checkout-tax-fields" (2024-03-14)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## [1.0.0-beta.0](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.29...@myparcel-pdk/checkout-tax-fields@1.0.0-beta.0) "@myparcel-pdk/checkout-tax-fields" (2024-03-06)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Features
|
|
68
|
+
|
|
69
|
+
* update @myparcelnl/constants to v2.0.0 ([022c980](https://github.com/myparcelnl/js-pdk/commit/022c980950dd37b6e750c04f65e57c6435f01279))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## [1.0.0-alpha.41](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.40...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.41) "@myparcel-pdk/checkout-tax-fields" (2023-11-02)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## [1.0.0-alpha.37](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.36...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.37) "@myparcel-pdk/checkout-tax-fields" (2023-10-13)
|
|
80
|
+
|
|
81
|
+
## [1.0.0-alpha.29](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.28...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.29) "@myparcel-pdk/checkout-tax-fields" (2023-09-06)
|
|
82
|
+
|
|
83
|
+
## [1.0.0-alpha.24](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.23...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.24) "@myparcel-pdk/checkout-tax-fields" (2023-08-04)
|
|
84
|
+
|
|
85
|
+
## [1.0.0-alpha.22](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.21...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.22) "@myparcel-pdk/checkout-tax-fields" (2023-08-03)
|
|
86
|
+
|
|
87
|
+
## [1.0.0-alpha.20](https://github.com/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.19...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.20) "@myparcel-pdk/checkout-tax-fields" (2023-07-26)
|
|
88
|
+
|
|
89
|
+
### Bug Fixes
|
|
90
|
+
|
|
91
|
+
- **npm:** update repository
|
|
92
|
+
field ([e940854](https://github.com/myparcelnl/js-pdk/commit/e940854ba1d99c0fcdada8b66f88a7c7e6060272))
|
|
93
|
+
|
|
94
|
+
## [1.0.0-alpha.18](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.17...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.18) "@myparcel-pdk/checkout-tax-fields" (2023-07-11)
|
|
95
|
+
|
|
96
|
+
## [1.0.0-alpha.16](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.15...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.16) "@myparcel-pdk/checkout-tax-fields" (2023-07-04)
|
|
97
|
+
|
|
98
|
+
## [1.0.0-alpha.15](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.14...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.15) "@myparcel-pdk/checkout-tax-fields" (2023-06-06)
|
|
99
|
+
|
|
100
|
+
## [1.0.0-alpha.14](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.13...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.14) "@myparcel-pdk/checkout-tax-fields" (2023-06-01)
|
|
101
|
+
|
|
102
|
+
## [1.0.0-alpha.12](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.11...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.12) "@myparcel-pdk/checkout-tax-fields" (2023-05-26)
|
|
103
|
+
|
|
104
|
+
### Bug Fixes
|
|
105
|
+
|
|
106
|
+
- restore missing types ([903cfb9](https://github/myparcelnl/js-pdk/commit/903cfb95f161bb5b49fbb91c4f96a7e44c524db8))
|
|
107
|
+
|
|
108
|
+
## [1.0.0-alpha.11](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.10...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.11) "@myparcel-pdk/checkout-tax-fields" (2023-05-25)
|
|
109
|
+
|
|
110
|
+
## [1.0.0-alpha.10](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.9...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.10) "@myparcel-pdk/checkout-tax-fields" (2023-05-25)
|
|
111
|
+
|
|
112
|
+
### ⚠ BREAKING CHANGES
|
|
113
|
+
|
|
114
|
+
- change all packages so imports don't need /src anymore
|
|
115
|
+
|
|
116
|
+
### Code Refactoring
|
|
117
|
+
|
|
118
|
+
- change all packages so imports don't need /src
|
|
119
|
+
anymore ([892306b](https://github/myparcelnl/js-pdk/commit/892306bd3307fe8d5d011bbf6eb7654f7365347a))
|
|
120
|
+
|
|
121
|
+
## [1.0.0-alpha.8](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.7...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.8) "@myparcel-pdk/checkout-tax-fields" (2023-05-15)
|
|
122
|
+
|
|
123
|
+
## [1.0.0-alpha.7](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.6...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.7) "@myparcel-pdk/checkout-tax-fields" (2023-05-09)
|
|
124
|
+
|
|
125
|
+
### Bug Fixes
|
|
126
|
+
|
|
127
|
+
- **checkout:** improve
|
|
128
|
+
functionality ([8172f7b](https://github/myparcelnl/js-pdk/commit/8172f7b72182253b87a5ab611f1aa9807cc6e63c))
|
|
129
|
+
|
|
130
|
+
## [1.0.0-alpha.6](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.5...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.6) "@myparcel-pdk/checkout-tax-fields" (2023-05-04)
|
|
131
|
+
|
|
132
|
+
### Features
|
|
133
|
+
|
|
134
|
+
- **checkout:** improve checkout
|
|
135
|
+
logic ([fb2a8bd](https://github/myparcelnl/js-pdk/commit/fb2a8bd4b9404cac0fe600526d85465e3a1ee5f9))
|
|
136
|
+
|
|
137
|
+
## [1.0.0-alpha.5](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.4...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.5) "@myparcel-pdk/checkout-tax-fields" (2023-04-20)
|
|
138
|
+
|
|
139
|
+
### Features
|
|
140
|
+
|
|
141
|
+
- **checkout:** move showing/hiding logic to app
|
|
142
|
+
config ([c5a9dea](https://github/myparcelnl/js-pdk/commit/c5a9dea4463efb3d293406e05fa010312faca76a))
|
|
143
|
+
|
|
144
|
+
## [1.0.0-alpha.4](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.3...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.4) "@myparcel-pdk/checkout-tax-fields" (2023-04-20)
|
|
145
|
+
|
|
146
|
+
## [1.0.0-alpha.3](https://github/myparcelnl/js-pdk/compare/@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.2...@myparcel-pdk/checkout-tax-fields@1.0.0-alpha.3) "@myparcel-pdk/checkout-tax-fields" (2023-04-20)
|
|
147
|
+
|
|
148
|
+
### Features
|
|
149
|
+
|
|
150
|
+
- add checkout packages ([ad1d9e1](https://github/myparcelnl/js-pdk/commit/ad1d9e1f027af9e6124f8266f64edc0509e22a9d))
|
package/dist/index.d.ts
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasTaxFields: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toggleTaxFields: () => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@myparcel-dev/pdk-checkout-tax-fields",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/myparcelnl/js-pdk.git",
|
|
7
|
+
"directory": "libs/checkout-tax-fields"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": "./src/index.ts",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"./src",
|
|
16
|
+
"./dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "run ws:ts:build \"$(pwd)\"",
|
|
20
|
+
"clean": "run ws:clean \"$(pwd)\"",
|
|
21
|
+
"emit": "run ws:ts:emit \"$(pwd)\"",
|
|
22
|
+
"lint": "run ws:lint \"$(pwd)\"",
|
|
23
|
+
"lint:fix": "run ws:lint:fix \"$(pwd)\"",
|
|
24
|
+
"test": "run ws:test \"$(pwd)\"",
|
|
25
|
+
"test:coverage": "run ws:test:coverage \"$(pwd)\"",
|
|
26
|
+
"test:run": "run ws:test:run \"$(pwd)\"",
|
|
27
|
+
"test:update": "run ws:test:update \"$(pwd)\"",
|
|
28
|
+
"typecheck": "run ws:ts:typecheck \"$(pwd)\""
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@myparcel-dev/constants": "^2.7.0",
|
|
32
|
+
"@myparcel-dev/pdk-checkout-common": "^1.7.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@myparcel-dev/pdk-build-vite": "1.0.0-alpha.0",
|
|
36
|
+
"typescript": "^5.2.2",
|
|
37
|
+
"vitest": "^2.1.3"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20"
|
|
41
|
+
},
|
|
42
|
+
"volta": {
|
|
43
|
+
"extends": "../../package.json"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"deployGroup": "checkout"
|
|
49
|
+
}
|
package/src/constants.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {StoreListener, useCheckoutStore} from '@myparcel-dev/pdk-checkout-common';
|
|
2
|
+
import {toggleTaxFields} from './utils';
|
|
3
|
+
|
|
4
|
+
export type {TaxFields} from './types';
|
|
5
|
+
|
|
6
|
+
export {TaxField} from './constants';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the checkout tax fields module.
|
|
10
|
+
*/
|
|
11
|
+
export const initializeCheckoutTaxFields = (): void => {
|
|
12
|
+
const checkout = useCheckoutStore();
|
|
13
|
+
|
|
14
|
+
checkout.on(StoreListener.Update, toggleTaxFields);
|
|
15
|
+
|
|
16
|
+
toggleTaxFields();
|
|
17
|
+
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {useSettings} from '@myparcel-dev/pdk-checkout-common';
|
|
2
|
+
import {type CarrierName} from '@myparcel-dev/constants';
|
|
3
|
+
|
|
4
|
+
export const hasTaxFields = (): boolean => {
|
|
5
|
+
const settings = useSettings();
|
|
6
|
+
|
|
7
|
+
let hasTaxFields = true;
|
|
8
|
+
|
|
9
|
+
if (settings.hasDeliveryOptions) {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
const {deliveryOptions} = window.MyParcelPdk.stores;
|
|
13
|
+
const carrier = deliveryOptions.state?.output?.carrier ?? null;
|
|
14
|
+
|
|
15
|
+
hasTaxFields = Boolean(carrier && settings.carriersWithTaxFields.includes(carrier as CarrierName));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return hasTaxFields;
|
|
19
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {PdkUtil, useCheckoutStore, useConfig, useUtil} from '@myparcel-dev/pdk-checkout-common';
|
|
2
|
+
import {TaxField} from '../constants';
|
|
3
|
+
import {hasTaxFields} from './hasTaxFields';
|
|
4
|
+
|
|
5
|
+
export const toggleTaxFields = (): void => {
|
|
6
|
+
const getAddressField = useUtil(PdkUtil.GetAddressField);
|
|
7
|
+
|
|
8
|
+
const checkout = useCheckoutStore();
|
|
9
|
+
const showTaxFields = hasTaxFields();
|
|
10
|
+
const config = useConfig();
|
|
11
|
+
|
|
12
|
+
checkout.state.addressTypes.forEach((addressType) => {
|
|
13
|
+
[TaxField.EoriNumber, TaxField.VatNumber].forEach((fieldName) => {
|
|
14
|
+
const field = getAddressField(fieldName, addressType, false);
|
|
15
|
+
|
|
16
|
+
if (!field) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
config.toggleField(field, showTaxFields);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
};
|