fix(pagination): type dispatched update event

This commit is contained in:
Eric Liu 2020-12-05 16:56:33 -08:00
commit ed8977beea
6 changed files with 79 additions and 63 deletions

View file

@ -2444,9 +2444,9 @@ None.
### Events ### Events
| Event name | Type | Detail | | Event name | Type | Detail |
| :--------- | :--------- | :----- | | :--------- | :--------- | :----------------------------------------------- |
| update | dispatched | -- | | update | dispatched | <code>{ pageSize: number; page: number; }</code> |
## `PaginationNav` ## `PaginationNav`

View file

@ -6356,31 +6356,6 @@
"typedefs": [], "typedefs": [],
"rest_props": { "type": "Element", "name": "div" } "rest_props": { "type": "Element", "name": "div" }
}, },
{
"moduleName": "SelectSkeleton",
"filePath": "/src/Select/SelectSkeleton.svelte",
"props": [
{
"name": "hideLabel",
"kind": "let",
"description": "Set to `true` to hide the label text",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
}
],
"slots": [],
"events": [
{ "type": "forwarded", "name": "click", "element": "div" },
{ "type": "forwarded", "name": "mouseover", "element": "div" },
{ "type": "forwarded", "name": "mouseenter", "element": "div" },
{ "type": "forwarded", "name": "mouseleave", "element": "div" }
],
"typedefs": [],
"rest_props": { "type": "Element", "name": "div" }
},
{ {
"moduleName": "SelectItem", "moduleName": "SelectItem",
"filePath": "/src/Select/SelectItem.svelte", "filePath": "/src/Select/SelectItem.svelte",
@ -6431,36 +6406,6 @@
"typedefs": [], "typedefs": [],
"rest_props": { "type": "Element", "name": "option" } "rest_props": { "type": "Element", "name": "option" }
}, },
{
"moduleName": "SelectItemGroup",
"filePath": "/src/Select/SelectItemGroup.svelte",
"props": [
{
"name": "disabled",
"kind": "let",
"description": "Set to `true` to disable the optgroup element",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "label",
"kind": "let",
"description": "Specify the label attribute of the optgroup element",
"type": "string",
"value": "\"Provide label\"",
"isFunction": false,
"constant": false,
"reactive": false
}
],
"slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }],
"events": [],
"typedefs": [],
"rest_props": { "type": "Element", "name": "optgroup" }
},
{ {
"moduleName": "Pagination", "moduleName": "Pagination",
"filePath": "/src/Pagination/Pagination.svelte", "filePath": "/src/Pagination/Pagination.svelte",
@ -6627,7 +6572,13 @@
} }
], ],
"slots": [], "slots": [],
"events": [{ "type": "dispatched", "name": "update" }], "events": [
{
"type": "dispatched",
"name": "update",
"detail": "{ pageSize: number; page: number; }"
}
],
"typedefs": [], "typedefs": [],
"rest_props": { "type": "Element", "name": "div" } "rest_props": { "type": "Element", "name": "div" }
}, },
@ -6989,6 +6940,61 @@
"typedefs": [], "typedefs": [],
"rest_props": { "type": "Element", "name": "div" } "rest_props": { "type": "Element", "name": "div" }
}, },
{
"moduleName": "SelectSkeleton",
"filePath": "/src/Select/SelectSkeleton.svelte",
"props": [
{
"name": "hideLabel",
"kind": "let",
"description": "Set to `true` to hide the label text",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
}
],
"slots": [],
"events": [
{ "type": "forwarded", "name": "click", "element": "div" },
{ "type": "forwarded", "name": "mouseover", "element": "div" },
{ "type": "forwarded", "name": "mouseenter", "element": "div" },
{ "type": "forwarded", "name": "mouseleave", "element": "div" }
],
"typedefs": [],
"rest_props": { "type": "Element", "name": "div" }
},
{
"moduleName": "SelectItemGroup",
"filePath": "/src/Select/SelectItemGroup.svelte",
"props": [
{
"name": "disabled",
"kind": "let",
"description": "Set to `true` to disable the optgroup element",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "label",
"kind": "let",
"description": "Specify the label attribute of the optgroup element",
"type": "string",
"value": "\"Provide label\"",
"isFunction": false,
"constant": false,
"reactive": false
}
],
"slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }],
"events": [],
"typedefs": [],
"rest_props": { "type": "Element", "name": "optgroup" }
},
{ {
"moduleName": "SkeletonPlaceholder", "moduleName": "SkeletonPlaceholder",
"filePath": "/src/SkeletonPlaceholder/SkeletonPlaceholder.svelte", "filePath": "/src/SkeletonPlaceholder/SkeletonPlaceholder.svelte",

View file

@ -1,4 +1,8 @@
<script> <script>
/**
* @event {{ pageSize: number; page: number; }} update
*/
/** Specify the current page index */ /** Specify the current page index */
export let page = 1; export let page = 1;

View file

@ -2,7 +2,13 @@
import { Pagination, PaginationSkeleton } from "../types"; import { Pagination, PaginationSkeleton } from "../types";
</script> </script>
<Pagination totalItems="{102}" pageSizes="{[10, 15, 20]}" /> <Pagination
totalItems="{102}"
pageSizes="{[10, 15, 20]}"
on:update="{(e) => {
console.log(e.detail); // { pageSize: number; page: number; }
}}"
/>
<Pagination totalItems="{102}" page="{4}" /> <Pagination totalItems="{102}" page="{4}" />

