Merge pull request #220 from IBM/chore

Add JSDoc type annotations to component props
This commit is contained in:
Eric Liu 2020-07-26 18:24:58 -07:00 committed by GitHub
commit 4b8373effa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
132 changed files with 3752 additions and 392 deletions

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Specify the number of accordion items to render
* @type {number} [count=4]
*/
export let count = 4; export let count = 4;
/**
* Set to `false` to close the first accordion item
* @type {boolean} [open=true]
*/
export let open = true; export let open = true;
import ChevronRight16 from "carbon-icons-svelte/lib/ChevronRight16"; import ChevronRight16 from "carbon-icons-svelte/lib/ChevronRight16";

View file

@ -1,5 +1,14 @@
<script> <script>
export let align = "end"; // "start" | "end" /**
* Specify alignment of accordion item chevron icon
* @type {"start" | "end"} [align="end"]
*/
export let align = "end";
/**
* Set to `true` to display the skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false; export let skeleton = false;
import AccordionSkeleton from "./Accordion.Skeleton.svelte"; import AccordionSkeleton from "./Accordion.Skeleton.svelte";

View file

@ -1,6 +1,21 @@
<script> <script>
/**
* Specify the title of the accordion item heading
* Alternatively, use the named slot "title" (e.g. <div slot="title">...</div>)
* @type {string} [title="title"]
*/
export let title = "title"; export let title = "title";
/**
* Set to `true` to open the first accordion item
* @type {boolean} [open=false]
*/
export let open = false; export let open = false;
/**
* Specify the ARIA label for the accordion item chevron icon
* @type {string} [iconDescription="Expand/Collapse"]
*/
export let iconDescription = "Expand/Collapse"; export let iconDescription = "Expand/Collapse";
import ChevronRight16 from "carbon-icons-svelte/lib/ChevronRight16"; import ChevronRight16 from "carbon-icons-svelte/lib/ChevronRight16";

View file

@ -1,12 +1,27 @@
<script>
/**
* Set to `true` to hide the breadcrumb trailing slash
* @type {boolean} [noTrailingSlash=false]
*/
export let noTrailingSlash = false;
/**
* Specify the number of breadcrumb items to render
* @type {number} [count=3]
*/
export let count = 3;
</script>
<div <div
class:bx--breadcrumb={true} class:bx--breadcrumb={true}
class:bx--breadcrumb--no-trailing-slash={noTrailingSlash}
class:bx--skeleton={true} class:bx--skeleton={true}
{...$$restProps} {...$$restProps}
on:click on:click
on:mouseover on:mouseover
on:mouseenter on:mouseenter
on:mouseleave> on:mouseleave>
{#each [0, 1, 2] as item, i (item)} {#each Array.from({ length: count }, (_, i) => i) as item, i (item)}
<div class:bx--breadcrumb-item={true}> <div class:bx--breadcrumb-item={true}>
<span class:bx--link={true}>&nbsp;</span> <span class:bx--link={true}>&nbsp;</span>
</div> </div>

View file

@ -24,7 +24,7 @@
<BreadcrumbItem href="#" aria-current="page">Breadcrumb 3</BreadcrumbItem> <BreadcrumbItem href="#" aria-current="page">Breadcrumb 3</BreadcrumbItem>
</Breadcrumb> </Breadcrumb>
{:else if story === 'skeleton'} {:else if story === 'skeleton'}
<BreadcrumbSkeleton /> <BreadcrumbSkeleton {noTrailingSlash} {...$$restProps} />
{:else} {:else}
<Breadcrumb {noTrailingSlash}> <Breadcrumb {noTrailingSlash}>
<BreadcrumbItem let:props> <BreadcrumbItem let:props>

View file

@ -1,4 +1,4 @@
import { withKnobs, boolean } from "@storybook/addon-knobs"; import { withKnobs, boolean, number } from "@storybook/addon-knobs";
import Component from "./Breadcrumb.Story.svelte"; import Component from "./Breadcrumb.Story.svelte";
export default { title: "Breadcrumb", decorators: [withKnobs] }; export default { title: "Breadcrumb", decorators: [withKnobs] };
@ -12,7 +12,11 @@ export const Default = () => ({
export const Skeleton = () => ({ export const Skeleton = () => ({
Component, Component,
props: { story: "skeleton" }, props: {
story: "skeleton",
noTrailingSlash: boolean("No Trailing Slash (noTrailingSlash)", false),
count: number("Number of breadcrumb items (count)", 3),
},
}); });
export const CurrentPage = () => ({ export const CurrentPage = () => ({

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set to `true` to hide the breadcrumb trailing slash
* @type {boolean} [noTrailingSlash=false]
*/
export let noTrailingSlash = false; export let noTrailingSlash = false;
/**
* Set to `true` to display skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false; export let skeleton = false;
import BreadcrumbSkeleton from "./Breadcrumb.Skeleton.svelte"; import BreadcrumbSkeleton from "./Breadcrumb.Skeleton.svelte";

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set the `href` to use an anchor link
* @type {string} [href]
*/
export let href = undefined; export let href = undefined;
/**
* Set to `true` if the breadcrumb item represents the current page
* @type {boolean} [isCurrentPage=false]
*/
export let isCurrentPage = false; export let isCurrentPage = false;
import { Link } from "../Link"; import { Link } from "../Link";

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set the `href` to use an anchor link
* @type {string} [href]
*/
export let href = undefined; export let href = undefined;
/**
* Set to `true` to use the small variant
* @type {boolean} [small=false]
*/
export let small = false; export let small = false;
</script> </script>

View file

@ -6,6 +6,7 @@ export default { title: "Button", decorators: [withKnobs] };
const kinds = { const kinds = {
"Primary button (primary)": "primary", "Primary button (primary)": "primary",
"Secondary button (secondary)": "secondary", "Secondary button (secondary)": "secondary",
"Tertiary button (tertiary)": "tertiary",
"Danger button (danger)": "danger", "Danger button (danger)": "danger",
"Ghost button (ghost)": "ghost", "Ghost button (ghost)": "ghost",
}; };

View file

@ -1,17 +1,88 @@
<script> <script>
export let as = undefined; /**
export let skeleton = false; * Specify the kind of button
export let disabled = false; * @type {"primary" | "secondary" | "tertiary" | "ghost" | "danger"} [kind="primary"]
export let href = undefined; */
export let icon = undefined;
export let iconDescription = undefined;
export let hasIconOnly = false;
export let kind = "primary"; export let kind = "primary";
/**
* Specify the size of button
* @type {"default" | "field" | "small"} [size="default"]
*/
export let size = "default"; export let size = "default";
export let tabindex = "0";
/**
* Set to `true` for the icon-only variant
* @type {boolean} [hasIconOnly=false]
*/
export let hasIconOnly = false;
/**
* Specify the icon from `carbon-icons-svelte` to render
* @type {typeof import("carbon-icons-svelte/lib/Add16").default} [icon]
*/
export let icon = undefined;
/**
* Specify the ARIA label for the button icon
* @type {string} [iconDescription]
*/
export let iconDescription = undefined;
/**
* Set the alignment of the tooltip relative to the icon
* `hasIconOnly` must be set to `true`
* @type {"start" | "center" | "end"} [tooltipAlignment]
*/
export let tooltipAlignment = undefined; export let tooltipAlignment = undefined;
/**
* Set the position of the tooltip relative to the icon
* @type {"top" | "right" | "bottom" | "left"} [tooltipPosition]
*/
export let tooltipPosition = undefined; export let tooltipPosition = undefined;
/**
* Set to `true` to render a custom HTML element
* Props are destructured as `props` in the default slot (e.g. <Button let:props><div {...props}>...</div></Button>)
* @type {boolean} [as=false]
*/
export let as = false;
/**
* Set to `true` to display the skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false;
/**
* Set to `true` to disable the button
* @type [boolean] [disabled=false]
*/
export let disabled = false;
/**
* Set the `href` to use an anchor link
* @type {string} [href]
*/
export let href = undefined;
/**
* Specify the tabindex
* @type {string} [tabindex="0"]
*/
export let tabindex = "0";
/**
* Specify the `type` attribute for the button element
* @type {string} [type="button"]
*/
export let type = "button"; export let type = "button";
/**
* Obtain a reference to the HTML element
* @type {null | HTMLAnchorElement | HTMLButtonElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { getContext } from "svelte"; import { getContext } from "svelte";

View file

@ -1,14 +1,68 @@
<script> <script>
export let skeleton = false; /**
export let indeterminate = false; * Specify whether the checkbox is checked
export let readonly = false; * @type {boolean} [checked=false]
*/
export let checked = false; export let checked = false;
/**
* Specify whether the checkbox is indeterminate
* @type {boolean} [indeterminate=false]
*/
export let indeterminate = false;
/**
* Set to `true` to display the skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false;
/**
* Set to `true` for the checkbox to be read-only
* @type {boolean} [readonly=false]
*/
export let readonly = false;
/**
* Set to `true` to disable the checkbox
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Specify the label text
* @type {string} [labelText=""]
*/
export let labelText = ""; export let labelText = "";
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
export let id = "ccs-" + Math.random().toString(36);
/**
* Set a name for the input element
* @type {string} [name=""]
*/
export let name = ""; export let name = "";
/**
* Specify the title attribute for the label element
* @type {string} [title]
*/
export let title = undefined; export let title = undefined;
/**
* Set an id for the input label
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
@ -49,7 +103,7 @@
on:change={() => { on:change={() => {
checked = !checked; checked = !checked;
}} /> }} />
<label class:bx--checkbox-label={true} for={id} {title}> <label for={id} {title} class:bx--checkbox-label={true}>
<span <span
class:bx--checkbox-label-text={true} class:bx--checkbox-label-text={true}
class:bx--visually-hidden={hideLabel}> class:bx--visually-hidden={hideLabel}>

View file

@ -1,5 +1,9 @@
<script> <script>
export let type = "single"; // "single" | "multi" /**
* Set the type of code snippet
* @type {"single" | "inline" | "multi"} [type="single"]
*/
export let type = "single";
</script> </script>
<div <div

View file

@ -1,17 +1,89 @@
<script> <script>
export let type = "single"; // "single" | "inline" | "multi" /**
* Set the type of code snippet
* @type {"single" | "inline" | "multi"} [type="single"]
*/
export let type = "single";
/**
* Set the code snippet text
* Alternatively, use the default slot (e.g. <CodeSnippet>{`code`}</CodeSnippet>)
* @type {string} [code]
*/
export let code = undefined; export let code = undefined;
/**
* Set to `true` to expand a multi-line code snippet (type="multi")
* @type {boolean} [expanded=false]
*/
export let expanded = false; export let expanded = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
/**
* Set to `true` to display the skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false; export let skeleton = false;
/**
* Specify the ARIA label for the copy button icon
* @type {string} [copyButtonDescription]
*/
export let copyButtonDescription = undefined; export let copyButtonDescription = undefined;
/**
* Specify the ARIA label of the copy button
* @type {string} [copyLabel]
*/
export let copyLabel = undefined; export let copyLabel = undefined;
/**
* Specify the feedback text displayed when clicking the snippet
* @type {string} [feedback="Copied!"]
*/
export let feedback = "Copied!"; export let feedback = "Copied!";
/**
* Set the timeout duration (ms) to display feedback text
* @type {number} [feedbackTimeout=2000]
*/
export let feedbackTimeout = 2000; export let feedbackTimeout = 2000;
/**
* Specify the show less text
* `type` must be "multi"
* @type {string} [showLessText="Show less"]
*/
export let showLessText = "Show less"; export let showLessText = "Show less";
/**
* Specify the show more text
* `type` must be "multi"
* @type {string} [showLessText="Show more"]
*/
export let showMoreText = "Show more"; export let showMoreText = "Show more";
/**
* Set to `true` to enable the show more/less button
* @type {boolean} [showMoreLess=false]
*/
export let showMoreLess = false; export let showMoreLess = false;
/**
* Set an id for the code element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Obtain a reference to the pre HTML element
* @type {null | HTMLPreElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { afterUpdate } from "svelte"; import { afterUpdate } from "svelte";
@ -48,7 +120,7 @@
{expanded && 'bx--snippet--expand'} {expanded && 'bx--snippet--expand'}
{light && 'bx--snippet--light'}" {light && 'bx--snippet--light'}"
{...$$restProps} {...$$restProps}
on:clicks on:click
on:mouseover on:mouseover
on:mouseenter on:mouseenter
on:mouseleave> on:mouseleave>

View file

@ -1,21 +1,114 @@
<script> <script>
export let disabled = false; /**
export let helperText = ""; * @typedef {{ id: string; text: string; }} ComboBoxItem
export let id = "ccs-" + Math.random().toString(36); */
export let invalid = false;
export let invalidText = ""; /**
* Set the combobox items
* @type {ComboBoxItem[]} [items=[]]
*/
export let items = []; export let items = [];
export let itemToString = item => item.text || item.id;
export let light = false; /**
export let open = false; * Override the display of a combobox item
export let placeholder = ""; * @type {(item: ComboBoxItem) => string;} [itemToString = (item: ComboBoxItem) => string;]
*/
export let itemToString = (item) => item.text || item.id;
/**
* Set the selected item by value index
* @type {number} [selectedIndex=-1]
*/
export let selectedIndex = -1; export let selectedIndex = -1;
export let shouldFilterItem = () => true;
export let size = undefined; /**
export let titleText = ""; * Specify the selected combobox value
export let translateWithId = undefined; * @type {string} [value=""]
*/
export let value = ""; export let value = "";
/**
* Set the size of the combobox
* @type {"sm" | "xl"} [size]
*/
export let size = undefined;
/**
* Set to `true` to disable the combobox
* @type {boolean} [disabled=false]
*/
export let disabled = false;
/**
* Specify the title text of the combobox
* @type {string} [titleText=""]
*/
export let titleText = "";
/**
* Specify the placeholder text
* @type {string} [placeholder=""]
*/
export let placeholder = "";
/**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = "";
/**
* Specify the invalid state text
* @type {string} [invalidText=""]
*/
export let invalidText = "";
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false;
/**
* Set to `true` to open the combobox menu dropdown
* @type {boolean} [open=false]
*/
export let open = false;
/**
* Determine if an item should be filtered given the current combobox value
* @type {(item: ComboBoxItem, value: string) => boolean} [shouldFilterItem=() => true]
*/
export let shouldFilterItem = () => true;
/**
* Override the default translation ids
* @type {(id: any) => string;} [translateWithId]
*/
export let translateWithId = undefined;
/**
* Set an id for the list box component
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name]
*/
export let name = undefined; export let name = undefined;
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { afterUpdate } from "svelte"; import { afterUpdate } from "svelte";
@ -26,7 +119,7 @@
ListBoxMenu, ListBoxMenu,
ListBoxMenuIcon, ListBoxMenuIcon,
ListBoxMenuItem, ListBoxMenuItem,
ListBoxSelection ListBoxSelection,
} from "../ListBox"; } from "../ListBox";
let selectedId = undefined; let selectedId = undefined;
@ -48,7 +141,7 @@
afterUpdate(() => { afterUpdate(() => {
if (open) { if (open) {
ref.focus(); ref.focus();
filteredItems = items.filter(item => shouldFilterItem(item, value)); filteredItems = items.filter((item) => shouldFilterItem(item, value));
} else { } else {
highlightedIndex = -1; highlightedIndex = -1;
inputValue = selectedItem ? selectedItem.text : ""; inputValue = selectedItem ? selectedItem.text : "";
@ -61,7 +154,7 @@
$: highlightedId = items[highlightedIndex] $: highlightedId = items[highlightedIndex]
? items[highlightedIndex].id ? items[highlightedIndex].id
: 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; $: inputValue = selectedItem ? selectedItem.text : undefined;
$: value = inputValue; $: value = inputValue;

View file

@ -1,9 +1,38 @@
<script> <script>
/**
* Set the size of the composed modal
* @type {"xs" | "sm" | "lg"} [size]
*/
export let size = undefined;
/**
* Set to `true` to open the modal
* @type {boolean} [open=false]
*/
export let open = false; export let open = false;
/**
* Set to `true` to use the danger variant
* @type {boolean} [danger=false]
*/
export let danger = false; export let danger = false;
export let size = undefined; // "xs" | "sm" | "lg"
/**
* Specify a class for the inner modal
* @type {string} [containerClass=""]
*/
export let containerClass = ""; export let containerClass = "";
/**
* Specify a selector to be focused when opening the modal
* @type {string} [selectorPrimaryFocus="[data-modal-primary-focus]"]
*/
export let selectorPrimaryFocus = "[data-modal-primary-focus]"; export let selectorPrimaryFocus = "[data-modal-primary-focus]";
/**
* Obtain a reference to the top-level HTML element
* @type {null | HTMLElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { import {
@ -11,7 +40,7 @@
tick, tick,
setContext, setContext,
onMount, onMount,
afterUpdate afterUpdate,
} from "svelte"; } from "svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -26,9 +55,9 @@
submit: () => { submit: () => {
dispatch("submit"); dispatch("submit");
}, },
declareRef: ref => { declareRef: (ref) => {
buttonRef = ref; buttonRef = ref;
} },
}); });
function focus(element) { function focus(element) {

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set to `true` if the modal contains form elements
* @type {boolean} [hasForm=false]
*/
export let hasForm = false; export let hasForm = false;
/**
* Set to `true` if the modal contains scrolling content
* @type {boolean} [hasScrollingContent=false]
*/
export let hasScrollingContent = false; export let hasScrollingContent = false;
</script> </script>

View file

@ -1,9 +1,38 @@
<script> <script>
export let primaryClass = undefined; /**
* Specify the primary button text
* @type {string} [primaryButtonText=""]
*/
export let primaryButtonText = ""; export let primaryButtonText = "";
/**
* Set to `true` to disable the primary button
* @type {boolean} [primaryButtonDisabled=false]
*/
export let primaryButtonDisabled = false; export let primaryButtonDisabled = false;
export let secondaryClass = undefined;
/**
* Specify a class for the primary button
* @type {string} [primaryClass]
*/
export let primaryClass = undefined;
/**
* Specify the secondary button text
* @type {string} [secondaryButtonText=""]
*/
export let secondaryButtonText = ""; export let secondaryButtonText = "";
/**
* Specify a class for the secondary button
* @type {string} [secondaryClass]
*/
export let secondaryClass = undefined;
/**
* Set to `true` to use the danger variant
* @type {boolean} [danger=false]
*/
export let danger = false; export let danger = false;
import { getContext } from "svelte"; import { getContext } from "svelte";

View file

@ -1,10 +1,44 @@
<script> <script>
/**
* Specify the modal title
* @type {string} [title=""]
*/
export let title = ""; export let title = "";
/**
* Specify the modal label
* @type {string} [label=""]
*/
export let label = ""; export let label = "";
/**
* Specify the label class
* @type {string} [labelClass=""]
*/
export let labelClass = ""; export let labelClass = "";
/**
* Specify the title class
* @type {string} [titleClass=""]
*/
export let titleClass = ""; export let titleClass = "";
/**
* Specify the close class
* @type {string} [closeClass=""]
*/
export let closeClass = ""; export let closeClass = "";
/**
* Specify the close icon class
* @type {string} [closeIconClass=""]
*/
export let closeIconClass = ""; export let closeIconClass = "";
/**
* Specify the ARIA label for the close icon
* @type {string} [iconDescription="Close"]
*/
export let iconDescription = "Close"; export let iconDescription = "Close";
import { getContext } from "svelte"; import { getContext } from "svelte";

View file

@ -1,5 +1,9 @@
<script> <script>
export let story = undefined; export let story = undefined;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
import ContentSwitcher from "./ContentSwitcher.svelte"; import ContentSwitcher from "./ContentSwitcher.svelte";

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set the selected index of the switch item
* @type {number} [selectedIndex=0]
*/
export let selectedIndex = 0; export let selectedIndex = 0;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
import { afterUpdate, createEventDispatcher, setContext } from "svelte"; import { afterUpdate, createEventDispatcher, setContext } from "svelte";
@ -24,10 +33,10 @@
switches = [...switches, { id, text, selected }]; switches = [...switches, { id, text, selected }];
}, },
update: id => { update: (id) => {
selectedIndex = switches.map(({ id }) => id).indexOf(id); selectedIndex = switches.map(({ id }) => id).indexOf(id);
}, },
change: direction => { change: (direction) => {
let index = currentIndex + direction; let index = currentIndex + direction;
if (index < 0) { if (index < 0) {
@ -37,7 +46,7 @@
} }
selectedIndex = index; selectedIndex = index;
} },
}); });
afterUpdate(() => { afterUpdate(() => {

View file

@ -1,8 +1,33 @@
<script> <script>
/**
* Specify the switch text
* Alternatively, use the named slot "text" (e.g. <span slot="text">...</span>)
* @type {string} [text="Provide text"]
*/
export let text = "Provide text"; export let text = "Provide text";
/**
* Set to `true` for the switch to be selected
* @type {boolean} [selected=false]
*/
export let selected = false; export let selected = false;
/**
* Set to `true` to disable the switch
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Set an id for the button element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Obtain a reference to the button HTML element
* @type {null | HTMLButtonElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { afterUpdate, getContext, onDestroy } from "svelte"; import { afterUpdate, getContext, onDestroy } from "svelte";
@ -11,7 +36,7 @@
ctx.add({ id, text, selected }); ctx.add({ id, text, selected });
const unsubscribe = ctx.currentId.subscribe($ => { const unsubscribe = ctx.currentId.subscribe(($) => {
selected = $ === id; selected = $ === id;
}); });

View file

@ -1,6 +1,20 @@
<script> <script>
/**
* Set the feedback text shown after clicking the button
* @type {string} [feedback="Copied!"]
*/
export let feedback = "Copied!"; export let feedback = "Copied!";
/**
* Set the timeout duration (ms) to display feedback text
* @type {number} [feedbackTimeout=2000]
*/
export let feedbackTimeout = 2000; export let feedbackTimeout = 2000;
/**
* Obtain a reference to the button HTML element
* @type {null | HTMLButtonElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { onMount } from "svelte"; import { onMount } from "svelte";
@ -8,8 +22,6 @@
let animation = undefined; let animation = undefined;
let timeout = undefined; let timeout = undefined;
$: showFeedback = timeout !== undefined;
onMount(() => { onMount(() => {
return () => { return () => {
clearTimeout(timeout); clearTimeout(timeout);

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set the title and ARIA label for the copy button
* @type {string} [iconDescription="Copy to clipboard"]
*/
export let iconDescription = "Copy to clipboard"; export let iconDescription = "Copy to clipboard";
import { Copy } from "../Copy"; import { Copy } from "../Copy";

View file

@ -1,13 +1,53 @@
<script> <script>
export let size = undefined; // "compact" | "short" | "tall" /**
export let title = ""; * Specify the data table headers
export let description = ""; * @type {{key: string; value: string;}} [headers=[]]
export let zebra = false; */
export let sortable = false;
export let stickyHeader = false;
export let rows = [];
export let headers = []; export let headers = [];
/**
* Specify the rows the data table should render
* keys defined in `headers` are used for the row ids
* @type {Object[]} [rows=[]]
*/
export let rows = [];
/**
* Set the size of the data table
* @type {"compact" | "short" | "tall"} [size]
*/
export let size = undefined;
/**
* Specify the title of the data table
* @type {string} [title=""]
*/
export let title = "";
/**
* Specify the description of the data table
* @type {string} [description=""]
*/
export let description = "";
/**
* Set to `true` to use zebra styles
* @type {boolean} [zebra=false]
*/
export let zebra = false;
/**
* Set to `true` for the sortable variant
* @type {boolean} [sortable=false]
*/
export let sortable = false;
/**
* Set to `true` to enable a sticky header
* @type {boolean} [stickyHeader=false]
*/
export let stickyHeader = false;
import { createEventDispatcher, setContext } from "svelte"; import { createEventDispatcher, setContext } from "svelte";
import { writable, derived } from "svelte/store"; import { writable, derived } from "svelte/store";
import Table from "./Table.svelte"; import Table from "./Table.svelte";
@ -21,7 +61,7 @@
const sortDirectionMap = { const sortDirectionMap = {
none: "ascending", none: "ascending",
ascending: "descending", ascending: "descending",
descending: "none" descending: "none",
}; };
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const tableSortable = writable(sortable); const tableSortable = writable(sortable);
@ -36,16 +76,16 @@
setContext("DataTable", { setContext("DataTable", {
sortHeader, sortHeader,
tableSortable, tableSortable,
add: id => { add: (id) => {
headerItems.update(_ => [..._, id]); headerItems.update((_) => [..._, id]);
} },
}); });
$: tableSortable.set(sortable); $: tableSortable.set(sortable);
$: headerKeys = headers.map(({ key }) => key); $: headerKeys = headers.map(({ key }) => key);
$: rows = rows.map(row => ({ $: rows = rows.map((row) => ({
...row, ...row,
cells: headerKeys.map(key => ({ key, value: row[key] })) cells: headerKeys.map((key) => ({ key, value: row[key] })),
})); }));
$: sortedRows = rows; $: sortedRows = rows;
$: ascending = $sortHeader.sortDirection === "ascending"; $: ascending = $sortHeader.sortDirection === "ascending";
@ -71,7 +111,7 @@
} }
$: props = { $: props = {
headers, headers,
rows rows,
}; };
</script> </script>
@ -91,7 +131,7 @@
sortHeader.set({ sortHeader.set({
id: sortDirection === 'none' ? null : $thKeys[header.key], id: sortDirection === 'none' ? null : $thKeys[header.key],
key: header.key, key: header.key,
sortDirection sortDirection,
}); });
}}> }}>
{header.value} {header.value}

View file

@ -1,9 +1,38 @@
<script> <script>
export let size = undefined; // "compact" | "short" | "tall" /**
* Set the size of the table
* @type {"compact" | "short" | "tall"} [size]
*/
export let size = undefined;
/**
* Set to `true` to use zebra styles
* @type {boolean} [zebra=false]
*/
export let zebra = false; export let zebra = false;
/**
* Set to `true` to use static width
* @type {boolean} [useStaticWidth=false]
*/
export let useStaticWidth = false; export let useStaticWidth = false;
/**
* Set to `true` for the bordered variant
* @type {boolean} [shouldShowBorder=false]
*/
export let shouldShowBorder = false; export let shouldShowBorder = false;
/**
* Set to `true` for the sortable variant
* @type {boolean} [sortable=false]
*/
export let sortable = false; export let sortable = false;
/**
* Set to `true` to enable a sticky header
* @type {boolean} [stickyHeader=false]
*/
export let stickyHeader = false; export let stickyHeader = false;
</script> </script>

View file

@ -1,7 +1,21 @@
<script> <script>
export let stickyHeader = false; /**
* Specify the title of the data table
* @type {string} [title=""]
*/
export let title = ""; export let title = "";
/**
* Specify the description of the data table
* @type {string} [description=""]
*/
export let description = ""; export let description = "";
/**
* Set to `true` to enable a sticky header
* @type {boolean} [stickyHeader=false]
*/
export let stickyHeader = false;
</script> </script>
<div <div

View file

@ -1,6 +1,20 @@
<script> <script>
/**
* Specify the `scope` attribute
* @type {string} [scope="col"]
*/
export let scope = "col"; export let scope = "col";
/**
* Override the default id translations
* @type {() => string;} [translateWithId = () => "";]
*/
export let translateWithId = () => ""; export let translateWithId = () => "";
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
import { getContext } from "svelte"; import { getContext } from "svelte";
@ -20,6 +34,7 @@
<th <th
aria-sort={active ? $sortHeader.sortDirection : 'none'} aria-sort={active ? $sortHeader.sortDirection : 'none'}
{scope} {scope}
{id}
{...$$restProps} {...$$restProps}
on:mouseover on:mouseover
on:mouseenter on:mouseenter
@ -41,6 +56,7 @@
{:else} {:else}
<th <th
{scope} {scope}
{id}
{...$$restProps} {...$$restProps}
on:click on:click
on:mouseover on:mouseover

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to select the row
* @type {boolean} [isSelected=false]
*/
export let isSelected = false; export let isSelected = false;
// TODO: include ariaLabel, onExpand, isExpanded, isSelected // TODO: include ariaLabel, onExpand, isExpanded, isSelected

View file

@ -1,8 +1,33 @@
<script> <script>
/**
* Specify the number of columns
* @type {number} [columns=5]
*/
export let columns = 5; export let columns = 5;
/**
* Specify the number of rows
* @type {number} [rows=5]
*/
export let rows = 5; export let rows = 5;
/**
* Set to `true` to use the compact variant
* @type {boolean} [compact=false]
*/
export let compact = false; export let compact = false;
/**
* Set to `true` to apply zebra styles to the datatable rows
* @type {boolean} [zebra=false]
*/
export let zebra = false; export let zebra = false;
/**
* Set the column headers
* If `headers` has one more items, `count` is ignored
* @type {string[]} [headers=[]]
*/
export let headers = []; export let headers = [];
$: cols = Array.from( $: cols = Array.from(

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set to `true` to use the range variant
* @type {boolean} [range=false]
*/
export let range = false; export let range = false;
/**
* Set an id to be used by the label element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
</script> </script>

View file

@ -1,35 +1,84 @@
<script> <script>
export let appendTo = document.body; /**
export let dateFormat = "m/d/Y"; * Specify the date picker type
* @type {"simple" | "single" | "range"} [datePickerType="simple"]
*/
export let datePickerType = "simple"; export let datePickerType = "simple";
export let id = "ccs-" + Math.random().toString(36);
export let light = false; /**
export let locale = "en"; * Specify the date picker input value
export let maxDate = null; * @type {string} [value=""]
export let minDate = null; */
export let short = false;
export let value = ""; export let value = "";
/**
* Specify the element to append the calendar to
* @type {HTMLElement} [appendTo=document.body]
*/
export let appendTo = document.body;
/**
* Specify the date format
* @type {string} [dateFormat="m/d/Y"]
*/
export let dateFormat = "m/d/Y";
/**
* Specify the maximum date
* @type {null | string | Date} [maxDate=null]
*/
export let maxDate = null;
/**
* Specify the minimum date
* @type {null | string | Date} [minDate=null]
*/
export let minDate = null;
/**
* Specify the locale
* @type {string} [locale="en"]
*/
export let locale = "en";
/**
* Set to `true` to use the short variant
* @type {boolean} [short=false]
*/
export let short = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false;
/**
* Set an id for the date picker element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
import { import {
createEventDispatcher, createEventDispatcher,
setContext, setContext,
afterUpdate, afterUpdate,
onDestroy onDestroy,
} from "svelte"; } from "svelte";
import { writable, derived } from "svelte/store"; import { writable, derived } from "svelte/store";
import { createCalendar } from "./createCalendar"; import { createCalendar } from "./createCalendar";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const inputs = writable([]); const inputs = writable([]);
const inputIds = derived(inputs, _ => _.map(({ id }) => id)); const inputIds = derived(inputs, (_) => _.map(({ id }) => id));
const labelTextEmpty = derived( const labelTextEmpty = derived(
inputs, inputs,
_ => _.filter(({ labelText }) => !!labelText).length === 0 (_) => _.filter(({ labelText }) => !!labelText).length === 0
); );
const inputValue = writable(value); const inputValue = writable(value);
const mode = writable(datePickerType); const mode = writable(datePickerType);
const range = derived(mode, _ => _ === "range"); const range = derived(mode, (_) => _ === "range");
const hasCalendar = derived(mode, _ => _ === "single" || _ === "range"); const hasCalendar = derived(mode, (_) => _ === "single" || _ === "range");
let calendar = undefined; let calendar = undefined;
let datePickerRef = undefined; let datePickerRef = undefined;
@ -40,8 +89,8 @@
range, range,
inputValue, inputValue,
hasCalendar, hasCalendar,
add: data => { add: (data) => {
inputs.update(_ => [..._, data]); inputs.update((_) => [..._, data]);
}, },
declareRef: ({ id, ref }) => { declareRef: ({ id, ref }) => {
if ($inputIds.indexOf(id) === 0) { if ($inputIds.indexOf(id) === 0) {
@ -59,7 +108,7 @@
dispatch("change", value); dispatch("change", value);
} }
}, },
blurInput: relatedTarget => { blurInput: (relatedTarget) => {
if (calendar && !calendar.calendarContainer.contains(relatedTarget)) { if (calendar && !calendar.calendarContainer.contains(relatedTarget)) {
calendar.close(); calendar.close();
} }
@ -74,7 +123,7 @@
calendar.calendarContainer.querySelector(".flatpickr-day[tabindex]") || calendar.calendarContainer.querySelector(".flatpickr-day[tabindex]") ||
calendar.calendarContainer calendar.calendarContainer
).focus(); ).focus();
} },
}); });
afterUpdate(() => { afterUpdate(() => {
@ -87,24 +136,24 @@
locale, locale,
maxDate, maxDate,
minDate, minDate,
mode: $mode mode: $mode,
}, },
base: inputRef, base: inputRef,
input: inputRefTo, input: inputRefTo,
dispatch: event => { dispatch: (event) => {
const detail = { selectedDates: calendar.selectedDates }; const detail = { selectedDates: calendar.selectedDates };
if ($range) { if ($range) {
detail.dateStr = { detail.dateStr = {
from: inputRef.value, from: inputRef.value,
to: inputRefTo.value to: inputRefTo.value,
}; };
} else { } else {
detail.dateStr = inputRef.value; detail.dateStr = inputRef.value;
} }
return dispatch(event, detail); return dispatch(event, detail);
} },
}); });
} }
@ -149,8 +198,8 @@
class:bx--date-picker={true} class:bx--date-picker={true}
class:bx--date-picker--short={short} class:bx--date-picker--short={short}
class:bx--date-picker--light={light} class:bx--date-picker--light={light}
class="{datePickerType && `--date-picker--${datePickerType}`} class="{datePickerType && `bx--date-picker--${datePickerType}`}
{datePickerType === 'range' && $labelTextEmpty && '--date-picker--nolabel'}"> {datePickerType === 'range' && $labelTextEmpty && 'bx--date-picker--nolabel'}">
<slot /> <slot />
</div> </div>
</div> </div>

View file

@ -1,16 +1,56 @@
<script> <script>
export let size = undefined; // "sm" | "xl" /**
* Set the size of the input
* @type {"sm" | "xl"} [size]
*/
export let size = undefined;
/**
* Specify the input type
* @type {string} [type="text"]
*/
export let type = "text"; export let type = "text";
/**
* Specify the input placeholder text
* @type {string} [placeholder=""]
*/
export let placeholder = ""; export let placeholder = "";
export let pattern = "\\d{1,2}\\/\\d{1,2}\\/\\d{4}"; export let pattern = "\\d{1,2}\\/\\d{1,2}\\/\\d{4}";
export let disabled = false; export let disabled = false;
/**
* Specify the ARIA label for the calendar icon
* @type {string} [iconDescription=""]
*/
export let iconDescription = ""; export let iconDescription = "";
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
export let labelText = ""; export let labelText = "";
export let hideLabel = false; export let hideLabel = false;
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
/**
* Specify the invalid state text
* @type {string} [invalidText=""]
*/
export let invalidText = ""; export let invalidText = "";
export let name = undefined; export let name = undefined;
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { getContext, onMount } from "svelte"; import { getContext, onMount } from "svelte";
@ -25,7 +65,7 @@
blurInput, blurInput,
openCalendar, openCalendar,
focusCalendar, focusCalendar,
inputValue inputValue,
} = getContext("DatePicker"); } = getContext("DatePicker");
add({ id, labelText }); add({ id, labelText });

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to use the inline variant
* @type {boolean} [inline=false]
*/
export let inline = false; export let inline = false;
</script> </script>

View file

@ -1,21 +1,116 @@
<script> <script>
export let selectedIndex = -1; /**
export let open = false; * @typedef {string} DropdownItemId
export let inline = false; * @typedef {string} DropdownItemText
export let light = false; * @typedef {{ id: DropdownItemId; text: DropdownItemText; }} DropdownItem
export let disabled = false; */
export let invalid = false;
/**
* Set the dropdown items
* @type {DropdownItem[]} [items=[]]
*/
export let items = []; export let items = [];
export let itemToString = item => item.text || item.id;
export let type = "default"; // "default" | "inline" /**
export let size = undefined; // "sm" | "lg" | "xl" * Override the display of a dropdown item
export let id = "ccs-" + Math.random().toString(36); * @type {(item: DropdownItem) => string;} [itemToString = (item: DropdownItem) => DropdownItemText | DropdownItemId;]
export let name = undefined; */
export let invalidText = ""; export let itemToString = (item) => item.text || item.id;
export let helperText = "";
export let label = undefined; /**
* Specify the selected item index
* @type {number} [selectedIndex=-1]
*/
export let selectedIndex = -1;
/**
* Specify the type of dropdown
* @type {"default" | "inline"} [type="default"]
*/
export let type = "default";
/**
* Specify the size of the dropdown field
* @type {"sm" | "lg" | "xl"} [size]
*/
export let size = undefined;
/**
* Set to `true` to open the dropdown
* @type {boolean} [open=false]
*/
export let open = false;
/**
* Set to `true` to use the inline variant
* @type {boolean} [inline=false]
*/
export let inline = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false;
/**
* Set to `true` to disable the dropdown
* @type {boolean} [disabled=false]
*/
export let disabled = false;
/**
* Specify the title text
* @type {string} [titleText=""]
*/
export let titleText = ""; export let titleText = "";
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false;
/**
* Specify the invalid state text
* @type {string} [invalidText=""]
*/
export let invalidText = "";
/**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = "";
/**
* Specify the list box label
* @type {string} [label]
*/
export let label = undefined;
/**
* Override the default translation ids
* @type {(id: any) => string;} [translateWithId]
*/
export let translateWithId = undefined; export let translateWithId = undefined;
/**
* Set an id for the list box component
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the list box
* @type {string} [name]
*/
export let name = undefined;
/**
* Obtain a reference to the button HTML element
* @type {null | HTMLButtonElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { setContext } from "svelte"; import { setContext } from "svelte";
@ -24,7 +119,7 @@
ListBox, ListBox,
ListBoxMenu, ListBoxMenu,
ListBoxMenuIcon, ListBoxMenuIcon,
ListBoxMenuItem ListBoxMenuItem,
} from "../ListBox"; } from "../ListBox";
let selectedId = undefined; let selectedId = undefined;

View file

@ -1,14 +1,70 @@
<script> <script>
export let status = "uploading"; // "uploading" | "edit" | "complete" /**
* Specify the file uploader status
* @type {"uploading" | "edit" | "complete"} [status="uploading"]
*/
export let status = "uploading";
/**
* Specify the accepted file types
* @type {string[]} [accept=[]]
*/
export let accept = []; export let accept = [];
/**
* Obtain the uploaded file names
* @type {string[]} [files=[]]
*/
export let files = []; export let files = [];
export const clearFiles = () => (files = []);
export let buttonLabel = ""; /**
export let iconDescription = "Provide icon description"; * Set to `true` to allow multiple files
export let kind = "primary"; * @type {boolean} [multiple=false]
export let labelDescription = ""; */
export let labelTitle = "";
export let multiple = false; export let multiple = false;
/**
* Override the default behavior of clearing the array of uploaded files
* @type {() => any;} [clearFiles = () => void;]
*/
export const clearFiles = () => {
files = [];
};
/**
* Specify the label description
* @type {string} [labelDescription=""]
*/
export let labelDescription = "";
/**
* Specify the label title
* @type {string} [labelTitle=""]
*/
export let labelTitle = "";
/**
* Specify the kind of file uploader button
* @type {"primary" | "secondary" | "tertiary" | "ghost" | "danger"} [kind="primary"]
*/
export let kind = "primary";
/**
* Specify the button label
* @type {string} [buttonLabel=""]
*/
export let buttonLabel = "";
/**
* Specify the ARIA label used for the status icons
* @type {string} [iconDescription=""]
*/
export let iconDescription = "Provide icon description";
/**
* Specify a name attribute for the file button uploader input
* @type {string} [name]
*/
export let name = ""; export let name = "";
import { createEventDispatcher, afterUpdate } from "svelte"; import { createEventDispatcher, afterUpdate } from "svelte";
@ -23,7 +79,10 @@
if (files.length > prevFiles.length) { if (files.length > prevFiles.length) {
dispatch("add", files); dispatch("add", files);
} else { } else {
dispatch("remove", prevFiles.filter(_ => !files.includes(_))); dispatch(
"remove",
prevFiles.filter((_) => !files.includes(_))
);
} }
prevFiles = [...files]; prevFiles = [...files];

View file

@ -1,14 +1,68 @@
<script> <script>
/**
* Specify the accepted file types
* @type {string[]} [accept=[]]
*/
export let accept = []; export let accept = [];
/**
* Set to `true` to allow multiple files
* @type {boolean} [multiple=false]
*/
export let multiple = false; export let multiple = false;
/**
* Set to `true` to disable the input
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Set to `true` to disable label changes
* @type {boolean} [disableLabelChanges=false]
*/
export let disableLabelChanges = false; export let disableLabelChanges = false;
export let kind = "primary"; // Button.kind
/**
* Specify the kind of file uploader button
* @type {"primary" | "secondary" | "tertiary" | "ghost" | "danger"} [kind="primary"]
*/
export let kind = "primary";
/**
* Specify the label text
* @type {string} [labelText="Add file"]
*/
export let labelText = "Add file"; export let labelText = "Add file";
/**
* Specify the label role
* @type {string} [role="button"]
*/
export let role = "button"; export let role = "button";
/**
* Specify `tabindex` attribute
* @type {string} [tabindex="0"]
*/
export let tabindex = "0"; export let tabindex = "0";
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name]
*/
export let name = ""; export let name = "";
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
</script> </script>

View file

@ -1,13 +1,67 @@
<script> <script>
/**
* @typedef {string[]} Files
*/
/**
* Specify the accepted file types
* @type {string[]} [accept=[]]
*/
export let accept = []; export let accept = [];
export let disabled = false;
/**
* Set to `true` to allow multiple files
* @type {boolean} [multiple=false]
*/
export let multiple = false; export let multiple = false;
export let validateFiles = files => files;
/**
* Override the default behavior of validating uploaded files
* The default behavior does not validate files
* @type {(files: Files) => Files} [validateFiles = (files: Files) => Files;]
*/
export let validateFiles = (files) => files;
/**
* Specify the label text
* @type {string} [labelText="Add file"]
*/
export let labelText = "Add file"; export let labelText = "Add file";
/**
* Specify the `role` attribute of the drop container
* @type {string} [role="button"]
*/
export let role = "button"; export let role = "button";
/**
* Set to `true` to disable the input
* @type {boolean} [disabled=false]
*/
export let disabled = false;
/**
* Specify `tabindex` attribute
* @type {string} [tabindex="0"]
*/
export let tabindex = "0"; export let tabindex = "0";
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name=""]
*/
export let name = ""; export let name = "";
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";

View file

@ -1,12 +1,46 @@
<script> <script>
export let errorBody = ""; /**
export let errorSubject = ""; * Specify the file uploader status
export let iconDescription = ""; * @type {"uploading" | "edit" | "complete"} [status="uploading"]
export let id = "ccs-" + Math.random().toString(36); */
export let invalid = false;
export let name = "";
export let status = "uploading"; export let status = "uploading";
/**
* Specify the ARIA label used for the status icons
* @type {string} [iconDescription=""]
*/
export let iconDescription = "";
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false;
/**
* Specify the error subject text
* @type {string} [errorSubject=""]
*/
export let errorSubject = "";
/**
* Specify the error body text
* @type {string} [errorBody=""]
*/
export let errorBody = "";
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify the file uploader name
* @type {string} [name=""]
*/
export let name = "";
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
import Filename from "./Filename.svelte"; import Filename from "./Filename.svelte";
@ -14,6 +48,7 @@
</script> </script>
<span <span
{id}
class:bx--file__selected-file={true} class:bx--file__selected-file={true}
class:bx--file__selected-file--invalid={invalid} class:bx--file__selected-file--invalid={invalid}
{...$$restProps} {...$$restProps}

View file

@ -1,7 +1,21 @@
<script> <script>
/**
* Specify the file name status
* @type {"uploading" | "edit" | "complete"} [status="uploading"]
*/
export let status = "uploading";
/**
* Specify the ARIA label used for the status icons
* @type {string} [iconDescription=""]
*/
export let iconDescription = ""; export let iconDescription = "";
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
export let status = "uploading"; // "uploading" | "edit" | "complete"
import Close16 from "carbon-icons-svelte/lib/Close16"; import Close16 from "carbon-icons-svelte/lib/Close16";
import CheckmarkFilled16 from "carbon-icons-svelte/lib/CheckmarkFilled16"; import CheckmarkFilled16 from "carbon-icons-svelte/lib/CheckmarkFilled16";

View file

@ -1,8 +1,13 @@
<script> <script>
export let legendText = ""; /**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
export let message = false; export let message = false;
export let messageText = ""; export let messageText = "";
export let legendText = "";
</script> </script>
<fieldset <fieldset

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set an id to be used by the label element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
</script> </script>

View file

@ -1,37 +1,61 @@
<script> <script>
/**
* Set to `true` to render a custom HTML element
* Props are destructured as `props` in the default slot (e.g. <Column let:props><article {...props}>...</article></Column>)
* @type {boolean} [as=false]
*/
export let as = false; export let as = false;
/**
* Set to `true` to remove the gutter
* @type {boolean} [noGutter=false]
*/
export let noGutter = false; export let noGutter = false;
/**
* Set to `true` to remove the left gutter
* @type {boolean} [noGutterLeft=false]
*/
export let noGutterLeft = false; export let noGutterLeft = false;
/**
* Set to `true` to remove the right gutter
* @type {boolean} [noGutterRight=false]
*/
export let noGutterRight = false; export let noGutterRight = false;
/** /**
* Aspect ratio of the column * Specify the aspect ratio of the column
* @type {("2x1" | "16x9" | "9x16" | "1x2" | "4x3" | "3x4" | "1x1")} [aspectRatio] * @type {"2x1" | "16x9" | "9x16" | "1x2" | "4x3" | "3x4" | "1x1"} [aspectRatio]
*/ */
export let aspectRatio = undefined; export let aspectRatio = undefined;
/** /**
* @typedef {(boolean | number)} ColumnSize * @typedef {boolean | number} ColumnSize
* @typedef {Object} ColumnSizeDescriptor * @typedef {{span?: ColumnSize: offset: number;}} ColumnSizeDescriptor
* @property {ColumnSize} [ColumnSizeDescriptor.span] Column size * @typedef {ColumnSize | ColumnSizeDescriptor} ColumnBreakpoint
* @property {number} [ColumnSizeDescriptor.offset] Column offset
*/ */
/** @type {ColumnSize|ColumnSizeDescriptor} [sm] */ /** @type {ColumnBreakpoint} [sm] */
export let sm = undefined; export let sm = undefined;
/** @type {ColumnSize|ColumnSizeDescriptor} [md] */ /** @type {ColumnBreakpoint} [md] */
export let md = undefined; export let md = undefined;
/** @type {ColumnSize|ColumnSizeDescriptor} [lg] */ /** @type {ColumnBreakpoint} [lg] */
export let lg = undefined; export let lg = undefined;
/** @type {ColumnSize|ColumnSizeDescriptor} [xlg] */ /** @type {ColumnBreakpoint} [xlg] */
export let xlg = undefined; export let xlg = undefined;
/** @type {ColumnSize|ColumnSizeDescriptor} [max] */ /** @type {ColumnBreakpoint} [max] */
export let max = undefined; export let max = undefined;
/**
* Column breakpoints
* @constant
* @type {string[]}
*/
const breakpoints = ["sm", "md", "lg", "xlg", "max"]; const breakpoints = ["sm", "md", "lg", "xlg", "max"];
$: columnClass = [sm, md, lg, xlg, max] $: columnClass = [sm, md, lg, xlg, max]

View file

@ -1,10 +1,45 @@
<script> <script>
/**
* Set to `true` to render a custom HTML element
* Props are destructured as `props` in the default slot (e.g. <Grid let:props><header {...props}>...</header></Grid>)
* @type {boolean} [as=false]
*/
export let as = false; export let as = false;
/**
* Set to `true` to use the condensed variant
* @type {boolean} [condensed=false]
*/
export let condensed = false; export let condensed = false;
/**
* Set to `true` to use the narrow variant
* @type {boolean} [narrow=false]
*/
export let narrow = false; export let narrow = false;
/**
* Set to `true` to use the fullWidth variant
* @type {boolean} [fullWidth=false]
*/
export let fullWidth = false; export let fullWidth = false;
/**
* Set to `true` to remove the gutter
* @type {boolean} [noGutter=false]
*/
export let noGutter = false; export let noGutter = false;
/**
* Set to `true` to remove the left gutter
* @type {boolean} [noGutterLeft=false]
*/
export let noGutterLeft = false; export let noGutterLeft = false;
/**
* Set to `true` to remove the right gutter
* @type {boolean} [noGutterRight=false]
*/
export let noGutterRight = false; export let noGutterRight = false;
$: props = { $: props = {

View file

@ -1,9 +1,39 @@
<script> <script>
/**
* Set to `true` to render a custom HTML element
* Props are destructured as `props` in the default slot (e.g. <Row let:props><section {...props}>...</section></Row>)
* @type {boolean} [as=false]
*/
export let as = false; export let as = false;
/**
* Set to `true` to use the condensed variant
* @type {boolean} [condensed=false]
*/
export let condensed = false; export let condensed = false;
/**
* Set to `true` to use the narrow variant
* @type {boolean} [narrow=false]
*/
export let narrow = false; export let narrow = false;
/**
* Set to `true` to remove the gutter
* @type {boolean} [noGutter=false]
*/
export let noGutter = false; export let noGutter = false;
/**
* Set to `true` to remove the left gutter
* @type {boolean} [noGutterLeft=false]
*/
export let noGutterLeft = false; export let noGutterLeft = false;
/**
* Set to `true` to remove the right gutter
* @type {boolean} [noGutterRight=false]
*/
export let noGutterRight = false; export let noGutterRight = false;
$: props = { $: props = {

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set the size of the icon
* @type {number} [size=16]
*/
export let size = 16; export let size = 16;
</script> </script>

View file

@ -1,5 +1,15 @@
<script> <script>
/**
* Specify the icon from `carbon-icons-svelte` to render
* Icon size must be 16px (e.g. `Add16`, `Task16`)
* @type {typeof import("carbon-icons-svelte/lib/Add16").default} [render]
*/
export let render = undefined; export let render = undefined;
/**
* Set to `true` to display the skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false; export let skeleton = false;
import IconSkeleton from "./Icon.Skeleton.svelte"; import IconSkeleton from "./Icon.Skeleton.svelte";

View file

@ -1,7 +1,26 @@
<script> <script>
export let status = "active"; // "active" | "inactive" | "finished" | "error" /**
* Set the loading status
* @type {"active" | "inactive" | "finished" | "error"} [status="active"]
*/
export let status = "active";
/**
* Set the loading description
* @type {string} [description]
*/
export let description = undefined; export let description = undefined;
/**
* Specify the ARIA label for the loading icon
* @type {string} [iconDescription="Expand/Collapse"]
*/
export let iconDescription = undefined; export let iconDescription = undefined;
/**
* Specify the timeout delay (ms) after `status` is set to "success"
* @type {number} [successDelay=1500]
*/
export let successDelay = 1500; export let successDelay = 1500;
import { createEventDispatcher, afterUpdate, onMount } from "svelte"; import { createEventDispatcher, afterUpdate, onMount } from "svelte";

View file

@ -1,6 +1,20 @@
<script> <script>
/**
* Set to `true` to use the inline variant
* @type {boolean} [inline=false]
*/
export let inline = false; export let inline = false;
/**
* Set to `true` to disable the checkbox
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Obtain a reference to the top-level HTML element
* @type {null | HTMLAnchorElement | HTMLParagraphElement} [ref=null]
*/
export let ref = null; export let ref = null;
</script> </script>

View file

@ -1,10 +1,44 @@
<script> <script>
export let size = undefined; // "sm" | "xl" /**
export let type = "default"; // "default" | "inline" * Set the size of the list box
* @type {"sm" | "xl"} [size]
*/
export let size = undefined;
/**
* Set the type of the list box
* @type {"default" | "inline"} [type="default"]
*/
export let type = "default";
/**
* Set to `true` to open the list box
* @type {boolean} [open=false]
*/
export let open = false; export let open = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
/**
* Set to `true` to disable the list box
* @type {boolean} [disable=false]
*/
export let disabled = false; export let disabled = false;
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
/**
* Specify the invalid state text
* @type {string} [invalidText=""]
*/
export let invalidText = ""; export let invalidText = "";
</script> </script>
@ -21,7 +55,7 @@
class="{size && `bx--list-box--${size}`} class="{size && `bx--list-box--${size}`}
{$$restProps.class}" {$$restProps.class}"
on:keydown on:keydown
on:keydown={e => { on:keydown={(e) => {
if (e.key === 'Escape') { if (e.key === 'Escape') {
e.stopPropagation(); e.stopPropagation();
} }

View file

@ -1,17 +1,56 @@
<script> <script>
/**
* Set to `true` to disable the list box field
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Specify the role attribute
* @type {string} [role="combobox"]
*/
export let role = "combobox"; export let role = "combobox";
/**
* Specify the tabindex
* @type {string} [tabindex="-1"]
*/
export let tabindex = "-1"; export let tabindex = "-1";
/**
* @typedef {"close" | "open"} ListBoxFieldTranslationId
*/
/**
* Default translation ids
* @constant
* @type {{ close: "close"; open: "open"; }}
*/
export const translationIds = { close: "close", open: "open" }; export const translationIds = { close: "close", open: "open" };
export let translateWithId = id => defaultTranslations[id];
/**
* Override the default translation ids
* @type {(id: ListBoxFieldTranslationId) => string;} [translateWithId = (id) => string;]
*/
export let translateWithId = (id) => defaultTranslations[id];
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Obtain a reference to the top-level HTML element
* @type {null | HTMLElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { getContext } from "svelte"; import { getContext } from "svelte";
const defaultTranslations = { const defaultTranslations = {
[translationIds.close]: "Close menu", [translationIds.close]: "Close menu",
[translationIds.open]: "Open menu" [translationIds.open]: "Open menu",
}; };
const ctx = getContext("MultiSelect"); const ctx = getContext("MultiSelect");

View file

@ -1,12 +1,14 @@
<script> <script>
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
$: menuId = `menu-${id}`;
</script> </script>
<div <div
role="listbox" role="listbox"
id={menuId} id="menu-{id}"
class:bx--list-box__menu={true} class:bx--list-box__menu={true}
{...$$restProps}> {...$$restProps}>
<slot /> <slot />

View file

@ -1,13 +1,32 @@
<script> <script>
export const translationIds = { close: "close", open: "open" }; /**
* Set to `true` to open the list box menu icon
* @type {boolean} [open=false]
*/
export let open = false; export let open = false;
export let translateWithId = id => defaultTranslations[id];
/**
* Default translation ids
* @constant
* @type {{ close: "close"; open: "open" }}
*/
export const translationIds = { close: "close", open: "open" };
/**
* @typedef {"close" | "open"} ListBoxMenuIconTranslationId
*/
/**
* Override the default translation ids
* @type {(id: ListBoxMenuIconTranslationId) => string;} [translateWithId = (id) => string;]
*/
export let translateWithId = (id) => defaultTranslations[id];
import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16"; import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16";
const defaultTranslations = { const defaultTranslations = {
[translationIds.close]: "Close menu", [translationIds.close]: "Close menu",
[translationIds.open]: "Open menu" [translationIds.open]: "Open menu",
}; };
$: description = open ? translateWithId("close") : translateWithId("open"); $: description = open ? translateWithId("close") : translateWithId("open");

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set to `true` to enable the active state
* @type {boolean} [active=false]
*/
export let active = false; export let active = false;
/**
* Set to `true` to enable the highlighted state
* @type {boolean} [highlighted=false]
*/
export let highlighted = false; export let highlighted = false;
</script> </script>

View file

@ -1,11 +1,40 @@
<script> <script>
/**
* Specify the number of selected items
* @type {*} [selectionCount]
*/
export let selectionCount = undefined;
/**
* Set to `true` to disable the list box selection
* @type {boolean} [disabled=false]
*/
export let disabled = false;
/**
* @typedef {"clearAll" | "clearSelection"} ListBoxSelectionTranslationId
*/
/**
* Default translation ids
* @constant
* @type {{ clearAll: "clearAll"; clearSelection: "clearSelection" }}
*/
export const translationIds = { export const translationIds = {
clearAll: "clearAll", clearAll: "clearAll",
clearSelection: "clearSelection" clearSelection: "clearSelection",
}; };
export let disabled = false;
export let selectionCount = undefined; /**
export let translateWithId = id => defaultTranslations[id]; * Override the default translation ids
* @type {(id: ListBoxSelectionTranslationId) => string;} [translateWithId = (id) => string;]
*/
export let translateWithId = (id) => defaultTranslations[id];
/**
* Obtain a reference to the top-level HTML element
* @type {null | HTMLElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { createEventDispatcher, getContext } from "svelte"; import { createEventDispatcher, getContext } from "svelte";
@ -13,7 +42,7 @@
const defaultTranslations = { const defaultTranslations = {
[translationIds.clearAll]: "Clear all selected items", [translationIds.clearAll]: "Clear all selected items",
[translationIds.clearSelection]: "Clear selected item" [translationIds.clearSelection]: "Clear selected item",
}; };
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const ctx = getContext("MultiSelect"); const ctx = getContext("MultiSelect");
@ -37,12 +66,12 @@
class:bx--tag--filter={selectionCount} class:bx--tag--filter={selectionCount}
class:bx--list-box__selection--multi={selectionCount} class:bx--list-box__selection--multi={selectionCount}
{...$$restProps} {...$$restProps}
on:click|preventDefault|stopPropagation={e => { on:click|preventDefault|stopPropagation={(e) => {
if (!disabled) { if (!disabled) {
dispatch('clear', e); dispatch('clear', e);
} }
}} }}
on:keydown|stopPropagation={e => { on:keydown|stopPropagation={(e) => {
if (!disabled && e.key === 'Enter') { if (!disabled && e.key === 'Enter') {
dispatch('clear', e); dispatch('clear', e);
} }

View file

@ -1,8 +1,32 @@
<script> <script>
/**
* Set to `true` to use the small variant
* @type {boolean} [small=false]
*/
export let small = false; export let small = false;
/**
* Set to `false` to disable the active state
* @type {boolean} [active=true]
*/
export let active = true; export let active = true;
/**
* Set to `false` to disable the overlay
* @type {boolean} [withOverlay=false]
*/
export let withOverlay = true; export let withOverlay = true;
/**
* Specify the label description
* @type {string} [description="Active loading indicator"]
*/
export let description = "Active loading indicator"; export let description = "Active loading indicator";
/**
* Set an id for the label element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
$: spinnerRadius = small ? "26.8125" : "37.5"; $: spinnerRadius = small ? "26.8125" : "37.5";

View file

@ -1,20 +1,104 @@
<script> <script>
export let size = undefined; // "xs" | "sm" | "lg" /**
* Set the size of the modal
* @type {"xs" | "sm" | "lg"} [size]
*/
export let size = undefined;
/**
* Set to `true` to open the modal
* @type {boolean} [open=false]
*/
export let open = false; export let open = false;
export let passiveModal = false;
/**
* Set to `true` to use the danger variant
* @type {boolean} [danger=false]
*/
export let danger = false; export let danger = false;
export let hasForm = false;
export let hasScrollingContent = false; /**
export let primaryButtonDisabled = false; * Set to `true` to use the passive variant
export let shouldSubmitOnEnter = true; * @type {boolean} [passiveModal=false]
export let modalAriaLabel = undefined; */
export let passiveModal = false;
/**
* Specify the modal heading
* @type {string} [modalHeading]
*/
export let modalHeading = undefined; export let modalHeading = undefined;
/**
* Specify the modal label
* @type {string} [modalLabel]
*/
export let modalLabel = undefined; export let modalLabel = undefined;
/**
* Specify the ARIA label for the modal
* @type {string} [modalAriaLabel]
*/
export let modalAriaLabel = undefined;
/**
* Specify the ARIA label for the close icon
* @type {string} [iconDescription="Close the modal"]
*/
export let iconDescription = "Close the modal"; export let iconDescription = "Close the modal";
/**
* Set to `true` if the modal contains form elements
* @type {boolean} [hasForm=false]
*/
export let hasForm = false;
/**
* Set to `true` if the modal contains scrolling content
* @type {boolean} [hasScrollingContent=false]
*/
export let hasScrollingContent = false;
/**
* Specify the primary button text
* @type {string} [primaryButtonText=""]
*/
export let primaryButtonText = ""; export let primaryButtonText = "";
/**
* Set to `true` to disable the primary button
* @type {boolean} [primaryButtonDisabled=false]
*/
export let primaryButtonDisabled = false;
/**
* Set to `true` for the primary button to be triggered when pressing "Enter"
* @type {boolean} [shouldSubmitOnEnter=true]
*/
export let shouldSubmitOnEnter = true;
/**
* Specify the secondary button text
* @type {string} [secondaryButtonText=""]
*/
export let secondaryButtonText = ""; export let secondaryButtonText = "";
/**
* Specify a selector to be focused when opening the modal
* @type {string} [selectorPrimaryFocus="[data-modal-primary-focus]"]
*/
export let selectorPrimaryFocus = "[data-modal-primary-focus]"; export let selectorPrimaryFocus = "[data-modal-primary-focus]";
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Obtain a reference to the top-level HTML element
* @type {null | HTMLElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { createEventDispatcher, onMount, afterUpdate } from "svelte"; import { createEventDispatcher, onMount, afterUpdate } from "svelte";

View file

@ -1,31 +1,157 @@
<script> <script>
export let size = undefined; // "sm" | "lg" | "xl" /**
export let type = "default"; // "default" | "inline" * @typedef {string} MultiSelectItemId
export let selectionFeedback = "top-after-reopen"; // "top" | "fixed" | "top-after-reopen" * @typedef {string} MultiSelectItemText
* @typedef {{ id: MultiSelectItemId; text: MultiSelectItemText; }} MultiSelectItem
*/
/**
* Set the multiselect items
* @type {MultiSelectItem[]} [items=[]]
*/
export let items = [];
/**
* Override the display of a multiselect item
* @type {(item: MultiSelectItem) => string;} [itemToString = (item: MultiSelectItem) => MultiSelectItemText | MultiSelectItemId;]
*/
export let itemToString = (item) => item.text || item.id;
/**
* Set the selected ids
* @type {MultiSelectItemId[]} [selectedIds=[]]
*/
export let selectedIds = [];
/**
* Specify the multiselect value
* @type {string} [value=""]
*/
export let value = "";
/**
* Set the size of the combobox
* @type {"sm" | "lg" | "xl"} [size]
*/
export let size = undefined;
/**
* Specify the type of multiselect
* @type {"default" | "inline"} [type="default"]
*/
export let type = "default";
/**
* Specify the selection feedback after selecting items
* @type {"top" | "fixed" | "top-after-reopen"} [selectionFeedback="top-after-reopen"]
*/
export let selectionFeedback = "top-after-reopen";
/**
* Set to `true` to disable the dropdown
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Set to `true` to filter items
* @type {boolean} [filterable=false]
*/
export let filterable = false; export let filterable = false;
/**
* Override the filtering logic
* The default filtering is an exact string comparison
* @type {(item: MultiSelectItem, value: string) => string;} [filterItem = ((item: MultiSelectItem, value: string) => string;)]
*/
export let filterItem = (item, value) => export let filterItem = (item, value) =>
item.text.toLowerCase().includes(value.toLowerCase()); item.text.toLowerCase().includes(value.toLowerCase());
export let id = "ccs-" + Math.random().toString(36);
export let name = undefined; /**
export let invalid = false; * Set to `true` to open the dropdown
export let invalidText = ""; * @type {boolean} [open=false]
export let helperText = ""; */
export let items = [];
export let itemToString = item => item.text || item.id;
export let label = "";
export let light = false;
export let locale = "en";
export let open = false; export let open = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false;
/**
* Specify the locale
* @type {string} [locale="en"]
*/
export let locale = "en";
/**
* Specify the placeholder text
* @type {string} [placeholder=""]
*/
export let placeholder = ""; export let placeholder = "";
export let selectedIds = [];
/**
* Override the sorting logic
* The default sorting compare the item text value
* @type {(a: MultiSelectItem, b: MultiSelectItem) => MultiSelectItem;} [sortItem = (a: MultiSelectItem, b: MultiSelectItem) => MultiSelectItem]
*/
export let sortItem = (a, b) => export let sortItem = (a, b) =>
a.text.localeCompare(b.text, locale, { numeric: true }); a.text.localeCompare(b.text, locale, { numeric: true });
export let titleText = "";
/**
* Override the default translation ids
* @type {(id: any) => string;} [translateWithId]
*/
export let translateWithId = undefined; export let translateWithId = undefined;
/**
* Specify the title text
* @type {string} [titleText=""]
*/
export let titleText = "";
/**
* Set to `true` to pass the item to `itemToString` in the checkbox
* @type {boolean} [useTitleInItem=false]
*/
export let useTitleInItem = false; export let useTitleInItem = false;
export let value = "";
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false;
/**
* Specify the invalid state text
* @type {string} [invalidText=""]
*/
export let invalidText = "";
/**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = "";
/**
* Specify the list box label
* @type {string} [label]
*/
export let label = "";
/**
* Set an id for the list box component
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the select
* @type {string} [name]
*/
export let name = undefined;
import { afterUpdate, setContext } from "svelte"; import { afterUpdate, setContext } from "svelte";
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
@ -36,7 +162,7 @@
ListBoxMenu, ListBoxMenu,
ListBoxMenuIcon, ListBoxMenuIcon,
ListBoxMenuItem, ListBoxMenuItem,
ListBoxSelection ListBoxSelection,
} from "../ListBox"; } from "../ListBox";
let multiSelectRef = null; let multiSelectRef = null;
@ -59,7 +185,7 @@
selectionRef = ref; selectionRef = ref;
break; break;
} }
} },
}); });
function change(direction) { function change(direction) {
@ -77,7 +203,7 @@
function sort() { function sort() {
return [ return [
...(checked.length > 1 ? checked.sort(sortItem) : checked), ...(checked.length > 1 ? checked.sort(sortItem) : checked),
...unchecked.sort(sortItem) ...unchecked.sort(sortItem),
]; ];
} }
@ -106,13 +232,13 @@
$: menuId = `menu-${id}`; $: menuId = `menu-${id}`;
$: inline = type === "inline"; $: inline = type === "inline";
$: ariaLabel = $$props["aria-label"] || "Choose an item"; $: ariaLabel = $$props["aria-label"] || "Choose an item";
$: sortedItems = items.map(item => ({ $: sortedItems = items.map((item) => ({
...item, ...item,
checked: selectedIds.includes(item.id) checked: selectedIds.includes(item.id),
})); }));
$: checked = sortedItems.filter(({ checked }) => checked); $: checked = sortedItems.filter(({ checked }) => checked);
$: unchecked = sortedItems.filter(({ checked }) => !checked); $: unchecked = sortedItems.filter(({ checked }) => !checked);
$: filteredItems = sortedItems.filter(item => filterItem(item, value)); $: filteredItems = sortedItems.filter((item) => filterItem(item, value));
$: highlightedId = sortedItems[highlightedIndex] $: highlightedId = sortedItems[highlightedIndex]
? sortedItems[highlightedIndex].id ? sortedItems[highlightedIndex].id
: undefined; : undefined;
@ -210,9 +336,9 @@
<ListBoxSelection <ListBoxSelection
selectionCount={checked.length} selectionCount={checked.length}
on:clear={() => { on:clear={() => {
sortedItems = sortedItems.map(item => ({ sortedItems = sortedItems.map((item) => ({
...item, ...item,
checked: false checked: false,
})); }));
fieldRef.blur(); fieldRef.blur();
}} }}
@ -294,7 +420,7 @@
active={item.checked} active={item.checked}
highlighted={highlightedIndex === i} highlighted={highlightedIndex === i}
on:click={() => { on:click={() => {
sortedItems = sortedItems.map(_ => sortedItems = sortedItems.map((_) =>
_.id === item.id ? { ..._, checked: !_.checked } : _ _.id === item.id ? { ..._, checked: !_.checked } : _
); );
fieldRef.focus(); fieldRef.focus();

View file

@ -1,13 +1,52 @@
<script> <script>
/**
* Set the type of notification
* @type {"toast" | "inline"} [notificationType="toast"]
*/
export let notificationType = "inline"; export let notificationType = "inline";
export let kind = "error"; // "error" | "info" | "info-square" | "success" | "warning" | "warning-alt"
export let role = "alert"; /**
export let title = "provide a title"; * Specify the kind of notification
export let subtitle = ""; * @type {"error" | "info" | "info-square" | "success" | "warning" | "warning-alt"} [kind="error"]
export let iconDescription = "closes notification"; */
export let kind = "error";
/**
* Set to `true` to use the low contrast variant
* @type {boolean} [lowContrast=false]
*/
export let lowContrast = false; export let lowContrast = false;
/**
* Set the `role` attribute
* @type {string} [role="alert"]
*/
export let role = "alert";
/**
* Specify the title text
* @type {string} [title="Title"]
*/
export let title = "Title";
/**
* Specify the subtitle text
* @type {string} [subtitle=""]
*/
export let subtitle = "";
/**
* Set to `true` to hide the close button
* @type {boolean} [hideCloseButton=false]
*/
export let hideCloseButton = false; export let hideCloseButton = false;
/**
* Specify the ARIA label for the icon
* @type {string} [iconDescription="Closes notification"]
*/
export let iconDescription = "Closes notification";
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
import NotificationIcon from "./NotificationIcon.svelte"; import NotificationIcon from "./NotificationIcon.svelte";
import NotificationTextDetails from "./NotificationTextDetails.svelte"; import NotificationTextDetails from "./NotificationTextDetails.svelte";

View file

@ -1,17 +1,34 @@
<script> <script>
export let notificationType = "toast"; // "toast" | "inline" /**
export let iconDescription = "close icon"; * Set the type of notification
* @type {"toast" | "inline"} [notificationType="toast"]
*/
export let notificationType = "toast";
/**
* Specify the icon from `carbon-icons-svelte` to render
* @type {typeof import("carbon-icons-svelte/lib/Add16").default} [renderIcon]
*/
export let renderIcon = Close20; export let renderIcon = Close20;
/**
* Specify the title of the icon
*/
export let title = undefined; export let title = undefined;
export let type = "button";
/**
* Specify the ARIA label for the icon
* @type {string} [iconDescription="Close icon"]
*/
export let iconDescription = "Close icon";
import Close20 from "carbon-icons-svelte/lib/Close20"; import Close20 from "carbon-icons-svelte/lib/Close20";
</script> </script>
<button <button
type="button"
aria-label={iconDescription} aria-label={iconDescription}
title={iconDescription} title={iconDescription}
{type}
class:bx--toast-notification__close-button={notificationType === 'toast'} class:bx--toast-notification__close-button={notificationType === 'toast'}
class:bx--inline-notification__close-button={notificationType === 'inline'} class:bx--inline-notification__close-button={notificationType === 'inline'}
{...$$restProps} {...$$restProps}

View file

@ -1,7 +1,21 @@
<script> <script>
/**
* Specify the kind of notification icon
* @type {"error" | "info" | "info-square" | "success" | "warning" | "warning-alt"} [kind="error"]
*/
export let kind = "error"; export let kind = "error";
/**
* Set the type of notification
* @type {"toast" | "inline"} [notificationType="toast"]
*/
export let notificationType = "toast"; export let notificationType = "toast";
export let iconDescription = "closes notification";
/**
* Specify the ARIA label for the icon
* @type {string} [iconDescription="Closes notification"]
*/
export let iconDescription = "Closes notification";
import CheckmarkFilled20 from "carbon-icons-svelte/lib/CheckmarkFilled20"; import CheckmarkFilled20 from "carbon-icons-svelte/lib/CheckmarkFilled20";
import ErrorFilled20 from "carbon-icons-svelte/lib/ErrorFilled20"; import ErrorFilled20 from "carbon-icons-svelte/lib/ErrorFilled20";
@ -16,7 +30,7 @@
info: InformationFilled20, info: InformationFilled20,
success: CheckmarkFilled20, success: CheckmarkFilled20,
warning: WarningFilled20, warning: WarningFilled20,
"warning-alt": WarningAltFilled20 "warning-alt": WarningAltFilled20,
}; };
</script> </script>

View file

@ -1,8 +1,27 @@
<script> <script>
export let notificationType = "toast"; // "toast" | "inline" /**
export let title = "title"; * Set the type of notification
* @type {"toast" | "inline"} [notificationType="toast"]
*/
export let notificationType = "toast";
/**
* Specify the title text
* @type {string} [title="Title"]
*/
export let title = "Title";
/**
* Specify the subtitle text
* @type {string} [subtitle=""]
*/
export let subtitle = ""; export let subtitle = "";
export let caption = "caption";
/**
* Specify the caption text
* @type {string} [caption="Caption"]
*/
export let caption = "Caption";
</script> </script>
{#if notificationType === 'toast'} {#if notificationType === 'toast'}

View file

@ -1,14 +1,63 @@
<script> <script>
export let iconDescription = "closes notification"; /**
export let notificationType = "toast"; // "toast" | "inline" * Set the type of notification
* @type {"toast" | "inline"} [notificationType="toast"]
*/
export let notificationType = "toast";
/**
* Specify the kind of notification
* @type {"error" | "info" | "info-square" | "success" | "warning" | "warning-alt"} [kind="error"]
*/
export let kind = "error"; export let kind = "error";
export let hideCloseButton = false;
/**
* Set to `true` to use the low contrast variant
* @type {boolean} [lowContrast=false]
*/
export let lowContrast = false; export let lowContrast = false;
/**
* Set the timeout duration (ms) to hide the notification after closing it
* @type {number} [timeout=0]
*/
export let timeout = 0; export let timeout = 0;
/**
* Set the `role` attribute
* @type {string} [role="alert"]
*/
export let role = "alert"; export let role = "alert";
export let title = "provide a title";
/**
* Specify the title text
* @type {string} [title="Title"]
*/
export let title = "Title";
/**
* Specify the subtitle text
* @type {string} [subtitle=""]
*/
export let subtitle = ""; export let subtitle = "";
export let caption = "provide a caption";
/**
* Specify the caption text
* @type {string} [caption="Caption"]
*/
export let caption = "Caption";
/**
* Specify the ARIA label for the icon
* @type {string} [iconDescription="Closes notification"]
*/
export let iconDescription = "Closes notification";
/**
* Set to `true` to hide the close button
* @type {boolean} [hideCloseButton=false]
*/
export let hideCloseButton = false;
import { createEventDispatcher, onMount } from "svelte"; import { createEventDispatcher, onMount } from "svelte";
import NotificationButton from "./NotificationButton.svelte"; import NotificationButton from "./NotificationButton.svelte";

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
</script> </script>

View file

@ -1,29 +1,140 @@
<script> <script>
export let size = undefined; // "sm" | "xl"
/**
* Set the size of the input
* @type {"sm" | "xl"} [size]
*/
export let size = undefined;
/**
* Specify the input value
* @type {string} [value=""]
*/
export let value = ""; export let value = "";
/**
* Specify the step increment
* @type {number} [step=1]
*/
export let step = 1; export let step = 1;
/**
* Specify the maximum value
* @type {number} [max]
*/
export let max = undefined; export let max = undefined;
/**
* Specify the minimum value
* @type {number} [min]
*/
export let min = undefined; export let min = undefined;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
/**
* Set to `true` for the input to be read-only
* @type {boolean} [readonly=false]
*/
export let readonly = false; export let readonly = false;
/**
* Set to `true` to enable the mobile variant
* @type {boolean} [mobile=false]
*/
export let mobile = false; export let mobile = false;
/**
* Set to `true` to allow for an empty value
* @type {boolean} [allowEmpty=false]
*/
export let allowEmpty = false; export let allowEmpty = false;
/**
* Set to `true` to disable the input
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Specify the ARIA label for the increment icons
* @type {string} [iconDescription=""]
*/
export let iconDescription = ""; export let iconDescription = "";
export let id = "ccs-" + Math.random().toString(36);
export let name = undefined; /**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
export let invalidText = "Provide invalidText";
/**
* Specify the invalid state text
* @type {string} [invalidText="Provide invalidText"]
*/
export let invalidText = "";
/**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = ""; export let helperText = "";
/**
* Specify the label text
* @type {string} [label=""]
*/
export let label = ""; export let label = "";
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
export let ref = null;
export let translateWithId = id => defaultTranslations[id]; /**
* @typedef {"increment" | "decrement"} NumberInputTranslationId
*/
/**
* Override the default translation ids
* @type {(id: NumberInputTranslationId) => string;} [translateWithId = (id: NumberInputTranslationId) => string;]
*/
export let translateWithId = (id) => defaultTranslations[id];
/**
* Default translation ids
* @constant
* @type {{ increment: "increment"; decrement: "decrement" }}
*/
export const translationIds = { export const translationIds = {
increment: "increment", increment: "increment",
decrement: "decrement" decrement: "decrement",
}; };
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name]
*/
export let name = undefined;
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null;
import { createEventDispatcher, afterUpdate } from "svelte"; import { createEventDispatcher, afterUpdate } from "svelte";
import CaretDownGlyph from "carbon-icons-svelte/lib/CaretDownGlyph"; import CaretDownGlyph from "carbon-icons-svelte/lib/CaretDownGlyph";
import CaretUpGlyph from "carbon-icons-svelte/lib/CaretUpGlyph"; import CaretUpGlyph from "carbon-icons-svelte/lib/CaretUpGlyph";
@ -31,7 +142,7 @@
const defaultTranslations = { const defaultTranslations = {
[translationIds.increment]: "Increment number", [translationIds.increment]: "Increment number",
[translationIds.decrement]: "Decrement number" [translationIds.decrement]: "Decrement number",
}; };
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to use the nested variant
* @type {boolean} [nested=false]
*/
export let nested = false; export let nested = false;
</script> </script>

View file

@ -1,15 +1,58 @@
<script> <script>
/**
* Specify the direction of the overflow menu relative to the button
* @type {"top" | "bottom"} [direction="bottom"]
*/
export let direction = "bottom";
/**
* Set to `true` to open the menu
* @type {boolean} [open=false]
*/
export let open = false; export let open = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
/**
* Set to `true` to flip the menu relative to the button
* @type {boolean} [flipped=false]
*/
export let flipped = false; export let flipped = false;
export let direction = "bottom"; // "top" | "bottom"
export let tabindex = "0"; /**
export let icon = OverflowMenuVertical16; * Specify the menu options class
export let iconClass = undefined; * @type {string} [menuOptionsClass]
export let iconDescription = "Open and close list of options"; */
export let id = "ccs-" + Math.random().toString(36);
export let menuOptionsClass = undefined; export let menuOptionsClass = undefined;
/**
* Specify the icon from `carbon-icons-svelte` to render
* @type {typeof import("carbon-icons-svelte/lib/Add16").default} [icon]
*/
export let icon = OverflowMenuVertical16;
/**
* Specify the icon class
* @type {string} [iconClass]
*/
export let iconClass = undefined;
/**
* Specify the ARIA label for the icon
* @type {string} [iconDescription="Open and close list of options"]
*/
export let iconDescription = "Open and close list of options";
/**
* Set an id for the button element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
import { createEventDispatcher, setContext, afterUpdate } from "svelte"; import { createEventDispatcher, setContext, afterUpdate } from "svelte";
import { writable } from "svelte/store"; import { writable } from "svelte/store";
import OverflowMenuVertical16 from "carbon-icons-svelte/lib/OverflowMenuVertical16"; import OverflowMenuVertical16 from "carbon-icons-svelte/lib/OverflowMenuVertical16";
@ -29,7 +72,7 @@
setContext("OverflowMenu", { setContext("OverflowMenu", {
focusedId, focusedId,
add: ({ id, text, primaryFocus }) => { add: ({ id, text, primaryFocus }) => {
items.update(_ => { items.update((_) => {
if (primaryFocus) { if (primaryFocus) {
currentIndex.set(_.length); currentIndex.set(_.length);
} }
@ -37,10 +80,10 @@
return [..._, { id, text, primaryFocus, index: _.length }]; return [..._, { id, text, primaryFocus, index: _.length }];
}); });
}, },
update: id => { update: (id) => {
currentId.set(id); currentId.set(id);
}, },
change: direction => { change: (direction) => {
// TODO: skip disabled // TODO: skip disabled
let index = $currentIndex + direction; let index = $currentIndex + direction;
@ -51,12 +94,12 @@
} }
currentIndex.set(index); currentIndex.set(index);
} },
}); });
afterUpdate(() => { afterUpdate(() => {
if ($currentId) { if ($currentId) {
const { index, text } = $items.filter(_ => _.id === $currentId)[0]; const { index, text } = $items.filter((_) => _.id === $currentId)[0];
dispatch("close", { index, text }); dispatch("close", { index, text });
open = false; open = false;
} }
@ -117,11 +160,11 @@
<button <button
bind:this={buttonRef} bind:this={buttonRef}
tabindex="0"
aria-haspopup aria-haspopup
aria-expanded={open} aria-expanded={open}
aria-label={ariaLabel} aria-label={ariaLabel}
{id} {id}
{tabindex}
class:bx--overflow-menu={true} class:bx--overflow-menu={true}
class:bx--overflow-menu--open={open} class:bx--overflow-menu--open={open}
class:bx--overflow-menu--light={light} class:bx--overflow-menu--light={light}
@ -136,7 +179,7 @@
on:mouseenter on:mouseenter
on:mouseleave on:mouseleave
on:keydown on:keydown
on:keydown={e => { on:keydown={(e) => {
if (open) { if (open) {
if (['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp'].includes(e.key)) { if (['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp'].includes(e.key)) {
e.preventDefault(); e.preventDefault();

View file

@ -1,12 +1,57 @@
<script> <script>
export let danger = false; /**
export let disabled = false; * Specify the item text
export let hasDivider = false; * Alternatively, use the default slot for a custom element
export let href = ""; * @type {string} [text="Provide text"]
export let primaryFocus = false; */
export let requireTitle = true;
export let text = "Provide text"; export let text = "Provide text";
/**
* Specify the `href` attribute if the item is a link
* @type {string} [href=""]
*/
export let href = "";
/**
* Set to `true` if the item should be focused when opening the menu
* @type {boolean} [primaryFocus=false]
*/
export let primaryFocus = false;
/**
* Set to `true` to disable the item
* @type {boolean} [disabled=false]
*/
export let disabled = false;
/**
* Set to `true` to include a divider
* @type {boolean} [hasDivider=false]
*/
export let hasDivider = false;
/**
* Set to `true` to use the danger variant
* @type {boolean} [danger=false]
*/
export let danger = false;
/**
* Set to `false` to omit the button `title` attribute
* @type {boolean} [requireTitle=false]
*/
export let requireTitle = true;
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Obtain a reference to the HTML element
* @type {null | HTMLAnchorElement | HTMLButtonElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { getContext, afterUpdate } from "svelte"; import { getContext, afterUpdate } from "svelte";
@ -27,12 +72,13 @@
title: requireTitle ? text : undefined, title: requireTitle ? text : undefined,
class: "bx--overflow-menu-options__btn", class: "bx--overflow-menu-options__btn",
disabled: href ? undefined : disabled, disabled: href ? undefined : disabled,
href: href ? href : undefined href: href ? href : undefined,
}; };
</script> </script>
<li <li
role="menuitem" role="menuitem"
{id}
class:bx--overflow-menu-options__option={true} class:bx--overflow-menu-options__option={true}
class:bx--overflow-menu--divider={hasDivider} class:bx--overflow-menu--divider={hasDivider}
class:bx--overflow-menu-options__option--danger={danger} class:bx--overflow-menu-options__option--danger={danger}

View file

@ -1,19 +1,93 @@
<script> <script>
/**
* Specify the current page index
* @type {number} [page=1]
*/
export let page = 1;
/**
* Specify the total number of items
* @type {number} [total=0]
*/
export let totalItems = 0; export let totalItems = 0;
/**
* Set to `true` to disable the pagination
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Specify the forward button text
* @type {string} [forwardText="Next page"]
*/
export let forwardText = "Next page"; export let forwardText = "Next page";
/**
* Specify the backward button text
* @type {string} [backwardText="Previous page"]
*/
export let backwardText = "Previous page"; export let backwardText = "Previous page";
/**
* Specify the items per page text
* @type {string} [itemsPerPageText="Items per page:"]
*/
export let itemsPerPageText = "Items per page:";
/**
* Override the item text
* @type {(min: number, max: number) => string;} [itemText = (min: number, max: number) => string;]
*/
export let itemText = (min, max) => `${min}${max} items`;
/**
* Override the item range text
* @type {(min: number, max: number, total: number) => string;} [itemRangeText = (min: number, max: number, total: number) => string;]
*/
export let itemRangeText = (min, max, total) => export let itemRangeText = (min, max, total) =>
`${min}${max} of ${total} items`; `${min}${max} of ${total} items`;
export let itemsPerPageText = "Items per page:";
export let itemText = (min, max) => `${min}${max} items`; /**
export let page = 1; * Set to `true` to disable the page input
* @type {boolean} [pageInputDisabled=false]
*/
export let pageInputDisabled = false; export let pageInputDisabled = false;
export let pageRangeText = (current, total) => `of ${total} pages`;
/**
* Specify the number of items to display in a page
* @type {number} [pageSize=10]
*/
export let pageSize = 10; export let pageSize = 10;
/**
* Specify the available page sizes
* @type {number[]} [pageSizes=[10]]
*/
export let pageSizes = [10]; export let pageSizes = [10];
/**
* Set to `true` if the number of pages is unknown
* @type {boolean} [pagesUnknown=false]
*/
export let pagesUnknown = false; export let pagesUnknown = false;
export let pageText = page => `page ${page}`;
/**
* Override the page text
* @type {(page: number) => string;} [pageText = (current: number) => string;]
*/
export let pageText = (page) => `page ${page}`;
/**
* Override the page range text
* @type {(current: number, total: number) => string;} [pageRangeText = (current: number, total: number) => string;]
*/
export let pageRangeText = (current, total) => `of ${total} pages`;
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
import CaretLeft24 from "carbon-icons-svelte/lib/CaretLeft24"; import CaretLeft24 from "carbon-icons-svelte/lib/CaretLeft24";
@ -33,7 +107,7 @@
$: forwardButtonDisabled = disabled || page === totalPages; $: forwardButtonDisabled = disabled || page === totalPages;
</script> </script>
<div class:bx--pagination={true} {...$$restProps}> <div {id} class:bx--pagination={true} {...$$restProps}>
<div class:bx--pagination__left={true}> <div class:bx--pagination__left={true}>
<label <label
id="bx--pagination-select-{id}-count-label" id="bx--pagination-select-{id}-count-label"

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Specify the current page index
* @type {number} [page=0]
*/
export let page = 0; export let page = 0;
/**
* Set to `true` to use the active state
* @type {boolean} [active=false]
*/
export let active = false; export let active = false;
</script> </script>

View file

@ -1,9 +1,38 @@
<script> <script>
/**
* Specify the current page index
* @type {number} [page=0]
*/
export let page = 0; export let page = 0;
/**
* Specify the total number of pages
* @type {number} [total=10]
*/
export let total = 10; export let total = 10;
/**
* Specify the total number of pages to show
* @type {number} [shown=10]
*/
export let shown = 10; export let shown = 10;
/**
* Set to `true` to loop the navigation
* @type {boolean} [loop=false]
*/
export let loop = false; export let loop = false;
/**
* Specify the forward button text
* @type {string} [forwardText="Next page"]
*/
export let forwardText = "Next page"; export let forwardText = "Next page";
/**
* Specify the backward button text
* @type {string} [backwardText="Next page"]
*/
export let backwardText = "Previous page"; export let backwardText = "Previous page";
import { afterUpdate, createEventDispatcher } from "svelte"; import { afterUpdate, createEventDispatcher } from "svelte";
@ -14,7 +43,13 @@
import { Button } from "../Button"; import { Button } from "../Button";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const MIN = 4; // minimum items shown
/**
* Minimum number of items to be shown
* @constant
* @type {4}
*/
const MIN = 4;
afterUpdate(() => { afterUpdate(() => {
dispatch("change", { page }); dispatch("change", { page });

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Specify the pivot start index
* @type {number} [fromIndex=0]
*/
export let fromIndex = 0; export let fromIndex = 0;
/**
* Specify the pivot end index
* @type {number} [count=0]
*/
export let count = 0; export let count = 0;
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";

View file

@ -1,4 +1,7 @@
<script> <script>
/**
* Set to `true` to use the vertical variant
*/
export let vertical = false; export let vertical = false;
</script> </script>

View file

@ -1,5 +1,13 @@
<script> <script>
/**
* Specify the current step index
* @type {number} [currentIndex=0]
*/
export let currentIndex = 0; export let currentIndex = 0;
/**
* Set to `true` to use the vertical variant
*/
export let vertical = false; export let vertical = false;
import { createEventDispatcher, setContext } from "svelte"; import { createEventDispatcher, setContext } from "svelte";
@ -7,27 +15,27 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const steps = writable([]); const steps = writable([]);
const stepsById = derived(steps, $ => const stepsById = derived(steps, ($) =>
$.reduce((a, c) => ({ ...a, [c.id]: c }), {}) $.reduce((a, c) => ({ ...a, [c.id]: c }), {})
); );
setContext("ProgressIndicator", { setContext("ProgressIndicator", {
steps, steps,
stepsById, stepsById,
add: step => { add: (step) => {
steps.update(_ => [ steps.update((_) => [
..._, ..._,
{ {
...step, ...step,
index: _.length, index: _.length,
current: _.length === currentIndex, current: _.length === currentIndex,
complete: _.length <= currentIndex complete: _.length <= currentIndex,
} },
]); ]);
}, },
change: index => { change: (index) => {
dispatch("change", index); dispatch("change", index);
} },
}); });
</script> </script>

View file

@ -1,11 +1,50 @@
<script> <script>
/**
* Set to `true` for the complete variant
* @type {boolean} [complete=false]
*/
export let complete = false; export let complete = false;
/**
* Set to `true` to use the current variant
* @type {boolean} [current=false]
*/
export let current = false; export let current = false;
/**
* Set to `true` to disable the progress step
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
/**
* Specify the step description
* @type {string} [descripton=""]
*/
export let description = ""; export let description = "";
/**
* Specify the step label
* @type {string} [label=""]
*/
export let label = ""; export let label = "";
/**
* Specify the step secondary label
* @type {string} [secondaryLabel=""]
*/
export let secondaryLabel = ""; export let secondaryLabel = "";
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
import { getContext } from "svelte"; import { getContext } from "svelte";
@ -25,6 +64,7 @@
<li <li
aria-disabled={disabled} aria-disabled={disabled}
{id}
class:bx--progress-step={true} class:bx--progress-step={true}
class:bx--progress-step--current={current} class:bx--progress-step--current={current}
class:bx--progress-step--complete={complete} class:bx--progress-step--complete={complete}
@ -43,7 +83,7 @@
on:mouseenter on:mouseenter
on:mouseleave on:mouseleave
on:keydown on:keydown
on:keydown={e => { on:keydown={(e) => {
if (e.key === ' ' || e.key === 'Enter') { if (e.key === ' ' || e.key === 'Enter') {
change(step.index); change(step.index);
} }

View file

@ -1,13 +1,58 @@
<script> <script>
/**
* Specify the value of the radio button
* @type {string} [value=""]
*/
export let value = ""; export let value = "";
/**
* Set to `true` to check the radio button
* @type {boolean} [checked=false]
*/
export let checked = false; export let checked = false;
/**
* Set to `true` to disable the radio button
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
export let id = "ccs-" + Math.random().toString(36);
export let labelPosition = "right"; // "left" | "right" /**
* Specify the label position
* @type {"right" | "left"} [labelPosition="right"]
*/
export let labelPosition = "right";
/**
* Specify the label text
* @type {string} [labelText=""]
*/
export let labelText = ""; export let labelText = "";
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the checkbox input
* @type {string} [name=""]
*/
export let name = ""; export let name = "";
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null;
import { getContext } from "svelte"; import { getContext } from "svelte";
import { writable } from "svelte/store"; import { writable } from "svelte/store";
@ -28,6 +73,7 @@
class:bx--radio-button-wrapper--label-left={labelPosition === 'left'} class:bx--radio-button-wrapper--label-left={labelPosition === 'left'}
{...$$restProps}> {...$$restProps}>
<input <input
bind:this={ref}
type="radio" type="radio"
{id} {id}
{name} {name}

View file

@ -1,8 +1,27 @@
<script> <script>
/**
* Set the selected radio button value
* @type {string} [selected]
*/
export let selected = undefined; export let selected = undefined;
/**
* Set to `true` to disable the radio buttons
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
export let labelPosition = "right"; // "right" | "left"
export let orientation = "horizontal"; // "horizontal" | "vertical" /**
* Specify the label position
* @type {"right" | "left"} [labelPosition="right"]
*/
export let labelPosition = "right";
/**
* Specify the orientation of the radio buttons
* @type {"horizontal" | "vertical"} [orientation="horizontal"]
*/
export let orientation = "horizontal";
import { createEventDispatcher, setContext } from "svelte"; import { createEventDispatcher, setContext } from "svelte";
import { writable } from "svelte/store"; import { writable } from "svelte/store";
@ -17,9 +36,9 @@
selectedValue.set(value); selectedValue.set(value);
} }
}, },
update: value => { update: (value) => {
selectedValue.set(value); selectedValue.set(value);
} },
}); });
$: selected = $selectedValue; $: selected = $selectedValue;

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to use the small variant
* @type {boolean} [small=false]
*/
export let small = false; export let small = false;
</script> </script>

View file

@ -1,16 +1,80 @@
<script> <script>
export let autocomplete = "off"; /**
export let autofocus = false; * Set to `true` to use the small variant
export let closeButtonLabelText = "Clear search input"; * @type {boolean} [small=false]
export let id = "ccs-" + Math.random().toString(36); */
export let type = "text";
export let value = "";
export let labelText = "";
export let placeholder = "Search...";
export let skeleton = false;
export let light = false;
export let small = false; export let small = false;
/**
* Specify the size of the search input
* @type {"sm" | "lg"} [size]
*/
export let size = small ? "sm" : "xl"; export let size = small ? "sm" : "xl";
/**
* Set to `true` to display the skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false;
/**
* Specify the value of the search input
* @type {string} [value="text"]
*/
export let value = "";
/**
* Specify the `type` attribute of the search input
* @type {string} [type="text"]
*/
export let type = "text";
/**
* Specify the `placeholder` attribute of the search input
* @type {string} [placeholder="Search..."]
*/
export let placeholder = "Search...";
/**
* Specify the `autocomplete` attribute
* @type {"on" | "off"} [autocomplete="off"]
*/
export let autocomplete = "off";
/**
* Set to `true` to auto focus the search element
* @type {boolean} [autofocus=false]
*/
export let autofocus = false;
/**
* Specify the close button label text
* @type {string} [closeButtonLabelText="Clear search input"]
*/
export let closeButtonLabelText = "Clear search input";
/**
* Specify the label text
* @type {string} [labelText=""]
*/
export let labelText = "";
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import Close16 from "carbon-icons-svelte/lib/Close16"; import Close16 from "carbon-icons-svelte/lib/Close16";
@ -30,11 +94,12 @@
{:else} {:else}
<div <div
class:bx--search={true} class:bx--search={true}
class="bx--search--{size}"
class:bx--search--light={light} class:bx--search--light={light}
{...$$restProps}> {...$$restProps}
class="bx--search--{size}
{$$restProps.class}">
<Search16 class="bx--search-magnifier" /> <Search16 class="bx--search-magnifier" />
<label class:bx--label={true} for={id}>{labelText}</label> <label for={id} class:bx--label={true}>{labelText}</label>
<!-- svelte-ignore a11y-autofocus --> <!-- svelte-ignore a11y-autofocus -->
<input <input
bind:this={ref} bind:this={ref}

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
</script> </script>

View file

@ -1,17 +1,86 @@
<script> <script>
export let size = undefined; // "sm" | "xl" /**
* Specify the selected item value
* @type {string} [selected]
*/
export let selected = undefined; export let selected = undefined;
/**
* Set the size of the select input
* @type {"sm" | "xl"} [size]
*/
export let size = undefined;
/**
* Set to `true` to use the inline variant
* @type {boolean} [inline=false]
*/
export let inline = false; export let inline = false;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
/**
* Set to `true` to disable the select element
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Set an id for the select element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the select element
* @type {string} [name]
*/
export let name = undefined; export let name = undefined;
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
/**
* Specify the invalid state text
* @type {string} [invalidText=""]
*/
export let invalidText = ""; export let invalidText = "";
/**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = ""; export let helperText = "";
/**
* Set to `true` to not render a label
* @type {boolean} [noLabel=false]
*/
export let noLabel = false; export let noLabel = false;
/**
* Specify the label text
* @type {string} [labelText=""]
*/
export let labelText = ""; export let labelText = "";
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
/**
* Obtain a reference to the select HTML element
* @type {null | HTMLSelectElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { createEventDispatcher, setContext, afterUpdate } from "svelte"; import { createEventDispatcher, setContext, afterUpdate } from "svelte";

View file

@ -10,7 +10,7 @@
let selected = false; let selected = false;
const unsubscribe = ctx.selectedValue.subscribe($ => { const unsubscribe = ctx.selectedValue.subscribe(($) => {
selected = $ === value; selected = $ === value;
}); });

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set to `true` to disable the optgroup element
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Specify the label attribute of the optgroup element
* @type {string} [label="Provide label"]
*/
export let label = "Provide label"; export let label = "Provide label";
</script> </script>

View file

@ -1,10 +1,34 @@
<script> <script>
/**
* Specify the number of lines to render
* @type {number} [lines=3]
*/
export let lines = 3; export let lines = 3;
/**
* Set to `true` to use the heading size variant
* @type {boolean} [heading=false]
*/
export let heading = false; export let heading = false;
/**
* Set to `true` to use the paragraph size variant
* @type {boolean} [paragraph=false]
*/
export let paragraph = false; export let paragraph = false;
/**
* Specify the width of the text (% or px)
* @type {string} [width="100%"]
*/
export let width = "100%"; export let width = "100%";
const randoms = [0.973, 0.153, 0.567]; /**
* Array of random numbers
* @constant
* @type {number[]}
*/
const RANDOM = [0.973, 0.153, 0.567];
$: rows = []; $: rows = [];
$: widthNum = parseInt(width, 10); $: widthNum = parseInt(width, 10);
@ -13,7 +37,7 @@
for (let i = 0; i < lines; i++) { for (let i = 0; i < lines; i++) {
const min = widthPx ? widthNum - 75 : 0; const min = widthPx ? widthNum - 75 : 0;
const max = widthPx ? widthNum : 75; const max = widthPx ? widthNum : 75;
const rand = Math.floor(randoms[i % 3] * (max - min + 1)) + min + "px"; const rand = Math.floor(RANDOM[i % 3] * (max - min + 1)) + min + "px";
rows = [...rows, { width: widthPx ? rand : `calc(${width} - ${rand})` }]; rows = [...rows, { width: widthPx ? rand : `calc(${width} - ${rand})` }];
} }
} }

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
</script> </script>

View file

@ -1,20 +1,51 @@
<script> <script>
export let disabled = false; export let disabled = false;
export let hideTextInput = false; export let hideTextInput = false;
/**
* Set an id for the slider div element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
export let inputType = "number"; export let inputType = "number";
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
/**
* Specify the label text
* @type {string} [labelText=""]
*/
export let labelText = ""; export let labelText = "";
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
export let max = 100; export let max = 100;
export let maxLabel = ""; export let maxLabel = "";
export let min = 0; export let min = 0;
export let minLabel = ""; export let minLabel = "";
/**
* Set a name for the slider element
* @type {string} [name=""]
*/
export let name = ""; export let name = "";
export let required = false; export let required = false;
export let step = 1; export let step = 1;
export let stepMultiplier = 4; export let stepMultiplier = 4;
export let value = ""; export let value = "";
/**
* Obtain a reference to the HTML element
* @type {null | HTMLElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { createEventDispatcher, afterUpdate } from "svelte"; import { createEventDispatcher, afterUpdate } from "svelte";

View file

@ -1,6 +1,15 @@
<script> <script>
export let border = false; /**
* Specify the number of rows
* @type {number} [rows=5]
*/
export let rows = 5; export let rows = 5;
/**
* Set to `true` to use the bordered variant
* @type {boolean} [border=false]
*/
export let border = false;
</script> </script>
<section <section

View file

@ -1,6 +1,20 @@
<script> <script>
/**
* Specify the selected structured list row value
* @type {string} [selected]
*/
export let selected = undefined; export let selected = undefined;
/**
* Set to `true` to use the bordered variant
* @type {boolean} [border=false]
*/
export let border = false; export let border = false;
/**
* Set to `true` to use the selection variant
* @type {boolean} [selection=false]
*/
export let selection = false; export let selection = false;
import { createEventDispatcher, setContext } from "svelte"; import { createEventDispatcher, setContext } from "svelte";

View file

@ -1,5 +1,14 @@
<script> <script>
/**
* Set to `true` to use as a header
* @type {boolean} [head=false]
*/
export let head = false; export let head = false;
/**
* Set to `true` to prevent wrapping
* @type {boolean} [noWrap=false]
*/
export let noWrap = false; export let noWrap = false;
</script> </script>

View file

@ -1,9 +1,38 @@
<script> <script>
/**
* Set to `true` to check the input
* @type {boolean} [checked=false]
*/
export let checked = false; export let checked = false;
/**
* Specify the title of the input
* @type {string} [title="title"]
*/
export let title = "title"; export let title = "title";
/**
* Specify the value of the input
* @type {string} [value="value"]
*/
export let value = "value"; export let value = "value";
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name=""]
*/
export let name = ""; export let name = "";
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import { getContext } from "svelte"; import { getContext } from "svelte";

View file

@ -1,6 +1,20 @@
<script> <script>
/**
* Set to `true` to use as a header
* @type {boolean} [head=false]
*/
export let head = false; export let head = false;
/**
* Set to `true` to render a label slot
* @type {boolean} [label=false]
*/
export let label = false; export let label = false;
/**
* Specify the tabindex
* @type {string} [tabindex="0"]
*/
export let tabindex = "0"; export let tabindex = "0";
</script> </script>

View file

@ -4,6 +4,11 @@
export let label = ""; export let label = "";
export let role = "presentation"; export let role = "presentation";
export let tabindex = "0"; export let tabindex = "0";
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
export let ref = null; export let ref = null;
@ -22,6 +27,7 @@
<li <li
tabindex="-1" tabindex="-1"
{role} {role}
{id}
class:bx--tabs__nav-item={true} class:bx--tabs__nav-item={true}
class:bx--tabs__nav-item--disabled={disabled} class:bx--tabs__nav-item--disabled={disabled}
class:bx--tabs__nav-item--selected={selected} class:bx--tabs__nav-item--selected={selected}

View file

@ -1,5 +1,10 @@
<script> <script>
/**
* Set an id for the top-level element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
import { getContext } from "svelte"; import { getContext } from "svelte";
const { selectedContent, addContent } = getContext("Tabs"); const { selectedContent, addContent } = getContext("Tabs");
@ -12,6 +17,8 @@
<div <div
aria-hidden={!selected} aria-hidden={!selected}
hidden={!selected} hidden={!selected}
{id}
{...$$restProps}
class:bx--tab-content={true} class:bx--tab-content={true}
class={$$restProps.class} class={$$restProps.class}
style={$$restProps.style}> style={$$restProps.style}>

View file

@ -13,7 +13,7 @@
let dropdownHidden = true; let dropdownHidden = true;
let tabs = writable([]); let tabs = writable([]);
let tabsById = derived(tabs, _ => let tabsById = derived(tabs, (_) =>
_.reduce((a, c) => ({ ...a, [c.id]: c }), {}) _.reduce((a, c) => ({ ...a, [c.id]: c }), {})
); );
let currentIndex = selected; let currentIndex = selected;
@ -24,16 +24,16 @@
setContext("Tabs", { setContext("Tabs", {
selectedTab, selectedTab,
selectedContent, selectedContent,
add: data => { add: (data) => {
tabs.update(_ => [..._, { ...data, index: _.length }]); tabs.update((_) => [..._, { ...data, index: _.length }]);
}, },
addContent: data => { addContent: (data) => {
content.update(_ => [..._, { ...data, index: _.length }]); content.update((_) => [..._, { ...data, index: _.length }]);
}, },
update: id => { update: (id) => {
currentIndex = $tabsById[id].index; currentIndex = $tabsById[id].index;
}, },
change: direction => { change: (direction) => {
let index = currentIndex + direction; let index = currentIndex + direction;
if (index < 0) { if (index < 0) {
@ -57,7 +57,7 @@
} }
currentIndex = index; currentIndex = index;
} },
}); });
afterUpdate(() => { afterUpdate(() => {

View file

@ -1,13 +1,52 @@
<script> <script>
export let type = undefined; // "red" | "magenta" | "purple" | "blue" | "cyan" | "teal" | "green" | "gray" | "cool-gray" | "warm-gray" | "high-contrast" /**
* Specify the type of tag
* @type {"red" | "magenta" | "purple" | "blue" | "cyan" | "teal" | "green" | "gray" | "cool-gray" | "warm-gray" | "high-contrast"} [type]
*/
export let type = undefined;
/**
* Set to `true` to use filterable variant
* @type {boolean} [filter=false]
*/
export let filter = false; export let filter = false;
/**
* Set to `true` to disable a filterable tag
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Set to `true` to display the skeleton state
* @type {boolean} [skeleton=false]
*/
export let skeleton = false;
/**
* Set the title for the close button in a filterable tag
* @type {string} [title="Clear filter"]
*/
export let title = "Clear filter"; export let title = "Clear filter";
/**
* Set an id for the filterable tag
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
import Close16 from "carbon-icons-svelte/lib/Close16"; import Close16 from "carbon-icons-svelte/lib/Close16";
import TagSkeleton from "./Tag.Skeleton.svelte";
</script> </script>
{#if skeleton}
<TagSkeleton
{...$$restProps}
on:click
on:mouseover
on:mouseenter
on:mouseleave />
{:else}
{#if filter} {#if filter}
<div <div
aria-label={title} aria-label={title}
@ -47,3 +86,4 @@
<slot /> <slot />
</span> </span>
{/if} {/if}
{/if}

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
</script> </script>

View file

@ -1,17 +1,86 @@
<script> <script>
/**
* Specify the textarea value
* @type {string} [value=""]
*/
export let value = ""; export let value = "";
/**
* Specify the placeholder text
* @type {string} [placeholder=""]
*/
export let placeholder = ""; export let placeholder = "";
/**
* Specify the number of cols
* @type {number} [cols=50]
*/
export let cols = 50; export let cols = 50;
/**
* Specify the number of rows
* @type {number} [rows=4]
*/
export let rows = 4; export let rows = 4;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
/**
* Set to `true` to disable the input
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
/**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = ""; export let helperText = "";
export let id = "ccs-" + Math.random().toString(36);
export let name = undefined; /**
export let invalid = false; * Specify the label text
export let invalidText = ""; * @type {string} [labelText=""]
*/
export let labelText = ""; export let labelText = "";
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false;
/**
* Specify the text for the invalid state
* @type {string} [invalidText=""]
*/
export let invalidText = "";
/**
* Set an id for the textarea element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name]
*/
export let name = undefined;
/**
* Obtain a reference to the textarea HTML element
* @type {null | HTMLTextAreaElement} [ref=null]
*/
export let ref = null; export let ref = null;
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";

View file

@ -1,21 +1,110 @@
<script> <script>
export let size = undefined; // "sm" | "xl" /**
export let type = "password"; * Set the size of the input
* @type {"sm" | "xl"} [size]
*/
export let size = undefined;
/**
* Specify the input value
* @type {string} [value=""]
*/
export let value = ""; export let value = "";
export let hidePasswordLabel = "Hide password";
export let showPasswordLabel = "Show password"; /**
export let light = false; * Specify the input type
export let disabled = false; * @type {string} [type="password"]
*/
export let type = "password";
/**
* Specify the placeholder text
* @type {string} [placeholder=""]
*/
export let placeholder = ""; export let placeholder = "";
/**
* Specify the hide password label text
* @type {string} [hidePasswordLabel="Hide password"]
*/
export let hidePasswordLabel = "Hide password";
/**
* Specify the show password label text
* @type {string} [showPasswordLabel="Show password"]
*/
export let showPasswordLabel = "Show password";
/**
* Set the alignment of the tooltip relative to the icon
* @type {"start" | "center" | "end"} [tooltipAlignment="center"]
*/
export let tooltipAlignment = undefined;
/**
* Set the position of the tooltip relative to the icon
* @type {"top" | "right" | "bottom" | "left"} [tooltipPosition="bottom"]
*/
export let tooltipPosition = undefined;
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false;
/**
* Set to `true` to disable the input
* @type {boolean} [disabled=false]
*/
export let disabled = false;
/**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = ""; export let helperText = "";
export let id = "ccs-" + Math.random().toString(36);
export let name = undefined; /**
export let invalid = false; * Specify the label text
export let invalidText = ""; * @type {string} [labelText=""]
*/
export let labelText = ""; export let labelText = "";
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
export let tooltipAlignment = "center";
export let tooltipPosition = "bottom"; /**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false;
/**
* Specify the text for the invalid state
* @type {string} [invalidText=""]
*/
export let invalidText = "";
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name]
*/
export let name = undefined;
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* Set to `true` to hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
</script> </script>

