Skip to content

Commit aa48cd6

Browse files
authored
Merge branch 'master' into next
Merge branch 'master' into next
2 parents e710289 + 369fff6 commit aa48cd6

31 files changed

+576
-93
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ That's it! Now we can run `npm start` and start building out our application!
4444

4545
> *Note:* This isn't the only way to bootstrap a `carbon-components-angular` application, but the combination of `@angular/cli` and the `carbon-components` scss is our recommended setup.
4646
47-
[![Edit Carbon Components Angular](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/0129r494ql)
47+
[![Edit Carbon Components Angular](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/stackblitz-starters-exxkq4?file=src%2Fmain.ts)
4848

4949
### Support
5050

package-lock.json

Lines changed: 78 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"@angular/platform-browser-dynamic": "18.2.12",
8383
"@angular/router": "18.2.12",
8484
"@babel/core": "7.9.6",
85-
"@carbon/styles": "1.67.0",
85+
"@carbon/styles": "1.70.0",
8686
"@commitlint/cli": "17.0.3",
8787
"@commitlint/config-conventional": "17.0.3",
8888
"@compodoc/compodoc": "1.1.26",

src/button/icon-button.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { ButtonSize, ButtonType } from "./button.types";
2727
<cds-tooltip
2828
class="cds--icon-tooltip"
2929
[description]="description"
30-
[disabled]="disabled"
30+
[disabled]="showTooltipWhenDisabled ? false : disabled"
3131
[caret]="caret"
3232
[dropShadow]="dropShadow"
3333
[highContrast]="highContrast"
@@ -123,6 +123,10 @@ export class IconButton extends BaseIconButton implements AfterViewInit {
123123
* The string or template content to be exposed by the tooltip.
124124
*/
125125
@Input() description: string | TemplateRef<any>;
126+
/**
127+
* Indicates whether the tooltip should be shown when the button is disabled
128+
*/
129+
@Input() showTooltipWhenDisabled = false;
126130

127131
/**
128132
* Common button events

src/button/icon-button.stories.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default {
2323
size: "md",
2424
isExpressive: "false",
2525
disabled: false,
26-
autoAlign: false
26+
autoAlign: false,
27+
showTooltipWhenDisabled: false
2728
},
2829
argTypes: {
2930
align: {
@@ -54,6 +55,9 @@ export default {
5455
disabled: {
5556
type: "boolean"
5657
},
58+
showTooltipWhenDisabled: {
59+
type: "boolean"
60+
},
5761
// Actions
5862
onClick: { action: "clicked" },
5963
onMouseEnter: { action: "mouseenter" },
@@ -79,6 +83,7 @@ const Template = (args) => ({
7983
[buttonNgClass]="buttonNgClass"
8084
[buttonAttributes]="buttonAttributes"
8185
[disabled]="disabled"
86+
[showTooltipWhenDisabled]="showTooltipWhenDisabled"
8287
description="Icon Description"
8388
(click)="onClick($event)"
8489
(mouseenter)="onMouseEnter($event)"
@@ -115,6 +120,7 @@ const AutoAlignTemplate = (args) => ({
115120
[isOpen]="isOpen"
116121
[buttonNgClass]="buttonNgClass"
117122
[disabled]="disabled"
123+
[showTooltipWhenDisabled]="showTooltipWhenDisabled"
118124
[description]="description"
119125
(click)="onClick($event)"
120126
(mouseenter)="onMouseEnter($event)"
@@ -134,3 +140,4 @@ WithAutoAlign.args = {
134140
align: "top",
135141
isOpen: true
136142
};
143+

src/combobox/combobox.component.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ import { Observable } from "rxjs";
4040
@Component({
4141
selector: "cds-combo-box, ibm-combo-box",
4242
template: `
43-
<div class="cds--list-box__wrapper">
43+
<div
44+
class="cds--list-box__wrapper"
45+
[ngClass]="{
46+
'cds--list-box__wrapper--fluid': fluid,
47+
'cds--list-box__wrapper--fluid--invalid': fluid && invalid,
48+
'cds--list-box__wrapper--fluid--focus': fluid && _isFocused
49+
}">
4450
<label
4551
*ngIf="label"
4652
[for]="id"
@@ -64,7 +70,8 @@ import { Observable } from "rxjs";
6470
'cds--list-box--lg': size === 'lg',
6571
'cds--list-box--disabled': disabled,
6672
'cds--combo-box--readonly': readonly,
67-
'cds--combo-box--warning cds--list-box--warning': warn
73+
'cds--combo-box--warning cds--list-box--warning': warn,
74+
'cds--list-box--invalid': invalid
6875
}"
6976
class="cds--list-box cds--combo-box"
7077
[attr.data-invalid]="(invalid ? true : null)">
@@ -109,7 +116,8 @@ import { Observable } from "rxjs";
109116
[disabled]="disabled"
110117
[readOnly]="readonly"
111118
(input)="onSearch($event.target.value)"
112-
(blur)="onBlur()"
119+
(focus)="fluid ? handleFocus($event) : null"
120+
(blur)="fluid ? handleFocus($event) : onBlur()"
113121
(keydown.enter)="onSubmit($event)"
114122
[value]="selectedValue"
115123
class="cds--text-input"
@@ -166,8 +174,9 @@ import { Observable } from "rxjs";
166174
<ng-content *ngIf="open"></ng-content>
167175
</div>
168176
</div>
177+
<hr *ngIf="fluid" class="cds--list-box__divider" />
169178
<div
170-
*ngIf="helperText && !invalid && !warn"
179+
*ngIf="helperText && !invalid && !warn && !fluid"
171180
class="cds--form__helper-text"
172181
[ngClass]="{'cds--form__helper-text--disabled': disabled}">
173182
<ng-container *ngIf="!isTemplate(helperText)">{{helperText}}</ng-container>
@@ -368,6 +377,10 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
368377
* Set to `true` for readonly state.
369378
*/
370379
@Input() readonly = false;
380+
/**
381+
* Experimental: enable fluid state
382+
*/
383+
@Input() fluid = false;
371384
/**
372385
* Emits a ListItem
373386
*
@@ -426,7 +439,6 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
426439
@ViewChild("input", { static: true }) input: ElementRef;
427440
@ViewChild("listbox", { static: true }) listbox: ElementRef;
428441
@HostBinding("class.cds--list-box__wrapper") hostClass = true;
429-
@HostBinding("style.display") display = "block";
430442

431443
public open = false;
432444

@@ -456,6 +468,8 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
456468
protected _clearSelectionTitle = this.i18n.getOverridable("COMBOBOX.CLEAR_SELECTED");
457469
protected _clearSelectionAria = this.i18n.getOverridable("COMBOBOX.A11Y.CLEAR_SELECTED");
458470

471+
protected _isFocused = false;
472+
459473
/**
460474
* Creates an instance of ComboBox.
461475
*/
@@ -680,7 +694,15 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
680694
// clearSelected can only fire on type=multi
681695
// so we just emit getSelected() (just in case there's any disabled but selected items)
682696
const selected = this.view.getSelected();
683-
this.propagateChangeCallback(selected);
697+
698+
// in case there are disabled items they should be mapped according to itemValueKey
699+
if (this.itemValueKey && selected) {
700+
const values = selected.map((item) => item[this.itemValueKey]);
701+
this.propagateChangeCallback(values);
702+
} else {
703+
this.propagateChangeCallback(selected);
704+
}
705+
684706
this.selected.emit(selected as any);
685707
this.clear.emit(event);
686708
}
@@ -877,6 +899,10 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
877899
}
878900
}
879901

