@spectric/ui 0.0.10 → 0.0.12

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.
Files changed (51) hide show
  1. package/dist/classes/DisposibleElement.d.ts +4 -2
  2. package/dist/components/Bitdisplay.d.ts +4 -4
  3. package/dist/components/Button.d.ts +1 -1
  4. package/dist/components/Header.d.ts +1 -1
  5. package/dist/components/input.d.ts +13 -12
  6. package/dist/components/pagination/pagination.d.ts +5 -5
  7. package/dist/components/splitview/splitview.d.ts +5 -5
  8. package/dist/components/table/body.d.ts +2 -1
  9. package/dist/components/table/cell.d.ts +2 -0
  10. package/dist/components/table/header.d.ts +2 -1
  11. package/dist/components/table/sorting.d.ts +5 -0
  12. package/dist/components/table/table.d.ts +51 -14
  13. package/dist/components/table/virtualBody.d.ts +49 -0
  14. package/dist/components/tooltip/tooltip.d.ts +17 -12
  15. package/dist/custom-elements.json +50 -16
  16. package/dist/index.es.js +2099 -1867
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.umd.js +128 -93
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/style.css +1 -1
  21. package/dist/utils/once.d.ts +1 -0
  22. package/dist/utils/spread.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/src/classes/DisposibleElement.ts +15 -9
  25. package/src/components/Bitdisplay.ts +7 -7
  26. package/src/components/Button.ts +1 -1
  27. package/src/components/Header.ts +1 -1
  28. package/src/components/input.ts +18 -15
  29. package/src/components/pagination/pagination.ts +7 -7
  30. package/src/components/query_bar/QueryBar.ts +26 -21
  31. package/src/components/splitview/splitview.ts +5 -5
  32. package/src/components/table/body.ts +13 -5
  33. package/src/components/table/cell.ts +9 -7
  34. package/src/components/table/header.ts +28 -4
  35. package/src/components/table/sorting.ts +34 -0
  36. package/src/components/table/table.css +60 -4
  37. package/src/components/table/table.ts +149 -33
  38. package/src/components/table/virtualBody.css +13 -0
  39. package/src/components/table/virtualBody.ts +127 -0
  40. package/src/components/tooltip/tooltip.ts +38 -32
  41. package/src/docs/HTML-Vue-Python Integration.mdx +3 -3
  42. package/src/docs/html-include.png +0 -0
  43. package/src/docs/vue-example.png +0 -0
  44. package/src/docs/vue-include.png +0 -0
  45. package/src/stories/BitDisplay.stories.ts +2 -0
  46. package/src/stories/fixtures/ExampleContent.ts +15 -8
  47. package/src/stories/fixtures/data.ts +21 -10
  48. package/src/stories/pagination.stories.ts +2 -1
  49. package/src/stories/table.stories.ts +27 -5
  50. package/src/utils/once.ts +12 -0
  51. package/src/utils/spread.ts +3 -3
@@ -2,6 +2,7 @@ import { LitElement } from 'lit-element/lit-element.js';
2
2
  export interface IDisposable {
3
3
  dispose(): void;
4
4
  }
