mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
fix(list-box): update styles for ListBoxSelection
This commit is contained in:
parent
bee8b521ca
commit
448f3488d4
4 changed files with 62 additions and 28 deletions
|
@ -1958,7 +1958,7 @@ export type ListBoxSelectionTranslationId = "clearAll" | "clearSelection";
|
||||||
| Prop name | Kind | Reactive | Type | Default value | Description |
|
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||||
| :-------------- | :----------------- | :------- | :----------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------ |
|
| :-------------- | :----------------- | :------- | :----------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------ |
|
||||||
| ref | <code>let</code> | Yes | <code>null | HTMLDivElement</code> | <code>null</code> | Obtain a reference to the top-level HTML element |
|
| ref | <code>let</code> | Yes | <code>null | HTMLDivElement</code> | <code>null</code> | Obtain a reference to the top-level HTML element |
|
||||||
| selectionCount | <code>let</code> | No | <code>any</code> | -- | Specify the number of selected items |
|
| selectionCount | <code>let</code> | No | <code>number</code> | -- | Specify the number of selected items |
|
||||||
| disabled | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the list box selection |
|
| disabled | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the list box selection |
|
||||||
| translationIds | <code>const</code> | No | <code>{ clearAll: "clearAll", clearSelection: "clearSelection", }</code> | <code>{ clearAll: "clearAll", clearSelection: "clearSelection", }</code> | Default translation ids |
|
| translationIds | <code>const</code> | No | <code>{ clearAll: "clearAll", clearSelection: "clearSelection", }</code> | <code>{ clearAll: "clearAll", clearSelection: "clearSelection", }</code> | Default translation ids |
|
||||||
| translateWithId | <code>let</code> | No | <code>(id: ListBoxSelectionTranslationId) => string</code> | <code>(id) => defaultTranslations[id]</code> | Override the default translation ids |
|
| translateWithId | <code>let</code> | No | <code>(id: ListBoxSelectionTranslationId) => string</code> | <code>(id) => defaultTranslations[id]</code> | Override the default translation ids |
|
||||||
|
|
|
@ -4595,7 +4595,7 @@
|
||||||
"name": "selectionCount",
|
"name": "selectionCount",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
"description": "Specify the number of selected items",
|
"description": "Specify the number of selected items",
|
||||||
"type": "any",
|
"type": "number",
|
||||||
"isFunction": false,
|
"isFunction": false,
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": false
|
"reactive": false
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the number of selected items
|
* Specify the number of selected items
|
||||||
* @type {any}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
export let selectionCount = undefined;
|
export let selectionCount = undefined;
|
||||||
|
|
||||||
|
@ -46,27 +46,61 @@
|
||||||
: translateWithId("clearSelection");
|
: translateWithId("clearSelection");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
{#if selectionCount !== undefined}
|
||||||
bind:this="{ref}"
|
<div
|
||||||
role="button"
|
class:bx--tag="{true}"
|
||||||
aria-label="Clear Selection"
|
class:bx--tag--filter="{true}"
|
||||||
tabindex="{disabled ? '-1' : '0'}"
|
class:bx--tag--high-contrast="{true}"
|
||||||
title="{description}"
|
class:bx--tag--disabled="{disabled}"
|
||||||
class:bx--list-box__selection="{true}"
|
>
|
||||||
class:bx--tag--filter="{selectionCount}"
|
<span class:bx--tag__label="{true}" title="{selectionCount}">
|
||||||
class:bx--list-box__selection--multi="{selectionCount}"
|
{selectionCount}
|
||||||
{...$$restProps}
|
</span>
|
||||||
on:click|preventDefault|stopPropagation="{(e) => {
|
<div
|
||||||
if (!disabled) {
|
bind:this="{ref}"
|
||||||
dispatch('clear', e);
|
role="button"
|
||||||
}
|
tabIndex="{disabled ? -1 : 0}"
|
||||||
}}"
|
class:bx--tag__close-icon="{true}"
|
||||||
on:keydown|stopPropagation="{(e) => {
|
on:click|preventDefault|stopPropagation="{(e) => {
|
||||||
if (!disabled && e.key === 'Enter') {
|
if (!disabled) {
|
||||||
dispatch('clear', e);
|
dispatch('clear', e);
|
||||||
}
|
}
|
||||||
}}"
|
}}"
|
||||||
>
|
on:keydown|stopPropagation="{(e) => {
|
||||||
{#if selectionCount}{selectionCount}{/if}
|
if (!disabled && e.key === 'Enter') {
|
||||||
<Close16 />
|
dispatch('clear', e);
|
||||||
</div>
|
}
|
||||||
|
}}"
|
||||||
|
disabled="{disabled}"
|
||||||
|
aria-label="{translationIds.clearAll}"
|
||||||
|
title="{description}"
|
||||||
|
>
|
||||||
|
<Close16 />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div
|
||||||
|
bind:this="{ref}"
|
||||||
|
role="button"
|
||||||
|
aria-label="{description}"
|
||||||
|
title="{description}"
|
||||||
|
tabindex="{disabled ? '-1' : '0'}"
|
||||||
|
class:bx--list-box__selection="{true}"
|
||||||
|
class:bx--tag--filter="{selectionCount}"
|
||||||
|
class:bx--list-box__selection--multi="{selectionCount}"
|
||||||
|
{...$$restProps}
|
||||||
|
on:click|preventDefault|stopPropagation="{(e) => {
|
||||||
|
if (!disabled) {
|
||||||
|
dispatch('clear', e);
|
||||||
|
}
|
||||||
|
}}"
|
||||||
|
on:keydown|stopPropagation="{(e) => {
|
||||||
|
if (!disabled && e.key === 'Enter') {
|
||||||
|
dispatch('clear', e);
|
||||||
|
}
|
||||||
|
}}"
|
||||||
|
>
|
||||||
|
{#if selectionCount !== undefined}{selectionCount}{/if}
|
||||||
|
<Close16 />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
2
types/ListBox/ListBoxSelection.d.ts
vendored
2
types/ListBox/ListBoxSelection.d.ts
vendored
|
@ -8,7 +8,7 @@ export interface ListBoxSelectionProps
|
||||||
/**
|
/**
|
||||||
* Specify the number of selected items
|
* Specify the number of selected items
|
||||||
*/
|
*/
|
||||||
selectionCount?: any;
|
selectionCount?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to `true` to disable the list box selection
|
* Set to `true` to disable the list box selection
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue