@dvrd/dvr-controls 1.1.32 → 1.1.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvrd/dvr-controls",
3
- "version": "1.1.32",
3
+ "version": "1.1.34",
4
4
  "description": "Custom web controls",
5
5
  "main": "index.ts",
6
6
  "files": [
@@ -12,6 +12,10 @@
12
12
  },
13
13
  "author": "Dave van Rijn",
14
14
  "license": "ISC",
15
+ "scripts": {
16
+ "build": "yarn typecheck && npm publish",
17
+ "typecheck": "tsc --noEmit"
18
+ },
15
19
  "browserslist": {
16
20
  "production": [
17
21
  ">0.2%",
@@ -5,15 +5,7 @@ import './style/dvrdDatePicker.scss';
5
5
 
6
6
  import classNames from 'classnames';
7
7
  import React, {
8
- ForwardedRef,
9
- forwardRef,
10
- Fragment,
11
- MouseEventHandler,
12
- useEffect,
13
- useImperativeHandle,
14
- useMemo,
15
- useRef,
16
- useState
8
+ ForwardedRef, forwardRef, Fragment, MouseEventHandler, useEffect, useImperativeHandle, useMemo, useRef, useState
17
9
  } from 'react';
18
10
  import {ChangeFunction, DatePickerTimeMode, ErrorType} from '../util/interfaces';
19
11
  import AwesomeIcon from '../icon/awesomeIcon';
@@ -21,7 +13,7 @@ import WithBackground from '../popup/withBackground';
21
13
  import DvrdButton from '../button/dvrdButton';
22
14
  import {generateComponentId} from '../util/componentUtil';
23
15
  import IDate from '@dvrd/idate';
24
- import {pad} from '../util/controlUtil';
16
+ import {pad, padNum} from '../util/controlUtil';
25
17
  import {Swiper, SwiperClass, SwiperSlide} from 'swiper/react';
26
18
  import {FreeMode, Mousewheel} from 'swiper/modules';
27
19
  import 'swiper/css';
@@ -45,7 +37,7 @@ interface Props {
45
37
  pickersOnly?: boolean;
46
38
  }
47
39
 
48
- export type DVRDDatePickerRef = { onOpen: VoidFunction; onClose: VoidFunction; }
40
+ export type DVRDDatePickerRef = {onOpen: VoidFunction; onClose: VoidFunction;}
49
41
 
50
42
  function DvrdDatePicker(props: Props, ref: ForwardedRef<DVRDDatePickerRef>) {
51
43
  const {
@@ -138,38 +130,72 @@ interface DatePickerProps {
138
130
  min?: IDate | string;
139
131
  }
140
132
 
133
+ type Day = {
134
+ number: number;
135
+ value: IDate;
136
+ currentMonth: boolean;
137
+ }
138
+
139
+ const beforePadDays = [6, 0, 1, 2, 3, 4, 5];
140
+
141
+ function buildFirstDaysRow(firstDay: IDate): [Array<Day> | null, IDate] {
142
+ const padBeforeDays = beforePadDays[firstDay.weekday()];
143
+ if (!padBeforeDays) return [null, firstDay];
144
+ const firstRow: Array<Day> = [];
145
+ for (let offset = padBeforeDays; offset >= 1; offset -= 1) {
146
+ const dayValue = firstDay.subtract(offset, 'days');
147
+ firstRow.push({
148
+ number: dayValue.day(),
149
+ value: dayValue,
150
+ currentMonth: false
151
+ });
152
+ }
153
+ let secondRowFirstDay = firstDay.clone();
154
+ while (firstRow.length < 7) {
155
+ firstRow.push({
156
+ number: secondRowFirstDay.day(),
157
+ value: secondRowFirstDay,
158
+ currentMonth: true
159
+ });
160
+ secondRowFirstDay = secondRowFirstDay.add(1, 'day');
161
+ }
162
+ return [firstRow, secondRowFirstDay];
163
+ }
164
+
165
+ function buildDay(value: IDate, year: number, month: number): Day {
166
+ return {
167
+ number: value.day(),
168
+ value,
169
+ currentMonth: value.year() === year && value.month() === month
170
+ };
171
+ }
172
+
173
+ const daysToRender = 42; // Always render 6 rows of days
174
+
141
175
  function DatePicker(props: DatePickerProps) {
142
176
  const {min, max, alwaysShowArrows, open, onClose, value, onChange} = props;
143
177
  const divRef = useRef<HTMLDivElement>(null);
144
178
  const pickerValue = useMemo(() => value?.clone() ?? IDate.now(), [value]);
145
- const [padBeforeDays, days, padAfterDays] = useMemo(() => {
146
- const daysInMonth = pickerValue.daysInMonth();
147
- const days: number[] = [];
148
- const padBeforeDays: number[] = [];
149
- const padAfterDays: number[] = [];
150
- for (let i = 1; i <= daysInMonth; i++) days.push(i);
151
- let firstMonthDay = pickerValue.day(1).weekday();
152
- if (!firstMonthDay) firstMonthDay = 7;
153
- const padDaysBefore = firstMonthDay - 1;
154
- let dayBefore = pickerValue.add(-1, 'month').daysInMonth();
155
- for (let i = 0; i < padDaysBefore; i++)
156
- padBeforeDays.splice(0, 0, dayBefore--);
157
-
158
- const lastWeekDay = pickerValue.day(daysInMonth).weekday();
159
- const padDaysAfter = 7 - lastWeekDay;
160
- for (let i = 0; i < padDaysAfter; i++)
161
- padAfterDays.push(i + 1);
162
-
163
- if (Math.ceil(padAfterDays.concat(days).concat(padBeforeDays).length / 7) < 6) {
164
- let dayAfter = padAfterDays[padAfterDays.length - 1] + 1;
165
- for (let i = 0; i < 7; i++)
166
- padAfterDays.push(dayAfter++);
179
+ const days: Array<Day> = useMemo(() => {
180
+ const month = pickerValue.month();
181
+ const year = pickerValue.year();
182
+ const days: Array<Day> = [];
183
+ let firstDay = new IDate(`${year}-${padNum(month)}-01`);
184
+ const [firstRow, nextFirstDay] = buildFirstDaysRow(firstDay);
185
+ if (firstRow) days.push(...firstRow);
186
+ firstDay = nextFirstDay;
187
+ while (days.length < daysToRender) {
188
+ for (let ix = 0; ix < 7; ix++) {
189
+ days.push(buildDay(firstDay, year, month));
190
+ firstDay = firstDay.add(1, 'day');
191
+ }
167
192
  }
168
- return [padBeforeDays, days, padAfterDays];
193
+
194
+ return days;
169
195
  }, [pickerValue]);
170
196
 
171
197
  function onReduce(key: 'year' | 'month') {
172
- return function () {
198
+ return function() {
173
199
  let value = pickerValue.clone();
174
200
  value = value.add(-1, key);
175
201
  value = value.day(Math.min(value.daysInMonth(), value.day()));
@@ -178,7 +204,7 @@ function DatePicker(props: DatePickerProps) {
178
204
  }
179
205
 
180
206
  function onAdd(key: 'year' | 'month') {
181
- return function () {
207
+ return function() {
182
208
  let value = pickerValue.clone();
183
209
  value = value.add(1, key);
184
210
  value = value.day(Math.min(value.daysInMonth(), value.day()));
@@ -187,7 +213,7 @@ function DatePicker(props: DatePickerProps) {
187
213
  }
188
214
 
189
215
  function onResetSwitcher(key: 'year' | 'month') {
190
- return function () {
216
+ return function() {
191
217
  let value = pickerValue.clone();
192
218
  if (key === 'year') value = value.year(IDate.now().year());
193
219
  else value = value.month(IDate.now().month());
@@ -200,25 +226,9 @@ function DatePicker(props: DatePickerProps) {
200
226
  onChange(true)(IDate.now());
201
227
  }
202
228
 
203
- function onSelectDay(day: number, month?: number, year?: number) {
204
- return function () {
205
- let pickValue = pickerValue.clone();
206
- if (day || value === null) {
207
- pickValue = pickValue.day(day);
208
- if (month !== undefined) pickValue = pickValue.month(month);
209
- if (year !== undefined) pickValue = pickValue.year(year);
210
- onChange(true)(pickValue);
211
- }
212
- };
213
- }
214
-
215
- function onSelectPadDay(day: number, kind: 'prev' | 'next') {
216
- return function () {
217
- let value = pickerValue.clone();
218
- if (kind === 'prev') value = value.add(-1, 'month');
219
- else value = value.add(1, 'month');
220
- value = value.day(day);
221
- onChange(true)(value);
229
+ function onSelectDay(day: Day) {
230
+ return function() {
231
+ onChange(true)(day.value);
222
232
  };
223
233
  }
224
234
 
@@ -267,14 +277,10 @@ function DatePicker(props: DatePickerProps) {
267
277
  divRef.current?.classList.remove('switch-mount');
268
278
  }
269
279
 
270
- function dateIsDisabled(day: number, month?: number, year?: number) {
280
+ function dateIsDisabled(day: Day) {
271
281
  if (!min && !max) return false;
272
- let pickValue = pickerValue.clone();
273
- pickValue = pickValue.day(day);
274
- if (month !== undefined) pickValue = pickValue.month(month);
275
- if (year !== undefined) pickValue = pickValue.year(year);
276
- if (min && new IDate(min).isAfter(pickValue, 'day')) return true;
277
- else if (max && new IDate(max).isBefore(pickValue, 'day')) return true;
282
+ if (min && new IDate(min).isAfter(day.value, 'day')) return true;
283
+ else if (max && new IDate(max).isBefore(day.value, 'day')) return true;
278
284
  return false;
279
285
  }
280
286
 
@@ -356,25 +362,17 @@ function DatePicker(props: DatePickerProps) {
356
362
  } else {
357
363
  document.removeEventListener('keydown', keyListener);
358
364
  }
359
- return function () {
365
+ return function() {
360
366
  document.removeEventListener('keydown', keyListener);
361
367
  };
362
368
  }, [open]);
363
369
 
364
- function renderDay(day: number, index: number, onClick: MouseEventHandler, className?: string,
365
- type?: 'prev' | 'next') {
366
- let pickValue = pickerValue.clone();
367
- if (type === 'prev')
368
- pickValue = pickValue.subtract(1, 'month');
369
- else if (type === 'next')
370
- pickValue = pickValue.add(1, 'month');
371
- const month = pickValue.month();
372
- const year = pickValue.year();
373
- const disabled = dateIsDisabled(day, month, year);
370
+ function renderDay(day: Day, index: number, onClick: MouseEventHandler, className?: string) {
371
+ const disabled = dateIsDisabled(day);
374
372
  return (
375
373
  <div className={classNames('day', disabled && 'disabled', className)}
376
374
  onClick={disabled ? undefined : onClick} key={index}>
377
- <span className='day-label'>{day}</span>
375
+ <span className='day-label'>{day.number}</span>
378
376
  </div>
379
377
  );
380
378
  }
@@ -420,16 +418,11 @@ function DatePicker(props: DatePickerProps) {
420
418
  <div className='day no-select'>
421
419
  <span className='day-label'>Zo</span>
422
420
  </div>
423
- {padBeforeDays.map((day: number, index: number) => {
424
- return renderDay(day, index, onSelectPadDay(day, 'prev'), 'pad', 'prev');
425
- })}
426
- {days.map((day: number, index: number) => {
427
- const isSelected = day === pickerValue.day();
421
+ {days.map((day: Day, index: number) => {
422
+ const isSelected = day.value.isAt(pickerValue, 'day');
428
423
  return renderDay(day, index, onSelectDay(day),
429
- classNames(isSelected && 'selected', day === 0 && 'hide'));
430
- })}
431
- {padAfterDays.map((day: number, index: number) => {
432
- return renderDay(day, index, onSelectPadDay(day, 'next'), 'pad', 'next');
424
+ classNames(isSelected && 'selected', day.number === 0 && 'hide',
425
+ !day.currentMonth && 'pad'));
433
426
  })}
434
427
  </div>
435
428
  <div className='actions-container'>
@@ -461,7 +454,7 @@ function TimePicker(props: TimePickerProps) {
461
454
  }
462
455
 
463
456
  function onSlideChange(key: 'hour' | 'minute' | 'second') {
464
- return function (swiper: SwiperClass) {
457
+ return function(swiper: SwiperClass) {
465
458
  if (key === 'hour') internalValue.current = internalValue.current.hours(swiper.realIndex);
466
459
  if (key === 'minute') internalValue.current = internalValue.current.minutes(swiper.realIndex);
467
460
  if (key === 'second') internalValue.current = internalValue.current.seconds(swiper.realIndex);
@@ -6,7 +6,7 @@ import './style/pdfElement.scss';
6
6
  import React, {MouseEventHandler, PropsWithChildren, PureComponent} from 'react';
7
7
  import {DraggableData, HandleClasses, HandleStyles, ResizeEnable, Rnd} from 'react-rnd';
8
8
  import {
9
- CustomAppEvent, ElementPosition, IndexedObject, PDFElementDimensions, PDFElementParams, PDFElementPersist, PdfFont,
9
+ CustomAppEvent, ElementPosition, PDFElementDimensions, PDFElementParams, PDFElementPersist, PdfFont,
10
10
  RNDDimensions
11
11
  } from "../../util/interfaces";
12
12
  import {generateComponentId} from "../../util/componentUtil";
@@ -17,7 +17,7 @@ import NumberString from "../../util/numberString";
17
17
 
18
18
  interface State {
19
19
  dragging: boolean;
20
- settings: IndexedObject<any>;
20
+ settings: Record<string, any>;
21
21
  }
22
22
 
23
23
  interface SharedProps {
@@ -5,7 +5,7 @@ import './style/pdfImage.scss';
5
5
 
6
6
  import React, {MouseEventHandler} from 'react';
7
7
  import {
8
- ElementPosition, IndexedObject, PDFDisplay, PDFElementParams, PDFElementPersist, PDFElementType, PDFImageParams
8
+ ElementPosition, PDFDisplay, PDFElementParams, PDFElementPersist, PDFElementType, PDFImageParams
9
9
  } from "../../util/interfaces";
10
10
  import {PDFDraggable, PdfElement} from "../element/pdfElement";
11
11
  import {nullify} from "../../util/miscUtil";
@@ -14,7 +14,7 @@ import {AwesomeIcon, directTimeout, PAGE_HEIGHT, PAGE_WIDTH} from "../../../../i
14
14
  interface Props {
15
15
  onDelete: MouseEventHandler;
16
16
  onSaveHistory: VoidFunction;
17
- values: IndexedObject<string>;
17
+ values: Record<string, string>;
18
18
  defaultSettings?: Partial<PDFImageParams>;
19
19
  id?: string;
20
20
  defaultPosition: { x: number; y: number };
@@ -11,7 +11,6 @@ import {
11
11
  dispatchCustomEvent,
12
12
  DvrdButton,
13
13
  generateUUID,
14
- IndexedObject,
15
14
  PDFElementParams,
16
15
  PDFElementPersist,
17
16
  PDFElementType,
@@ -37,7 +36,7 @@ interface Props {
37
36
  onPreview?: PDFSubmitHandler;
38
37
  onSubmit: PDFSubmitHandler;
39
38
  onChangeFont: (font: PdfFont, callback?: VoidFunction) => void;
40
- values: IndexedObject<string>;
39
+ values: Record<string, string>;
41
40
  defaultItems?: DefaultPDFElementParams<any, any>[];
42
41
  resetItems: DefaultPDFElementParams<any, any>[];
43
42
  customVariables?: PDFTextVariables;
@@ -53,7 +52,7 @@ interface Props {
53
52
  }
54
53
 
55
54
  interface State {
56
- elements: IndexedObject<{ element: React.ReactElement, config: DefaultPDFElementParams<any, any> }>;
55
+ elements: Record<string, { element: React.ReactElement, config: DefaultPDFElementParams<any, any> }>;
57
56
  focusedElement: PdfElement | null;
58
57
  canUndo: boolean;
59
58
  canRedo: boolean;
@@ -66,12 +65,12 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
66
65
  supportMultiPage: false,
67
66
  singleImage: false,
68
67
  };
69
- private refObjects: IndexedObject<PdfElement>;
68
+ private refObjects: Record<string, PdfElement>;
70
69
 
71
70
  constructor(props: Props) {
72
71
  super(props);
73
72
  this.refObjects = {};
74
- const elements: IndexedObject<{
73
+ const elements: Record<string, {
75
74
  element: React.ReactElement,
76
75
  config: DefaultPDFElementParams<any, any>
77
76
  }> = this.processItems(props.defaultItems);
@@ -79,7 +78,7 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
79
78
  }
80
79
 
81
80
  reloadTemplate(items: DefaultPDFElementParams<any, any>[]) {
82
- const elements: IndexedObject<{
81
+ const elements: Record<string, {
83
82
  element: React.ReactElement,
84
83
  config: DefaultPDFElementParams<any, any>
85
84
  }> = this.processItems(items);
@@ -87,11 +86,11 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
87
86
  }
88
87
 
89
88
  processItems = (items?: DefaultPDFElementParams<any, any>[],
90
- convertUnits: boolean = true): IndexedObject<{
89
+ convertUnits: boolean = true): Record<string, {
91
90
  element: React.ReactElement,
92
91
  config: DefaultPDFElementParams<any, any>
93
92
  }> => {
94
- const elements: IndexedObject<{ element: React.ReactElement, config: DefaultPDFElementParams<any, any> }> = {};
93
+ const elements: Record<string, { element: React.ReactElement, config: DefaultPDFElementParams<any, any> }> = {};
95
94
  if (items?.length) {
96
95
  items = JSON.parse(JSON.stringify(items));
97
96
  if (items) {
@@ -6,13 +6,7 @@ import './style/pdfTextSettings.scss';
6
6
  import React, {PureComponent} from 'react';
7
7
  import PdfText from "../../text/pdfText";
8
8
  import {
9
- ElementPosition,
10
- IndexedObject,
11
- PDFDisplay,
12
- PdfFont,
13
- PDFTextParams,
14
- PDFTextVariables,
15
- SelectItemShape
9
+ ElementPosition, PDFDisplay, PdfFont, PDFTextParams, PDFTextVariables, SelectItemShape
16
10
  } from "../../../util/interfaces";
17
11
  import {ColorPicker, DVRDNumberInput, DvrdSelect, fontItems, getPdfVariables} from "../../../../../index";
18
12
  import classNames from 'classnames';
@@ -24,7 +18,7 @@ interface Props {
24
18
  supportMultiPage: boolean;
25
19
  }
26
20
 
27
- interface State extends IndexedObject<any> {
21
+ interface State extends Record<string, any> {
28
22
  openVariables: keyof PDFTextVariables;
29
23
  bold: boolean;
30
24
  underline: boolean;
@@ -134,7 +128,7 @@ export default class PdfTextSettings extends PureComponent<Props, State> {
134
128
  )
135
129
  };
136
130
 
137
- renderVariables = (type: keyof PDFTextVariables, title: string, variables: IndexedObject<string>) => (
131
+ renderVariables = (type: keyof PDFTextVariables, title: string, variables: Record<string, string>) => (
138
132
  <div className={classNames('variables-container', this.state.openVariables === type && 'open')}>
139
133
  <label className='variables-title' onClick={this.onClickVariablesTitle(type)}>{title}</label>
140
134
  <div className='variables-main-container'>
@@ -6,7 +6,6 @@ import './style/pdfText.scss';
6
6
  import React, {CSSProperties, MouseEventHandler} from 'react';
7
7
  import {
8
8
  CustomAppEvent,
9
- IndexedObject,
10
9
  PDFDisplay,
11
10
  PDFElementParams,
12
11
  PDFElementPersist,
@@ -25,7 +24,7 @@ import {remToPx, WithEvents} from "../../../../";
25
24
  interface Props {
26
25
  onDelete: MouseEventHandler;
27
26
  onSaveHistory: VoidFunction;
28
- values: IndexedObject<string>;
27
+ values: Record<string, string>;
29
28
  defaultSettings?: Partial<PDFTextParams>;
30
29
  id?: string;
31
30
  customVariables?: PDFTextVariables;
@@ -36,10 +36,6 @@ export interface PasswordRule {
36
36
  validator: (password: string) => boolean;
37
37
  }
38
38
 
39
- export interface IndexedObject<T> {
40
- [key: string]: T;
41
- }
42
-
43
39
  export interface ColorSet {
44
40
  base: string;
45
41
  contrast: string;
@@ -51,7 +47,7 @@ export interface OrnamentShape {
51
47
  allowPropagation?: boolean;
52
48
  }
53
49
 
54
- export interface ResponseData extends IndexedObject<any> {
50
+ export interface ResponseData extends Record<string, any> {
55
51
  status: string;
56
52
  message?: string;
57
53
  success?: boolean;
@@ -197,7 +193,7 @@ export type ModelResponse<T> = (obj: T, success: boolean | undefined, data: Resp
197
193
  export type StrengthGauge = {validator: (password: string) => boolean};
198
194
  export type PDFSetting = {key: string; label: string; type: PDFSettingType; value: any};
199
195
 
200
- export type PDFElementParams<T extends PDFElementType, O extends IndexedObject<any>> = {
196
+ export type PDFElementParams<T extends PDFElementType, O extends Record<string, any>> = {
201
197
  key: string;
202
198
  type: T;
203
199
  sub_type?: PDFElementSubType | null;
@@ -206,7 +202,7 @@ export type PDFElementParams<T extends PDFElementType, O extends IndexedObject<a
206
202
  persistent?: PDFElementPersist;
207
203
  linkedID?: string;
208
204
  }
209
- export type DefaultPDFElementParams<T extends PDFElementType, O extends IndexedObject<any>> = Partial<{
205
+ export type DefaultPDFElementParams<T extends PDFElementType, O extends Record<string, any>> = Partial<{
210
206
  type: T;
211
207
  dimensions: Partial<{left: number; top: number; width: number; height: number}>;
212
208
  options: O;
@@ -246,9 +242,9 @@ export type PDFInvoiceTableParams = {
246
242
  };
247
243
  export type PDFInvoiceWidths = {name: number; price: number; quantity: number; subtotal: number}
248
244
  export type PDFTextVariables = {
249
- company: IndexedObject<string>;
250
- client: IndexedObject<string>;
251
- invoice: IndexedObject<string>;
245
+ company: Record<string, string>;
246
+ client: Record<string, string>;
247
+ invoice: Record<string, string>;
252
248
  }
253
249
  export type PDFSubmitHandler = (items: PDFElementParams<any, any>[], callback?: VoidFunction) => void;
254
250
  export type PDFElementDimensions = {left: number; top: number; width: number; height: number};
@@ -4,13 +4,12 @@
4
4
 
5
5
  import DOMPurify from 'dompurify';
6
6
  import React from 'react';
7
- import {IndexedObject} from './interfaces';
8
7
 
9
8
  declare global {
10
9
  // noinspection JSUnusedGlobalSymbols
11
10
  interface Window {
12
11
  log: Function;
13
- settings: IndexedObject<any>;
12
+ settings: Record<string, any>;
14
13
  allowCookies: boolean;
15
14
  gtag?: Function;
16
15
  gapi?: any;
@@ -18,7 +17,7 @@ declare global {
18
17
  }
19
18
 
20
19
  export const getSetting = (name: string): any => {
21
- const settings: IndexedObject<any> = window.settings;
20
+ const settings: Record<string, any> = window.settings;
22
21
  if (settings.hasOwnProperty(name))
23
22
  return settings[name];
24
23
  console.warn(`Global settings does not contain a value for '${name}'`);
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2024. Dave van Rijn Development
3
3
  */
4
4
 
5
- import {DefaultPDFElementParams, IndexedObject, PdfFont, PDFTextVariables, SelectItemShape} from "./interfaces";
5
+ import {DefaultPDFElementParams, PdfFont, PDFTextVariables, SelectItemShape} from "./interfaces";
6
6
 
7
7
  export const mmToPt = (mm: number) => Math.round(pxToPt(mmToPx(mm)));
8
8
  export const mmToPx = (mm: number, toTens: boolean = true) => {
@@ -70,7 +70,7 @@ export const getPdfVariables = (customVariables?: PDFTextVariables): PDFTextVari
70
70
  return variables;
71
71
  }
72
72
 
73
- export const setPdfVariables = (text: string, values: IndexedObject<string>) => {
73
+ export const setPdfVariables = (text: string, values: Record<string, string>) => {
74
74
  for (const key of Object.keys(values)) {
75
75
  const value = values[key];
76
76
  if (text.includes(`{${key}}`) && value.length) text =