@driveflux/pdf 1.7.0 → 1.7.1

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 (38) hide show
  1. package/dist/__mocks__/quotation.js +11 -10
  2. package/dist/__mocks__/subscription.js +122 -380
  3. package/dist/components/FluxLogo.js +3 -62
  4. package/dist/components/StandardPage.js +8 -97
  5. package/dist/debug.js +26 -203
  6. package/dist/index.js +1 -0
  7. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.js +27 -145
  8. package/dist/templates/QuotationPdf/GFV.js +12 -49
  9. package/dist/templates/QuotationPdf/Header.js +5 -63
  10. package/dist/templates/QuotationPdf/Pricing.js +204 -574
  11. package/dist/templates/QuotationPdf/QuotationPdfPage.js +3 -23
  12. package/dist/templates/QuotationPdf/SectionBoxNew.js +4 -34
  13. package/dist/templates/QuotationPdf/TermsSection.js +5 -42
  14. package/dist/templates/QuotationPdf/VehiclePhotos.js +24 -54
  15. package/dist/templates/QuotationPdf/index.js +10 -189
  16. package/dist/templates/QuotationPdf/translations.js +23 -38
  17. package/dist/templates/QuotationPdf/utils.js +29 -59
  18. package/dist/templates/SubscriptionAgreement/Confirmation.js +11 -66
  19. package/dist/templates/SubscriptionAgreement/CoverPage.js +10 -77
  20. package/dist/templates/SubscriptionAgreement/CoverPageSection.js +5 -16
  21. package/dist/templates/SubscriptionAgreement/Details.js +43 -69
  22. package/dist/templates/SubscriptionAgreement/Footer.js +6 -48
  23. package/dist/templates/SubscriptionAgreement/Header.js +5 -35
  24. package/dist/templates/SubscriptionAgreement/LabelValue.js +3 -25
  25. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.js +3 -26
  26. package/dist/templates/SubscriptionAgreement/TermsOfUse.js +3 -52
  27. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.js +9 -97
  28. package/dist/templates/SubscriptionAgreement/index.js +14 -240
  29. package/dist/templates/SubscriptionAgreement/translations.js +193 -194
  30. package/dist/templates/SubscriptionAgreement/types.js +2 -1
  31. package/dist/templates/SubscriptionAgreement/utils.js +5 -3
  32. package/dist/templates/index.js +1 -0
  33. package/dist/theme/colors.js +63 -44
  34. package/dist/theme/index.js +1 -0
  35. package/dist/types.js +2 -1
  36. package/dist/utils.js +16 -159
  37. package/dist/watch.js +4 -3
  38. package/package.json +2 -2
