mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
feat(loading): integrate Loading
, InlineLoading
with v11
This commit is contained in:
parent
52adc778ca
commit
28c59a97bb
5 changed files with 35 additions and 49 deletions
|
@ -1911,11 +1911,11 @@ None.
|
||||||
### Props
|
### Props
|
||||||
|
|
||||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||||
| :-------------- | :------- | :--------------- | :------- | ------------------------------------------------------------------------ | ---------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
| :-------------- | :------- | :--------------- | :------- | ------------------------------------------------------------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| status | No | <code>let</code> | No | <code>"active" | "inactive" | "finished" | "error"</code> | <code>"active"</code> | Set the loading status |
|
| status | No | <code>let</code> | No | <code>"active" | "inactive" | "finished" | "error"</code> | <code>"active"</code> | Set the loading status |
|
||||||
| description | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Set the loading description |
|
| description | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Set the loading description |
|
||||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a description for the loading icon.<br />Defaults to the `status` prop for the "error" and "finished" states |
|
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a description for the loading icon.<br />Defaults to the `status` value for the<br /> "error" and "finished" states. |
|
||||||
| successDelay | No | <code>let</code> | No | <code>number</code> | <code>1500</code> | Specify the timeout delay (ms) after `status` is set to "success" |
|
| successDelay | No | <code>let</code> | No | <code>number</code> | <code>1500</code> | Specify the timeout delay (ms) after `status` is set to "finished".<br />The `on:success` event will be dispatched after this delay. |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -1925,10 +1925,6 @@ None.
|
||||||
|
|
||||||
| Event name | Type | Detail |
|
| Event name | Type | Detail |
|
||||||
| :--------- | :--------- | :---------------- |
|
| :--------- | :--------- | :---------------- |
|
||||||
| click | forwarded | -- |
|
|
||||||
| mouseover | forwarded | -- |
|
|
||||||
| mouseenter | forwarded | -- |
|
|
||||||
| mouseleave | forwarded | -- |
|
|
||||||
| success | dispatched | <code>null</code> |
|
| success | dispatched | <code>null</code> |
|
||||||
|
|
||||||
## `InlineNotification`
|
## `InlineNotification`
|
||||||
|
|
|
@ -5543,7 +5543,7 @@
|
||||||
{
|
{
|
||||||
"name": "iconDescription",
|
"name": "iconDescription",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
"description": "Specify a description for the loading icon.\nDefaults to the `status` prop for the \"error\" and \"finished\" states",
|
"description": "Specify a description for the loading icon.\nDefaults to the `status` value for the\n \"error\" and \"finished\" states.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"isFunction": false,
|
"isFunction": false,
|
||||||
"isFunctionDeclaration": false,
|
"isFunctionDeclaration": false,
|
||||||
|
@ -5554,7 +5554,7 @@
|
||||||
{
|
{
|
||||||
"name": "successDelay",
|
"name": "successDelay",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
"description": "Specify the timeout delay (ms) after `status` is set to \"success\"",
|
"description": "Specify the timeout delay (ms) after `status` is set to \"finished\".\nThe `on:success` event will be dispatched after this delay.",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": "1500",
|
"value": "1500",
|
||||||
"isFunction": false,
|
"isFunction": false,
|
||||||
|
@ -5566,13 +5566,7 @@
|
||||||
],
|
],
|
||||||
"moduleExports": [],
|
"moduleExports": [],
|
||||||
"slots": [],
|
"slots": [],
|
||||||
"events": [
|
"events": [{ "type": "dispatched", "name": "success", "detail": "null" }],
|
||||||
{ "type": "forwarded", "name": "click", "element": "div" },
|
|
||||||
{ "type": "forwarded", "name": "mouseover", "element": "div" },
|
|
||||||
{ "type": "forwarded", "name": "mouseenter", "element": "div" },
|
|
||||||
{ "type": "forwarded", "name": "mouseleave", "element": "div" },
|
|
||||||
{ "type": "dispatched", "name": "success", "detail": "null" }
|
|
||||||
],
|
|
||||||
"typedefs": [],
|
"typedefs": [],
|
||||||
"rest_props": { "type": "Element", "name": "div" }
|
"rest_props": { "type": "Element", "name": "div" }
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the loading status
|
* Set the loading status
|
||||||
* @type {"active" | "inactive" | "finished" | "error"}
|
* @type {"active" | "inactive" | "finished" | "error"}
|
||||||
|
@ -13,21 +15,27 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a description for the loading icon.
|
* Specify a description for the loading icon.
|
||||||
* Defaults to the `status` prop for the "error" and "finished" states
|
* Defaults to the `status` value for the
|
||||||
|
* "error" and "finished" states.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
export let iconDescription = undefined;
|
export let iconDescription = undefined;
|
||||||
|
|
||||||
/** Specify the timeout delay (ms) after `status` is set to "success" */
|
/**
|
||||||
|
* Specify the timeout delay (ms) after `status` is set to "finished".
|
||||||
|
* The `on:success` event will be dispatched after this delay.
|
||||||
|
*/
|
||||||
export let successDelay = 1500;
|
export let successDelay = 1500;
|
||||||
|
|
||||||
import { createEventDispatcher, afterUpdate, onMount } from "svelte";
|
import { createEventDispatcher, onMount } from "svelte";
|
||||||
import CheckmarkFilled from "../icons/CheckmarkFilled.svelte";
|
import CheckmarkFilled from "../icons/CheckmarkFilled.svelte";
|
||||||
import ErrorFilled from "../icons/ErrorFilled.svelte";
|
import ErrorFilled from "../icons/ErrorFilled.svelte";
|
||||||
import Loading from "../Loading/Loading.svelte";
|
import Loading from "../Loading/Loading.svelte";
|
||||||
|
|
||||||
|
/** @type {import("svelte").EventDispatcher<{ success: null }>} */
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
/** @type {NodeJS.Timeout} */
|
||||||
let timeout = undefined;
|
let timeout = undefined;
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
@ -36,26 +44,16 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
afterUpdate(() => {
|
$: if (status === "finished") {
|
||||||
if (status === "finished") {
|
if (timeout) clearTimeout(timeout);
|
||||||
|
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
dispatch("success");
|
dispatch("success");
|
||||||
}, successDelay);
|
}, successDelay);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
<div class:bx--inline-loading="{true}" aria-live="assertive" {...$$restProps}>
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
||||||
<div
|
|
||||||
class:bx--inline-loading="{true}"
|
|
||||||
aria-live="assertive"
|
|
||||||
{...$$restProps}
|
|
||||||
on:click
|
|
||||||
on:mouseover
|
|
||||||
on:mouseenter
|
|
||||||
on:mouseleave
|
|
||||||
>
|
|
||||||
<div class:bx--inline-loading__animation="{true}">
|
<div class:bx--inline-loading__animation="{true}">
|
||||||
{#if status === "error"}
|
{#if status === "error"}
|
||||||
<ErrorFilled
|
<ErrorFilled
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
/** Set to `true` to use the small variant */
|
/** Set to `true` to use the small variant */
|
||||||
export let small = false;
|
export let small = false;
|
||||||
|
|
||||||
|
|
14
types/InlineLoading/InlineLoading.svelte.d.ts
vendored
14
types/InlineLoading/InlineLoading.svelte.d.ts
vendored
|
@ -18,13 +18,15 @@ export interface InlineLoadingProps extends RestProps {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a description for the loading icon.
|
* Specify a description for the loading icon.
|
||||||
* Defaults to the `status` prop for the "error" and "finished" states
|
* Defaults to the `status` value for the
|
||||||
|
* "error" and "finished" states.
|
||||||
* @default undefined
|
* @default undefined
|
||||||
*/
|
*/
|
||||||
iconDescription?: string;
|
iconDescription?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the timeout delay (ms) after `status` is set to "success"
|
* Specify the timeout delay (ms) after `status` is set to "finished".
|
||||||
|
* The `on:success` event will be dispatched after this delay.
|
||||||
* @default 1500
|
* @default 1500
|
||||||
*/
|
*/
|
||||||
successDelay?: number;
|
successDelay?: number;
|
||||||
|
@ -34,12 +36,6 @@ export interface InlineLoadingProps extends RestProps {
|
||||||
|
|
||||||
export default class InlineLoading extends SvelteComponentTyped<
|
export default class InlineLoading extends SvelteComponentTyped<
|
||||||
InlineLoadingProps,
|
InlineLoadingProps,
|
||||||
{
|
{ success: CustomEvent<null> },
|
||||||
click: WindowEventMap["click"];
|
|
||||||
mouseover: WindowEventMap["mouseover"];
|
|
||||||
mouseenter: WindowEventMap["mouseenter"];
|
|
||||||
mouseleave: WindowEventMap["mouseleave"];
|
|
||||||
success: CustomEvent<null>;
|
|
||||||
},
|
|
||||||
{}
|
{}
|
||||||
> {}
|
> {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue