This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bring-mac-tests-back
- Loading branch information
Showing
28 changed files
with
777 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright IBM Corp. 2020 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { Directive, forwardRef } from '@angular/core'; | ||
import { NG_VALUE_ACCESSOR, SelectControlValueAccessor } from '@angular/forms'; | ||
import settings from 'carbon-components/es/globals/js/settings'; | ||
|
||
const prefix = settings.prefix; // eslint-disable-line prefer-destructuring | ||
|
||
const host = { | ||
'(blur)': 'onTouched()', | ||
}; | ||
|
||
// NOTE: Referring `BXComboBox.eventChange` seems to cause ng-packagr to package up `src/components/combo-box/combo-box.ts` code, | ||
// Which is not desirable | ||
host[`(${prefix}-combo-box-selected)`] = 'onChange($event.detail.item.value)'; | ||
|
||
@Directive({ | ||
selector: `${prefix}-combo-box[formControlName],${prefix}-combo-box[formControl],${prefix}-combo-box[ngModel]`, | ||
host, | ||
providers: [ | ||
{ | ||
provide: NG_VALUE_ACCESSOR, | ||
useExisting: forwardRef(() => BXComboBoxDirective), // eslint-disable-line no-use-before-define | ||
multi: true, | ||
}, | ||
], | ||
}) | ||
export class BXComboBoxDirective extends SelectControlValueAccessor {} // eslint-disable-line import/prefer-default-export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright IBM Corp. 2020 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { Directive, forwardRef } from '@angular/core'; | ||
import { NG_VALUE_ACCESSOR, SelectControlValueAccessor } from '@angular/forms'; | ||
import settings from 'carbon-components/es/globals/js/settings'; | ||
|
||
const prefix = settings.prefix; // eslint-disable-line prefer-destructuring | ||
|
||
const host = { | ||
'(blur)': 'onTouched()', | ||
}; | ||
|
||
// NOTE: Referring `BXDropdown.eventChange` seems to cause ng-packagr to package up `src/components/dropdown/dropdown.ts` code, | ||
// Which is not desirable | ||
host[`(${prefix}-dropdown-selected)`] = 'onChange($event.detail.item.value)'; | ||
|
||
@Directive({ | ||
selector: `${prefix}-dropdown[formControlName],${prefix}-dropdown[formControl],${prefix}-dropdown[ngModel]`, | ||
host, | ||
providers: [ | ||
{ | ||
provide: NG_VALUE_ACCESSOR, | ||
useExisting: forwardRef(() => BXDropdownDirective), // eslint-disable-line no-use-before-define | ||
multi: true, | ||
}, | ||
], | ||
}) | ||
export class BXDropdownDirective extends SelectControlValueAccessor {} // eslint-disable-line import/prefer-default-export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright IBM Corp. 2019 | ||
* Copyright IBM Corp. 2019, 2020 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { NgModule } from '@angular/core'; | ||
import { BXCheckboxDirective } from './checkbox'; | ||
import { BXComboBoxDirective } from './combo-box'; | ||
import { BXDropdownDirective } from './dropdown'; | ||
import { BXInputDirective } from './input'; | ||
import { BXMultiSelectDirective } from './multi-select'; | ||
import { BXNumberInputDirective } from './number-input'; | ||
import { BXSliderDirective } from './slider'; | ||
import { BXToggleDirective } from './toggle'; | ||
|
||
@NgModule({ | ||
declarations: [BXCheckboxDirective, BXInputDirective, BXSliderDirective, BXToggleDirective], | ||
exports: [BXCheckboxDirective, BXInputDirective, BXSliderDirective, BXToggleDirective], | ||
declarations: [ | ||
BXCheckboxDirective, | ||
BXComboBoxDirective, | ||
BXDropdownDirective, | ||
BXInputDirective, | ||
BXMultiSelectDirective, | ||
BXNumberInputDirective, | ||
BXSliderDirective, | ||
BXToggleDirective, | ||
], | ||
exports: [ | ||
BXCheckboxDirective, | ||
BXComboBoxDirective, | ||
BXDropdownDirective, | ||
BXInputDirective, | ||
BXMultiSelectDirective, | ||
BXNumberInputDirective, | ||
BXSliderDirective, | ||
BXToggleDirective, | ||
], | ||
}) | ||
export class BXFormAccessorsModule {} // eslint-disable-line import/prefer-default-export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright IBM Corp. 2020 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { Directive, forwardRef } from '@angular/core'; | ||
import { NG_VALUE_ACCESSOR, SelectMultipleControlValueAccessor } from '@angular/forms'; | ||
import settings from 'carbon-components/es/globals/js/settings'; | ||
|
||
const prefix = settings.prefix; // eslint-disable-line prefer-destructuring | ||
|
||
const host = { | ||
'(blur)': 'onTouched()', | ||
}; | ||
|
||
// NOTE: Referring `BXMultiSelect.eventChange` seems to cause | ||
// ng-packagr to package up `src/components/multi-select/multi-select.ts` code, Which is not desirable | ||
host[`(${prefix}-multi-select-selected)`] = 'onChange($event.detail.item.value)'; | ||
|
||
@Directive({ | ||
selector: `${prefix}-multi-select[formControlName],${prefix}-multi-select[formControl],${prefix}-multi-select[ngModel]`, | ||
host, | ||
providers: [ | ||
{ | ||
provide: NG_VALUE_ACCESSOR, | ||
useExisting: forwardRef(() => BXMultiSelectDirective), // eslint-disable-line no-use-before-define | ||
multi: true, | ||
}, | ||
], | ||
}) | ||
// eslint-disable-next-line import/prefer-default-export | ||
export class BXMultiSelectDirective extends SelectMultipleControlValueAccessor { | ||
/** | ||
* Registers `onChange` handler. | ||
* @param fn The event listener. | ||
*/ | ||
registerOnChange(fn: (selected: string[]) => void) { | ||
// NOTE: Referring `BXMultiSelect` seems to cause ng-packagr to package up `src/components/multi-select/multi-select.ts` code, | ||
this.onChange = function handleOnChange(selectedValue) { | ||
const { value: oldValue } = this; | ||
const oldValues = !oldValue ? [] : oldValue.split(','); | ||
const values = | ||
oldValues.indexOf(selectedValue) < 0 | ||
? oldValues.concat(selectedValue) | ||
: oldValues.filter(oldItemValue => oldItemValue !== selectedValue); | ||
const value = values.join(','); | ||
this.value = value; | ||
fn(value); | ||
}; | ||
} | ||
} |
Oops, something went wrong.