View file

@ -1,17 +1,86 @@
<script> <script>
export let size = undefined; // "sm" | "xl" /**
export let type = ""; * Set the size of the input
* @type {"sm" | "xl"} [size]
*/
export let size = undefined;
/**
* Specify the input value
* @type {string} [value=""]
*/
export let value = ""; export let value = "";
/**
* Specify the input type
* @type {string} [type=""]
*/
export let type = "";
/**
* Specify the placeholder text
* @type {string} [placeholder=""]
*/
export let placeholder = ""; export let placeholder = "";
/**
* Set to `true` to enable the light variant
* @type {boolean} [light=false]
*/
export let light = false; export let light = false;
/**
* Set to `true` to disable the input
* @type {boolean} [disabled=false]
*/
export let disabled = false; export let disabled = false;
export let id = "ccs-" + Math.random().toString(36);
export let name = undefined; /**
* Specify the helper text
* @type {string} [helperText=""]
*/
export let helperText = ""; export let helperText = "";
/**
* Set an id for the input element
* @type {string} [id]
*/
export let id = "ccs-" + Math.random().toString(36);
/**
* Specify a name attribute for the input
* @type {string} [name]
*/
export let name = undefined;
/**
* Specify the label text
* @type {string} [labelText=""]
*/
export let labelText = ""; export let labelText = "";
/**
* Set to `true` to visually hide the label text
* @type {boolean} [hideLabel=false]
*/
export let hideLabel = false; export let hideLabel = false;
/**
* Set to `true` to indicate an invalid state
* @type {boolean} [invalid=false]
*/
export let invalid = false; export let invalid = false;
/**
* Specify the invalid state text
* @type {string} [invalidText=""]
*/
export let invalidText = ""; export let invalidText = "";
/**
* Obtain a reference to the input HTML element
* @type {null | HTMLInputElement} [ref=null]
*/
export let ref = null; export let ref = null;
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16"; import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";

Some files were not shown because too many files have changed in this diff Show more