902+
handleFocus(event: FocusEvent) {
903+
this._isFocused = event.type === "focus";
904+
}
905+
880906
protected updateSelected() {
881907
const selected = this.view.getSelected();
882908
if (this.type === "multi") {

src/combobox/combobox.stories.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ export default {
7272
dropUp: false,
7373
selectionFeedback: "top-after-reopen",
7474
size: "md",
75-
theme: "dark"
75+
theme: "dark",
76+
fluid: false
7677
},
7778
argTypes: {
7879
size: {
@@ -119,6 +120,7 @@ const Template = (args) => ({
119120
[items]="items"
120121
[theme]="theme"
121122
[dropUp]="dropUp"
123+
[fluid]="fluid"
122124
(selected)="selected($event)"
123125
(submit)="submit($event)"
124126
(search)="search($event)"
@@ -176,6 +178,10 @@ Dynamic.parameters = {
176178
}
177179
};
178180

181+
export const Fluid = Template.bind({});
182+
Fluid.args = {
183+
fluid: true
184+
};
179185

180186
const MultiTemplate = (args) => ({
181187
props: args,
@@ -196,6 +202,7 @@ const MultiTemplate = (args) => ({
196202
[selectionFeedback]="selectionFeedback"
197203
[dropUp]="dropUp"
198204
[appendInline]="appendInline"
205+
[fluid]="fluid"
199206
type="multi"
200207
(selected)="selected($event)"
201208
(submit)="submit($event)"

0 commit comments

Comments
 (0)