Skip to content

Commit 8a5d4a8

Browse files
committed
Fix clipboard copy bug. Catch up with Ivy version changes.
1 parent 4e2f9da commit 8a5d4a8

7 files changed

Lines changed: 67 additions & 10 deletions

File tree

projects/ng-widgets-showcase/src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="top-line">
33
<label [style.margin-right]="'1em'"><input type="checkbox"
44
[(ngModel)]="darkMode" (change)="settingsUpdated()">Dark mode</label>
5-
<tbw-angle-editor></tbw-angle-editor>
5+
<tbw-angle-editor [viewOnly]="viewOnly"></tbw-angle-editor>
66
<tbw-angle-editor [options]="{ angleStyle: DD_MM, compass: true }"></tbw-angle-editor>
77
<tbw-angle-editor [(ngModel)]="angle" [options]="{ compass: true, copyDecimal: true }"></tbw-angle-editor>
88
<tbw-angle-editor [(ngModel)]="angle" [options]="{ unsigned: true }"></tbw-angle-editor>

projects/ng-widgets-showcase/src/app/app.component.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22
import { DateAndTime, DateTime, newDateTimeFormat, Timezone, YMDDate } from '@tubular/time';
33
import { clone, isAndroid, isEqual, isIOS, isString, toBoolean, toNumber } from '@tubular/util';
4-
import { DateTimeStyle, HourStyle, TimeEditorOptions, YearStyle }
4+
import { DateTimeStyle, HourStyle, OPTIONS_ISO, OPTIONS_ISO_DATE, OPTIONS_ISO_TIME, TimeEditorOptions, YearStyle }
55
from '../../../tubular-ng-widgets/src/lib/time-editor/time-editor.component';
66
import { TimeEditorLimit } from '../../../tubular-ng-widgets/src/lib/time-editor/time-editor-limit';
77
import { AngleStyle } from '../../../tubular-ng-widgets/src/lib/angle-editor/angle-editor.component';
@@ -252,15 +252,32 @@ export class AppComponent {
252252
}
253253

254254
getOptions(): TimeEditorOptions {
255+
const style = toNumber(this.customStyle);
256+
let yearStyle = toNumber(this.yearStyle);
257+
258+
if (this.customLocale?.toLowerCase() === 'iso') {
259+
const options = clone(style === DateTimeStyle.DATE_ONLY ? OPTIONS_ISO_DATE :
260+
style === DateTimeStyle.TIME_ONLY ? OPTIONS_ISO_TIME : OPTIONS_ISO);
261+
262+
if (yearStyle === YearStyle.AD_BC)
263+
yearStyle = YearStyle.SIGNED;
264+
265+
return Object.assign(options, {
266+
millisDigits: this.millis,
267+
showSeconds: this.showSeconds,
268+
yearStyle
269+
});
270+
}
271+
255272
return {
256-
dateTimeStyle: toNumber(this.customStyle),
273+
dateTimeStyle: style,
257274
hourStyle: toNumber(this.customCycle),
258275
locale: this.customLocale,
259276
millisDigits: this.millis,
260277
numbering: this.numSystem || undefined,
261278
showSeconds: this.showSeconds,
262279
twoDigitYear: this.customYear ? toBoolean(this.customYear) : undefined,
263-
yearStyle: toNumber(this.yearStyle)
280+
yearStyle
264281
};
265282
}
266283

projects/tubular-ng-widgets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tubular/ng-widgets",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"peerDependencies": {
55
"@angular/common": "^12.0.0",
66
"@angular/core": "^12.0.0",

projects/tubular-ng-widgets/src/lib/angle-editor/angle-editor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ export class AngleEditorComponent extends DigitSequenceEditorDirective<number> i
544544
this._options.angleStyle === AngleStyle.DD || this._options.angleStyle === AngleStyle.DDD)
545545
return this.value.toString();
546546
else
547-
return this.items.map(item => item.value.toString()).join('');
547+
return this.items.map(item => (item.value ?? '').toString()).join('');
548548
}
549549

