@pdfme/schemas 5.1.1 → 5.1.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/src/date/date.js +1 -2
- package/dist/cjs/src/date/date.js.map +1 -1
- package/dist/cjs/src/date/dateTime.js +1 -2
- package/dist/cjs/src/date/dateTime.js.map +1 -1
- package/dist/cjs/src/date/helper.js +91 -67
- package/dist/cjs/src/date/helper.js.map +1 -1
- package/dist/cjs/src/date/time.js +1 -2
- package/dist/cjs/src/date/time.js.map +1 -1
- package/dist/esm/src/date/date.js +1 -2
- package/dist/esm/src/date/date.js.map +1 -1
- package/dist/esm/src/date/dateTime.js +1 -2
- package/dist/esm/src/date/dateTime.js.map +1 -1
- package/dist/esm/src/date/helper.js +93 -69
- package/dist/esm/src/date/helper.js.map +1 -1
- package/dist/esm/src/date/time.js +1 -2
- package/dist/esm/src/date/time.js.map +1 -1
- package/dist/types/src/date/helper.d.ts +2 -2
- package/dist/types/src/date/types.d.ts +1 -2
- package/package.json +2 -1
- package/src/date/date.ts +1 -3
- package/src/date/dateTime.ts +1 -3
- package/src/date/helper.ts +97 -78
- package/src/date/time.ts +1 -3
- package/src/date/types.ts +1 -2
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const helper_1 = require("./helper");
|
4
4
|
const type = 'date';
|
5
|
-
const inputType = 'date';
|
6
5
|
const defaultFormat = 'yyyy/MM/dd';
|
7
6
|
const formatsByLang = {
|
8
7
|
en: [
|
@@ -51,5 +50,5 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" ' +
|
|
51
50
|
'class="lucide lucide-calendar"><path d="M8 2v4"/><path d="M16 2v4"/>' +
|
52
51
|
'<rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>' +
|
53
52
|
'</svg>';
|
54
|
-
exports.default = (0, helper_1.getPlugin)({ type, defaultFormat, icon,
|
53
|
+
exports.default = (0, helper_1.getPlugin)({ type, defaultFormat, icon, formatsByLang });
|
55
54
|
//# sourceMappingURL=date.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../src/date/date.ts"],"names":[],"mappings":";;AACA,qCAAqC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../src/date/date.ts"],"names":[],"mappings":";;AACA,qCAAqC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,aAAa,GAA2B;IAC5C,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,cAAc;QACd,aAAa;QACb,oBAAoB;QACpB,YAAY;KACb;IACD,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC;IAClE,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC;IAClE,EAAE,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC;IACtE,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,CAAC;IACjG,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,uBAAuB;QACvB,YAAY;KACb;IACD,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,CAAC;IACjG,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,CAAC;IAChG,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,cAAc;QACd,aAAa;QACb,oBAAoB;QACpB,YAAY;KACb;IACD,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,mBAAmB;QACnB,kBAAkB;QAClB,yBAAyB;QACzB,YAAY;KACb;IACD,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,CAAC;CACjG,CAAC;AAEF,MAAM,IAAI,GACR,iEAAiE;IACjE,wDAAwD;IACxD,kEAAkE;IAClE,sEAAsE;IACtE,uEAAuE;IACvE,QAAQ,CAAC;AAEX,kBAAe,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC"}
|
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const helper_1 = require("./helper");
|
4
4
|
const type = 'dateTime';
|
5
|
-
const inputType = 'datetime-local';
|
6
5
|
const defaultFormat = 'yyyy/MM/dd HH:mm';
|
7
6
|
const formatsByLang = {
|
8
7
|
en: [
|
@@ -93,5 +92,5 @@ const formatsByLang = {
|
|
93
92
|
],
|
94
93
|
};
|
95
94
|
const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock"><path d="M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"/><path d="M16 2v4"/><path d="M8 2v4"/><path d="M3 10h5"/><path d="M17.5 17.5 16 16.3V14"/><circle cx="16" cy="16" r="6"/></svg>';
|
96
|
-
exports.default = (0, helper_1.getPlugin)({ type, defaultFormat, icon,
|
95
|
+
exports.default = (0, helper_1.getPlugin)({ type, defaultFormat, icon, formatsByLang });
|
97
96
|
//# sourceMappingURL=dateTime.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dateTime.js","sourceRoot":"","sources":["../../../../src/date/dateTime.ts"],"names":[],"mappings":";;AACA,qCAAqC;AAErC,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,MAAM,
|
1
|
+
{"version":3,"file":"dateTime.js","sourceRoot":"","sources":["../../../../src/date/dateTime.ts"],"names":[],"mappings":";;AACA,qCAAqC;AAErC,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,aAAa,GAA2B;IAC5C,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,qBAAqB;QACrB,oBAAoB;QACpB,2BAA2B;QAC3B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,cAAc;QACd,YAAY;QACZ,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,cAAc;QACd,YAAY;QACZ,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,qBAAqB;QACrB,eAAe;QACf,aAAa;QACb,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,oBAAoB;QACpB,mBAAmB;QACnB,0BAA0B;QAC1B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,6BAA6B;QAC7B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,yBAAyB;QACzB,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,wBAAwB;QACxB,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,oBAAoB;QACpB,mBAAmB;QACnB,0BAA0B;QAC1B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,0BAA0B;QAC1B,yBAAyB;QACzB,gCAAgC;QAChC,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,wBAAwB;QACxB,uBAAuB;KACxB;CACF,CAAC;AAEF,MAAM,IAAI,GACR,kaAAka,CAAC;AAEra,kBAAe,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC"}
|
@@ -4,6 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.getPlugin = void 0;
|
7
|
+
const air_datepicker_1 = __importDefault(require("air-datepicker"));
|
8
|
+
const en_1 = __importDefault(require("air-datepicker/locale/en"));
|
9
|
+
const zh_1 = __importDefault(require("air-datepicker/locale/zh"));
|
10
|
+
const ja_1 = __importDefault(require("air-datepicker/locale/ja"));
|
11
|
+
const ko_1 = __importDefault(require("air-datepicker/locale/ko"));
|
12
|
+
const ar_1 = __importDefault(require("air-datepicker/locale/ar"));
|
13
|
+
const th_1 = __importDefault(require("air-datepicker/locale/th"));
|
14
|
+
const pl_1 = __importDefault(require("air-datepicker/locale/pl"));
|
15
|
+
const it_1 = __importDefault(require("air-datepicker/locale/it"));
|
16
|
+
const de_1 = __importDefault(require("air-datepicker/locale/de"));
|
17
|
+
const es_1 = __importDefault(require("air-datepicker/locale/es"));
|
18
|
+
const fr_1 = __importDefault(require("air-datepicker/locale/fr"));
|
19
|
+
require("air-datepicker/air-datepicker.css");
|
7
20
|
const date_fns_1 = require("date-fns");
|
8
21
|
const locale_1 = require("date-fns/locale");
|
9
22
|
const common_1 = require("@pdfme/common");
|
@@ -13,15 +26,30 @@ const uiRender_1 = require("../text/uiRender");
|
|
13
26
|
const helper_js_1 = require("../text/helper.js");
|
14
27
|
const constants_js_2 = require("../text/constants.js");
|
15
28
|
const extraFormatter_1 = require("../text/extraFormatter");
|
16
|
-
const
|
17
|
-
const
|
29
|
+
const utils_1 = require("../utils");
|
30
|
+
const getDateFnsLocale = (lang) => ({ en: locale_1.enUS, zh: locale_1.zhCN, ja: locale_1.ja, ko: locale_1.ko, ar: locale_1.ar, th: locale_1.th, pl: locale_1.pl, it: locale_1.it, de: locale_1.de, es: locale_1.es, fr: locale_1.fr }[lang]);
|
31
|
+
const getAirDatepickerLocale = (lang) => ({
|
32
|
+
en: en_1.default,
|
33
|
+
zh: zh_1.default,
|
34
|
+
ja: ja_1.default,
|
35
|
+
ko: ko_1.default,
|
36
|
+
ar: ar_1.default,
|
37
|
+
th: th_1.default,
|
38
|
+
pl: pl_1.default,
|
39
|
+
it: it_1.default,
|
40
|
+
de: de_1.default,
|
41
|
+
es: es_1.default,
|
42
|
+
fr: fr_1.default,
|
43
|
+
}[lang]);
|
44
|
+
const getPlugin = ({ type, defaultFormat, icon, formatsByLang, }) => {
|
18
45
|
const plugin = {
|
19
46
|
ui: async (arg) => {
|
20
|
-
const { schema, value, onChange, rootElement, mode, options, _cache } = arg;
|
21
|
-
|
47
|
+
const { schema, value, onChange, rootElement, mode, options, i18n, _cache } = arg;
|
48
|
+
const beforeRemoveEvent = new Event('beforeRemove');
|
49
|
+
rootElement.dispatchEvent(beforeRemoveEvent);
|
22
50
|
const font = options?.font || (0, common_1.getDefaultFont)();
|
23
51
|
const fontKitFont = await (0, helper_js_1.getFontKitFont)(schema.fontName, font, _cache);
|
24
|
-
const { topAdj, bottomAdj } = (0, helper_js_1.getBrowserVerticalFontAdjustments)(fontKitFont, schema.fontSize ?? constants_js_2.DEFAULT_FONT_SIZE, constants_js_2.DEFAULT_LINE_HEIGHT,
|
52
|
+
const { topAdj, bottomAdj } = (0, helper_js_1.getBrowserVerticalFontAdjustments)(fontKitFont, schema.fontSize ?? constants_js_2.DEFAULT_FONT_SIZE, constants_js_2.DEFAULT_LINE_HEIGHT, constants_js_2.VERTICAL_ALIGN_MIDDLE);
|
25
53
|
const topAdjustment = topAdj.toString();
|
26
54
|
const bottomAdjustment = bottomAdj.toString();
|
27
55
|
const textStyle = {
|
@@ -32,93 +60,90 @@ const getPlugin = ({ type, defaultFormat, icon, inputType, formatsByLang, }) =>
|
|
32
60
|
textAlign: schema.alignment ?? constants_js_2.DEFAULT_ALIGNMENT,
|
33
61
|
backgroundColor: (0, uiRender_1.getBackgroundColor)(value, schema),
|
34
62
|
margin: '0',
|
63
|
+
padding: '0',
|
64
|
+
border: 'none',
|
65
|
+
outline: 'none',
|
35
66
|
width: `${schema.width}mm`,
|
36
67
|
height: `${schema.height}mm`,
|
37
68
|
display: 'flex',
|
38
69
|
flexDirection: 'column',
|
39
|
-
justifyContent: (0, uiRender_1.mapVerticalAlignToFlex)(
|
70
|
+
justifyContent: (0, uiRender_1.mapVerticalAlignToFlex)(constants_js_2.VERTICAL_ALIGN_MIDDLE),
|
40
71
|
paddingTop: `${topAdjustment}px`,
|
41
72
|
marginBottom: `${bottomAdjustment}px`,
|
42
73
|
position: 'relative',
|
43
74
|
};
|
44
|
-
const
|
45
|
-
Object.assign(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
})
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
padding: '5px',
|
90
|
-
width: `${buttonWidth}px`,
|
91
|
-
height: `${buttonWidth}px`,
|
92
|
-
};
|
93
|
-
Object.assign(removeButton.style, removeButtonStyle);
|
94
|
-
removeButton.addEventListener('click', () => {
|
95
|
-
onChange && onChange({ key: 'content', value: '' });
|
96
|
-
});
|
97
|
-
rootElement.appendChild(removeButton);
|
98
|
-
}
|
75
|
+
const input = document.createElement('input');
|
76
|
+
Object.assign(input.style, textStyle);
|
77
|
+
const commitChange = ({ datepicker }) => {
|
78
|
+
if (onChange) {
|
79
|
+
const date = datepicker.selectedDates;
|
80
|
+
const fmt = type === 'time' ? 'HH:mm' : type === 'date' ? 'yyyy/MM/dd' : 'yyyy/MM/dd HH:mm';
|
81
|
+
const d = Array.isArray(date) ? date[0] : date || '';
|
82
|
+
const value = d ? (0, date_fns_1.format)(d, fmt) : '';
|
83
|
+
onChange({ key: 'content', value });
|
84
|
+
}
|
85
|
+
};
|
86
|
+
const airDatepicker = new air_datepicker_1.default(input, {
|
87
|
+
locale: getAirDatepickerLocale(options.lang || 'en'),
|
88
|
+
selectedDates: [schema.type === 'time' ? new Date(`2021-01-01T${value}`) : new Date(value)],
|
89
|
+
dateFormat: (date) => (schema.format ? (0, date_fns_1.format)(date, schema.format) : ''),
|
90
|
+
timepicker: type !== 'date',
|
91
|
+
onlyTimepicker: type === 'time',
|
92
|
+
buttons: [
|
93
|
+
'clear',
|
94
|
+
{
|
95
|
+
content: i18n('close'),
|
96
|
+
onClick: (datepicker) => {
|
97
|
+
datepicker.hide();
|
98
|
+
commitChange({ datepicker });
|
99
|
+
},
|
100
|
+
},
|
101
|
+
],
|
102
|
+
onSelect: ({ datepicker }) => {
|
103
|
+
mode !== 'designer' && commitChange({ datepicker });
|
104
|
+
},
|
105
|
+
onShow: () => {
|
106
|
+
input.disabled = !(0, utils_1.isEditable)(mode, schema);
|
107
|
+
},
|
108
|
+
});
|
109
|
+
rootElement.addEventListener('beforeRemove', () => {
|
110
|
+
if (mode === 'designer') {
|
111
|
+
airDatepicker.destroy();
|
112
|
+
}
|
113
|
+
});
|
114
|
+
input.addEventListener('click', () => {
|
115
|
+
if (mode === 'designer') {
|
116
|
+
airDatepicker.show();
|
117
|
+
}
|
118
|
+
});
|
119
|
+
rootElement.appendChild(input);
|
99
120
|
},
|
100
121
|
pdf: (arg) => {
|
101
122
|
const { schema, value, options } = arg;
|
102
123
|
if (!value)
|
103
124
|
return void 0;
|
104
|
-
const lang = (options.
|
105
|
-
const locale =
|
125
|
+
const lang = (options.lang || 'en');
|
126
|
+
const locale = getDateFnsLocale(lang);
|
106
127
|
const date = schema.type === 'time' ? new Date(`2021-01-01T${value}`) : new Date(value);
|
107
128
|
const formattedValue = (0, date_fns_1.format)(date, schema.format, { locale });
|
108
129
|
return text_1.default.pdf(Object.assign(arg, {
|
109
130
|
value: formattedValue,
|
110
|
-
schema: {
|
131
|
+
schema: {
|
132
|
+
...schema,
|
133
|
+
verticalAlignment: constants_js_2.VERTICAL_ALIGN_MIDDLE,
|
134
|
+
lineHeight: constants_js_2.DEFAULT_LINE_HEIGHT,
|
135
|
+
},
|
111
136
|
}));
|
112
137
|
},
|
113
138
|
propPanel: {
|
114
139
|
schema: ({ options, i18n }) => {
|
115
140
|
const font = options.font || { [common_1.DEFAULT_FONT_NAME]: { data: '', fallback: true } };
|
116
141
|
const lang = options.lang || 'en';
|
117
|
-
const locale =
|
142
|
+
const locale = getDateFnsLocale(lang);
|
118
143
|
const fontNames = Object.keys(font);
|
119
144
|
const fallbackFontName = (0, common_1.getFallbackFontName)(font);
|
120
145
|
const formatter = (0, extraFormatter_1.getExtraFormatterSchema)(i18n);
|
121
|
-
formatter.buttons = formatter.buttons.filter((button) => button.key
|
146
|
+
formatter.buttons = formatter.buttons.filter((button) => button.key === extraFormatter_1.Formatter.ALIGNMENT);
|
122
147
|
const currentDate = new Date();
|
123
148
|
const dateSchema = {
|
124
149
|
format: {
|
@@ -191,7 +216,6 @@ const getPlugin = ({ type, defaultFormat, icon, inputType, formatsByLang, }) =>
|
|
191
216
|
height: 10,
|
192
217
|
rotate: 0,
|
193
218
|
alignment: constants_js_2.DEFAULT_ALIGNMENT,
|
194
|
-
verticalAlignment: constants_js_2.DEFAULT_VERTICAL_ALIGNMENT,
|
195
219
|
fontSize: constants_js_2.DEFAULT_FONT_SIZE,
|
196
220
|
characterSpacing: constants_js_2.DEFAULT_CHARACTER_SPACING,
|
197
221
|
fontColor: constants_js_2.DEFAULT_FONT_COLOR,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/date/helper.ts"],"names":[],"mappings":";;;;;;AACA,uCAAkC;AAClC,
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/date/helper.ts"],"names":[],"mappings":";;;;;;AACA,oEAAoE;AACpE,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,6CAA2C;AAC3C,uCAAkC;AAClC,4CAAyF;AACzF,0CAOuB;AACvB,mDAA2B;AAC3B,kDAAqE;AACrE,+CAA8E;AAC9E,iDAAsF;AACtF,uDAO8B;AAE9B,2DAA4E;AAC5E,oCAAsC;AAEtC,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAsB,EAAE,CAC1D,CAAC,EAAE,EAAE,EAAE,aAAI,EAAE,EAAE,EAAE,aAAI,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,EAAE,EAAF,WAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAErE,MAAM,sBAAsB,GAAG,CAAC,IAAU,EAAmC,EAAE,CAC7E,CAAC;IACC,EAAE,EAAE,YAAQ;IACZ,EAAE,EAAE,YAAQ;IACZ,EAAE,EAAE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B;gCAC1B,OAAO,EAAE,IAAI,CAAC,qBAAqB,CAAC;6BACrC;yBACF;qBACF;iBACF,CAAC;gBAEF,OAAO,UAAU,CAAC;YACpB,CAAC;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,aAAa;gBACrB,IAAI;gBACJ,OAAO,EAAE,IAAA,iBAAM,EAAC,IAAI,IAAI,EAAE,EAAE,aAAa,CAAC;gBAC1C,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;gBACxB,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,CAAC;gBACT,SAAS,EAAE,gCAAiB;gBAC5B,QAAQ,EAAE,gCAAiB;gBAC3B,gBAAgB,EAAE,wCAAyB;gBAC3C,SAAS,EAAE,iCAAkB;gBAC7B,QAAQ,EAAE,SAAS;gBACnB,eAAe,EAAE,EAAE;gBACnB,OAAO,EAAE,8BAAe;aACzB;SACF;QACD,IAAI;KACL,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA9NW,QAAA,SAAS,aA8NpB"}
|
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const helper_1 = require("./helper");
|
4
4
|
const type = 'time';
|
5
|
-
const inputType = 'time';
|
6
5
|
const defaultFormat = 'HH:mm';
|
7
6
|
const formatsByLang = {
|
8
7
|
en: [defaultFormat, 'hh:mm a', 'HH:mm:ss', 'hh:mm:ss a'],
|
@@ -22,5 +21,5 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" ' +
|
|
22
21
|
'stroke-width="2" stroke-linecap="round" stroke-linejoin="round" ' +
|
23
22
|
'class="lucide lucide-clock"><circle cx="12" cy="12" r="10"/>' +
|
24
23
|
'<polyline points="12 6 12 12 16 14"/></svg>';
|
25
|
-
exports.default = (0, helper_1.getPlugin)({ type, defaultFormat, icon,
|
24
|
+
exports.default = (0, helper_1.getPlugin)({ type, defaultFormat, icon, formatsByLang });
|
26
25
|
//# sourceMappingURL=time.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../../../src/date/time.ts"],"names":[],"mappings":";;AACA,qCAAqC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../../../src/date/time.ts"],"names":[],"mappings":";;AACA,qCAAqC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,MAAM,aAAa,GAA2B;IAC5C,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC;IACxD,EAAE,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC;IACzC,EAAE,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC;IACzC,EAAE,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,UAAU,CAAC;IAC3C,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC;IAC1C,EAAE,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC;IACxC,EAAE,EAAE,CAAC,aAAa,EAAE,UAAU,CAAC;IAC/B,EAAE,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC;IACxC,EAAE,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC;IACxC,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC;IAC1C,EAAE,EAAE,CAAC,aAAa,EAAE,UAAU,CAAC;CAChC,CAAC;AAEF,MAAM,IAAI,GACR,iEAAiE;IACjE,wDAAwD;IACxD,kEAAkE;IAClE,8DAA8D;IAC9D,6CAA6C,CAAC;AAEhD,kBAAe,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC"}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { getPlugin } from './helper';
|
2
2
|
const type = 'date';
|
3
|
-
const inputType = 'date';
|
4
3
|
const defaultFormat = 'yyyy/MM/dd';
|
5
4
|
const formatsByLang = {
|
6
5
|
en: [
|
@@ -49,5 +48,5 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" ' +
|
|
49
48
|
'class="lucide lucide-calendar"><path d="M8 2v4"/><path d="M16 2v4"/>' +
|
50
49
|
'<rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>' +
|
51
50
|
'</svg>';
|
52
|
-
export default getPlugin({ type, defaultFormat, icon,
|
51
|
+
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
53
52
|
//# sourceMappingURL=date.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../src/date/date.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../src/date/date.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,aAAa,GAA2B;IAC5C,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,cAAc;QACd,aAAa;QACb,oBAAoB;QACpB,YAAY;KACb;IACD,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC;IAClE,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC;IAClE,EAAE,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC;IACtE,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,CAAC;IACjG,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,uBAAuB;QACvB,YAAY;KACb;IACD,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,CAAC;IACjG,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,CAAC;IAChG,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,cAAc;QACd,aAAa;QACb,oBAAoB;QACpB,YAAY;KACb;IACD,EAAE,EAAE;QACF,aAAa;QACb,YAAY;QACZ,mBAAmB;QACnB,kBAAkB;QAClB,yBAAyB;QACzB,YAAY;KACb;IACD,EAAE,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,CAAC;CACjG,CAAC;AAEF,MAAM,IAAI,GACR,iEAAiE;IACjE,wDAAwD;IACxD,kEAAkE;IAClE,sEAAsE;IACtE,uEAAuE;IACvE,QAAQ,CAAC;AAEX,eAAe,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC"}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { getPlugin } from './helper';
|
2
2
|
const type = 'dateTime';
|
3
|
-
const inputType = 'datetime-local';
|
4
3
|
const defaultFormat = 'yyyy/MM/dd HH:mm';
|
5
4
|
const formatsByLang = {
|
6
5
|
en: [
|
@@ -91,5 +90,5 @@ const formatsByLang = {
|
|
91
90
|
],
|
92
91
|
};
|
93
92
|
const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock"><path d="M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"/><path d="M16 2v4"/><path d="M8 2v4"/><path d="M3 10h5"/><path d="M17.5 17.5 16 16.3V14"/><circle cx="16" cy="16" r="6"/></svg>';
|
94
|
-
export default getPlugin({ type, defaultFormat, icon,
|
93
|
+
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
95
94
|
//# sourceMappingURL=dateTime.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dateTime.js","sourceRoot":"","sources":["../../../../src/date/dateTime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,MAAM,
|
1
|
+
{"version":3,"file":"dateTime.js","sourceRoot":"","sources":["../../../../src/date/dateTime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,aAAa,GAA2B;IAC5C,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,qBAAqB;QACrB,oBAAoB;QACpB,2BAA2B;QAC3B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,cAAc;QACd,YAAY;QACZ,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,cAAc;QACd,YAAY;QACZ,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,qBAAqB;QACrB,eAAe;QACf,aAAa;QACb,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,oBAAoB;QACpB,mBAAmB;QACnB,0BAA0B;QAC1B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,6BAA6B;QAC7B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,yBAAyB;QACzB,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,wBAAwB;QACxB,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,oBAAoB;QACpB,mBAAmB;QACnB,0BAA0B;QAC1B,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,mBAAmB;QACnB,0BAA0B;QAC1B,yBAAyB;QACzB,gCAAgC;QAChC,uBAAuB;KACxB;IACD,EAAE,EAAE;QACF,aAAa;QACb,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,wBAAwB;QACxB,uBAAuB;KACxB;CACF,CAAC;AAEF,MAAM,IAAI,GACR,kaAAka,CAAC;AAEra,eAAe,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC"}
|
@@ -1,21 +1,49 @@
|
|
1
|
+
import AirDatepicker from 'air-datepicker';
|
2
|
+
import localeEn from 'air-datepicker/locale/en';
|
3
|
+
import localeZh from 'air-datepicker/locale/zh';
|
4
|
+
import localeJa from 'air-datepicker/locale/ja';
|
5
|
+
import localeKo from 'air-datepicker/locale/ko';
|
6
|
+
import localeAr from 'air-datepicker/locale/ar';
|
7
|
+
import localeTh from 'air-datepicker/locale/th';
|
8
|
+
import localePl from 'air-datepicker/locale/pl';
|
9
|
+
import localeIt from 'air-datepicker/locale/it';
|
10
|
+
import localeDe from 'air-datepicker/locale/de';
|
11
|
+
import localeEs from 'air-datepicker/locale/es';
|
12
|
+
import localeFr from 'air-datepicker/locale/fr';
|
13
|
+
import 'air-datepicker/air-datepicker.css';
|
1
14
|
import { format } from 'date-fns';
|
2
|
-
import { zhCN, ja, ko, ar, th, pl, it, de, es, fr } from 'date-fns/locale';
|
15
|
+
import { enUS, zhCN, ja, ko, ar, th, pl, it, de, es, fr } from 'date-fns/locale';
|
3
16
|
import { getDefaultFont, getFallbackFontName, DEFAULT_FONT_NAME, } from '@pdfme/common';
|
4
17
|
import text from '../text';
|
5
18
|
import { DEFAULT_OPACITY, HEX_COLOR_PATTERN } from '../constants.js';
|
6
19
|
import { mapVerticalAlignToFlex, getBackgroundColor } from '../text/uiRender';
|
7
20
|
import { getFontKitFont, getBrowserVerticalFontAdjustments } from '../text/helper.js';
|
8
|
-
import { DEFAULT_FONT_SIZE, DEFAULT_ALIGNMENT,
|
21
|
+
import { DEFAULT_FONT_SIZE, DEFAULT_ALIGNMENT, VERTICAL_ALIGN_MIDDLE, DEFAULT_LINE_HEIGHT, DEFAULT_CHARACTER_SPACING, DEFAULT_FONT_COLOR, } from '../text/constants.js';
|
9
22
|
import { getExtraFormatterSchema, Formatter } from '../text/extraFormatter';
|
10
|
-
|
11
|
-
|
23
|
+
import { isEditable } from '../utils';
|
24
|
+
const getDateFnsLocale = (lang) => ({ en: enUS, zh: zhCN, ja, ko, ar, th, pl, it, de, es, fr }[lang]);
|
25
|
+
const getAirDatepickerLocale = (lang) => ({
|
26
|
+
en: localeEn,
|
27
|
+
zh: localeZh,
|
28
|
+
ja: localeJa,
|
29
|
+
ko: localeKo,
|
30
|
+
ar: localeAr,
|
31
|
+
th: localeTh,
|
32
|
+
pl: localePl,
|
33
|
+
it: localeIt,
|
34
|
+
de: localeDe,
|
35
|
+
es: localeEs,
|
36
|
+
fr: localeFr,
|
37
|
+
}[lang]);
|
38
|
+
export const getPlugin = ({ type, defaultFormat, icon, formatsByLang, }) => {
|
12
39
|
const plugin = {
|
13
40
|
ui: async (arg) => {
|
14
|
-
const { schema, value, onChange, rootElement, mode, options, _cache } = arg;
|
15
|
-
|
41
|
+
const { schema, value, onChange, rootElement, mode, options, i18n, _cache } = arg;
|
42
|
+
const beforeRemoveEvent = new Event('beforeRemove');
|
43
|
+
rootElement.dispatchEvent(beforeRemoveEvent);
|
16
44
|
const font = options?.font || getDefaultFont();
|
17
45
|
const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
|
18
|
-
const { topAdj, bottomAdj } = getBrowserVerticalFontAdjustments(fontKitFont, schema.fontSize ?? DEFAULT_FONT_SIZE, DEFAULT_LINE_HEIGHT,
|
46
|
+
const { topAdj, bottomAdj } = getBrowserVerticalFontAdjustments(fontKitFont, schema.fontSize ?? DEFAULT_FONT_SIZE, DEFAULT_LINE_HEIGHT, VERTICAL_ALIGN_MIDDLE);
|
19
47
|
const topAdjustment = topAdj.toString();
|
20
48
|
const bottomAdjustment = bottomAdj.toString();
|
21
49
|
const textStyle = {
|
@@ -26,93 +54,90 @@ export const getPlugin = ({ type, defaultFormat, icon, inputType, formatsByLang,
|
|
26
54
|
textAlign: schema.alignment ?? DEFAULT_ALIGNMENT,
|
27
55
|
backgroundColor: getBackgroundColor(value, schema),
|
28
56
|
margin: '0',
|
57
|
+
padding: '0',
|
58
|
+
border: 'none',
|
59
|
+
outline: 'none',
|
29
60
|
width: `${schema.width}mm`,
|
30
61
|
height: `${schema.height}mm`,
|
31
62
|
display: 'flex',
|
32
63
|
flexDirection: 'column',
|
33
|
-
justifyContent: mapVerticalAlignToFlex(
|
64
|
+
justifyContent: mapVerticalAlignToFlex(VERTICAL_ALIGN_MIDDLE),
|
34
65
|
paddingTop: `${topAdjustment}px`,
|
35
66
|
marginBottom: `${bottomAdjustment}px`,
|
36
67
|
position: 'relative',
|
37
68
|
};
|
38
|
-
const
|
39
|
-
Object.assign(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
})
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
padding: '5px',
|
84
|
-
width: `${buttonWidth}px`,
|
85
|
-
height: `${buttonWidth}px`,
|
86
|
-
};
|
87
|
-
Object.assign(removeButton.style, removeButtonStyle);
|
88
|
-
removeButton.addEventListener('click', () => {
|
89
|
-
onChange && onChange({ key: 'content', value: '' });
|
90
|
-
});
|
91
|
-
rootElement.appendChild(removeButton);
|
92
|
-
}
|
69
|
+
const input = document.createElement('input');
|
70
|
+
Object.assign(input.style, textStyle);
|
71
|
+
const commitChange = ({ datepicker }) => {
|
72
|
+
if (onChange) {
|
73
|
+
const date = datepicker.selectedDates;
|
74
|
+
const fmt = type === 'time' ? 'HH:mm' : type === 'date' ? 'yyyy/MM/dd' : 'yyyy/MM/dd HH:mm';
|
75
|
+
const d = Array.isArray(date) ? date[0] : date || '';
|
76
|
+
const value = d ? format(d, fmt) : '';
|
77
|
+
onChange({ key: 'content', value });
|
78
|
+
}
|
79
|
+
};
|
80
|
+
const airDatepicker = new AirDatepicker(input, {
|
81
|
+
locale: getAirDatepickerLocale(options.lang || 'en'),
|
82
|
+
selectedDates: [schema.type === 'time' ? new Date(`2021-01-01T${value}`) : new Date(value)],
|
83
|
+
dateFormat: (date) => (schema.format ? format(date, schema.format) : ''),
|
84
|
+
timepicker: type !== 'date',
|
85
|
+
onlyTimepicker: type === 'time',
|
86
|
+
buttons: [
|
87
|
+
'clear',
|
88
|
+
{
|
89
|
+
content: i18n('close'),
|
90
|
+
onClick: (datepicker) => {
|
91
|
+
datepicker.hide();
|
92
|
+
commitChange({ datepicker });
|
93
|
+
},
|
94
|
+
},
|
95
|
+
],
|
96
|
+
onSelect: ({ datepicker }) => {
|
97
|
+
mode !== 'designer' && commitChange({ datepicker });
|
98
|
+
},
|
99
|
+
onShow: () => {
|
100
|
+
input.disabled = !isEditable(mode, schema);
|
101
|
+
},
|
102
|
+
});
|
103
|
+
rootElement.addEventListener('beforeRemove', () => {
|
104
|
+
if (mode === 'designer') {
|
105
|
+
airDatepicker.destroy();
|
106
|
+
}
|
107
|
+
});
|
108
|
+
input.addEventListener('click', () => {
|
109
|
+
if (mode === 'designer') {
|
110
|
+
airDatepicker.show();
|
111
|
+
}
|
112
|
+
});
|
113
|
+
rootElement.appendChild(input);
|
93
114
|
},
|
94
115
|
pdf: (arg) => {
|
95
116
|
const { schema, value, options } = arg;
|
96
117
|
if (!value)
|
97
118
|
return void 0;
|
98
|
-
const lang = (options.
|
99
|
-
const locale =
|
119
|
+
const lang = (options.lang || 'en');
|
120
|
+
const locale = getDateFnsLocale(lang);
|
100
121
|
const date = schema.type === 'time' ? new Date(`2021-01-01T${value}`) : new Date(value);
|
101
122
|
const formattedValue = format(date, schema.format, { locale });
|
102
123
|
return text.pdf(Object.assign(arg, {
|
103
124
|
value: formattedValue,
|
104
|
-
schema: {
|
125
|
+
schema: {
|
126
|
+
...schema,
|
127
|
+
verticalAlignment: VERTICAL_ALIGN_MIDDLE,
|
128
|
+
lineHeight: DEFAULT_LINE_HEIGHT,
|
129
|
+
},
|
105
130
|
}));
|
106
131
|
},
|
107
132
|
propPanel: {
|
108
133
|
schema: ({ options, i18n }) => {
|
109
134
|
const font = options.font || { [DEFAULT_FONT_NAME]: { data: '', fallback: true } };
|
110
135
|
const lang = options.lang || 'en';
|
111
|
-
const locale =
|
136
|
+
const locale = getDateFnsLocale(lang);
|
112
137
|
const fontNames = Object.keys(font);
|
113
138
|
const fallbackFontName = getFallbackFontName(font);
|
114
139
|
const formatter = getExtraFormatterSchema(i18n);
|
115
|
-
formatter.buttons = formatter.buttons.filter((button) => button.key
|
140
|
+
formatter.buttons = formatter.buttons.filter((button) => button.key === Formatter.ALIGNMENT);
|
116
141
|
const currentDate = new Date();
|
117
142
|
const dateSchema = {
|
118
143
|
format: {
|
@@ -185,7 +210,6 @@ export const getPlugin = ({ type, defaultFormat, icon, inputType, formatsByLang,
|
|
185
210
|
height: 10,
|
186
211
|
rotate: 0,
|
187
212
|
alignment: DEFAULT_ALIGNMENT,
|
188
|
-
verticalAlignment: DEFAULT_VERTICAL_ALIGNMENT,
|
189
213
|
fontSize: DEFAULT_FONT_SIZE,
|
190
214
|
characterSpacing: DEFAULT_CHARACTER_SPACING,
|
191
215
|
fontColor: DEFAULT_FONT_COLOR,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/date/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAU,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/date/helper.ts"],"names":[],"mappings":"AACA,OAAO,aAAsC,MAAM,gBAAgB,CAAC;AACpE,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAChD,OAAO,QAAQ,MAAM,0BAA0B,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AC,qBAAqB,CAAC;6BACrC;yBACF;qBACF;iBACF,CAAC;gBAEF,OAAO,UAAU,CAAC;YACpB,CAAC;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,aAAa;gBACrB,IAAI;gBACJ,OAAO,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,aAAa,CAAC;gBAC1C,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;gBACxB,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,CAAC;gBACT,SAAS,EAAE,iBAAiB;gBAC5B,QAAQ,EAAE,iBAAiB;gBAC3B,gBAAgB,EAAE,yBAAyB;gBAC3C,SAAS,EAAE,kBAAkB;gBAC7B,QAAQ,EAAE,SAAS;gBACnB,eAAe,EAAE,EAAE;gBACnB,OAAO,EAAE,eAAe;aACzB;SACF;QACD,IAAI;KACL,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { getPlugin } from './helper';
|
2
2
|
const type = 'time';
|
3
|
-
const inputType = 'time';
|
4
3
|
const defaultFormat = 'HH:mm';
|
5
4
|
const formatsByLang = {
|
6
5
|
en: [defaultFormat, 'hh:mm a', 'HH:mm:ss', 'hh:mm:ss a'],
|
@@ -20,5 +19,5 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" ' +
|
|
20
19
|
'stroke-width="2" stroke-linecap="round" stroke-linejoin="round" ' +
|
21
20
|
'class="lucide lucide-clock"><circle cx="12" cy="12" r="10"/>' +
|
22
21
|
'<polyline points="12 6 12 12 16 14"/></svg>';
|
23
|
-
export default getPlugin({ type, defaultFormat, icon,
|
22
|
+
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
24
23
|
//# sourceMappingURL=time.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../../../src/date/time.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../../../src/date/time.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,MAAM,aAAa,GAA2B;IAC5C,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC;IACxD,EAAE,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC;IACzC,EAAE,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC;IACzC,EAAE,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,UAAU,CAAC;IAC3C,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC;IAC1C,EAAE,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC;IACxC,EAAE,EAAE,CAAC,aAAa,EAAE,UAAU,CAAC;IAC/B,EAAE,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC;IACxC,EAAE,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC;IACxC,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC;IAC1C,EAAE,EAAE,CAAC,aAAa,EAAE,UAAU,CAAC;CAChC,CAAC;AAEF,MAAM,IAAI,GACR,iEAAiE;IACjE,wDAAwD;IACxD,kEAAkE;IAClE,8DAA8D;IAC9D,6CAA6C,CAAC;AAEhD,eAAe,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC"}
|
@@ -1,9 +1,9 @@
|
|
1
|
+
import 'air-datepicker/air-datepicker.css';
|
1
2
|
import { Lang, Plugin } from '@pdfme/common';
|
2
3
|
import { DateSchema } from './types';
|
3
|
-
export declare const getPlugin: ({ type, defaultFormat, icon,
|
4
|
+
export declare const getPlugin: ({ type, defaultFormat, icon, formatsByLang, }: {
|
4
5
|
type: 'date' | 'time' | 'dateTime';
|
5
6
|
defaultFormat: string;
|
6
7
|
icon: string;
|
7
|
-
inputType: string;
|
8
8
|
formatsByLang: Record<Lang, string[]>;
|
9
9
|
}) => Plugin<DateSchema>;
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import { Schema } from '@pdfme/common';
|
2
|
-
import { ALIGNMENT
|
2
|
+
import { ALIGNMENT } from '../text/types';
|
3
3
|
export interface DateSchema extends Schema {
|
4
4
|
format: string;
|
5
5
|
fontName?: string;
|
6
6
|
alignment: ALIGNMENT;
|
7
|
-
verticalAlignment: VERTICAL_ALIGNMENT;
|
8
7
|
fontSize: number;
|
9
8
|
characterSpacing: number;
|
10
9
|
fontColor: string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/schemas",
|
3
|
-
"version": "5.1.
|
3
|
+
"version": "5.1.2",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -49,6 +49,7 @@
|
|
49
49
|
},
|
50
50
|
"dependencies": {
|
51
51
|
"@pdfme/pdf-lib": "^1.18.3",
|
52
|
+
"air-datepicker": "^3.5.3",
|
52
53
|
"bwip-js": "^4.1.1",
|
53
54
|
"date-fns": "^4.1.0",
|
54
55
|
"fast-xml-parser": "^4.3.2",
|
package/src/date/date.ts
CHANGED
@@ -3,8 +3,6 @@ import { getPlugin } from './helper';
|
|
3
3
|
|
4
4
|
const type = 'date';
|
5
5
|
|
6
|
-
const inputType = 'date';
|
7
|
-
|
8
6
|
const defaultFormat = 'yyyy/MM/dd';
|
9
7
|
|
10
8
|
const formatsByLang: Record<Lang, string[]> = {
|
@@ -57,4 +55,4 @@ const icon =
|
|
57
55
|
'<rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>' +
|
58
56
|
'</svg>';
|
59
57
|
|
60
|
-
export default getPlugin({ type, defaultFormat, icon,
|
58
|
+
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
package/src/date/dateTime.ts
CHANGED
@@ -3,8 +3,6 @@ import { getPlugin } from './helper';
|
|
3
3
|
|
4
4
|
const type = 'dateTime';
|
5
5
|
|
6
|
-
const inputType = 'datetime-local';
|
7
|
-
|
8
6
|
const defaultFormat = 'yyyy/MM/dd HH:mm';
|
9
7
|
|
10
8
|
const formatsByLang: Record<Lang, string[]> = {
|
@@ -99,4 +97,4 @@ const formatsByLang: Record<Lang, string[]> = {
|
|
99
97
|
const icon =
|
100
98
|
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock"><path d="M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"/><path d="M16 2v4"/><path d="M8 2v4"/><path d="M3 10h5"/><path d="M17.5 17.5 16 16.3V14"/><circle cx="16" cy="16" r="6"/></svg>';
|
101
99
|
|
102
|
-
export default getPlugin({ type, defaultFormat, icon,
|
100
|
+
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
package/src/date/helper.ts
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
import type * as CSS from 'csstype';
|
2
|
+
import AirDatepicker, { AirDatepickerLocale } from 'air-datepicker';
|
3
|
+
import localeEn from 'air-datepicker/locale/en';
|
4
|
+
import localeZh from 'air-datepicker/locale/zh';
|
5
|
+
import localeJa from 'air-datepicker/locale/ja';
|
6
|
+
import localeKo from 'air-datepicker/locale/ko';
|
7
|
+
import localeAr from 'air-datepicker/locale/ar';
|
8
|
+
import localeTh from 'air-datepicker/locale/th';
|
9
|
+
import localePl from 'air-datepicker/locale/pl';
|
10
|
+
import localeIt from 'air-datepicker/locale/it';
|
11
|
+
import localeDe from 'air-datepicker/locale/de';
|
12
|
+
import localeEs from 'air-datepicker/locale/es';
|
13
|
+
import localeFr from 'air-datepicker/locale/fr';
|
14
|
+
import 'air-datepicker/air-datepicker.css';
|
2
15
|
import { format } from 'date-fns';
|
3
|
-
import { zhCN, ja, ko, ar, th, pl, it, de, es, fr, Locale } from 'date-fns/locale';
|
16
|
+
import { enUS, zhCN, ja, ko, ar, th, pl, it, de, es, fr, Locale } from 'date-fns/locale';
|
4
17
|
import {
|
5
18
|
Lang,
|
6
19
|
Plugin,
|
@@ -16,34 +29,50 @@ import { getFontKitFont, getBrowserVerticalFontAdjustments } from '../text/helpe
|
|
16
29
|
import {
|
17
30
|
DEFAULT_FONT_SIZE,
|
18
31
|
DEFAULT_ALIGNMENT,
|
19
|
-
|
32
|
+
VERTICAL_ALIGN_MIDDLE,
|
20
33
|
DEFAULT_LINE_HEIGHT,
|
21
34
|
DEFAULT_CHARACTER_SPACING,
|
22
35
|
DEFAULT_FONT_COLOR,
|
23
36
|
} from '../text/constants.js';
|
24
37
|
import { DateSchema } from './types';
|
25
38
|
import { getExtraFormatterSchema, Formatter } from '../text/extraFormatter';
|
39
|
+
import { isEditable } from '../utils';
|
26
40
|
|
27
|
-
const
|
28
|
-
({ en:
|
41
|
+
const getDateFnsLocale = (lang: Lang): Locale | undefined =>
|
42
|
+
({ en: enUS, zh: zhCN, ja, ko, ar, th, pl, it, de, es, fr }[lang]);
|
43
|
+
|
44
|
+
const getAirDatepickerLocale = (lang: Lang): AirDatepickerLocale | undefined =>
|
45
|
+
({
|
46
|
+
en: localeEn,
|
47
|
+
zh: localeZh,
|
48
|
+
ja: localeJa,
|
49
|
+
ko: localeKo,
|
50
|
+
ar: localeAr,
|
51
|
+
th: localeTh,
|
52
|
+
pl: localePl,
|
53
|
+
it: localeIt,
|
54
|
+
de: localeDe,
|
55
|
+
es: localeEs,
|
56
|
+
fr: localeFr,
|
57
|
+
}[lang]);
|
29
58
|
|
30
59
|
export const getPlugin = ({
|
31
60
|
type,
|
32
61
|
defaultFormat,
|
33
62
|
icon,
|
34
|
-
inputType,
|
35
63
|
formatsByLang,
|
36
64
|
}: {
|
37
65
|
type: 'date' | 'time' | 'dateTime';
|
38
66
|
defaultFormat: string;
|
39
67
|
icon: string;
|
40
|
-
inputType: string;
|
41
68
|
formatsByLang: Record<Lang, string[]>;
|
42
69
|
}) => {
|
43
70
|
const plugin: Plugin<DateSchema> = {
|
44
71
|
ui: async (arg) => {
|
45
|
-
const { schema, value, onChange, rootElement, mode, options, _cache } = arg;
|
46
|
-
|
72
|
+
const { schema, value, onChange, rootElement, mode, options, i18n, _cache } = arg;
|
73
|
+
|
74
|
+
const beforeRemoveEvent = new Event('beforeRemove');
|
75
|
+
rootElement.dispatchEvent(beforeRemoveEvent);
|
47
76
|
|
48
77
|
const font = options?.font || getDefaultFont();
|
49
78
|
const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
|
@@ -52,7 +81,7 @@ export const getPlugin = ({
|
|
52
81
|
fontKitFont,
|
53
82
|
schema.fontSize ?? DEFAULT_FONT_SIZE,
|
54
83
|
DEFAULT_LINE_HEIGHT,
|
55
|
-
|
84
|
+
VERTICAL_ALIGN_MIDDLE
|
56
85
|
);
|
57
86
|
|
58
87
|
const topAdjustment = topAdj.toString();
|
@@ -66,95 +95,86 @@ export const getPlugin = ({
|
|
66
95
|
backgroundColor: getBackgroundColor(value, schema),
|
67
96
|
|
68
97
|
margin: '0',
|
98
|
+
padding: '0',
|
99
|
+
border: 'none',
|
100
|
+
outline: 'none',
|
69
101
|
width: `${schema.width}mm`,
|
70
102
|
height: `${schema.height}mm`,
|
71
103
|
display: 'flex',
|
72
104
|
flexDirection: 'column',
|
73
|
-
justifyContent: mapVerticalAlignToFlex(
|
105
|
+
justifyContent: mapVerticalAlignToFlex(VERTICAL_ALIGN_MIDDLE),
|
74
106
|
paddingTop: `${topAdjustment}px`,
|
75
107
|
marginBottom: `${bottomAdjustment}px`,
|
76
108
|
position: 'relative',
|
77
109
|
};
|
78
110
|
|
79
|
-
const
|
80
|
-
Object.assign(textElement.style, textStyle);
|
81
|
-
rootElement.appendChild(textElement);
|
82
|
-
|
83
|
-
textElement.textContent = value
|
84
|
-
? format(
|
85
|
-
type === 'time' ? new Date(`2021-01-01T${value}`) : new Date(value),
|
86
|
-
schema.format,
|
87
|
-
{ locale: getLocale(options?.lang || 'en') }
|
88
|
-
)
|
89
|
-
: '';
|
90
|
-
|
91
|
-
if (mode !== 'viewer' && !(mode === 'form' && schema.readOnly)) {
|
92
|
-
const dateTimeInput = document.createElement('input');
|
93
|
-
dateTimeInput.type = inputType;
|
94
|
-
dateTimeInput.value = value;
|
95
|
-
|
96
|
-
const dateTimeInputStyle: CSS.Properties = {
|
97
|
-
...textStyle,
|
98
|
-
opacity: '0',
|
99
|
-
position: 'absolute',
|
100
|
-
top: '0',
|
101
|
-
left: '0',
|
102
|
-
border: 'none',
|
103
|
-
zIndex: '-1',
|
104
|
-
};
|
111
|
+
const input = document.createElement('input');
|
105
112
|
|
106
|
-
|
107
|
-
rootElement.appendChild(dateTimeInput);
|
113
|
+
Object.assign(input.style, textStyle);
|
108
114
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
115
|
+
const commitChange = ({ datepicker }: { datepicker: AirDatepicker<HTMLInputElement> }) => {
|
116
|
+
if (onChange) {
|
117
|
+
const date = datepicker.selectedDates;
|
118
|
+
const fmt =
|
119
|
+
type === 'time' ? 'HH:mm' : type === 'date' ? 'yyyy/MM/dd' : 'yyyy/MM/dd HH:mm';
|
120
|
+
const d = Array.isArray(date) ? date[0] : date || '';
|
121
|
+
const value = d ? format(d, fmt) : '';
|
122
|
+
onChange({ key: 'content', value });
|
123
|
+
}
|
124
|
+
};
|
116
125
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
126
|
+
const airDatepicker = new AirDatepicker(input, {
|
127
|
+
locale: getAirDatepickerLocale(options.lang || 'en'),
|
128
|
+
selectedDates: [schema.type === 'time' ? new Date(`2021-01-01T${value}`) : new Date(value)],
|
129
|
+
dateFormat: (date) => (schema.format ? format(date, schema.format) : ''),
|
130
|
+
timepicker: type !== 'date',
|
131
|
+
onlyTimepicker: type === 'time',
|
132
|
+
buttons: [
|
133
|
+
'clear',
|
134
|
+
{
|
135
|
+
content: i18n('close'),
|
136
|
+
onClick: (datepicker) => {
|
137
|
+
datepicker.hide();
|
138
|
+
commitChange({ datepicker });
|
139
|
+
},
|
140
|
+
},
|
141
|
+
],
|
142
|
+
onSelect: ({ datepicker }) => {
|
143
|
+
mode !== 'designer' && commitChange({ datepicker });
|
144
|
+
},
|
145
|
+
onShow: () => {
|
146
|
+
input.disabled = !isEditable(mode, schema);
|
147
|
+
},
|
148
|
+
});
|
122
149
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
150
|
+
rootElement.addEventListener('beforeRemove', () => {
|
151
|
+
if (mode === 'designer') {
|
152
|
+
airDatepicker.destroy();
|
153
|
+
}
|
154
|
+
});
|
155
|
+
input.addEventListener('click', () => {
|
156
|
+
if (mode === 'designer') {
|
157
|
+
airDatepicker.show();
|
158
|
+
}
|
159
|
+
});
|
128
160
|
|
129
|
-
|
130
|
-
removeButton.textContent = 'x';
|
131
|
-
const buttonWidth = 30;
|
132
|
-
const removeButtonStyle: CSS.Properties = {
|
133
|
-
position: 'absolute',
|
134
|
-
top: '0px',
|
135
|
-
right: `-${buttonWidth}px`,
|
136
|
-
padding: '5px',
|
137
|
-
width: `${buttonWidth}px`,
|
138
|
-
height: `${buttonWidth}px`,
|
139
|
-
};
|
140
|
-
Object.assign(removeButton.style, removeButtonStyle);
|
141
|
-
removeButton.addEventListener('click', () => {
|
142
|
-
onChange && onChange({ key: 'content', value: '' });
|
143
|
-
});
|
144
|
-
rootElement.appendChild(removeButton);
|
145
|
-
}
|
161
|
+
rootElement.appendChild(input);
|
146
162
|
},
|
147
163
|
pdf: (arg) => {
|
148
164
|
const { schema, value, options } = arg;
|
149
165
|
if (!value) return void 0;
|
150
|
-
const lang = (options.
|
151
|
-
const locale =
|
166
|
+
const lang = (options.lang || 'en') as Lang;
|
167
|
+
const locale = getDateFnsLocale(lang);
|
152
168
|
const date = schema.type === 'time' ? new Date(`2021-01-01T${value}`) : new Date(value);
|
153
169
|
const formattedValue = format(date, schema.format, { locale });
|
154
170
|
return text.pdf(
|
155
171
|
Object.assign(arg, {
|
156
172
|
value: formattedValue,
|
157
|
-
schema: {
|
173
|
+
schema: {
|
174
|
+
...schema,
|
175
|
+
verticalAlignment: VERTICAL_ALIGN_MIDDLE,
|
176
|
+
lineHeight: DEFAULT_LINE_HEIGHT,
|
177
|
+
},
|
158
178
|
})
|
159
179
|
);
|
160
180
|
},
|
@@ -162,14 +182,14 @@ export const getPlugin = ({
|
|
162
182
|
schema: ({ options, i18n }) => {
|
163
183
|
const font = options.font || { [DEFAULT_FONT_NAME]: { data: '', fallback: true } };
|
164
184
|
const lang = options.lang || 'en';
|
165
|
-
const locale =
|
185
|
+
const locale = getDateFnsLocale(lang);
|
166
186
|
|
167
187
|
const fontNames = Object.keys(font);
|
168
188
|
const fallbackFontName = getFallbackFontName(font);
|
169
189
|
|
170
190
|
const formatter = getExtraFormatterSchema(i18n);
|
171
191
|
formatter.buttons = formatter.buttons.filter(
|
172
|
-
(button) => button.key
|
192
|
+
(button) => button.key === Formatter.ALIGNMENT
|
173
193
|
);
|
174
194
|
|
175
195
|
const currentDate = new Date();
|
@@ -246,7 +266,6 @@ export const getPlugin = ({
|
|
246
266
|
height: 10,
|
247
267
|
rotate: 0,
|
248
268
|
alignment: DEFAULT_ALIGNMENT,
|
249
|
-
verticalAlignment: DEFAULT_VERTICAL_ALIGNMENT,
|
250
269
|
fontSize: DEFAULT_FONT_SIZE,
|
251
270
|
characterSpacing: DEFAULT_CHARACTER_SPACING,
|
252
271
|
fontColor: DEFAULT_FONT_COLOR,
|
package/src/date/time.ts
CHANGED
@@ -3,8 +3,6 @@ import { getPlugin } from './helper';
|
|
3
3
|
|
4
4
|
const type = 'time';
|
5
5
|
|
6
|
-
const inputType = 'time';
|
7
|
-
|
8
6
|
const defaultFormat = 'HH:mm';
|
9
7
|
|
10
8
|
const formatsByLang: Record<Lang, string[]> = {
|
@@ -28,4 +26,4 @@ const icon =
|
|
28
26
|
'class="lucide lucide-clock"><circle cx="12" cy="12" r="10"/>' +
|
29
27
|
'<polyline points="12 6 12 12 16 14"/></svg>';
|
30
28
|
|
31
|
-
export default getPlugin({ type, defaultFormat, icon,
|
29
|
+
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
package/src/date/types.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import { Schema } from '@pdfme/common';
|
2
|
-
import { ALIGNMENT
|
2
|
+
import { ALIGNMENT } from '../text/types';
|
3
3
|
|
4
4
|
export interface DateSchema extends Schema {
|
5
5
|
format: string;
|
6
6
|
fontName?: string;
|
7
7
|
alignment: ALIGNMENT;
|
8
|
-
verticalAlignment: VERTICAL_ALIGNMENT;
|
9
8
|
fontSize: number;
|
10
9
|
characterSpacing: number;
|
11
10
|
fontColor: string;
|