@@ -1,29 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Text, View } from '@react-pdf/renderer';
3
- var LabelValue = function(param) {
4
- var label = param.label, value = param.value;
5
- return /*#__PURE__*/ _jsxs(View, {
6
- style: {
7
- flexDirection: 'row'
8
- },
9
- children: [
10
- /*#__PURE__*/ _jsx(Text, {
11
- style: {
12
- minWidth: 120,
13
- textTransform: 'capitalize'
14
- },
15
- children: label
16
- }),
17
- /*#__PURE__*/ _jsx(Text, {
18
- children: ':'
19
- }),
20
- /*#__PURE__*/ _jsx(Text, {
21
- style: {
22
- paddingLeft: 16
23
- },
24
- children: value ? "".concat(value) : '-'
25
- })
26
- ]
27
- });
3
+ const LabelValue = ({ label, value }) => {
4
+ return (_jsxs(View, { style: { flexDirection: 'row' }, children: [_jsx(Text, { style: { minWidth: 120, textTransform: 'capitalize' }, children: label }), _jsx(Text, { children: ':' }), _jsx(Text, { style: { paddingLeft: 16 }, children: value ? `${value}` : '-' })] }));
28
5
  };
29
6
  export default LabelValue;
7
+ //# sourceMappingURL=LabelValue.js.map
@@ -3,31 +3,8 @@ import { View } from '@react-pdf/renderer';
3
3
  import StandardPage from '../../components/StandardPage.js';
4
4
  import Footer from './Footer.js';
5
5
  import Header from './Header.js';
6
- var SubscriptionAgreementPage = function(param) {
7
- var t = param.t, userId = param.userId, subscriptionId = param.subscriptionId, children = param.children;
8
- return /*#__PURE__*/ _jsxs(StandardPage, {
9
- style: {
10
- padding: 40,
11
- fontSize: 10
12
- },
13
- children: [
14
- /*#__PURE__*/ _jsx(Header, {
15
- tTitle: t.title,
16
- userId: userId,
17
- subscriptionId: subscriptionId
18
- }),
19
- /*#__PURE__*/ _jsx(View, {
20
- style: {
21
- flex: 1
22
- },
23
- children: children
24
- }),
25
- /*#__PURE__*/ _jsx(Footer, {
26
- tComputerGenerated: t.computerGenerated,
27
- tPage: t.page,
28
- tOf: t.of
29
- })
30
- ]
31
- });
6
+ const SubscriptionAgreementPage = ({ t, userId, subscriptionId, children, }) => {
7
+ return (_jsxs(StandardPage, { style: { padding: 40, fontSize: 10 }, children: [_jsx(Header, { tTitle: t.title, userId: userId, subscriptionId: subscriptionId }), _jsx(View, { style: { flex: 1 }, children: children }), _jsx(Footer, { tComputerGenerated: t.computerGenerated, tPage: t.page, tOf: t.of })] }));
32
8
  };
33
9
  export default SubscriptionAgreementPage;
10
+ //# sourceMappingURL=SubscriptionAgreementPage.js.map
@@ -1,57 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Text, View } from '@react-pdf/renderer';
3
3
  import TermsOfUseSubSection from './TermsOfUseSubSection.js';
4
- var TermsOfUse = function(param) {
5
- var t = param.t;
6
- return /*#__PURE__*/ _jsxs(View, {
7
- style: {
8
- rowGap: 16
9
- },
10
- children: [
11
- /*#__PURE__*/ _jsx(Text, {
12
- style: {
13
- fontWeight: 'bold',
14
- textTransform: 'uppercase'
15
- },
16
- children: t.title
17
- }),
18
- /*#__PURE__*/ _jsx(View, {
19
- style: {
20
- rowGap: 16,
21
- lineHeight: 1.4
22
- },
23
- children: t.content.map(function(section, i) {
24
- return /*#__PURE__*/ _jsxs(View, {
25
- style: {
26
- rowGap: 16
27
- },
28
- children: [
29
- /*#__PURE__*/ _jsx(Text, {
30
- style: {
31
- fontWeight: 'bold'
32
- },
33
- children: "".concat(i + 1, " ").concat(section.title)
34
- }),
35
- /*#__PURE__*/ _jsx(View, {
36
- style: {
37
- rowGap: 16,
38
- paddingLeft: 16
39
- },
40
- children: section.subSections.map(function(subSection, j) {
41
- return /*#__PURE__*/ _jsx(TermsOfUseSubSection, {
42
- indices: [
43
- i + 1,
44
- j + 1
45
- ],
46
- subSection: subSection
47
- }, "".concat(i + 1, ".").concat(j));
48
- })
49
- })
50
- ]
51
- }, section.title);
52
- })
53
- })
54
- ]
55
- });
4
+ const TermsOfUse = ({ t }) => {
5
+ return (_jsxs(View, { style: { rowGap: 16 }, children: [_jsx(Text, { style: { fontWeight: 'bold', textTransform: 'uppercase' }, children: t.title }), _jsx(View, { style: { rowGap: 16, lineHeight: 1.4 }, children: t.content.map((section, i) => (_jsxs(View, { style: { rowGap: 16 }, children: [_jsx(Text, { style: { fontWeight: 'bold' }, children: `${i + 1} ${section.title}` }), _jsx(View, { style: { rowGap: 16, paddingLeft: 16 }, children: section.subSections.map((subSection, j) => (_jsx(TermsOfUseSubSection, { indices: [i + 1, j + 1], subSection: subSection }, `${i + 1}.${j}`))) })] }, section.title))) })] }));
56
6
  };
57
7
  export default TermsOfUse;
8
+ //# sourceMappingURL=TermsOfUse.js.map
@@ -1,102 +1,14 @@
1
- function _array_like_to_array(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _array_without_holes(arr) {
7
- if (Array.isArray(arr)) return _array_like_to_array(arr);
8
- }
9
- function _iterable_to_array(iter) {
10
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
- }
12
- function _non_iterable_spread() {
13
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
- }
15
- function _to_consumable_array(arr) {
16
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
- }
18
- function _unsupported_iterable_to_array(o, minLen) {
19
- if (!o) return;
20
- if (typeof o === "string") return _array_like_to_array(o, minLen);
21
- var n = Object.prototype.toString.call(o).slice(8, -1);
22
- if (n === "Object" && o.constructor) n = o.constructor.name;
23
- if (n === "Map" || n === "Set") return Array.from(n);
24
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
- }
26
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
27
2
  import { Text, View } from '@react-pdf/renderer';
28
3
  import { useMemo } from 'react';
29
- var TermsOfUseSubSection = function(param) {
30
- var indices = param.indices, subSection = param.subSection;
31
- var _useMemo = useMemo(function() {
32
- return {
33
- indicesString: indices.reduce(function(prev, curr, i) {
34
- return "".concat(prev).concat(curr).concat(i === indices.length - 1 ? '' : '.');
35
- }, ''),
36
- paddingLeft: Math.max(indices.length - 2, 0) * 16
37
- };
38
- }, [
39
- indices.length,
40
- indices.reduce
41
- ]), indicesString = _useMemo.indicesString, paddingLeft = _useMemo.paddingLeft;
42
- return typeof subSection === 'string' ? /*#__PURE__*/ _jsxs(View, {
43
- style: {
44
- flexDirection: 'row',
45
- paddingLeft: paddingLeft,
46
- columnGap: 16
47
- },
48
- children: [
49
- /*#__PURE__*/ _jsx(Text, {
50
- style: {
51
- fontWeight: 'bold'
52
- },
53
- children: indicesString
54
- }),
55
- /*#__PURE__*/ _jsx(Text, {
56
- style: {
57
- textAlign: 'justify',
58
- flex: 1
59
- },
60
- children: subSection
61
- })
62
- ]
63
- }, indicesString) : 'subSections' in subSection ? /*#__PURE__*/ _jsxs(View, {
64
- style: {
65
- gap: 16
66
- },
67
- children: [
68
- /*#__PURE__*/ _jsxs(View, {
69
- style: {
70
- flexDirection: 'row',
71
- paddingLeft: paddingLeft,
72
- columnGap: 16
73
- },
74
- children: [
75
- /*#__PURE__*/ _jsx(Text, {
76
- style: {
77
- fontWeight: 'bold'
78
- },
79
- children: indicesString
80
- }),
81
- /*#__PURE__*/ _jsx(Text, {
82
- style: {
83
- textAlign: 'justify',
84
- flex: 1
85
- },
86
- children: subSection.paragraph
87
- })
88
- ]
89
- }, indicesString),
90
- subSection.subSections.map(function(subSection, i) {
91
- return /*#__PURE__*/ _jsx(TermsOfUseSubSection, {
92
- indices: _to_consumable_array(indices).concat([
93
- i + 1
94
- ]),
95
- subSection: subSection
96
- }, "".// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
97
- concat(indices, ".").concat(i));
98
- })
99
- ]
100
- }, indicesString) : null;
4
+ const TermsOfUseSubSection = ({ indices, subSection }) => {
5
+ const { indicesString, paddingLeft } = useMemo(() => ({
6
+ indicesString: indices.reduce((prev, curr, i) => `${prev}${curr}${i === indices.length - 1 ? '' : '.'}`, ''),
7
+ paddingLeft: Math.max(indices.length - 2, 0) * 16,
8
+ }), [indices.length, indices.reduce]);
9
+ return typeof subSection === 'string' ? (_jsxs(View, { style: { flexDirection: 'row', paddingLeft, columnGap: 16 }, children: [_jsx(Text, { style: { fontWeight: 'bold' }, children: indicesString }), _jsx(Text, { style: { textAlign: 'justify', flex: 1 }, children: subSection })] }, indicesString)) : 'subSections' in subSection ? (_jsxs(View, { style: { gap: 16 }, children: [_jsxs(View, { style: { flexDirection: 'row', paddingLeft, columnGap: 16 }, children: [_jsx(Text, { style: { fontWeight: 'bold' }, children: indicesString }), _jsx(Text, { style: { textAlign: 'justify', flex: 1 }, children: subSection.paragraph })] }, indicesString), subSection.subSections.map((subSection, i) => (_jsx(TermsOfUseSubSection, { indices: [...indices, i + 1], subSection: subSection }, `${indices}.${
10
+ // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
11
+ i}`)))] }, indicesString)) : null;
101
12
  };
102
13
  export default TermsOfUseSubSection;
14
+ //# sourceMappingURL=TermsOfUseSubSection.js.map
@@ -1,175 +1,3 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _async_to_generator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _define_property(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
42
- }
43
- function _object_spread(target) {
44
- for(var i = 1; i < arguments.length; i++){
45
- var source = arguments[i] != null ? arguments[i] : {};
46
- var ownKeys = Object.keys(source);
47
- if (typeof Object.getOwnPropertySymbols === "function") {
48
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
- }));
51
- }
52
- ownKeys.forEach(function(key) {
53
- _define_property(target, key, source[key]);
54
- });
55
- }
56
- return target;
57
- }
58
- function ownKeys(object, enumerableOnly) {
59
- var keys = Object.keys(object);
60
- if (Object.getOwnPropertySymbols) {
61
- var symbols = Object.getOwnPropertySymbols(object);
62
- if (enumerableOnly) {
63
- symbols = symbols.filter(function(sym) {
64
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
- });
66
- }
67
- keys.push.apply(keys, symbols);
68
- }
69
- return keys;
70
- }
71
- function _object_spread_props(target, source) {
72
- source = source != null ? source : {};
73
- if (Object.getOwnPropertyDescriptors) {
74
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
- } else {
76
- ownKeys(Object(source)).forEach(function(key) {
77
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
- });
79
- }
80
- return target;
81
- }
82
- function _ts_generator(thisArg, body) {
83
- var f, y, t, _ = {
84
- label: 0,
85
- sent: function() {
86
- if (t[0] & 1) throw t[1];
87
- return t[1];
88
- },
89
- trys: [],
90
- ops: []
91
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
92
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
93
- return this;
94
- }), g;
95
- function verb(n) {
96
- return function(v) {
97
- return step([
98
- n,
99
- v
100
- ]);
101
- };
102
- }
103
- function step(op) {
104
- if (f) throw new TypeError("Generator is already executing.");
105
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
106
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
107
- if (y = 0, t) op = [
108
- op[0] & 2,
109
- t.value
110
- ];
111
- switch(op[0]){
112
- case 0:
113
- case 1:
114
- t = op;
115
- break;
116
- case 4:
117
- _.label++;
118
- return {
119
- value: op[1],
120
- done: false
121
- };
122
- case 5:
123
- _.label++;
124
- y = op[1];
125
- op = [
126
- 0
127
- ];
128
- continue;
129
- case 7:
130
- op = _.ops.pop();
131
- _.trys.pop();
132
- continue;
133
- default:
134
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
135
- _ = 0;
136
- continue;
137
- }
138
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
139
- _.label = op[1];
140
- break;
141
- }
142
- if (op[0] === 6 && _.label < t[1]) {
143
- _.label = t[1];
144
- t = op;
145
- break;
146
- }
147
- if (t && _.label < t[2]) {
148
- _.label = t[2];
149
- _.ops.push(op);
150
- break;
151
- }
152
- if (t[2]) _.ops.pop();
153
- _.trys.pop();
154
- continue;
155
- }
156
- op = body.call(thisArg, _);
157
- } catch (e) {
158
- op = [
159
- 6,
160
- e
161
- ];
162
- y = 0;
163
- } finally{
164
- f = t = 0;
165
- }
166
- if (op[0] & 5) throw op[1];
167
- return {
168
- value: op[0] ? op[1] : void 0,
169
- done: true
170
- };
171
- }
172
- }
173
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
174
2
  import { Document } from '@react-pdf/renderer';