550550
private parseText(text: string): number {

projects/tubular-ng-widgets/src/lib/digit-sequence-editor/digit-sequence-editor.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ export abstract class DigitSequenceEditorDirective<T> implements
16191619
if (this.hiddenInput) {
16201620
const disabled = (this._floating || this._disabled || this._viewOnly || this._disableMobileKeyboard);
16211621
this.hiddenInput.setAttribute('tabindex', this.disabled ? '-1' : this.tabindex);
1622+
this.hiddenInput.inputMode = this.inputOff ? 'none' : this._fakeUrl ? 'url' : 'decimal';
16221623
this.hiddenInput.disabled = disabled;
16231624
this.hiddenInput.readOnly = disabled;
16241625
}

projects/tubular-ng-widgets/src/lib/shrink-wrap/shrink-wrap.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ export class ShrinkWrapComponent implements AfterViewInit, OnDestroy, OnInit {
164164
else {
165165
this.innerStyle = {
166166
transform: `scale(${this.scale})`,
167-
'transform-origin': 'top center',
167+
'transform-origin': 'top center', // eslint-disable-line @typescript-eslint/naming-convention
168168
margin: `0 ${this.marginX}px ${this.marginY}px ${this.marginX}px`,
169-
'max-width': `${scalingWidth}px`
169+
'max-width': `${scalingWidth}px` // eslint-disable-line @typescript-eslint/naming-convention
170170
};
171171
this.outerStyle.padding = '0.05px'; // prevents margin collapse
172172
}

projects/tubular-ng-widgets/src/lib/time-editor/time-editor.component.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,20 @@ export const OPTIONS_ISO_DATE: TimeEditorOptions = {
7979
twoDigitYear: false
8080
};
8181

82+
export const OPTIONS_ISO_TIME: TimeEditorOptions = {
83+
dateTimeStyle: DateTimeStyle.TIME_ONLY,
84+
decimal: '.',
85+
hourStyle: HourStyle.HOURS_24,
86+
numbering: 'latn',
87+
showSeconds: true,
88+
timeFieldSeparator: ':',
89+
};
90+
8291
const namedOptions: Record<string, TimeEditorOptions> = {
8392
date_only: OPTIONS_DATE_ONLY,
8493
iso: OPTIONS_ISO,
85-
iso_date: OPTIONS_ISO_DATE
94+
iso_date: OPTIONS_ISO_DATE,
95+
iso_time: OPTIONS_ISO_TIME
8696
};
8797

8898
type TimeFormat = 'date' | 'time' | 'datetime-local';
@@ -1395,8 +1405,37 @@ export class TimeEditorComponent extends DigitSequenceEditorDirective<number> im
13951405

13961406
if (newValue !== origValue || this.outOfRange) {
13971407
i[sel].value = newValue;
1408+
let wallTime = this.getWallTimeFromDigits();
1409+
1410+
if (this.yearIndex >= 0 &&
1411+
(sel === this.signIndex || (this.yearIndex <= sel && sel < this.yearIndex + this.yearDigits))) {
1412+
const yi = this.yearIndex;
1413+
const yd = this.yearDigits;
1414+
const len = sel - yi + 2;
1415+
const yv = this.getDigits(yi, yd);
1416+
const yp = ((yv >= 0 ? '+' : '-') + abs(yv).toString().padStart(yd, '0')).substring(0, len);
1417+
let yearTarget: number;
1418+
let timeTarget: number | DateAndTime;
1419+
1420+
if (this.minLimit.year != null && wallTime.y < this.minLimit.year) {
1421+
yearTarget = this.minLimit.year;
1422+
timeTarget = this.minLimit.wallTime ?? this.minLimit.utc;
1423+
}
1424+
else if (this.maxLimit.year != null && wallTime.y > this.maxLimit.year) {
1425+
yearTarget = this.maxLimit.year;
1426+
timeTarget = this.maxLimit.wallTime ?? this.maxLimit.utc;
1427+
}
1428+
1429+
if (yearTarget != null) {
1430+
const tp = ((yearTarget >= 0 ? '+' : '-') + abs(yearTarget).toString().padStart(yd, '0')).substring(0, len);
1431+
1432+
if (yp === tp) {
1433+
this.updateDigits(new DateTime(timeTarget, this.timezone));
1434+
wallTime = this.getWallTimeFromDigits();
1435+
}
1436+
}
1437+
}
13981438

1399-
const wallTime = this.getWallTimeFromDigits();
14001439
const wasLeap = (this._tai && wallTime.sec >= 60);
14011440
let extraSec = (wasLeap ? 1 : 0);
14021441

0 commit comments

Comments
 (0)