@ekzo-dev/bootstrap-addons 5.3.20 → 5.3.22

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/README.md CHANGED
@@ -1,181 +1,95 @@
1
- # `ui-utils`
1
+ # @ekzo-dev/bootstrap-addons
2
2
 
3
- This project is bootstrapped by [aurelia-cli](https://github.com/aurelia/cli).
3
+ Additional Bootstrap form components for Aurelia 2 applications.
4
4
 
5
- This Aurelia plugin project has a built-in dev app (with CLI built-in bundler and RequireJS) to simplify development.
5
+ This package extends [@ekzo-dev/bootstrap](https://github.com/ekzo-dev/aurelia-components/tree/main/packages-adapters/bootstrap) with advanced form components that provide enhanced functionality beyond the standard Bootstrap form controls.
6
6
 
7
- 1. The local `src/` folder, is the source code for the plugin.
8
- 2. The local `dev-app/` folder, is the code for the dev app, just like a normal app bootstrapped by aurelia-cli.
9
- 3. You can use normal `au run` and `au test` in development just like developing an app.
10
- 4. You can use aurelia-testing to test your plugin, just like developing an app.
11
- 5. To ensure compatibility to other apps, always use `PLATFORM.moduleName()` wrapper in files inside `src/`. You don't need to use the wrapper in `dev-app/` folder as CLI built-in bundler supports module name without the wrapper.
7
+ ## Installation
12
8
 
13
- Note aurelia-cli doesn't provide a plugin skeleton with Webpack setup (not yet), but this plugin can be consumed by any app using Webpack, or CLI built-in bundler, or jspm.
14
-
15
- ## How to write an Aurelia plugin
16
-
17
- For a full length tutorial, visit [Aurelia plugin guide](https://aurelia.io/docs/plugins/write-new-plugin).
18
-
19
- Here is some basics. You can create new custom element, custom attribute, value converter or binding behavior manually, or use command `au generate` to help.
20
-
21
- ```shell
22
- au generate element some-name
23
- au generate attribute some-name
24
- au generate value-converter some-name
25
- au generate binding-behavior some-name
9
+ ```bash
10
+ npm install @ekzo-dev/bootstrap-addons
26
11
  ```
27
12
 
28
- By default, the cli generates command generates files in following folders:
29
-
30
- ```
31
- src/elements
32
- src/attributes
33
- src/value-converters
34
- src/binding-behaviors
35
- ```
36
-
37
- Note the folder structure is only to help you organising the files, it's not a requirement of Aurelia. You can manually create new element (or other thing) anywhere in `src/`.
38
-
39
- After you added some new file, you need to register it in `src/index.ts`. Like this:
40
-
41
- ```js
42
- config.globalResources([
43
- // ...
44
- PLATFORM.moduleName('./path/to/new-file-without-ext'),
45
- ]);
46
- ```
47
-
48
- The usage of `PLATFORM.moduleName` wrapper is mandatory. It's needed for your plugin to be consumed by any app using webpack, CLI built-in bundler, or jspm.
49
-
50
- ## Resource import within the dev app
51
-
52
- In dev app, when you need to import something from the inner plugin (for example, importing a class for dependency injection), use special name `"resources"` to reference the inner plugin.
53
-
54
- ```js
55
- import {autoinject} from 'aurelia-framework';
56
- // "resources" refers the inner plugin src/index.ts
57
- import {MyService} from 'resources';
58
-
59
- @autoinject()
60
- export class App {
61
- constructor(myService: MyService) {}
62
- }
63
- ```
64
-
65
- ## Manage dependencies
66
-
67
- By default, this plugin has no "dependencies" in package.json. Theoretically this plugin depends on at least `aurelia-pal` because `src/index.ts` imports it. It could also depends on more core Aurelia package like `aurelia-binding` or `aurelia-templating` if you build advanced components that reference them.
68
-
69
- Ideally you need to carefully add those `aurelia-pal` (`aurelia-binding`...) to "dependencies" in package.json. But in practice you don't have to. Because every app that consumes this plugin will have full Aurelia core packages installed.
70
-
71
- Furthermore, there are two benefits by leaving those dependencies out of plugin's package.json.
13
+ ### Peer Dependencies
72
14
 
73
- 1. ensure this plugin doesn't bring in a duplicated Aurelia core package to consumers' app. This is mainly for app built with webpack. We had been hit with `aurelia-binding` v1 and v2 conflicts due to 3rd party plugin asks for `aurelia-binding` v1.
74
- 2. reduce the burden for npm/yarn when installing this plugin.
15
+ This package requires the following peer dependencies:
75
16
 
76
- If you are a perfectionist who could not stand leaving out dependencies, I recommend you to add `aurelia-pal` (`aurelia-binding`...) to "peerDependencies" in package.json. So at least it could not cause a duplicated Aurelia core package.
17
+ - `aurelia` ^2.0.0
18
+ - `bootstrap` ~5.3.7
19
+ - `@popperjs/core` ^2.11.8
20
+ - `vanilla-jsoneditor` ~3.11.0
21
+ - `immutable-json-patch` ^6.0.1
77
22
 
78
- If your plugin depends on other npm package, like `lodash` or `jquery`, **you have to add them to "dependencies" in package.json**.
23
+ ## Usage
79
24
 
80
- ## Build Plugin
25
+ Register the plugin in your Aurelia application:
81
26
 
82
- Run `au build-plugin`. This will transpile all files from `src/` folder to `dist/native-modules/` and `dist/commonjs/`.
27
+ ```typescript
28
+ import Aurelia from 'aurelia';
29
+ import { BootstrapAddonsConfiguration } from '@ekzo-dev/bootstrap-addons';
83
30
 
84
- For example, `src/index.ts` will become `dist/native-modules/index.js` and `dist/commonjs/index.js`.
85
-
86
- Note all other files in `dev-app/` folder are for the dev app, they would not appear in the published npm package.
87
-
88
- ## Consume Plugin
89
-
90
- By default, the `dist/` folder is not committed to git. (We have `/dist` in `.gitignore`). But that would not prevent you from consuming this plugin through direct git reference.
91
-
92
- You can consume this plugin directly by:
93
-
94
- ```shell
95
- npm i github:your_github_username/ui-utils
96
- # or if you use bitbucket
97
- npm i bitbucket:your_github_username/ui-utils
98
- # or if you use gitlab
99
- npm i gitlab:your_github_username/ui-utils
100
- # or plain url
101
- npm i https:/github.com/your_github_username/ui-utils.git
31
+ Aurelia
32
+ .register(BootstrapAddonsConfiguration)
33
+ .app(MyApp)
34
+ .start();
102
35
  ```
103
36
 
104
- Then load the plugin in app's `main.ts` like this.
37
+ ## Components
105
38
 
106
- ```js
107
- aurelia.use.plugin('ui-utils');
108
- // for webpack user, use PLATFORM.moduleName wrapper
109
- aurelia.use.plugin(PLATFORM.moduleName('ui-utils'));
110
- ```
39
+ | Component | Description | Documentation |
40
+ |-----------|-------------|---------------|
41
+ | **Duration Input** | Form control for entering time durations in ISO 8601 format | [View docs](./src/forms/duration-input/README.md) |
42
+ | **Select Dropdown** | Enhanced select component with improved styling and functionality | [View docs](./src/forms/select-dropdown/README.md) |
111
43
 
112
- The missing `dist/` files will be filled up by npm through `"prepare": "npm run build"` (in `"scripts"` section of package.json).
44
+ ## Quick Examples
113
45
 
114
- Yarn has a [bug](https://github.com/yarnpkg/yarn/issues/5235) that ignores `"prepare"` script. If you want to use yarn to consume your plugin through direct git reference, remove `/dist` from `.gitignore` and commit all the files. Note you don't need to commit `dist/` files if you only use yarn to consume this plugin through published npm package (`npm i ui-utils`).
46
+ ### Duration Input
115
47
 
116
- ## Publish npm package
117
-
118
- By default, `"private"` field in package.json has been turned on, this prevents you from accidentally publish a private plugin to npm.
119
-
120
- To publish the plugin to npm for public consumption:
121
-
122
- 1. Remove `"private": true,` from package.json.
123
- 2. Pump up project version. This will run through `au test` (in "preversion" in package.json) first.
124
-
125
- ```shell
126
- npm version patch # or minor or major
48
+ ```html
49
+ <bs-duration-input
50
+ value.bind="duration"
51
+ label="Duration"
52
+ required.bind="true"
53
+ ></bs-duration-input>
127
54
  ```
128
55
 
129
- 3. Push up changes to your git server
56
+ ### Select Dropdown
130
57
 
131
- ```shell
132
- git push && git push --tags
58
+ ```html
59
+ <bs-select-dropdown
60
+ value.bind="selectedValue"
61
+ options.bind="countries"
62
+ label="Country"
63
+ ></bs-select-dropdown>
133
64
  ```
134
65
 
135
- 4. Then publish to npm, you need to have your npm account logged in.
136
-
137
- ```shell
138
- npm publish
139
- ```
140
-
141
- ## Automate changelog, git push, and npm publish
142
-
143
- You can enable `npm version patch # or minor or major` to automatically update changelog, push commits and version tag to the git server, and publish to npm.
144
-
145
- Here is one simple setup.
146
-
147
- 1. `npm i -D standard-changelog`. We use [`standard-changelog`](https://github.com/conventional-changelog/conventional-changelog) as a minimum example to support conventional changelog.
148
-
149
- - Alternatively you can use high level [standard-version](https://github.com/conventional-changelog/standard-version).
150
-
151
- 2. Add two commands to `"scripts"` section of package.json.
152
-
153
- ```
154
- "scripts": {
155
- // ...
156
- "version": "standard-changelog && git add CHANGELOG.md",
157
- "postversion": "git push && git push --tags && npm publish"
158
- },
159
- ```
66
+ ## Dependencies
160
67
 
161
- 3. you can remove `&& npm publish` if your project is private
68
+ This package uses:
162
69
 
163
- For more information, go to https://aurelia.io/docs/cli/cli-bundler
70
+ - **@ekzo-dev/bootstrap** - Core Bootstrap components for Aurelia 2
71
+ - **@ekzo-dev/toolkit** - Utility functions and helpers
72
+ - **@js-temporal/polyfill** - Temporal API polyfill for date/time handling
164
73
 
165
- ## Run dev app
74
+ ## Browser Support
166
75
 
167
- Run `au run`, then open `http://localhost:9000`
76
+ This package supports all modern browsers that support ES2015+ and the following features:
168
77
 
169
- To open browser automatically, do `au run --open`.
78
+ - Custom Elements (Web Components)
79
+ - ES Modules
80
+ - Temporal API (polyfilled)
170
81
 
171
- To change dev server port, do `au run --port 8888`.
82
+ ## Contributing
172
83
 
173
- To change dev server host, do `au run --host 127.0.0.1`
84
+ Contributions are welcome! Please read the [contributing guidelines](https://github.com/ekzo-dev/aurelia-components/blob/main/CONTRIBUTING.md) first.
174
85
 
175
- **PS:** You could mix all the flags as well, `au run --host 127.0.0.1 --port 7070 --open`
86
+ ## License
176
87
 
177
- ## Unit tests
88
+ MIT © [Ekzo](https://github.com/ekzo-dev)
178
89
 
179
- Run `au test` (or `au jest`).
90
+ ## Links
180
91
 
181
- To run in watch mode, `au test --watch` or `au jest --watch`.
92
+ - [GitHub Repository](https://github.com/ekzo-dev/aurelia-components)
93
+ - [Issue Tracker](https://github.com/ekzo-dev/aurelia-components/issues)
94
+ - [Aurelia 2 Documentation](https://docs.aurelia.io)
95
+ - [Bootstrap 5 Documentation](https://getbootstrap.com/docs/5.3/)
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.20",
4
+ "version": "5.3.22",
5
5
  "homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/bootstrap-addons",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,22 +9,14 @@
9
9
  },
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@ekzo-dev/bootstrap": "~5.3.6",
13
- "@ekzo-dev/vanilla-jsoneditor": "~3.11.0",
12
+ "@ekzo-dev/bootstrap": "~5.3.9",
14
13
  "@ekzo-dev/toolkit": "^1.3.0",
15
- "@fortawesome/free-solid-svg-icons": "^7.0.1",
16
- "@types/json-schema": "^7.0.14",
17
- "@js-temporal/polyfill": "^0.5.1",
18
- "ajv": "^8.17.1",
19
- "ajv-formats": "^3.0.1",
20
- "json-schema-library": "^11.0.0"
14
+ "@js-temporal/polyfill": "^0.5.1"
21
15
  },
22
16
  "peerDependencies": {
23
17
  "aurelia": "^2.0.0-rc.0",
24
18
  "bootstrap": "~5.3.7",
25
- "@popperjs/core": "^2.11.8",
26
- "vanilla-jsoneditor": "~3.11.0",
27
- "immutable-json-patch": "^6.0.1"
19
+ "@popperjs/core": "^2.11.8"
28
20
  },
29
21
  "main": "src/index.ts",
30
22
  "files": [
@@ -0,0 +1,153 @@
1
+ # Duration Input
2
+
3
+ A form control for entering time durations in ISO 8601 format.
4
+
5
+ ## Overview
6
+
7
+ The Duration Input component allows users to input time durations using separate fields for days, hours, minutes, and seconds. The component automatically converts the input to ISO 8601 duration format (e.g., `P5DT1H` for 5 days and 1 hour).
8
+
9
+ ## Features
10
+
11
+ - ISO 8601 duration format support
12
+ - Separate inputs for days, hours, minutes, seconds
13
+ - Integration with Bootstrap form validation
14
+ - Floating label support
15
+ - Size variants (sm, lg)
16
+ - Full Bootstrap styling
17
+ - Inherits all BaseField functionality
18
+
19
+ ## Basic Usage
20
+
21
+ ```html
22
+ <bs-duration-input
23
+ value.bind="duration"
24
+ label="Duration"
25
+ ></bs-duration-input>
26
+ ```
27
+
28
+ ```typescript
29
+ export class MyComponent {
30
+ duration = 'P5DT1H30M'; // 5 days, 1 hour, 30 minutes
31
+ }
32
+ ```
33
+
34
+ ## Examples
35
+
36
+ ### With Validation
37
+
38
+ ```html
39
+ <bs-duration-input
40
+ value.bind="duration"
41
+ label="Task Duration"
42
+ required.bind="true"
43
+ invalid-feedback="Please enter a duration"
44
+ ></bs-duration-input>
45
+ ```
46
+
47
+ ### With Floating Label
48
+
49
+ ```html
50
+ <bs-duration-input
51
+ value.bind="duration"
52
+ label="Duration"
53
+ floating-label.bind="true"
54
+ bs-size="lg"
55
+ ></bs-duration-input>
56
+ ```
57
+
58
+ ### Custom Validation
59
+
60
+ ```html
61
+ <bs-duration-input
62
+ value.bind="duration"
63
+ label="Duration"
64
+ valid.bind="isValid"
65
+ valid-feedback="Duration is valid"
66
+ invalid-feedback="Duration must be at least 1 hour"
67
+ ></bs-duration-input>
68
+ ```
69
+
70
+ ```typescript
71
+ export class MyComponent {
72
+ duration = '';
73
+
74
+ get isValid() {
75
+ if (!this.duration) return undefined;
76
+ // Check if duration is at least 1 hour
77
+ const match = this.duration.match(/PT(\d+)H/);
78
+ return match && parseInt(match[1]) >= 1;
79
+ }
80
+ }
81
+ ```
82
+
83
+ ## Bindable Properties
84
+
85
+ | Property | Type | Default | Description |
86
+ |----------|------|---------|-------------|
87
+ | `value` | `string` | - | Two-way bound ISO 8601 duration string (e.g., `P5DT1H30M`) |
88
+ | `bsSize` | `'sm' \| 'lg'` | - | Bootstrap size variant |
89
+ | `floatingLabel` | `boolean` | `false` | Enable floating label style |
90
+
91
+ ### Inherited from BaseField
92
+
93
+ | Property | Type | Default | Description |
94
+ |----------|------|---------|-------------|
95
+ | `name` | `string` | - | Input name attribute |
96
+ | `label` | `string` | - | Label text |
97
+ | `title` | `string` | - | Title attribute |
98
+ | `disabled` | `boolean` | `false` | Disable the input |
99
+ | `required` | `boolean` | `false` | Mark as required |
100
+ | `valid` | `boolean` | - | Validation state (undefined = not validated, true = valid, false = invalid) |
101
+ | `validFeedback` | `string` | - | Valid feedback message |
102
+ | `invalidFeedback` | `string` | - | Invalid feedback message |
103
+ | `form` | `string` | - | Associated form id |
104
+ | `text` | `string \| HTMLElement` | - | Helper text displayed below the input |
105
+
106
+ ## ISO 8601 Duration Format
107
+
108
+ The component uses ISO 8601 duration format:
109
+
110
+ - `P` - Period designator (required)
111
+ - `nD` - Number of days
112
+ - `T` - Time designator (required if hours/minutes/seconds are present)
113
+ - `nH` - Number of hours
114
+ - `nM` - Number of minutes
115
+ - `nS` - Number of seconds
116
+
117
+ ### Examples
118
+
119
+ - `P5D` - 5 days
120
+ - `PT2H` - 2 hours
121
+ - `PT30M` - 30 minutes
122
+ - `P1DT6H30M` - 1 day, 6 hours, 30 minutes
123
+ - `PT1H30M45S` - 1 hour, 30 minutes, 45 seconds
124
+
125
+ ## Styling
126
+
127
+ The component uses standard Bootstrap form control classes and can be styled using Bootstrap utilities:
128
+
129
+ ```html
130
+ <bs-duration-input
131
+ value.bind="duration"
132
+ label="Duration"
133
+ class="mb-3"
134
+ bs-size="sm"
135
+ ></bs-duration-input>
136
+ ```
137
+
138
+ ## Accessibility
139
+
140
+ The component follows accessibility best practices:
141
+
142
+ - Proper label association
143
+ - ARIA attributes for validation states
144
+ - Keyboard navigation support
145
+ - Screen reader friendly
146
+
147
+ ## Browser Support
148
+
149
+ Requires browsers that support:
150
+
151
+ - ES2015+
152
+ - Custom Elements
153
+ - Temporal API (polyfilled)
@@ -1,7 +1,7 @@
1
1
  <template class="${floatingLabel ? 'form-floating' : ''}">
2
2
  <label for.one-time="id" if.bind="label && !floatingLabel" class="form-label">${label}</label>
3
3
  <fieldset class="${classes}" disabled.bind="disabled">
4
- <input type="text" id.one-time="id" value.bind="value" focus.trigger="focus()" ref="control" />
4
+ <input id.one-time="id" value.bind="value" focus.trigger="focus()" ref="control" />
5
5
 
6
6
  <input type="number" min="0" value.bind="duration.years" placeholder="--" />
7
7
  <span>${labels.years}</span>
@@ -43,7 +43,7 @@ bs-duration-input {
43
43
  }
44
44
  }
45
45
 
46
- input[type='text'] {
46
+ input[id] {
47
47
  position: absolute;
48
48
  height: 100%;
49
49
  width: 100%;
@@ -1,39 +1,84 @@
1
1
  import { BsButton } from '@ekzo-dev/bootstrap';
2
- import { createComponentTemplate, Meta, Story, StoryFnAureliaReturnType } from '@storybook/aurelia';
3
-
4
- import { selectControl } from '../../../../../.storybook/helpers';
5
2
 
6
3
  import { BsDurationInput } from '.';
7
4
 
8
- const meta: Meta = {
9
- title: 'Ekzo / Bootstrap Addons / Forms / Duration input',
5
+ const meta = {
6
+ title: 'Bootstrap Addons / Forms / Duration input',
10
7
  component: BsDurationInput,
11
- args: {
12
- value: 'P5DT1Hasds',
13
- label: 'Duration',
14
- },
8
+ render: () => ({
9
+ template: `<bs-duration-input
10
+ value.bind='value'
11
+ bs-size.bind='bsSize'
12
+ floating-label.bind='floatingLabel'
13
+ name.bind='name'
14
+ label.bind='label'
15
+ title.bind='title'
16
+ disabled.bind='disabled'
17
+ required.bind='required'
18
+ valid.bind='valid'
19
+ valid-feedback.bind='validFeedback'
20
+ invalid-feedback.bind='invalidFeedback'
21
+ form.bind='form'
22
+ text.bind='text'
23
+ ></bs-duration-input>`,
24
+ }),
15
25
  argTypes: {
16
- bsSize: selectControl(['', 'sm', 'lg']),
26
+ // BsDurationInput properties
27
+ value: { control: 'text' },
28
+ bsSize: {
29
+ control: 'select',
30
+ options: ['sm', 'lg'],
31
+ },
32
+ floatingLabel: { control: 'boolean' },
33
+
34
+ // BaseField properties
35
+ name: { control: 'text' },
36
+ label: { control: 'text' },
37
+ title: { control: 'text' },
38
+ disabled: { control: 'boolean' },
39
+ required: { control: 'boolean' },
40
+ valid: { control: 'boolean' },
41
+ validFeedback: { control: 'text' },
42
+ invalidFeedback: { control: 'text' },
43
+ form: { control: 'text' },
44
+ text: { control: 'text' },
17
45
  },
18
46
  };
19
47
 
20
48
  export default meta;
21
49
 
22
- const Overview: Story = (args): StoryFnAureliaReturnType => ({
23
- props: args,
24
- });
25
-
26
- const Validation: Story = (args): StoryFnAureliaReturnType => ({
27
- props: args,
28
- template: `<form class='was-validated'>${createComponentTemplate(
29
- BsDurationInput
30
- )}<br>\${value} <button bs-button>Validate</button></form>`,
31
- components: [BsButton],
32
- });
33
-
34
- Validation.args = {
35
- required: true,
50
+ export const Overview = {
51
+ args: {
52
+ value: 'P5DT1H',
53
+ label: 'Duration',
54
+ },
36
55
  };
37
56
 
38
- // eslint-disable-next-line
39
- export { Overview, Validation };
57
+ export const Validation = {
58
+ render: () => ({
59
+ template: `<form class='was-validated'>
60
+ <bs-duration-input
61
+ value.bind='value'
62
+ bs-size.bind='bsSize'
63
+ floating-label.bind='floatingLabel'
64
+ name.bind='name'
65
+ label.bind='label'
66
+ title.bind='title'
67
+ disabled.bind='disabled'
68
+ required.bind='required'
69
+ valid.bind='valid'
70
+ valid-feedback.bind='validFeedback'
71
+ invalid-feedback.bind='invalidFeedback'
72
+ form.bind='form'
73
+ text.bind='text'
74
+ ></bs-duration-input>
75
+ <br>\${value}
76
+ <button bs-button>Validate</button>
77
+ </form>`,
78
+ components: [BsButton],
79
+ }),
80
+ args: {
81
+ label: 'Duration',
82
+ required: true,
83
+ },
84
+ };
@@ -7,12 +7,17 @@ import { coerceBoolean } from '@ekzo-dev/toolkit';
7
7
  import { Temporal } from '@js-temporal/polyfill';
8
8
  import { bindable, BindingMode, customElement } from 'aurelia';
9
9
 
10
- type Duration = Partial<Pick<Temporal.Duration, 'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds'>>;
10
+ type Writable<T> = {
11
+ -readonly [P in keyof T]: T[P];
12
+ };
13
+ type Duration = Writable<
14
+ Partial<Pick<Temporal.Duration, 'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds'>>
15
+ >;
11
16
  type DurationLabels = {
12
17
  [K in keyof Duration]: string;
13
18
  };
14
19
 
15
- const durationKeys = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'] as const;
20
+ const durationKeys: (keyof Duration)[] = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'] as const;
16
21
 
17
22
  /**
18
23
  * https://github.com/whatwg/html/issues/5488
@@ -81,7 +86,7 @@ export class BsDurationInput extends BaseField implements EventListenerObject {
81
86
  }
82
87
 
83
88
  handleEvent(event: KeyboardEvent | ClipboardEvent): void {
84
- const data = event instanceof KeyboardEvent ? event.key : event.clipboardData.getData('text');
89
+ const data = event instanceof KeyboardEvent ? event.key : event.clipboardData!.getData('text');
85
90
 
86
91
  // don't allow non-numeric values
87
92
  if (!/^\d+$/.test(data)) {
@@ -101,10 +106,10 @@ export class BsDurationInput extends BaseField implements EventListenerObject {
101
106
  private _parseDuration(value: string) {
102
107
  try {
103
108
  const duration = Temporal.Duration.from(value);
104
- const result = {};
109
+ const result: Duration = {};
105
110
 
106
111
  durationKeys.forEach((key) => {
107
- result[key] = duration[key] ? duration[key].toString() : '';
112
+ result[key] = duration[key] ? duration[key] : undefined;
108
113
  });
109
114
  this.duration = result;
110
115
  } catch (error) {
@@ -118,6 +123,7 @@ export class BsDurationInput extends BaseField implements EventListenerObject {
118
123
  }
119
124
 
120
125
  #getLabels(): DurationLabels {
126
+ // @ts-ignore
121
127
  const str: string = new Intl['DurationFormat'](navigator.language, { style: 'narrow' }).format({
122
128
  years: 1,
123
129
  months: 1,