View file

@ -102,6 +102,6 @@ export default class Pagination {
$$prop_def: PaginationProps; $$prop_def: PaginationProps;
$$slot_def: {}; $$slot_def: {};
$on(eventname: "update", cb: (event: CustomEvent<any>) => void): () => void; $on(eventname: "update", cb: (event: CustomEvent<{ pageSize: number; page: number }>) => void): () => void;
$on(eventname: string, cb: (event: Event) => void): () => void; $on(eventname: string, cb: (event: Event) => void): () => void;
} }

4
types/index.d.ts vendored
View file

@ -86,9 +86,7 @@ export { default as NumberInput } from "./NumberInput/NumberInput";
export { default as NumberInputSkeleton } from "./NumberInput/NumberInputSkeleton"; export { default as NumberInputSkeleton } from "./NumberInput/NumberInputSkeleton";
export { default as OrderedList } from "./OrderedList/OrderedList"; export { default as OrderedList } from "./OrderedList/OrderedList";
export { default as Select } from "./Select/Select"; export { default as Select } from "./Select/Select";
export { default as SelectSkeleton } from "./Select/SelectSkeleton";
export { default as SelectItem } from "./Select/SelectItem"; export { default as SelectItem } from "./Select/SelectItem";
export { default as SelectItemGroup } from "./Select/SelectItemGroup";
export { default as Pagination } from "./Pagination/Pagination"; export { default as Pagination } from "./Pagination/Pagination";
export { default as PaginationSkeleton } from "./Pagination/PaginationSkeleton"; export { default as PaginationSkeleton } from "./Pagination/PaginationSkeleton";
export { default as PaginationNav } from "./PaginationNav/PaginationNav"; export { default as PaginationNav } from "./PaginationNav/PaginationNav";
@ -96,6 +94,8 @@ export { default as ProgressIndicator } from "./ProgressIndicator/ProgressIndica
export { default as ProgressIndicatorSkeleton } from "./ProgressIndicator/ProgressIndicatorSkeleton"; export { default as ProgressIndicatorSkeleton } from "./ProgressIndicator/ProgressIndicatorSkeleton";
export { default as ProgressStep } from "./ProgressIndicator/ProgressStep"; export { default as ProgressStep } from "./ProgressIndicator/ProgressStep";
export { default as RadioButtonGroup } from "./RadioButtonGroup/RadioButtonGroup"; export { default as RadioButtonGroup } from "./RadioButtonGroup/RadioButtonGroup";
export { default as SelectSkeleton } from "./Select/SelectSkeleton";
export { default as SelectItemGroup } from "./Select/SelectItemGroup";
export { default as SkeletonPlaceholder } from "./SkeletonPlaceholder/SkeletonPlaceholder"; export { default as SkeletonPlaceholder } from "./SkeletonPlaceholder/SkeletonPlaceholder";
export { default as Slider } from "./Slider/Slider"; export { default as Slider } from "./Slider/Slider";
export { default as SliderSkeleton } from "./Slider/SliderSkeleton"; export { default as SliderSkeleton } from "./Slider/SliderSkeleton";