@spectric/ui 0.0.10 → 0.0.11
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/components/pagination/pagination.d.ts +5 -5
- package/dist/components/table/cell.d.ts +1 -0
- package/dist/components/table/header.d.ts +2 -1
- package/dist/components/table/sorting.d.ts +5 -0
- package/dist/components/table/table.d.ts +41 -8
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/custom-elements.json +28 -8
- package/dist/index.es.js +1585 -1520
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +86 -84
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils/once.d.ts +1 -0
- package/dist/utils/spread.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/input.ts +0 -1
- package/src/components/pagination/pagination.ts +7 -7
- package/src/components/query_bar/QueryBar.ts +26 -21
- package/src/components/table/cell.ts +5 -6
- package/src/components/table/header.ts +22 -3
- package/src/components/table/sorting.ts +34 -0
- package/src/components/table/table.css +52 -0
- package/src/components/table/table.ts +109 -22
- package/src/components/tooltip/tooltip.ts +2 -2
- package/src/stories/fixtures/ExampleContent.ts +15 -8
- package/src/stories/fixtures/data.ts +21 -10
- package/src/stories/table.stories.ts +25 -5
- package/src/utils/once.ts +12 -0
- package/src/utils/spread.ts +3 -3
|
@@ -4,11 +4,11 @@ import { ButtonSizesTypes } from '../Button';
|
|
|
4
4
|
export declare const PaginationElementTag = "spectric-pagination";
|
|
5
5
|
export type { PaginationProps, PaginationChangeProps, PaginationEvents };
|
|
6
6
|
interface PaginationChangeProps {
|
|
7
|
-
page
|
|
8
|
-
pageSize
|
|
7
|
+
page?: number;
|
|
8
|
+
pageSize?: number;
|
|
9
9
|
}
|
|
10
10
|
interface PaginationProps extends PaginationChangeProps {
|
|
11
|
-
size
|
|
11
|
+
size?: ButtonSizesTypes;
|
|
12
12
|
totalItems?: number;
|
|
13
13
|
pageSizeOptions?: number[];
|
|
14
14
|
}
|
|
@@ -42,7 +42,7 @@ declare global {
|
|
|
42
42
|
namespace JSX {
|
|
43
43
|
interface IntrinsicElements {
|
|
44
44
|
/**
|
|
45
|
-
* @see {@link
|
|
45
|
+
* @see {@link PaginationElement}
|
|
46
46
|
*/
|
|
47
47
|
[PaginationElementTag]: ReactElementWithPropsAndEvents<PaginationElement, PaginationProps, PaginationEvents>;
|
|
48
48
|
}
|
|
@@ -51,7 +51,7 @@ declare global {
|
|
|
51
51
|
namespace JSX {
|
|
52
52
|
interface IntrinsicElements {
|
|
53
53
|
/**
|
|
54
|
-
* @see {@link
|
|
54
|
+
* @see {@link PaginationElement}
|
|
55
55
|
*/
|
|
56
56
|
[PaginationElementTag]: ReactElementWithPropsAndEvents<PaginationElement, PaginationProps, PaginationEvents>;
|
|
57
57
|
}
|
|
@@ -11,10 +11,11 @@ interface HeaderProps<T> {
|
|
|
11
11
|
export declare class TableHeaderElement<T> extends LitElement implements HeaderProps<T> {
|
|
12
12
|
columns: ColumnSettings<T>[];
|
|
13
13
|
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
14
|
+
_handleSortChange: (column: ColumnSettings<T>) => void;
|
|
14
15
|
protected render(): unknown;
|
|
15
16
|
}
|
|
16
17
|
interface TableHeaderEvents {
|
|
17
|
-
'
|
|
18
|
+
'sortChange': (event: CustomEvent<ColumnSettings<any>>) => void;
|
|
18
19
|
}
|
|
19
20
|
declare global {
|
|
20
21
|
interface HTMLElementTagNameMap {
|
|
@@ -5,22 +5,52 @@ import { FilterEvent } from './cell';
|
|
|
5
5
|
export declare const TableElementTag = "spectric-table";
|
|
6
6
|
export type { TableProps, TableEvents };
|
|
7
7
|
export type DomRenderable = HTMLElement | TemplateResult | string | number | null;
|
|
8
|
+
export declare enum TableSelectOptions {
|
|
9
|
+
multi = "multi",
|
|
10
|
+
single = "single",
|
|
11
|
+
none = "none"
|
|
12
|
+
}
|
|
13
|
+
export declare enum TableSortOption {
|
|
14
|
+
multi = "multi",
|
|
15
|
+
single = "single"
|
|
16
|
+
}
|
|
17
|
+
export type TableSortOptionTypes = `${TableSortOption}`;
|
|
18
|
+
export declare enum TableSortDirection {
|
|
19
|
+
ascending = "ascending",
|
|
20
|
+
decending = "decending",
|
|
21
|
+
none = "none"
|
|
22
|
+
}
|
|
23
|
+
export type TableSortDirectionTypes = `${TableSortDirection}`;
|
|
8
24
|
export type ColumnSettings<T> = {
|
|
9
25
|
width?: number;
|
|
10
26
|
whiteSpace?: "nowrap";
|
|
11
27
|
hidden?: boolean;
|
|
12
28
|
sortable?: boolean;
|
|
29
|
+
sortDirection?: TableSortDirectionTypes;
|
|
13
30
|
filterable?: boolean;
|
|
14
31
|
title?: DomRenderable;
|
|
32
|
+
/**
|
|
33
|
+
* Key to used for getting data from an object for a cell
|
|
34
|
+
*/
|
|
15
35
|
key?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Render function to render a table cell for displaying custom html
|
|
38
|
+
*/
|
|
16
39
|
render?: (row: T, table: TableElement<T>) => DomRenderable;
|
|
40
|
+
/**
|
|
41
|
+
* Custom comparator function for sorting
|
|
42
|
+
*/
|
|
43
|
+
compareFn?: ((a: T, b: T) => number) | undefined;
|
|
17
44
|
};
|
|
18
|
-
type
|
|
19
|
-
interface
|
|
45
|
+
export type TableSelectOptionsTypes = `${TableSelectOptions}`;
|
|
46
|
+
export interface TableDataOptions<T> {
|
|
20
47
|
pagination?: PaginationProps;
|
|
21
48
|
columns: ColumnSettings<T>[];
|
|
49
|
+
}
|
|
50
|
+
interface TableProps<T> extends TableDataOptions<T> {
|
|
22
51
|
data: T[];
|
|
23
|
-
select
|
|
52
|
+
select: TableSelectOptionsTypes;
|
|
53
|
+
sort?: TableSortOptionTypes;
|
|
24
54
|
}
|
|
25
55
|
type DomEvent<T> = Event & {
|
|
26
56
|
target: T;
|
|
@@ -32,13 +62,16 @@ type DomEvent<T> = Event & {
|
|
|
32
62
|
*/
|
|
33
63
|
export declare class TableElement<T> extends LitElement implements TableProps<T> {
|
|
34
64
|
data: T[];
|
|
35
|
-
pagination?: PaginationProps
|
|
65
|
+
pagination?: PaginationProps;
|
|
36
66
|
columns: ColumnSettings<T>[];
|
|
37
|
-
select
|
|
67
|
+
select: TableSelectOptionsTypes;
|
|
68
|
+
sort: TableSortOptionTypes;
|
|
69
|
+
static getDefaultDataSorterAndPaginatior<T>(data: T[]): (props: TableDataOptions<T>) => T[];
|
|
38
70
|
private _handlePaginationChange;
|
|
71
|
+
private _handleSortChange;
|
|
39
72
|
private _emitChange;
|
|
40
73
|
private __DO_NOT_USE_filter;
|
|
41
|
-
selected
|
|
74
|
+
private selected;
|
|
42
75
|
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
43
76
|
_handleSelectAllChange: (e: DomEvent<HTMLInputElement>) => void;
|
|
44
77
|
protected render(): unknown;
|
|
@@ -56,7 +89,7 @@ declare global {
|
|
|
56
89
|
namespace JSX {
|
|
57
90
|
interface IntrinsicElements {
|
|
58
91
|
/**
|
|
59
|
-
* @see {@link
|
|
92
|
+
* @see {@link TableElement}
|
|
60
93
|
*/
|
|
61
94
|
[TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
|
|
62
95
|
}
|
|
@@ -65,7 +98,7 @@ declare global {
|
|
|
65
98
|
namespace JSX {
|
|
66
99
|
interface IntrinsicElements {
|
|
67
100
|
/**
|
|
68
|
-
* @see {@link
|
|
101
|
+
* @see {@link TableElement}
|
|
69
102
|
*/
|
|
70
103
|
[TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
|
|
71
104
|
}
|
|
@@ -77,7 +77,7 @@ declare global {
|
|
|
77
77
|
namespace JSX {
|
|
78
78
|
interface IntrinsicElements {
|
|
79
79
|
/**
|
|
80
|
-
* @see {@link
|
|
80
|
+
* @see {@link TooltipElement}
|
|
81
81
|
*/
|
|
82
82
|
[TooltipElementTag]: ReactElementWithPropsAndEvents<TooltipElement, TooltipProps, TooltipEvents>;
|
|
83
83
|
}
|
|
@@ -86,7 +86,7 @@ declare global {
|
|
|
86
86
|
namespace JSX {
|
|
87
87
|
interface IntrinsicElements {
|
|
88
88
|
/**
|
|
89
|
-
* @see {@link
|
|
89
|
+
* @see {@link TooltipElement}
|
|
90
90
|
*/
|
|
91
91
|
[TooltipElementTag]: ReactElementWithPropsAndEvents<TooltipElement, TooltipProps, TooltipEvents>;
|
|
92
92
|
}
|
|
@@ -2015,16 +2015,36 @@
|
|
|
2015
2015
|
},
|
|
2016
2016
|
{
|
|
2017
2017
|
"name": "spectric-table-header",
|
|
2018
|
-
"description": "Pagination Element\n\nProperties:\n\n * `columns` {`ColumnSettings<T>[]`} - ",
|
|
2019
|
-
"attributes": [
|
|
2018
|
+
"description": "Pagination Element\n\nEvents:\n\n * `sortChange` {`CustomEvent<ColumnSettings<T>>`} - \n\nProperties:\n\n * `_handleSortChange` - \n\n * `columns` {`ColumnSettings<T>[]`} - ",
|
|
2019
|
+
"attributes": [
|
|
2020
|
+
{
|
|
2021
|
+
"name": "onsortChange",
|
|
2022
|
+
"description": "`sortChange` {`CustomEvent<ColumnSettings<T>>`} - "
|
|
2023
|
+
}
|
|
2024
|
+
]
|
|
2020
2025
|
},
|
|
2021
2026
|
{
|
|
2022
2027
|
"name": "spectric-table",
|
|
2023
|
-
"description": "React example\n<iframe width=\"100%\" height=\"400px\" src=\"https://stackblitz.com/edit/react-ts-2ue7azag?ctl=1&embed=1&file=App.tsx&hideExplorer=1&hideNavigation=1\"/>\n\nEvents:\n\n * `change` {`CustomEvent<
|
|
2028
|
+
"description": "React example\n<iframe width=\"100%\" height=\"400px\" src=\"https://stackblitz.com/edit/react-ts-2ue7azag?ctl=1&embed=1&file=App.tsx&hideExplorer=1&hideNavigation=1\"/>\n\nEvents:\n\n * `change` {`CustomEvent<TableDataOptions<T>>`} - \n\n * `filter` {`CustomEvent<FilterEvent<T>>`} - \n\n * `selected` {`CustomEvent<T[]>`} - \n\nAttributes:\n\n * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\nProperties:\n\n * `_handlePaginationChange` - \n\n * `_handleSortChange` - \n\n * `_emitChange` - \n\n * `__DO_NOT_USE_filter` - \n\n * `selected` {`T[]`} - \n\n * `_handleSelectAllChange` - \n\n * `data` {`T[]`} - \n\n * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\n * `pagination` {`PaginationProps | undefined`} - \n\n * `columns` {`ColumnSettings<T>[]`} - ",
|
|
2024
2029
|
"attributes": [
|
|
2025
2030
|
{
|
|
2026
2031
|
"name": "select",
|
|
2027
|
-
"description": "`select` {
|
|
2032
|
+
"description": "`select` {`\"none\" | \"multi\" | \"single\"`} - \n\nProperty: select\n\nDefault: none",
|
|
2033
|
+
"values": [
|
|
2034
|
+
{
|
|
2035
|
+
"name": "none"
|
|
2036
|
+
},
|
|
2037
|
+
{
|
|
2038
|
+
"name": "multi"
|
|
2039
|
+
},
|
|
2040
|
+
{
|
|
2041
|
+
"name": "single"
|
|
2042
|
+
}
|
|
2043
|
+
]
|
|
2044
|
+
},
|
|
2045
|
+
{
|
|
2046
|
+
"name": "sort",
|
|
2047
|
+
"description": "`sort` {`\"multi\" | \"single\"`} - \n\nProperty: sort\n\nDefault: single",
|
|
2028
2048
|
"values": [
|
|
2029
2049
|
{
|
|
2030
2050
|
"name": "multi"
|
|
@@ -2036,15 +2056,15 @@
|
|
|
2036
2056
|
},
|
|
2037
2057
|
{
|
|
2038
2058
|
"name": "onchange",
|
|
2039
|
-
"description": "`change` {`CustomEvent<
|
|
2059
|
+
"description": "`change` {`CustomEvent<TableDataOptions<T>>`} - "
|
|
2040
2060
|
},
|
|
2041
2061
|
{
|
|
2042
2062
|
"name": "onfilter",
|
|
2043
2063
|
"description": "`filter` {`CustomEvent<FilterEvent<T>>`} - "
|
|
2044
2064
|
},
|
|
2045
2065
|
{
|
|
2046
|
-
"name": "
|
|
2047
|
-
"description": "`
|
|
2066
|
+
"name": "onselected",
|
|
2067
|
+
"description": "`selected` {`CustomEvent<T[]>`} - "
|
|
2048
2068
|
}
|
|
2049
2069
|
]
|
|
2050
2070
|
},
|
|
@@ -2095,7 +2115,7 @@
|
|
|
2095
2115
|
},
|
|
2096
2116
|
{
|
|
2097
2117
|
"name": "spectric-storybook-example-content",
|
|
2098
|
-
"description": "Attributes:\n\n * `frameWidth` {`number`} - \n\nProperties:\n\n * `frameWidth` {`number`} - \n\n * `query` {`SpectricQuery`} - \n\n * `dialogOpen` {`boolean`} - \n\n * `tableData` {`TestData[]`} - \n\n * `
|
|
2118
|
+
"description": "Attributes:\n\n * `frameWidth` {`number`} - \n\nProperties:\n\n * `frameWidth` {`number`} - \n\n * `query` {`SpectricQuery`} - \n\n * `dataSorter` - \n\n * `dialogOpen` {`boolean`} - \n\n * `tableData` {`TestData[]`} - \n\n * `columns` {`ColumnSettings<TestData>[]`} - \n\n * `pagination` {`PaginationProps`} - \n\n * `_handleFilter` - \n\n * `_handlePaginationChange` - ",
|
|
2099
2119
|
"attributes": [
|
|
2100
2120
|
{
|
|
2101
2121
|
"name": "frameWidth",
|