@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
@@ -4,6 +4,7 @@ import { ButtonSizes, ButtonVariants, type ButtonProps } from '../components/But
4
4
  import '../components';
5
5
  import { html } from 'lit';
6
6
  import { ifDefined } from 'lit/directives/if-defined.js';
7
+ import { TooltipPostions } from '../components';
7
8
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
8
9
  const meta = {
9
10
  title: 'UI/Button',
@@ -13,6 +14,7 @@ const meta = {
13
14
  <spectric-button
14
15
  ?disabled=${args.disabled}
15
16
  ?danger=${args.danger}
17
+ ?icon=${args.icon}
16
18
  variant=${ifDefined(args.variant)}
17
19
  size=${ifDefined(args.size)}
18
20
  backgroundColor=${ifDefined(args.backgroundColor)}
@@ -31,11 +33,11 @@ const meta = {
31
33
  backgroundColor: { control: 'color', description: "sets the background color for the element" },
32
34
  size: {
33
35
  control: { type: 'select' },
34
- options: ['small', 'medium', 'large'],
36
+ options: Object.values(ButtonSizes),
35
37
  },
36
38
  variant: {
37
39
  control: { type: 'select' },
38
- options: ['primary', 'secondary', 'text'],
40
+ options: Object.values(ButtonVariants),
39
41
  },
40
42
  disabled: {
41
43
  control: { type: 'boolean' },
@@ -135,4 +137,25 @@ export const Dangerous: Story = {
135
137
  args: {
136
138
  danger: true
137
139
  },
140
+ };
141
+
142
+ export const ButtonsWithTooltips: Story = {
143
+ render: (args) => html`
144
+ ${Object.values(TooltipPostions).map(p => {
145
+ return html`
146
+ <spectric-button
147
+ ?danger=${args.danger}
148
+ tooltip=${p}
149
+ tooltipPosition=${p}
150
+ size=${ifDefined(args.size)}
151
+ backgroundColor=${ifDefined(args.backgroundColor)}
152
+ @click=${() => { alert("clicked") }}
153
+ >
154
+ ${p}
155
+ </spectric-button>`
156
+ })}
157
+ `,
158
+ args: {
159
+
160
+ },
138
161
  };
@@ -1,12 +1,14 @@
1
1
 
2
- import { filterByColumn } from "./data";
2
+ import { filterByColumn, tablecolumns, tabledata } from "./data";
3
3
  import { ExampleBits } from "./Bits";
4
- import { FieldTypes } from "../../components/query_bar/QueryBar";
4
+ import { FieldTypes, SpectricQuery } from "../../components/query_bar/QueryBar";
5
5
 
6
6
  import { html, LitElement } from 'lit';
7
7
 
8
- import { customElement, property, state } from 'lit/decorators.js';
8
+ import { customElement, property, query, state } from 'lit/decorators.js';
9
9
  import "./lorumipsum"
10
+ import { PaginationChangeProps } from "../../components/pagination";
11
+ import { FilterEvent } from "../../components/table/cell";
10
12
  type Props = {
11
13
  frameWidth: number
12
14
  }
@@ -17,8 +19,35 @@ export class SpectricStorybookExampleContent extends LitElement implements Props
17
19
  }
18
20
  @property({ type: Number, reflect: true })
19
21
  frameWidth: number = 10;
22
+
23
+ @query("spectric-query")
24
+ query!: SpectricQuery
25
+
20
26
  @state()
21
27
  dialogOpen: boolean = false;
28
+ tableData = tabledata.slice(0, 3)
29
+ pagination = {
30
+ page: 1,
31
+ pageSize: 3,
32
+ size: "xsmall",
33
+ totalItems: tabledata.length,
34
+ }
35
+ _handleFilter = (e: CustomEvent<FilterEvent<any>>) => {
36
+ let include = e.detail.include ? "" : "not "
37
+ if (e.detail.column.key && e.detail.value) {
38
+ if (this.query.value !== "") {
39
+ this.query.value = `${this.query.value} and ${include}${e.detail.column.key}: '${e.detail.value}'`
40
+ } else {
41
+ this.query.value = `${include}${e.detail.column.key}: '${e.detail.value}'`
42
+ }
43
+ }
44
+ }
45
+ _handlePaginationChange = (e: CustomEvent<{ pagination: PaginationChangeProps }>) => {
46
+ let { pagination } = e.detail
47
+ this.pagination = { ...this.pagination, ...pagination }
48
+ this.tableData = tabledata.slice((pagination.page - 1) * pagination.pageSize, (pagination.page) * pagination.pageSize)
49
+ this.requestUpdate()
50
+ }
22
51
  render() {
23
52
  return html`
24
53
  <spectric-dialog
@@ -59,6 +88,12 @@ export class SpectricStorybookExampleContent extends LitElement implements Props
59
88
  >
60
89
 
61
90
  </spectric-query>
91
+ <spectric-table
92
+ .data=${this.tableData}
93
+ .columns=${tablecolumns}
94
+ @filter=${this._handleFilter}
95
+ @change=${this._handlePaginationChange}
96
+ .pagination=${this.pagination}></spectric-table>
62
97
  <spectric-panel style="display:flex">
63
98
  <spectric-bit-display
64
99
  frameWidth=${this.frameWidth}
@@ -92,7 +127,7 @@ export class SpectricStorybookExampleContent extends LitElement implements Props
92
127
  <spectric-button size="small" danger @click=${() => {
93
128
  this.dialogOpen = true
94
129
  this.requestUpdate()
95
- }}>Delete</spectric-button>
130
+ }}>Delete (show modal)</spectric-button>
96
131
  <spectric-button size="small" danger variant="secondary">Override</spectric-button>
97
132
  <spectric-button size="small" danger variant="text">Disable</spectric-button>
98
133
  <spectric-button size="small" variant="text">test</spectric-button>
@@ -1,3 +1,4 @@
1
+ import { ColumnSettings } from "../../components/table";
1
2
 
2
3
 
3
4
  export const modulations = [
@@ -15,7 +16,7 @@ export const modulations = [
15
16
  //pulled from https://www.sigidwiki.com/wiki/Category:Digital signals that don't have a space or -
16
17
  export const signals = ["802.11n", "8PSK", "ASCII", "AUTOSPEC", "Aprizesat", "Autocab", "Bluetooth", "CCITT", "CDMA420", "CHIP", "CHU", "COFDMTV", "CompuLert", "Contestia", "Coquelet", "DCF77", "DominoEX", "DominoF", "EIA", "FLEX", "FSK441", "FSQ", "FST4W", "FT4", "FT8", "Hellschreiber", "ISCAT", "JS8", "JT4", "JT65", "JT6M", "JT9", "JTMS", "Kiwi", "Lentus", "LoRa", "MDC1200", "MOBITEX", "MSK144", "MT63", "Milstar", "NML", "NOV", "NPM", "NWC", "Olivia", "OpenSky", "Orbcomm", "PACKET", "PAX", "PI4", "POCSAG", "PSK2K", "Piccolo", "ProVoice", "Q15X25", "ROS", "RTTYM", "ReFLEX", "SIGFOX", "SPREAD", "Serdolik", "SkyOFDM", "THOR", "THROB", "TT2300", "TWINPLEX", "Tetrapol", "VISEL", "VOICE", "WSPR", "WiMAX", "WinDRM"]
17
18
  export const filterByColumn = async (field, text) => {
18
- if(field === "time_seen"){
19
+ if (field === "time_seen") {
19
20
  return []
20
21
  }
21
22
  if (field === "modulations") {
@@ -30,4 +31,21 @@ export const filterByColumn = async (field, text) => {
30
31
  return values
31
32
  }
32
33
  return values.filter(v => v.includes(text))
33
- }
34
+ }
35
+
36
+ type TestData = {
37
+ name: string
38
+ company: string
39
+ contact: string
40
+ country: string
41
+ }
42
+
43
+ export const tabledata: TestData[] = [
44
+ { name: "Sean", company: "Spectric Labs", "contact": "123-4567", "country": "US" },
45
+ { name: "Kipp", company: "Spectric Labs", "contact": "123-4567", "country": "UK" },
46
+ { name: "Adam", company: "Spectric Labs", "contact": "123-4567", "country": "US" },
47
+ { name: "Chris", company: "Spectric Labs", "contact": "123-4567", "country": "US" },
48
+ { name: "Michael", company: "Spectric Labs", "contact": "123-4567", "country": "US" },
49
+ { name: "Matt", company: "Spectric Labs", "contact": "123-4567", "country": "US" },
50
+ { name: "Grant", company: "Spectric Labs", "contact": "123-4567", "country": "UK" },]
51
+ export const tablecolumns: ColumnSettings<TestData>[] = [{ "title": "Company", key: "company" }, { "title": "Name", key: "name" }, { "title": "Contact", key: "contact" }, { "title": "Country", key: "country", filterable: true }]
@@ -0,0 +1,63 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components";
2
+
3
+ import { PaginationChangeProps, type PaginationProps as Props } from "../components/pagination/pagination";
4
+ import { html } from "lit";
5
+ import '../components';
6
+ import { ifDefined } from "lit/directives/if-defined.js";
7
+ import { useArgs } from "@storybook/client-api";
8
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
9
+ const meta = {
10
+ title: "UI/Pagination",
11
+ tags: ["autodocs"],
12
+ component: "spectric-pagination",
13
+ render: (args) => {
14
+ const [_, updateArgs] = useArgs();
15
+
16
+ return html`
17
+ <spectric-pagination
18
+ page=${ifDefined(args.page)}
19
+ pageSize=${ifDefined(args.pageSize)}
20
+ totalItems=${ifDefined(args.totalItems)}
21
+ size=${args.size}
22
+ @change=${(e: CustomEvent<PaginationChangeProps>) => {
23
+ updateArgs({ ...e.detail });
24
+ }}
25
+ >
26
+ </spectric-pagination>
27
+ `;
28
+ },
29
+ argTypes: {
30
+ size: {
31
+ control: { type: 'select' },
32
+ options: ['small', 'medium', 'large'],
33
+ },
34
+ },
35
+ args: {
36
+ page: 1,
37
+ pageSize: 3,
38
+ size: "small",
39
+ totalItems: 103,
40
+ },
41
+ } satisfies Meta<Props>;
42
+
43
+ export default meta;
44
+ type Story = StoryObj<Props>;
45
+
46
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
47
+ export const Basic: Story = {
48
+ args: {
49
+ page: 1,
50
+ pageSize: 3,
51
+ totalItems: 103,
52
+ },
53
+ };
54
+ /**
55
+ * When the total items is unknown pagination will only shows page size
56
+ */
57
+ export const NoTotalItems: Story = {
58
+ args: {
59
+ page: 1,
60
+ pageSize: 3,
61
+ totalItems: undefined,
62
+ },
63
+ };
@@ -0,0 +1,88 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components";
2
+
3
+ import { ColumnSettings, PaginationChangeProps, type TableProps as Props } from "../components/";
4
+ import { html } from "lit";
5
+ import '../components';
6
+ import { ifDefined } from "lit/directives/if-defined.js";
7
+ import { useArgs } from "@storybook/client-api";
8
+ import { FilterEvent } from "../components/table/cell";
9
+ import { tablecolumns, tabledata } from "./fixtures/data";
10
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
11
+ type TestData = {
12
+ name: string
13
+ company: string
14
+ contact: string
15
+ country: string
16
+ }
17
+ const data = tabledata
18
+ const columns = tablecolumns
19
+ const meta = {
20
+ title: "UI/Table",
21
+ tags: ["autodocs"],
22
+ component: "spectric-table",
23
+ render: (args) => {
24
+ const [_, updateArgs] = useArgs();
25
+
26
+ return html`
27
+ <spectric-table
28
+ .pagination=${args.pagination}
29
+ .columns=${args.columns}
30
+ .data=${!args.pagination ? data : data.slice((args.pagination.page - 1) * args.pagination.pageSize, (args.pagination.page) * args.pagination.pageSize)}
31
+ select=${ifDefined(args.select)}
32
+ @filter=${(e: CustomEvent<FilterEvent<any>>) => {
33
+ alert(`filter ${e.detail.include ? "for" : "out"} event value ${e.detail.value}`)
34
+ }}
35
+ @change=${(e: CustomEvent<PaginationChangeProps>) => {
36
+ console.log(e)
37
+ updateArgs({ ...e.detail });
38
+ }}
39
+ >
40
+ </spectric-table>
41
+ `;
42
+ },
43
+ argTypes: {
44
+ },
45
+ args: {
46
+ pagination: {
47
+ page: 1,
48
+ pageSize: 3,
49
+ size: "xsmall",
50
+ totalItems: data.length,
51
+ },
52
+ columns: columns
53
+ },
54
+ } satisfies Meta<Props<TestData>>;
55
+
56
+ export default meta;
57
+ type Story = StoryObj<Props<TestData>>;
58
+
59
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
60
+ export const Basic: Story = {
61
+ args: {
62
+ pagination: {
63
+ page: 1,
64
+ pageSize: 3,
65
+ size: "xsmall",
66
+ totalItems: data.length,
67
+ }
68
+ },
69
+ };
70
+
71
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
72
+ export const NoPagination: Story = {
73
+ args: {
74
+ pagination: undefined
75
+ },
76
+ };
77
+
78
+ export const MiltiSelect: Story = {
79
+ args: {
80
+ select: "multi"
81
+ },
82
+ };
83
+
84
+ export const SingleSelect: Story = {
85
+ args: {
86
+ select: "single"
87
+ },
88
+ };
@@ -0,0 +1,68 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components";
2
+
3
+ import { TooltipPostions, type TooltipProps as Props } from "../components/";
4
+ import { html } from "lit";
5
+ import "../components";
6
+ import { useArgs } from "@storybook/client-api";
7
+ import { ifDefined } from "lit/directives/if-defined.js";
8
+ let positions = Object.values(TooltipPostions);
9
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
10
+ const meta = {
11
+ title: "UI/Tooltip",
12
+ tags: ["autodocs"],
13
+ component: "spectric-tooltip",
14
+ render: (args) => {
15
+ const [_, updateArgs] = useArgs();
16
+
17
+ return html`
18
+ ${positions.map((p) => {
19
+ return html` <span>
20
+ <spectric-tooltip
21
+ position=${p}
22
+ text=${args.text || p}
23
+ delay=${args.delay}
24
+ animationDuration=${ifDefined(args.animationDuration)}
25
+ >
26
+ </spectric-tooltip>
27
+ ${p}
28
+ </span>
29
+
30
+ `;
31
+ })}
32
+ `;
33
+ },
34
+ argTypes: {},
35
+ args: {
36
+ animationDuration: 500,
37
+ delay: 100
38
+ },
39
+ } satisfies Meta<Props>;
40
+
41
+ export default meta;
42
+ type Story = StoryObj<Props>;
43
+
44
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
45
+ export const PositionTop: Story = {
46
+ args: {
47
+ position: "top",
48
+ },
49
+ };
50
+
51
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
52
+ export const PositionLeft: Story = {
53
+ args: {
54
+ position: "left",
55
+ },
56
+ };
57
+
58
+ export const PositionRight: Story = {
59
+ args: {
60
+ position: "right",
61
+ },
62
+ };
63
+
64
+ export const PositionBottom: Story = {
65
+ args: {
66
+ position: "bottom",
67
+ },
68
+ };