mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 04:13:02 +00:00
* docs: update number of available Carbon icons * docs: add svelte:head example for loading CDN styles * chore(deps-dev): upgrade svelte to 3.40.1 * fix(a11y): disable a11y-mouse-events-have-key-events warning #760 * fix(deps): upgrade carbon-icons-svelte to v10.36.0 to avoid a11y warnings #760 * refactor(overflow-menu): remove formatStyle utility * docs: links in paragraphs should be inline * docs: add note on using all styles for dynamic theming
55 lines
1.3 KiB
Svelte
55 lines
1.3 KiB
Svelte
<script>
|
|
/**
|
|
* Specify the selected structured list row value
|
|
* @type {string}
|
|
*/
|
|
export let selected = undefined;
|
|
|
|
/**
|
|
* Set to `true` to use the bordered variant
|
|
* @deprecated
|
|
*/
|
|
export let border = false;
|
|
|
|
/** Set to `true` to use the condensed variant */
|
|
export let condensed = false;
|
|
|
|
/** Set to `true` to flush the list */
|
|
export let flush = false;
|
|
|
|
/** Set to `true` to use the selection variant */
|
|
export let selection = false;
|
|
|
|
import { createEventDispatcher, setContext } from "svelte";
|
|
import { writable } from "svelte/store";
|
|
|
|
const dispatch = createEventDispatcher();
|
|
const selectedValue = writable(selected);
|
|
|
|
setContext("StructuredListWrapper", {
|
|
selectedValue,
|
|
update: (value) => {
|
|
selectedValue.set(value);
|
|
},
|
|
});
|
|
|
|
$: selected = $selectedValue;
|
|
$: dispatch("change", $selectedValue);
|
|
</script>
|
|
|
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
|
<div
|
|
role="table"
|
|
class:bx--structured-list="{true}"
|
|
class:bx--structured-list--border="{border}"
|
|
class:bx--structured-list--selection="{selection}"
|
|
class:bx--structured-list--condensed="{condensed}"
|
|
class:bx--structured-list--flush="{flush}"
|
|
{...$$restProps}
|
|
on:click
|
|
on:mouseover
|
|
on:mouseenter
|
|
on:mouseleave
|
|
>
|
|
<slot />
|
|
</div>
|