inviton-powerduck 0.0.183 → 0.0.184

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.
@@ -68,7 +68,31 @@ function fromDateImpl(this: typeof Temporal.PlainDateTime, date: Date): Temporal
68
68
 
69
69
  export const utcEpochMilliseconds = Symbol('utcEpochMilliseconds');
70
70
  function utcEpochMillisecondsImpl(this: Temporal.PlainDateTime): number {
71
- return this.toZonedDateTime('UTC').epochMilliseconds;
71
+ if (this == null) {
72
+ return null;
73
+ }
74
+
75
+ let y = this.year;
76
+ let m = this.month;
77
+ if (m <= 2) {
78
+ y -= 1;
79
+ m += 12;
80
+ }
81
+
82
+ // Algorithm from Howard Hinnant's civil date conversion
83
+ const era = Math.floor(y / 400);
84
+ const yoe = y - era * 400;
85
+ const doy = Math.floor((153 * (m - 3) + 2) / 5) + this.day - 1;
86
+ const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
87
+ const daysSinceEpoch = era * 146097 + doe - 719468;
88
+
89
+ const msOfDay
90
+ = this.hour * 3_600_000
91
+ + this.minute * 60_000
92
+ + this.second * 1_000
93
+ + (this.millisecond ?? 0);
94
+
95
+ return daysSinceEpoch * 86_400_000 + msOfDay;
72
96
  }
73
97
 
74
98
  export const toJsDate = Symbol('toJsDate');
@@ -38,6 +38,43 @@ export default class TemporalUtils {
38
38
  }
39
39
 
40
40
  static fromEpochMs(val: number): Temporal.PlainDateTime {
41
- return Temporal.Instant.fromEpochMilliseconds(val).toZonedDateTimeISO('UTC').toPlainDateTime();
41
+ const MS_PER_DAY = 86_400_000;
42
+
43
+ let daysSinceEpoch = Math.floor(val / MS_PER_DAY);
44
+ let msInDay = val - daysSinceEpoch * MS_PER_DAY;
45
+ if (msInDay < 0) {
46
+ msInDay += MS_PER_DAY;
47
+ daysSinceEpoch -= 1;
48
+ }
49
+
50
+ // Convert daysSinceEpoch → Y-M-D
51
+ const z = daysSinceEpoch + 719468;
52
+ const era = Math.floor(z / 146097);
53
+ const doe = z - era * 146097;
54
+ const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);
55
+ const y = yoe + era * 400;
56
+ const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
57
+ const mp = Math.floor((5 * doy + 2) / 153);
58
+ const day = doy - Math.floor((153 * mp + 2) / 5) + 1;
59
+ const month = mp + (mp < 10 ? 3 : -9);
60
+ const year = y + (month <= 2 ? 1 : 0);
61
+
62
+ // Compute time from milliseconds in day
63
+ const hour = Math.floor(msInDay / 3_600_000);
64
+ const minute = Math.floor((msInDay % 3_600_000) / 60_000);
65
+ const second = Math.floor((msInDay % 60_000) / 1000);
66
+ const millisecond = msInDay % 1000;
67
+
68
+ return new Temporal.PlainDateTime(
69
+ year,
70
+ month,
71
+ day,
72
+ hour,
73
+ minute,
74
+ second,
75
+ millisecond,
76
+ 0,
77
+ 0,
78
+ );
42
79
  }
43
80
  }
@@ -1,9 +1,9 @@
1
1
  import type { DropdownButtonItemArgs } from '../dropdown-button/dropdown-button-item';
2
2
  import type { FormItemWrapperArgs, MarginType } from '../form/form-item-wrapper';
3
- import { globalState } from '../../app/global-state';
4
3
  import Sortable from 'sortablejs';
5
4
  import { h as _h, h, render, VNodeChild } from 'vue';
6
5
  import { Prop, toNative } from 'vue-facing-decorator';
6
+ import { globalState } from '../../app/global-state';
7
7
  import PowerduckState from '../../app/powerduck-state';
8
8
  import TsxComponent, { Component } from '../../app/vuetsx';
9
9
  import { remove } from '../../common/extensions/array-extensions';
@@ -327,16 +327,30 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
327
327
  return retArr;
328
328
  }
329
329
 
