Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(chip)!: make label property required and value optional #10787

Merged
merged 3 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/calcite-components/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export class Alert extends LitElement implements OpenCloseComponent, LoadableCom
}}
key="queue-count"
>
<calcite-chip scale={this.scale} value={queueText}>
<calcite-chip label={queueText} scale={this.scale} value={queueText}>
{queueText}
</calcite-chip>
</div>
Expand Down
12 changes: 6 additions & 6 deletions packages/calcite-components/src/components/chip/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ export class Chip extends LitElement implements InteractiveComponent, LoadableCo
/** Specifies the kind of the component, which will apply to border and background if applicable. */
@property({ reflect: true }) kind: Extract<"brand" | "inverse" | "neutral", Kind> = "neutral";

/** Accessible name for the component. */
/**
* Accessible name for the component.
*
* @required
*/
@property() label: string;

/** Use this property to override individual strings used by the component. */
Expand Down Expand Up @@ -124,11 +128,7 @@ export class Chip extends LitElement implements InteractiveComponent, LoadableCo
SelectionMode
> = "none";

/**
* The component's value.
*
* @required
*/
/** The component's value. */
@property() value: any;

// #endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,7 @@ export class Combobox
iconFlipRtl={item.iconFlipRtl}
id={item.guid ? `${chipUidPrefix}${item.guid}` : null}
key={itemLabel}
label={label}
messageOverrides={{ dismissLabel: messages.removeTag }}
onFocusIn={() => (this.activeChipIndex = i)}
oncalciteChipClose={() => this.calciteChipCloseHandler(item)}
Expand Down Expand Up @@ -1480,6 +1481,7 @@ export class Combobox
!compactSelectionDisplay
),
}}
label={label}
ref={setAllSelectedIndicatorChipEl}
scale={scale}
title={label}
Expand All @@ -1503,6 +1505,7 @@ export class Combobox
compactSelectionDisplay
),
}}
label={label}
scale={scale}
title={label}
value=""
Expand Down Expand Up @@ -1555,6 +1558,7 @@ export class Combobox
chip: true,
[CSS.chipInvisible]: chipInvisible,
}}
label={label}
ref={setSelectedIndicatorChipEl}
scale={scale}
title={label}
Expand Down Expand Up @@ -1596,6 +1600,7 @@ export class Combobox
chip: true,
[CSS.chipInvisible]: chipInvisible,
}}
label={label}
scale={scale}
title={label}
value=""
Expand Down
6 changes: 4 additions & 2 deletions packages/calcite-components/src/components/rating/rating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ export class Rating
// #region Rendering

override render(): JsxNode {
const countString = this.count?.toString();

return (
<InteractiveContainer disabled={this.disabled}>
<span class="wrapper">
Expand Down Expand Up @@ -442,9 +444,9 @@ export class Rating
)}

{(this.count || this.average) && this.showChip ? (
<calcite-chip scale={this.scale} value={this.count?.toString()}>
<calcite-chip label={countString} scale={this.scale} value={countString}>
{!!this.average && <span class="number--average">{this.average.toString()}</span>}
{!!this.count && <span class="number--count">({this.count?.toString()})</span>}
{!!this.count && <span class="number--count">({countString})</span>}
</calcite-chip>
) : null}
</fieldset>
Expand Down
9 changes: 8 additions & 1 deletion packages/calcite-components/src/components/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,20 @@ export class Table extends LitElement implements LoadableComponent {
<div class={CSS.selectionArea}>
<calcite-chip
kind={this.selectedCount > 0 ? "brand" : "neutral"}
label={selectionText}
scale={this.scale}
value={selectionText}
>
{selectionText}
</calcite-chip>
{outOfViewCount > 0 && (
<calcite-chip icon="hide-empty" scale={this.scale} title={outOfView} value={outOfView}>
<calcite-chip
icon="hide-empty"
label={outOfView}
scale={this.scale}
title={outOfView}
value={outOfView}
>
{localizedOutOfView}
</calcite-chip>
)}
Expand Down
Loading