@spectric/ui 0.0.7 → 0.0.9

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 (46) hide show
  1. package/README.MD +5 -28
  2. package/dist/components/Button.d.ts +14 -3
  3. package/dist/components/index.d.ts +3 -0
  4. package/dist/components/input.d.ts +5 -1
  5. package/dist/components/pagination/index.d.ts +1 -0
  6. package/dist/components/pagination/pagination.d.ts +60 -0
  7. package/dist/components/table/body.d.ts +44 -0
  8. package/dist/components/table/cell.d.ts +58 -0
  9. package/dist/components/table/header.d.ts +42 -0
  10. package/dist/components/table/index.d.ts +1 -0
  11. package/dist/components/table/table.d.ts +100 -0
  12. package/dist/components/tooltip/index.d.ts +1 -0
  13. package/dist/components/tooltip/tooltip.d.ts +95 -0
  14. package/dist/custom-elements.json +201 -7
  15. package/dist/index.es.js +2104 -1612
  16. package/dist/index.es.js.map +1 -1
  17. package/dist/index.umd.js +222 -83
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/style.css +1 -1
  20. package/package.json +1 -1
  21. package/src/components/Button.ts +23 -4
  22. package/src/components/button.css.ts +85 -2
  23. package/src/components/index.ts +4 -1
  24. package/src/components/input.css +6 -1
  25. package/src/components/input.ts +26 -5
  26. package/src/components/pagination/index.ts +1 -0
  27. package/src/components/pagination/pagination.css +10 -0
  28. package/src/components/pagination/pagination.ts +133 -0
  29. package/src/components/table/body.ts +69 -0
  30. package/src/components/table/cell.ts +133 -0
  31. package/src/components/table/header.ts +68 -0
  32. package/src/components/table/index.ts +1 -0
  33. package/src/components/table/table.css +46 -0
  34. package/src/components/table/table.ts +174 -0
  35. package/src/components/tooltip/index.ts +1 -0
  36. package/src/components/tooltip/tooltip.css +52 -0
  37. package/src/components/tooltip/tooltip.ts +228 -0
  38. package/src/docs/HTML-Vue-Python Integration.mdx +18 -0
  39. package/src/docs/React.mdx +20 -0
  40. package/src/docs/welcome.mdx +29 -0
  41. package/src/stories/Button.stories.ts +25 -2
  42. package/src/stories/fixtures/ExampleContent.ts +39 -4
  43. package/src/stories/fixtures/data.ts +20 -2
  44. package/src/stories/pagination.stories.ts +63 -0
  45. package/src/stories/table.stories.ts +88 -0
  46. package/src/stories/tooltip.stories.ts +68 -0
package/README.MD CHANGED
@@ -1,50 +1,27 @@
1
1
  # Component Examples and playground
2
+
2
3
  https://pages.spectric.com/web/spectric-ui/?path=/docs/spectric-ui-components-ui-page--docs
3
4
 
4
5
  # Developing
6
+
5
7
  ```
6
8
  nvm use
7
9
  npm start
8
10
  ```
11
+
9
12
  # Publishing
10
13
 
11
14
  To publish a new version run
15
+
12
16
  ```
13
17
  npm version patch
14
18
  git push --follow-tags
15
19
  ```
20
+
16
21
  This will trigger a pipeline to run and build the source and publish to our internal gitlab NPM
17
22
 
18
23
  # Installing In your project
