carbon-components-angular 3.14.7 → 3.15.3
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/datepicker/datepicker.component.d.ts +8 -4
- package/datepicker/datepicker.component.js +26 -10
- package/datepicker/datepicker.component.js.map +1 -1
- package/datepicker/datepicker.component.metadata.json +1 -1
- package/datepicker/datepicker.component.ngfactory.js +1 -1
- package/datepicker/datepicker.component.ngsummary.json +1 -1
- package/dialog/dialog.component.js +5 -29
- package/dialog/dialog.component.js.map +1 -1
- package/dialog/dialog.component.metadata.json +1 -1
- package/dialog/overflow-menu/overflow-menu-option.component.js +1 -1
- package/dialog/overflow-menu/overflow-menu-option.component.js.map +1 -1
- package/dialog/overflow-menu/overflow-menu-option.component.metadata.json +1 -1
- package/dialog/overflow-menu/overflow-menu-option.component.ngfactory.js +2 -2
- package/dialog/overflow-menu/overflow-menu-option.component.ngfactory.js.map +1 -1
- package/docs/documentation/components/ClickableTile.html +173 -160
- package/docs/documentation/components/DatePicker.html +109 -36
- package/docs/documentation/components/Dialog.html +12 -41
- package/docs/documentation/components/Dropdown.html +82 -176
- package/docs/documentation/components/HeaderItem.html +241 -11
- package/docs/documentation/components/OverflowMenuOption.html +5 -5
- package/docs/documentation/components/OverflowMenuPane.html +7 -7
- package/docs/documentation/components/SideNavItem.html +236 -13
- package/docs/documentation/components/Tooltip.html +7 -7
- package/docs/documentation/coverage.html +64 -16
- package/docs/documentation/images/coverage-badge-documentation.svg +1 -1
- package/docs/documentation/js/search/search_index.js +2 -2
- package/docs/documentation/miscellaneous/variables.html +144 -0
- package/docs/storybook/iframe.html +3 -3
- package/docs/storybook/{main.12c0e82df31275c6b327.bundle.js → main.d9349fe343a2c719f60b.bundle.js} +352 -99
- package/docs/storybook/main.d9349fe343a2c719f60b.bundle.js.map +1 -0
- package/docs/storybook/{runtime~main.12c0e82df31275c6b327.bundle.js → runtime~main.d9349fe343a2c719f60b.bundle.js} +1 -1
- package/docs/storybook/{runtime~main.12c0e82df31275c6b327.bundle.js.map → runtime~main.d9349fe343a2c719f60b.bundle.js.map} +1 -1
- package/docs/storybook/{vendors~main.12c0e82df31275c6b327.bundle.js → vendors~main.d9349fe343a2c719f60b.bundle.js} +5472 -1
- package/docs/storybook/vendors~main.d9349fe343a2c719f60b.bundle.js.map +1 -0
- package/dropdown/dropdown.component.d.ts +0 -4
- package/dropdown/dropdown.component.js +14 -25
- package/dropdown/dropdown.component.js.map +1 -1
- package/dropdown/dropdown.component.metadata.json +1 -1
- package/dropdown/dropdown.component.ngsummary.json +1 -1
- package/modal/modal.component.d.ts +1 -1
- package/package.json +1 -1
- package/tiles/clickable-tile.component.d.ts +19 -13
- package/tiles/clickable-tile.component.js +26 -17
- package/tiles/clickable-tile.component.js.map +1 -1
- package/tiles/clickable-tile.component.metadata.json +1 -1
- package/tiles/clickable-tile.component.ngfactory.js +8 -11
- package/tiles/clickable-tile.component.ngfactory.js.map +1 -1
- package/tiles/clickable-tile.component.ngsummary.json +1 -1
- package/tiles/tiles.module.ngfactory.js.map +1 -1
- package/ui-shell/header/header-item.component.d.ts +19 -1
- package/ui-shell/header/header-item.component.js +22 -5
- package/ui-shell/header/header-item.component.js.map +1 -1
- package/ui-shell/header/header-item.component.metadata.json +1 -1
- package/ui-shell/header/header-item.component.ngfactory.js +7 -3
- package/ui-shell/header/header-item.component.ngfactory.js.map +1 -1
- package/ui-shell/header/header-item.component.ngsummary.json +1 -1
- package/ui-shell/header/header.module.ngfactory.js.map +1 -1
- package/ui-shell/sidenav/sidenav-item.component.d.ts +19 -1
- package/ui-shell/sidenav/sidenav-item.component.js +22 -5
- package/ui-shell/sidenav/sidenav-item.component.js.map +1 -1
- package/ui-shell/sidenav/sidenav-item.component.metadata.json +1 -1
- package/ui-shell/sidenav/sidenav-item.component.ngfactory.js +7 -3
- package/ui-shell/sidenav/sidenav-item.component.ngfactory.js.map +1 -1
- package/ui-shell/sidenav/sidenav-item.component.ngsummary.json +1 -1
- package/ui-shell/sidenav/sidenav.module.ngfactory.js.map +1 -1
- package/utils/scroll.d.ts +38 -0
- package/utils/scroll.js +66 -0
- package/utils/scroll.js.map +1 -0
- package/utils/scroll.metadata.json +1 -0
- package/utils/scroll.ngsummary.json +1 -0
- package/breadcrumb/breadcrumb.component.spec.d.ts +0 -21
- package/bundle/carbon-angular.umd.js +0 -60
- package/bundle/carbon-angular.umd.js.map +0 -1
- package/checkbox/checkbox.component.spec.d.ts +0 -21
- package/code-snippet/code-snippet.component.spec.d.ts +0 -21
- package/combobox/combobox.component.spec.d.ts +0 -21
- package/common/utils.spec.d.ts +0 -21
- package/dialog/tooltip/tooltip.directive.spec.d.ts +0 -21
- package/docs/storybook/main.12c0e82df31275c6b327.bundle.js.map +0 -1
- package/docs/storybook/vendors~main.12c0e82df31275c6b327.bundle.js.map +0 -1
- package/dropdown/dropdown.component.spec.d.ts +0 -21
- package/dropdown/list/dropdown-list.component.spec.d.ts +0 -21
- package/grid/grid.directive.spec.d.ts +0 -21
- package/i18n/i18n.spec.d.ts +0 -21
- package/inline-loading/inline-loading.spec.d.ts +0 -21
- package/input/label.component.spec.d.ts +0 -21
- package/link/link.spec.d.ts +0 -21
- package/loading/loading.component.spec.d.ts +0 -21
- package/modal/modal.component.spec.d.ts +0 -21
- package/notification/notification.component.spec.d.ts +0 -21
- package/number-input/number.component.spec.d.ts +0 -21
- package/radio/radio.component.spec.d.ts +0 -21
- package/sample/sample-base.class.d.ts +0 -35
- package/sample/sample.component.d.ts +0 -48
- package/sample/sample.component.spec.d.ts +0 -21
- package/sample/sample.interface.d.ts +0 -29
- package/sample/sample.module.d.ts +0 -26
- package/sample/subcomponent/sample-sub.component.d.ts +0 -38
- package/sample/subcomponent/sample-sub.component.spec.d.ts +0 -21
- package/search/search.component.spec.d.ts +0 -21
- package/table/table-model.class.spec.d.ts +0 -21
- package/table/table.component.spec.d.ts +0 -21
- package/tabs/tab-headers.component.spec.d.ts +0 -21
- package/tabs/tabs.component.spec.d.ts +0 -22
- package/tiles/clickable-tile.component.spec.d.ts +0 -22
- package/tiles/tile.component.spec.d.ts +0 -22
- package/toggle/toggle.component.spec.d.ts +0 -21
- package/ui-shell/header/header.component.spec.d.ts +0 -21
- package/utils/a11y.d.ts +0 -26
- package/utils/position.d.ts +0 -21
- package/utils/utils.d.ts +0 -21
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
import { EventEmitter, ElementRef, OnDestroy, TemplateRef,
|
|
21
|
+
import { EventEmitter, ElementRef, OnDestroy, TemplateRef, OnChanges, SimpleChanges, AfterViewChecked } from "@angular/core";
|
|
22
22
|
/**
|
|
23
23
|
* [See demo](../../?path=/story/date-picker--single)
|
|
24
24
|
*
|
|
@@ -28,7 +28,7 @@ import { EventEmitter, ElementRef, OnDestroy, TemplateRef, AfterViewInit, OnChan
|
|
|
28
28
|
* @class DatePicker
|
|
29
29
|
* @implements {OnDestroy}
|
|
30
30
|
*/
|
|
31
|
-
export declare class DatePicker implements OnDestroy,
|
|
31
|
+
export declare class DatePicker implements OnDestroy, OnChanges, AfterViewChecked {
|
|
32
32
|
protected elementRef: ElementRef;
|
|
33
33
|
private static datePickerCount;
|
|
34
34
|
/**
|
|
@@ -70,11 +70,11 @@ export declare class DatePicker implements OnDestroy, AfterViewInit, OnChanges {
|
|
|
70
70
|
protected flatpickrInstance: any;
|
|
71
71
|
constructor(elementRef: ElementRef);
|
|
72
72
|
ngOnChanges(changes: SimpleChanges): void;
|
|
73
|
-
|
|
73
|
+
ngAfterViewChecked(): void;
|
|
74
74
|
onFocus(): void;
|
|
75
75
|
/**
|
|
76
76
|
* Writes a value from the model to the component. Expects the value to be `null` or `(Date | string)[]`
|
|
77
|
-
* @param value value
|
|
77
|
+
* @param value value received from the model
|
|
78
78
|
*/
|
|
79
79
|
writeValue(value: (Date | string)[]): void;
|
|
80
80
|
registerOnChange(fn: any): void;
|
|
@@ -104,4 +104,8 @@ export declare class DatePicker implements OnDestroy, AfterViewInit, OnChanges {
|
|
|
104
104
|
protected setDateValues(dates: (Date | string)[]): void;
|
|
105
105
|
protected doSelect(selectedValue: (Date | string)[]): void;
|
|
106
106
|
protected didDateValueChange(currentValue: any, previousValue: any): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* More advanced checking of the loaded state of flatpickr
|
|
109
|
+
*/
|
|
110
|
+
protected isFlatpickrLoaded(): boolean;
|
|
107
111
|
}
|
|
@@ -66,6 +66,7 @@ var DatePicker = /** @class */ (function () {
|
|
|
66
66
|
onOpen: function () { _this.updateClassNames(); },
|
|
67
67
|
value: this.value
|
|
68
68
|
};
|
|
69
|
+
this.flatpickrInstance = null;
|
|
69
70
|
this.onTouched = function () { };
|
|
70
71
|
this.propagateChange = function (_) { };
|
|
71
72
|
}
|
|
@@ -114,7 +115,7 @@ var DatePicker = /** @class */ (function () {
|
|
|
114
115
|
configurable: true
|
|
115
116
|
});
|
|
116
117
|
DatePicker.prototype.ngOnChanges = function (changes) {
|
|
117
|
-
if (this.
|
|
118
|
+
if (this.isFlatpickrLoaded()) {
|
|
118
119
|
var dates = this.flatpickrInstance.selectedDates;
|
|
119
120
|
if (changes.value && this.didDateValueChange(changes.value.currentValue, changes.value.previousValue)) {
|
|
120
121
|
dates = changes.value.currentValue;
|
|
@@ -124,10 +125,18 @@ var DatePicker = /** @class */ (function () {
|
|
|
124
125
|
this.setDateValues(dates);
|
|
125
126
|
}
|
|
126
127
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
// because the actual view may be delayed in loading (think projection into a tab pane)
|
|
129
|
+
// and because we rely on a library that operates outside the Angular view of the world
|
|
130
|
+
// we need to keep trying to load the library, until the relevant DOM is actually live
|
|
131
|
+
DatePicker.prototype.ngAfterViewChecked = function () {
|
|
132
|
+
if (!this.isFlatpickrLoaded()) {
|
|
133
|
+
this.flatpickrInstance = flatpickr("#" + this.id, this.flatpickrOptions);
|
|
134
|
+
// if (and only if) the initialization succeeded, we can set the date values
|
|
135
|
+
if (this.isFlatpickrLoaded()) {
|
|
136
|
+
if (this.value.length > 0) {
|
|
137
|
+
this.setDateValues(this.value);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
131
140
|
}
|
|
132
141
|
};
|
|
133
142
|
DatePicker.prototype.onFocus = function () {
|
|
@@ -135,7 +144,7 @@ var DatePicker = /** @class */ (function () {
|
|
|
135
144
|
};
|
|
136
145
|
/**
|
|
137
146
|
* Writes a value from the model to the component. Expects the value to be `null` or `(Date | string)[]`
|
|
138
|
-
* @param value value
|
|
147
|
+
* @param value value received from the model
|
|
139
148
|
*/
|
|
140
149
|
DatePicker.prototype.writeValue = function (value) {
|
|
141
150
|
this.value = value;
|
|
@@ -151,7 +160,7 @@ var DatePicker = /** @class */ (function () {
|
|
|
151
160
|
* Cleans up our flatpickr instance
|
|
152
161
|
*/
|
|
153
162
|
DatePicker.prototype.ngOnDestroy = function () {
|
|
154
|
-
if (!this.
|
|
163
|
+
if (!this.isFlatpickrLoaded()) {
|
|
155
164
|
return;
|
|
156
165
|
}
|
|
157
166
|
this.flatpickrInstance.destroy();
|
|
@@ -160,7 +169,7 @@ var DatePicker = /** @class */ (function () {
|
|
|
160
169
|
* Handles the `valueChange` event from the primary/single input
|
|
161
170
|
*/
|
|
162
171
|
DatePicker.prototype.onValueChange = function (event) {
|
|
163
|
-
if (this.
|
|
172
|
+
if (this.isFlatpickrLoaded()) {
|
|
164
173
|
var date = this.flatpickrInstance.parseDate(event, this.dateFormat);
|
|
165
174
|
if (this.range) {
|
|
166
175
|
this.setDateValues([date, this.flatpickrInstance.selectedDates[1]]);
|
|
@@ -175,7 +184,7 @@ var DatePicker = /** @class */ (function () {
|
|
|
175
184
|
* Handles the `valueChange` event from the range input
|
|
176
185
|
*/
|
|
177
186
|
DatePicker.prototype.onRangeValueChange = function (event) {
|
|
178
|
-
if (this.
|
|
187
|
+
if (this.isFlatpickrLoaded()) {
|
|
179
188
|
var date = this.flatpickrInstance.parseDate(event, this.dateFormat);
|
|
180
189
|
this.setDateValues([this.flatpickrInstance.selectedDates[0], date]);
|
|
181
190
|
this.doSelect(this.flatpickrInstance.selectedDates);
|
|
@@ -233,7 +242,7 @@ var DatePicker = /** @class */ (function () {
|
|
|
233
242
|
* @param dates the date values to apply
|
|
234
243
|
*/
|
|
235
244
|
DatePicker.prototype.setDateValues = function (dates) {
|
|
236
|
-
if (this.
|
|
245
|
+
if (this.isFlatpickrLoaded()) {
|
|
237
246
|
var singleInput = this.elementRef.nativeElement.querySelector("#" + this.id);
|
|
238
247
|
var rangeInput = this.elementRef.nativeElement.querySelector("#" + this.id + "-rangeInput");
|
|
239
248
|
// set the date on the instance
|
|
@@ -275,6 +284,13 @@ var DatePicker = /** @class */ (function () {
|
|
|
275
284
|
DatePicker.prototype.didDateValueChange = function (currentValue, previousValue) {
|
|
276
285
|
return currentValue[0] !== previousValue[0] || currentValue[1] !== previousValue[1];
|
|
277
286
|
};
|
|
287
|
+
/**
|
|
288
|
+
* More advanced checking of the loaded state of flatpickr
|
|
289
|
+
*/
|
|
290
|
+
DatePicker.prototype.isFlatpickrLoaded = function () {
|
|
291
|
+
// cast the instance to a boolean, and some method that has to exist for the library to be loaded in this case `setDate`
|
|
292
|
+
return !!this.flatpickrInstance && !!this.flatpickrInstance.setDate;
|
|
293
|
+
};
|
|
278
294
|
DatePicker.datePickerCount = 0;
|
|
279
295
|
DatePicker.decorators = [
|
|
280
296
|
{ type: Component, args: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datepicker.component.js","sourceRoot":"","sources":["../src/datepicker/datepicker.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,UAAU,EAEV,YAAY,EAKZ,MAAM,eAAe,CAAC;AACvB,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,i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AAE,iBAAiB;oBAC3B,QAAQ,EAAE,+iDA6CT;oBACD,MAAM,EAAE;wBACP,yDAEE;qBACF;oBACD,SAAS,EAAE;wBACV;4BACC,OAAO,EAAE,iBAAiB;4BAC1B,WAAW,EAAE,UAAU;4BACvB,KAAK,EAAE,IAAI;yBACX;qBACD;oBACD,aAAa,EAAE,iBAAiB,CAAC,IAAI;iBACrC;;;;gBAnFA,UAAU;;;wBA0FT,KAAK;6BAOL,KAAK;wBAEL,KAAK;6BAEL,KAAK;8BAEL,KAAK;0BAEL,KAAK;qBAEL,KAAK;wBAEL,KAAK;wBAWL,KAAK;2BAEL,KAAK;0BAEL,KAAK;8BAEL,KAAK;2BAEL,KAAK;0BAEL,KAAK;mCAEL,KAAK;8BA0BL,MAAM;0BAwCN,YAAY,SAAC,SAAS;;IA+JxB,iBAAC;CAAA,AA/UD,IA+UC;SAjRY,UAAU","sourcesContent":["import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tViewEncapsulation,\n\tElementRef,\n\tOnDestroy,\n\tHostListener,\n\tTemplateRef,\n\tAfterViewInit,\n\tOnChanges,\n\tSimpleChanges\n} from \"@angular/core\";\nimport rangePlugin from \"flatpickr/dist/plugins/rangePlugin\";\nimport flatpickr from \"flatpickr\";\nimport { NG_VALUE_ACCESSOR } from \"@angular/forms\";\nimport { carbonFlatpickrMonthSelectPlugin } from \"./carbon-flatpickr-month-select\";\n\n/**\n * [See demo](../../?path=/story/date-picker--single)\n *\n * <example-url>../../iframe.html?id=date-picker--single</example-url>\n *\n * @export\n * @class DatePicker\n * @implements {OnDestroy}\n */\n@Component({\n\tselector: \"ibm-date-picker\",\n\ttemplate: `\n\t<div class=\"bx--form-item\">\n\t\t<div class=\"bx--form-item\">\n\t\t\t<div\n\t\t\t\tclass=\"bx--date-picker\"\n\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t'bx--date-picker--range' : range,\n\t\t\t\t\t'bx--date-picker--single' : !range,\n\t\t\t\t\t'bx--date-picker--light' : theme === 'light',\n\t\t\t\t\t'bx--skeleton' : skeleton\n\t\t\t\t}\">\n\t\t\t\t<div class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"label\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? false : true)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\n\t\t\t\t<div *ngIf=\"range\" class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"rangeLabel\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id + '-rangeInput'\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? true : null)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onRangeValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t`,\n\tstyles: [\n\t\t`.dayContainer {\n\t\t\tjustify-content: initial;\n\t\t}`\n\t],\n\tproviders: [\n\t\t{\n\t\t\tprovide: NG_VALUE_ACCESSOR,\n\t\t\tuseExisting: DatePicker,\n\t\t\tmulti: true\n\t\t}\n\t],\n\tencapsulation: ViewEncapsulation.None\n})\nexport class DatePicker implements OnDestroy, AfterViewInit, OnChanges {\n\tprivate static datePickerCount = 0;\n\n\t/**\n\t * Select calendar range mode\n\t */\n\t@Input() range = false;\n\n\t/**\n\t * Format of date\n\t *\n\t * For reference: https://flatpickr.js.org/formatting/\n\t */\n\t@Input() dateFormat = \"m/d/Y\";\n\n\t@Input() label: string | TemplateRef<any>;\n\n\t@Input() rangeLabel: string;\n\n\t@Input() placeholder = \"mm/dd/yyyy\";\n\n\t@Input() pattern = \"^\\\\d{1,2}/\\\\d{1,2}/\\\\d{4}$\";\n\n\t@Input() id = `datepicker-${DatePicker.datePickerCount++}`;\n\n\t@Input() set value(v: (Date | string)[]) {\n\t\tif (!v) {\n\t\t\tv = [];\n\t\t}\n\t\tthis._value = v;\n\t}\n\n\tget value() {\n\t\treturn this._value;\n\t}\n\n\t@Input() theme: \"light\" | \"dark\" = \"dark\";\n\n\t@Input() disabled = false;\n\n\t@Input() invalid = false;\n\n\t@Input() invalidText: string | TemplateRef<any>;\n\n\t@Input() skeleton = false;\n\n\t@Input() plugins = [];\n\n\t@Input()\n\tset flatpickrOptions(options) {\n\t\tthis._flatpickrOptions = Object.assign({}, this._flatpickrOptions, options);\n\t}\n\tget flatpickrOptions() {\n\t\tconst plugins = [...this.plugins, carbonFlatpickrMonthSelectPlugin];\n\t\tif (this.range) {\n\t\t\tplugins.push(rangePlugin({ input: `#${this.id}-rangeInput`, position: \"left\"}));\n\t\t}\n\t\treturn Object.assign({}, this._flatpickrOptions, this.flatpickrBaseOptions, {\n\t\t\tmode: this.range ? \"range\" : \"single\",\n\t\t\tplugins,\n\t\t\tdateFormat: this.dateFormat\n\t\t});\n\t}\n\n\tset flatpickrOptionsRange (options) {\n\t\tconsole.warn(\"flatpickrOptionsRange is deprecated, use flatpickrOptions and set the range to true instead\");\n\t\tthis.range = true;\n\t\tthis.flatpickrOptions = options;\n\t}\n\tget flatpickrOptionsRange () {\n\t\tconsole.warn(\"flatpickrOptionsRange is deprecated, use flatpickrOptions and set the range to true instead\");\n\t\treturn this.flatpickrOptions;\n\t}\n\n\t@Output() valueChange: EventEmitter<any> = new EventEmitter();\n\n\tprotected _value = [];\n\n\tprotected _flatpickrOptions = {\n\t\tallowInput: true\n\t};\n\n\tprotected flatpickrBaseOptions = {\n\t\tmode: \"single\",\n\t\tdateFormat: \"m/d/Y\",\n\t\tplugins: this.plugins,\n\t\tonOpen: () => { this.updateClassNames(); },\n\t\tvalue: this.value\n\t};\n\n\tprotected flatpickrInstance;\n\n\tconstructor(protected elementRef: ElementRef) { }\n\n\tngOnChanges(changes: SimpleChanges) {\n\t\tif (this.flatpickrInstance) {\n\t\t\tlet dates = this.flatpickrInstance.selectedDates;\n\t\t\tif (changes.value && this.didDateValueChange(changes.value.currentValue, changes.value.previousValue)) {\n\t\t\t\tdates = changes.value.currentValue;\n\t\t\t}\n\t\t\t// only reset the flatpickr instance on Input changes\n\t\t\tthis.flatpickrInstance = flatpickr(`#${this.id}`, this.flatpickrOptions);\n\t\t\tthis.setDateValues(dates);\n\t\t}\n\t}\n\n\tngAfterViewInit() {\n\t\tthis.flatpickrInstance = flatpickr(`#${this.id}`, this.flatpickrOptions);\n\n\t\tif (this.value.length > 0) {\n\t\t\tthis.setDateValues(this.value);\n\t\t}\n\t}\n\n\t@HostListener(\"focusin\")\n\tonFocus() {\n\t\tthis.onTouched();\n\t}\n\n\t/**\n\t * Writes a value from the model to the component. Expects the value to be `null` or `(Date | string)[]`\n\t * @param value value recived from the model\n\t */\n\twriteValue(value: (Date | string)[]) {\n\t\tthis.value = value;\n\t\tthis.setDateValues(this.value);\n\t}\n\n\tregisterOnChange(fn: any) {\n\t\tthis.propagateChange = fn;\n\t}\n\n\tregisterOnTouched(fn: any) {\n\t\tthis.onTouched = fn;\n\t}\n\n\tonTouched: () => any = () => {};\n\n\tpropagateChange = (_: any) => {};\n\n\t/**\n\t * Cleans up our flatpickr instance\n\t */\n\tngOnDestroy() {\n\t\tif (!this.flatpickrInstance) { return; }\n\t\tthis.flatpickrInstance.destroy();\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the primary/single input\n\t */\n\tonValueChange(event: string) {\n\t\tif (this.flatpickrInstance) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tif (this.range) {\n\t\t\t\tthis.setDateValues([date, this.flatpickrInstance.selectedDates[1]]);\n\t\t\t} else {\n\t\t\t\tthis.setDateValues([date]);\n\t\t\t}\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the range input\n\t */\n\tonRangeValueChange(event: string) {\n\t\tif (this.flatpickrInstance) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tthis.setDateValues([this.flatpickrInstance.selectedDates[0], date]);\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Carbon uses a number of specific classnames for parts of the flatpickr - this idempotent method applies them if needed.\n\t */\n\tprotected updateClassNames() {\n\t\tif (!this.elementRef) { return; }\n\n\t\t// get all the possible flatpickrs in the document - we need to add classes to (potentially) all of them\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tconst monthContainer = document.querySelectorAll(\".flatpickr-month\");\n\t\tconst weekdaysContainer = document.querySelectorAll(\".flatpickr-weekdays\");\n\t\tconst weekdayContainer = document.querySelectorAll(\".flatpickr-weekday\");\n\t\tconst daysContainer = document.querySelectorAll(\".flatpickr-days\");\n\t\tconst dayContainer = document.querySelectorAll(\".flatpickr-day\");\n\n\t\t// add classes to lists of elements\n\t\tconst addClassIfNotExists = (classname: string, elementList: NodeListOf<Element>) => {\n\t\t\tArray.from(elementList).forEach(element => {\n\t\t\t\tif (!element.classList.contains(classname)) {\n\t\t\t\t\telement.classList.add(classname);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\t// add classes (but only if they don't exist, small perf win)\n\t\taddClassIfNotExists(\"bx--date-picker__calendar\", calendarContainer);\n\t\taddClassIfNotExists(\"bx--date-picker__month\", monthContainer);\n\t\taddClassIfNotExists(\"bx--date-picker__weekdays\", weekdaysContainer);\n\t\taddClassIfNotExists(\"bx--date-picker__days\", daysContainer);\n\n\t\t// add weekday classes and format the text\n\t\tArray.from(weekdayContainer).forEach(element => {\n\t\t\telement.innerHTML = element.innerHTML.replace(/\\s+/g, \"\");\n\t\t\telement.classList.add(\"bx--date-picker__weekday\");\n\t\t});\n\n\t\t// add day classes and special case the \"today\" element based on `this.value`\n\t\tArray.from(dayContainer).forEach(element => {\n\t\t\telement.classList.add(\"bx--date-picker__day\");\n\t\t\tif (!this.value) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (element.classList.contains(\"today\") && this.value.length > 0) {\n\t\t\t\telement.classList.add(\"no-border\");\n\t\t\t} else if (element.classList.contains(\"today\") && this.value.length === 0) {\n\t\t\t\telement.classList.remove(\"no-border\");\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Applies the given date value array to both the flatpickr instance and the `input`(s)\n\t * @param dates the date values to apply\n\t */\n\tprotected setDateValues(dates: (Date | string)[]) {\n\t\tif (this.flatpickrInstance) {\n\t\t\tconst singleInput = this.elementRef.nativeElement.querySelector(`#${this.id}`);\n\t\t\tconst rangeInput = this.elementRef.nativeElement.querySelector(`#${this.id}-rangeInput`);\n\n\t\t\t// set the date on the instance\n\t\t\tthis.flatpickrInstance.setDate(dates);\n\n\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\tlet singleDate = \"\";\n\t\t\t// if date is a string, parse and format\n\t\t\tif (typeof dates[0] === \"string\") {\n\t\t\t\tsingleDate = this.flatpickrInstance.parseDate(dates[0], this.dateFormat);\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(singleDate, this.dateFormat);\n\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t} else if (!!dates[0]) {\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(dates[0], this.dateFormat);\n\t\t\t}\n\t\t\t// apply the value\n\t\t\tsingleInput.value = singleDate;\n\n\t\t\tif (rangeInput) {\n\t\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\t\tlet rangeDate = \"\";\n\t\t\t\t// if date is a string, parse and format\n\t\t\t\tif (typeof dates[1] === \"string\") {\n\t\t\t\t\trangeDate = this.flatpickrInstance.parseDate(dates[1].toString(), this.dateFormat);\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(rangeDate, this.dateFormat);\n\t\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t\t} else if (!!dates[1]) {\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(dates[1], this.dateFormat);\n\t\t\t\t}\n\t\t\t\t// apply the value\n\t\t\t\trangeInput.value = rangeDate;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected doSelect(selectedValue: (Date | string)[]) {\n\t\tthis.valueChange.emit(selectedValue);\n\t\tthis.propagateChange(selectedValue);\n\t}\n\n\tprotected didDateValueChange(currentValue, previousValue) {\n\t\treturn currentValue[0] !== previousValue[0] || currentValue[1] !== previousValue[1];\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"datepicker.component.js","sourceRoot":"","sources":["../src/datepicker/datepicker.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,UAAU,EAEV,YAAY,EAKZ,MAAM,eAAe,CAAC;AACvB,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAEnF;;;;;;;;GAQG;AACH;IA0JC,oBAAsB,UAAsB;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CAAC,CAAC,CAAC;IACrF,CAAC;IAED;;OAEG;IACO,sCAAiB,GAA3B;QACC,wHAAwH;QACxH,OAAO,CAAC,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;IACrE,CAAC;IA/Rc,0BAAe,GAAG,CAAC,CAAC;;gBA/DnC,SAAS,SAAC;oBACV,QAAQ,EAAE,iBAAiB;oBAC3B,QAAQ,EAAE,+iDA6CT;oBACD,MAAM,EAAE;wBACP,yDAEE;qBACF;oBACD,SAAS,EAAE;wBACV;4BACC,OAAO,EAAE,iBAAiB;4BAC1B,WAAW,EAAE,UAAU;4BACvB,KAAK,EAAE,IAAI;yBACX;qBACD;oBACD,aAAa,EAAE,iBAAiB,CAAC,IAAI;iBACrC;;;;gBAnFA,UAAU;;;wBA0FT,KAAK;6BAOL,KAAK;wBAEL,KAAK;6BAEL,KAAK;8BAEL,KAAK;0BAEL,KAAK;qBAEL,KAAK;wBAEL,KAAK;wBAWL,KAAK;2BAEL,KAAK;0BAEL,KAAK;8BAEL,KAAK;2BAEL,KAAK;0BAEL,KAAK;mCAEL,KAAK;8BA0BL,MAAM;0BAgDN,YAAY,SAAC,SAAS;;IAuKxB,iBAAC;CAAA,AA/VD,IA+VC;SAjSY,UAAU","sourcesContent":["import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tViewEncapsulation,\n\tElementRef,\n\tOnDestroy,\n\tHostListener,\n\tTemplateRef,\n\tOnChanges,\n\tSimpleChanges,\n\tAfterViewChecked\n} from \"@angular/core\";\nimport rangePlugin from \"flatpickr/dist/plugins/rangePlugin\";\nimport flatpickr from \"flatpickr\";\nimport { NG_VALUE_ACCESSOR } from \"@angular/forms\";\nimport { carbonFlatpickrMonthSelectPlugin } from \"./carbon-flatpickr-month-select\";\n\n/**\n * [See demo](../../?path=/story/date-picker--single)\n *\n * <example-url>../../iframe.html?id=date-picker--single</example-url>\n *\n * @export\n * @class DatePicker\n * @implements {OnDestroy}\n */\n@Component({\n\tselector: \"ibm-date-picker\",\n\ttemplate: `\n\t<div class=\"bx--form-item\">\n\t\t<div class=\"bx--form-item\">\n\t\t\t<div\n\t\t\t\tclass=\"bx--date-picker\"\n\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t'bx--date-picker--range' : range,\n\t\t\t\t\t'bx--date-picker--single' : !range,\n\t\t\t\t\t'bx--date-picker--light' : theme === 'light',\n\t\t\t\t\t'bx--skeleton' : skeleton\n\t\t\t\t}\">\n\t\t\t\t<div class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"label\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? false : true)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\n\t\t\t\t<div *ngIf=\"range\" class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"rangeLabel\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id + '-rangeInput'\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? true : null)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onRangeValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t`,\n\tstyles: [\n\t\t`.dayContainer {\n\t\t\tjustify-content: initial;\n\t\t}`\n\t],\n\tproviders: [\n\t\t{\n\t\t\tprovide: NG_VALUE_ACCESSOR,\n\t\t\tuseExisting: DatePicker,\n\t\t\tmulti: true\n\t\t}\n\t],\n\tencapsulation: ViewEncapsulation.None\n})\nexport class DatePicker implements OnDestroy, OnChanges, AfterViewChecked {\n\tprivate static datePickerCount = 0;\n\n\t/**\n\t * Select calendar range mode\n\t */\n\t@Input() range = false;\n\n\t/**\n\t * Format of date\n\t *\n\t * For reference: https://flatpickr.js.org/formatting/\n\t */\n\t@Input() dateFormat = \"m/d/Y\";\n\n\t@Input() label: string | TemplateRef<any>;\n\n\t@Input() rangeLabel: string;\n\n\t@Input() placeholder = \"mm/dd/yyyy\";\n\n\t@Input() pattern = \"^\\\\d{1,2}/\\\\d{1,2}/\\\\d{4}$\";\n\n\t@Input() id = `datepicker-${DatePicker.datePickerCount++}`;\n\n\t@Input() set value(v: (Date | string)[]) {\n\t\tif (!v) {\n\t\t\tv = [];\n\t\t}\n\t\tthis._value = v;\n\t}\n\n\tget value() {\n\t\treturn this._value;\n\t}\n\n\t@Input() theme: \"light\" | \"dark\" = \"dark\";\n\n\t@Input() disabled = false;\n\n\t@Input() invalid = false;\n\n\t@Input() invalidText: string | TemplateRef<any>;\n\n\t@Input() skeleton = false;\n\n\t@Input() plugins = [];\n\n\t@Input()\n\tset flatpickrOptions(options) {\n\t\tthis._flatpickrOptions = Object.assign({}, this._flatpickrOptions, options);\n\t}\n\tget flatpickrOptions() {\n\t\tconst plugins = [...this.plugins, carbonFlatpickrMonthSelectPlugin];\n\t\tif (this.range) {\n\t\t\tplugins.push(rangePlugin({ input: `#${this.id}-rangeInput`, position: \"left\"}));\n\t\t}\n\t\treturn Object.assign({}, this._flatpickrOptions, this.flatpickrBaseOptions, {\n\t\t\tmode: this.range ? \"range\" : \"single\",\n\t\t\tplugins,\n\t\t\tdateFormat: this.dateFormat\n\t\t});\n\t}\n\n\tset flatpickrOptionsRange (options) {\n\t\tconsole.warn(\"flatpickrOptionsRange is deprecated, use flatpickrOptions and set the range to true instead\");\n\t\tthis.range = true;\n\t\tthis.flatpickrOptions = options;\n\t}\n\tget flatpickrOptionsRange () {\n\t\tconsole.warn(\"flatpickrOptionsRange is deprecated, use flatpickrOptions and set the range to true instead\");\n\t\treturn this.flatpickrOptions;\n\t}\n\n\t@Output() valueChange: EventEmitter<any> = new EventEmitter();\n\n\tprotected _value = [];\n\n\tprotected _flatpickrOptions = {\n\t\tallowInput: true\n\t};\n\n\tprotected flatpickrBaseOptions = {\n\t\tmode: \"single\",\n\t\tdateFormat: \"m/d/Y\",\n\t\tplugins: this.plugins,\n\t\tonOpen: () => { this.updateClassNames(); },\n\t\tvalue: this.value\n\t};\n\n\tprotected flatpickrInstance = null;\n\n\tconstructor(protected elementRef: ElementRef) { }\n\n\tngOnChanges(changes: SimpleChanges) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tlet dates = this.flatpickrInstance.selectedDates;\n\t\t\tif (changes.value && this.didDateValueChange(changes.value.currentValue, changes.value.previousValue)) {\n\t\t\t\tdates = changes.value.currentValue;\n\t\t\t}\n\t\t\t// only reset the flatpickr instance on Input changes\n\t\t\tthis.flatpickrInstance = flatpickr(`#${this.id}`, this.flatpickrOptions);\n\t\t\tthis.setDateValues(dates);\n\t\t}\n\t}\n\n\t// because the actual view may be delayed in loading (think projection into a tab pane)\n\t// and because we rely on a library that operates outside the Angular view of the world\n\t// we need to keep trying to load the library, until the relevant DOM is actually live\n\tngAfterViewChecked() {\n\t\tif (!this.isFlatpickrLoaded()) {\n\t\t\tthis.flatpickrInstance = flatpickr(`#${this.id}`, this.flatpickrOptions);\n\n\t\t\t// if (and only if) the initialization succeeded, we can set the date values\n\t\t\tif (this.isFlatpickrLoaded()) {\n\t\t\t\tif (this.value.length > 0) {\n\t\t\t\t\tthis.setDateValues(this.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@HostListener(\"focusin\")\n\tonFocus() {\n\t\tthis.onTouched();\n\t}\n\n\t/**\n\t * Writes a value from the model to the component. Expects the value to be `null` or `(Date | string)[]`\n\t * @param value value received from the model\n\t */\n\twriteValue(value: (Date | string)[]) {\n\t\tthis.value = value;\n\t\tthis.setDateValues(this.value);\n\t}\n\n\tregisterOnChange(fn: any) {\n\t\tthis.propagateChange = fn;\n\t}\n\n\tregisterOnTouched(fn: any) {\n\t\tthis.onTouched = fn;\n\t}\n\n\tonTouched: () => any = () => {};\n\n\tpropagateChange = (_: any) => {};\n\n\t/**\n\t * Cleans up our flatpickr instance\n\t */\n\tngOnDestroy() {\n\t\tif (!this.isFlatpickrLoaded()) { return; }\n\t\tthis.flatpickrInstance.destroy();\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the primary/single input\n\t */\n\tonValueChange(event: string) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tif (this.range) {\n\t\t\t\tthis.setDateValues([date, this.flatpickrInstance.selectedDates[1]]);\n\t\t\t} else {\n\t\t\t\tthis.setDateValues([date]);\n\t\t\t}\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the range input\n\t */\n\tonRangeValueChange(event: string) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tthis.setDateValues([this.flatpickrInstance.selectedDates[0], date]);\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Carbon uses a number of specific classnames for parts of the flatpickr - this idempotent method applies them if needed.\n\t */\n\tprotected updateClassNames() {\n\t\tif (!this.elementRef) { return; }\n\n\t\t// get all the possible flatpickrs in the document - we need to add classes to (potentially) all of them\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tconst monthContainer = document.querySelectorAll(\".flatpickr-month\");\n\t\tconst weekdaysContainer = document.querySelectorAll(\".flatpickr-weekdays\");\n\t\tconst weekdayContainer = document.querySelectorAll(\".flatpickr-weekday\");\n\t\tconst daysContainer = document.querySelectorAll(\".flatpickr-days\");\n\t\tconst dayContainer = document.querySelectorAll(\".flatpickr-day\");\n\n\t\t// add classes to lists of elements\n\t\tconst addClassIfNotExists = (classname: string, elementList: NodeListOf<Element>) => {\n\t\t\tArray.from(elementList).forEach(element => {\n\t\t\t\tif (!element.classList.contains(classname)) {\n\t\t\t\t\telement.classList.add(classname);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\t// add classes (but only if they don't exist, small perf win)\n\t\taddClassIfNotExists(\"bx--date-picker__calendar\", calendarContainer);\n\t\taddClassIfNotExists(\"bx--date-picker__month\", monthContainer);\n\t\taddClassIfNotExists(\"bx--date-picker__weekdays\", weekdaysContainer);\n\t\taddClassIfNotExists(\"bx--date-picker__days\", daysContainer);\n\n\t\t// add weekday classes and format the text\n\t\tArray.from(weekdayContainer).forEach(element => {\n\t\t\telement.innerHTML = element.innerHTML.replace(/\\s+/g, \"\");\n\t\t\telement.classList.add(\"bx--date-picker__weekday\");\n\t\t});\n\n\t\t// add day classes and special case the \"today\" element based on `this.value`\n\t\tArray.from(dayContainer).forEach(element => {\n\t\t\telement.classList.add(\"bx--date-picker__day\");\n\t\t\tif (!this.value) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (element.classList.contains(\"today\") && this.value.length > 0) {\n\t\t\t\telement.classList.add(\"no-border\");\n\t\t\t} else if (element.classList.contains(\"today\") && this.value.length === 0) {\n\t\t\t\telement.classList.remove(\"no-border\");\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Applies the given date value array to both the flatpickr instance and the `input`(s)\n\t * @param dates the date values to apply\n\t */\n\tprotected setDateValues(dates: (Date | string)[]) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tconst singleInput = this.elementRef.nativeElement.querySelector(`#${this.id}`);\n\t\t\tconst rangeInput = this.elementRef.nativeElement.querySelector(`#${this.id}-rangeInput`);\n\n\t\t\t// set the date on the instance\n\t\t\tthis.flatpickrInstance.setDate(dates);\n\n\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\tlet singleDate = \"\";\n\t\t\t// if date is a string, parse and format\n\t\t\tif (typeof dates[0] === \"string\") {\n\t\t\t\tsingleDate = this.flatpickrInstance.parseDate(dates[0], this.dateFormat);\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(singleDate, this.dateFormat);\n\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t} else if (!!dates[0]) {\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(dates[0], this.dateFormat);\n\t\t\t}\n\t\t\t// apply the value\n\t\t\tsingleInput.value = singleDate;\n\n\t\t\tif (rangeInput) {\n\t\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\t\tlet rangeDate = \"\";\n\t\t\t\t// if date is a string, parse and format\n\t\t\t\tif (typeof dates[1] === \"string\") {\n\t\t\t\t\trangeDate = this.flatpickrInstance.parseDate(dates[1].toString(), this.dateFormat);\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(rangeDate, this.dateFormat);\n\t\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t\t} else if (!!dates[1]) {\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(dates[1], this.dateFormat);\n\t\t\t\t}\n\t\t\t\t// apply the value\n\t\t\t\trangeInput.value = rangeDate;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected doSelect(selectedValue: (Date | string)[]) {\n\t\tthis.valueChange.emit(selectedValue);\n\t\tthis.propagateChange(selectedValue);\n\t}\n\n\tprotected didDateValueChange(currentValue, previousValue) {\n\t\treturn currentValue[0] !== previousValue[0] || currentValue[1] !== previousValue[1];\n\t}\n\n\t/**\n\t * More advanced checking of the loaded state of flatpickr\n\t */\n\tprotected isFlatpickrLoaded() {\n\t\t// cast the instance to a boolean, and some method that has to exist for the library to be loaded in this case `setDate`\n\t\treturn !!this.flatpickrInstance && !!this.flatpickrInstance.setDate;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"DatePicker":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":28,"character":1},"arguments":[{"selector":"ibm-date-picker","template":"\n\t<div class=\"bx--form-item\">\n\t\t<div class=\"bx--form-item\">\n\t\t\t<div\n\t\t\t\tclass=\"bx--date-picker\"\n\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t'bx--date-picker--range' : range,\n\t\t\t\t\t'bx--date-picker--single' : !range,\n\t\t\t\t\t'bx--date-picker--light' : theme === 'light',\n\t\t\t\t\t'bx--skeleton' : skeleton\n\t\t\t\t}\">\n\t\t\t\t<div class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"label\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? false : true)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\n\t\t\t\t<div *ngIf=\"range\" class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"rangeLabel\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id + '-rangeInput'\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? true : null)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onRangeValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t","styles":[".dayContainer {\n\t\t\tjustify-content: initial;\n\t\t}"],"providers":[{"provide":{"__symbolic":"reference","module":"@angular/forms","name":"NG_VALUE_ACCESSOR","line":83,"character":12},"useExisting":{"__symbolic":"reference","name":"DatePicker"},"multi":true}],"encapsulation":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewEncapsulation","line":88,"character":16},"member":"None"}}]}],"members":{"range":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":96,"character":2}}]}],"dateFormat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":103,"character":2}}]}],"label":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":105,"character":2}}]}],"rangeLabel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":107,"character":2}}]}],"placeholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":109,"character":2}}]}],"pattern":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":111,"character":2}}]}],"id":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":113,"character":2}}]}],"value":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":115,"character":2}}]}],"theme":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":126,"character":2}}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":128,"character":2}}]}],"invalid":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":130,"character":2}}]}],"invalidText":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":132,"character":2}}]}],"skeleton":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":134,"character":2}}]}],"plugins":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":136,"character":2}}]}],"flatpickrOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":138,"character":2}}]}],"valueChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":164,"character":2}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":182,"character":35}]}],"ngOnChanges":[{"__symbolic":"method"}],"
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"DatePicker":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":28,"character":1},"arguments":[{"selector":"ibm-date-picker","template":"\n\t<div class=\"bx--form-item\">\n\t\t<div class=\"bx--form-item\">\n\t\t\t<div\n\t\t\t\tclass=\"bx--date-picker\"\n\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t'bx--date-picker--range' : range,\n\t\t\t\t\t'bx--date-picker--single' : !range,\n\t\t\t\t\t'bx--date-picker--light' : theme === 'light',\n\t\t\t\t\t'bx--skeleton' : skeleton\n\t\t\t\t}\">\n\t\t\t\t<div class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"label\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? false : true)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\n\t\t\t\t<div *ngIf=\"range\" class=\"bx--date-picker-container\">\n\t\t\t\t\t<ibm-date-picker-input\n\t\t\t\t\t\t[label]=\"rangeLabel\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[id]=\"id + '-rangeInput'\"\n\t\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t\t[hasIcon]=\"(range ? true : null)\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t\t(valueChange)=\"onRangeValueChange($event)\">\n\t\t\t\t\t</ibm-date-picker-input>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t","styles":[".dayContainer {\n\t\t\tjustify-content: initial;\n\t\t}"],"providers":[{"provide":{"__symbolic":"reference","module":"@angular/forms","name":"NG_VALUE_ACCESSOR","line":83,"character":12},"useExisting":{"__symbolic":"reference","name":"DatePicker"},"multi":true}],"encapsulation":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewEncapsulation","line":88,"character":16},"member":"None"}}]}],"members":{"range":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":96,"character":2}}]}],"dateFormat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":103,"character":2}}]}],"label":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":105,"character":2}}]}],"rangeLabel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":107,"character":2}}]}],"placeholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":109,"character":2}}]}],"pattern":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":111,"character":2}}]}],"id":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":113,"character":2}}]}],"value":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":115,"character":2}}]}],"theme":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":126,"character":2}}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":128,"character":2}}]}],"invalid":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":130,"character":2}}]}],"invalidText":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":132,"character":2}}]}],"skeleton":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":134,"character":2}}]}],"plugins":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":136,"character":2}}]}],"flatpickrOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":138,"character":2}}]}],"valueChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":164,"character":2}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":182,"character":35}]}],"ngOnChanges":[{"__symbolic":"method"}],"ngAfterViewChecked":[{"__symbolic":"method"}],"onFocus":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":212,"character":2},"arguments":["focusin"]}]}],"writeValue":[{"__symbolic":"method"}],"registerOnChange":[{"__symbolic":"method"}],"registerOnTouched":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onValueChange":[{"__symbolic":"method"}],"onRangeValueChange":[{"__symbolic":"method"}],"updateClassNames":[{"__symbolic":"method"}],"setDateValues":[{"__symbolic":"method"}],"doSelect":[{"__symbolic":"method"}],"didDateValueChange":[{"__symbolic":"method"}],"isFlatpickrLoaded":[{"__symbolic":"method"}]},"statics":{"datePickerCount":0}}}}]
|
|
@@ -44,7 +44,7 @@ export function View_DatePicker_0(_l) { return i0.ɵvid(0, [(_l()(), i0.ɵeld(0,
|
|
|
44
44
|
export function View_DatePicker_Host_0(_l) { return i0.ɵvid(0, [(_l()(), i0.ɵeld(0, 0, null, null, 2, "ibm-date-picker", [], null, [[null, "focusin"]], function (_v, en, $event) { var ad = true; if (("focusin" === en)) {
|
|
45
45
|
var pd_0 = (i0.ɵnov(_v, 2).onFocus() !== false);
|
|
46
46
|
ad = (pd_0 && ad);
|
|
47
|
-
} return ad; }, View_DatePicker_0, RenderType_DatePicker)), i0.ɵprd(5120, null, i2.NG_VALUE_ACCESSOR, function (p0_0) { return [p0_0]; }, [i5.DatePicker]), i0.ɵdid(2,
|
|
47
|
+
} return ad; }, View_DatePicker_0, RenderType_DatePicker)), i0.ɵprd(5120, null, i2.NG_VALUE_ACCESSOR, function (p0_0) { return [p0_0]; }, [i5.DatePicker]), i0.ɵdid(2, 9093120, null, 0, i5.DatePicker, [i0.ElementRef], null, null)], null, null); }
|
|
48
48
|
var DatePickerNgFactory = i0.ɵccf("ibm-date-picker", i5.DatePicker, View_DatePicker_Host_0, { range: "range", dateFormat: "dateFormat", label: "label", rangeLabel: "rangeLabel", placeholder: "placeholder", pattern: "pattern", id: "id", value: "value", theme: "theme", disabled: "disabled", invalid: "invalid", invalidText: "invalidText", skeleton: "skeleton", plugins: "plugins", flatpickrOptions: "flatpickrOptions" }, { valueChange: "valueChange" }, []);
|
|
49
49
|
export { DatePickerNgFactory as DatePickerNgFactory };
|
|
50
50
|
//# sourceMappingURL=datepicker.component.ngfactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"moduleName":null,"summaries":[{"symbol":{"__symbol":0,"members":[]},"metadata":{"__symbolic":"class","members":{"range":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"dateFormat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"label":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"rangeLabel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"placeholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"pattern":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"id":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"value":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"theme":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"invalid":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"invalidText":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"skeleton":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"plugins":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"flatpickrOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"valueChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":2,"members":[]}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbol":3,"members":[]}]}],"ngOnChanges":[{"__symbolic":"method"}],"
|
|
1
|
+
{"moduleName":null,"summaries":[{"symbol":{"__symbol":0,"members":[]},"metadata":{"__symbolic":"class","members":{"range":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"dateFormat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"label":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"rangeLabel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"placeholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"pattern":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"id":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"value":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"theme":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"invalid":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"invalidText":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"skeleton":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"plugins":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"flatpickrOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":1,"members":[]}}]}],"valueChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbol":2,"members":[]}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbol":3,"members":[]}]}],"ngOnChanges":[{"__symbolic":"method"}],"ngAfterViewChecked":[{"__symbolic":"method"}],"onFocus":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbol":4,"members":[]},"arguments":["focusin"]}]}],"writeValue":[{"__symbolic":"method"}],"registerOnChange":[{"__symbolic":"method"}],"registerOnTouched":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onValueChange":[{"__symbolic":"method"}],"onRangeValueChange":[{"__symbolic":"method"}],"updateClassNames":[{"__symbolic":"method"}],"setDateValues":[{"__symbolic":"method"}],"doSelect":[{"__symbolic":"method"}],"didDateValueChange":[{"__symbolic":"method"}],"isFlatpickrLoaded":[{"__symbolic":"method"}]},"statics":{"datePickerCount":0}},"type":{"summaryKind":1,"type":{"reference":{"__symbol":0,"members":[]},"diDeps":[{"isAttribute":false,"isHost":false,"isSelf":false,"isSkipSelf":false,"isOptional":false,"token":{"identifier":{"reference":{"__symbol":3,"members":[]}}}}],"lifecycleHooks":[1,3,7]},"isComponent":true,"selector":"ibm-date-picker","exportAs":null,"inputs":{"range":"range","dateFormat":"dateFormat","label":"label","rangeLabel":"rangeLabel","placeholder":"placeholder","pattern":"pattern","id":"id","value":"value","theme":"theme","disabled":"disabled","invalid":"invalid","invalidText":"invalidText","skeleton":"skeleton","plugins":"plugins","flatpickrOptions":"flatpickrOptions"},"outputs":{"valueChange":"valueChange"},"hostListeners":{"focusin":"onFocus()"},"hostProperties":{},"hostAttributes":{},"providers":[{"token":{"identifier":{"reference":{"__symbol":5,"members":[]}}},"useClass":null,"useFactory":null,"useExisting":{"identifier":{"reference":{"__symbol":0,"members":[]}}},"multi":true}],"viewProviders":[],"queries":[],"guards":{},"viewQueries":[],"entryComponents":[],"changeDetection":1,"template":{"ngContentSelectors":[],"encapsulation":2},"componentViewType":{"__symbol":6,"members":[]},"rendererType":{"__symbol":7,"members":[]},"componentFactory":{"__symbol":8,"members":[]}}}],"symbols":[{"__symbol":0,"name":"DatePicker","filePath":"./datepicker.component"},{"__symbol":1,"name":"Input","filePath":"@angular/core"},{"__symbol":2,"name":"Output","filePath":"@angular/core"},{"__symbol":3,"name":"ElementRef","filePath":"@angular/core"},{"__symbol":4,"name":"HostListener","filePath":"@angular/core"},{"__symbol":5,"name":"NG_VALUE_ACCESSOR","filePath":"@angular/forms"},{"__symbol":6,"name":"View_DatePicker_0","filePath":"./datepicker.component.ngfactory"},{"__symbol":7,"name":"RenderType_DatePicker","filePath":"./datepicker.component.ngfactory"},{"__symbol":8,"name":"DatePickerNgFactory","filePath":"./datepicker.component.ngfactory"}]}
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
import { Component, Input, Output, EventEmitter, ElementRef, ViewChild, HostListener } from "@angular/core";
|
|
22
|
-
import { Subscription, fromEvent
|
|
22
|
+
import { Subscription, fromEvent } from "rxjs";
|
|
23
23
|
import { throttleTime } from "rxjs/operators";
|
|
24
24
|
// the AbsolutePosition is required to import the declaration correctly
|
|
25
25
|
import Position, { position } from "@carbon/utils-position";
|
|
26
26
|
import { cycleTabs, getFocusElementList } from "./../common/tab.service";
|
|
27
|
+
import { scrollableParentsObservable, isVisibleInContainer } from "./../utils/scroll";
|
|
27
28
|
/**
|
|
28
29
|
* Implements a `Dialog` that can be positioned anywhere on the page.
|
|
29
30
|
* Used to implement a popover or tooltip.
|
|
@@ -93,7 +94,7 @@ var Dialog = /** @class */ (function () {
|
|
|
93
94
|
Dialog.prototype.ngAfterViewInit = function () {
|
|
94
95
|
var _this = this;
|
|
95
96
|
var dialogElement = this.dialog.nativeElement;
|
|
96
|
-
// split the wrapper class list and apply separately to avoid IE
|
|
97
|
+
// split the wrapper class list and apply separately to avoid IE
|
|
97
98
|
// 1. throwing an error due to assigning a readonly property (classList)
|
|
98
99
|
// 2. throwing a SyntaxError due to passing an empty string to `add`
|
|
99
100
|
if (this.dialogConfig.wrapperClass) {
|
|
@@ -106,38 +107,13 @@ var Dialog = /** @class */ (function () {
|
|
|
106
107
|
if (getFocusElementList(this.dialog.nativeElement).length > 0) {
|
|
107
108
|
dialogElement.focus();
|
|
108
109
|
}
|
|
109
|
-
var
|
|
110
|
-
var node = parentEl;
|
|
111
|
-
var observables = [];
|
|
112
|
-
// if the element has an overflow set as part of
|
|
113
|
-
// its computed style it can scroll
|
|
114
|
-
var isScrollableElement = function (element) {
|
|
115
|
-
var computedStyle = getComputedStyle(element);
|
|
116
|
-
return (computedStyle.overflow === "auto" ||
|
|
117
|
-
computedStyle.overflow === "scroll" ||
|
|
118
|
-
computedStyle["overflow-y"] === "auto" ||
|
|
119
|
-
computedStyle["overflow-y"] === "scroll" ||
|
|
120
|
-
computedStyle["overflow-x"] === "auto" ||
|
|
121
|
-
computedStyle["overflow-x"] === "scroll");
|
|
122
|
-
};
|
|
123
|
-
var isVisibleInContainer = function (element, container) {
|
|
124
|
-
var elementRect = element.getBoundingClientRect();
|
|
125
|
-
var containerRect = container.getBoundingClientRect();
|
|
126
|
-
return elementRect.bottom <= containerRect.bottom && elementRect.top >= containerRect.top;
|
|
127
|
-
};
|
|
110
|
+
var parentElement = this.dialogConfig.parentRef.nativeElement;
|
|
128
111
|
var placeDialogInContainer = function () {
|
|
129
112
|
// only do the work to find the scroll containers if we're appended to body
|
|
130
113
|
// or skip this work if we're inline
|
|
131
114
|
if (!_this.dialogConfig.appendInline) {
|
|
132
|
-
// walk the parents and subscribe to all the scroll events we can
|
|
133
|
-
while (node.parentElement && node !== document.body) {
|
|
134
|
-
if (isScrollableElement(node)) {
|
|
135
|
-
observables.push(fromEvent(node, "scroll"));
|
|
136
|
-
}
|
|
137
|
-
node = node.parentElement;
|
|
138
|
-
}
|
|
139
115
|
// subscribe to the observable, and update the position and visibility
|
|
140
|
-
var scrollObservable =
|
|
116
|
+
var scrollObservable = scrollableParentsObservable(parentElement);
|
|
141
117
|
_this.scrollSubscription = scrollObservable.subscribe(function (event) {
|
|
142
118
|
_this.placeDialog();
|
|
143
119
|
if (!isVisibleInContainer(_this.dialogConfig.parentRef.nativeElement, event.target)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.component.js","sourceRoot":"","sources":["../src/dialog/dialog.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,SAAS,EAIT,YAAY,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,YAAY,EACZ,SAAS,EACT,KAAK,EACL,MAAM,MAAM,CAAC;AACd,OAAO,EAA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QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAG;YACvE,IAAI,CAAC,OAAO,EAAE,CAAC;SACf;IACF,CAAC;IAED;;OAEG;IACI,wBAAO,GAAd;QACC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,4BAAW,GAAX;QACC,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC;QACtC,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAjPD;;OAEG;IACc,uBAAgB,GAAoB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;;gBARzG,SAAS,SAAC;oBACV,QAAQ,EAAE,YAAY;oBACtB,QAAQ,EAAE,EAAE;iBACZ;;;;gBAjCA,UAAU;;;wBA0CT,MAAM;+BAKN,KAAK;yBAIL,SAAS,SAAC,QAAQ;8BAuLlB,YAAY,SAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;6BAqBlC,YAAY,SAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC;;IAsB3C,aAAC;CAAA,AAvPD,IAuPC;SAnPY,MAAM","sourcesContent":["import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tElementRef,\n\tViewChild,\n\tOnInit,\n\tAfterViewInit,\n\tOnDestroy,\n\tHostListener\n} from \"@angular/core\";\nimport {\n\tObservable,\n\tSubscription,\n\tfromEvent,\n\tmerge\n} from \"rxjs\";\nimport { throttleTime } from \"rxjs/operators\";\n// the AbsolutePosition is required to import the declaration correctly\nimport Position, { position, AbsolutePosition, Positions } from \"@carbon/utils-position\";\nimport { cycleTabs, getFocusElementList } from \"./../common/tab.service\";\nimport { DialogConfig } from \"./dialog-config.interface\";\n\n\n/**\n * Implements a `Dialog` that can be positioned anywhere on the page.\n * Used to implement a popover or tooltip.\n *\n * @export\n * @class Dialog\n * @implements {OnInit}\n * @implements {AfterViewInit}\n * @implements {OnDestroy}\n */\n@Component({\n\tselector: \"ibm-dialog\",\n\ttemplate: \"\"\n})\nexport class Dialog implements OnInit, AfterViewInit, OnDestroy {\n\t/**\n\t * One static event observable to handle window resizing.\n\t */\n\tprotected static resizeObservable: Observable<any> = fromEvent(window, \"resize\").pipe(throttleTime(100));\n\t/**\n\t * Emits event that handles the closing of a `Dialog` object.\n\t */\n\t@Output() close: EventEmitter<any> = new EventEmitter();\n\t/**\n\t * Receives `DialogConfig` interface object with properties of `Dialog`\n\t * explicitly defined.\n\t */\n\t@Input() dialogConfig: DialogConfig;\n\t/**\n\t * Maintains a reference to the view DOM element of the `Dialog`.\n\t */\n\t@ViewChild(\"dialog\") dialog: ElementRef;\n\n\t/**\n\t * Stores the data received from `dialogConfig`.\n\t */\n\tpublic data = {};\n\n\t/**\n\t * The placement of the `Dialog` is received from the `Position` service.\n\t */\n\tpublic placement: string;\n\n\t/**\n\t * `Subscription` used to update placement in the event of a window resize.\n\t */\n\tprotected resizeSubscription: Subscription;\n\t/**\n\t * Subscription to all the scrollable parents `scroll` event\n\t */\n\t// add a new subscription temporarily so that contexts (such as tests)\n\t// that don't run ngAfterViewInit have something to unsubscribe in ngOnDestroy\n\tprotected scrollSubscription: Subscription = new Subscription();\n\t/**\n\t * Handles offsetting the `Dialog` item based on the defined position\n\t * to not obscure the content beneath.\n\t */\n\tprotected addGap = {\n\t\t\"left\": pos => position.addOffset(pos, 0, -this.dialogConfig.gap),\n\t\t\"right\": pos => position.addOffset(pos, 0, this.dialogConfig.gap),\n\t\t\"top\": pos => position.addOffset(pos, -this.dialogConfig.gap),\n\t\t\"bottom\": pos => position.addOffset(pos, this.dialogConfig.gap),\n\t\t\"left-bottom\": pos => position.addOffset(pos, 0, -this.dialogConfig.gap),\n\t\t\"right-bottom\": pos => position.addOffset(pos, 0, this.dialogConfig.gap)\n\t};\n\n\t/**\n\t * Extra placements. Child classes can add to this for use in `placeDialog`.\n\t */\n\tprotected placements: Positions = {};\n\n\t/**\n\t * Creates an instance of `Dialog`.\n\t * @param {ElementRef} elementRef\n\t */\n\tconstructor(protected elementRef: ElementRef) {\t}\n\n\t/**\n\t * Initialize the `Dialog`, set the placement and gap, and add a `Subscription` to resize events.\n\t */\n\tngOnInit() {\n\t\tthis.placement = this.dialogConfig.placement.split(\",\")[0];\n\t\tthis.data = this.dialogConfig.data;\n\n\t\tthis.resizeSubscription = Dialog.resizeObservable.subscribe(() => {\n\t\t\tthis.placeDialog();\n\t\t});\n\n\t\t// run any additional initialization code that consuming classes may have\n\t\tthis.onDialogInit();\n\t}\n\n\t/**\n\t * After the DOM is ready, focus is set and dialog is placed\n\t * in respect to the parent element.\n\t */\n\tngAfterViewInit() {\n\t\tconst dialogElement = this.dialog.nativeElement;\n\t\t// split the wrapper class list and apply separately to avoid IE from\n\t\t// 1. throwing an error due to assigning a readonly property (classList)\n\t\t// 2. throwing a SyntaxError due to passing an empty string to `add`\n\t\tif (this.dialogConfig.wrapperClass) {\n\t\t\tfor (const extraClass of this.dialogConfig.wrapperClass.split(\" \")) {\n\t\t\t\tdialogElement.classList.add(extraClass);\n\t\t\t}\n\t\t}\n\t\tthis.placeDialog();\n\t\tif (getFocusElementList(this.dialog.nativeElement).length > 0) {\n\t\t\tdialogElement.focus();\n\t\t}\n\t\tconst parentEl: HTMLElement = this.dialogConfig.parentRef.nativeElement;\n\t\tlet node = parentEl;\n\t\tlet observables = [];\n\n\t\t// if the element has an overflow set as part of\n\t\t// its computed style it can scroll\n\t\tconst isScrollableElement = (element: HTMLElement) => {\n\t\t\tconst computedStyle = getComputedStyle(element);\n\t\t\treturn (\n\t\t\t\tcomputedStyle.overflow === \"auto\" ||\n\t\t\t\tcomputedStyle.overflow === \"scroll\" ||\n\t\t\t\tcomputedStyle[\"overflow-y\"] === \"auto\" ||\n\t\t\t\tcomputedStyle[\"overflow-y\"] === \"scroll\" ||\n\t\t\t\tcomputedStyle[\"overflow-x\"] === \"auto\" ||\n\t\t\t\tcomputedStyle[\"overflow-x\"] === \"scroll\"\n\t\t\t);\n\t\t};\n\n\t\tconst isVisibleInContainer = (element, container) => {\n\t\t\tconst elementRect = element.getBoundingClientRect();\n\t\t\tconst containerRect = container.getBoundingClientRect();\n\t\t\treturn elementRect.bottom <= containerRect.bottom && elementRect.top >= containerRect.top;\n\t\t};\n\n\t\tconst placeDialogInContainer = () => {\n\t\t\t// only do the work to find the scroll containers if we're appended to body\n\t\t\t// or skip this work if we're inline\n\t\t\tif (!this.dialogConfig.appendInline) {\n\t\t\t\t// walk the parents and subscribe to all the scroll events we can\n\t\t\t\twhile (node.parentElement && node !== document.body) {\n\t\t\t\t\tif (isScrollableElement(node)) {\n\t\t\t\t\t\tobservables.push(fromEvent(node, \"scroll\"));\n\t\t\t\t\t}\n\t\t\t\t\tnode = node.parentElement;\n\t\t\t\t}\n\t\t\t\t// subscribe to the observable, and update the position and visibility\n\t\t\t\tconst scrollObservable = merge(...observables);\n\t\t\t\tthis.scrollSubscription = scrollObservable.subscribe((event: any) => {\n\t\t\t\t\tthis.placeDialog();\n\t\t\t\t\tif (!isVisibleInContainer(this.dialogConfig.parentRef.nativeElement, event.target)) {\n\t\t\t\t\t\tthis.doClose();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\t// settimeout to let the DOM settle before attempting to place the dialog\n\t\t// and before notifying components that the DOM is ready\n\t\tsetTimeout(() => {\n\t\t\tplaceDialogInContainer();\n\t\t\tthis.afterDialogViewInit();\n\t\t});\n\t}\n\n\t/**\n\t * Empty method to be overridden by consuming classes to run any additional initialization code.\n\t */\n\tonDialogInit() {}\n\n\t/**\n\t * Empty method to be overridden by consuming classes to run any additional initialization code after the view is available.\n\t * NOTE: this does _not_ guarantee the dialog will be positioned, simply that it will exist in the DOM\n\t */\n\tafterDialogViewInit() {}\n\n\t/**\n\t * Uses the position service to position the `Dialog` in screen space\n\t */\n\tplaceDialog(): void {\n\t\tconst positionService = new Position(this.placements);\n\t\t// helper to find the position based on the current/given environment\n\t\tconst findPosition = (reference, target, placement) => {\n\t\t\tlet pos;\n\t\t\tif (this.dialogConfig.appendInline) {\n\t\t\t\tpos = this.addGap[placement](positionService.findRelative(reference, target, placement));\n\t\t\t} else {\n\t\t\t\tpos = this.addGap[placement](positionService.findAbsolute(reference, target, placement));\n\t\t\t}\n\t\t\treturn pos;\n\t\t};\n\n\t\tlet parentEl = this.dialogConfig.parentRef.nativeElement;\n\t\tlet el = this.dialog.nativeElement;\n\t\tlet dialogPlacement = this.placement;\n\n\t\t// split always returns an array, so we can just use the auto position logic\n\t\t// for single positions too\n\t\tconst placements = this.dialogConfig.placement.split(\",\");\n\n\t\t// find the best placement\n\t\tdialogPlacement = positionService.findBestPlacement(parentEl, el, placements);\n\n\t\t// calculate the final position\n\t\tconst pos = findPosition(parentEl, el, dialogPlacement);\n\n\t\t// update the element\n\t\tpositionService.setElement(el, pos);\n\t\tsetTimeout(() => { this.placement = dialogPlacement; });\n\t}\n\n\t/**\n\t * Sets up a KeyboardEvent to close `Dialog` with Escape key.\n\t * @param {KeyboardEvent} event\n\t */\n\t@HostListener(\"keydown\", [\"$event\"])\n\tescapeClose(event: KeyboardEvent) {\n\t\tswitch (event.key) {\n\t\t\tcase \"Esc\": // IE specific value\n\t\t\tcase \"Escape\": {\n\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t\tthis.doClose();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"Tab\": {\n\t\t\t\tcycleTabs(event, this.elementRef.nativeElement);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Sets up a event Listener to close `Dialog` if click event occurs outside\n\t * `Dialog` object.\n\t * @param {any} event\n\t */\n\t@HostListener(\"document:click\", [\"$event\"])\n\tclickClose(event) {\n\t\tif (!this.elementRef.nativeElement.contains(event.target)\n\t\t\t&& !this.dialogConfig.parentRef.nativeElement.contains(event.target) ) {\n\t\t\tthis.doClose();\n\t\t}\n\t}\n\n\t/**\n\t * Closes `Dialog` object by emitting the close event upwards to parents.\n\t */\n\tpublic doClose() {\n\t\tthis.close.emit();\n\t}\n\n\t/**\n\t * At destruction of component, `Dialog` unsubscribes from handling window resizing changes.\n\t */\n\tngOnDestroy() {\n\t\tthis.resizeSubscription.unsubscribe();\n\t\tthis.scrollSubscription.unsubscribe();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dialog.component.js","sourceRoot":"","sources":["../src/dialog/dialog.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,SAAS,EAIT,YAAY,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,YAAY,EACZ,SAAS,EAET,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAO,MAAM,gBAAgB,CAAC;AACnD,uEAAuE;AACvE,OAAO,QAAQ,EAAE,EAAE,QAAQ,EAA+B,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEtF;;;;;;;;;GASG;AACH;IA6DC;;;OAGG;IACH,gBAAsB,UAAsB;QAA5C,iBAAiD;QAA3B,eAAU,GAAV,UAAU,CAAY;QAxD5C;;WAEG;QACO,UAAK,GAAsB,IAAI,YAAY,EAAE,CAAC;QAWxD;;WAEG;QACI,SAAI,GAAG,EAAE,CAAC;QAWjB;;WAEG;QACH,sEAAsE;QACtE,8EAA8E;QACpE,uBAAkB,GAAiB,IAAI,YAAY,EAAE,CAAC;QAChE;;;WAGG;QACO,WAAM,GAAG;YAClB,MAAM,EAAE,UAAA,GAAG,IAAI,OAAA,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,KAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAlD,CAAkD;YACj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AAY;oBACtB,QAAQ,EAAE,EAAE;iBACZ;;;;gBAjCA,UAAU;;;wBA0CT,MAAM;+BAKN,KAAK;yBAIL,SAAS,SAAC,QAAQ;8BA0JlB,YAAY,SAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;6BAqBlC,YAAY,SAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC;;IAsB3C,aAAC;CAAA,AA1ND,IA0NC;SAtNY,MAAM","sourcesContent":["import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tElementRef,\n\tViewChild,\n\tOnInit,\n\tAfterViewInit,\n\tOnDestroy,\n\tHostListener\n} from \"@angular/core\";\nimport {\n\tObservable,\n\tSubscription,\n\tfromEvent,\n\tmerge\n} from \"rxjs\";\nimport { throttleTime, map } from \"rxjs/operators\";\n// the AbsolutePosition is required to import the declaration correctly\nimport Position, { position, AbsolutePosition, Positions } from \"@carbon/utils-position\";\nimport { cycleTabs, getFocusElementList } from \"./../common/tab.service\";\nimport { DialogConfig } from \"./dialog-config.interface\";\nimport { scrollableParentsObservable, isVisibleInContainer } from \"./../utils/scroll\";\n\n/**\n * Implements a `Dialog` that can be positioned anywhere on the page.\n * Used to implement a popover or tooltip.\n *\n * @export\n * @class Dialog\n * @implements {OnInit}\n * @implements {AfterViewInit}\n * @implements {OnDestroy}\n */\n@Component({\n\tselector: \"ibm-dialog\",\n\ttemplate: \"\"\n})\nexport class Dialog implements OnInit, AfterViewInit, OnDestroy {\n\t/**\n\t * One static event observable to handle window resizing.\n\t */\n\tprotected static resizeObservable: Observable<any> = fromEvent(window, \"resize\").pipe(throttleTime(100));\n\t/**\n\t * Emits event that handles the closing of a `Dialog` object.\n\t */\n\t@Output() close: EventEmitter<any> = new EventEmitter();\n\t/**\n\t * Receives `DialogConfig` interface object with properties of `Dialog`\n\t * explicitly defined.\n\t */\n\t@Input() dialogConfig: DialogConfig;\n\t/**\n\t * Maintains a reference to the view DOM element of the `Dialog`.\n\t */\n\t@ViewChild(\"dialog\") dialog: ElementRef;\n\n\t/**\n\t * Stores the data received from `dialogConfig`.\n\t */\n\tpublic data = {};\n\n\t/**\n\t * The placement of the `Dialog` is received from the `Position` service.\n\t */\n\tpublic placement: string;\n\n\t/**\n\t * `Subscription` used to update placement in the event of a window resize.\n\t */\n\tprotected resizeSubscription: Subscription;\n\t/**\n\t * Subscription to all the scrollable parents `scroll` event\n\t */\n\t// add a new subscription temporarily so that contexts (such as tests)\n\t// that don't run ngAfterViewInit have something to unsubscribe in ngOnDestroy\n\tprotected scrollSubscription: Subscription = new Subscription();\n\t/**\n\t * Handles offsetting the `Dialog` item based on the defined position\n\t * to not obscure the content beneath.\n\t */\n\tprotected addGap = {\n\t\t\"left\": pos => position.addOffset(pos, 0, -this.dialogConfig.gap),\n\t\t\"right\": pos => position.addOffset(pos, 0, this.dialogConfig.gap),\n\t\t\"top\": pos => position.addOffset(pos, -this.dialogConfig.gap),\n\t\t\"bottom\": pos => position.addOffset(pos, this.dialogConfig.gap),\n\t\t\"left-bottom\": pos => position.addOffset(pos, 0, -this.dialogConfig.gap),\n\t\t\"right-bottom\": pos => position.addOffset(pos, 0, this.dialogConfig.gap)\n\t};\n\n\t/**\n\t * Extra placements. Child classes can add to this for use in `placeDialog`.\n\t */\n\tprotected placements: Positions = {};\n\n\t/**\n\t * Creates an instance of `Dialog`.\n\t * @param {ElementRef} elementRef\n\t */\n\tconstructor(protected elementRef: ElementRef) {\t}\n\n\t/**\n\t * Initialize the `Dialog`, set the placement and gap, and add a `Subscription` to resize events.\n\t */\n\tngOnInit() {\n\t\tthis.placement = this.dialogConfig.placement.split(\",\")[0];\n\t\tthis.data = this.dialogConfig.data;\n\n\t\tthis.resizeSubscription = Dialog.resizeObservable.subscribe(() => {\n\t\t\tthis.placeDialog();\n\t\t});\n\n\t\t// run any additional initialization code that consuming classes may have\n\t\tthis.onDialogInit();\n\t}\n\n\t/**\n\t * After the DOM is ready, focus is set and dialog is placed\n\t * in respect to the parent element.\n\t */\n\tngAfterViewInit() {\n\t\tconst dialogElement = this.dialog.nativeElement;\n\t\t// split the wrapper class list and apply separately to avoid IE\n\t\t// 1. throwing an error due to assigning a readonly property (classList)\n\t\t// 2. throwing a SyntaxError due to passing an empty string to `add`\n\t\tif (this.dialogConfig.wrapperClass) {\n\t\t\tfor (const extraClass of this.dialogConfig.wrapperClass.split(\" \")) {\n\t\t\t\tdialogElement.classList.add(extraClass);\n\t\t\t}\n\t\t}\n\t\tthis.placeDialog();\n\t\tif (getFocusElementList(this.dialog.nativeElement).length > 0) {\n\t\t\tdialogElement.focus();\n\t\t}\n\t\tconst parentElement = this.dialogConfig.parentRef.nativeElement;\n\n\t\tconst placeDialogInContainer = () => {\n\t\t\t// only do the work to find the scroll containers if we're appended to body\n\t\t\t// or skip this work if we're inline\n\t\t\tif (!this.dialogConfig.appendInline) {\n\t\t\t\t// subscribe to the observable, and update the position and visibility\n\t\t\t\tconst scrollObservable = scrollableParentsObservable(parentElement);\n\t\t\t\tthis.scrollSubscription = scrollObservable.subscribe((event: any) => {\n\t\t\t\t\tthis.placeDialog();\n\t\t\t\t\tif (!isVisibleInContainer(this.dialogConfig.parentRef.nativeElement, event.target)) {\n\t\t\t\t\t\tthis.doClose();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\t// settimeout to let the DOM settle before attempting to place the dialog\n\t\t// and before notifying components that the DOM is ready\n\t\tsetTimeout(() => {\n\t\t\tplaceDialogInContainer();\n\t\t\tthis.afterDialogViewInit();\n\t\t});\n\t}\n\n\t/**\n\t * Empty method to be overridden by consuming classes to run any additional initialization code.\n\t */\n\tonDialogInit() {}\n\n\t/**\n\t * Empty method to be overridden by consuming classes to run any additional initialization code after the view is available.\n\t * NOTE: this does _not_ guarantee the dialog will be positioned, simply that it will exist in the DOM\n\t */\n\tafterDialogViewInit() {}\n\n\t/**\n\t * Uses the position service to position the `Dialog` in screen space\n\t */\n\tplaceDialog(): void {\n\t\tconst positionService = new Position(this.placements);\n\t\t// helper to find the position based on the current/given environment\n\t\tconst findPosition = (reference, target, placement) => {\n\t\t\tlet pos;\n\t\t\tif (this.dialogConfig.appendInline) {\n\t\t\t\tpos = this.addGap[placement](positionService.findRelative(reference, target, placement));\n\t\t\t} else {\n\t\t\t\tpos = this.addGap[placement](positionService.findAbsolute(reference, target, placement));\n\t\t\t}\n\t\t\treturn pos;\n\t\t};\n\n\t\tlet parentEl = this.dialogConfig.parentRef.nativeElement;\n\t\tlet el = this.dialog.nativeElement;\n\t\tlet dialogPlacement = this.placement;\n\n\t\t// split always returns an array, so we can just use the auto position logic\n\t\t// for single positions too\n\t\tconst placements = this.dialogConfig.placement.split(\",\");\n\n\t\t// find the best placement\n\t\tdialogPlacement = positionService.findBestPlacement(parentEl, el, placements);\n\n\t\t// calculate the final position\n\t\tconst pos = findPosition(parentEl, el, dialogPlacement);\n\n\t\t// update the element\n\t\tpositionService.setElement(el, pos);\n\t\tsetTimeout(() => { this.placement = dialogPlacement; });\n\t}\n\n\t/**\n\t * Sets up a KeyboardEvent to close `Dialog` with Escape key.\n\t * @param {KeyboardEvent} event\n\t */\n\t@HostListener(\"keydown\", [\"$event\"])\n\tescapeClose(event: KeyboardEvent) {\n\t\tswitch (event.key) {\n\t\t\tcase \"Esc\": // IE specific value\n\t\t\tcase \"Escape\": {\n\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t\tthis.doClose();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"Tab\": {\n\t\t\t\tcycleTabs(event, this.elementRef.nativeElement);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Sets up a event Listener to close `Dialog` if click event occurs outside\n\t * `Dialog` object.\n\t * @param {any} event\n\t */\n\t@HostListener(\"document:click\", [\"$event\"])\n\tclickClose(event) {\n\t\tif (!this.elementRef.nativeElement.contains(event.target)\n\t\t\t&& !this.dialogConfig.parentRef.nativeElement.contains(event.target) ) {\n\t\t\tthis.doClose();\n\t\t}\n\t}\n\n\t/**\n\t * Closes `Dialog` object by emitting the close event upwards to parents.\n\t */\n\tpublic doClose() {\n\t\tthis.close.emit();\n\t}\n\n\t/**\n\t * At destruction of component, `Dialog` unsubscribes from handling window resizing changes.\n\t */\n\tngOnDestroy() {\n\t\tthis.resizeSubscription.unsubscribe();\n\t\tthis.scrollSubscription.unsubscribe();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"Dialog":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":35,"character":1},"arguments":[{"selector":"ibm-dialog","template":""}]}],"members":{"close":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":47,"character":2}}]}],"dialogConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":52,"character":2}}]}],"dialog":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":56,"character":2},"arguments":["dialog"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":100,"character":35}]}],"ngOnInit":[{"__symbolic":"method"}],"ngAfterViewInit":[{"__symbolic":"method"}],"onDialogInit":[{"__symbolic":"method"}],"afterDialogViewInit":[{"__symbolic":"method"}],"placeDialog":[{"__symbolic":"method"}],"escapeClose":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"Dialog":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":35,"character":1},"arguments":[{"selector":"ibm-dialog","template":""}]}],"members":{"close":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":47,"character":2}}]}],"dialogConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":52,"character":2}}]}],"dialog":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":56,"character":2},"arguments":["dialog"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":100,"character":35}]}],"ngOnInit":[{"__symbolic":"method"}],"ngAfterViewInit":[{"__symbolic":"method"}],"onDialogInit":[{"__symbolic":"method"}],"afterDialogViewInit":[{"__symbolic":"method"}],"placeDialog":[{"__symbolic":"method"}],"escapeClose":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":210,"character":2},"arguments":["keydown",["$event"]]}]}],"clickClose":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":231,"character":2},"arguments":["document:click",["$event"]]}]}],"doClose":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}]},"statics":{"resizeObservable":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"rxjs","name":"fromEvent","line":43,"character":54},"arguments":[{"__symbolic":"reference","name":"window"},"resize"]},"member":"pipe"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"rxjs/operators","name":"throttleTime","line":43,"character":87},"arguments":[100]}]}}}}}]
|
|
@@ -84,7 +84,7 @@ var OverflowMenuOption = /** @class */ (function () {
|
|
|
84
84
|
OverflowMenuOption.decorators = [
|
|
85
85
|
{ type: Component, args: [{
|
|
86
86
|
selector: "ibm-overflow-menu-option",
|
|
87
|
-
template: "\n\t\t<button\n\t\t\t*ngIf=\"!href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick(
|
|
87
|
+
template: "\n\t\t<button\n\t\t\t*ngIf=\"!href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick()\"\n\t\t\t[disabled]=\"disabled\"\n\t\t\t[attr.title]=\"title\">\n\t\t\t<ng-container *ngTemplateOutlet=\"tempOutlet\"></ng-container>\n\t\t</button>\n\n\t\t<a\n\t\t\t*ngIf=\"href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick()\"\n\t\t\t[attr.disabled]=\"disabled\"\n\t\t\t[href]=\"href\"\n\t\t\t[attr.title]=\"title\">\n\t\t\t<ng-container *ngTemplateOutlet=\"tempOutlet\"></ng-container>\n\t\t</a>\n\n\t\t<ng-template #tempOutlet>\n\t\t\t<div class=\"bx--overflow-menu-options__option-content\">\n\t\t\t\t<ng-content></ng-content>\n\t\t\t</div>\n\t\t</ng-template>\n\t"
|
|
88
88
|
},] },
|
|
89
89
|
];
|
|
90
90
|
/** @nocollapse */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overflow-menu-option.component.js","sourceRoot":"","sources":["../../src/dialog/overflow-menu/overflow-menu-option.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,UAAU,EACV,MAAM,EACN,YAAY,EAEZ,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;GAWG;AACH;IAoEC,4BAAsB,UAAsB;QAAtB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C,WAAW,EAAE;YAC5C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;SAChC;IACF,CAAC;;gBAvFD,SAAS,SAAC;oBACV,QAAQ,EAAE,0BAA0B;oBACpC,QAAQ,EAAE,w6BAiCT;iBACD;;;;gBAtDA,UAAU;;;8BAwDT,WAAW,SAAC,OAAO;uBACnB,WAAW,SAAC,WAAW;2BAEvB,WAAW,SAAC,iDAAiD;6BAK7D,WAAW,SAAC,mDAAmD;uBAO/D,KAAK;2BAIL,KAAK;uBAEL,KAAK;2BAEL,MAAM;;IA2BR,yBAAC;CAAA,AAxFD,IAwFC;SAnDY,kBAAkB","sourcesContent":["import {\n\tHostBinding,\n\tComponent,\n\tInput,\n\tElementRef,\n\tOutput,\n\tEventEmitter,\n\tAfterViewInit\n} from \"@angular/core\";\n\n/**\n * `OverflowMenuOption` represents a single option in an overflow menu\n *\n * Presently it has three possible states - normal, disabled, and danger:\n * ```\n * <ibm-overflow-menu-option>Simple option</ibm-overflow-menu-option>\n * <ibm-overflow-menu-option disabled=\"true\">Disabled</ibm-overflow-menu-option>\n * <ibm-overflow-menu-option type=\"danger\">Danger option</ibm-overflow-menu-option>\n * ```\n *\n * For content that expands beyond the overflow menu `OverflowMenuOption` automatically adds a title attribute.\n */\n@Component({\n\tselector: \"ibm-overflow-menu-option\",\n\ttemplate: `\n\t\t<button\n\t\t\t*ngIf=\"!href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick()\"\n\t\t\t[disabled]=\"disabled\"\n\t\t\t[attr.title]=\"title\">\n\t\t\t<ng-container *ngTemplateOutlet=\"tempOutlet\"></ng-container>\n\t\t</button>\n\n\t\t<a\n\t\t\t*ngIf=\"href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick()\"\n\t\t\t[attr.disabled]=\"disabled\"\n\t\t\t[href]=\"href\"\n\t\t\t[attr.title]=\"title\">\n\t\t\t<ng-container *ngTemplateOutlet=\"tempOutlet\"></ng-container>\n\t\t</a>\n\n\t\t<ng-template #tempOutlet>\n\t\t\t<div class=\"bx--overflow-menu-options__option-content\">\n\t\t\t\t<ng-content></ng-content>\n\t\t\t</div>\n\t\t</ng-template>\n\t`\n})\nexport class OverflowMenuOption implements AfterViewInit {\n\t@HostBinding(\"class\") optionClass = \"bx--overflow-menu-options__option\";\n\t@HostBinding(\"attr.role\") role = \"presentation\";\n\n\t@HostBinding(\"class.bx--overflow-menu-options__option--danger\")\n\tpublic get isDanger(): Boolean {\n\t\treturn this.type === \"danger\";\n\t}\n\n\t@HostBinding(\"class.bx--overflow-menu-options__option--disabled\")\n\tpublic get isDisabled(): Boolean {\n\t\treturn this.disabled;\n\t}\n\t/**\n\t * toggles between `normal` and `danger` states\n\t */\n\t@Input() type: \"normal\" | \"danger\" = \"normal\";\n\t/**\n\t * disable/enable interactions\n\t */\n\t@Input() disabled = false;\n\n\t@Input() href: string;\n\n\t@Output() selected: EventEmitter<any> = new EventEmitter();\n\n\tpublic tabIndex = -1;\n\t// note: title must be a real attribute (i.e. not a getter) as of Angular@6 due to\n\t// change after checked errors\n\tpublic title = null;\n\n\tconstructor(protected elementRef: ElementRef) {}\n\n\tonClick() {\n\t\tthis.selected.emit();\n\t}\n\n\tonFocus() {\n\t\tsetTimeout(() => this.tabIndex = 0);\n\t}\n\n\tonBlur() {\n\t\tsetTimeout(() => this.tabIndex = -1);\n\t}\n\n\tngAfterViewInit() {\n\t\tconst button = this.elementRef.nativeElement.querySelector(\"button, a\");\n\t\tif (button.scrollWidth > button.offsetWidth) {\n\t\t\tthis.title = button.textContent;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"OverflowMenuOption":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":22,"character":1},"arguments":[{"selector":"ibm-overflow-menu-option","template":"\n\t\t<button\n\t\t\t*ngIf=\"!href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick(
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"OverflowMenuOption":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":22,"character":1},"arguments":[{"selector":"ibm-overflow-menu-option","template":"\n\t\t<button\n\t\t\t*ngIf=\"!href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick()\"\n\t\t\t[disabled]=\"disabled\"\n\t\t\t[attr.title]=\"title\">\n\t\t\t<ng-container *ngTemplateOutlet=\"tempOutlet\"></ng-container>\n\t\t</button>\n\n\t\t<a\n\t\t\t*ngIf=\"href\"\n\t\t\tclass=\"bx--overflow-menu-options__btn\"\n\t\t\trole=\"menuitem\"\n\t\t\t[tabindex]=\"tabIndex\"\n\t\t\t(focus)=\"onFocus()\"\n\t\t\t(blur)=\"onBlur()\"\n\t\t\t(click)=\"onClick()\"\n\t\t\t[attr.disabled]=\"disabled\"\n\t\t\t[href]=\"href\"\n\t\t\t[attr.title]=\"title\">\n\t\t\t<ng-container *ngTemplateOutlet=\"tempOutlet\"></ng-container>\n\t\t</a>\n\n\t\t<ng-template #tempOutlet>\n\t\t\t<div class=\"bx--overflow-menu-options__option-content\">\n\t\t\t\t<ng-content></ng-content>\n\t\t\t</div>\n\t\t</ng-template>\n\t"}]}],"members":{"optionClass":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostBinding","line":60,"character":2},"arguments":["class"]}]}],"role":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostBinding","line":61,"character":2},"arguments":["attr.role"]}]}],"isDanger":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostBinding","line":63,"character":2},"arguments":["class.bx--overflow-menu-options__option--danger"]}]}],"isDisabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostBinding","line":68,"character":2},"arguments":["class.bx--overflow-menu-options__option--disabled"]}]}],"type":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":75,"character":2}}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":79,"character":2}}]}],"href":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":81,"character":2}}]}],"selected":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":83,"character":2}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":90,"character":35}]}],"onClick":[{"__symbolic":"method"}],"onFocus":[{"__symbolic":"method"}],"onBlur":[{"__symbolic":"method"}],"ngAfterViewInit":[{"__symbolic":"method"}]}}}}]
|
|
@@ -38,7 +38,7 @@ function View_OverflowMenuOption_1(_l) { return i0.ɵvid(0, [(_l()(), i0.ɵeld(0
|
|
|
38
38
|
var pd_1 = (_co.onBlur() !== false);
|
|
39
39
|
ad = (pd_1 && ad);
|
|
40
40
|
} if (("click" === en)) {
|
|
41
|
-
var pd_2 = (_co.onClick(
|
|
41
|
+
var pd_2 = (_co.onClick() !== false);
|
|
42
42
|
ad = (pd_2 && ad);
|
|
43
43
|
} return ad; }, null, null)), (_l()(), i0.ɵand(16777216, null, null, 1, null, View_OverflowMenuOption_2)), i0.ɵdid(2, 540672, null, 0, i1.NgTemplateOutlet, [i0.ViewContainerRef], { ngTemplateOutlet: [0, "ngTemplateOutlet"] }, null)], function (_ck, _v) { var currVal_3 = i0.ɵnov(_v.parent, 4); _ck(_v, 2, 0, currVal_3); }, function (_ck, _v) { var _co = _v.component; var currVal_0 = _co.tabIndex; var currVal_1 = _co.disabled; var currVal_2 = _co.title; _ck(_v, 0, 0, currVal_0, currVal_1, currVal_2); }); }
|
|
44
44
|
function View_OverflowMenuOption_4(_l) { return i0.ɵvid(0, [(_l()(), i0.ɵeld(0, 0, null, null, 0, null, null, null, null, null, null, null))], null, null); }
|
|
@@ -49,7 +49,7 @@ function View_OverflowMenuOption_3(_l) { return i0.ɵvid(0, [(_l()(), i0.ɵeld(0
|
|
|
49
49
|
var pd_1 = (_co.onBlur() !== false);
|
|
50
50
|
ad = (pd_1 && ad);
|
|
51
51
|
} if (("click" === en)) {
|
|
52
|
-
var pd_2 = (_co.onClick(
|
|
52
|
+
var pd_2 = (_co.onClick() !== false);
|
|
53
53
|
ad = (pd_2 && ad);
|
|
54
54
|
} return ad; }, null, null)), (_l()(), i0.ɵand(16777216, null, null, 1, null, View_OverflowMenuOption_4)), i0.ɵdid(2, 540672, null, 0, i1.NgTemplateOutlet, [i0.ViewContainerRef], { ngTemplateOutlet: [0, "ngTemplateOutlet"] }, null)], function (_ck, _v) { var currVal_4 = i0.ɵnov(_v.parent, 4); _ck(_v, 2, 0, currVal_4); }, function (_ck, _v) { var _co = _v.component; var currVal_0 = _co.tabIndex; var currVal_1 = _co.disabled; var currVal_2 = _co.href; var currVal_3 = _co.title; _ck(_v, 0, 0, currVal_0, currVal_1, currVal_2, currVal_3); }); }
|
|
55
55
|
function View_OverflowMenuOption_5(_l) { return i0.ɵvid(0, [(_l()(), i0.ɵeld(0, 0, null, null, 1, "div", [["class", "bx--overflow-menu-options__option-content"]], null, null, null, null, null)), i0.ɵncd(null, 0)], null, null); }
|