175
3
  import { useMemo } from 'react';
@@ -180,79 +8,25 @@ import Details from './Details.js';
180
8
  import SubscriptionAgreementPage from './SubscriptionAgreementPage.js';
181
9
  import TermsOfUse from './TermsOfUse.js';
182
10
  import { useTranslations } from './translations.js';
183
- export var generateSubscriptionAgreementPdf = function(param, fileName) {
184
- var _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, subscription = param.subscription;
185
- return _async_to_generator(function() {
186
- return _ts_generator(this, function(_state) {
187
- switch(_state.label){
188
- case 0:
189
- if (!subscription.signature) {
190
- throw new Error('Signature not found');
191
- }
192
- return [
193
- 4,
194
- toPdf(/*#__PURE__*/ _jsx(SubscriptionAgreement, {
195
- locale: locale,
196
- signature: subscription.signature,
197
- subscription: subscription
198
- }), fileName)
199
- ];
200
- case 1:
201
- return [
202
- 2,
203
- _state.sent()
204
- ];
205
- }
206
- });
207
- })();
11
+ export const generateSubscriptionAgreementPdf = async ({ locale = 'en', subscription }, fileName) => {
12
+ if (!subscription.signature) {
13
+ throw new Error('Signature not found');
14
+ }
15
+ return await toPdf(_jsx(SubscriptionAgreement, { locale: locale, signature: subscription.signature, subscription: subscription }), fileName);
208
16
  };
209
- var SubscriptionAgreement = function(param) {
210
- var _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, signature = param.signature, subscription = param.subscription;
17
+ const SubscriptionAgreement = ({ locale = 'en', signature, subscription, }) => {
211
18
  if (!signature.signedAt) {
212
- throw new Error("Missing 'signature.signedAt'");
19
+ throw new Error(`Missing 'signature.signedAt'`);
213
20
  }
214
- var useT = useTranslations(locale);
215
- var pageProps = useMemo(function() {
21
+ const useT = useTranslations(locale);
22
+ const pageProps = useMemo(() => {
216
23
  return {
217
24
  t: useT,
218
25
  userId: subscription.userId,
219
- subscriptionId: subscription.id
26
+ subscriptionId: subscription.id,
220
27
  };
221
- }, [
222
- subscription.userId,
223
- subscription.id,
224
- useT
225
- ]);
226
- var t = pageProps.t;
227
- return /*#__PURE__*/ _jsxs(Document, {
228
- title: t.title,
229
- language: locale,
230
- children: [
231
- /*#__PURE__*/ _jsx(SubscriptionAgreementPage, _object_spread_props(_object_spread({}, pageProps), {
232
- children: /*#__PURE__*/ _jsx(CoverPage, {
233
- tTitle: t.title,
234
- tCover: t.cover,
235
- signedAt: signature.signedAt,
236
- user: subscription.user
237
- })
238
- })),
239
- /*#__PURE__*/ _jsx(SubscriptionAgreementPage, _object_spread_props(_object_spread({}, pageProps), {
240
- children: /*#__PURE__*/ _jsx(TermsOfUse, {
241
- t: t.termsOfUse
242
- })
243
- })),
244
- /*#__PURE__*/ _jsxs(SubscriptionAgreementPage, _object_spread_props(_object_spread({}, pageProps), {
245
- children: [
246
- /*#__PURE__*/ _jsx(Details, {
247
- tDetails: t.details,
248
- subscription: subscription
249
- }),
250
- /*#__PURE__*/ _jsx(Confirmation, {
251
- tConfirmation: t.confirmation,
252
- subscription: subscription
253
- })
254
- ]
255
- }))
256
- ]
257
- });
28
+ }, [subscription.userId, subscription.id, useT]);
29
+ const { t } = pageProps;
30
+ return (_jsxs(Document, { title: t.title, language: locale, children: [_jsx(SubscriptionAgreementPage, { ...pageProps, children: _jsx(CoverPage, { tTitle: t.title, tCover: t.cover, signedAt: signature.signedAt, user: subscription.user }) }), _jsx(SubscriptionAgreementPage, { ...pageProps, children: _jsx(TermsOfUse, { t: t.termsOfUse }) }), _jsxs(SubscriptionAgreementPage, { ...pageProps, children: [_jsx(Details, { tDetails: t.details, subscription: subscription }), _jsx(Confirmation, { tConfirmation: t.confirmation, subscription: subscription })] })] }));
258
31
  };
32
+ //# sourceMappingURL=index.js.map