inviton-powerduck 0.0.134 → 0.0.136

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.
@@ -1,3 +1,4 @@
1
+ import PowerduckState from '../../app/powerduck-state';
1
2
  import { DateWrapper } from '../date-wrapper';
2
3
 
3
4
  const _isInteger = (val: any) => {
@@ -30,7 +31,7 @@ const _getInt = (
30
31
  };
31
32
 
32
33
  export default class DateUtils {
33
- static getWeekNumber(date: DateWrapper | Date) {
34
+ static getWeekNumber (date: DateWrapper | Date) {
34
35
  const target = new Date(date.getTime());
35
36
  // Nastaviť na najbližší štvrtok (ISO týždne začínajú v pondelok)
36
37
  target.setHours(
@@ -50,7 +51,7 @@ export default class DateUtils {
50
51
  return weekNumber;
51
52
  }
52
53
 
53
- static formatDate(date: Date | DateWrapper | number, format: string): string {
54
+ static formatDate (date: Date | DateWrapper | number, format: string): string {
54
55
  if (typeof date === 'number') {
55
56
  date = new DateWrapper(date);
56
57
  }
@@ -69,6 +70,8 @@ export default class DateUtils {
69
70
  const s = date.getSeconds();
70
71
  const LZ = x => (x < 0 || x > 9 ? '' : '0') + x;
71
72
 
73
+ const locale = PowerduckState.getCurrentLanguage();
74
+
72
75
  // Convert real date parts into formatted versions
73
76
  const value: any = new Object();
74
77
  if (y.length < 4) {
@@ -80,8 +83,12 @@ export default class DateUtils {
80
83
  value.yy = y.substring(2, 4);
81
84
  value.M = M;
82
85
  value.MM = LZ(M);
86
+ value.MMM = date.toLocaleDateString({ month: 'short', timeZone: 'UTC', language: locale });
87
+ value.MMMM = date.toLocaleDateString({ month: 'long', timeZone: 'UTC', language: locale });
83
88
  value.d = d;
84
89
  value.dd = LZ(d);
90
+ value.E = date.toLocaleDateString({ weekday: 'short', timeZone: 'UTC', language: locale });
91
+ value.EEEE = date.toLocaleDateString({ weekday: 'long', timeZone: 'UTC', language: locale });
85
92
  value.H = H;
86
93
  value.HH = LZ(H);
87
94
  if (H == 0) {
@@ -127,7 +134,7 @@ export default class DateUtils {
127
134
  return result;
128
135
  };
129
136
 
130
- static getDateWrapperFromFormat(val: string, format: string): DateWrapper {
137
+ static getDateWrapperFromFormat (val: string, format: string): DateWrapper {
131
138
  // In case somehow the date is already a datewrapper
132
139
  if ((val as any)._dte != null) {
133
140
  return (val as any);
@@ -149,6 +156,44 @@ export default class DateUtils {
149
156
  let ss: any = now.getSeconds();
150
157
  let ampm = '';
151
158
 
159
+ const _isValidChar = (char: string): boolean => /[a-záčďéíĺľńóôŕšťúýž]/i.test(char);
160
+ const locale = PowerduckState.getCurrentLanguage();
161
+ const getMonthFromName = (monthName: string, isShort: boolean = false): number => {
162
+ const date = new Date(2022, 0, 1);
163
+
164
+ for (let monthIndex = 0; monthIndex < 12; monthIndex++) {
165
+ date.setMonth(monthIndex);
166
+ const name = date.toLocaleDateString(locale, {
167
+ month: isShort ? 'short' : 'long',
168
+ timeZone: 'UTC'
169
+ }).toLowerCase();
170
+
171
+ if (name == monthName.toLowerCase()) {
172
+ return monthIndex;
173
+ }
174
+ }
175
+
176
+ return null;
177
+ };
178
+
179
+ const getDayFromName = (dayName: string, isShort: boolean = false): number => {
180
+ const date = new Date(2022, 0, 2);
181
+
182
+ for (let dayIndex = 0; dayIndex < 7; dayIndex++) {
183
+ date.setDate(2 + dayIndex);
184
+ const name = date.toLocaleDateString(locale, {
185
+ weekday: isShort ? 'short' : 'long',
186
+ timeZone: 'UTC'
187
+ }).toLowerCase();
188
+
189
+ if (name == dayName.toLowerCase()) {
190
+ return date.getDay();
191
+ }
192
+ }
193
+
194
+ return null;
195
+ };
196
+
152
197
  while (i_format < format.length) {
153
198
  // Get next token from format string
154
199
  c = format.charAt(i_format);
@@ -203,6 +248,46 @@ export default class DateUtils {
203
248
  }
204
249
 
205
250
  i_val += month.length;
251
+ } else if (token == 'MMMM') {
252
+ let monthName = '';
253
+ let tmpIndex = i_val;
254
+
255
+ while (tmpIndex < val.length) {
256
+ const char = val.charAt(tmpIndex);
257
+ if (_isValidChar(char)) {
258
+ monthName += char;
259
+ tmpIndex++;
260
+ } else {
261
+ break;
262
+ }
263
+ }
264
+
265
+ month = getMonthFromName(monthName, false);
266
+ if (month == null) {
267
+ return null;
268
+ }
269
+
270
+ i_val = tmpIndex;
271
+ } else if (token == 'MMM') {
272
+ let monthName = '';
273
+ let tempIndex = i_val;
274
+
275
+ while (tempIndex < val.length && (tempIndex - i_val) < 4) {
276
+ const char = val.charAt(tempIndex);
277
+ if (_isValidChar(char)) {
278
+ monthName += char;
279
+ tempIndex++;
280
+ } else {
281
+ break;
282
+ }
283
+ }
284
+
285
+ month = getMonthFromName(monthName, true);
286
+ if (month == null) {
287
+ return null;
288
+ }
289
+
290
+ i_val = tempIndex;
206
291
  } else if (token == 'dd' || token == 'd') {
207
292
  date = _getInt(
208
293
  val,
@@ -215,6 +300,46 @@ export default class DateUtils {
215
300
  }
216
301
 
217
302
  i_val += date.length;
303
+ } else if (token == 'EEEE') {
304
+ let dayName = '';
305
+ let tempIndex = i_val;
306
+
307
+ while (tempIndex < val.length) {
308
+ const char = val.charAt(tempIndex);
309
+ if (_isValidChar(char)) {
310
+ dayName += char;
311
+ tempIndex++;
312
+ } else {
313
+ break;
314
+ }
315
+ }
316
+
317
+ const dayIndex = getDayFromName(dayName, false);
318
+ if (dayIndex == null) {
319
+ return null;
320
+ }
321
+
322
+ i_val = tempIndex;
323
+ } else if (token == 'E') {
324
+ let dayName = '';
325
+ let tempIndex = i_val;
326
+
327
+ while (tempIndex < val.length && (tempIndex - i_val) < 4) {
328
+ const char = val.charAt(tempIndex);
329
+ if (_isValidChar(char)) {
330
+ dayName += char;
331
+ tempIndex++;
332
+ } else {
333
+ break;
334
+ }
335
+ }
336
+
337
+ const dayIndex = getDayFromName(dayName, true);
338
+ if (dayIndex == null) {
339
+ return null;
340
+ }
341
+
342
+ i_val = tempIndex;
218
343
  } else if (token == 'hh' || token == 'h') {
219
344
  hh = _getInt(
220
345
  val,
@@ -1419,7 +1419,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1419
1419
  } else {
1420
1420
  mySelf.totalCount = data.totalCount ?? data.TotalCount;
1421
1421
  mySelf.totalFilteredCount = data.totalFilteredCount ?? data.TotalFilteredCount;
1422
- mySelf.rows = data.rows ?? data.Rows;
1422
+ mySelf.rows = data.rows ?? data.Rows ?? data.data;
1423
1423
  }
1424
1424
 
1425
1425
  mySelf.loadedRows = mySelf.rows;
@@ -42,6 +42,7 @@ interface DaterangePickerArgs extends FormItemWrapperArgs {
42
42
  maxDate?: DateWrapper;
43
43
  prevIcon?: string;
44
44
  nextIcon?: string;
45
+ hideYearInMonthName?: boolean;
45
46
  singleMonth?: boolean;
46
47
  calendarPlacement?: 'body' | 'inline' | 'input-container-leftalign' | 'input-container-rightalign';
47
48
  ensureMonthContinuity?: boolean;
@@ -112,6 +113,7 @@ class DaterangePickerComponent extends TsxComponent<DaterangePickerArgs> impleme
112
113
  @Prop() maxDate?: DateWrapper;
113
114
  @Prop() prevIcon?: string;
114
115
  @Prop() nextIcon?: string;
116
+ @Prop() hideYearInMonthName?: boolean;
115
117
  @Prop() disabled!: boolean;
116
118
  @Prop() readOnly?: boolean;
117
119
  @Prop() customTooltip?: (dayCount: number) => string;
@@ -161,6 +163,7 @@ class DaterangePickerComponent extends TsxComponent<DaterangePickerArgs> impleme
161
163
  singleDate: this.singleDate == true,
162
164
  startOfWeek: DateInputHelper.getStartOfWeek() == 0 ? 'sunday' : 'monday',
163
165
  separator: self.getSeparator(),
166
+ hideYearInMonthName: this.hideYearInMonthName == true,
164
167
  format: self.getFormat(),
165
168
  language: self.getLanguage(),
166
169
  autoClose: self.autoClose,
@@ -405,7 +408,7 @@ class DaterangePickerComponent extends TsxComponent<DaterangePickerArgs> impleme
405
408
  }
406
409
  }
407
410
 
408
- syncInputDefaultValue(dateStart?: string, dateEnd?: string) {
411
+ syncInputDefaultValue (dateStart?: string, dateEnd?: string) {
409
412
  const startDate = this.getDateFromString(dateStart);
410
413
  if (startDate?.getTime() != this._startDate?.getTime()) {
411
414
  this._startDate = startDate;
@@ -420,7 +423,16 @@ class DaterangePickerComponent extends TsxComponent<DaterangePickerArgs> impleme
420
423
  }
421
424
  }
422
425
 
423
- const inputValue = DateUtils.formatDate(startDate, this.getFormat()) + this.getSeparator() + DateUtils.formatDate(endDate, this.getFormat());
426
+ const getInputValue = (): string => {
427
+ const formattedStartDate = DateUtils.formatDate(startDate, this.getFormat());
428
+ if (this.singleDate) {
429
+ return formattedStartDate;
430
+ }
431
+
432
+ return formattedStartDate + this.getSeparator() + DateUtils.formatDate(endDate, this.getFormat());
433
+ }
434
+
435
+ const inputValue = getInputValue();
424
436
  this._lastText = inputValue;
425
437
  this.writeCustomText();
426
438
  }
@@ -1696,7 +1696,7 @@ import './daterangepicker.css';
1696
1696
  function showMonth(date: DateWrapper, month: 'month1' | 'month2') {
1697
1697
  date = date.clone();
1698
1698
  const monthName = nameMonth(date.getMonth());
1699
- box.find(`.${month} .month-name`).html(`${monthName} ${date.getFullYear()}`);
1699
+ box.find(`.${month} .month-name`).html(`${monthName}${opt.hideYearInMonthName ? '' : ` ${date.getFullYear()}`}`);
1700
1700
  box.find(`.${month} tbody`).html(createMonthHTML(date));
1701
1701
  opt[month] = date;
1702
1702
  updateSelectableRange();
@@ -2290,4 +2290,4 @@ import './daterangepicker.css';
2290
2290
  showGap();
2291
2291
  }
2292
2292
  };
2293
- })($);
2293
+ })($);
@@ -21,6 +21,7 @@ import './plugins/trumbowyg/modal-issues-fix';
21
21
  import 'trumbowyg/plugins/emoji/trumbowyg.emoji.js';
22
22
  import 'trumbowyg/plugins/noembed/trumbowyg.noembed.js';
23
23
  import 'trumbowyg/plugins/fontsize/trumbowyg.fontsize.js';
24
+ import 'trumbowyg/plugins/lineheight/trumbowyg.lineheight.js';
24
25
  import 'trumbowyg/dist/ui/trumbowyg.min.css';
25
26
  import 'trumbowyg/dist/plugins/emoji/ui/trumbowyg.emoji.css';
26
27
  import '../input/css/wysiwig.css';
@@ -96,6 +97,18 @@ class WysiwigEditorComponent extends TsxComponent<WysiwigEditorArgs> implements
96
97
  },
97
98
  cleanPasteCustom: {
98
99
 
100
+ },
101
+ lineheight: {
102
+ sizeList: [
103
+ '0.9',
104
+ '1.0',
105
+ 'normal',
106
+ '1.2',
107
+ '1.3',
108
+ '1.5',
109
+ '2.0'
110
+ ],
111
+ allowCustomSize: true,
99
112
  },
100
113
  fontsize: {
101
114
  sizeList: [
@@ -132,6 +145,7 @@ class WysiwigEditorComponent extends TsxComponent<WysiwigEditorArgs> implements
132
145
  'foreColor',
133
146
  'backColor',
134
147
  ],
148
+ ['lineheight'],
135
149
  ['link'],
136
150
  ['image'],
137
151
  ['emoji'],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.134",
4
+ "version": "0.0.136",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",