@spectric/ui 0.0.9 → 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.
@@ -19,13 +19,13 @@ export declare enum ButtonVariants {
19
19
  type ButtonVariantsTypes = `${ButtonVariants}`;
20
20
  export interface ButtonProps {
21
21
  /** Is this the principal call to action on the page? */
22
- variant: ButtonVariantsTypes;
22
+ variant?: ButtonVariantsTypes;
23
23
  /** What background color to use */
24
24
  backgroundColor?: string;
25
25
  /** How large should the button be? */
26
26
  size: ButtonSizesTypes;
27
27
  label?: string;
28
- disabled: boolean;
28
+ disabled?: boolean;
29
29
  danger?: boolean;
30
30
  icon?: boolean;
31
31
  tooltip?: DomRenderable;
@@ -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: number;
8
- pageSize: number;
7
+ page?: number;
8
+ pageSize?: number;
9
9
  }
10
10
  interface PaginationProps extends PaginationChangeProps {
11
- size: ButtonSizesTypes;
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 DialogElement}
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 DialogElement}
54
+ * @see {@link PaginationElement}
55
55
  */
56
56
  [PaginationElementTag]: ReactElementWithPropsAndEvents<PaginationElement, PaginationProps, PaginationEvents>;
57
57
  }
@@ -33,7 +33,7 @@ export interface IQueryProps {
33
33
  /**
34
34
  * The output of the query in a specific format
35
35
  */
36
- outputLanguage: SupportedLanguagesTypes;
36
+ outputLanguage?: SupportedLanguagesTypes;
37
37
  /**
38
38
  * The output of the query
39
39
  */
@@ -41,15 +41,15 @@ export interface IQueryProps {
41
41
  /**
42
42
  * Fields that are used for the auto complete
43
43
  */
44
- fields: FieldTypes[];
44
+ fields?: FieldTypes[];
45
45
  /**
46
46
  * Callback that will provide values for specific fields
47
47
  */
48
- getValuesForField: (field: string, text: string) => Promise<string[]>;
48
+ getValuesForField?: (field: string, text: string) => Promise<string[]>;
49
49
  /**
50
50
  * Input placeholder
51
51
  */
52
- placeholder: string;
52
+ placeholder?: string;
53
53
  }
54
54
  /**
55
55
  * The Query component will take Opensearch Dashboard Query language and transform it into various outputs
@@ -55,4 +55,5 @@ declare global {
55
55
  }
56
56
  }
57
57
  }
58
+ export declare const rowGetValue: (context: Record<string, any>, key: string) => any;
58
59
  export {};
@@ -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
- 'sort': (event: CustomEvent<ColumnSettings<any>>) => void;
18
+ 'sortChange': (event: CustomEvent<ColumnSettings<any>>) => void;
18
19
  }
19
20
  declare global {
20
21
  interface HTMLElementTagNameMap {
@@ -0,0 +1,5 @@
1
+ import { ColumnSettings } from './table';
2
+ /**
3
+ * Creates a chain of sort functions so you can perform multi column sorting.
4
+ */
5
+ export declare const createSortChain: <T>(sorts: ColumnSettings<T>[]) => ((a: T, b: T) => number | undefined)[];
@@ -5,66 +5,73 @@ 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 TableSelectOptions = "multi" | "single";
19
- interface TableProps<T> {
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?: TableSelectOptions;
52
+ select: TableSelectOptionsTypes;
53
+ sort?: TableSortOptionTypes;
24
54
  }
25
55
  type DomEvent<T> = Event & {
26
56
  target: T;
27
57
  };
28
58
  /**
29
- * Table Element
30
- *
31
- * The table element is a bit more complex and the column settings and data can only be set through the properties
32
- *
59
+ * React example
60
+ * <iframe width="100%" height="400px" src="https://stackblitz.com/edit/react-ts-2ue7azag?ctl=1&embed=1&file=App.tsx&hideExplorer=1&hideNavigation=1"/>
33
61
  *
34
- * React
35
- *
36
- * ``` tsx
37
- * <spectric-table data={[{col1:1}]} columns={[{key:"col1",}]} ></spectric-table>
38
- * ```
39
- *
40
- * Javascript
41
- *
42
- * ``` js
43
- * table = document.createElement("spectric-table")
44
- * table.data = [{col1:1}]
45
- * table.columns = [{key:"col1",}]
46
- * ```
47
- *
48
- * HTML
49
- *
50
- * ``` html
51
- * <spectric-table id="table"></spectric-table>
52
- * <script>
53
- * document.querySelector("#table")
54
- * table.data = [{col1:1}]
55
- * table.columns = [{key:"col1",}]
56
- * </script>
57
- * ```
58
62
  */
59
63
  export declare class TableElement<T> extends LitElement implements TableProps<T> {
60
64
  data: T[];
61
- pagination?: PaginationProps | undefined;
65
+ pagination?: PaginationProps;
62
66
  columns: ColumnSettings<T>[];
63
- select?: TableSelectOptions;
67
+ select: TableSelectOptionsTypes;
68
+ sort: TableSortOptionTypes;
69
+ static getDefaultDataSorterAndPaginatior<T>(data: T[]): (props: TableDataOptions<T>) => T[];
64
70
  private _handlePaginationChange;
71
+ private _handleSortChange;
65
72
  private _emitChange;
66
73
  private __DO_NOT_USE_filter;
67
- selected: T[];
74
+ private selected;
68
75
  protected createRenderRoot(): HTMLElement | DocumentFragment;
69
76
  _handleSelectAllChange: (e: DomEvent<HTMLInputElement>) => void;
70
77
  protected render(): unknown;
@@ -82,7 +89,7 @@ declare global {
82
89
  namespace JSX {
83
90
  interface IntrinsicElements {
84
91
  /**
85
- * @see {@link DialogElement}
92
+ * @see {@link TableElement}
86
93
  */
87
94
  [TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
88
95
  }
@@ -91,7 +98,7 @@ declare global {
91
98
  namespace JSX {
92
99
  interface IntrinsicElements {
93
100
  /**
94
- * @see {@link DialogElement}
101
+ * @see {@link TableElement}
95
102
  */
96
103
  [TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
97
104
  }
@@ -77,7 +77,7 @@ declare global {
77
77
  namespace JSX {
78
78
  interface IntrinsicElements {
79
79
  /**
80
- * @see {@link DialogElement}
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 DialogElement}
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": "Table Element\n\nThe table element is a bit more complex and the column settings and data can only be set through the properties\n\n\nReact\n\n``` tsx\n<spectric-table data={[{col1:1}]} columns={[{key:\"col1\",}]} ></spectric-table>\n```\n\nJavascript\n\n``` js\ntable = document.createElement(\"spectric-table\")\ntable.data = [{col1:1}]\ntable.columns = [{key:\"col1\",}]\n```\n\nHTML \n\n``` html\n<spectric-table id=\"table\"></spectric-table>\n<script>\ndocument.querySelector(\"#table\")\ntable.data = [{col1:1}]\ntable.columns = [{key:\"col1\",}]\n</script>\n```\n\nEvents:\n\n * `change` {`CustomEvent<{ pagination?: PaginationChangeProps | undefined; }>`} - \n\n * `filter` {`CustomEvent<FilterEvent<T>>`} - \n\n * `select` {`CustomEvent<T[]>`} - \n\nAttributes:\n\n * `select` {`TableSelectOptions | undefined`} - \n\nProperties:\n\n * `_handlePaginationChange` - \n\n * `_emitChange` - \n\n * `__DO_NOT_USE_filter` - \n\n * `selected` {`T[]`} - \n\n * `_handleSelectAllChange` - \n\n * `pagination` {`PaginationProps | undefined`} - \n\n * `columns` {`ColumnSettings<T>[]`} - \n\n * `data` {`T[]`} - \n\n * `select` {`TableSelectOptions | undefined`} - ",
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` {`TableSelectOptions | undefined`} - \n\nProperty: 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<{ pagination?: PaginationChangeProps | undefined; }>`} - "
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": "onselect",
2047
- "description": "`select` {`CustomEvent<T[]>`} - "
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 * `pagination` {`{ page: number; pageSize: number; size: string; totalItems: number; }`} - \n\n * `_handleFilter` - \n\n * `_handlePaginationChange` - ",
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",