330
- getMobileSelectionText(): string {
330
+ getMobileSelectionText(): { text: string; placeholder: boolean } {
331
331
  const opts = this.getOptions();
332
332
  const selectedItems = this.getSelectedItems();
333
333
 
334
334
  if (selectedItems.length > 2 || (this.mobileShortMode == true && selectedItems.length > 0)) {
335
- return PowerduckState.getResourceValue('itemsOutOfArray').replace('{0}', selectedItems.length.toString()).replace('{1}', opts.length.toString());
335
+ return {
336
+ text: PowerduckState.getResourceValue('itemsOutOfArray').replace('{0}', selectedItems.length.toString()).replace('{1}', opts.length.toString()),
337
+ placeholder: false,
338
+ };
336
339
  } else if (selectedItems.length == 1) {
337
- return selectedItems[0].text;
340
+ return {
341
+ placeholder: false,
342
+ text: selectedItems[0].text,
343
+ };
344
+ } else if ((selectedItems == null || selectedItems.length == 0) && this.placeholder?.length > 0) {
345
+ return {
346
+ placeholder: true,
347
+ text: this.placeholder,
348
+ };
338
349
  } else {
339
- return selectedItems.map(p => p.text).join(', ');
350
+ return {
351
+ placeholder: false,
352
+ text: selectedItems.map(p => p.text).join(', '),
353
+ };
340
354
  }
341
355
  }
342
356
 
@@ -418,21 +432,14 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
418
432
  }
419
433
 
420
434
  renderMobileComponent(h) {
421
- let selectedText = this.getMobileSelectionText();
422
- if (selectedText == null || selectedText.length == 0) {
423
- selectedText = this.placeholder || '';
424
- }
425
-
426
- if (isNullOrEmpty(selectedText) && this.multiselect == true) {
427
- selectedText = `[${PowerduckState.getResourceValue('all')}]`;
428
- }
435
+ const selText = this.getMobileSelectionText();
429
436
 
430
437
  return (
431
438
  <span ref="mobileModeRoot" onClick={e => this.showMobilePicker(h)} class={`select2 select2-container select2-container--default s2-pseudo maxwidth-input ${this.getRootBaseCssClass()}`} dir="ltr">
432
439
  <span class="selection">
433
440
  <span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true">
434
- <span class="select2-selection__rendered mbl-ddl-text" title={selectedText} style="font-size: inherit;">
435
- {selectedText}
441
+ <span class={`select2-selection__rendered mbl-ddl-text ${selText.placeholder ? 'mbl-ddl-placeholder' : 'mbl-ddl-selval'}`} title={selText.text} style="font-size: inherit;">
442
+ {selText.text}
436
443
  </span>
437
444
  <span class="select2-selection__arrow" role="presentation">
438
445
  <b role="presentation"></b>
@@ -449,10 +456,10 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
449
456
  const self = this;
450
457
  return (row) => {
451
458
  const retVal = $(`<span class="s2-ri-withtb">${row.text
452
- }<button class="s2-trailing-button ${self.trailingButton.cssClass || ''
453
- } btn-sm">${self.trailingButton.icon != null ? `<i class="${self.trailingButton.icon}"></i> ` : ''
454
- }${self.trailingButton.text || ''
455
- }</button></span>`);
459
+ }<button class="s2-trailing-button ${self.trailingButton.cssClass || ''
460
+ } btn-sm">${self.trailingButton.icon != null ? `<i class="${self.trailingButton.icon}"></i> ` : ''
461
+ }${self.trailingButton.text || ''
462
+ }</button></span>`);
456
463
  retVal.find('button').click((e) => {
457
464
  try {
458
465
  clearTimeout(self.preventDefaultTimeout);
@@ -543,10 +550,10 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
543
550
  useListviewBuilder: false,
544
551
  formatSelection: this.customRenderSelectionResult != null
545
552
  ? this.handleCustomRenderResult(
546
- h,
547
- this.customRenderSelectionResult,
548
- 'mobile',
549
- )
553
+ h,
554
+ this.customRenderSelectionResult,
555
+ 'mobile',
556
+ )
550
557
  : null,
551
558
  formatResult: this.getCustomFormatOptions(h, 'mobile'),
552
559
  onItemSelected: (items, exclusivity) => {
@@ -566,16 +573,17 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
566
573
 
567
574
  setMobilePickerInputText(h: any, items: DropdownDisplayArgs[]): void {
568
575
  this.$nextTick(() => {
569
- let selectedText = this.getMobileSelectionText();
576
+ const textVal = this.getMobileSelectionText();
570
577
  const textContext = $(this.$el).find('.mbl-ddl-text') as any;
571
- const isPlaceholder = (items || []).length == 0;
572
-
573
- if (isNullOrEmpty(selectedText)) {
574
- selectedText = this.placeholder;
575
- }
578
+ const isPlaceholder = textVal.placeholder;
579
+ const selectedText = textVal.text;
576
580
 
577
- if (isNullOrEmpty(selectedText) && this.multiselect == true) {
578
- selectedText = `[${PowerduckState.getResourceValue('all')}]`;
581
+ if (isPlaceholder) {
582
+ textContext.text(selectedText);
583
+ textContext.addClass('mbl-ddl-placeholder').removeClass('mbl-ddl-selval');
584
+ return;
585
+ } else {
586
+ textContext.removeClass('mbl-ddl-placeholder').addClass('mbl-ddl-selval');
579
587
  }
580
588
 
581
589
  if (this.customRenderSelectionResult == null) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.183",
4
+ "version": "0.0.184",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",