Align v10.38 (#698)

* chore(deps-dev): upgrade carbon-components to v10.38.0

* feat(text-input): support read-only variant

* docs: use consistent lingo for inline variant examples

* docs(popover): add Popover alignment example

* fix(file-uploader): adjust markup to avoid accessibility errors

Ref: 0dfde60e3

* fix(inline-loading): use error filled icon

* fix(inline-loading): render iconDescription as title in error/warning icons

Ref: 51c53c923

* fix(structured-list): update accessibility attributes

* fix(tooltip-definition): use span instead of div

Ref: cb6de3025

* fix(multi-select): close menu when blurring the last filterable option

* fix(multi-select): open/focus field for filterable multiselect #635

* fix(multi-select): unblock focus when blurring input #635

* fix(combo-box): select correct item with keys, allow input after clearing #195

* fix(combo-box): update input text if item is selected

* feat(combo-box): render checkmark icon for selected item

* fix(ui-shell): toggle SideNav rail when clicking the hamburger menu #699

* fix(context-menu): update context menu classes #684

* docs(context-menu): improve demo instructions #684

* fix(context-menu): close menu when clicking anywhere
This commit is contained in:
Eric Liu 2021-06-27 08:46:57 -07:00 committed by GitHub
commit e51f50da0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 285 additions and 88 deletions

View file

@ -4072,7 +4072,8 @@ None.
| warn | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an warning state | | warn | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an warning state |
| warnText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the warning state text | | warnText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the warning state text |
| required | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to mark the field as required | | required | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to mark the field as required |
| inline | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use inline version | | inline | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the inline variant |
| readonly | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the read-only variant |
### Slots ### Slots

View file

@ -11,7 +11,7 @@
"devDependencies": { "devDependencies": {
"@sveltech/routify": "^1.9.9", "@sveltech/routify": "^1.9.9",
"autoprefixer": "^10.2.3", "autoprefixer": "^10.2.3",
"carbon-components": "10.37.0", "carbon-components": "10.38.0",
"carbon-components-svelte": "../", "carbon-components-svelte": "../",
"mdsvex": "^0.8.8", "mdsvex": "^0.8.8",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",

View file

@ -10416,7 +10416,17 @@
{ {
"name": "inline", "name": "inline",
"kind": "let", "kind": "let",
"description": "Set to `true` to use inline version", "description": "Set to `true` to use the inline variant",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "readonly",
"kind": "let",
"description": "Set to `true` to use the read-only variant",
"type": "boolean", "type": "boolean",
"value": "false", "value": "false",
"isFunction": false, "isFunction": false,

View file

@ -217,4 +217,8 @@
[data-outline] { [data-outline] {
position: relative; position: relative;
} }
[data-outline] ~ [data-outline] {
margin-top: var(--cds-spacing-08);
}
</style> </style>

View file

@ -47,7 +47,7 @@ Set `direction` to `"top"` for the dropdown menu to appear above the input.
{id: "1", text: "Email"}, {id: "1", text: "Email"},
{id: "2", text: "Fax"}]}" /> {id: "2", text: "Fax"}]}" />
### Inline type ### Inline variant
<Dropdown type="inline" titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"}, <Dropdown type="inline" titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
{id: "1", text: "Email"}, {id: "1", text: "Email"},

View file

@ -79,7 +79,7 @@ Set `direction` to `"top"` for the dropdown menu to appear above the input.
{id: "2", text: "Fax"}]}" {id: "2", text: "Fax"}]}"
/> />
### Inline type ### Inline variant
<MultiSelect type="inline" titleText="Contact" label="Select contact methods..." <MultiSelect type="inline" titleText="Contact" label="Select contact methods..."
items="{[{id: "0", text: "Slack"}, items="{[{id: "0", text: "Slack"},

View file

@ -36,6 +36,79 @@ Set `closeOnOutsideClick` to set `open` to `false` when clicking outside of the
</Popover> </Popover>
</div> </div>
### Popover alignment
Customize the popover alignment using the `align` prop. Valid values include: `"top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"`.
The default `align` value is `"top"`.
<div data-outline>
Parent
<Popover open align="top-left">
<div style="padding: var(--cds-spacing-05)">top-left</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="top-right">
<div style="padding: var(--cds-spacing-05)">top-right</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="bottom">
<div style="padding: var(--cds-spacing-05)">bottom</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="bottom-left">
<div style="padding: var(--cds-spacing-05)">bottom-left</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="bottom-right">
<div style="padding: var(--cds-spacing-05)">bottom-right</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="left">
<div style="padding: var(--cds-spacing-05)">left</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="left-bottom">
<div style="padding: var(--cds-spacing-05)">left-bottom</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="left-right">
<div style="padding: var(--cds-spacing-05)">left-right</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="right">
<div style="padding: var(--cds-spacing-05)">right</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="right-bottom">
<div style="padding: var(--cds-spacing-05)">right-bottom</div>
</Popover>
</div>
<div data-outline>
Parent
<Popover open align="right-top">
<div style="padding: var(--cds-spacing-05)">right-top</div>
</Popover>
</div>
### With caret ### With caret
<div data-outline> <div data-outline>

View file

@ -62,7 +62,7 @@ components: ["Select", "SelectItem", "SelectItemGroup", "SelectSkeleton"]
<SelectItem value="g100" text="Gray 100" /> <SelectItem value="g100" text="Gray 100" />
</Select> </Select>
### Inline type ### Inline variant
<Select inline labelText="Carbon theme" selected="g10" > <Select inline labelText="Carbon theme" selected="g10" >
<SelectItem value="white" text="White" /> <SelectItem value="white" text="White" />

View file

@ -23,10 +23,14 @@ components: ["TextInput", "TextInputSkeleton"]
<TextInput light labelText="User name" placeholder="Enter user name..." /> <TextInput light labelText="User name" placeholder="Enter user name..." />
### Inline ### Inline variant
<TextInput inline labelText="User name" placeholder="Enter user name..." /> <TextInput inline labelText="User name" placeholder="Enter user name..." />
### Read-only variant
<TextInput readonly labelText="User name" value="IBM" />
### Extra-large size ### Extra-large size
<TextInput size="xl" labelText="User name" placeholder="Enter user name..." /> <TextInput size="xl" labelText="User name" placeholder="Enter user name..." />

View file

@ -45,3 +45,19 @@
<ContextMenuDivider /> <ContextMenuDivider />
<ContextMenuOption indented kind="danger" labelText="Delete" /> <ContextMenuOption indented kind="danger" labelText="Delete" />
</ContextMenu> </ContextMenu>
<div>
<p>Right click anywhere on this page</p>
</div>
<style>
div {
position: absolute;
width: calc(100% - var(--cds-spacing-05));
height: calc(100% - var(--cds-spacing-06));
display: flex;
align-items: center;
justify-content: center;
color: var(--cds-text-02);
}
</style>

View file

@ -21,3 +21,19 @@
<ContextMenuDivider /> <ContextMenuDivider />
<ContextMenuOption selectable labelText="Lock layer" /> <ContextMenuOption selectable labelText="Lock layer" />
</ContextMenu> </ContextMenu>
<div>
<p>Right click anywhere on this page</p>
</div>
<style>
div {
position: absolute;
width: calc(100% - var(--cds-spacing-05));
height: calc(100% - var(--cds-spacing-06));
display: flex;
align-items: center;
justify-content: center;
color: var(--cds-text-02);
}
</style>

View file

@ -37,9 +37,8 @@
</HeaderNavMenu> </HeaderNavMenu>
<HeaderNavItem href="/" text="Link 4" /> <HeaderNavItem href="/" text="Link 4" />
</HeaderNav> </HeaderNav>
</Header>
<SideNav bind:isOpen="{isSideNavOpen}" rail> <SideNav bind:isOpen="{isSideNavOpen}" rail>
<SideNavItems> <SideNavItems>
<SideNavLink icon="{Fade16}" text="Link 1" href="/" isSelected /> <SideNavLink icon="{Fade16}" text="Link 1" href="/" isSelected />
<SideNavLink icon="{Fade16}" text="Link 2" href="/" /> <SideNavLink icon="{Fade16}" text="Link 2" href="/" />
@ -52,7 +51,8 @@
<SideNavDivider /> <SideNavDivider />
<SideNavLink icon="{Fade16}" text="Link 4" href="/" /> <SideNavLink icon="{Fade16}" text="Link 4" href="/" />
</SideNavItems> </SideNavItems>
</SideNav> </SideNav>
</Header>
<Content> <Content>
<Grid> <Grid>

View file

@ -837,16 +837,16 @@ caniuse-lite@^1.0.30001173, caniuse-lite@^1.0.30001178:
integrity sha512-n8JVqXuZMVSPKiPiypjFtDTXc4jWIdjxull0f92WLo7e1MSi3uJ3NvveakSh/aCl1QKFAvIz3vIj0v+0K+FrXw== integrity sha512-n8JVqXuZMVSPKiPiypjFtDTXc4jWIdjxull0f92WLo7e1MSi3uJ3NvveakSh/aCl1QKFAvIz3vIj0v+0K+FrXw==
carbon-components-svelte@../: carbon-components-svelte@../:
version "0.36.0" version "0.37.0"
dependencies: dependencies:
carbon-icons-svelte "^10.27.0" carbon-icons-svelte "^10.27.0"
clipboard-copy "3.2.0" clipboard-copy "3.2.0"
flatpickr "4.6.9" flatpickr "4.6.9"
carbon-components@10.37.0: carbon-components@10.38.0:
version "10.37.0" version "10.38.0"
resolved "https://registry.yarnpkg.com/carbon-components/-/carbon-components-10.37.0.tgz#bc53138151ea58e79f5b249b1ec5be8ae2c0a7e4" resolved "https://registry.yarnpkg.com/carbon-components/-/carbon-components-10.38.0.tgz#f275192f70eccf0d0052a192113ee20059594d4f"
integrity sha512-LHReeqzzieP/q/xAHfKJNWLdWhOkr7+DIVZkrQGPf6kZYj5H8tb1KYKOIhasvCNRxJ2es8QJXuH7XW0JoLDfdQ== integrity sha512-o5Ns3M2LQMuQ41UJiT+WFU+t/hAerde+77LKmrBpiPRBHJ+/VEBAfKmjB5TiH5QM/VWVDWo0Dvr8gc6yNKRqug==
dependencies: dependencies:
"@carbon/telemetry" "0.0.0-alpha.6" "@carbon/telemetry" "0.0.0-alpha.6"
flatpickr "4.6.1" flatpickr "4.6.1"

View file

@ -32,7 +32,7 @@
"@rollup/plugin-node-resolve": "^11.1.1", "@rollup/plugin-node-resolve": "^11.1.1",
"@tsconfig/svelte": "^1.0.10", "@tsconfig/svelte": "^1.0.10",
"autoprefixer": "^10.2.4", "autoprefixer": "^10.2.4",
"carbon-components": "10.37.0", "carbon-components": "10.38.0",
"gh-pages": "^3.1.0", "gh-pages": "^3.1.0",
"husky": "^4.3.8", "husky": "^4.3.8",
"lint-staged": "^10.5.3", "lint-staged": "^10.5.3",

View file

@ -79,6 +79,7 @@
on:change="{() => { on:change="{() => {
checked = !checked; checked = !checked;
}}" }}"
on:blur
/> />
<label for="{id}" title="{title}" class:bx--checkbox-label="{true}"> <label for="{id}" title="{title}" class:bx--checkbox-label="{true}">
<span <span

View file

@ -95,6 +95,7 @@
export let listRef = null; export let listRef = null;
import { createEventDispatcher, afterUpdate, tick } from "svelte"; import { createEventDispatcher, afterUpdate, tick } from "svelte";
import Checkmark16 from "carbon-icons-svelte/lib/Checkmark16/Checkmark16.svelte";
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16/WarningFilled16.svelte"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16/WarningFilled16.svelte";
import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16/WarningAltFilled16.svelte"; import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16/WarningAltFilled16.svelte";
import ListBox from "../ListBox/ListBox.svelte"; import ListBox from "../ListBox/ListBox.svelte";
@ -128,7 +129,6 @@
filteredItems = items.filter((item) => shouldFilterItem(item, value)); filteredItems = items.filter((item) => shouldFilterItem(item, value));
} else { } else {
highlightedIndex = -1; highlightedIndex = -1;
inputValue = selectedItem ? selectedItem.text : "";
if (!selectedItem) { if (!selectedItem) {
selectedId = undefined; selectedId = undefined;
@ -149,7 +149,6 @@
: undefined; : undefined;
$: filteredItems = items.filter((item) => shouldFilterItem(item, value)); $: filteredItems = items.filter((item) => shouldFilterItem(item, value));
$: selectedItem = items[selectedIndex]; $: selectedItem = items[selectedIndex];
$: inputValue = selectedItem ? selectedItem.text : undefined;
$: value = inputValue; $: value = inputValue;
</script> </script>
@ -217,16 +216,31 @@
class:bx--text-input="{true}" class:bx--text-input="{true}"
class:bx--text-input--light="{light}" class:bx--text-input--light="{light}"
class:bx--text-input--empty="{inputValue === ''}" class:bx--text-input--empty="{inputValue === ''}"
on:input="{({ target }) => { on:input="{async ({ target }) => {
if (!open && target.value.length > 0) {
open = true;
}
inputValue = target.value; inputValue = target.value;
}}" }}"
on:keydown on:keydown
on:keydown|stopPropagation="{({ key }) => { on:keydown|stopPropagation="{({ key }) => {
if (key === 'Enter') { if (key === 'Enter') {
open = !open; open = !open;
if (highlightedIndex > -1 && highlightedIndex !== selectedIndex) { if (highlightedIndex > -1 && highlightedIndex !== selectedIndex) {
selectedIndex = highlightedIndex; selectedIndex = highlightedIndex;
open = false; open = false;
if (filteredItems[selectedIndex]) {
inputValue = filteredItems[selectedIndex].text;
}
}
if (highlightedIndex < 0 && selectedIndex > -1) {
if (filteredItems[selectedIndex]) {
inputValue = filteredItems[selectedIndex].text;
}
} }
} else if (key === 'Tab') { } else if (key === 'Tab') {
open = false; open = false;
@ -242,6 +256,12 @@
on:focus on:focus
on:blur on:blur
on:blur="{({ relatedTarget }) => { on:blur="{({ relatedTarget }) => {
if (inputValue.length === 0 && selectedIndex > -1) {
if (filteredItems[selectedIndex]) {
inputValue = filteredItems[selectedIndex].text;
}
}
if (!open || !relatedTarget) return; if (!open || !relatedTarget) return;
if ( if (
relatedTarget && relatedTarget &&
@ -266,7 +286,9 @@
on:clear on:clear
on:clear="{() => { on:clear="{() => {
selectedIndex = -1; selectedIndex = -1;
highlightedIndex = -1;
open = false; open = false;
inputValue = '';
ref.focus(); ref.focus();
}}" }}"
translateWithId="{translateWithId}" translateWithId="{translateWithId}"
@ -300,12 +322,19 @@
.map(({ id }) => id) .map(({ id }) => id)
.indexOf(filteredItems[i].id); .indexOf(filteredItems[i].id);
open = false; open = false;
if (filteredItems[i]) {
inputValue = filteredItems[i].text;
}
}}" }}"
on:mouseenter="{() => { on:mouseenter="{() => {
highlightedIndex = i; highlightedIndex = i;
}}" }}"
> >
{itemToString(item)} {itemToString(item)}
{#if selectedItem && selectedItem.id === item.id}
<Checkmark16 class="bx--list-box__menu-item__selected-icon" />
{/if}
</ListBoxMenuItem> </ListBoxMenuItem>
{/each} {/each}
</ListBoxMenu> </ListBoxMenu>

View file

@ -79,6 +79,7 @@
<svelte:window <svelte:window
on:contextmenu|preventDefault="{(e) => { on:contextmenu|preventDefault="{(e) => {
if (level > 1) return; if (level > 1) return;
if (!ref) return;
const { height, width } = ref.getBoundingClientRect(); const { height, width } = ref.getBoundingClientRect();
@ -104,7 +105,7 @@
}}" }}"
on:click="{(e) => { on:click="{(e) => {
if (!open) return; if (!open) return;
if (e.target.contains(ref)) close(); close();
}}" }}"
on:keydown="{(e) => { on:keydown="{(e) => {
if (open && e.key === 'Escape') close(); if (open && e.key === 'Escape') close();
@ -117,10 +118,10 @@
tabindex="-1" tabindex="-1"
data-direction="{direction}" data-direction="{direction}"
data-level="{level}" data-level="{level}"
class:bx--context-menu="{true}" class:bx--menu="{true}"
class:bx--context-menu--open="{open}" class:bx--menu--open="{open}"
class:bx--context-menu--invisible="{open && x === 0 && y === 0}" class:bx--menu--invisible="{open && x === 0 && y === 0}"
class:bx--context-menu--root="{level === 1}" class:bx--menu--root="{level === 1}"
{...$$restProps} {...$$restProps}
style="left: {x}px; top: {y}px; {$$restProps.style}" style="left: {x}px; top: {y}px; {$$restProps.style}"
on:click on:click

View file

@ -1 +1 @@
<li role="separator" class:bx--context-menu-divider="{true}"></li> <li role="separator" class:bx--menu-divider="{true}"></li>

View file

@ -173,14 +173,14 @@
aria-disabled="{!subOptions && disabled}" aria-disabled="{!subOptions && disabled}"
aria-haspopup="{subOptions ? true : undefined}" aria-haspopup="{subOptions ? true : undefined}"
aria-expanded="{subOptions ? submenuOpen : undefined}" aria-expanded="{subOptions ? submenuOpen : undefined}"
class:bx--context-menu-option="{true}" class:bx--menu-option="{true}"
class:bx--context-menu-option--disabled="{true}" class:bx--menu-option--disabled="{true}"
class:bx--context-menu-option--active="{subOptions && submenuOpen}" class:bx--menu-option--active="{subOptions && submenuOpen}"
class:bx--context-menu-option--danger="{!subOptions && kind === 'danger'}" class:bx--menu-option--danger="{!subOptions && kind === 'danger'}"
indented="{indented}" indented="{indented}"
aria-checked="{isSelectable || isRadio ? selected : undefined}" aria-checked="{isSelectable || isRadio ? selected : undefined}"
data-nested="{ref && data-nested="{ref &&
ref.closest('.bx--context-menu').getAttribute('data-level') === '2'}" ref.closest('.bx--menu').getAttribute('data-level') === '2'}"
data-sub="{subOptions}" data-sub="{subOptions}"
data-id="{id}" data-id="{id}"
{...$$restProps} {...$$restProps}
@ -240,18 +240,18 @@
> >
{#if subOptions} {#if subOptions}
<div <div
class:bx--context-menu-option__content="{true}" class:bx--menu-option__content="{true}"
class:bx--context-menu-option__content--disabled="{disabled}" class:bx--menu-option__content--disabled="{disabled}"
> >
{#if indented} {#if indented}
<div class:bx--context-menu-option__icon="{true}"> <div class:bx--menu-option__icon="{true}">
<svelte:component this="{icon}" /> <svelte:component this="{icon}" />
</div> </div>
{/if} {/if}
<span class:bx--context-menu-option__label="{true}" title="{labelText}"> <span class:bx--menu-option__label="{true}" title="{labelText}">
<slot name="labelText">{labelText}</slot> <slot name="labelText">{labelText}</slot>
</span> </span>
<div class:bx--context-menu-option__info="{true}"><CaretRight16 /></div> <div class:bx--menu-option__info="{true}"><CaretRight16 /></div>
</div> </div>
<ContextMenu <ContextMenu
@ -263,18 +263,18 @@
</ContextMenu> </ContextMenu>
{:else} {:else}
<div <div
class:bx--context-menu-option__content="{true}" class:bx--menu-option__content="{true}"
class:bx--context-menu-option__content--disabled="{disabled}" class:bx--menu-option__content--disabled="{disabled}"
> >
{#if indented} {#if indented}
<div class:bx--context-menu-option__icon="{true}"> <div class:bx--menu-option__icon="{true}">
<svelte:component this="{icon}" /> <svelte:component this="{icon}" />
</div> </div>
{/if} {/if}
<span class:bx--context-menu-option__label="{true}" title="{labelText}"> <span class:bx--menu-option__label="{true}" title="{labelText}">
<slot name="labelText">{labelText}</slot> <slot name="labelText">{labelText}</slot>
</span> </span>
<div class:bx--context-menu-option__info="{true}"> <div class:bx--menu-option__info="{true}">
<slot name="shortcutText">{shortcutText}</slot> <slot name="shortcutText">{shortcutText}</slot>
</div> </div>
</div> </div>

View file

@ -92,6 +92,7 @@
<slot name="labelText"> <slot name="labelText">
{labelText} {labelText}
</slot> </slot>
</div>
<input <input
bind:this="{ref}" bind:this="{ref}"
type="file" type="file"
@ -111,6 +112,5 @@
target.value = null; target.value = null;
}}" }}"
/> />
</div>
</label> </label>
</div> </div>

View file

@ -22,7 +22,7 @@
import { createEventDispatcher, afterUpdate, onMount } from "svelte"; import { createEventDispatcher, afterUpdate, onMount } from "svelte";
import CheckmarkFilled16 from "carbon-icons-svelte/lib/CheckmarkFilled16/CheckmarkFilled16.svelte"; import CheckmarkFilled16 from "carbon-icons-svelte/lib/CheckmarkFilled16/CheckmarkFilled16.svelte";
import Error20 from "carbon-icons-svelte/lib/Error20/Error20.svelte"; import ErrorFilled16 from "carbon-icons-svelte/lib/ErrorFilled16/ErrorFilled16.svelte";
import Loading from "../Loading/Loading.svelte"; import Loading from "../Loading/Loading.svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -55,9 +55,15 @@
> >
<div class:bx--inline-loading__animation="{true}"> <div class:bx--inline-loading__animation="{true}">
{#if status === "error"} {#if status === "error"}
<Error20 class="bx--inline-loading--error" /> <ErrorFilled16
class="bx--inline-loading--error"
title="{iconDescription}"
/>
{:else if status === "finished"} {:else if status === "finished"}
<CheckmarkFilled16 class="bx--inline-loading__checkmark-container" /> <CheckmarkFilled16
class="bx--inline-loading__checkmark-container"
title="{iconDescription}"
/>
{:else if status === "inactive" || status === "active"} {:else if status === "inactive" || status === "active"}
<Loading <Loading
small small

View file

@ -61,6 +61,7 @@
on:mouseenter on:mouseenter
on:mouseleave on:mouseleave
on:keydown|preventDefault|stopPropagation on:keydown|preventDefault|stopPropagation
on:focus
on:blur on:blur
> >
<slot /> <slot />

View file

@ -319,6 +319,12 @@
} }
} }
}}" }}"
on:focus="{() => {
if (filterable) {
open = true;
if (inputRef) inputRef.focus();
}
}}"
on:blur="{({ relatedTarget }) => { on:blur="{({ relatedTarget }) => {
if ( if (
relatedTarget && relatedTarget &&
@ -342,7 +348,7 @@
...item, ...item,
checked: false, checked: false,
})); }));
fieldRef.blur(); if (fieldRef) fieldRef.blur();
}}" }}"
translateWithId="{translateWithId}" translateWithId="{translateWithId}"
disabled="{disabled}" disabled="{disabled}"
@ -388,7 +394,11 @@
on:blur="{({ relatedTarget }) => { on:blur="{({ relatedTarget }) => {
if ( if (
relatedTarget && relatedTarget &&
relatedTarget.getAttribute('role') !== 'button' !['INPUT', 'SELECT', 'TEXTAREA'].includes(
relatedTarget.tagName
) &&
relatedTarget.getAttribute('role') !== 'button' &&
relatedTarget.getAttribute('role') !== 'searchbox'
) { ) {
inputRef.focus(); inputRef.focus();
} }
@ -453,6 +463,9 @@
labelText="{itemToString(item)}" labelText="{itemToString(item)}"
checked="{item.checked}" checked="{item.checked}"
disabled="{disabled}" disabled="{disabled}"
on:blur="{() => {
if (i === filteredItems.length - 1) open = false;
}}"
/> />
</ListBoxMenuItem> </ListBoxMenuItem>
{/each} {/each}

View file

@ -38,7 +38,7 @@
</script> </script>
<div <div
aria-label="Structured list section" role="table"
class:bx--structured-list="{true}" class:bx--structured-list="{true}"
class:bx--structured-list--border="{border}" class:bx--structured-list--border="{border}"
class:bx--structured-list--selection="{selection}" class:bx--structured-list--selection="{selection}"

View file

@ -1,6 +1,6 @@
<div <div
class:bx--structured-list-tbody="{true}"
role="rowgroup" role="rowgroup"
class:bx--structured-list-tbody="{true}"
{...$$restProps} {...$$restProps}
on:click on:click
on:mouseover on:mouseover

View file

@ -7,6 +7,7 @@
</script> </script>
<div <div
role="{head ? 'columnheader' : 'cell'}"
class:bx--structured-list-th="{head}" class:bx--structured-list-th="{head}"
class:bx--structured-list-td="{!head}" class:bx--structured-list-td="{!head}"
class:bx--structured-list-content--nowrap="{noWrap}" class:bx--structured-list-content--nowrap="{noWrap}"

View file

@ -1,4 +1,5 @@
<div <div
role="rowgroup"
class:bx--structured-list-thead="{true}" class:bx--structured-list-thead="{true}"
{...$$restProps} {...$$restProps}
on:click on:click

View file

@ -12,7 +12,6 @@
{#if label} {#if label}
<!-- svelte-ignore a11y-label-has-associated-control --> <!-- svelte-ignore a11y-label-has-associated-control -->
<label <label
role="presentation"
tabindex="{tabindex}" tabindex="{tabindex}"
class:bx--structured-list-row="{true}" class:bx--structured-list-row="{true}"
class:bx--structured-list-row--header-row="{head}" class:bx--structured-list-row--header-row="{head}"
@ -27,6 +26,7 @@
</label> </label>
{:else} {:else}
<div <div
role="row"
class:bx--structured-list-row="{true}" class:bx--structured-list-row="{true}"
class:bx--structured-list-row--header-row="{head}" class:bx--structured-list-row--header-row="{head}"
{...$$restProps} {...$$restProps}

View file

@ -59,12 +59,16 @@
/** Set to `true` to mark the field as required */ /** Set to `true` to mark the field as required */
export let required = false; export let required = false;
/** Set to `true` to use inline version */ /** Set to `true` to use the inline variant */
export let inline = false; export let inline = false;
/** Set to `true` to use the read-only variant */
export let readonly = false;
import { getContext } from "svelte"; import { getContext } from "svelte";
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16/WarningFilled16.svelte"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16/WarningFilled16.svelte";
import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16/WarningAltFilled16.svelte"; import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16/WarningAltFilled16.svelte";
import EditOff16 from "carbon-icons-svelte/lib/EditOff16/EditOff16.svelte";
const ctx = getContext("Form"); const ctx = getContext("Form");
@ -77,6 +81,8 @@
class:bx--form-item="{true}" class:bx--form-item="{true}"
class:bx--text-input-wrapper="{true}" class:bx--text-input-wrapper="{true}"
class:bx--text-input-wrapper--inline="{inline}" class:bx--text-input-wrapper--inline="{inline}"
class:bx--text-input-wrapper--light="{light}"
class:bx--text-input-wrapper--readonly="{readonly}"
on:click on:click
on:mouseover on:mouseover
on:mouseenter on:mouseenter
@ -142,6 +148,9 @@
bx--text-input__invalid-icon--warning" bx--text-input__invalid-icon--warning"
/> />
{/if} {/if}
{#if readonly}
<EditOff16 class="bx--text-input__readonly-icon" />
{/if}
<input <input
bind:this="{ref}" bind:this="{ref}"
data-invalid="{invalid || undefined}" data-invalid="{invalid || undefined}"
@ -155,6 +164,7 @@
type="{type}" type="{type}"
value="{value}" value="{value}"
required="{required}" required="{required}"
readonly="{readonly}"
class:bx--text-input="{true}" class:bx--text-input="{true}"
class:bx--text-input--light="{light}" class:bx--text-input--light="{light}"
class:bx--text-input--invalid="{invalid}" class:bx--text-input--invalid="{invalid}"

View file

@ -36,7 +36,7 @@
if (key === 'Escape') hide(); if (key === 'Escape') hide();
}}" /> }}" />
<div <span
class:bx--tooltip--definition="{true}" class:bx--tooltip--definition="{true}"
class:bx--tooltip--a11y="{true}" class:bx--tooltip--a11y="{true}"
{...$$restProps} {...$$restProps}
@ -69,4 +69,4 @@
<div role="tooltip" id="{id}" class:bx--assistive-text="{true}"> <div role="tooltip" id="{id}" class:bx--assistive-text="{true}">
<slot name="tooltip">{tooltipText}</slot> <slot name="tooltip">{tooltipText}</slot>
</div> </div>
</div> </span>

View file

@ -25,6 +25,8 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
let winWidth = undefined;
$: dispatch(isOpen ? "open" : "close"); $: dispatch(isOpen ? "open" : "close");
onMount(() => { onMount(() => {
@ -33,6 +35,8 @@
}); });
</script> </script>
<svelte:window bind:innerWidth="{winWidth}" />
{#if !fixed} {#if !fixed}
<div <div
on:click="{() => { on:click="{() => {
@ -49,7 +53,7 @@
class:bx--side-nav__navigation="{true}" class:bx--side-nav__navigation="{true}"
class:bx--side-nav="{true}" class:bx--side-nav="{true}"
class:bx--side-nav--ux="{true}" class:bx--side-nav--ux="{true}"
class:bx--side-nav--expanded="{isOpen && !rail}" class:bx--side-nav--expanded="{rail && winWidth >= 1056 ? false : isOpen}"
class:bx--side-nav--collapsed="{!isOpen && !rail}" class:bx--side-nav--collapsed="{!isOpen && !rail}"
class:bx--side-nav--rail="{rail}" class:bx--side-nav--rail="{rail}"
{...$$restProps} {...$$restProps}

View file

@ -104,10 +104,16 @@ export interface TextInputProps
required?: boolean; required?: boolean;
/** /**
* Set to `true` to use inline version * Set to `true` to use the inline variant
* @default false * @default false
*/ */
inline?: boolean; inline?: boolean;
/**
* Set to `true` to use the read-only variant
* @default false
*/
readonly?: boolean;
} }
export default class TextInput extends SvelteComponentTyped< export default class TextInput extends SvelteComponentTyped<

View file

@ -453,10 +453,10 @@ caniuse-lite@^1.0.30001181:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001183.tgz#7a57ba9d6584119bb5f2bc76d3cc47ba9356b3e2" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001183.tgz#7a57ba9d6584119bb5f2bc76d3cc47ba9356b3e2"
integrity sha512-7JkwTEE1hlRKETbCFd8HDZeLiQIUcl8rC6JgNjvHCNaxOeNmQ9V4LvQXRUsKIV2CC73qKxljwVhToaA3kLRqTw== integrity sha512-7JkwTEE1hlRKETbCFd8HDZeLiQIUcl8rC6JgNjvHCNaxOeNmQ9V4LvQXRUsKIV2CC73qKxljwVhToaA3kLRqTw==
carbon-components@10.37.0: carbon-components@10.38.0:
version "10.37.0" version "10.38.0"
resolved "https://registry.yarnpkg.com/carbon-components/-/carbon-components-10.37.0.tgz#bc53138151ea58e79f5b249b1ec5be8ae2c0a7e4" resolved "https://registry.yarnpkg.com/carbon-components/-/carbon-components-10.38.0.tgz#f275192f70eccf0d0052a192113ee20059594d4f"
integrity sha512-LHReeqzzieP/q/xAHfKJNWLdWhOkr7+DIVZkrQGPf6kZYj5H8tb1KYKOIhasvCNRxJ2es8QJXuH7XW0JoLDfdQ== integrity sha512-o5Ns3M2LQMuQ41UJiT+WFU+t/hAerde+77LKmrBpiPRBHJ+/VEBAfKmjB5TiH5QM/VWVDWo0Dvr8gc6yNKRqug==
dependencies: dependencies:
"@carbon/telemetry" "0.0.0-alpha.6" "@carbon/telemetry" "0.0.0-alpha.6"
flatpickr "4.6.1" flatpickr "4.6.1"