@ekzo-dev/bootstrap-addons 5.2.18 → 5.2.19
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekzo-dev/bootstrap-addons",
|
|
3
3
|
"description": "Aurelia Bootstrap additional component",
|
|
4
|
-
"version": "5.2.
|
|
4
|
+
"version": "5.2.19",
|
|
5
5
|
"homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/bootstrap-addons",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,6 +9,21 @@ bs-duration-input {
|
|
|
9
9
|
|
|
10
10
|
fieldset {
|
|
11
11
|
position: relative;
|
|
12
|
+
|
|
13
|
+
// Customize the `:focus` state to imitate native WebKit styles.
|
|
14
|
+
&:focus-within {
|
|
15
|
+
color: $input-focus-color;
|
|
16
|
+
background-color: $input-focus-bg;
|
|
17
|
+
border-color: $input-focus-border-color;
|
|
18
|
+
outline: 0;
|
|
19
|
+
|
|
20
|
+
@if $enable-shadows {
|
|
21
|
+
@include box-shadow($input-box-shadow, $input-focus-box-shadow);
|
|
22
|
+
} @else {
|
|
23
|
+
// Avoid using mixin so we can pass custom focus shadow properly
|
|
24
|
+
box-shadow: $input-focus-box-shadow;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
input[type='number'] {
|
|
@@ -37,6 +52,18 @@ bs-duration-input {
|
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
|
|
55
|
+
.was-validated bs-duration-input {
|
|
56
|
+
.form-control:invalid:focus-within,
|
|
57
|
+
.form-control.is-invalid:focus-within {
|
|
58
|
+
box-shadow: 0 0 0 0.25rem rgb(220 53 69 / 25%);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.form-control:valid:focus-within,
|
|
62
|
+
.form-control.is-valid:focus-within {
|
|
63
|
+
box-shadow: 0 0 0 0.25rem rgb(25 135 84 / 25%);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
40
67
|
@supports not (field-sizing: content) {
|
|
41
68
|
bs-duration-input {
|
|
42
69
|
input[type='number'] {
|
|
@@ -6,7 +6,7 @@ import '@formatjs/intl-durationformat/polyfill';
|
|
|
6
6
|
|
|
7
7
|
import { BaseField, Size } from '@ekzo-dev/bootstrap';
|
|
8
8
|
import { coerceBoolean } from '@ekzo-dev/toolkit';
|
|
9
|
-
import { bindable, BindingMode, customElement } from 'aurelia';
|
|
9
|
+
import { bindable, BindingMode, customElement, resolve } from 'aurelia';
|
|
10
10
|
|
|
11
11
|
interface IDuration {
|
|
12
12
|
years?: string;
|
|
@@ -21,7 +21,7 @@ interface IDuration {
|
|
|
21
21
|
name: 'bs-duration-input',
|
|
22
22
|
template,
|
|
23
23
|
})
|
|
24
|
-
export class BsDurationInput extends BaseField {
|
|
24
|
+
export class BsDurationInput extends BaseField implements EventListenerObject {
|
|
25
25
|
@bindable({ mode: BindingMode.twoWay })
|
|
26
26
|
get value(): string {
|
|
27
27
|
const { years, months, days, hours, minutes, seconds } = this.duration;
|
|
@@ -32,20 +32,7 @@ export class BsDurationInput extends BaseField {
|
|
|
32
32
|
return date || time ? `P${date}${time ? 'T' + time : ''}` : '';
|
|
33
33
|
}
|
|
34
34
|
set value(value: string | null | undefined) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (match) {
|
|
38
|
-
this.duration = {
|
|
39
|
-
years: match[1],
|
|
40
|
-
months: match[2],
|
|
41
|
-
days: match[3],
|
|
42
|
-
hours: match[4],
|
|
43
|
-
minutes: match[5],
|
|
44
|
-
seconds: match[6],
|
|
45
|
-
};
|
|
46
|
-
} else {
|
|
47
|
-
this.duration = {};
|
|
48
|
-
}
|
|
35
|
+
this.parseDuration(value);
|
|
49
36
|
}
|
|
50
37
|
|
|
51
38
|
@bindable()
|
|
@@ -54,10 +41,14 @@ export class BsDurationInput extends BaseField {
|
|
|
54
41
|
@bindable(coerceBoolean)
|
|
55
42
|
floatingLabel: boolean = false;
|
|
56
43
|
|
|
44
|
+
readonly host = resolve(HTMLElement);
|
|
45
|
+
|
|
57
46
|
duration: IDuration = {};
|
|
58
47
|
|
|
59
48
|
labels: IDuration = this.#getLabels();
|
|
60
49
|
|
|
50
|
+
controls!: NodeListOf<HTMLInputElement>;
|
|
51
|
+
|
|
61
52
|
get classes(): string {
|
|
62
53
|
return [
|
|
63
54
|
'form-control',
|
|
@@ -69,6 +60,52 @@ export class BsDurationInput extends BaseField {
|
|
|
69
60
|
.join(' ');
|
|
70
61
|
}
|
|
71
62
|
|
|
63
|
+
attaching() {
|
|
64
|
+
this.controls = this.host.querySelectorAll('input[type=number]');
|
|
65
|
+
this.controls.forEach((control) => {
|
|
66
|
+
control.addEventListener('keypress', this);
|
|
67
|
+
control.addEventListener('paste', this);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
detached() {
|
|
72
|
+
this.controls.forEach((control) => {
|
|
73
|
+
control.removeEventListener('keypress', this);
|
|
74
|
+
control.removeEventListener('paste', this);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
handleEvent(event: KeyboardEvent | ClipboardEvent): void {
|
|
79
|
+
const data = event instanceof KeyboardEvent ? event.key : event.clipboardData.getData('text');
|
|
80
|
+
|
|
81
|
+
// don't allow non-numeric values
|
|
82
|
+
if (!/^\d+$/.test(data)) {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// allow pasting full duration value, e.g. P2YT2H
|
|
87
|
+
if (event instanceof ClipboardEvent && data.startsWith('P')) {
|
|
88
|
+
this.parseDuration(data);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private parseDuration(value: string) {
|
|
93
|
+
const match = value?.match(/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/);
|
|
94
|
+
|
|
95
|
+
if (match) {
|
|
96
|
+
this.duration = {
|
|
97
|
+
years: match[1],
|
|
98
|
+
months: match[2],
|
|
99
|
+
days: match[3],
|
|
100
|
+
hours: match[4],
|
|
101
|
+
minutes: match[5],
|
|
102
|
+
seconds: match[6],
|
|
103
|
+
};
|
|
104
|
+
} else {
|
|
105
|
+
this.duration = {};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
72
109
|
#getLabels(): IDuration {
|
|
73
110
|
const str: string = new Intl['DurationFormat'](navigator.language, { style: 'narrow' }).format({
|
|
74
111
|
years: 1,
|