@pdfme/schemas 6.0.3 → 6.0.4-dev.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.
- package/dist/barcodes/constants.d.ts +4 -0
- package/dist/barcodes/helper.d.ts +21 -0
- package/dist/barcodes/index.d.ts +4 -0
- package/dist/barcodes/pdfRender.d.ts +3 -0
- package/dist/barcodes/propPanel.d.ts +3 -0
- package/{src/barcodes/types.ts → dist/barcodes/types.d.ts} +5 -7
- package/dist/barcodes/uiRender.d.ts +3 -0
- package/dist/builtins-CgaZ0UX3.js +613 -0
- package/dist/builtins-CgaZ0UX3.js.map +1 -0
- package/dist/builtins.d.ts +4 -0
- package/dist/builtins.js +2 -0
- package/dist/checkbox/index.d.ts +6 -0
- package/dist/constants.d.ts +2 -0
- package/dist/date/date.d.ts +2 -0
- package/dist/date/dateTime.d.ts +2 -0
- package/dist/date/helper.d.ts +20 -0
- package/dist/date/time.d.ts +2 -0
- package/dist/date/types.d.ts +17 -0
- package/dist/dynamicTemplate-D_DHR3-X.js +1128 -0
- package/dist/dynamicTemplate-D_DHR3-X.js.map +1 -0
- package/dist/graphics/image.d.ts +5 -0
- package/dist/graphics/imagehelper.d.ts +4 -0
- package/dist/graphics/signature.d.ts +4 -0
- package/dist/graphics/svg.d.ts +4 -0
- package/{src/index.ts → dist/index.d.ts} +1 -22
- package/dist/index.js +5383 -0
- package/dist/index.js.map +1 -0
- package/dist/multiVariableText/helper.d.ts +3 -0
- package/dist/multiVariableText/index.d.ts +4 -0
- package/dist/multiVariableText/pdfRender.d.ts +3 -0
- package/dist/multiVariableText/propPanel.d.ts +3 -0
- package/{src/multiVariableText/types.ts → dist/multiVariableText/types.d.ts} +2 -3
- package/dist/multiVariableText/uiRender.d.ts +3 -0
- package/dist/multiVariableText/variables.d.ts +10 -0
- package/dist/radioGroup/index.d.ts +7 -0
- package/dist/sanitize.d.ts +1 -0
- package/dist/select/index.d.ts +7 -0
- package/dist/shapes/line.d.ts +6 -0
- package/dist/shapes/rectAndEllipse.d.ts +11 -0
- package/dist/tables/cell.d.ts +4 -0
- package/dist/tables/classes.d.ts +69 -0
- package/dist/tables/dynamicTemplate.d.ts +7 -0
- package/dist/tables/helper.d.ts +265 -0
- package/dist/tables/index.d.ts +4 -0
- package/dist/tables/pdfRender.d.ts +3 -0
- package/dist/tables/propPanel.d.ts +3 -0
- package/dist/tables/tableHelper.d.ts +10 -0
- package/dist/tables/types.d.ts +88 -0
- package/dist/tables/uiRender.d.ts +3 -0
- package/dist/tables.js +2 -0
- package/dist/text/constants.d.ts +23 -0
- package/dist/text/extraFormatter.d.ts +25 -0
- package/dist/text/helper.d.ts +40 -0
- package/dist/text/icons/index.d.ts +9 -0
- package/dist/text/index.d.ts +4 -0
- package/dist/text/pdfRender.d.ts +3 -0
- package/dist/text/propPanel.d.ts +3 -0
- package/dist/text/types.d.ts +28 -0
- package/dist/text/uiRender.d.ts +11 -0
- package/dist/utils.d.ts +40 -0
- package/dist/utils.js +215 -0
- package/dist/utils.js.map +1 -0
- package/package.json +5 -1
- package/src/barcodes/constants.ts +0 -20
- package/src/barcodes/helper.ts +0 -187
- package/src/barcodes/index.ts +0 -23
- package/src/barcodes/pdfRender.ts +0 -37
- package/src/barcodes/propPanel.ts +0 -249
- package/src/barcodes/uiRender.ts +0 -94
- package/src/builtins.ts +0 -8
- package/src/checkbox/index.ts +0 -70
- package/src/constants.ts +0 -2
- package/src/date/date.ts +0 -9
- package/src/date/dateTime.ts +0 -9
- package/src/date/helper.ts +0 -544
- package/src/date/time.ts +0 -9
- package/src/date/types.ts +0 -19
- package/src/graphics/image.ts +0 -201
- package/src/graphics/imagehelper.ts +0 -156
- package/src/graphics/signature.ts +0 -136
- package/src/graphics/svg.ts +0 -121
- package/src/multiVariableText/helper.ts +0 -65
- package/src/multiVariableText/index.ts +0 -16
- package/src/multiVariableText/pdfRender.ts +0 -21
- package/src/multiVariableText/propPanel.ts +0 -169
- package/src/multiVariableText/uiRender.ts +0 -157
- package/src/multiVariableText/variables.ts +0 -63
- package/src/radioGroup/index.ts +0 -115
- package/src/sanitize.ts +0 -50
- package/src/select/index.ts +0 -205
- package/src/shapes/line.ts +0 -94
- package/src/shapes/rectAndEllipse.ts +0 -152
- package/src/tables/cell.ts +0 -152
- package/src/tables/classes.ts +0 -402
- package/src/tables/dynamicTemplate.ts +0 -88
- package/src/tables/helper.ts +0 -216
- package/src/tables/index.ts +0 -15
- package/src/tables/pdfRender.ts +0 -144
- package/src/tables/propPanel.ts +0 -111
- package/src/tables/tableHelper.ts +0 -289
- package/src/tables/types.ts +0 -87
- package/src/tables/uiRender.ts +0 -436
- package/src/text/constants.ts +0 -104
- package/src/text/extraFormatter.ts +0 -83
- package/src/text/helper.ts +0 -573
- package/src/text/icons/index.ts +0 -30
- package/src/text/index.ts +0 -16
- package/src/text/pdfRender.ts +0 -240
- package/src/text/propPanel.ts +0 -184
- package/src/text/types.ts +0 -30
- package/src/text/uiRender.ts +0 -292
- package/src/utils.ts +0 -354
- package/tsconfig.build.json +0 -14
- package/tsconfig.json +0 -16
- package/vite.config.mts +0 -51
- /package/{src/tables.ts → dist/tables.d.ts} +0 -0
package/src/date/helper.ts
DELETED
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
import type * as CSS from 'csstype';
|
|
2
|
-
|
|
3
|
-
import AirDatepicker from 'air-datepicker';
|
|
4
|
-
import type { AirDatepickerLocale, AirDatepickerButton, AirDatepickerDate } from 'air-datepicker';
|
|
5
|
-
import localeAr from 'air-datepicker/locale/ar';
|
|
6
|
-
import localeBg from 'air-datepicker/locale/bg';
|
|
7
|
-
import localeCa from 'air-datepicker/locale/ca';
|
|
8
|
-
import localeCs from 'air-datepicker/locale/cs';
|
|
9
|
-
import localeDa from 'air-datepicker/locale/da';
|
|
10
|
-
import localeDe from 'air-datepicker/locale/de';
|
|
11
|
-
import localeEl from 'air-datepicker/locale/el';
|
|
12
|
-
import localeEn from 'air-datepicker/locale/en';
|
|
13
|
-
import localeEs from 'air-datepicker/locale/es';
|
|
14
|
-
import localeEu from 'air-datepicker/locale/eu';
|
|
15
|
-
import localeFi from 'air-datepicker/locale/fi';
|
|
16
|
-
import localeFr from 'air-datepicker/locale/fr';
|
|
17
|
-
import localeHr from 'air-datepicker/locale/hr';
|
|
18
|
-
import localeHu from 'air-datepicker/locale/hu';
|
|
19
|
-
import localeId from 'air-datepicker/locale/id';
|
|
20
|
-
import localeIt from 'air-datepicker/locale/it';
|
|
21
|
-
import localeJa from 'air-datepicker/locale/ja';
|
|
22
|
-
import localeKo from 'air-datepicker/locale/ko';
|
|
23
|
-
import localeNb from 'air-datepicker/locale/nb';
|
|
24
|
-
import localeNl from 'air-datepicker/locale/nl';
|
|
25
|
-
import localeTh from 'air-datepicker/locale/th';
|
|
26
|
-
import localePl from 'air-datepicker/locale/pl';
|
|
27
|
-
import localePtBR from 'air-datepicker/locale/pt-BR';
|
|
28
|
-
import localePt from 'air-datepicker/locale/pt';
|
|
29
|
-
import localeRo from 'air-datepicker/locale/ro';
|
|
30
|
-
import localeRu from 'air-datepicker/locale/ru';
|
|
31
|
-
import localeSi from 'air-datepicker/locale/si';
|
|
32
|
-
import localeSk from 'air-datepicker/locale/sk';
|
|
33
|
-
import localeSl from 'air-datepicker/locale/sl';
|
|
34
|
-
import localeSv from 'air-datepicker/locale/sv';
|
|
35
|
-
import localeTr from 'air-datepicker/locale/tr';
|
|
36
|
-
import localeUk from 'air-datepicker/locale/uk';
|
|
37
|
-
import localeZh from 'air-datepicker/locale/zh';
|
|
38
|
-
|
|
39
|
-
import * as dateFns from 'date-fns/locale';
|
|
40
|
-
import { format } from 'date-fns';
|
|
41
|
-
|
|
42
|
-
import { Plugin, getFallbackFontName, DEFAULT_FONT_NAME, PropPanelSchema } from '@pdfme/common';
|
|
43
|
-
import text from '../text/index.js';
|
|
44
|
-
import { DEFAULT_OPACITY, HEX_COLOR_PATTERN } from '../constants.js';
|
|
45
|
-
import { mapVerticalAlignToFlex } from '../text/uiRender.js';
|
|
46
|
-
import {
|
|
47
|
-
DEFAULT_FONT_SIZE,
|
|
48
|
-
DEFAULT_ALIGNMENT,
|
|
49
|
-
VERTICAL_ALIGN_MIDDLE,
|
|
50
|
-
DEFAULT_LINE_HEIGHT,
|
|
51
|
-
DEFAULT_CHARACTER_SPACING,
|
|
52
|
-
DEFAULT_FONT_COLOR,
|
|
53
|
-
} from '../text/constants.js';
|
|
54
|
-
import { DateSchema } from './types.js';
|
|
55
|
-
import { getExtraFormatterSchema, Formatter } from '../text/extraFormatter.js';
|
|
56
|
-
import { isEditable } from '../utils.js';
|
|
57
|
-
|
|
58
|
-
interface AirDatepickerInstance {
|
|
59
|
-
selectedDates: Date[];
|
|
60
|
-
hide: () => void;
|
|
61
|
-
destroy: () => void;
|
|
62
|
-
show: () => void;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
type PickerType = 'date' | 'time' | 'dateTime';
|
|
66
|
-
|
|
67
|
-
interface Locale {
|
|
68
|
-
label: string;
|
|
69
|
-
adLocale: AirDatepickerLocale;
|
|
70
|
-
formatLocale: dateFns.Locale;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const normalizeAdLocale = (
|
|
74
|
-
locale: AirDatepickerLocale | { default: AirDatepickerLocale },
|
|
75
|
-
): AirDatepickerLocale => {
|
|
76
|
-
// Air Datepicker locales can arrive as either the locale object itself or as an
|
|
77
|
-
// ESM default export shim when bundlers interop with the package's CJS build.
|
|
78
|
-
return 'default' in locale ? locale.default : locale;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const LOCALE_MAP: Record<string, Locale> = {
|
|
82
|
-
ar: { label: 'Arabic', adLocale: normalizeAdLocale(localeAr), formatLocale: dateFns.ar },
|
|
83
|
-
bg: { label: 'Bulgarian', adLocale: normalizeAdLocale(localeBg), formatLocale: dateFns.bg },
|
|
84
|
-
ca: { label: 'Catalan', adLocale: normalizeAdLocale(localeCa), formatLocale: dateFns.ca },
|
|
85
|
-
cs: { label: 'Czech', adLocale: normalizeAdLocale(localeCs), formatLocale: dateFns.cs },
|
|
86
|
-
da: { label: 'Danish', adLocale: normalizeAdLocale(localeDa), formatLocale: dateFns.da },
|
|
87
|
-
de: { label: 'German', adLocale: normalizeAdLocale(localeDe), formatLocale: dateFns.de },
|
|
88
|
-
el: { label: 'Greek', adLocale: normalizeAdLocale(localeEl), formatLocale: dateFns.el },
|
|
89
|
-
en: { label: 'English', adLocale: normalizeAdLocale(localeEn), formatLocale: dateFns.enUS },
|
|
90
|
-
es: { label: 'Spanish', adLocale: normalizeAdLocale(localeEs), formatLocale: dateFns.es },
|
|
91
|
-
eu: { label: 'Basque', adLocale: normalizeAdLocale(localeEu), formatLocale: dateFns.eu },
|
|
92
|
-
fi: { label: 'Finnish', adLocale: normalizeAdLocale(localeFi), formatLocale: dateFns.fi },
|
|
93
|
-
fr: { label: 'French', adLocale: normalizeAdLocale(localeFr), formatLocale: dateFns.fr },
|
|
94
|
-
hr: { label: 'Croatian', adLocale: normalizeAdLocale(localeHr), formatLocale: dateFns.hr },
|
|
95
|
-
hu: { label: 'Hungarian', adLocale: normalizeAdLocale(localeHu), formatLocale: dateFns.hu },
|
|
96
|
-
id: { label: 'Indonesian', adLocale: normalizeAdLocale(localeId), formatLocale: dateFns.id },
|
|
97
|
-
it: { label: 'Italian', adLocale: normalizeAdLocale(localeIt), formatLocale: dateFns.it },
|
|
98
|
-
ja: { label: 'Japanese', adLocale: normalizeAdLocale(localeJa), formatLocale: dateFns.ja },
|
|
99
|
-
ko: { label: 'Korean', adLocale: normalizeAdLocale(localeKo), formatLocale: dateFns.ko },
|
|
100
|
-
nb: { label: 'Norwegian Bokmål', adLocale: normalizeAdLocale(localeNb), formatLocale: dateFns.nb },
|
|
101
|
-
nl: { label: 'Dutch', adLocale: normalizeAdLocale(localeNl), formatLocale: dateFns.nl },
|
|
102
|
-
pl: { label: 'Polish', adLocale: normalizeAdLocale(localePl), formatLocale: dateFns.pl },
|
|
103
|
-
'pt-Br': {
|
|
104
|
-
label: 'Portuguese',
|
|
105
|
-
adLocale: normalizeAdLocale(localePtBR),
|
|
106
|
-
formatLocale: dateFns.ptBR,
|
|
107
|
-
},
|
|
108
|
-
pt: { label: 'Portuguese', adLocale: normalizeAdLocale(localePt), formatLocale: dateFns.pt },
|
|
109
|
-
ro: { label: 'Romanian', adLocale: normalizeAdLocale(localeRo), formatLocale: dateFns.ro },
|
|
110
|
-
ru: { label: 'Russian', adLocale: normalizeAdLocale(localeRu), formatLocale: dateFns.ru },
|
|
111
|
-
si: { label: 'Sinhala', adLocale: normalizeAdLocale(localeSi), formatLocale: dateFns.enUS },
|
|
112
|
-
sk: { label: 'Slovak', adLocale: normalizeAdLocale(localeSk), formatLocale: dateFns.sk },
|
|
113
|
-
sl: { label: 'Slovenian', adLocale: normalizeAdLocale(localeSl), formatLocale: dateFns.sl },
|
|
114
|
-
sv: { label: 'Swedish', adLocale: normalizeAdLocale(localeSv), formatLocale: dateFns.sv },
|
|
115
|
-
th: { label: 'Thai', adLocale: normalizeAdLocale(localeTh), formatLocale: dateFns.th },
|
|
116
|
-
tr: { label: 'Turkish', adLocale: normalizeAdLocale(localeTr), formatLocale: dateFns.tr },
|
|
117
|
-
uk: { label: 'Ukrainian', adLocale: normalizeAdLocale(localeUk), formatLocale: dateFns.uk },
|
|
118
|
-
zh: { label: 'Chinese', adLocale: normalizeAdLocale(localeZh), formatLocale: dateFns.zhCN },
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const getAirDatepickerLocale = (locale: string) => {
|
|
122
|
-
const data = LOCALE_MAP[locale];
|
|
123
|
-
if (!data) {
|
|
124
|
-
throw new Error(`Unsupported locale: ${locale}`);
|
|
125
|
-
}
|
|
126
|
-
return data;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const airDatepickerCss = `.air-datepicker-cell.-year-.-other-decade-,.air-datepicker-cell.-day-.-other-month-{color:var(--adp-color-other-month)}.air-datepicker-cell.-year-.-other-decade-:hover,.air-datepicker-cell.-day-.-other-month-:hover{color:var(--adp-color-other-month-hover)}.-disabled-.-focus-.air-datepicker-cell.-year-.-other-decade-,.-disabled-.-focus-.air-datepicker-cell.-day-.-other-month-{color:var(--adp-color-other-month)}.-selected-.air-datepicker-cell.-year-.-other-decade-,.-selected-.air-datepicker-cell.-day-.-other-month-{color:#fff;background:var(--adp-background-color-selected-other-month)}.-selected-.-focus-.air-datepicker-cell.-year-.-other-decade-,.-selected-.-focus-.air-datepicker-cell.-day-.-other-month-{background:var(--adp-background-color-selected-other-month-focused)}.-in-range-.air-datepicker-cell.-year-.-other-decade-,.-in-range-.air-datepicker-cell.-day-.-other-month-{background-color:var(--adp-background-color-in-range);color:var(--adp-color)}.-in-range-.-focus-.air-datepicker-cell.-year-.-other-decade-,.-in-range-.-focus-.air-datepicker-cell.-day-.-other-month-{background-color:var(--adp-background-color-in-range-focused)}.air-datepicker-cell.-year-.-other-decade-:empty,.air-datepicker-cell.-day-.-other-month-:empty{background:none;border:none}.air-datepicker-cell{border-radius:var(--adp-cell-border-radius);box-sizing:border-box;cursor:pointer;display:flex;position:relative;align-items:center;justify-content:center;z-index:1}.air-datepicker-cell.-focus-{background:var(--adp-cell-background-color-hover)}.air-datepicker-cell.-current-{color:var(--adp-color-current-date)}.air-datepicker-cell.-current-.-focus-{color:var(--adp-color)}.air-datepicker-cell.-current-.-in-range-{color:var(--adp-color-current-date)}.air-datepicker-cell.-disabled-{cursor:default;color:var(--adp-color-disabled)}.air-datepicker-cell.-disabled-.-focus-{color:var(--adp-color-disabled)}.air-datepicker-cell.-disabled-.-in-range-{color:var(--adp-color-disabled-in-range)}.air-datepicker-cell.-disabled-.-current-.-focus-{color:var(--adp-color-disabled)}.air-datepicker-cell.-in-range-{background:var(--adp-cell-background-color-in-range);border-radius:0}.air-datepicker-cell.-in-range-:hover,.air-datepicker-cell.-in-range-.-focus-{background:var(--adp-cell-background-color-in-range-hover)}.air-datepicker-cell.-range-from-{border:1px solid var(--adp-cell-border-color-in-range);background-color:var(--adp-cell-background-color-in-range);border-radius:var(--adp-cell-border-radius) 0 0 var(--adp-cell-border-radius)}.air-datepicker-cell.-range-to-{border:1px solid var(--adp-cell-border-color-in-range);background-color:var(--adp-cell-background-color-in-range);border-radius:0 var(--adp-cell-border-radius) var(--adp-cell-border-radius) 0}.air-datepicker-cell.-range-to-.-range-from-{border-radius:var(--adp-cell-border-radius)}.air-datepicker-cell.-selected-{color:#fff;border:none;background:var(--adp-cell-background-color-selected)}.air-datepicker-cell.-selected-.-current-{color:#fff;background:var(--adp-cell-background-color-selected)}.air-datepicker-cell.-selected-.-focus-{background:var(--adp-cell-background-color-selected-hover)}
|
|
130
|
-
.air-datepicker-body{transition:all var(--adp-transition-duration) var(--adp-transition-ease)}.air-datepicker-body.-hidden-{display:none}.air-datepicker-body--day-names{display:grid;grid-template-columns:repeat(7, var(--adp-day-cell-width));margin:8px 0 3px}.air-datepicker-body--day-name{color:var(--adp-day-name-color);display:flex;align-items:center;justify-content:center;flex:1;text-align:center;text-transform:uppercase;font-size:.8em}.air-datepicker-body--day-name.-clickable-{cursor:pointer}.air-datepicker-body--day-name.-clickable-:hover{color:var(--adp-day-name-color-hover)}.air-datepicker-body--cells{display:grid}.air-datepicker-body--cells.-days-{grid-template-columns:repeat(7, var(--adp-day-cell-width));grid-auto-rows:var(--adp-day-cell-height)}.air-datepicker-body--cells.-months-{grid-template-columns:repeat(3, 1fr);grid-auto-rows:var(--adp-month-cell-height)}.air-datepicker-body--cells.-years-{grid-template-columns:repeat(4, 1fr);grid-auto-rows:var(--adp-year-cell-height)}
|
|
131
|
-
.air-datepicker-nav{display:flex;justify-content:space-between;border-bottom:1px solid var(--adp-border-color-inner);min-height:var(--adp-nav-height);padding:var(--adp-padding);box-sizing:content-box}.-only-timepicker- .air-datepicker-nav{display:none}.air-datepicker-nav--title,.air-datepicker-nav--action{display:flex;cursor:pointer;align-items:center;justify-content:center}.air-datepicker-nav--action{width:var(--adp-nav-action-size);border-radius:var(--adp-border-radius);-webkit-user-select:none;-moz-user-select:none;user-select:none}.air-datepicker-nav--action:hover{background:var(--adp-background-color-hover)}.air-datepicker-nav--action:active{background:var(--adp-background-color-active)}.air-datepicker-nav--action.-disabled-{visibility:hidden}.air-datepicker-nav--action svg{width:32px;height:32px}.air-datepicker-nav--action path{fill:none;stroke:var(--adp-nav-arrow-color);stroke-width:2px}.air-datepicker-nav--title{border-radius:var(--adp-border-radius);padding:0 8px}.air-datepicker-nav--title i{font-style:normal;color:var(--adp-nav-color-secondary);margin-left:.3em}.air-datepicker-nav--title:hover{background:var(--adp-background-color-hover)}.air-datepicker-nav--title:active{background:var(--adp-background-color-active)}.air-datepicker-nav--title.-disabled-{cursor:default;background:none}
|
|
132
|
-
.air-datepicker-buttons{display:grid;grid-auto-columns:1fr;grid-auto-flow:column}.air-datepicker-button{display:inline-flex;color:var(--adp-btn-color);border-radius:var(--adp-btn-border-radius);cursor:pointer;height:var(--adp-btn-height);border:none;background:rgba(255,255,255,0)}.air-datepicker-button:hover{color:var(--adp-btn-color-hover);background:var(--adp-btn-background-color-hover)}.air-datepicker-button:focus{color:var(--adp-btn-color-hover);background:var(--adp-btn-background-color-hover);outline:none}.air-datepicker-button:active{background:var(--adp-btn-background-color-active)}.air-datepicker-button span{outline:none;display:flex;align-items:center;justify-content:center;width:100%;height:100%}
|
|
133
|
-
.air-datepicker-time{display:grid;grid-template-columns:max-content 1fr;grid-column-gap:12px;align-items:center;position:relative;padding:0 var(--adp-time-padding-inner)}.-only-timepicker- .air-datepicker-time{border-top:none}.air-datepicker-time--current{display:flex;align-items:center;flex:1;font-size:14px;text-align:center}.air-datepicker-time--current-colon{margin:0 2px 3px;line-height:1}.air-datepicker-time--current-hours,.air-datepicker-time--current-minutes{line-height:1;font-size:19px;font-family:"Century Gothic",CenturyGothic,AppleGothic,sans-serif;position:relative;z-index:1}.air-datepicker-time--current-hours:after,.air-datepicker-time--current-minutes:after{content:"";background:var(--adp-background-color-hover);border-radius:var(--adp-border-radius);position:absolute;left:-2px;top:-3px;right:-2px;bottom:-2px;z-index:-1;opacity:0}.air-datepicker-time--current-hours.-focus-:after,.air-datepicker-time--current-minutes.-focus-:after{opacity:1}.air-datepicker-time--current-ampm{text-transform:uppercase;align-self:flex-end;color:var(--adp-time-day-period-color);margin-left:6px;font-size:11px;margin-bottom:1px}.air-datepicker-time--row{display:flex;align-items:center;font-size:11px;height:17px;background:linear-gradient(to right, var(--adp-time-track-color), var(--adp-time-track-color)) left 50%/100% var(--adp-time-track-height) no-repeat}.air-datepicker-time--row:first-child{margin-bottom:4px}.air-datepicker-time--row input[type=range]{background:none;cursor:pointer;flex:1;height:100%;width:100%;padding:0;margin:0;-webkit-appearance:none}.air-datepicker-time--row input[type=range]::-webkit-slider-thumb{-webkit-appearance:none}.air-datepicker-time--row input[type=range]::-ms-tooltip{display:none}.air-datepicker-time--row input[type=range]:hover::-webkit-slider-thumb{border-color:var(--adp-time-track-color-hover)}.air-datepicker-time--row input[type=range]:hover::-moz-range-thumb{border-color:var(--adp-time-track-color-hover)}.air-datepicker-time--row input[type=range]:hover::-ms-thumb{border-color:var(--adp-time-track-color-hover)}.air-datepicker-time--row input[type=range]:focus{outline:none}.air-datepicker-time--row input[type=range]:focus::-webkit-slider-thumb{background:var(--adp-cell-background-color-selected);border-color:var(--adp-cell-background-color-selected)}.air-datepicker-time--row input[type=range]:focus::-moz-range-thumb{background:var(--adp-cell-background-color-selected);border-color:var(--adp-cell-background-color-selected)}.air-datepicker-time--row input[type=range]:focus::-ms-thumb{background:var(--adp-cell-background-color-selected);border-color:var(--adp-cell-background-color-selected)}.air-datepicker-time--row input[type=range]::-webkit-slider-thumb{box-sizing:border-box;height:12px;width:12px;border-radius:3px;border:1px solid var(--adp-time-track-color);background:#fff;cursor:pointer;-webkit-transition:background var(--adp-transition-duration);transition:background var(--adp-transition-duration)}.air-datepicker-time--row input[type=range]::-moz-range-thumb{box-sizing:border-box;height:12px;width:12px;border-radius:3px;border:1px solid var(--adp-time-track-color);background:#fff;cursor:pointer;-moz-transition:background var(--adp-transition-duration);transition:background var(--adp-transition-duration)}.air-datepicker-time--row input[type=range]::-ms-thumb{box-sizing:border-box;height:12px;width:12px;border-radius:3px;border:1px solid var(--adp-time-track-color);background:#fff;cursor:pointer;-ms-transition:background var(--adp-transition-duration);transition:background var(--adp-transition-duration)}.air-datepicker-time--row input[type=range]::-webkit-slider-thumb{margin-top:calc(var(--adp-time-thumb-size)/2*-1)}.air-datepicker-time--row input[type=range]::-webkit-slider-runnable-track{border:none;height:var(--adp-time-track-height);cursor:pointer;color:rgba(0,0,0,0);background:rgba(0,0,0,0)}.air-datepicker-time--row input[type=range]::-moz-range-track{border:none;height:var(--adp-time-track-height);cursor:pointer;color:rgba(0,0,0,0);background:rgba(0,0,0,0)}.air-datepicker-time--row input[type=range]::-ms-track{border:none;height:var(--adp-time-track-height);cursor:pointer;color:rgba(0,0,0,0);background:rgba(0,0,0,0)}.air-datepicker-time--row input[type=range]::-ms-fill-lower{background:rgba(0,0,0,0)}.air-datepicker-time--row input[type=range]::-ms-fill-upper{background:rgba(0,0,0,0)}
|
|
134
|
-
.air-datepicker{--adp-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--adp-font-size: 14px;--adp-width: 246px;--adp-z-index: 100;--adp-padding: 4px;--adp-grid-areas: "nav" "body" "timepicker" "buttons";--adp-transition-duration: .3s;--adp-transition-ease: ease-out;--adp-transition-offset: 8px;--adp-background-color: #fff;--adp-background-color-hover: #f0f0f0;--adp-background-color-active: #eaeaea;--adp-background-color-in-range: rgba(92, 196, 239, .1);--adp-background-color-in-range-focused: rgba(92, 196, 239, .2);--adp-background-color-selected-other-month-focused: #8ad5f4;--adp-background-color-selected-other-month: #a2ddf6;--adp-color: #4a4a4a;--adp-color-secondary: #9c9c9c;--adp-accent-color: #4eb5e6;--adp-color-current-date: var(--adp-accent-color);--adp-color-other-month: #dedede;--adp-color-disabled: #aeaeae;--adp-color-disabled-in-range: #939393;--adp-color-other-month-hover: #c5c5c5;--adp-border-color: #dbdbdb;--adp-border-color-inner: #efefef;--adp-border-radius: 4px;--adp-border-color-inline: #d7d7d7;--adp-nav-height: 32px;--adp-nav-arrow-color: var(--adp-color-secondary);--adp-nav-action-size: 32px;--adp-nav-color-secondary: var(--adp-color-secondary);--adp-day-name-color: #ff9a19;--adp-day-name-color-hover: #8ad5f4;--adp-day-cell-width: 1fr;--adp-day-cell-height: 32px;--adp-month-cell-height: 42px;--adp-year-cell-height: 56px;--adp-pointer-size: 10px;--adp-poiner-border-radius: 2px;--adp-pointer-offset: 14px;--adp-cell-border-radius: 4px;--adp-cell-background-color-hover: var(--adp-background-color-hover);--adp-cell-background-color-selected: #5cc4ef;--adp-cell-background-color-selected-hover: #45bced;--adp-cell-background-color-in-range: rgba(92, 196, 239, 0.1);--adp-cell-background-color-in-range-hover: rgba(92, 196, 239, 0.2);--adp-cell-border-color-in-range: var(--adp-cell-background-color-selected);--adp-btn-height: 32px;--adp-btn-color: var(--adp-accent-color);--adp-btn-color-hover: var(--adp-color);--adp-btn-border-radius: var(--adp-border-radius);--adp-btn-background-color-hover: var(--adp-background-color-hover);--adp-btn-background-color-active: var(--adp-background-color-active);--adp-time-track-height: 1px;--adp-time-track-color: #dedede;--adp-time-track-color-hover: #b1b1b1;--adp-time-thumb-size: 12px;--adp-time-padding-inner: 10px;--adp-time-day-period-color: var(--adp-color-secondary);--adp-mobile-font-size: 16px;--adp-mobile-nav-height: 40px;--adp-mobile-width: 320px;--adp-mobile-day-cell-height: 38px;--adp-mobile-month-cell-height: 48px;--adp-mobile-year-cell-height: 64px}.air-datepicker-overlay{--adp-overlay-background-color: rgba(0, 0, 0, .3);--adp-overlay-transition-duration: .3s;--adp-overlay-transition-ease: ease-out;--adp-overlay-z-index: 99}
|
|
135
|
-
.air-datepicker{background:var(--adp-background-color);border:1px solid var(--adp-border-color);box-shadow:0 4px 12px rgba(0,0,0,.15);border-radius:var(--adp-border-radius);box-sizing:content-box;display:grid;grid-template-columns:1fr;grid-template-rows:repeat(4, max-content);grid-template-areas:var(--adp-grid-areas);font-family:var(--adp-font-family),sans-serif;font-size:var(--adp-font-size);color:var(--adp-color);width:var(--adp-width);position:absolute;transition:opacity var(--adp-transition-duration) var(--adp-transition-ease),transform var(--adp-transition-duration) var(--adp-transition-ease);z-index:var(--adp-z-index)}.air-datepicker:not(.-custom-position-){opacity:0}.air-datepicker.-from-top-{transform:translateY(calc(var(--adp-transition-offset) * -1))}.air-datepicker.-from-right-{transform:translateX(var(--adp-transition-offset))}.air-datepicker.-from-bottom-{transform:translateY(var(--adp-transition-offset))}.air-datepicker.-from-left-{transform:translateX(calc(var(--adp-transition-offset) * -1))}.air-datepicker.-active-:not(.-custom-position-){transform:translate(0, 0);opacity:1}.air-datepicker.-active-.-custom-position-{transition:none}.air-datepicker.-inline-{border-color:var(--adp-border-color-inline);box-shadow:none;position:static;left:auto;right:auto;opacity:1;transform:none}.air-datepicker.-inline- .air-datepicker--pointer{display:none}.air-datepicker.-is-mobile-{--adp-font-size: var(--adp-mobile-font-size);--adp-day-cell-height: var(--adp-mobile-day-cell-height);--adp-month-cell-height: var(--adp-mobile-month-cell-height);--adp-year-cell-height: var(--adp-mobile-year-cell-height);--adp-nav-height: var(--adp-mobile-nav-height);--adp-nav-action-size: var(--adp-mobile-nav-height);position:fixed;width:var(--adp-mobile-width);border:none}.air-datepicker.-is-mobile- *{-webkit-tap-highlight-color:rgba(0,0,0,0)}.air-datepicker.-is-mobile- .air-datepicker--pointer{display:none}.air-datepicker.-is-mobile-:not(.-custom-position-){transform:translate(-50%, calc(-50% + var(--adp-transition-offset)))}.air-datepicker.-is-mobile-.-active-:not(.-custom-position-){transform:translate(-50%, -50%)}.air-datepicker.-custom-position-{transition:none}.air-datepicker-global-container{position:absolute;left:0;top:0}.air-datepicker--pointer{--pointer-half-size: calc(var(--adp-pointer-size) / 2);position:absolute;width:var(--adp-pointer-size);height:var(--adp-pointer-size);z-index:-1}.air-datepicker--pointer:after{content:"";position:absolute;background:#fff;border-top:1px solid var(--adp-border-color-inline);border-right:1px solid var(--adp-border-color-inline);border-top-right-radius:var(--adp-poiner-border-radius);width:var(--adp-pointer-size);height:var(--adp-pointer-size);box-sizing:border-box}.-top-left- .air-datepicker--pointer,.-top-center- .air-datepicker--pointer,.-top-right- .air-datepicker--pointer,[data-popper-placement^=top] .air-datepicker--pointer{top:calc(100% - var(--pointer-half-size) + 1px)}.-top-left- .air-datepicker--pointer:after,.-top-center- .air-datepicker--pointer:after,.-top-right- .air-datepicker--pointer:after,[data-popper-placement^=top] .air-datepicker--pointer:after{transform:rotate(135deg)}.-right-top- .air-datepicker--pointer,.-right-center- .air-datepicker--pointer,.-right-bottom- .air-datepicker--pointer,[data-popper-placement^=right] .air-datepicker--pointer{right:calc(100% - var(--pointer-half-size) + 1px)}.-right-top- .air-datepicker--pointer:after,.-right-center- .air-datepicker--pointer:after,.-right-bottom- .air-datepicker--pointer:after,[data-popper-placement^=right] .air-datepicker--pointer:after{transform:rotate(225deg)}.-bottom-left- .air-datepicker--pointer,.-bottom-center- .air-datepicker--pointer,.-bottom-right- .air-datepicker--pointer,[data-popper-placement^=bottom] .air-datepicker--pointer{bottom:calc(100% - var(--pointer-half-size) + 1px)}.-bottom-left- .air-datepicker--pointer:after,.-bottom-center- .air-datepicker--pointer:after,.-bottom-right- .air-datepicker--pointer:after,[data-popper-placement^=bottom] .air-datepicker--pointer:after{transform:rotate(315deg)}.-left-top- .air-datepicker--pointer,.-left-center- .air-datepicker--pointer,.-left-bottom- .air-datepicker--pointer,[data-popper-placement^=left] .air-datepicker--pointer{left:calc(100% - var(--pointer-half-size) + 1px)}.-left-top- .air-datepicker--pointer:after,.-left-center- .air-datepicker--pointer:after,.-left-bottom- .air-datepicker--pointer:after,[data-popper-placement^=left] .air-datepicker--pointer:after{transform:rotate(45deg)}.-top-left- .air-datepicker--pointer,.-bottom-left- .air-datepicker--pointer{left:var(--adp-pointer-offset)}.-top-right- .air-datepicker--pointer,.-bottom-right- .air-datepicker--pointer{right:var(--adp-pointer-offset)}.-top-center- .air-datepicker--pointer,.-bottom-center- .air-datepicker--pointer{left:calc(50% - var(--adp-pointer-size)/2)}.-left-top- .air-datepicker--pointer,.-right-top- .air-datepicker--pointer{top:var(--adp-pointer-offset)}.-left-bottom- .air-datepicker--pointer,.-right-bottom- .air-datepicker--pointer{bottom:var(--adp-pointer-offset)}.-left-center- .air-datepicker--pointer,.-right-center- .air-datepicker--pointer{top:calc(50% - var(--adp-pointer-size)/2)}.air-datepicker--navigation{grid-area:nav}.air-datepicker--content{box-sizing:content-box;padding:var(--adp-padding);grid-area:body}.-only-timepicker- .air-datepicker--content{display:none}.air-datepicker--time{grid-area:timepicker}.air-datepicker--buttons{grid-area:buttons}.air-datepicker--buttons,.air-datepicker--time{padding:var(--adp-padding);border-top:1px solid var(--adp-border-color-inner)}.air-datepicker-overlay{position:fixed;background:var(--adp-overlay-background-color);left:0;top:0;width:0;height:0;opacity:0;transition:opacity var(--adp-overlay-transition-duration) var(--adp-overlay-transition-ease),left 0s,height 0s,width 0s;transition-delay:0s,var(--adp-overlay-transition-duration),var(--adp-overlay-transition-duration),var(--adp-overlay-transition-duration);z-index:var(--adp-overlay-z-index)}.air-datepicker-overlay.-active-{opacity:1;width:100%;height:100%;transition:opacity var(--adp-overlay-transition-duration) var(--adp-overlay-transition-ease),height 0s,width 0s}`;
|
|
136
|
-
|
|
137
|
-
const injectStyles = (css: string) => {
|
|
138
|
-
if (typeof document !== 'undefined') {
|
|
139
|
-
const styleElementId = 'pdfme-air-datepicker-styles';
|
|
140
|
-
if (!document.getElementById(styleElementId)) {
|
|
141
|
-
const style = document.createElement('style');
|
|
142
|
-
style.id = styleElementId;
|
|
143
|
-
style.type = 'text/css';
|
|
144
|
-
style.appendChild(document.createTextNode(css));
|
|
145
|
-
document.head.appendChild(style);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const strDateToDate = (strDate: string, type: PickerType): Date => {
|
|
151
|
-
if (!strDate.trim()) {
|
|
152
|
-
return new Date();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (type === 'time') {
|
|
156
|
-
const dateTimePattern = /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}$/;
|
|
157
|
-
if (dateTimePattern.test(strDate)) {
|
|
158
|
-
return new Date(strDate.replace(/\//g, '-').replace(' ', 'T'));
|
|
159
|
-
}
|
|
160
|
-
return new Date(`2021-01-01T${strDate}`);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return new Date(strDate);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export const getFormat = (type: PickerType, locale: Locale): string => {
|
|
167
|
-
switch (type) {
|
|
168
|
-
case 'date': {
|
|
169
|
-
return locale.adLocale.dateFormat;
|
|
170
|
-
}
|
|
171
|
-
case 'time': {
|
|
172
|
-
return 'HH:mm';
|
|
173
|
-
}
|
|
174
|
-
case 'dateTime': {
|
|
175
|
-
return `${locale.adLocale.dateFormat} ${locale.adLocale.timeFormat}`;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export const isValidDateFormat = (
|
|
181
|
-
formatString: string | undefined,
|
|
182
|
-
locale: Locale,
|
|
183
|
-
): formatString is string => {
|
|
184
|
-
if (typeof formatString !== 'string') {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const normalizedFormat = formatString.trim();
|
|
189
|
-
if (!normalizedFormat || normalizedFormat === 'undefined') {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
format(new Date(0), normalizedFormat, {
|
|
195
|
-
locale: locale.formatLocale,
|
|
196
|
-
});
|
|
197
|
-
return true;
|
|
198
|
-
} catch {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export const getSafeFormat = (
|
|
204
|
-
type: PickerType,
|
|
205
|
-
schema: Pick<DateSchema, 'format'>,
|
|
206
|
-
locale: Locale,
|
|
207
|
-
): string => {
|
|
208
|
-
return isValidDateFormat(schema.format, locale)
|
|
209
|
-
? schema.format.trim()
|
|
210
|
-
: getFormat(type, locale);
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export const getFmtValue = (
|
|
214
|
-
value: string,
|
|
215
|
-
type: PickerType,
|
|
216
|
-
schema: DateSchema,
|
|
217
|
-
locale: Locale,
|
|
218
|
-
): string => {
|
|
219
|
-
const formatString = getSafeFormat(type, schema, locale);
|
|
220
|
-
|
|
221
|
-
return value
|
|
222
|
-
? format(strDateToDate(value, type), formatString, {
|
|
223
|
-
locale: locale.formatLocale,
|
|
224
|
-
})
|
|
225
|
-
: '';
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const getFmtContent = (date: Date | null, type: PickerType) => {
|
|
229
|
-
const fmt = (() => {
|
|
230
|
-
switch (type) {
|
|
231
|
-
case 'date': {
|
|
232
|
-
return 'yyyy/MM/dd';
|
|
233
|
-
}
|
|
234
|
-
case 'time': {
|
|
235
|
-
return 'HH:mm';
|
|
236
|
-
}
|
|
237
|
-
case 'dateTime': {
|
|
238
|
-
return 'yyyy/MM/dd HH:mm';
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
})();
|
|
242
|
-
return date ? format(date, fmt) : '';
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export const getPlugin = ({ type, icon }: { type: PickerType; icon: string }) => {
|
|
246
|
-
const defaultLocale = 'en';
|
|
247
|
-
const defaultFormat = getFormat(type, getAirDatepickerLocale(defaultLocale));
|
|
248
|
-
|
|
249
|
-
const plugin: Plugin<DateSchema> = {
|
|
250
|
-
ui: async (arg) => {
|
|
251
|
-
const { schema, value, onChange, rootElement, mode, options, i18n } = arg;
|
|
252
|
-
|
|
253
|
-
const locale = getAirDatepickerLocale(schema.locale || options.lang || defaultLocale);
|
|
254
|
-
const formatString = getSafeFormat(type, schema, locale);
|
|
255
|
-
|
|
256
|
-
const textElement = document.createElement('div');
|
|
257
|
-
const textElementStyle: CSS.Properties = {
|
|
258
|
-
width: `${schema.width}mm`,
|
|
259
|
-
height: `${schema.height}mm`,
|
|
260
|
-
display: 'flex',
|
|
261
|
-
flexDirection: 'column',
|
|
262
|
-
justifyContent: mapVerticalAlignToFlex(VERTICAL_ALIGN_MIDDLE),
|
|
263
|
-
};
|
|
264
|
-
Object.assign(textElement.style, textElementStyle);
|
|
265
|
-
|
|
266
|
-
await text.ui({
|
|
267
|
-
...arg,
|
|
268
|
-
rootElement: textElement,
|
|
269
|
-
mode: 'viewer',
|
|
270
|
-
value: getFmtValue(value, type, schema, locale),
|
|
271
|
-
schema: {
|
|
272
|
-
...schema,
|
|
273
|
-
verticalAlignment: VERTICAL_ALIGN_MIDDLE,
|
|
274
|
-
lineHeight: DEFAULT_LINE_HEIGHT,
|
|
275
|
-
},
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
injectStyles(airDatepickerCss);
|
|
279
|
-
|
|
280
|
-
const beforeRemoveEvent = new Event('beforeRemove');
|
|
281
|
-
rootElement.dispatchEvent(beforeRemoveEvent);
|
|
282
|
-
|
|
283
|
-
const input = document.createElement('input');
|
|
284
|
-
Object.assign(input.style, { visibility: 'hidden', position: 'absolute' });
|
|
285
|
-
|
|
286
|
-
const commitChange = (date: Date | null) => {
|
|
287
|
-
if (onChange) {
|
|
288
|
-
onChange({ key: 'content', value: getFmtContent(date, type) });
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
const adButtons: AirDatepickerButton[] = [
|
|
293
|
-
{
|
|
294
|
-
content: i18n('cancel'),
|
|
295
|
-
onClick: (datepicker) => {
|
|
296
|
-
datepicker.hide();
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
content: i18n('clear'),
|
|
301
|
-
onClick: (datepicker) => {
|
|
302
|
-
datepicker.hide();
|
|
303
|
-
commitChange(null);
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
];
|
|
307
|
-
if (type !== 'date') {
|
|
308
|
-
adButtons.push({
|
|
309
|
-
content: i18n('set'),
|
|
310
|
-
onClick: (datepicker) => {
|
|
311
|
-
datepicker.hide();
|
|
312
|
-
const date = datepicker.selectedDates.length ? datepicker.selectedDates[0] : null;
|
|
313
|
-
commitChange(date);
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
const airDatepicker = new AirDatepicker(input, {
|
|
318
|
-
locale: locale.adLocale,
|
|
319
|
-
selectedDates: value.trim() ? [strDateToDate(value, type)] : [],
|
|
320
|
-
dateFormat: (date: AirDatepickerDate) =>
|
|
321
|
-
format(date, formatString, { locale: locale.formatLocale }),
|
|
322
|
-
timepicker: type !== 'date',
|
|
323
|
-
onlyTimepicker: type === 'time',
|
|
324
|
-
isMobile: window.innerWidth < 768,
|
|
325
|
-
buttons: adButtons,
|
|
326
|
-
position({ $datepicker, $target, $pointer, done }) {
|
|
327
|
-
$datepicker.style.position = 'fixed';
|
|
328
|
-
const offset = 5;
|
|
329
|
-
const scrollY = window.scrollY;
|
|
330
|
-
const scrollX = window.scrollX;
|
|
331
|
-
|
|
332
|
-
const targetRect = $target.getBoundingClientRect();
|
|
333
|
-
const dpHeight = $datepicker.offsetHeight;
|
|
334
|
-
const dpWidth = $datepicker.offsetWidth;
|
|
335
|
-
|
|
336
|
-
const spaceBelow = window.innerHeight - targetRect.bottom;
|
|
337
|
-
const spaceAbove = targetRect.top;
|
|
338
|
-
|
|
339
|
-
const showAbove = spaceBelow < dpHeight + offset && spaceAbove > dpHeight;
|
|
340
|
-
|
|
341
|
-
let top = showAbove
|
|
342
|
-
? targetRect.top + scrollY - dpHeight - offset
|
|
343
|
-
: targetRect.bottom + scrollY + offset;
|
|
344
|
-
|
|
345
|
-
let left = targetRect.left + scrollX;
|
|
346
|
-
|
|
347
|
-
if (left + dpWidth > window.innerWidth) {
|
|
348
|
-
left = window.innerWidth - dpWidth - 10;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
$datepicker.style.position = 'absolute';
|
|
352
|
-
$datepicker.style.top = `${top}px`;
|
|
353
|
-
$datepicker.style.left = `${left}px`;
|
|
354
|
-
if ($pointer) {
|
|
355
|
-
$pointer.style.display = 'block';
|
|
356
|
-
$pointer.style.position = 'absolute';
|
|
357
|
-
$pointer.style.left = '10px';
|
|
358
|
-
$pointer.style.top = showAbove ? 'calc(100% - 5px)' : '-5px';
|
|
359
|
-
$pointer.style.transform = showAbove ? 'rotate(135deg)' : 'rotate(-45deg)';
|
|
360
|
-
}
|
|
361
|
-
return function completeHide() {
|
|
362
|
-
done();
|
|
363
|
-
};
|
|
364
|
-
},
|
|
365
|
-
onSelect: ({ datepicker }: { datepicker: AirDatepickerInstance }) => {
|
|
366
|
-
if (type === 'date') {
|
|
367
|
-
commitChange(datepicker.selectedDates.length ? datepicker.selectedDates[0] : null);
|
|
368
|
-
datepicker.hide();
|
|
369
|
-
}
|
|
370
|
-
},
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
rootElement.addEventListener('beforeRemove', () => {
|
|
374
|
-
if (isEditable(mode, schema)) {
|
|
375
|
-
airDatepicker.destroy();
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
textElement.addEventListener('click', () => {
|
|
379
|
-
if (isEditable(mode, schema)) {
|
|
380
|
-
airDatepicker.show();
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
rootElement.appendChild(input);
|
|
385
|
-
rootElement.appendChild(textElement);
|
|
386
|
-
},
|
|
387
|
-
pdf: (arg) => {
|
|
388
|
-
const { schema, value, options } = arg;
|
|
389
|
-
if (!value) return void 0;
|
|
390
|
-
const locale = getAirDatepickerLocale(schema.locale || options.lang || defaultLocale);
|
|
391
|
-
return text.pdf({
|
|
392
|
-
...arg,
|
|
393
|
-
value: getFmtValue(value, type, schema, locale),
|
|
394
|
-
schema: {
|
|
395
|
-
...schema,
|
|
396
|
-
verticalAlignment: VERTICAL_ALIGN_MIDDLE,
|
|
397
|
-
lineHeight: DEFAULT_LINE_HEIGHT,
|
|
398
|
-
},
|
|
399
|
-
});
|
|
400
|
-
},
|
|
401
|
-
propPanel: {
|
|
402
|
-
schema: ({ options, i18n, activeSchema, changeSchemas }) => {
|
|
403
|
-
const font = options.font || { [DEFAULT_FONT_NAME]: { data: '', fallback: true } };
|
|
404
|
-
const fontNames = Object.keys(font);
|
|
405
|
-
const fallbackFontName = getFallbackFontName(font);
|
|
406
|
-
const activeDateSchema = activeSchema as { locale?: string; format?: string };
|
|
407
|
-
|
|
408
|
-
const locale = getAirDatepickerLocale(
|
|
409
|
-
activeDateSchema.locale || options.lang || defaultLocale,
|
|
410
|
-
);
|
|
411
|
-
const defaultFormat = getFormat(type, locale);
|
|
412
|
-
const safeFormat = getSafeFormat(
|
|
413
|
-
type,
|
|
414
|
-
activeDateSchema as Pick<DateSchema, 'format'>,
|
|
415
|
-
locale,
|
|
416
|
-
);
|
|
417
|
-
const schemaChanges = [];
|
|
418
|
-
|
|
419
|
-
if (activeDateSchema.locale === undefined && activeDateSchema.locale !== options.lang) {
|
|
420
|
-
schemaChanges.push({ schemaId: activeSchema.id, key: 'locale', value: options.lang });
|
|
421
|
-
}
|
|
422
|
-
if (activeDateSchema.format !== safeFormat) {
|
|
423
|
-
schemaChanges.push({ schemaId: activeSchema.id, key: 'format', value: safeFormat });
|
|
424
|
-
}
|
|
425
|
-
if (schemaChanges.length > 0) {
|
|
426
|
-
changeSchemas(schemaChanges);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
const formatter = getExtraFormatterSchema(i18n);
|
|
430
|
-
formatter.buttons = formatter.buttons.filter(
|
|
431
|
-
(button) => button.key === Formatter.ALIGNMENT,
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
const validateDateTimeFormat = (_rule: unknown, formatString: string): boolean =>
|
|
435
|
-
isValidDateFormat(formatString, locale);
|
|
436
|
-
|
|
437
|
-
const localeOptions = Object.keys(LOCALE_MAP).map((lc) => ({
|
|
438
|
-
label: `${lc} (${LOCALE_MAP[lc].label})`,
|
|
439
|
-
value: lc,
|
|
440
|
-
}));
|
|
441
|
-
|
|
442
|
-
const dateSchema: Record<string, PropPanelSchema> = {
|
|
443
|
-
format: {
|
|
444
|
-
title: i18n('schemas.date.format'),
|
|
445
|
-
type: 'string',
|
|
446
|
-
default: safeFormat,
|
|
447
|
-
placeholder: defaultFormat,
|
|
448
|
-
rules: [
|
|
449
|
-
{
|
|
450
|
-
validator: validateDateTimeFormat,
|
|
451
|
-
message: i18n('validation.dateTimeFormat'),
|
|
452
|
-
},
|
|
453
|
-
],
|
|
454
|
-
span: 24,
|
|
455
|
-
},
|
|
456
|
-
fontName: {
|
|
457
|
-
title: i18n('schemas.text.fontName'),
|
|
458
|
-
type: 'string',
|
|
459
|
-
widget: 'select',
|
|
460
|
-
default: fallbackFontName,
|
|
461
|
-
placeholder: fallbackFontName,
|
|
462
|
-
props: { options: fontNames.map((name) => ({ label: name, value: name })) },
|
|
463
|
-
span: 12,
|
|
464
|
-
},
|
|
465
|
-
fontSize: {
|
|
466
|
-
title: i18n('schemas.text.size'),
|
|
467
|
-
type: 'number',
|
|
468
|
-
widget: 'inputNumber',
|
|
469
|
-
span: 6,
|
|
470
|
-
props: { min: 0 },
|
|
471
|
-
},
|
|
472
|
-
characterSpacing: {
|
|
473
|
-
title: i18n('schemas.text.spacing'),
|
|
474
|
-
type: 'number',
|
|
475
|
-
widget: 'inputNumber',
|
|
476
|
-
span: 6,
|
|
477
|
-
props: { min: 0 },
|
|
478
|
-
},
|
|
479
|
-
formatter,
|
|
480
|
-
fontColor: {
|
|
481
|
-
title: i18n('schemas.textColor'),
|
|
482
|
-
type: 'string',
|
|
483
|
-
widget: 'color',
|
|
484
|
-
props: {
|
|
485
|
-
disabledAlpha: true,
|
|
486
|
-
},
|
|
487
|
-
rules: [
|
|
488
|
-
{
|
|
489
|
-
pattern: HEX_COLOR_PATTERN,
|
|
490
|
-
message: i18n('validation.hexColor'),
|
|
491
|
-
},
|
|
492
|
-
],
|
|
493
|
-
},
|
|
494
|
-
backgroundColor: {
|
|
495
|
-
title: i18n('schemas.bgColor'),
|
|
496
|
-
type: 'string',
|
|
497
|
-
widget: 'color',
|
|
498
|
-
props: {
|
|
499
|
-
disabledAlpha: true,
|
|
500
|
-
},
|
|
501
|
-
rules: [
|
|
502
|
-
{
|
|
503
|
-
pattern: HEX_COLOR_PATTERN,
|
|
504
|
-
message: i18n('validation.hexColor'),
|
|
505
|
-
},
|
|
506
|
-
],
|
|
507
|
-
},
|
|
508
|
-
locale: {
|
|
509
|
-
title: i18n('schemas.date.locale'),
|
|
510
|
-
type: 'string',
|
|
511
|
-
widget: 'select',
|
|
512
|
-
props: {
|
|
513
|
-
options: localeOptions,
|
|
514
|
-
},
|
|
515
|
-
span: 16,
|
|
516
|
-
},
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
return dateSchema;
|
|
520
|
-
},
|
|
521
|
-
defaultSchema: {
|
|
522
|
-
name: '',
|
|
523
|
-
format: defaultFormat,
|
|
524
|
-
type,
|
|
525
|
-
content: getFmtContent(new Date(), type),
|
|
526
|
-
position: { x: 0, y: 0 },
|
|
527
|
-
width: 50,
|
|
528
|
-
height: 10,
|
|
529
|
-
rotate: 0,
|
|
530
|
-
alignment: DEFAULT_ALIGNMENT,
|
|
531
|
-
fontSize: DEFAULT_FONT_SIZE,
|
|
532
|
-
characterSpacing: DEFAULT_CHARACTER_SPACING,
|
|
533
|
-
fontColor: DEFAULT_FONT_COLOR,
|
|
534
|
-
fontName: undefined,
|
|
535
|
-
backgroundColor: '',
|
|
536
|
-
locale: undefined,
|
|
537
|
-
opacity: DEFAULT_OPACITY,
|
|
538
|
-
} as DateSchema,
|
|
539
|
-
},
|
|
540
|
-
icon,
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
return plugin;
|
|
544
|
-
};
|
package/src/date/time.ts
DELETED
package/src/date/types.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@pdfme/common';
|
|
2
|
-
import { ALIGNMENT } from '../text/types.js';
|
|
3
|
-
|
|
4
|
-
export interface DateSchema extends Schema {
|
|
5
|
-
format: string;
|
|
6
|
-
fontName?: string;
|
|
7
|
-
alignment: ALIGNMENT;
|
|
8
|
-
fontSize: number;
|
|
9
|
-
characterSpacing: number;
|
|
10
|
-
fontColor: string;
|
|
11
|
-
backgroundColor: string;
|
|
12
|
-
locale?: string;
|
|
13
|
-
// Explicitly include these properties from Schema for TypeScript
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
name: string;
|
|
17
|
-
type: string;
|
|
18
|
-
content?: string;
|
|
19
|
-
}
|