5
+ type DisposableTarget = HTMLElement | Promise<HTMLElement> | (() => HTMLElement);
5
6
  export declare class DisposableElement extends LitElement {
6
7
  private readonly _disposables;
7
8
  private _isDisposed;
@@ -13,9 +14,10 @@ export declare class DisposableElement extends LitElement {
13
14
  * @param event The event name
14
15
  * @param handler The event handler
15
16
  */
16
- addDisposableListener<K extends keyof GlobalEventHandlersEventMap>(target: HTMLElement | Promise<HTMLElement>, event: K, handler: (event: GlobalEventHandlersEventMap[K]) => void): void;
17
- addDisposableListener<K extends keyof SpectricGlobalEvents>(target: HTMLElement | Promise<HTMLElement>, event: K, handler: SpectricGlobalEvents[K]): void;
17
+ addDisposableListener<K extends keyof GlobalEventHandlersEventMap>(target: DisposableTarget, event: K, handler: (event: GlobalEventHandlersEventMap[K]) => void): void;
18
+ addDisposableListener<K extends keyof SpectricGlobalEvents>(target: DisposableTarget, event: K, handler: SpectricGlobalEvents[K]): void;
18
19
  registerDisposable<T extends IDisposable>(o: T): T;
19
20
  connectedCallback(): void;
20
21
  disconnectedCallback(): void;
21
22
  }
23
+ export {};
@@ -5,13 +5,13 @@ export interface BitDisplayProps {
5
5
  /** Array buffer to display */
6
6
  arrayBuffer: ArrayBuffer;
7
7
  /** Bits per line */
8
- frameWidth: number;
8
+ frameWidth?: number;
9
9
  /** How many pixels per bit */
10
- scale: number;
10
+ scale?: number;
11
11
  /** Width of the display canvas */
12
- width: number;
12
+ width?: number;
13
13
  /** Height of the display canvas */
14
- height: number;
14
+ height?: number;
15
15
  }
16
16
  type Position = {
17
17
  x: number;
@@ -23,7 +23,7 @@ export interface ButtonProps {
23
23
  /** What background color to use */
24
24
  backgroundColor?: string;
25
25
  /** How large should the button be? */
26
- size: ButtonSizesTypes;
26
+ size?: ButtonSizesTypes;
27
27
  label?: string;
28
28
  disabled?: boolean;
29
29
  danger?: boolean;
@@ -4,7 +4,7 @@ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from './type
4
4
  * Properties defining
5
5
  */
6
6
  export interface HeaderProps {
7
- username: string;
7
+ username?: string;
8
8
  /**
9
9
  * Shows the login Button
10
10
  */
@@ -1,4 +1,4 @@
1
- import { LitElement, TemplateResult } from 'lit';
1
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
2
  import { ReactElementWithPropsAndEvents } from './types';
3
3
  import { ButtonSizesTypes } from './Button';
4
4
  export declare enum InputVariants {
@@ -17,29 +17,29 @@ export declare enum InputVariants {
17
17
  type InputVariantsTypes = `${InputVariants}`;
18
18
  export interface InputProps {
19
19
  /** Input type */
20
- variant: InputVariantsTypes;
20
+ variant?: InputVariantsTypes;
21
21
  /**Label to display above the input */
22
- label: string;
22
+ label?: string;
23
23
  /**placeholder text to display*/
24
- placeholder: string;
25
- disabled: boolean;
26
- readonly: boolean;
24
+ placeholder?: string;
25
+ disabled?: boolean;
26
+ readonly?: boolean;
27
27
  /**
28
28
  * The helper text.
29
29
  */
30
- helperText: string;
30
+ helperText?: string;
31
31
  /**
32
32
  * Specify if the currently value is invalid.
33
33
  */
34
- invalid: boolean;
34
+ invalid?: boolean;
35
35
  /**
36
36
  * Message which is displayed if the value is invalid.
37
37
  */
38
- invalidText: string | TemplateResult<1>;
38
+ invalidText?: string | TemplateResult<1>;
39
39
  /**
40
40
  * Max character count allowed for input. This is needed in order for enableCounter to display
41
41
  */
42
- maxCount: number;
42
+ maxCount?: number;
43
43
  /**
44
44
  * Boolean property to set the required status
45
45
  */
@@ -59,7 +59,7 @@ export interface InputProps {
59
59
  /**
60
60
  * The sets the autocomplete for the input.
61
61
  */
62
- autocomplete: HTMLInputElement['autocomplete'];
62
+ autocomplete?: HTMLInputElement['autocomplete'];
63
63
  }
64
64
  export declare class SpectricInput extends LitElement implements InputProps {
65
65
  checked?: boolean;
@@ -106,7 +106,7 @@ export declare class SpectricInput extends LitElement implements InputProps {
106
106
  * Pattern to validate the input against for HTML validity checking
107
107
  */
108
108
  pattern: string;
109
- maxCount: InputProps['maxCount'];
109
+ maxCount: number;
110
110
  /**
111
111
  * The internal value.
112
112
  */
@@ -134,6 +134,7 @@ export declare class SpectricInput extends LitElement implements InputProps {
134
134
  */
135
135
  protected _input?: HTMLInputElement;
136
136
  private handleTogglePasswordVisibility;
137
+ protected updated(changedProperties: PropertyValues): void;
137
138
  protected render(): unknown;
138
139
  }
139
140
  declare global {
@@ -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
  }
@@ -7,15 +7,15 @@ export declare enum Orientations {
7
7
  }
8
8
  export interface SplitViewProps {
9
9
  /** Controls the orientation of the splitter handle */
10
- orientation: `${Orientations}`;
10
+ orientation?: `${Orientations}`;
11
11
  /** the percentage to split the view default: 50*/
12
12
  percentage?: number;
13
13
  /** Should the splitter handle be invisible? */
14
14
  invisible?: boolean;
15
15
  /** Clamps the minimum split percentage default: 10 */
16
- min: number;
16
+ min?: number;
17
17
  /** Clamps the maximum split percentage default: 90 */
18
- max: number;
18
+ max?: number;
19
19
  /** save and load split state to localstorage splitter must have an id attribute default: true */
20
20
  useSavedState?: boolean;
21
21
  }
@@ -30,8 +30,8 @@ export declare class SplitView extends DisposableElement implements SplitViewPro
30
30
  percentage: SplitViewProps['percentage'];
31
31
  invisible: SplitViewProps['invisible'];
32
32
  static styles: import('lit').CSSResult;
33
- min: SplitViewProps['min'];
34
- max: SplitViewProps['max'];
33
+ min: number;
34
+ max: number;
35
35
  useSavedState: SplitViewProps['useSavedState'];
36
36
  private isDragging;
37
37
  private _error;
@@ -1,4 +1,4 @@
1
- import { LitElement } from 'lit';
1
+ import { LitElement, PropertyValues } from 'lit';
2
2
  import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
3
  import { ColumnSettings, TableElement } from './table';
4
4
  export declare const TableBodyElementTag = "spectric-table-body";
@@ -14,6 +14,7 @@ export declare class TableBodyElement<T> extends LitElement implements BodyProps
14
14
  columns: ColumnSettings<T>[];
15
15
  table: TableElement<T>;
16
16
  protected createRenderRoot(): HTMLElement | DocumentFragment;
17
+ protected firstUpdated(_changedProperties: PropertyValues): void;
17
18
  protected render(): unknown;
18
19
  }
19
20
  interface TableBodyEvents {
@@ -17,6 +17,7 @@ export type FilterEvent<T> = {
17
17
  */
18
18
  export declare class TableCellElement<T> extends LitElement implements CellProps<T> {
19
19
  row: T;
20
+ index: number;
20
21
  column: ColumnSettings<T>;
21
22
  columns: ColumnSettings<T>[];
22
23
  table: TableElement<T>;
@@ -55,4 +56,5 @@ declare global {
55
56
  }
56
57
  }
57
58
  }
59
+ export declare const rowGetValue: (context: Record<string, any>, key: string) => any;
58
60
  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)[];
@@ -1,26 +1,57 @@
1
- import { LitElement, TemplateResult } from 'lit';
1
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
2
  import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
- import { PaginationChangeProps, PaginationProps } from '../pagination';
3
+ import { PaginationProps } from '../pagination';
4
4
  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;
16
- render?: (row: T, table: TableElement<T>) => DomRenderable;
36
+ /**
37
+ * Render function to render a table cell for displaying custom html
38
+ */
39
+ render?: (row: T, index: number, 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;
54
+ rowHeight?: number;
24
55
  }
25
56
  type DomEvent<T> = Event & {
26
57
  target: T;
@@ -32,21 +63,27 @@ type DomEvent<T> = Event & {
32
63
  */
33
64
  export declare class TableElement<T> extends LitElement implements TableProps<T> {
34
65
  data: T[];
35
- pagination?: PaginationProps | undefined;
66
+ pagination?: PaginationProps;
36
67
  columns: ColumnSettings<T>[];
37
- select?: TableSelectOptions;
68
+ select: TableSelectOptionsTypes;
69
+ sort: TableSortOptionTypes;
70
+ /**
71
+ * Needed for virtualization
72
+ */
73
+ rowHeight: number;
74
+ static getDefaultDataSorterAndPaginatior<T>(data: T[]): (props: TableDataOptions<T>) => T[];
38
75
  private _handlePaginationChange;
76
+ private _handleSortChange;
39
77
  private _emitChange;
40
78
  private __DO_NOT_USE_filter;
41
- selected: T[];
79
+ private selected;
42
80
  protected createRenderRoot(): HTMLElement | DocumentFragment;
43
81
  _handleSelectAllChange: (e: DomEvent<HTMLInputElement>) => void;
82
+ protected update(changedProperties: PropertyValues): void;
44
83
  protected render(): unknown;
45
84
  }
46
85
  interface TableEvents {
47
- 'change': (event: CustomEvent<{
48
- pagination: PaginationChangeProps;
49
- }>) => void;
86
+ 'change': (event: CustomEvent<TableDataOptions<any>>) => void;
50
87
  'filter': (event: CustomEvent<FilterEvent<any>>) => void;
51
88
  }
52
89
  declare global {
@@ -56,7 +93,7 @@ declare global {
56
93
  namespace JSX {
57
94
  interface IntrinsicElements {
58
95
  /**
59
- * @see {@link DialogElement}
96
+ * @see {@link TableElement}
60
97
  */
61
98
  [TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
62
99
  }
@@ -65,7 +102,7 @@ declare global {
65
102
  namespace JSX {
66
103
  interface IntrinsicElements {
67
104
  /**
68
- * @see {@link DialogElement}
105
+ * @see {@link TableElement}
69
106
  */
70
107
  [TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
71
108
  }
@@ -0,0 +1,49 @@
1
+ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
2
+ import { ColumnSettings, TableElement } from './table';
3
+ import { DisposableElement } from '../../classes/DisposibleElement';
4
+ export declare const TableBodyElementTag = "spectric-table-virtual-body";
5
+ interface BodyProps<T> {
6
+ columns: ColumnSettings<T>[];
7
+ data: T[];
8
+ rowHeight: number;
9
+ }
10
+ /**
11
+ * Table Body Element
12
+ */
13
+ export declare class TableVirtualBodyElement<T> extends DisposableElement implements BodyProps<T> {
14
+ data: T[];
15
+ columns: ColumnSettings<T>[];
16
+ rowHeight: number;
17
+ startIndex: number;
18
+ table: TableElement<T>;
19
+ constructor();
20
+ protected firstUpdated(): void;
21
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
22
+ protected render(): unknown;
23
+ }
24
+ interface TableBodyEvents {
25
+ }
26
+ declare global {
27
+ interface HTMLElementTagNameMap {
28
+ [TableBodyElementTag]: HTMLElementTagWithEvents<TableVirtualBodyElement<any>, TableBodyEvents>;
29
+ }
30
+ namespace JSX {
31
+ interface IntrinsicElements {
32
+ /**
33
+ * @see {@link DialogElement}
34
+ */
35
+ [TableBodyElementTag]: ReactElementWithPropsAndEvents<TableVirtualBodyElement<any>, BodyProps<any>, TableBodyEvents>;
36
+ }
37
+ }
38
+ namespace React {
39
+ namespace JSX {
40
+ interface IntrinsicElements {
41
+ /**
42
+ * @see {@link DialogElement}
43
+ */
44
+ [TableBodyElementTag]: ReactElementWithPropsAndEvents<TableVirtualBodyElement<any>, BodyProps<any>, TableBodyEvents>;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
2
- import { CSSResultGroup, LitElement } from 'lit-element';
2
+ import { CSSResultGroup } from 'lit-element';
3
3
  import { DomRenderable } from '../table';
4
+ import { DisposableElement } from '../../classes/DisposibleElement';
4
5
  export declare const TooltipElementTag = "spectric-tooltip";
5
6
  export type { TooltipProps, TooltipEvents };
6
7
  export declare enum TooltipPostions {
@@ -15,11 +16,11 @@ interface TooltipProps {
15
16
  /**
16
17
  * How long you need to hover before the tooltip displays
17
18
  */
18
- delay: number;
19
+ delay?: number;
19
20
  /**
20
21
  * How long the fade in animation should run
21
22
  */
22
- animationDuration: number;
23
+ animationDuration?: number;
23
24
  /**
24
25
  * Tooltip contents
25
26
  */
@@ -27,24 +28,24 @@ interface TooltipProps {
27
28
  /**
28
29
  * Where to anchor the tooltip
29
30
  */
30
- position: TooltipPostionsTypes;
31
+ position?: TooltipPostionsTypes;
31
32
  /**
32
- * Sets a max width for the contents (default:300) you can disable this by setting to 0 or -1
33
+ * Sets a max width for the contents you can disable this by setting to 0 or -1
33
34
  */
34
35
  maxWidth?: number;
35
36
  /**
36
- * Container the tool tip will be attached to. (default:document.body)
37
+ * Container the tool tip will be attached to.
37
38
  */
38
39
  portalTarget?: HTMLElement;
39
40
  /**
40
- * The element that triggers the tooltip. (default:node.parentElement) This is used for special cases like in the shadow dom if you want to target a host element instead of the immediate parent element
41
+ * The element that triggers the tooltip. This is used for special cases like in the shadow dom if you want to target a host element instead of the immediate parent element
41
42
  */
42
43
  triggerTarget?: HTMLElement;
43
44
  }
44
45
  /**
45
46
  * Spectric tooltip will add a tooltip to any container
46
47
  */
47
- export declare class TooltipElement extends LitElement implements TooltipProps {
48
+ export declare class TooltipElement extends DisposableElement implements TooltipProps {
48
49
  delay: number;
49
50
  animationDuration: number;
50
51
  text: DomRenderable;
@@ -56,9 +57,13 @@ export declare class TooltipElement extends LitElement implements TooltipProps {
56
57
  portalTarget: HTMLElement;
57
58
  private timer?;
58
59
  private open;
59
- mouseframe?: number;
60
- triggerTarget?: HTMLElement;
60
+ private mouseframe?;
61
+ /**
62
+ * @default parentElement
63
+ */
64
+ triggerTarget: HTMLElement;
61
65
  private get target();
66
+ constructor();
62
67
  connectedCallback(): void;
63
68
  disconnectedCallback(): void;
64
69
  private _getMousePosition;
@@ -77,7 +82,7 @@ declare global {
77
82
  namespace JSX {
78
83
  interface IntrinsicElements {
79
84
  /**
80
- * @see {@link DialogElement}
85
+ * @see {@link TooltipElement}
81
86
  */
82
87
  [TooltipElementTag]: ReactElementWithPropsAndEvents<TooltipElement, TooltipProps, TooltipEvents>;
83
88
  }
@@ -86,7 +91,7 @@ declare global {
86
91
  namespace JSX {
87
92
  interface IntrinsicElements {
88
93
  /**
89
- * @see {@link DialogElement}
94
+ * @see {@link TooltipElement}
90
95
  */
91
96
  [TooltipElementTag]: ReactElementWithPropsAndEvents<TooltipElement, TooltipProps, TooltipEvents>;
92
97
  }