@casinogate/ui 1.10.3 → 1.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/css/root.css +43 -0
- package/dist/components/data-table/components/data-table.sort-button.svelte +9 -2
- package/dist/components/data-table/data-table.svelte +19 -2
- package/dist/components/data-table/index.d.ts +1 -1
- package/dist/components/data-table/index.js +1 -1
- package/dist/components/data-table/styles.js +6 -2
- package/dist/components/data-table/types.d.ts +3 -1
- package/dist/components/data-table/utils/index.d.ts +1 -0
- package/dist/components/data-table/utils/index.js +1 -0
- package/dist/components/data-table/utils/use-sort-sate.svelte.d.ts +14 -0
- package/dist/components/data-table/utils/use-sort-sate.svelte.js +30 -0
- package/dist/components/icons/exports.d.ts +2 -0
- package/dist/components/icons/exports.js +2 -0
- package/dist/components/icons/sort-down.svelte +14 -0
- package/dist/components/icons/sort-down.svelte.d.ts +3 -0
- package/dist/components/icons/sort-up.svelte +14 -0
- package/dist/components/icons/sort-up.svelte.d.ts +3 -0
- package/dist/components/select/select.svelte +0 -2
- package/dist/internal/mocks/MOCK_DATA.json +100 -0
- package/dist/internal/mocks/types.d.ts +2 -0
- package/dist/internal/mocks/types.js +1 -0
- package/dist/internal/mocks/utils.d.ts +16 -0
- package/dist/internal/mocks/utils.js +37 -0
- package/package.json +1 -1
- package/dist/internal/mocks/data-table.d.ts +0 -9
- package/dist/internal/mocks/data-table.js +0 -146
package/dist/assets/css/root.css
CHANGED
|
@@ -256,12 +256,18 @@
|
|
|
256
256
|
.cgui\:ms-auto {
|
|
257
257
|
margin-inline-start: auto;
|
|
258
258
|
}
|
|
259
|
+
.cgui\:-mt-0\.5 {
|
|
260
|
+
margin-top: calc(var(--cgui-spacing) * -0.5);
|
|
261
|
+
}
|
|
259
262
|
.cgui\:mt-2 {
|
|
260
263
|
margin-top: calc(var(--cgui-spacing) * 2);
|
|
261
264
|
}
|
|
262
265
|
.cgui\:mt-4 {
|
|
263
266
|
margin-top: calc(var(--cgui-spacing) * 4);
|
|
264
267
|
}
|
|
268
|
+
.cgui\:-mb-0\.5 {
|
|
269
|
+
margin-bottom: calc(var(--cgui-spacing) * -0.5);
|
|
270
|
+
}
|
|
265
271
|
.cgui\:mb-1 {
|
|
266
272
|
margin-bottom: calc(var(--cgui-spacing) * 1);
|
|
267
273
|
}
|
|
@@ -1268,6 +1274,10 @@
|
|
|
1268
1274
|
--tw-duration: 150ms;
|
|
1269
1275
|
transition-duration: 150ms;
|
|
1270
1276
|
}
|
|
1277
|
+
.cgui\:duration-200 {
|
|
1278
|
+
--tw-duration: 200ms;
|
|
1279
|
+
transition-duration: 200ms;
|
|
1280
|
+
}
|
|
1271
1281
|
.cgui\:duration-250 {
|
|
1272
1282
|
--tw-duration: 250ms;
|
|
1273
1283
|
transition-duration: 250ms;
|
|
@@ -1888,6 +1898,20 @@
|
|
|
1888
1898
|
}
|
|
1889
1899
|
}
|
|
1890
1900
|
}
|
|
1901
|
+
.cgui\:data-\[direction\=asc\]\:\[\&_\[data-direction\=asc\]\]\:text-icon-regular {
|
|
1902
|
+
&[data-direction="asc"] {
|
|
1903
|
+
& [data-direction=asc] {
|
|
1904
|
+
color: var(--cg-ui-color-icon-regular);
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
.cgui\:data-\[direction\=desc\]\:\[\&_\[data-direction\=desc\]\]\:text-icon-regular {
|
|
1909
|
+
&[data-direction="desc"] {
|
|
1910
|
+
& [data-direction=desc] {
|
|
1911
|
+
color: var(--cg-ui-color-icon-regular);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1891
1915
|
.cgui\:group-data-\[compact\=false\]\/navigation\:data-\[state\=open\]\:\[\&_\[data-slot\=\"chevron\"\]\]\:rotate-180 {
|
|
1892
1916
|
&:is(:where(.cgui\:group\/navigation)[data-compact="false"] *) {
|
|
1893
1917
|
&[data-state="open"] {
|
|
@@ -2029,6 +2053,25 @@
|
|
|
2029
2053
|
color: var(--cg-ui-color-icon-regular);
|
|
2030
2054
|
}
|
|
2031
2055
|
}
|
|
2056
|
+
.cgui\:\[\&_svg\]\:transition-all {
|
|
2057
|
+
& svg {
|
|
2058
|
+
transition-property: all;
|
|
2059
|
+
transition-timing-function: var(--tw-ease, var(--cgui-default-transition-timing-function));
|
|
2060
|
+
transition-duration: var(--tw-duration, var(--cgui-default-transition-duration));
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
.cgui\:\[\&_svg\]\:duration-200 {
|
|
2064
|
+
& svg {
|
|
2065
|
+
--tw-duration: 200ms;
|
|
2066
|
+
transition-duration: 200ms;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
.cgui\:\[\&_svg\]\:ease-in-out {
|
|
2070
|
+
& svg {
|
|
2071
|
+
--tw-ease: var(--cgui-ease-in-out);
|
|
2072
|
+
transition-timing-function: var(--cgui-ease-in-out);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2032
2075
|
.cgui\:\[\&_svg\:not\(\[class\*\=\"size-\"\]\)\]\:size-3 {
|
|
2033
2076
|
& svg:not([class*="size-"]) {
|
|
2034
2077
|
width: calc(var(--cgui-spacing) * 3);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
ref = $bindable(null),
|
|
11
11
|
id = useId(),
|
|
12
12
|
class: className,
|
|
13
|
+
direction,
|
|
13
14
|
children,
|
|
14
15
|
child,
|
|
15
16
|
...restProps
|
|
@@ -25,8 +26,12 @@
|
|
|
25
26
|
|
|
26
27
|
const styles = DataTableStylesContext.get();
|
|
27
28
|
|
|
29
|
+
const attrs = $derived({
|
|
30
|
+
'data-direction': direction,
|
|
31
|
+
});
|
|
32
|
+
|
|
28
33
|
const mergedProps = $derived(
|
|
29
|
-
mergeProps(restProps, sortButtonState.props, { class: cn(styles.current.sortButton(), className) })
|
|
34
|
+
mergeProps(restProps, sortButtonState.props, attrs, { class: cn(styles.current.sortButton(), className) })
|
|
30
35
|
);
|
|
31
36
|
</script>
|
|
32
37
|
|
|
@@ -37,7 +42,9 @@
|
|
|
37
42
|
{#if children}
|
|
38
43
|
{@render children?.()}
|
|
39
44
|
{:else}
|
|
40
|
-
<Icon.
|
|
45
|
+
<Icon.SortUp class="cgui:-mb-0.5" data-direction="asc" />
|
|
46
|
+
|
|
47
|
+
<Icon.SortDown class="cgui:-mt-0.5" data-direction="desc" />
|
|
41
48
|
{/if}
|
|
42
49
|
</button>
|
|
43
50
|
{/if}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends RowData = any">
|
|
2
2
|
import { Spinner } from '../spinner/index.js';
|
|
3
|
+
import { atom, cn } from '../../internal/utils/common.js';
|
|
3
4
|
import { watch } from 'runed';
|
|
4
5
|
import { fade } from 'svelte/transition';
|
|
5
6
|
import DataTableBody from './components/data-table.body.svelte';
|
|
@@ -42,12 +43,28 @@
|
|
|
42
43
|
{#each table.getHeaderGroups() as headerGroup (headerGroup.id)}
|
|
43
44
|
<DataTableRow>
|
|
44
45
|
{#each headerGroup.headers as header (header.id)}
|
|
45
|
-
<DataTableHead
|
|
46
|
+
<DataTableHead
|
|
47
|
+
{header}
|
|
48
|
+
class={cn({
|
|
49
|
+
'cgui:cursor-pointer cgui:select-none': header.column.getCanSort(),
|
|
50
|
+
})}
|
|
51
|
+
onclick={() => {
|
|
52
|
+
if (header.column.getCanSort()) {
|
|
53
|
+
header.column.toggleSorting();
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
46
57
|
{#if !header.isPlaceholder}
|
|
47
58
|
<FlexRender content={header.column.columnDef.header} context={header.getContext()} />
|
|
48
59
|
|
|
49
60
|
{#if header.column.getCanSort()}
|
|
50
|
-
|
|
61
|
+
{@const dir = atom(() => {
|
|
62
|
+
const val = header.column.getIsSorted();
|
|
63
|
+
|
|
64
|
+
return typeof val === 'boolean' ? null : val;
|
|
65
|
+
})}
|
|
66
|
+
|
|
67
|
+
<DataTableSortButton direction={dir} />
|
|
51
68
|
{/if}
|
|
52
69
|
|
|
53
70
|
{#if restProps.resizable && header.column.getCanResize()}
|
|
@@ -3,4 +3,4 @@ export * from './exports.js';
|
|
|
3
3
|
export type { ColumnSizingState, ExpandedState, ExpandedStateList, GroupingState, PaginationState, RowSelectionState, SortingState, TableState, Updater, } from '@tanstack/table-core';
|
|
4
4
|
export { createTable } from './models/index.js';
|
|
5
5
|
export type { ColumnDef, DataTableBodyProps, DataTableCellProps, DataTableHeaderProps, DataTableHeadProps, DataTableProps, DataTableResizeHandlerProps, DataTableRootProps, DataTableRowProps, DataTableSortButtonProps, DataTableTableProps, RowData, } from './types.js';
|
|
6
|
-
export { rowModels, usePaginationState, useResizeState, useRowSelectionState } from './utils/index.js';
|
|
6
|
+
export { rowModels, usePaginationState, useResizeState, useRowSelectionState, useSortState } from './utils/index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * as DataTablePrimitive from './exports-primitive.js';
|
|
2
2
|
export * from './exports.js';
|
|
3
3
|
export { createTable } from './models/index.js';
|
|
4
|
-
export { rowModels, usePaginationState, useResizeState, useRowSelectionState } from './utils/index.js';
|
|
4
|
+
export { rowModels, usePaginationState, useResizeState, useRowSelectionState, useSortState } from './utils/index.js';
|
|
@@ -21,8 +21,12 @@ export const dataTableVariants = tv({
|
|
|
21
21
|
head: ['cgui:h-12 cgui:relative cgui:px-2', 'cgui:whitespace-nowrap cgui:bg-clip-padding cgui:align-middle'],
|
|
22
22
|
sortButton: [
|
|
23
23
|
'cgui:absolute cgui:top-1/2 cgui:-translate-y-1/2 cgui:right-4',
|
|
24
|
-
'cgui:flex cgui:shrink-0 cgui:size-
|
|
25
|
-
'cgui:
|
|
24
|
+
'cgui:flex cgui:flex-col cgui:shrink-0 cgui:size-6 cgui:justify-center cgui:items-center cgui:text-icon-default',
|
|
25
|
+
'cgui:transition-all cgui:duration-200 cgui:ease-in-out',
|
|
26
|
+
'cgui:cursor-pointer cgui:select-none',
|
|
27
|
+
'cgui:[&_svg]:size-4 cgui:[&_svg]:transition-all cgui:[&_svg]:duration-200 cgui:[&_svg]:ease-in-out',
|
|
28
|
+
'cgui:data-[direction=asc]:[&_[data-direction=asc]]:text-icon-regular',
|
|
29
|
+
'cgui:data-[direction=desc]:[&_[data-direction=desc]]:text-icon-regular',
|
|
26
30
|
],
|
|
27
31
|
cell: ['cgui:whitespace-nowrap cgui:bg-clip-padding cgui:p-2', 'cgui:font-normal cgui:align-middle'],
|
|
28
32
|
resizeHandler: [
|
|
@@ -26,7 +26,9 @@ type DataTableResizeHandlerPropsWithoutHTML = WithElementRef<{}>;
|
|
|
26
26
|
export type DataTableResizeHandlerProps = DataTableResizeHandlerPropsWithoutHTML & Without<PrimitiveDivAttributes, DataTableResizeHandlerPropsWithoutHTML>;
|
|
27
27
|
type DataTableRowPropsWithoutHTML = WithElementRef<WithChildren<{}>>;
|
|
28
28
|
export type DataTableRowProps = DataTableRowPropsWithoutHTML & Without<PrimitiveDivAttributes, DataTableRowPropsWithoutHTML>;
|
|
29
|
-
type DataTableSortButtonPropsWithoutHTML = WithElementRef<WithChild<{
|
|
29
|
+
type DataTableSortButtonPropsWithoutHTML = WithElementRef<WithChild<{
|
|
30
|
+
direction?: 'asc' | 'desc' | null | undefined;
|
|
31
|
+
}>>;
|
|
30
32
|
export type DataTableSortButtonProps = DataTableSortButtonPropsWithoutHTML & Without<PrimitiveButtonAttributes, DataTableSortButtonPropsWithoutHTML>;
|
|
31
33
|
type DataTableTablePropsWithoutHTML = WithElementRef<WithChildren<{}>>;
|
|
32
34
|
export type DataTableTableProps = DataTableTablePropsWithoutHTML & Without<PrimitiveTableAttributes, DataTableTablePropsWithoutHTML>;
|
|
@@ -2,3 +2,4 @@ export { usePaginationState } from './pagination-state.svelte.js';
|
|
|
2
2
|
export { useResizeState } from './resize-state.svelte.js';
|
|
3
3
|
export { rowModels } from './row-models.js';
|
|
4
4
|
export { useRowSelectionState } from './row-selection-state.svelte.js';
|
|
5
|
+
export { useSortState } from './use-sort-sate.svelte.js';
|
|
@@ -2,3 +2,4 @@ export { usePaginationState } from './pagination-state.svelte.js';
|
|
|
2
2
|
export { useResizeState } from './resize-state.svelte.js';
|
|
3
3
|
export { rowModels } from './row-models.js';
|
|
4
4
|
export { useRowSelectionState } from './row-selection-state.svelte.js';
|
|
5
|
+
export { useSortState } from './use-sort-sate.svelte.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OnChangeFn, SortingState } from '@tanstack/table-core';
|
|
2
|
+
type Opts = {
|
|
3
|
+
defaultValue?: () => SortingState;
|
|
4
|
+
onValueChange?: (value: SortingState) => void;
|
|
5
|
+
};
|
|
6
|
+
declare class SortState {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(opts?: Opts);
|
|
9
|
+
updater: OnChangeFn<SortingState>;
|
|
10
|
+
get current(): SortingState;
|
|
11
|
+
set current(value: SortingState);
|
|
12
|
+
}
|
|
13
|
+
export declare const useSortState: (opts?: Opts) => SortState;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { noop } from '../../../internal/utils/common.js';
|
|
2
|
+
class SortState {
|
|
3
|
+
#current;
|
|
4
|
+
#onValueChange;
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
this.#current = $state(opts?.defaultValue?.() ?? []);
|
|
7
|
+
this.#onValueChange = opts?.onValueChange ?? noop;
|
|
8
|
+
}
|
|
9
|
+
updater = (updater) => {
|
|
10
|
+
let newSort;
|
|
11
|
+
if (updater instanceof Function) {
|
|
12
|
+
newSort = updater(this.#current);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
newSort = updater;
|
|
16
|
+
}
|
|
17
|
+
this.current = newSort;
|
|
18
|
+
this.#onValueChange(newSort);
|
|
19
|
+
console.log(newSort);
|
|
20
|
+
};
|
|
21
|
+
get current() {
|
|
22
|
+
return this.#current;
|
|
23
|
+
}
|
|
24
|
+
set current(value) {
|
|
25
|
+
this.#current = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export const useSortState = (opts) => {
|
|
29
|
+
return new SortState(opts);
|
|
30
|
+
};
|
|
@@ -22,6 +22,8 @@ export { default as Minus } from './minus.svelte';
|
|
|
22
22
|
export { default as Plus } from './plus.svelte';
|
|
23
23
|
export { default as SidebarToggle } from './sidebar-toggle.svelte';
|
|
24
24
|
export { default as Slash } from './slash.svelte';
|
|
25
|
+
export { default as SortDown } from './sort-down.svelte';
|
|
26
|
+
export { default as SortUp } from './sort-up.svelte';
|
|
25
27
|
export { default as Sort } from './sort.svelte';
|
|
26
28
|
export { default as Spinner } from './spinner.svelte';
|
|
27
29
|
export { default as Success } from './success.svelte';
|
|
@@ -22,6 +22,8 @@ export { default as Minus } from './minus.svelte';
|
|
|
22
22
|
export { default as Plus } from './plus.svelte';
|
|
23
23
|
export { default as SidebarToggle } from './sidebar-toggle.svelte';
|
|
24
24
|
export { default as Slash } from './slash.svelte';
|
|
25
|
+
export { default as SortDown } from './sort-down.svelte';
|
|
26
|
+
export { default as SortUp } from './sort-up.svelte';
|
|
25
27
|
export { default as Sort } from './sort.svelte';
|
|
26
28
|
export { default as Spinner } from './spinner.svelte';
|
|
27
29
|
export { default as Success } from './success.svelte';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
let { width = 24, height = 24, color = 'currentColor', ...props }: IconProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" {width} {height} viewBox="0 0 24 24" {...props}>
|
|
8
|
+
<path
|
|
9
|
+
fill={color}
|
|
10
|
+
fill-rule="evenodd"
|
|
11
|
+
d="M18.425 10.271C19.499 8.967 18.57 7 16.88 7H7.12c-1.69 0-2.618 1.967-1.544 3.271l4.881 5.927a2 2 0 0 0 3.088 0z"
|
|
12
|
+
clip-rule="evenodd"
|
|
13
|
+
/></svg
|
|
14
|
+
>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
let { width = 24, height = 24, color = 'currentColor', ...props }: IconProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" {width} {height} viewBox="0 0 24 24" {...props}>
|
|
8
|
+
<path
|
|
9
|
+
fill={color}
|
|
10
|
+
fill-rule="evenodd"
|
|
11
|
+
d="M5.575 13.729C4.501 15.033 5.43 17 7.12 17h9.762c1.69 0 2.618-1.967 1.544-3.271l-4.881-5.927a2 2 0 0 0-3.088 0l-4.88 5.927Z"
|
|
12
|
+
clip-rule="evenodd"
|
|
13
|
+
/></svg
|
|
14
|
+
>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
[{"id":1,"first_name":"Buiron","last_name":"Moffett","email":"bmoffett0@accuweather.com","gender":"Male","city":"Pará de Minas"},
|
|
2
|
+
{"id":2,"first_name":"Gabriellia","last_name":"Erratt","email":"gerratt1@huffingtonpost.com","gender":"Female","city":"Staroyur’yevo"},
|
|
3
|
+
{"id":3,"first_name":"Arturo","last_name":"Wimpress","email":"awimpress2@ft.com","gender":"Male","city":"Haiphong"},
|
|
4
|
+
{"id":4,"first_name":"Dev","last_name":"Olivetti","email":"dolivetti3@cbsnews.com","gender":"Male","city":"Itambé"},
|
|
5
|
+
{"id":5,"first_name":"Nariko","last_name":"Baguley","email":"nbaguley4@w3.org","gender":"Female","city":"Rzhev"},
|
|
6
|
+
{"id":6,"first_name":"Samantha","last_name":"Pardi","email":"spardi5@dell.com","gender":"Female","city":"Pimentel"},
|
|
7
|
+
{"id":7,"first_name":"Eduino","last_name":"Hanby","email":"ehanby6@senate.gov","gender":"Male","city":"Doljo"},
|
|
8
|
+
{"id":8,"first_name":"Peter","last_name":"Comelini","email":"pcomelini7@etsy.com","gender":"Male","city":"Norakert"},
|
|
9
|
+
{"id":9,"first_name":"Pinchas","last_name":"Skene","email":"pskene8@oracle.com","gender":"Male","city":"Orekhovo-Zuyevo"},
|
|
10
|
+
{"id":10,"first_name":"Angeli","last_name":"Bounde","email":"abounde9@ning.com","gender":"Male","city":"Mirpur Khas"},
|
|
11
|
+
{"id":11,"first_name":"Ettie","last_name":"Ech","email":"eecha@jigsy.com","gender":"Female","city":"Wucheng"},
|
|
12
|
+
{"id":12,"first_name":"Trace","last_name":"Haglington","email":"thaglingtonb@51.la","gender":"Male","city":"Mtsensk"},
|
|
13
|
+
{"id":13,"first_name":"Lavena","last_name":"Gurnay","email":"lgurnayc@mlb.com","gender":"Female","city":"Zhanggongmiao"},
|
|
14
|
+
{"id":14,"first_name":"Maribeth","last_name":"Diggin","email":"mdiggind@tripod.com","gender":"Polygender","city":"Digdig"},
|
|
15
|
+
{"id":15,"first_name":"Nichole","last_name":"Ellcock","email":"nellcocke@elegantthemes.com","gender":"Female","city":"Tuanjie"},
|
|
16
|
+
{"id":16,"first_name":"Frasquito","last_name":"Martill","email":"fmartillf@japanpost.jp","gender":"Male","city":"Tân Việt"},
|
|
17
|
+
{"id":17,"first_name":"Sylvia","last_name":"Lansdale","email":"slansdaleg@loc.gov","gender":"Female","city":"Uren’"},
|
|
18
|
+
{"id":18,"first_name":"Toinette","last_name":"Burren","email":"tburrenh@redcross.org","gender":"Female","city":"Sungai Raya"},
|
|
19
|
+
{"id":19,"first_name":"Daria","last_name":"Eden","email":"dedeni@oaic.gov.au","gender":"Female","city":"Norrköping"},
|
|
20
|
+
{"id":20,"first_name":"Adore","last_name":"Cockshott","email":"acockshottj@wikimedia.org","gender":"Female","city":"Tonj"},
|
|
21
|
+
{"id":21,"first_name":"Jobyna","last_name":"Langmaid","email":"jlangmaidk@simplemachines.org","gender":"Female","city":"Al Qurayn"},
|
|
22
|
+
{"id":22,"first_name":"Aldis","last_name":"Davydkov","email":"adavydkovl@icq.com","gender":"Male","city":"Shuanglongchang"},
|
|
23
|
+
{"id":23,"first_name":"Ben","last_name":"Bethell","email":"bbethellm@cdc.gov","gender":"Male","city":"Gotse Delchev"},
|
|
24
|
+
{"id":24,"first_name":"Ulric","last_name":"Aspinwall","email":"uaspinwalln@hibu.com","gender":"Male","city":"Central"},
|
|
25
|
+
{"id":25,"first_name":"Gabbie","last_name":"Renny","email":"grennyo@163.com","gender":"Male","city":"Sarmanovo"},
|
|
26
|
+
{"id":26,"first_name":"Tybie","last_name":"Shippam","email":"tshippamp@va.gov","gender":"Female","city":"Tifni"},
|
|
27
|
+
{"id":27,"first_name":"Bartolemo","last_name":"Legen","email":"blegenq@techcrunch.com","gender":"Male","city":"Vanderhoof"},
|
|
28
|
+
{"id":28,"first_name":"Cecilia","last_name":"Tarbath","email":"ctarbathr@joomla.org","gender":"Female","city":"Biscoitos"},
|
|
29
|
+
{"id":29,"first_name":"Ambrosi","last_name":"Ferreiro","email":"aferreiros@adobe.com","gender":"Male","city":"Qorovulbozor Shahri"},
|
|
30
|
+
{"id":30,"first_name":"Jody","last_name":"Wickmann","email":"jwickmannt@va.gov","gender":"Genderfluid","city":"Palumbungan"},
|
|
31
|
+
{"id":31,"first_name":"Aeriell","last_name":"Aberdein","email":"aaberdeinu@lycos.com","gender":"Genderqueer","city":"Shishi"},
|
|
32
|
+
{"id":32,"first_name":"Normy","last_name":"Jakobsson","email":"njakobssonv@phoca.cz","gender":"Bigender","city":"Falun"},
|
|
33
|
+
{"id":33,"first_name":"Adan","last_name":"Crus","email":"acrusw@netlog.com","gender":"Female","city":"Pobé"},
|
|
34
|
+
{"id":34,"first_name":"Maddalena","last_name":"Lishman","email":"mlishmanx@salon.com","gender":"Female","city":"Sidaharja"},
|
|
35
|
+
{"id":35,"first_name":"Rozalin","last_name":"Devall","email":"rdevally@spotify.com","gender":"Female","city":"Stare Miasto"},
|
|
36
|
+
{"id":36,"first_name":"Yasmin","last_name":"Bossingham","email":"ybossinghamz@cdc.gov","gender":"Genderqueer","city":"Gadingrejo"},
|
|
37
|
+
{"id":37,"first_name":"Catina","last_name":"Salla","email":"csalla10@hud.gov","gender":"Female","city":"Bershet’"},
|
|
38
|
+
{"id":38,"first_name":"Ryon","last_name":"Breslau","email":"rbreslau11@wired.com","gender":"Male","city":"Keswick"},
|
|
39
|
+
{"id":39,"first_name":"Sal","last_name":"Malone","email":"smalone12@nature.com","gender":"Female","city":"Larangan"},
|
|
40
|
+
{"id":40,"first_name":"Torrence","last_name":"Garth","email":"tgarth13@dropbox.com","gender":"Male","city":"Lidingö"},
|
|
41
|
+
{"id":41,"first_name":"Dre","last_name":"Prewer","email":"dprewer14@patch.com","gender":"Female","city":"Huandiqiao"},
|
|
42
|
+
{"id":42,"first_name":"Shurwood","last_name":"Gyngyll","email":"sgyngyll15@google.co.jp","gender":"Male","city":"Kambove"},
|
|
43
|
+
{"id":43,"first_name":"Laural","last_name":"Ioselev","email":"lioselev16@ycombinator.com","gender":"Female","city":"Pitogo"},
|
|
44
|
+
{"id":44,"first_name":"Rozelle","last_name":"Moncrefe","email":"rmoncrefe17@wikimedia.org","gender":"Female","city":"Sanhe"},
|
|
45
|
+
{"id":45,"first_name":"Rudy","last_name":"Testo","email":"rtesto18@storify.com","gender":"Male","city":"Darungan Lor"},
|
|
46
|
+
{"id":46,"first_name":"Vincents","last_name":"Winkett","email":"vwinkett19@wunderground.com","gender":"Male","city":"Cimara"},
|
|
47
|
+
{"id":47,"first_name":"Berkly","last_name":"Crannis","email":"bcrannis1a@businessinsider.com","gender":"Male","city":"Era"},
|
|
48
|
+
{"id":48,"first_name":"Billie","last_name":"Kinver","email":"bkinver1b@github.com","gender":"Female","city":"Vĩnh Tường"},
|
|
49
|
+
{"id":49,"first_name":"Cully","last_name":"McVee","email":"cmcvee1c@jigsy.com","gender":"Male","city":"Purda"},
|
|
50
|
+
{"id":50,"first_name":"Rube","last_name":"McKerron","email":"rmckerron1d@artisteer.com","gender":"Male","city":"Lunenburg"},
|
|
51
|
+
{"id":51,"first_name":"Christoffer","last_name":"Blankman","email":"cblankman1e@dailymail.co.uk","gender":"Male","city":"Bijelo Polje"},
|
|
52
|
+
{"id":52,"first_name":"Josefa","last_name":"Claxson","email":"jclaxson1f@sogou.com","gender":"Female","city":"Esperanza"},
|
|
53
|
+
{"id":53,"first_name":"Pat","last_name":"Pinchon","email":"ppinchon1g@livejournal.com","gender":"Male","city":"Shilaoren"},
|
|
54
|
+
{"id":54,"first_name":"Kinsley","last_name":"Wolstenholme","email":"kwolstenholme1h@deliciousdays.com","gender":"Male","city":"La Cruz"},
|
|
55
|
+
{"id":55,"first_name":"Martha","last_name":"Fishbourne","email":"mfishbourne1i@engadget.com","gender":"Female","city":"Yepocapa"},
|
|
56
|
+
{"id":56,"first_name":"Binky","last_name":"Hollyer","email":"bhollyer1j@webs.com","gender":"Bigender","city":"Viking"},
|
|
57
|
+
{"id":57,"first_name":"Norean","last_name":"Jaycox","email":"njaycox1k@mapy.cz","gender":"Genderfluid","city":"Kepahiang"},
|
|
58
|
+
{"id":58,"first_name":"Francois","last_name":"Witchard","email":"fwitchard1l@seattletimes.com","gender":"Male","city":"Araçatuba"},
|
|
59
|
+
{"id":59,"first_name":"Gordy","last_name":"Adelsberg","email":"gadelsberg1m@creativecommons.org","gender":"Male","city":"Lukolela"},
|
|
60
|
+
{"id":60,"first_name":"Babara","last_name":"Landsbury","email":"blandsbury1n@is.gd","gender":"Female","city":"Esuk Oron"},
|
|
61
|
+
{"id":61,"first_name":"Ruby","last_name":"Posse","email":"rposse1o@unc.edu","gender":"Female","city":"Ramanavichy"},
|
|
62
|
+
{"id":62,"first_name":"Roobbie","last_name":"Brookes","email":"rbrookes1p@va.gov","gender":"Female","city":"Villanueva"},
|
|
63
|
+
{"id":63,"first_name":"Richardo","last_name":"McKeran","email":"rmckeran1q@sitemeter.com","gender":"Polygender","city":"Meilin"},
|
|
64
|
+
{"id":64,"first_name":"Jany","last_name":"Heasly","email":"jheasly1r@salon.com","gender":"Female","city":"Kuhmalahti"},
|
|
65
|
+
{"id":65,"first_name":"Clotilda","last_name":"Dyball","email":"cdyball1s@mapquest.com","gender":"Female","city":"Machachi"},
|
|
66
|
+
{"id":66,"first_name":"Eartha","last_name":"Benzie","email":"ebenzie1t@unicef.org","gender":"Female","city":"Belyayevka"},
|
|
67
|
+
{"id":67,"first_name":"Massimo","last_name":"Bodd","email":"mbodd1u@businessweek.com","gender":"Male","city":"Lere"},
|
|
68
|
+
{"id":68,"first_name":"Bendick","last_name":"Arthars","email":"barthars1v@chronoengine.com","gender":"Male","city":"Martil"},
|
|
69
|
+
{"id":69,"first_name":"Ingemar","last_name":"Willox","email":"iwillox1w@cbslocal.com","gender":"Male","city":"Saint-Bruno"},
|
|
70
|
+
{"id":70,"first_name":"Raddy","last_name":"Summerill","email":"rsummerill1x@nature.com","gender":"Male","city":"Laško"},
|
|
71
|
+
{"id":71,"first_name":"Suzy","last_name":"Freke","email":"sfreke1y@wordpress.com","gender":"Female","city":"Krynice"},
|
|
72
|
+
{"id":72,"first_name":"Obadias","last_name":"Finnes","email":"ofinnes1z@ox.ac.uk","gender":"Male","city":"Gedongmulyo"},
|
|
73
|
+
{"id":73,"first_name":"Fredra","last_name":"Linay","email":"flinay20@intel.com","gender":"Female","city":"Tādif"},
|
|
74
|
+
{"id":74,"first_name":"Rozelle","last_name":"Gostick","email":"rgostick21@last.fm","gender":"Female","city":"Xiaohenglong"},
|
|
75
|
+
{"id":75,"first_name":"Joleen","last_name":"Marrian","email":"jmarrian22@nbcnews.com","gender":"Female","city":"‘Afak"},
|
|
76
|
+
{"id":76,"first_name":"Townie","last_name":"Cattlemull","email":"tcattlemull23@lulu.com","gender":"Male","city":"Skaramangás"},
|
|
77
|
+
{"id":77,"first_name":"Sosanna","last_name":"Airy","email":"sairy24@fastcompany.com","gender":"Female","city":"Sevilla"},
|
|
78
|
+
{"id":78,"first_name":"Ulrich","last_name":"De Mattei","email":"udemattei25@tinyurl.com","gender":"Male","city":"Juarez"},
|
|
79
|
+
{"id":79,"first_name":"Tabb","last_name":"Pether","email":"tpether26@ovh.net","gender":"Male","city":"Ourovéni"},
|
|
80
|
+
{"id":80,"first_name":"Collie","last_name":"Roadnight","email":"croadnight27@icq.com","gender":"Female","city":"Lintingkou"},
|
|
81
|
+
{"id":81,"first_name":"Freddy","last_name":"Douthwaite","email":"fdouthwaite28@intel.com","gender":"Male","city":"Datong"},
|
|
82
|
+
{"id":82,"first_name":"Barry","last_name":"Peery","email":"bpeery29@sina.com.cn","gender":"Male","city":"Xiayunling"},
|
|
83
|
+
{"id":83,"first_name":"Chryste","last_name":"Biggs","email":"cbiggs2a@tumblr.com","gender":"Female","city":"Tanjung Palas"},
|
|
84
|
+
{"id":84,"first_name":"Maurene","last_name":"Tatham","email":"mtatham2b@altervista.org","gender":"Female","city":"Daba"},
|
|
85
|
+
{"id":85,"first_name":"Therese","last_name":"Ithell","email":"tithell2c@adobe.com","gender":"Non-binary","city":"Nikitinskiy"},
|
|
86
|
+
{"id":86,"first_name":"Marlowe","last_name":"Zettoi","email":"mzettoi2d@rakuten.co.jp","gender":"Male","city":"Itaí"},
|
|
87
|
+
{"id":87,"first_name":"Bethina","last_name":"Arndtsen","email":"barndtsen2e@uol.com.br","gender":"Polygender","city":"Laranjeiras"},
|
|
88
|
+
{"id":88,"first_name":"Davie","last_name":"Iglesia","email":"diglesia2f@facebook.com","gender":"Male","city":"Robīt"},
|
|
89
|
+
{"id":89,"first_name":"Tiffanie","last_name":"Welchman","email":"twelchman2g@yahoo.co.jp","gender":"Female","city":"Budapest"},
|
|
90
|
+
{"id":90,"first_name":"Remus","last_name":"Zimmermeister","email":"rzimmermeister2h@wikipedia.org","gender":"Male","city":"Karnobat"},
|
|
91
|
+
{"id":91,"first_name":"Lotti","last_name":"Arnall","email":"larnall2i@redcross.org","gender":"Female","city":"Sidu"},
|
|
92
|
+
{"id":92,"first_name":"Tildi","last_name":"Chorlton","email":"tchorlton2j@freewebs.com","gender":"Female","city":"Skála"},
|
|
93
|
+
{"id":93,"first_name":"Hogan","last_name":"Gwyllt","email":"hgwyllt2k@tripadvisor.com","gender":"Male","city":"Echarate"},
|
|
94
|
+
{"id":94,"first_name":"Nanci","last_name":"Ansteys","email":"nansteys2l@umn.edu","gender":"Female","city":"Hezhi"},
|
|
95
|
+
{"id":95,"first_name":"Katha","last_name":"Casson","email":"kcasson2m@dagondesign.com","gender":"Female","city":"Bailizhou"},
|
|
96
|
+
{"id":96,"first_name":"Orson","last_name":"Aberkirdo","email":"oaberkirdo2n@yahoo.com","gender":"Male","city":"Bačka Topola"},
|
|
97
|
+
{"id":97,"first_name":"Jenda","last_name":"Danilenko","email":"jdanilenko2o@php.net","gender":"Female","city":"Stamford"},
|
|
98
|
+
{"id":98,"first_name":"Eugene","last_name":"Waterfall","email":"ewaterfall2p@ted.com","gender":"Male","city":"Satuek"},
|
|
99
|
+
{"id":99,"first_name":"Ondrea","last_name":"Bernardez","email":"obernardez2q@google.com.au","gender":"Female","city":"Smołdzino"},
|
|
100
|
+
{"id":100,"first_name":"Shepperd","last_name":"Simao","email":"ssimao2r@github.com","gender":"Male","city":"Detusoko"}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import data from './MOCK_DATA.json' with { type: 'json' };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MockDataItem } from './types.js';
|
|
2
|
+
export interface FetchParams {
|
|
3
|
+
page?: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
sort_order?: 'asc' | 'desc';
|
|
6
|
+
sort_by?: keyof MockDataItem;
|
|
7
|
+
}
|
|
8
|
+
export interface FetchResponse {
|
|
9
|
+
data: MockDataItem[];
|
|
10
|
+
total: number;
|
|
11
|
+
page: number;
|
|
12
|
+
limit: number;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const promiseData: () => Promise<unknown>;
|
|
16
|
+
export declare const fetchMockData: ({ page, limit, sort_order, sort_by, }?: FetchParams) => Promise<FetchResponse>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import data from './MOCK_DATA.json' with { type: 'json' };
|
|
2
|
+
export const promiseData = () => {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
setTimeout(() => {
|
|
5
|
+
resolve(data);
|
|
6
|
+
}, 1000);
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export const fetchMockData = ({ page = 1, limit = 10, sort_order = 'asc', sort_by, } = {}) => {
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
let result = [...data];
|
|
13
|
+
if (sort_by) {
|
|
14
|
+
result.sort((a, b) => {
|
|
15
|
+
const valA = a[sort_by];
|
|
16
|
+
const valB = b[sort_by];
|
|
17
|
+
if (typeof valA === 'number' && typeof valB === 'number') {
|
|
18
|
+
return sort_order === 'asc' ? valA - valB : valB - valA;
|
|
19
|
+
}
|
|
20
|
+
const strA = String(valA).toLowerCase();
|
|
21
|
+
const strB = String(valB).toLowerCase();
|
|
22
|
+
const comparison = strA.localeCompare(strB);
|
|
23
|
+
return sort_order === 'asc' ? comparison : -comparison;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const start = (page - 1) * limit;
|
|
27
|
+
const paginated = result.slice(start, start + limit);
|
|
28
|
+
resolve({
|
|
29
|
+
data: paginated,
|
|
30
|
+
total: data.length,
|
|
31
|
+
page,
|
|
32
|
+
limit,
|
|
33
|
+
totalPages: Math.ceil(data.length / limit),
|
|
34
|
+
});
|
|
35
|
+
}, 2000);
|
|
36
|
+
});
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
export const MOCK_DATA_TABLE = [
|
|
2
|
-
{
|
|
3
|
-
id: 1,
|
|
4
|
-
first_name: 'Malissia',
|
|
5
|
-
last_name: 'Addy',
|
|
6
|
-
email: 'maddy0@de.vu',
|
|
7
|
-
gender: 'Female',
|
|
8
|
-
ip_address: '43.68.51.116',
|
|
9
|
-
Bank: 'DE',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
id: 2,
|
|
13
|
-
first_name: 'Damita',
|
|
14
|
-
last_name: 'Straughan',
|
|
15
|
-
email: 'dstraughan1@usnews.com',
|
|
16
|
-
gender: 'Female',
|
|
17
|
-
ip_address: '238.67.96.239',
|
|
18
|
-
Bank: 'US',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: 3,
|
|
22
|
-
first_name: 'Paulette',
|
|
23
|
-
last_name: 'Rabbe',
|
|
24
|
-
email: 'prabbe2@nbcnews.com',
|
|
25
|
-
gender: 'Female',
|
|
26
|
-
ip_address: '128.249.122.73',
|
|
27
|
-
Bank: 'FR',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
id: 4,
|
|
31
|
-
first_name: 'Nariko',
|
|
32
|
-
last_name: 'Waddam',
|
|
33
|
-
email: 'nwaddam3@geocities.jp',
|
|
34
|
-
gender: 'Female',
|
|
35
|
-
ip_address: '124.56.149.7',
|
|
36
|
-
Bank: 'US',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 5,
|
|
40
|
-
first_name: 'Dianna',
|
|
41
|
-
last_name: 'Moorcraft',
|
|
42
|
-
email: 'dmoorcraft4@slate.com',
|
|
43
|
-
gender: 'Bigender',
|
|
44
|
-
ip_address: '148.209.188.127',
|
|
45
|
-
Bank: 'US',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: 6,
|
|
49
|
-
first_name: 'Dall',
|
|
50
|
-
last_name: 'Pither',
|
|
51
|
-
email: 'dpither5@ezinearticles.com',
|
|
52
|
-
gender: 'Male',
|
|
53
|
-
ip_address: '36.167.238.151',
|
|
54
|
-
Bank: 'US',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 7,
|
|
58
|
-
first_name: 'Shurlock',
|
|
59
|
-
last_name: 'Prall',
|
|
60
|
-
email: 'sprall6@google.es',
|
|
61
|
-
gender: 'Male',
|
|
62
|
-
ip_address: '20.242.10.212',
|
|
63
|
-
Bank: 'PL',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
id: 8,
|
|
67
|
-
first_name: 'Trenna',
|
|
68
|
-
last_name: 'Hartopp',
|
|
69
|
-
email: 'thartopp7@admin.ch',
|
|
70
|
-
gender: 'Female',
|
|
71
|
-
ip_address: '182.114.18.31',
|
|
72
|
-
Bank: 'AT',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
id: 9,
|
|
76
|
-
first_name: 'Diena',
|
|
77
|
-
last_name: 'Franckton',
|
|
78
|
-
email: 'dfranckton8@alexa.com',
|
|
79
|
-
gender: 'Female',
|
|
80
|
-
ip_address: '104.28.228.192',
|
|
81
|
-
Bank: 'DE',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: 10,
|
|
85
|
-
first_name: 'Alfonso',
|
|
86
|
-
last_name: 'Amps',
|
|
87
|
-
email: 'aamps9@a8.net',
|
|
88
|
-
gender: 'Male',
|
|
89
|
-
ip_address: '30.142.173.108',
|
|
90
|
-
Bank: 'IE',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 11,
|
|
94
|
-
first_name: 'Kaiser',
|
|
95
|
-
last_name: 'Chadwell',
|
|
96
|
-
email: 'kchadwella@state.gov',
|
|
97
|
-
gender: 'Male',
|
|
98
|
-
ip_address: '142.228.205.126',
|
|
99
|
-
Bank: 'US',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: 12,
|
|
103
|
-
first_name: 'Farrand',
|
|
104
|
-
last_name: 'Micklem',
|
|
105
|
-
email: 'fmicklemb@nyu.edu',
|
|
106
|
-
gender: 'Female',
|
|
107
|
-
ip_address: '200.225.126.182',
|
|
108
|
-
Bank: 'US',
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
id: 13,
|
|
112
|
-
first_name: 'Bebe',
|
|
113
|
-
last_name: 'Sleightholm',
|
|
114
|
-
email: 'bsleightholmc@linkedin.com',
|
|
115
|
-
gender: 'Female',
|
|
116
|
-
ip_address: '135.114.24.235',
|
|
117
|
-
Bank: 'US',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
id: 14,
|
|
121
|
-
first_name: 'Zelma',
|
|
122
|
-
last_name: 'Shapcott',
|
|
123
|
-
email: 'zshapcottd@theguardian.com',
|
|
124
|
-
gender: 'Female',
|
|
125
|
-
ip_address: '150.185.115.144',
|
|
126
|
-
Bank: 'US',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: 15,
|
|
130
|
-
first_name: 'Glenna',
|
|
131
|
-
last_name: 'Harpur',
|
|
132
|
-
email: 'gharpure@jigsy.com',
|
|
133
|
-
gender: 'Female',
|
|
134
|
-
ip_address: '118.161.247.224',
|
|
135
|
-
Bank: 'US',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: 16,
|
|
139
|
-
first_name: 'Brigida',
|
|
140
|
-
last_name: 'Bemrose',
|
|
141
|
-
email: 'bbemrosef@ow.ly',
|
|
142
|
-
gender: 'Female',
|
|
143
|
-
ip_address: '136.222.10.10',
|
|
144
|
-
Bank: 'US',
|
|
145
|
-
},
|
|
146
|
-
];
|