@ekzo-dev/bootstrap-addons 5.3.17 → 5.3.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.3.17",
4
+ "version": "5.3.19",
5
5
  "homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/bootstrap-addons",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,6 +12,8 @@ type DurationLabels = {
12
12
  [K in keyof Duration]: string;
13
13
  };
14
14
 
15
+ const durationKeys = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'] as const;
16
+
15
17
  /**
16
18
  * https://github.com/whatwg/html/issues/5488
17
19
  * https://github.com/tc39/proposal-intl-duration-format
@@ -25,7 +27,7 @@ export class BsDurationInput extends BaseField implements EventListenerObject {
25
27
  get value(): string {
26
28
  const { duration } = this;
27
29
 
28
- if (Object.values(duration).every((v) => v == null || v.toString() === '')) {
30
+ if (durationKeys.every((v) => duration[v] == null || duration[v].toString() === '')) {
29
31
  return '';
30
32
  }
31
33
 
@@ -99,15 +101,12 @@ export class BsDurationInput extends BaseField implements EventListenerObject {
99
101
  private _parseDuration(value: string) {
100
102
  try {
101
103
  const duration = Temporal.Duration.from(value);
104
+ const result = {};
102
105
 
103
- this.duration = {
104
- years: duration.years,
105
- months: duration.months,
106
- days: duration.days,
107
- hours: duration.hours,
108
- minutes: duration.minutes,
109
- seconds: duration.seconds,
110
- };
106
+ durationKeys.forEach((key) => {
107
+ result[key] = duration[key] ? duration[key].toString() : '';
108
+ });
109
+ this.duration = result;
111
110
  } catch (error) {
112
111
  if (error instanceof RangeError) {
113
112
  console.warn(`[bs-duration-input] ${error.message}`);