@spicainternational/ngx-sds-components 2.23.0 → 2.23.2
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/esm2020/src/lib/duration-box/duration-box.component.mjs +85 -60
- package/esm2020/src/lib/duration-box/duration-box.module.mjs +1 -1
- package/esm2020/src/lib/duration-box/duration.service.mjs +69 -0
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-duration-box.mjs +108 -64
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-duration-box.mjs.map +1 -1
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-duration-box.mjs +108 -64
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-duration-box.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/duration-box/duration-box.component.d.ts +67 -7
- package/src/lib/duration-box/duration.service.d.ts +10 -0
- package/esm2020/src/lib/duration-box/duration-input-resolver.service.mjs +0 -49
- package/src/lib/duration-box/duration-input-resolver.service.d.ts +0 -7
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, EventEmitter, Component, Input, Output,
|
|
2
|
+
import { Injectable, EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
|
|
3
3
|
import * as i4 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
|
+
import * as i6 from '@spicainternational/ngx-sds-components/src/lib/duration-pipe';
|
|
6
|
+
import { SdsDurationFormatPipe, SdsDurationPipeModule } from '@spicainternational/ngx-sds-components/src/lib/duration-pipe';
|
|
5
7
|
import * as i2 from 'devextreme-angular';
|
|
6
8
|
import { DxTextBoxModule, DxPopoverModule, DxScrollViewModule } from 'devextreme-angular';
|
|
7
9
|
import * as i3 from 'devextreme-angular/ui/nested';
|
|
8
10
|
import * as i5 from 'devextreme-angular/core';
|
|
9
|
-
import * as i6 from '@spicainternational/ngx-sds-components/src/lib/duration-pipe';
|
|
10
|
-
import { SdsDurationPipeModule } from '@spicainternational/ngx-sds-components/src/lib/duration-pipe';
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class DurationService {
|
|
13
13
|
constructor() { }
|
|
14
14
|
resolve(input) {
|
|
15
15
|
if (!input || input.length === 0) {
|
|
@@ -46,10 +46,30 @@ class DurationInputResolverService {
|
|
|
46
46
|
}
|
|
47
47
|
return 0;
|
|
48
48
|
}
|
|
49
|
+
isValidInput(input) {
|
|
50
|
+
const regexNumbersOnly = /^[+-]?\d+$/;
|
|
51
|
+
const regexColonSeparated = /^[+-]?\d+:\d+$/;
|
|
52
|
+
return regexNumbersOnly.test(input) || regexColonSeparated.test(input);
|
|
53
|
+
}
|
|
54
|
+
getDefaultValue(min, max) {
|
|
55
|
+
let defaultValue = 0;
|
|
56
|
+
// try keeping the 0 as default
|
|
57
|
+
// if it is outside the min/max then adjust
|
|
58
|
+
if (min) {
|
|
59
|
+
defaultValue = Math.max(defaultValue, min);
|
|
60
|
+
}
|
|
61
|
+
if (max) {
|
|
62
|
+
defaultValue = Math.min(defaultValue, max);
|
|
63
|
+
}
|
|
64
|
+
return defaultValue;
|
|
65
|
+
}
|
|
66
|
+
isValueWithinLimits(value, min, max) {
|
|
67
|
+
return !((min && value < min) || (max && value > max));
|
|
68
|
+
}
|
|
49
69
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type:
|
|
70
|
+
DurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DurationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
71
|
+
DurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DurationService, providedIn: 'root' });
|
|
72
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DurationService, decorators: [{
|
|
53
73
|
type: Injectable,
|
|
54
74
|
args: [{
|
|
55
75
|
providedIn: 'root',
|
|
@@ -59,14 +79,55 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
59
79
|
class SdsDurationBoxComponent {
|
|
60
80
|
constructor(_durationInputResolver) {
|
|
61
81
|
this._durationInputResolver = _durationInputResolver;
|
|
82
|
+
/**
|
|
83
|
+
* Duration length expressed in minutes; when we allow empty values this property can be null.
|
|
84
|
+
*
|
|
85
|
+
* @type {(number | null)}
|
|
86
|
+
* @memberof SdsDurationBoxComponent
|
|
87
|
+
*/
|
|
62
88
|
this.value = null;
|
|
63
89
|
this.valueChange = new EventEmitter();
|
|
90
|
+
/**
|
|
91
|
+
* Allow user to select empty value. You should provide emptyValueText in this case.
|
|
92
|
+
*
|
|
93
|
+
* @type {boolean}
|
|
94
|
+
* @memberof SdsDurationBoxComponent
|
|
95
|
+
*/
|
|
64
96
|
this.allowEmptyValue = true;
|
|
97
|
+
/**
|
|
98
|
+
* 'emptyValueText' - text to be displayed when value is cleared
|
|
99
|
+
*
|
|
100
|
+
* @type {string}
|
|
101
|
+
* @memberof SdsDurationBoxComponent
|
|
102
|
+
*/
|
|
65
103
|
this.emptyValueText = 'not set';
|
|
104
|
+
/**
|
|
105
|
+
* Width of component
|
|
106
|
+
*
|
|
107
|
+
* @type {string}
|
|
108
|
+
* @memberof SdsDurationBoxComponent
|
|
109
|
+
*/
|
|
66
110
|
this.width = '10rem';
|
|
111
|
+
/**
|
|
112
|
+
* Specifies whether the UI component responds to user interaction.
|
|
113
|
+
*
|
|
114
|
+
* @type {boolean}
|
|
115
|
+
* @memberof SdsDurationBoxComponent
|
|
116
|
+
*/
|
|
117
|
+
this.disabled = false;
|
|
118
|
+
/**
|
|
119
|
+
* Specifies whether to display the Clear button in the UI component.
|
|
120
|
+
*
|
|
121
|
+
* @type {boolean}
|
|
122
|
+
* @memberof SdsDurationBoxComponent
|
|
123
|
+
*/
|
|
124
|
+
this.showClearButton = false;
|
|
67
125
|
this.elementUUID = 'sds-db-' + crypto.randomUUID();
|
|
68
126
|
this.inputValue = '';
|
|
69
127
|
this.showOptions = false;
|
|
128
|
+
this.isValueEmpty = false;
|
|
129
|
+
this.isValueSetInternally = false;
|
|
130
|
+
this._durationPipe = new SdsDurationFormatPipe();
|
|
70
131
|
this.optionsDropdownButton = {
|
|
71
132
|
icon: 'spindown',
|
|
72
133
|
stylingMode: 'text',
|
|
@@ -77,68 +138,55 @@ class SdsDurationBoxComponent {
|
|
|
77
138
|
this.clearValueButton = {
|
|
78
139
|
icon: 'clear',
|
|
79
140
|
stylingMode: 'text',
|
|
141
|
+
elementAttr: { class: 'sds-durationbox-clear-button' },
|
|
80
142
|
onClick: () => {
|
|
81
143
|
this.applyOption(null);
|
|
82
144
|
}
|
|
83
145
|
};
|
|
84
|
-
this.isValueEmpty = false;
|
|
85
|
-
this.isValueSetInternally = false;
|
|
86
146
|
}
|
|
87
147
|
ngOnChanges(changes) {
|
|
88
148
|
if (changes['value']) {
|
|
89
149
|
if (this.value === null) {
|
|
90
150
|
if (this.allowEmptyValue) {
|
|
91
|
-
this.
|
|
92
|
-
this.inputValue = this.emptyValueText;
|
|
151
|
+
this.setValue(null);
|
|
93
152
|
}
|
|
94
153
|
else {
|
|
95
|
-
this.
|
|
154
|
+
this.setValue(this._durationInputResolver.getDefaultValue());
|
|
155
|
+
this.inputValue = this._durationPipe.transform(this.value, this.emptyValueText);
|
|
96
156
|
}
|
|
97
157
|
}
|
|
98
158
|
else {
|
|
99
|
-
this.inputValue = this.
|
|
159
|
+
this.inputValue = this._durationPipe.transform(this.value, this.emptyValueText);
|
|
100
160
|
}
|
|
101
161
|
}
|
|
102
162
|
}
|
|
103
163
|
ngOnInit() { }
|
|
104
164
|
blockNonNumberOrSemicolon(e) {
|
|
105
165
|
this.isValueSetInternally = false;
|
|
106
|
-
if (!(e.event.key === 'Enter' ||
|
|
107
|
-
e.event.key === 'NumpadEnter' ||
|
|
108
|
-
e.event.key === 'Delete' ||
|
|
109
|
-
e.event.key === 'Tab' ||
|
|
110
|
-
e.event.key === 'Backspace' ||
|
|
111
|
-
e.event.key === 'ArrowLeft' ||
|
|
112
|
-
e.event.key === 'ArrowRight' ||
|
|
113
|
-
e.event.key === 'ArrowTop' ||
|
|
114
|
-
e.event.key === 'ArrowBottom')) {
|
|
115
|
-
const regexNumberOfSemicolon = /\d|:/;
|
|
116
|
-
if (!regexNumberOfSemicolon.test(e.event.key)) {
|
|
117
|
-
e.event.preventDefault();
|
|
118
|
-
console.log(`${e.event.key} is not valid`);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
this.isValueEmpty = false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
166
|
}
|
|
125
|
-
resolveInput(
|
|
167
|
+
resolveInput() {
|
|
126
168
|
if (!this.isValueSetInternally) {
|
|
127
|
-
if (this.
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
this.setValue(null);
|
|
169
|
+
if (!this._durationInputResolver.isValidInput(this.inputValue)) {
|
|
170
|
+
// we have invalid input. use old value
|
|
171
|
+
this.setInputValueInternally(this.value);
|
|
131
172
|
}
|
|
132
173
|
else {
|
|
133
|
-
const resolvedValue = this._durationInputResolver.resolve(
|
|
174
|
+
const resolvedValue = this._durationInputResolver.resolve(this.inputValue);
|
|
134
175
|
if (resolvedValue === null && this.allowEmptyValue) {
|
|
135
176
|
this.setValue(null);
|
|
136
177
|
}
|
|
137
178
|
else if (resolvedValue === null && !this.allowEmptyValue) {
|
|
138
|
-
this.setValue(
|
|
179
|
+
this.setValue(this._durationInputResolver.getDefaultValue());
|
|
139
180
|
}
|
|
140
181
|
else {
|
|
141
|
-
|
|
182
|
+
// make sure that the value is within the min/max period
|
|
183
|
+
if (this._durationInputResolver.isValueWithinLimits(resolvedValue, this.min, this.max)) {
|
|
184
|
+
this.setValue(resolvedValue);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
// use old value
|
|
188
|
+
this.setInputValueInternally(this.value);
|
|
189
|
+
}
|
|
142
190
|
}
|
|
143
191
|
}
|
|
144
192
|
}
|
|
@@ -149,33 +197,24 @@ class SdsDurationBoxComponent {
|
|
|
149
197
|
this.setValue(value);
|
|
150
198
|
}
|
|
151
199
|
setValue(value) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
this.isValueEmpty = true;
|
|
157
|
-
this.isValueSetInternally = true;
|
|
158
|
-
this.inputValue = this.emptyValueText;
|
|
159
|
-
}
|
|
160
|
-
else if (typeof value === 'number') {
|
|
161
|
-
this.isValueEmpty = false;
|
|
162
|
-
this.isValueSetInternally = true;
|
|
163
|
-
this.inputValue = this.minutesToDurationString(this.value);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
200
|
+
this.isValueEmpty = (value === null);
|
|
201
|
+
this.value = value;
|
|
202
|
+
this.valueChange.emit(this.value);
|
|
203
|
+
this.setInputValueInternally(value);
|
|
166
204
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
205
|
+
setInputValueInternally(value) {
|
|
206
|
+
this.isValueSetInternally = true;
|
|
207
|
+
setTimeout(() => {
|
|
208
|
+
this.inputValue = this._durationPipe.transform(this.value, this.emptyValueText);
|
|
209
|
+
}, 0);
|
|
171
210
|
}
|
|
172
211
|
}
|
|
173
|
-
SdsDurationBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsDurationBoxComponent, deps: [{ token:
|
|
174
|
-
SdsDurationBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SdsDurationBoxComponent, selector: "sds-duration-box", inputs: { value: "value", allowEmptyValue: "allowEmptyValue", emptyValueText: "emptyValueText", options: "options", width: "width"
|
|
212
|
+
SdsDurationBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsDurationBoxComponent, deps: [{ token: DurationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
213
|
+
SdsDurationBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SdsDurationBoxComponent, selector: "sds-duration-box", inputs: { value: "value", allowEmptyValue: "allowEmptyValue", emptyValueText: "emptyValueText", options: "options", width: "width", disabled: "disabled", showClearButton: "showClearButton", max: "max", min: "min" }, outputs: { valueChange: "valueChange" }, usesOnChanges: true, ngImport: i0, template: "<dx-text-box\r\n #textbox\r\n [id]=\"elementUUID\"\r\n class=\"sds-durationbox\"\r\n [(value)]=\"inputValue\"\r\n (onKeyDown)=\"blockNonNumberOrSemicolon($event)\"\r\n (onChange)=\"resolveInput()\"\r\n [width]=\"width\"\r\n [disabled]=\"disabled\"\r\n >\r\n\r\n <!-- (onValueChanged)=\"resolveInput($event)\" -->\r\n\r\n <dxi-button\r\n *ngIf=\"allowEmptyValue && showClearButton\"\r\n name=\"clearValue\"\r\n location=\"after\"\r\n [options]=\"clearValueButton\"\r\n ></dxi-button>\r\n <dxi-button\r\n *ngIf=\"options && options.length > 0\"\r\n name=\"optionsDropdown\"\r\n location=\"after\"\r\n [options]=\"optionsDropdownButton\"\r\n ></dxi-button>\r\n</dx-text-box>\r\n\r\n\r\n<dx-popover\r\n target=\"#{{elementUUID}}\"\r\n [(visible)]=\"showOptions\"\r\n [minWidth]=\"width\"\r\n [hideOnOutsideClick]=\"true\"\r\n [wrapperAttr]=\"{ class: 'sds-durationbox-options-popover' }\"\r\n >\r\n\r\n <div *dxTemplate=\"let data of 'content'\">\r\n <dx-scroll-view>\r\n <button\r\n class=\"dropdown-item border-0\"\r\n [class.selected] = \"isValueEmpty\"\r\n (click)=\"applyOption(null)\"\r\n > {{ emptyValueText}}\r\n </button>\r\n\r\n <div *ngFor=\"let option of options\">\r\n <button\r\n class=\"dropdown-item border-0\"\r\n [class.selected] = \"option === value\"\r\n (click)=\"applyOption(option)\"\r\n > {{option | sdsDurationFormat}}\r\n </button>\r\n </div>\r\n </dx-scroll-view>\r\n </div>\r\n</dx-popover>", styles: ["::ng-deep .sds-durationbox .sds-durationbox-clear-button .dx-icon{color:#999}::ng-deep .sds-durationbox-options-popover .dx-popup-content{padding:.25rem;font-size:1rem}::ng-deep .sds-durationbox-options-popover .dropdown-item:focus{outline:none}::ng-deep .sds-durationbox-options-popover .dropdown-item.selected{background-color:#dee2e6}\n"], components: [{ type: i2.DxTextBoxComponent, selector: "dx-text-box", inputs: ["accessKey", "activeStateEnabled", "buttons", "disabled", "elementAttr", "focusStateEnabled", "height", "hint", "hoverStateEnabled", "inputAttr", "isValid", "label", "labelMode", "mask", "maskChar", "maskInvalidMessage", "maskRules", "maxLength", "mode", "name", "placeholder", "readOnly", "rtlEnabled", "showClearButton", "showMaskMode", "spellcheck", "stylingMode", "tabIndex", "text", "useMaskedValue", "validationError", "validationErrors", "validationMessageMode", "validationMessagePosition", "validationStatus", "value", "valueChangeEvent", "visible", "width"], outputs: ["onChange", "onContentReady", "onCopy", "onCut", "onDisposing", "onEnterKey", "onFocusIn", "onFocusOut", "onInitialized", "onInput", "onKeyDown", "onKeyUp", "onOptionChanged", "onPaste", "onValueChanged", "accessKeyChange", "activeStateEnabledChange", "buttonsChange", "disabledChange", "elementAttrChange", "focusStateEnabledChange", "heightChange", "hintChange", "hoverStateEnabledChange", "inputAttrChange", "isValidChange", "labelChange", "labelModeChange", "maskChange", "maskCharChange", "maskInvalidMessageChange", "maskRulesChange", "maxLengthChange", "modeChange", "nameChange", "placeholderChange", "readOnlyChange", "rtlEnabledChange", "showClearButtonChange", "showMaskModeChange", "spellcheckChange", "stylingModeChange", "tabIndexChange", "textChange", "useMaskedValueChange", "validationErrorChange", "validationErrorsChange", "validationMessageModeChange", "validationMessagePositionChange", "validationStatusChange", "valueChange", "valueChangeEventChange", "visibleChange", "widthChange", "onBlur"] }, { type: i3.DxiButtonComponent, selector: "dxi-button", inputs: ["location", "name", "options", "cssClass", "disabled", "hint", "icon", "onClick", "template", "text", "visible"] }, { type: i2.DxPopoverComponent, selector: "dx-popover", inputs: ["animation", "closeOnOutsideClick", "container", "contentTemplate", "copyRootClassesToWrapper", "deferRendering", "disabled", "elementAttr", "height", "hideEvent", "hideOnOutsideClick", "hideOnParentScroll", "hint", "hoverStateEnabled", "maxHeight", "maxWidth", "minHeight", "minWidth", "position", "rtlEnabled", "shading", "shadingColor", "showCloseButton", "showEvent", "showTitle", "target", "title", "titleTemplate", "toolbarItems", "visible", "width", "wrapperAttr"], outputs: ["onContentReady", "onDisposing", "onHidden", "onHiding", "onInitialized", "onOptionChanged", "onShowing", "onShown", "onTitleRendered", "animationChange", "closeOnOutsideClickChange", "containerChange", "contentTemplateChange", "copyRootClassesToWrapperChange", "deferRenderingChange", "disabledChange", "elementAttrChange", "heightChange", "hideEventChange", "hideOnOutsideClickChange", "hideOnParentScrollChange", "hintChange", "hoverStateEnabledChange", "maxHeightChange", "maxWidthChange", "minHeightChange", "minWidthChange", "positionChange", "rtlEnabledChange", "shadingChange", "shadingColorChange", "showCloseButtonChange", "showEventChange", "showTitleChange", "targetChange", "titleChange", "titleTemplateChange", "toolbarItemsChange", "visibleChange", "widthChange", "wrapperAttrChange"] }, { type: i2.DxScrollViewComponent, selector: "dx-scroll-view", inputs: ["bounceEnabled", "direction", "disabled", "elementAttr", "height", "pulledDownText", "pullingDownText", "reachBottomText", "refreshingText", "rtlEnabled", "scrollByContent", "scrollByThumb", "showScrollbar", "useNative", "width"], outputs: ["onDisposing", "onInitialized", "onOptionChanged", "onPullDown", "onReachBottom", "onScroll", "onUpdated", "bounceEnabledChange", "directionChange", "disabledChange", "elementAttrChange", "heightChange", "pulledDownTextChange", "pullingDownTextChange", "reachBottomTextChange", "refreshingTextChange", "rtlEnabledChange", "scrollByContentChange", "scrollByThumbChange", "showScrollbarChange", "useNativeChange", "widthChange"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.DxTemplateDirective, selector: "[dxTemplate]", inputs: ["dxTemplateOf"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "sdsDurationFormat": i6.SdsDurationFormatPipe } });
|
|
175
214
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsDurationBoxComponent, decorators: [{
|
|
176
215
|
type: Component,
|
|
177
|
-
args: [{ selector: 'sds-duration-box', template: "<dx-text-box\n #textbox\n [id]=\"elementUUID\"\n [value]=\"inputValue\"\n (onKeyDown)=\"blockNonNumberOrSemicolon($event)\"\n (
|
|
178
|
-
}], ctorParameters: function () { return [{ type:
|
|
216
|
+
args: [{ selector: 'sds-duration-box', template: "<dx-text-box\r\n #textbox\r\n [id]=\"elementUUID\"\r\n class=\"sds-durationbox\"\r\n [(value)]=\"inputValue\"\r\n (onKeyDown)=\"blockNonNumberOrSemicolon($event)\"\r\n (onChange)=\"resolveInput()\"\r\n [width]=\"width\"\r\n [disabled]=\"disabled\"\r\n >\r\n\r\n <!-- (onValueChanged)=\"resolveInput($event)\" -->\r\n\r\n <dxi-button\r\n *ngIf=\"allowEmptyValue && showClearButton\"\r\n name=\"clearValue\"\r\n location=\"after\"\r\n [options]=\"clearValueButton\"\r\n ></dxi-button>\r\n <dxi-button\r\n *ngIf=\"options && options.length > 0\"\r\n name=\"optionsDropdown\"\r\n location=\"after\"\r\n [options]=\"optionsDropdownButton\"\r\n ></dxi-button>\r\n</dx-text-box>\r\n\r\n\r\n<dx-popover\r\n target=\"#{{elementUUID}}\"\r\n [(visible)]=\"showOptions\"\r\n [minWidth]=\"width\"\r\n [hideOnOutsideClick]=\"true\"\r\n [wrapperAttr]=\"{ class: 'sds-durationbox-options-popover' }\"\r\n >\r\n\r\n <div *dxTemplate=\"let data of 'content'\">\r\n <dx-scroll-view>\r\n <button\r\n class=\"dropdown-item border-0\"\r\n [class.selected] = \"isValueEmpty\"\r\n (click)=\"applyOption(null)\"\r\n > {{ emptyValueText}}\r\n </button>\r\n\r\n <div *ngFor=\"let option of options\">\r\n <button\r\n class=\"dropdown-item border-0\"\r\n [class.selected] = \"option === value\"\r\n (click)=\"applyOption(option)\"\r\n > {{option | sdsDurationFormat}}\r\n </button>\r\n </div>\r\n </dx-scroll-view>\r\n </div>\r\n</dx-popover>", styles: ["::ng-deep .sds-durationbox .sds-durationbox-clear-button .dx-icon{color:#999}::ng-deep .sds-durationbox-options-popover .dx-popup-content{padding:.25rem;font-size:1rem}::ng-deep .sds-durationbox-options-popover .dropdown-item:focus{outline:none}::ng-deep .sds-durationbox-options-popover .dropdown-item.selected{background-color:#dee2e6}\n"] }]
|
|
217
|
+
}], ctorParameters: function () { return [{ type: DurationService }]; }, propDecorators: { value: [{
|
|
179
218
|
type: Input
|
|
180
219
|
}], valueChange: [{
|
|
181
220
|
type: Output
|
|
@@ -187,9 +226,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
187
226
|
type: Input
|
|
188
227
|
}], width: [{
|
|
189
228
|
type: Input
|
|
190
|
-
}],
|
|
191
|
-
type:
|
|
192
|
-
|
|
229
|
+
}], disabled: [{
|
|
230
|
+
type: Input
|
|
231
|
+
}], showClearButton: [{
|
|
232
|
+
type: Input
|
|
233
|
+
}], max: [{
|
|
234
|
+
type: Input
|
|
235
|
+
}], min: [{
|
|
236
|
+
type: Input
|
|
193
237
|
}] } });
|
|
194
238
|
|
|
195
239
|
const components = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spicainternational-ngx-sds-components-src-lib-duration-box.mjs","sources":["../../../projects/ngx-sds-components/src/lib/duration-box/duration-input-resolver.service.ts","../../../projects/ngx-sds-components/src/lib/duration-box/duration-box.component.ts","../../../projects/ngx-sds-components/src/lib/duration-box/duration-box.component.html","../../../projects/ngx-sds-components/src/lib/duration-box/duration-box.module.ts","../../../projects/ngx-sds-components/src/lib/duration-box/spicainternational-ngx-sds-components-src-lib-duration-box.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DurationInputResolverService {\n \n constructor() {}\n\n public resolve(input: string): number | null{\n if (!input || input.length === 0) {\n return 0;\n }\n\n const inputSegments = input.split(':');\n if (inputSegments.length > 2) {\n //invalid input\n return 0;\n } else if (inputSegments.length == 2){\n // we have hrs and minutes\n const hrs = parseInt(inputSegments[0] ? inputSegments[0] : '0');\n const mins = parseInt(inputSegments[1] ? inputSegments[1] : '0');\n const totalMins = (hrs * 60) + mins;\n\n return totalMins;\n } else if (inputSegments.length == 1) {\n // take last two digits as mins\n const nonSeparated = inputSegments[0];\n\n let totalMins = 0;\n if (nonSeparated.length <= 2) {\n totalMins = parseInt(nonSeparated)\n } else {\n const lastIndex = nonSeparated.length - 2;\n const part1 = nonSeparated.slice(0, lastIndex);\n const part2 = nonSeparated.slice(lastIndex);\n const hrs = parseInt(part1);\n const mins = parseInt(part2);\n totalMins = (hrs * 60) + mins; \n }\n return totalMins;\n }\n return 0; \n }\n}\n","import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';\nimport { DxTextBoxComponent } from 'devextreme-angular';\nimport { DurationInputResolverService } from './duration-input-resolver.service';\n\n@Component({\n selector: 'sds-duration-box',\n templateUrl: './duration-box.component.html',\n styleUrls: ['./duration-box.component.scss'],\n})\nexport class SdsDurationBoxComponent implements OnInit, OnChanges {\n\n @Input() value: number | null = null;\n @Output() valueChange = new EventEmitter<number | null>();\n\n @Input() allowEmptyValue: boolean = true;\n @Input() emptyValueText: string = 'not set';\n\n @Input() options?: number[];\n @Input() width: string = '10rem';\n\n @ViewChild('textbox', {static: true}) textbox?: DxTextBoxComponent;\n\n\n public elementUUID = 'sds-db-' + crypto.randomUUID();\n\n public inputValue: string = '';\n public showOptions: boolean = false;\n \n public optionsDropdownButton = {\n icon: 'spindown',\n stylingMode: 'text',\n onClick: () => {\n this.showOptions = !this.showOptions;\n }\n }\n\n public clearValueButton = {\n icon: 'clear',\n stylingMode: 'text',\n onClick: () => {\n this.applyOption(null);\n }\n }\n\n public isValueEmpty = false;\n\n private isValueSetInternally = false;\n\n constructor(\n private _durationInputResolver: DurationInputResolverService\n ) {}\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['value']) {\n if (this.value === null) {\n if (this.allowEmptyValue) {\n this.isValueEmpty = true;\n this.inputValue = this.emptyValueText;\n } else {\n this.inputValue = '0:00'; // TO-DO: resolve this scenario\n }\n\n } else {\n this.inputValue = this.minutesToDurationString(this.value)\n }\n }\n }\n\n ngOnInit(): void {}\n\n public blockNonNumberOrSemicolon(e: any) {\n this.isValueSetInternally = false;\n\n if (!(\n e.event.key === 'Enter' || \n e.event.key === 'NumpadEnter' || \n e.event.key === 'Delete' || \n e.event.key === 'Tab' ||\n e.event.key === 'Backspace' ||\n e.event.key === 'ArrowLeft' ||\n e.event.key === 'ArrowRight' ||\n e.event.key === 'ArrowTop' ||\n e.event.key === 'ArrowBottom'\n )) {\n const regexNumberOfSemicolon = /\\d|:/;\n if (!regexNumberOfSemicolon.test(e.event.key)) {\n e.event.preventDefault();\n console.log(`${e.event.key} is not valid`);\n } else {\n this.isValueEmpty = false;\n }\n }\n }\n\n public resolveInput(data: any) {\n if (!this.isValueSetInternally){\n if (this.isValueEmpty || (data.value === '' && this.allowEmptyValue)) {\n // this.inputValue = this.emptyValueTextthis\n // this.applyOption(null);\n this.setValue(null);\n } else { \n const resolvedValue = this._durationInputResolver.resolve(data.value);\n \n if (resolvedValue === null && this.allowEmptyValue) {\n this.setValue(null);\n } else if (resolvedValue === null && !this.allowEmptyValue) {\n this.setValue(resolvedValue);\n } else {\n this.setValue(resolvedValue);\n }\n }\n }\n }\n\n public applyOption(value: number | null){\n this.showOptions = false;\n this.isValueSetInternally = false;\n this.setValue(value);\n }\n\n private setValue(value: number | null){\n if ( (this.isValueEmpty && value != null) || (!this.isValueEmpty && this.value != value)) {\n this.value = value;\n this.valueChange.emit(this.value);\n if (value === null) {\n this.isValueEmpty = true;\n this.isValueSetInternally = true;\n this.inputValue = this.emptyValueText;\n } else if (typeof value === 'number') {\n this.isValueEmpty = false;\n this.isValueSetInternally = true;\n this.inputValue = this.minutesToDurationString(this.value as number);\n }\n }\n\n }\n\n private minutesToDurationString(minutes: number): string {\n const hours = Math.floor(minutes/60);\n const mins = minutes % 60;\n return `${hours.toString().padStart(1, \"0\")}:${mins.toString().padStart(2, \"0\")}`;\n }\n}\n","<dx-text-box\n #textbox\n [id]=\"elementUUID\"\n [value]=\"inputValue\"\n (onKeyDown)=\"blockNonNumberOrSemicolon($event)\"\n (onValueChanged)=\"resolveInput($event)\"\n [width]=\"width\"\n >\n <dxi-button\n *ngIf=\"allowEmptyValue\"\n name=\"clearValue\"\n location=\"after\"\n [options]=\"clearValueButton\"\n ></dxi-button>\n <dxi-button\n \n *ngIf=\"options && options.length > 0\"\n name=\"optionsDropdown\"\n location=\"after\"\n [options]=\"optionsDropdownButton\"\n ></dxi-button>\n</dx-text-box>\n\n\n<dx-popover\n target=\"#{{elementUUID}}\"\n [(visible)]=\"showOptions\"\n [width]=\"width\"\n [closeOnOutsideClick]=\"true\"\n [wrapperAttr]=\"{ class: 'sds-durationbox-options-popover' }\"\n >\n\n <div *dxTemplate=\"let data of 'content'\">\n\n <button\n class=\"dropdown-item border-0\"\n [class.selected] = \"isValueEmpty\"\n (click)=\"applyOption(null)\"\n > {{ emptyValueText}}\n </button>\n\n <div *ngFor=\"let option of options\">\n <button\n class=\"dropdown-item border-0\"\n [class.selected] = \"option === value\"\n (click)=\"applyOption(option)\"\n > {{option | sdsDurationFormat}}\n </button>\n </div>\n </div>\n\n <!-- <div *ngFor=\"let option of options\"\n class=\"d-flex align-items-center p-1 my-1 mx-1 overflow-avatar-container\" >\n <div class=\"ml-2 pl-1\">\n {{option | sdsDurationFormat}}\n </div>\n </div> -->\n</dx-popover>","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SdsDurationBoxComponent } from './duration-box.component';\nimport { DxPopoverModule, DxScrollViewModule, DxTextBoxModule } from 'devextreme-angular';\nimport { SdsDurationPipeModule } from '@spicainternational/ngx-sds-components/src/lib/duration-pipe';\n\n\n\nconst components = [\n SdsDurationBoxComponent\n]\n\n@NgModule({\n declarations: [\n SdsDurationBoxComponent\n ],\n imports: [\n CommonModule,\n\n SdsDurationPipeModule,\n \n DxTextBoxModule,\n DxPopoverModule,\n DxScrollViewModule,\n ],\n exports: [\n ...components\n ]\n})\nexport class SdsDurationBoxModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.DurationInputResolverService"],"mappings":";;;;;;;;;;;MAKa,4BAA4B,CAAA;AAErC,IAAA,WAAA,GAAA,GAAgB;AAET,IAAA,OAAO,CAAC,KAAa,EAAA;QACxB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AAC9B,YAAA,OAAO,CAAC,CAAC;AACZ,SAAA;QAED,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACvC,QAAA,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;;AAE1B,YAAA,OAAO,CAAC,CAAC;AACZ,SAAA;AAAM,aAAA,IAAI,aAAa,CAAC,MAAM,IAAI,CAAC,EAAC;;YAEjC,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;YAChE,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;YACjE,MAAM,SAAS,GAAG,CAAC,GAAG,GAAG,EAAE,IAAI,IAAI,CAAC;AAEpC,YAAA,OAAO,SAAS,CAAC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AmBY,oBAAoB,CAAA;;iHAApB,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;kHAApB,oBAAoB,EAAA,YAAA,EAAA,CAf7B,uBAAuB,CAAA,EAAA,OAAA,EAAA,CAGvB,YAAY;QAEZ,qBAAqB;QAErB,eAAe;QACf,eAAe;AACf,QAAA,kBAAkB,aAdlB,uBAAuB,CAAA,EAAA,CAAA,CAAA;AAoBd,oBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,EAbtB,OAAA,EAAA,CAAA;YACP,YAAY;YAEZ,qBAAqB;YAErB,eAAe;YACf,eAAe;YACf,kBAAkB;AACnB,SAAA,CAAA,EAAA,CAAA,CAAA;2FAKU,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAjBhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,uBAAuB;AACxB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;wBAEZ,qBAAqB;wBAErB,eAAe;wBACf,eAAe;wBACf,kBAAkB;AACnB,qBAAA;AACD,oBAAA,OAAO,EAAE;AACP,wBAAA,GAAG,UAAU;AACd,qBAAA;AACF,iBAAA,CAAA;;;AC5BD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"spicainternational-ngx-sds-components-src-lib-duration-box.mjs","sources":["../../../projects/ngx-sds-components/src/lib/duration-box/duration.service.ts","../../../projects/ngx-sds-components/src/lib/duration-box/duration-box.component.ts","../../../projects/ngx-sds-components/src/lib/duration-box/duration-box.component.html","../../../projects/ngx-sds-components/src/lib/duration-box/duration-box.module.ts","../../../projects/ngx-sds-components/src/lib/duration-box/spicainternational-ngx-sds-components-src-lib-duration-box.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class DurationService {\r\n \r\n constructor() {}\r\n\r\n public resolve(input: string): number | null{\r\n if (!input || input.length === 0) {\r\n return 0;\r\n }\r\n\r\n const inputSegments = input.split(':');\r\n if (inputSegments.length > 2) {\r\n //invalid input\r\n return 0;\r\n } else if (inputSegments.length == 2){\r\n // we have hrs and minutes\r\n const hrs = parseInt(inputSegments[0] ? inputSegments[0] : '0');\r\n const mins = parseInt(inputSegments[1] ? inputSegments[1] : '0');\r\n const totalMins = (hrs * 60) + mins;\r\n\r\n return totalMins;\r\n } else if (inputSegments.length == 1) {\r\n // take last two digits as mins\r\n const nonSeparated = inputSegments[0];\r\n\r\n let totalMins = 0;\r\n if (nonSeparated.length <= 2) {\r\n totalMins = parseInt(nonSeparated)\r\n } else {\r\n const lastIndex = nonSeparated.length - 2;\r\n const part1 = nonSeparated.slice(0, lastIndex);\r\n const part2 = nonSeparated.slice(lastIndex);\r\n const hrs = parseInt(part1);\r\n const mins = parseInt(part2);\r\n totalMins = (hrs * 60) + mins; \r\n }\r\n return totalMins;\r\n }\r\n return 0; \r\n }\r\n\r\n public isValidInput(input: string) {\r\n const regexNumbersOnly = /^[+-]?\\d+$/;\r\n const regexColonSeparated = /^[+-]?\\d+:\\d+$/;\r\n return regexNumbersOnly.test(input) || regexColonSeparated.test(input);\r\n }\r\n\r\n public getDefaultValue(min?: number, max?: number): number {\r\n let defaultValue = 0;\r\n // try keeping the 0 as default\r\n // if it is outside the min/max then adjust\r\n if (min) {\r\n defaultValue = Math.max(defaultValue, min);\r\n }\r\n if (max) {\r\n defaultValue = Math.min(defaultValue, max);\r\n }\r\n return defaultValue;\r\n }\r\n\r\n public isValueWithinLimits(value: number, min?: number, max?: number): boolean {\r\n return !((min && value < min) || (max && value > max))\r\n } \r\n\r\n}\r\n","import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';\r\nimport { SdsDurationFormatPipe } from '@spicainternational/ngx-sds-components/src/lib/duration-pipe';\r\nimport { DurationService } from './duration.service';\r\n\r\n@Component({\r\n selector: 'sds-duration-box',\r\n templateUrl: './duration-box.component.html',\r\n styleUrls: ['./duration-box.component.scss'],\r\n})\r\nexport class SdsDurationBoxComponent implements OnInit, OnChanges {\r\n /**\r\n * Duration length expressed in minutes; when we allow empty values this property can be null.\r\n *\r\n * @type {(number | null)}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() value: number | null = null;\r\n @Output() valueChange = new EventEmitter<number | null>();\r\n\r\n /**\r\n * Allow user to select empty value. You should provide emptyValueText in this case.\r\n *\r\n * @type {boolean}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() allowEmptyValue: boolean = true;\r\n\r\n /**\r\n * 'emptyValueText' - text to be displayed when value is cleared\r\n *\r\n * @type {string}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() emptyValueText: string = 'not set';\r\n\r\n /**\r\n * Array of pre-defined durations that will be displayed in dropdown for easier selection.\r\n *\r\n * @type {number[]}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() options?: number[];\r\n \r\n /**\r\n * Width of component\r\n *\r\n * @type {string}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() width: string = '10rem';\r\n\r\n /**\r\n * Specifies whether the UI component responds to user interaction.\r\n *\r\n * @type {boolean}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() disabled: boolean = false;\r\n \r\n /**\r\n * Specifies whether to display the Clear button in the UI component.\r\n *\r\n * @type {boolean}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() showClearButton: boolean = false;\r\n\r\n /**\r\n * The maximum value accepted by the duration box.\r\n *\r\n * @type {number}\r\n * @memberof SdsDurationBoxComponent\r\n */\r\n @Input() max?: number;\r\n\r\n /**\r\n * The minimum value accepted by the duration box.\r\n *\r\n * @type {number}\r\n * @memberof SdsDurationBoxComponent\r\n */ \r\n @Input() min?: number;\r\n\r\n public elementUUID = 'sds-db-' + crypto.randomUUID();\r\n\r\n public inputValue: string = '';\r\n public showOptions: boolean = false;\r\n \r\n public optionsDropdownButton;\r\n public clearValueButton;\r\n\r\n public isValueEmpty = false;\r\n\r\n private isValueSetInternally = false;\r\n private _durationPipe: SdsDurationFormatPipe;\r\n\r\n constructor(\r\n private _durationInputResolver: DurationService,\r\n ) {\r\n this._durationPipe = new SdsDurationFormatPipe();\r\n \r\n this.optionsDropdownButton = {\r\n icon: 'spindown',\r\n stylingMode: 'text',\r\n \r\n onClick: () => {\r\n this.showOptions = !this.showOptions;\r\n }\r\n }\r\n\r\n this.clearValueButton = {\r\n icon: 'clear',\r\n stylingMode: 'text',\r\n elementAttr: { class: 'sds-durationbox-clear-button' },\r\n onClick: () => {\r\n this.applyOption(null);\r\n }\r\n } \r\n }\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n if (changes['value']) {\r\n if (this.value === null) {\r\n if (this.allowEmptyValue) {\r\n this.setValue(null);\r\n } else {\r\n this.setValue(this._durationInputResolver.getDefaultValue());\r\n this.inputValue = this._durationPipe.transform(this.value, this.emptyValueText);\r\n }\r\n } else {\r\n this.inputValue = this._durationPipe.transform(this.value, this.emptyValueText);\r\n }\r\n }\r\n }\r\n\r\n ngOnInit(): void {}\r\n\r\n public blockNonNumberOrSemicolon(e: any) {\r\n this.isValueSetInternally = false;\r\n }\r\n\r\n\r\n public resolveInput() {\r\n if (!this.isValueSetInternally){\r\n if (!this._durationInputResolver.isValidInput(this.inputValue)) {\r\n // we have invalid input. use old value\r\n this.setInputValueInternally(this.value);\r\n } else {\r\n const resolvedValue = this._durationInputResolver.resolve(this.inputValue);\r\n \r\n if (resolvedValue === null && this.allowEmptyValue) {\r\n this.setValue(null);\r\n } else if (resolvedValue === null && !this.allowEmptyValue) {\r\n this.setValue(this._durationInputResolver.getDefaultValue());\r\n } else {\r\n\r\n // make sure that the value is within the min/max period\r\n if (this._durationInputResolver.isValueWithinLimits(resolvedValue as number, this.min, this.max)) {\r\n this.setValue(resolvedValue);\r\n } else {\r\n // use old value\r\n this.setInputValueInternally(this.value);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n public applyOption(value: number | null){\r\n this.showOptions = false;\r\n this.isValueSetInternally = false;\r\n this.setValue(value);\r\n }\r\n\r\n private setValue(value: number | null){\r\n this.isValueEmpty = (value === null);\r\n this.value = value;\r\n this.valueChange.emit(this.value);\r\n this.setInputValueInternally(value);\r\n }\r\n\r\n private setInputValueInternally(value: number | null){\r\n this.isValueSetInternally = true;\r\n setTimeout(() => {\r\n this.inputValue = this._durationPipe.transform(this.value, this.emptyValueText);\r\n }, 0);\r\n }\r\n\r\n}\r\n","<dx-text-box\r\n #textbox\r\n [id]=\"elementUUID\"\r\n class=\"sds-durationbox\"\r\n [(value)]=\"inputValue\"\r\n (onKeyDown)=\"blockNonNumberOrSemicolon($event)\"\r\n (onChange)=\"resolveInput()\"\r\n [width]=\"width\"\r\n [disabled]=\"disabled\"\r\n >\r\n\r\n <!-- (onValueChanged)=\"resolveInput($event)\" -->\r\n\r\n <dxi-button\r\n *ngIf=\"allowEmptyValue && showClearButton\"\r\n name=\"clearValue\"\r\n location=\"after\"\r\n [options]=\"clearValueButton\"\r\n ></dxi-button>\r\n <dxi-button\r\n *ngIf=\"options && options.length > 0\"\r\n name=\"optionsDropdown\"\r\n location=\"after\"\r\n [options]=\"optionsDropdownButton\"\r\n ></dxi-button>\r\n</dx-text-box>\r\n\r\n\r\n<dx-popover\r\n target=\"#{{elementUUID}}\"\r\n [(visible)]=\"showOptions\"\r\n [minWidth]=\"width\"\r\n [hideOnOutsideClick]=\"true\"\r\n [wrapperAttr]=\"{ class: 'sds-durationbox-options-popover' }\"\r\n >\r\n\r\n <div *dxTemplate=\"let data of 'content'\">\r\n <dx-scroll-view>\r\n <button\r\n class=\"dropdown-item border-0\"\r\n [class.selected] = \"isValueEmpty\"\r\n (click)=\"applyOption(null)\"\r\n > {{ emptyValueText}}\r\n </button>\r\n\r\n <div *ngFor=\"let option of options\">\r\n <button\r\n class=\"dropdown-item border-0\"\r\n [class.selected] = \"option === value\"\r\n (click)=\"applyOption(option)\"\r\n > {{option | sdsDurationFormat}}\r\n </button>\r\n </div>\r\n </dx-scroll-view>\r\n </div>\r\n</dx-popover>","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { SdsDurationBoxComponent } from './duration-box.component';\r\nimport { DxPopoverModule, DxScrollViewModule, DxTextBoxModule } from 'devextreme-angular';\r\nimport { SdsDurationPipeModule } from '@spicainternational/ngx-sds-components/src/lib/duration-pipe';\r\n\r\n\r\n\r\nconst components = [\r\n SdsDurationBoxComponent\r\n]\r\n\r\n@NgModule({\r\n declarations: [\r\n SdsDurationBoxComponent\r\n ],\r\n imports: [\r\n CommonModule,\r\n\r\n SdsDurationPipeModule,\r\n \r\n DxTextBoxModule,\r\n DxPopoverModule,\r\n DxScrollViewModule,\r\n ],\r\n exports: [\r\n ...components\r\n ]\r\n})\r\nexport class SdsDurationBoxModule { }\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.DurationService"],"mappings":";;;;;;;;;;;MAKa,eAAe,CAAA;AAExB,IAAA,WAAA,GAAA,GAAgB;AAET,IAAA,OAAO,CAAC,KAAa,EAAA;QACxB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AAC9B,YAAA,OAAO,CAAC,CAAC;AACZ,SAAA;QAED,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACvC,QAAA,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;;AAE1B,YAAA,OAAO,CAAC,CAAC;AACZ,SAAA;AAAM,aAAA,IAAI,aAAa,CAAC,MAAM,IAAI,CAAC,EAAC;;YAEjC,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa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A,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,EAbtB,OAAA,EAAA,CAAA;YACP,YAAY;YAEZ,qBAAqB;YAErB,eAAe;YACf,eAAe;YACf,kBAAkB;AACnB,SAAA,CAAA,EAAA,CAAA,CAAA;2FAKU,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAjBhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,uBAAuB;AACxB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;wBAEZ,qBAAqB;wBAErB,eAAe;wBACf,eAAe;wBACf,kBAAkB;AACnB,qBAAA;AACD,oBAAA,OAAO,EAAE;AACP,wBAAA,GAAG,UAAU;AACd,qBAAA;AACF,iBAAA,CAAA;;;AC5BD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,72 @@
|
|
|
1
1
|
import { EventEmitter, OnChanges, OnInit, SimpleChanges } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { DurationInputResolverService } from './duration-input-resolver.service';
|
|
2
|
+
import { DurationService } from './duration.service';
|
|
4
3
|
import * as i0 from "@angular/core";
|
|
5
4
|
export declare class SdsDurationBoxComponent implements OnInit, OnChanges {
|
|
6
5
|
private _durationInputResolver;
|
|
6
|
+
/**
|
|
7
|
+
* Duration length expressed in minutes; when we allow empty values this property can be null.
|
|
8
|
+
*
|
|
9
|
+
* @type {(number | null)}
|
|
10
|
+
* @memberof SdsDurationBoxComponent
|
|
11
|
+
*/
|
|
7
12
|
value: number | null;
|
|
8
13
|
valueChange: EventEmitter<number | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Allow user to select empty value. You should provide emptyValueText in this case.
|
|
16
|
+
*
|
|
17
|
+
* @type {boolean}
|
|
18
|
+
* @memberof SdsDurationBoxComponent
|
|
19
|
+
*/
|
|
9
20
|
allowEmptyValue: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 'emptyValueText' - text to be displayed when value is cleared
|
|
23
|
+
*
|
|
24
|
+
* @type {string}
|
|
25
|
+
* @memberof SdsDurationBoxComponent
|
|
26
|
+
*/
|
|
10
27
|
emptyValueText: string;
|
|
28
|
+
/**
|
|
29
|
+
* Array of pre-defined durations that will be displayed in dropdown for easier selection.
|
|
30
|
+
*
|
|
31
|
+
* @type {number[]}
|
|
32
|
+
* @memberof SdsDurationBoxComponent
|
|
33
|
+
*/
|
|
11
34
|
options?: number[];
|
|
35
|
+
/**
|
|
36
|
+
* Width of component
|
|
37
|
+
*
|
|
38
|
+
* @type {string}
|
|
39
|
+
* @memberof SdsDurationBoxComponent
|
|
40
|
+
*/
|
|
12
41
|
width: string;
|
|
13
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Specifies whether the UI component responds to user interaction.
|
|
44
|
+
*
|
|
45
|
+
* @type {boolean}
|
|
46
|
+
* @memberof SdsDurationBoxComponent
|
|
47
|
+
*/
|
|
48
|
+
disabled: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Specifies whether to display the Clear button in the UI component.
|
|
51
|
+
*
|
|
52
|
+
* @type {boolean}
|
|
53
|
+
* @memberof SdsDurationBoxComponent
|
|
54
|
+
*/
|
|
55
|
+
showClearButton: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The maximum value accepted by the duration box.
|
|
58
|
+
*
|
|
59
|
+
* @type {number}
|
|
60
|
+
* @memberof SdsDurationBoxComponent
|
|
61
|
+
*/
|
|
62
|
+
max?: number;
|
|
63
|
+
/**
|
|
64
|
+
* The minimum value accepted by the duration box.
|
|
65
|
+
*
|
|
66
|
+
* @type {number}
|
|
67
|
+
* @memberof SdsDurationBoxComponent
|
|
68
|
+
*/
|
|
69
|
+
min?: number;
|
|
14
70
|
elementUUID: string;
|
|
15
71
|
inputValue: string;
|
|
16
72
|
showOptions: boolean;
|
|
@@ -22,18 +78,22 @@ export declare class SdsDurationBoxComponent implements OnInit, OnChanges {
|
|
|
22
78
|
clearValueButton: {
|
|
23
79
|
icon: string;
|
|
24
80
|
stylingMode: string;
|
|
81
|
+
elementAttr: {
|
|
82
|
+
class: string;
|
|
83
|
+
};
|
|
25
84
|
onClick: () => void;
|
|
26
85
|
};
|
|
27
86
|
isValueEmpty: boolean;
|
|
28
87
|
private isValueSetInternally;
|
|
29
|
-
|
|
88
|
+
private _durationPipe;
|
|
89
|
+
constructor(_durationInputResolver: DurationService);
|
|
30
90
|
ngOnChanges(changes: SimpleChanges): void;
|
|
31
91
|
ngOnInit(): void;
|
|
32
92
|
blockNonNumberOrSemicolon(e: any): void;
|
|
33
|
-
resolveInput(
|
|
93
|
+
resolveInput(): void;
|
|
34
94
|
applyOption(value: number | null): void;
|
|
35
95
|
private setValue;
|
|
36
|
-
private
|
|
96
|
+
private setInputValueInternally;
|
|
37
97
|
static ɵfac: i0.ɵɵFactoryDeclaration<SdsDurationBoxComponent, never>;
|
|
38
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<SdsDurationBoxComponent, "sds-duration-box", never, { "value": "value"; "allowEmptyValue": "allowEmptyValue"; "emptyValueText": "emptyValueText"; "options": "options"; "width": "width"; }, { "valueChange": "valueChange"; }, never, never>;
|
|
98
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SdsDurationBoxComponent, "sds-duration-box", never, { "value": "value"; "allowEmptyValue": "allowEmptyValue"; "emptyValueText": "emptyValueText"; "options": "options"; "width": "width"; "disabled": "disabled"; "showClearButton": "showClearButton"; "max": "max"; "min": "min"; }, { "valueChange": "valueChange"; }, never, never>;
|
|
39
99
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export declare class DurationService {
|
|
3
|
+
constructor();
|
|
4
|
+
resolve(input: string): number | null;
|
|
5
|
+
isValidInput(input: string): boolean;
|
|
6
|
+
getDefaultValue(min?: number, max?: number): number;
|
|
7
|
+
isValueWithinLimits(value: number, min?: number, max?: number): boolean;
|
|
8
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DurationService, never>;
|
|
9
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DurationService>;
|
|
10
|
+
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export class DurationInputResolverService {
|
|
4
|
-
constructor() { }
|
|
5
|
-
resolve(input) {
|
|
6
|
-
if (!input || input.length === 0) {
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
const inputSegments = input.split(':');
|
|
10
|
-
if (inputSegments.length > 2) {
|
|
11
|
-
//invalid input
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
else if (inputSegments.length == 2) {
|
|
15
|
-
// we have hrs and minutes
|
|
16
|
-
const hrs = parseInt(inputSegments[0] ? inputSegments[0] : '0');
|
|
17
|
-
const mins = parseInt(inputSegments[1] ? inputSegments[1] : '0');
|
|
18
|
-
const totalMins = (hrs * 60) + mins;
|
|
19
|
-
return totalMins;
|
|
20
|
-
}
|
|
21
|
-
else if (inputSegments.length == 1) {
|
|
22
|
-
// take last two digits as mins
|
|
23
|
-
const nonSeparated = inputSegments[0];
|
|
24
|
-
let totalMins = 0;
|
|
25
|
-
if (nonSeparated.length <= 2) {
|
|
26
|
-
totalMins = parseInt(nonSeparated);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const lastIndex = nonSeparated.length - 2;
|
|
30
|
-
const part1 = nonSeparated.slice(0, lastIndex);
|
|
31
|
-
const part2 = nonSeparated.slice(lastIndex);
|
|
32
|
-
const hrs = parseInt(part1);
|
|
33
|
-
const mins = parseInt(part2);
|
|
34
|
-
totalMins = (hrs * 60) + mins;
|
|
35
|
-
}
|
|
36
|
-
return totalMins;
|
|
37
|
-
}
|
|
38
|
-
return 0;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
DurationInputResolverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DurationInputResolverService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
42
|
-
DurationInputResolverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DurationInputResolverService, providedIn: 'root' });
|
|
43
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DurationInputResolverService, decorators: [{
|
|
44
|
-
type: Injectable,
|
|
45
|
-
args: [{
|
|
46
|
-
providedIn: 'root',
|
|
47
|
-
}]
|
|
48
|
-
}], ctorParameters: function () { return []; } });
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHVyYXRpb24taW5wdXQtcmVzb2x2ZXIuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL25neC1zZHMtY29tcG9uZW50cy9zcmMvbGliL2R1cmF0aW9uLWJveC9kdXJhdGlvbi1pbnB1dC1yZXNvbHZlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7O0FBSzNDLE1BQU0sT0FBTyw0QkFBNEI7SUFFckMsZ0JBQWUsQ0FBQztJQUVULE9BQU8sQ0FBQyxLQUFhO1FBQ3hCLElBQUksQ0FBQyxLQUFLLElBQUksS0FBSyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUU7WUFDOUIsT0FBTyxDQUFDLENBQUM7U0FDWjtRQUVELE1BQU0sYUFBYSxHQUFHLEtBQUssQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUM7UUFDdkMsSUFBSSxhQUFhLENBQUMsTUFBTSxHQUFHLENBQUMsRUFBRTtZQUMxQixlQUFlO1lBQ2YsT0FBTyxDQUFDLEN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dXRTZWdtZW50cy5sZW5ndGggPT0gMil7XG4gICAgICAgICAgICAvLyB3ZSBoYXZlIGhycyBhbmQgbWludXRlc1xuICAgICAgICAgICAgY29uc3QgaHJzID0gcGFyc2VJbnQoaW5wdXRTZWdtZW50c1swXSA/IGlucHV0U2VnbWVudHNbMF0gOiAnMCcpO1xuICAgICAgICAgICAgY29uc3QgbWlucyA9IHBhcnNlSW50KGlucHV0U2VnbWVudHNbMV0gPyBpbnB1dFNlZ21lbnRzWzFdIDogJzAnKTtcbiAgICAgICAgICAgIGNvbnN0IHRvdGFsTWlucyA9IChocnMgKiA2MCkgKyBtaW5zO1xuXG4gICAgICAgICAgICByZXR1cm4gdG90YWxNaW5zO1xuICAgICAgICB9IGVsc2UgaWYgKGlucHV0U2VnbWVudHMubGVuZ3RoID09IDEpIHtcbiAgICAgICAgICAgIC8vIHRha2UgbGFzdCB0d28gZGlnaXRzIGFzIG1pbnNcbiAgICAgICAgICAgIGNvbnN0IG5vblNlcGFyYXRlZCA9IGlucHV0U2VnbWVudHNbMF07XG5cbiAgICAgICAgICAgIGxldCB0b3RhbE1pbnMgPSAwO1xuICAgICAgICAgICAgaWYgKG5vblNlcGFyYXRlZC5sZW5ndGggPD0gMikge1xuICAgICAgICAgICAgICAgIHRvdGFsTWlucyA9IHBhcnNlSW50KG5vblNlcGFyYXRlZClcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbGFzdEluZGV4ID0gbm9uU2VwYXJhdGVkLmxlbmd0aCAtIDI7XG4gICAgICAgICAgICAgICAgY29uc3QgcGFydDEgPSBub25TZXBhcmF0ZWQuc2xpY2UoMCwgbGFzdEluZGV4KTtcbiAgICAgICAgICAgICAgICBjb25zdCBwYXJ0MiA9IG5vblNlcGFyYXRlZC5zbGljZShsYXN0SW5kZXgpO1xuICAgICAgICAgICAgICAgIGNvbnN0IGhycyA9IHBhcnNlSW50KHBhcnQxKTtcbiAgICAgICAgICAgICAgICBjb25zdCBtaW5zID0gcGFyc2VJbnQocGFydDIpO1xuICAgICAgICAgICAgICAgIHRvdGFsTWlucyA9IChocnMgKiA2MCkgKyBtaW5zOyAgICAgICAgICAgIFxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRvdGFsTWlucztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gMDsgICAgICAgIFxuICAgIH1cbn1cbiJdfQ==
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class DurationInputResolverService {
|
|
3
|
-
constructor();
|
|
4
|
-
resolve(input: string): number | null;
|
|
5
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DurationInputResolverService, never>;
|
|
6
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<DurationInputResolverService>;
|
|
7
|
-
}
|