19
- Internally (for now) we use gitlab as the package registry. To configure npm to use gitlab for `@spectric` packages follow the one time steps below
20
- 1. Create an access token for npm [Personal Access Token](https://gitlab.spectric.com/-/user_settings/personal_access_tokens)
21
- - ensure it has api access
22
- 2. Point npm to install `@spectric` packages from gitlab
23
- - run `npm config set -- @spectric:registry=https://gitlab.spectric.com/api/v4/groups/585/-/packages/npm/`
24
- 3. Have npm use the access token created in 1. to authenticate
25
- - run `npm config set -- //gitlab.spectric.com/api/v4/groups/585/-/packages/npm/:_authToken <token>`
26
-
27
- After you have setup npm witht he steps above you can install this package normally.
28
24
 
29
25
  ```
30
26
  npm i @spectric/ui
31
27
  ```
32
-
33
- # Javascript/typescript integration
34
- The types files produced when building seemlessly integrate the custom elements into javascript giving full type hinting
35
-
36
- # HTML integration
37
- Add the dist/custom-element.json to the html.languge settings
38
- https://code.visualstudio.com/docs/languages/html#_html-custom-data
39
- ![Add spectric custom elements](html-include.png)
40
-
41
- # VUE Integration
42
- Complete steps to include custom elements in the HTML language server
43
- then
44
- Add the HTML language server in the @ext:Vue.volar extention
45
- ![Add the HTML language server in the @ext:Vue.volar extention](vue-include.png)
46
- Once setup hovering over spectric elements will provide documentation
47
- ![alt text](vue-example.png)
48
-
49
- # Python Jinja
50
- Same as HTML Integration
@@ -1,11 +1,16 @@
1
1
  import { CSSResultGroup, LitElement } from 'lit';
2
2
  import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from './types';
3
+ import { DomRenderable } from './table';
4
+ import { TooltipPostionsTypes } from './tooltip';
3
5
  export declare enum ButtonSizes {
4
6
  large = "large",
5
7
  medium = "medium",
6
- small = "small"
8
+ small = "small",
9
+ xsmall = "xsmall",
10
+ xxsmall = "xxsmall",
11
+ tiny = "tiny"
7
12
  }
8
- type ButtonSizesTypes = `${ButtonSizes}`;
13
+ export type ButtonSizesTypes = `${ButtonSizes}`;
9
14
  export declare enum ButtonVariants {
10
15
  primary = "primary",
11
16
  secondary = "secondary",
@@ -22,15 +27,21 @@ export interface ButtonProps {
22
27
  label?: string;
23
28
  disabled: boolean;
24
29
  danger?: boolean;
30
+ icon?: boolean;
31
+ tooltip?: DomRenderable;
32
+ tooltipPosition?: TooltipPostionsTypes;
25
33
  }
26
34
  export declare class SpectricButton extends LitElement implements ButtonProps {
27
35
  static styles?: CSSResultGroup | undefined;
28
36
  variant: 'primary' | 'secondary' | 'text';
29
37
  disabled: boolean;
30
38
  backgroundColor?: string | undefined;
31
- size: 'small' | 'medium' | 'large';
39
+ size: ButtonSizesTypes;
32
40
  label?: string;
33
41
  danger: boolean;
42
+ icon: boolean;
43
+ tooltip?: DomRenderable;
44
+ tooltipPosition?: TooltipPostionsTypes;
34
45
  connectedCallback(): void;
35
46
  disconnectedCallback(): void;
36
47
  private _onClick;
@@ -8,3 +8,6 @@ export * from './Panel';
8
8
  export * from './ThemeProvider';
9
9
  export * from './dialog';
10
10
  export * from './splitview';
11
+ export * from './pagination';
12
+ export * from './table';
13
+ export * from './tooltip';
@@ -1,5 +1,6 @@
1
1
  import { LitElement, TemplateResult } from 'lit';
2
2
  import { ReactElementWithPropsAndEvents } from './types';
3
+ import { ButtonSizesTypes } from './Button';
3
4
  export declare enum InputVariants {
4
5
  Text = "text",
5
6
  TextArea = "text-area",
@@ -10,7 +11,8 @@ export declare enum InputVariants {
10
11
  email = "email",
11
12
  file = "file",//display drop area
12
13
  hidden = "hidden",//display drop area
13
- password = "password"
14
+ password = "password",
15
+ checkbox = "checkbox"
14
16
  }
15
17
  type InputVariantsTypes = `${InputVariants}`;
16
18
  export interface InputProps {
@@ -60,6 +62,8 @@ export interface InputProps {
60
62
  autocomplete: HTMLInputElement['autocomplete'];
61
63
  }
62
64
  export declare class SpectricInput extends LitElement implements InputProps {
65
+ checked?: boolean;
66
+ size?: ButtonSizesTypes;
63
67
  protected createRenderRoot(): HTMLElement | DocumentFragment;
64
68
  placeholder: string;
65
69
  readonly: boolean;
@@ -0,0 +1 @@
1
+ export * from './pagination';
@@ -0,0 +1,60 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
+ import { ButtonSizesTypes } from '../Button';
4
+ export declare const PaginationElementTag = "spectric-pagination";
5
+ export type { PaginationProps, PaginationChangeProps, PaginationEvents };
6
+ interface PaginationChangeProps {
7
+ page: number;
8
+ pageSize: number;
9
+ }
10
+ interface PaginationProps extends PaginationChangeProps {
11
+ size: ButtonSizesTypes;
12
+ totalItems?: number;
13
+ pageSizeOptions?: number[];
14
+ }
15
+ /**
16
+ * Pagination Element
17
+ */
18
+ export declare class PaginationElement extends LitElement implements PaginationProps {
19
+ page: number;
20
+ pageSize: number;
21
+ totalItems?: number;
22
+ pageSizeOptions: number[];
23
+ /**
24
+ * Size of the pagination buttons
25
+ */
26
+ size: ButtonSizesTypes;
27
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
28
+ protected updated(_changedProperties: PropertyValues): void;
29
+ private _handlePageUp;
30
+ private _handlePageDown;
31
+ private _handleSizeChange;
32
+ private _emitChange;
33
+ protected render(): unknown;
34
+ }
35
+ interface PaginationEvents {
36
+ 'change': (event: CustomEvent<PaginationChangeProps>) => void;
37
+ }
38
+ declare global {
39
+ interface HTMLElementTagNameMap {
40
+ [PaginationElementTag]: HTMLElementTagWithEvents<PaginationElement, PaginationEvents>;
41
+ }
42
+ namespace JSX {
43
+ interface IntrinsicElements {
44
+ /**
45
+ * @see {@link DialogElement}
46
+ */
47
+ [PaginationElementTag]: ReactElementWithPropsAndEvents<PaginationElement, PaginationProps, PaginationEvents>;
48
+ }
49
+ }
50
+ namespace React {
51
+ namespace JSX {
52
+ interface IntrinsicElements {
53
+ /**
54
+ * @see {@link DialogElement}
55
+ */
56
+ [PaginationElementTag]: ReactElementWithPropsAndEvents<PaginationElement, PaginationProps, PaginationEvents>;
57
+ }
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,44 @@
1
+ import { LitElement } from 'lit';
2
+ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
+ import { ColumnSettings, TableElement } from './table';
4
+ export declare const TableBodyElementTag = "spectric-table-body";
5
+ interface BodyProps<T> {
6
+ columns: ColumnSettings<T>[];
7
+ data: T[];
8
+ }
9
+ /**
10
+ * Table Body Element
11
+ */
12
+ export declare class TableBodyElement<T> extends LitElement implements BodyProps<T> {
13
+ data: T[];
14
+ columns: ColumnSettings<T>[];
15
+ table: TableElement<T>;
16
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
17
+ protected render(): unknown;
18
+ }
19
+ interface TableBodyEvents {
20
+ }
21
+ declare global {
22
+ interface HTMLElementTagNameMap {
23
+ [TableBodyElementTag]: HTMLElementTagWithEvents<TableBodyElement<any>, TableBodyEvents>;
24
+ }
25
+ namespace JSX {
26
+ interface IntrinsicElements {
27
+ /**
28
+ * @see {@link DialogElement}
29
+ */
30
+ [TableBodyElementTag]: ReactElementWithPropsAndEvents<TableBodyElement<any>, BodyProps<any>, TableBodyEvents>;
31
+ }
32
+ }
33
+ namespace React {
34
+ namespace JSX {
35
+ interface IntrinsicElements {
36
+ /**
37
+ * @see {@link DialogElement}
38
+ */
39
+ [TableBodyElementTag]: ReactElementWithPropsAndEvents<TableBodyElement<any>, BodyProps<any>, TableBodyEvents>;
40
+ }
41
+ }
42
+ }
43
+ }
44
+ export {};
@@ -0,0 +1,58 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
+ import { ColumnSettings, TableElement } from './table';
4
+ export declare const TableCellElementTag = "spectric-table-cell";
5
+ interface CellProps<T> {
6
+ column: ColumnSettings<T>;
7
+ row: T;
8
+ }
9
+ export type FilterEvent<T> = {
10
+ value?: T;
11
+ include: boolean;
12
+ column: ColumnSettings<T>;
13
+ row: T;
14
+ };
15
+ /**
16
+ * Pagination Element
17
+ */
18
+ export declare class TableCellElement<T> extends LitElement implements CellProps<T> {
19
+ row: T;
20
+ column: ColumnSettings<T>;
21
+ columns: ColumnSettings<T>[];
22
+ table: TableElement<T>;
23
+ styleRules: CSSStyleDeclaration;
24
+ td: HTMLTableCellElement;
25
+ constructor();
26
+ protected updated(_changedProperties: PropertyValues): void;
27
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
28
+ _handleFilterOut: () => void;
29
+ _handleFilterFor: () => void;
30
+ protected render(): unknown;
31
+ }
32
+ interface TableBodyEvents {
33
+ 'filter': (event: CustomEvent<ColumnSettings<any>>) => void;
34
+ }
35
+ declare global {
36
+ interface HTMLElementTagNameMap {
37
+ [TableCellElementTag]: HTMLElementTagWithEvents<TableCellElement<any>, TableBodyEvents>;
38
+ }
39
+ namespace JSX {
40
+ interface IntrinsicElements {
41
+ /**
42
+ * @see {@link DialogElement}
43
+ */
44
+ [TableCellElementTag]: ReactElementWithPropsAndEvents<TableCellElement<any>, CellProps<any>, TableBodyEvents>;
45
+ }
46
+ }
47
+ namespace React {
48
+ namespace JSX {
49
+ interface IntrinsicElements {
50
+ /**
51
+ * @see {@link DialogElement}
52
+ */
53
+ [TableCellElementTag]: ReactElementWithPropsAndEvents<TableCellElement<any>, CellProps<any>, TableBodyEvents>;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ export {};
@@ -0,0 +1,42 @@
1
+ import { LitElement } from 'lit';
2
+ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
+ import { ColumnSettings } from './table';
4
+ export declare const TableHeaderElementTag = "spectric-table-header";
5
+ interface HeaderProps<T> {
6
+ columns: ColumnSettings<T>[];
7
+ }
8
+ /**
9
+ * Pagination Element
10
+ */
11
+ export declare class TableHeaderElement<T> extends LitElement implements HeaderProps<T> {
12
+ columns: ColumnSettings<T>[];
13
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
14
+ protected render(): unknown;
15
+ }
16
+ interface TableHeaderEvents {
17
+ 'sort': (event: CustomEvent<ColumnSettings<any>>) => void;
18
+ }
19
+ declare global {
20
+ interface HTMLElementTagNameMap {
21
+ [TableHeaderElementTag]: HTMLElementTagWithEvents<TableHeaderElement<any>, TableHeaderEvents>;
22
+ }
23
+ namespace JSX {
24
+ interface IntrinsicElements {
25
+ /**
26
+ * @see {@link DialogElement}
27
+ */
28
+ [TableHeaderElementTag]: ReactElementWithPropsAndEvents<TableHeaderElement<any>, HeaderProps<any>, TableHeaderEvents>;
29
+ }
30
+ }
31
+ namespace React {
32
+ namespace JSX {
33
+ interface IntrinsicElements {
34
+ /**
35
+ * @see {@link DialogElement}
36
+ */
37
+ [TableHeaderElementTag]: ReactElementWithPropsAndEvents<TableHeaderElement<any>, HeaderProps<any>, TableHeaderEvents>;
38
+ }
39
+ }
40
+ }
41
+ }
42
+ export {};
@@ -0,0 +1 @@
1
+ export * from './table';
@@ -0,0 +1,100 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
+ import { PaginationChangeProps, PaginationProps } from '../pagination';
4
+ import { FilterEvent } from './cell';
5
+ export declare const TableElementTag = "spectric-table";
6
+ export type { TableProps, TableEvents };
7
+ export type DomRenderable = HTMLElement | TemplateResult | string | number | null;
8
+ export type ColumnSettings<T> = {
9
+ width?: number;
10
+ whiteSpace?: "nowrap";
11
+ hidden?: boolean;
12
+ sortable?: boolean;
13
+ filterable?: boolean;
14
+ title?: DomRenderable;
15
+ key?: string;
16
+ render?: (row: T, table: TableElement<T>) => DomRenderable;
17
+ };
18
+ type TableSelectOptions = "multi" | "single";
19
+ interface TableProps<T> {
20
+ pagination?: PaginationProps;
21
+ columns: ColumnSettings<T>[];
22
+ data: T[];
23
+ select?: TableSelectOptions;
24
+ }
25
+ type DomEvent<T> = Event & {
26
+ target: T;
27
+ };
28
+ /**
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
+ *
33
+ *
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
+ */
59
+ export declare class TableElement<T> extends LitElement implements TableProps<T> {
60
+ data: T[];
61
+ pagination?: PaginationProps | undefined;
62
+ columns: ColumnSettings<T>[];
63
+ select?: TableSelectOptions;
64
+ private _handlePaginationChange;
65
+ private _emitChange;
66
+ private __DO_NOT_USE_filter;
67
+ selected: T[];
68
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
69
+ _handleSelectAllChange: (e: DomEvent<HTMLInputElement>) => void;
70
+ protected render(): unknown;
71
+ }
72
+ interface TableEvents {
73
+ 'change': (event: CustomEvent<{
74
+ pagination: PaginationChangeProps;
75
+ }>) => void;
76
+ 'filter': (event: CustomEvent<FilterEvent<any>>) => void;
77
+ }
78
+ declare global {
79
+ interface HTMLElementTagNameMap {
80
+ [TableElementTag]: HTMLElementTagWithEvents<TableElement<any>, TableEvents>;
81
+ }
82
+ namespace JSX {
83
+ interface IntrinsicElements {
84
+ /**
85
+ * @see {@link DialogElement}
86
+ */
87
+ [TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
88
+ }
89
+ }
90
+ namespace React {
91
+ namespace JSX {
92
+ interface IntrinsicElements {
93
+ /**
94
+ * @see {@link DialogElement}
95
+ */
96
+ [TableElementTag]: ReactElementWithPropsAndEvents<TableElement<any>, TableProps<any>, TableEvents>;
97
+ }
98
+ }
99
+ }
100
+ }
@@ -0,0 +1 @@
1
+ export * from './tooltip';
@@ -0,0 +1,95 @@
1
+ import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
2
+ import { CSSResultGroup, LitElement } from 'lit-element';
3
+ import { DomRenderable } from '../table';
4
+ export declare const TooltipElementTag = "spectric-tooltip";
5
+ export type { TooltipProps, TooltipEvents };
6
+ export declare enum TooltipPostions {
7
+ top = "top",
8
+ bottom = "bottom",
9
+ left = "left",
10
+ right = "right",
11
+ mouse = "mouse"
12
+ }
13
+ export type TooltipPostionsTypes = `${TooltipPostions}`;
14
+ interface TooltipProps {
15
+ /**
16
+ * How long you need to hover before the tooltip displays
17
+ */
18
+ delay: number;
19
+ /**
20
+ * How long the fade in animation should run
21
+ */
22
+ animationDuration: number;
23
+ /**
24
+ * Tooltip contents
25
+ */
26
+ text: DomRenderable;
27
+ /**
28
+ * Where to anchor the tooltip
29
+ */
30
+ position: TooltipPostionsTypes;
31
+ /**
32
+ * Sets a max width for the contents (default:300) you can disable this by setting to 0 or -1
33
+ */
34
+ maxWidth?: number;
35
+ /**
36
+ * Container the tool tip will be attached to. (default:document.body)
37
+ */
38
+ portalTarget?: HTMLElement;
39
+ /**
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
+ */
42
+ triggerTarget?: HTMLElement;
43
+ }
44
+ /**
45
+ * Spectric tooltip will add a tooltip to any container
46
+ */
47
+ export declare class TooltipElement extends LitElement implements TooltipProps {
48
+ delay: number;
49
+ animationDuration: number;
50
+ text: DomRenderable;
51
+ position: TooltipPostionsTypes;
52
+ maxWidth?: number;
53
+ private portalElement;
54
+ private mouseLocation?;
55
+ static styles?: CSSResultGroup | undefined;
56
+ portalTarget: HTMLElement;
57
+ private timer?;
58
+ private open;
59
+ mouseframe?: number;
60
+ triggerTarget?: HTMLElement;
61
+ private get target();
62
+ connectedCallback(): void;
63
+ disconnectedCallback(): void;
64
+ private _getMousePosition;
65
+ _hideTooltip: () => void;
66
+ private showToolTip;
67
+ private applyStyle;
68
+ private positionTooltip;
69
+ protected render(): void;
70
+ }
71
+ interface TooltipEvents {
72
+ }
73
+ declare global {
74
+ interface HTMLElementTagNameMap {
75
+ [TooltipElementTag]: HTMLElementTagWithEvents<TooltipElement, TooltipEvents>;
76
+ }
77
+ namespace JSX {
78
+ interface IntrinsicElements {
79
+ /**
80
+ * @see {@link DialogElement}
81
+ */
82
+ [TooltipElementTag]: ReactElementWithPropsAndEvents<TooltipElement, TooltipProps, TooltipEvents>;
83
+ }
84
+ }
85
+ namespace React {
86
+ namespace JSX {
87
+ interface IntrinsicElements {
88
+ /**
89
+ * @see {@link DialogElement}
90
+ */
91
+ [TooltipElementTag]: ReactElementWithPropsAndEvents<TooltipElement, TooltipProps, TooltipEvents>;
92
+ }
93
+ }
94
+ }
95
+ }