@spectric/ui 0.0.4

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 (88) hide show
  1. package/.gitlab-ci.yml +28 -0
  2. package/.nvmrc +1 -0
  3. package/.storybook/analyze.sh +4 -0
  4. package/.storybook/main.ts +55 -0
  5. package/.storybook/preview.ts +42 -0
  6. package/.vscode/extensions.json +5 -0
  7. package/.vscode/settings.json +41 -0
  8. package/README.MD +50 -0
  9. package/html-include.png +0 -0
  10. package/package.json +33 -0
  11. package/src/classes/BitArray.ts +48 -0
  12. package/src/classes/DisposibleElement.ts +108 -0
  13. package/src/components/Banner.ts +102 -0
  14. package/src/components/Bitdisplay.ts +383 -0
  15. package/src/components/Button.ts +121 -0
  16. package/src/components/Header.ts +125 -0
  17. package/src/components/Page.ts +157 -0
  18. package/src/components/Panel.ts +56 -0
  19. package/src/components/ThemeProvider.ts +251 -0
  20. package/src/components/button.css.ts +160 -0
  21. package/src/components/configurations/classifications.ts +194 -0
  22. package/src/components/dialog/dialog.css.ts +50 -0
  23. package/src/components/dialog/dialog.ts +163 -0
  24. package/src/components/dialog/index.ts +1 -0
  25. package/src/components/header.css.ts +38 -0
  26. package/src/components/index.ts +10 -0
  27. package/src/components/input.css +75 -0
  28. package/src/components/input.ts +312 -0
  29. package/src/components/page.css.ts +158 -0
  30. package/src/components/panel.css.ts +44 -0
  31. package/src/components/query_bar/QueryBar.css +48 -0
  32. package/src/components/query_bar/QueryBar.ts +378 -0
  33. package/src/components/query_bar/index.ts +2 -0
  34. package/src/components/query_bar/querylanguage/kuery/ast/_generated_/kuery.js +3186 -0
  35. package/src/components/query_bar/querylanguage/kuery/ast/ast.ts +113 -0
  36. package/src/components/query_bar/querylanguage/kuery/ast/index.ts +31 -0
  37. package/src/components/query_bar/querylanguage/kuery/ast/kuery.peg +417 -0
  38. package/src/components/query_bar/querylanguage/kuery/functions/and.ts +55 -0
  39. package/src/components/query_bar/querylanguage/kuery/functions/exists.ts +62 -0
  40. package/src/components/query_bar/querylanguage/kuery/functions/index.ts +47 -0
  41. package/src/components/query_bar/querylanguage/kuery/functions/is.ts +211 -0
  42. package/src/components/query_bar/querylanguage/kuery/functions/nested.ts +63 -0
  43. package/src/components/query_bar/querylanguage/kuery/functions/not.ts +53 -0
  44. package/src/components/query_bar/querylanguage/kuery/functions/or.ts +56 -0
  45. package/src/components/query_bar/querylanguage/kuery/functions/range.ts +163 -0
  46. package/src/components/query_bar/querylanguage/kuery/functions/utils/get_fields.ts +49 -0
  47. package/src/components/query_bar/querylanguage/kuery/functions/utils/get_full_field_name_node.ts +87 -0
  48. package/src/components/query_bar/querylanguage/kuery/index.ts +38 -0
  49. package/src/components/query_bar/querylanguage/kuery/kuery_syntax_error.ts +76 -0
  50. package/src/components/query_bar/querylanguage/kuery/node_types/function.ts +75 -0
  51. package/src/components/query_bar/querylanguage/kuery/node_types/index.ts +46 -0
  52. package/src/components/query_bar/querylanguage/kuery/node_types/literal.ts +42 -0
  53. package/src/components/query_bar/querylanguage/kuery/node_types/named_arg.ts +47 -0
  54. package/src/components/query_bar/querylanguage/kuery/node_types/types.ts +108 -0
  55. package/src/components/query_bar/querylanguage/kuery/node_types/wildcard.ts +80 -0
  56. package/src/components/query_bar/querylanguage/kuery/types.ts +52 -0
  57. package/src/components/query_bar/querylanguage/outputTypes/toCQL.ts +122 -0
  58. package/src/components/query_bar/querylanguage/outputTypes/toMongo.ts +103 -0
  59. package/src/components/query_bar/querylanguage/utils.ts +35 -0
  60. package/src/components/query_bar/types.ts +59 -0
  61. package/src/components/splitview/index.ts +1 -0
  62. package/src/components/splitview/splitview.css.ts +66 -0
  63. package/src/components/splitview/splitview.ts +183 -0
  64. package/src/components/types.ts +35 -0
  65. package/src/index.ts +1 -0
  66. package/src/stories/Banner.stories.ts +46 -0
  67. package/src/stories/BitDisplay.stories.ts +68 -0
  68. package/src/stories/Button.stories.ts +138 -0
  69. package/src/stories/Header.stories.ts +55 -0
  70. package/src/stories/Page.stories.ts +108 -0
  71. package/src/stories/QueryBar.stories.ts +63 -0
  72. package/src/stories/Splitview.stories.ts +52 -0
  73. package/src/stories/fixtures/Bits.ts +15 -0
  74. package/src/stories/fixtures/ExampleContent.ts +102 -0
  75. package/src/stories/fixtures/data.ts +30 -0
  76. package/src/stories/fixtures/lorumipsum.ts +19 -0
  77. package/src/stories/input.stories.ts +77 -0
  78. package/src/stories/tsconfig.json +35 -0
  79. package/src/utils/debounce.ts +18 -0
  80. package/src/utils/spread.ts +71 -0
  81. package/src/vite-env.d.ts +1 -0
  82. package/test/__init__.py +9 -0
  83. package/test/elastic.py +9 -0
  84. package/test/interface.py +16 -0
  85. package/tsconfig.json +29 -0
  86. package/vite.config.js +34 -0
  87. package/vue-example.png +0 -0
  88. package/vue-include.png +0 -0
@@ -0,0 +1,68 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+
3
+ import type { BitDisplayProps } from '../components';
4
+ import '../components';
5
+ import { html } from 'lit';
6
+ import { ExampleBits } from './fixtures/Bits';
7
+ import { BitArray } from '../classes/BitArray';
8
+ import { useArgs } from '@storybook/client-api';
9
+ let bitarray = new BitArray(ExampleBits.buffer)
10
+ let dataview: DataView | undefined;
11
+ let pad = (v: number | number) => String(v).padEnd(8, " ")
12
+ const meta = {
13
+ title: 'DSP Related/BitDisplay',
14
+ tags: ['autodocs'],
15
+ component: "spectric-bit-display",
16
+ render: (args) => {
17
+ const [_, updateArgs] = useArgs();
18
+
19
+ return html`
20
+ <spectric-bit-display
21
+ style="display:inline-block"
22
+ frameWidth=${args.frameWidth}
23
+ scale=${args.scale}
24
+ .arrayBuffer=${args.arrayBuffer}
25
+ width=${args.width}
26
+ height=${args.height}
27
+ @bitMousemove=${(e) => {
28
+ let a = bitarray.subarray(e.detail.bitIndex, e.detail.bitIndex + 64)
29
+ let array = []
30
+ while (a.length) {
31
+ let n = parseInt(a.splice(0, 8).join(""), 2)
32
+ array.push(n)
33
+ }
34
+ let uint = new Uint8Array(array)
35
+ dataview = new DataView(uint.buffer)
36
+ updateArgs({ ...args })
37
+ }}
38
+ >
39
+ </spectric-bit-display>
40
+ ${dataview ? html`<pre style="display:inline-block">Mouse Readout:
41
+ Int8: ${pad(dataview.getInt8(0))} 0x${dataview.getInt8(0).toString(16)}
42
+ UInt8: ${pad(dataview.getUint8(0))} 0x${dataview.getUint8(0).toString(16)}
43
+ Int16-E: ${pad(dataview.getInt16(0, false))}
44
+ Int16-e: ${pad(dataview.getInt16(0, true))}
45
+ UInt16-E: ${pad(dataview.getUint16(0, false))} 0x${dataview.getUint16(0, false).toString(16)}
46
+ Int16-e: ${pad(dataview.getUint16(0, true))} 0x${dataview.getUint16(0, true).toString(16)}
47
+ </pre>`: null}
48
+ `},
49
+
50
+
51
+ } satisfies Meta<BitDisplayProps>;
52
+
53
+ export default meta;
54
+ type Story = StoryObj<BitDisplayProps>;
55
+
56
+
57
+
58
+
59
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
60
+ export const Primary: Story = {
61
+ args: {
62
+ scale: 1,
63
+ frameWidth: 100,
64
+ width: 200,
65
+ height: 200,
66
+ arrayBuffer: ExampleBits.buffer
67
+ },
68
+ };
@@ -0,0 +1,138 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+
3
+ import { ButtonSizes, ButtonVariants, type ButtonProps } from '../components/Button';
4
+ import '../components';
5
+ import { html } from 'lit';
6
+ import { ifDefined } from 'lit/directives/if-defined.js';
7
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
8
+ const meta = {
9
+ title: 'UI/Button',
10
+ tags: ['autodocs'],
11
+ component: "spectric-button",
12
+ render: (args) => html`
13
+ <spectric-button
14
+ ?disabled=${args.disabled}
15
+ ?danger=${args.danger}
16
+ variant=${ifDefined(args.variant)}
17
+ size=${ifDefined(args.size)}
18
+ backgroundColor=${ifDefined(args.backgroundColor)}
19
+ @click=${(e) => {
20
+ console.log(e);
21
+ alert("clicked")
22
+ }}
23
+ >
24
+ ${args.label}
25
+ </spectric-button>
26
+ `,
27
+ args: {
28
+ label: 'Button',
29
+ },
30
+ argTypes: {
31
+ backgroundColor: { control: 'color', description: "sets the background color for the element" },
32
+ size: {
33
+ control: { type: 'select' },
34
+ options: ['small', 'medium', 'large'],
35
+ },
36
+ variant: {
37
+ control: { type: 'select' },
38
+ options: ['primary', 'secondary', 'text'],
39
+ },
40
+ disabled: {
41
+ control: { type: 'boolean' },
42
+ },
43
+ danger: {
44
+ control: { type: 'boolean' },
45
+ },
46
+ }
47
+ } satisfies Meta<ButtonProps>;
48
+
49
+ export default meta;
50
+ type Story = StoryObj<ButtonProps>;
51
+
52
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
53
+ export const Basic: Story = {
54
+ args: {
55
+ label: 'Button',
56
+ },
57
+ };
58
+
59
+ export const Variants: Story = {
60
+ render: (args) => html`
61
+ ${Object.values(ButtonVariants).map(v => {
62
+ return html`
63
+ <spectric-button
64
+ ?disabled=${args.disabled}
65
+ variant=${v}
66
+ size=${ifDefined(args.size)}
67
+ backgroundColor=${ifDefined(args.backgroundColor)}
68
+ @click=${() => { alert("clicked") }}
69
+ >
70
+ ${v}
71
+ </spectric-button>`
72
+ })}
73
+ `,
74
+ args: {
75
+ variant: "primary",
76
+ label: 'Button',
77
+ },
78
+ };
79
+
80
+ export const Sizes: Story = {
81
+ render: (args) => html`
82
+ ${Object.values(ButtonSizes).map(v => {
83
+ return html`
84
+ <spectric-button
85
+ ?disabled=${args.disabled}
86
+ variant=${"primary"}
87
+ size=${ifDefined(v)}
88
+ backgroundColor=${ifDefined(args.backgroundColor)}
89
+ @click=${() => { alert("clicked") }}
90
+ >
91
+ ${v}
92
+ </spectric-button>`
93
+ })}
94
+ `,
95
+ args: {
96
+ size: 'large',
97
+ label: 'Button',
98
+ },
99
+ };
100
+ export const Disabled: Story = {
101
+ render: (args) => html`
102
+ ${Object.values(ButtonVariants).map(v => {
103
+ return html`
104
+ <spectric-button
105
+ ?disabled=${args.disabled}
106
+ variant=${v}
107
+ size=${ifDefined(args.size)}
108
+ backgroundColor=${ifDefined(args.backgroundColor)}
109
+ @click=${() => { alert("clicked") }}
110
+ >
111
+ ${v}
112
+ </spectric-button>`
113
+ })}
114
+ `,
115
+ args: {
116
+ disabled: true
117
+ },
118
+ };
119
+
120
+ export const Dangerous: Story = {
121
+ render: (args) => html`
122
+ ${Object.values(ButtonVariants).map(v => {
123
+ return html`
124
+ <spectric-button
125
+ ?danger=${args.danger}
126
+ variant=${v}
127
+ size=${ifDefined(args.size)}
128
+ backgroundColor=${ifDefined(args.backgroundColor)}
129
+ @click=${() => { alert("clicked") }}
130
+ >
131
+ ${v}
132
+ </spectric-button>`
133
+ })}
134
+ `,
135
+ args: {
136
+ danger: true
137
+ },
138
+ };
@@ -0,0 +1,55 @@
1
+
2
+ import type { Meta, StoryObj } from '@storybook/web-components';
3
+
4
+ import type { HeaderProps, HeaderSlots } from '../components/Header';
5
+ import '../components/Header';
6
+ import { html } from 'lit';
7
+ import { ifDefined } from 'lit/directives/if-defined.js';
8
+
9
+ const meta = {
10
+ title: 'UI/Header',
11
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
12
+ tags: ['autodocs'],
13
+ component: "spectric-header",
14
+ render: (args) => {
15
+ console.log(args)
16
+ return html`<spectric-header
17
+ username=${ifDefined(args.username)}
18
+ ?showCreateAccount=${args.showCreateAccount}
19
+ ?showLoginButton=${args.showLoginButton}
20
+ @login=${() => alert("login")}
21
+ @logout=${() => alert("logout")}
22
+ @createAccount=${() => alert("create")}>
23
+ ${args.name ? html`<span slot="name">${args.name}</span>` : null}
24
+ ${args.center ? html`<span slot="end">${args.center}</span>` : null}
25
+ ${args.end ? html`<span slot="end">${args.end}</span>` : null}
26
+ ${args.branding ? html`<span slot="branding">${args.branding}</span>` : null}
27
+ </spectric-header>`
28
+ },
29
+ args: { showLoginButton: true, showCreateAccount: false }
30
+ } satisfies Meta<HeaderProps & HeaderSlots>;
31
+
32
+ export default meta;
33
+ type Story = StoryObj<HeaderProps & HeaderSlots>;
34
+
35
+ export const LoggedIn: Story = {
36
+ args: {
37
+ username: "Jane Doe"
38
+ },
39
+ };
40
+
41
+ export const LoggedOut: Story = {};
42
+
43
+ export const ShowCreateAccount: Story = {
44
+ args: {
45
+ showCreateAccount: true
46
+ }
47
+ };
48
+
49
+
50
+ export const LoginNotRequired: Story = {
51
+ args: {
52
+ showLoginButton: false,
53
+ name: 'App without Login function'
54
+ }
55
+ };
@@ -0,0 +1,108 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+
3
+ import * as HeaderStories from './Header.stories';
4
+ import type { CSSProps, PageProps, PageSlots } from '../components/Page';
5
+ import '../components/Page';
6
+ import { html } from 'lit';
7
+ import { ifDefined } from 'lit/directives/if-defined.js';
8
+ import { CSSPropsControls, FieldTypes, HeaderSlots, ThemeSelections } from '../components';
9
+ import { useArgs } from '@storybook/client-api';
10
+ import { styleMap } from 'lit/directives/style-map.js';
11
+ import { ClassificationVariants } from '../components/configurations/classifications';
12
+ import "./fixtures/ExampleContent"
13
+ var frameWidth = 10
14
+ const content = () => html`<spectric-storybook-example-content/>`
15
+
16
+ const defaultHeader: HeaderSlots = { name: html`<span class="spectric">Spectric Components</span>`, branding: html`<img height="35" src='https://static.wixstatic.com/media/bb8de2_d075320863814eeb9c954fcc57ce2822%7Emv2.png/v1/fill/w_192%2Ch_192%2Clg_1%2Cusm_0.66_1.00_0.01/bb8de2_d075320863814eeb9c954fcc57ce2822%7Emv2.png'/>` }
17
+ const meta = {
18
+ title: 'UI/Page',
19
+ tags: ['autodocs'],
20
+ component: 'spectric-page',
21
+ //parameters:{docs:{source:{code:"test",language:'html',type:'auto'}}},
22
+ render: (args, context) => {
23
+ const [_, updateArgs] = useArgs();
24
+ let customStyles = Object.fromEntries(Object.entries(args).filter(([key, value]) => key.startsWith("--")))
25
+ return html`<spectric-page @change=${() => updateArgs({ ...args })}
26
+ style=${styleMap({ ...customStyles, height: "600px/*default is full screen*/" })}
27
+ theme=${ifDefined(args.theme)}
28
+ ?headerSticky=${args.headerSticky}
29
+ ?showHeader=${args.showHeader}
30
+ ?showCreateAccount=${args.showCreateAccount}
31
+ ?showLoginButton=${args.showLoginButton}
32
+ classificationLevel=${ifDefined(args.classificationLevel)}
33
+ classificationText=${ifDefined(args.classificationText)}
34
+ .notifications=${args.notifications || []}
35
+ username=${ifDefined(args.username)}
36
+ @createAccount=${() => {
37
+ let username = prompt("Username");
38
+ updateArgs({ ...args, username: username })
39
+ }}
40
+ @login=${() => { updateArgs({ ...args, username: "Spectric-User" }) }}
41
+ @logout=${() => { updateArgs({ ...args, username: "" }) }}
42
+ @bannerDismissed=${(e) => {
43
+ console.log(e)
44
+ alert("banner dismissed")
45
+ }}>
46
+ ${args.branding ? html`<span slot="branding">${args.branding}</span>` : null}
47
+ ${args.name ? html`<span slot="name">${args.name}</span>` : null}
48
+ ${args.center ?
49
+ html`<span slot="center">
50
+ ${args.center}
51
+ </span>`: null}
52
+ ${args.end ?
53
+ html`<span slot="end">
54
+ ${args.end}
55
+ </span>`: null}
56
+ ${args.content || content()}
57
+
58
+ </spectric-page>`
59
+ },
60
+ //args:{content:content}
61
+ argTypes: {
62
+ classificationLevel: { options: Object.values(ClassificationVariants) },
63
+ theme: { options: Object.values(ThemeSelections) },
64
+ ...CSSPropsControls,
65
+ },
66
+ } satisfies Meta<PageProps & PageSlots & CSSProps>;
67
+
68
+ export default meta;
69
+ type Story = StoryObj<PageProps & PageSlots>;
70
+
71
+ const UnclassifiedStyle = { backgroundColor: "green", color: "white" }
72
+
73
+
74
+
75
+ export const WithBannersAndNotifications: Story = {
76
+ args: {
77
+ classificationLevel: "us.unclassified",
78
+ classificationText: "",
79
+ notifications: [{
80
+ bannerId: "mx-banner",
81
+ text: "We will be doing some maintenance",
82
+ headerStyle: { backgroundColor: "var(--spectric-primary)", color: "var(--spectric-text-on-color)" },
83
+ dismissable: true
84
+ }, {
85
+ text: "You cannot dismiss this banner because it it important",
86
+ headerStyle: { backgroundColor: "cadetblue" },
87
+ dismissable: false
88
+ }],
89
+ // More on composing args: https://storybook.js.org/docs/writing-stories/args#args-composition
90
+ ...defaultHeader,
91
+ },
92
+ }
93
+ export const LoggedIn: Story = {
94
+ args: {
95
+ // More on composing args: https://storybook.js.org/docs/writing-stories/args#args-composition
96
+ ...defaultHeader,
97
+ ...HeaderStories.LoggedIn.args,
98
+ },
99
+ };
100
+
101
+ export const LoggedOut: Story = {
102
+ args: {
103
+ ...defaultHeader,
104
+ ...HeaderStories.LoggedOut.args,
105
+ },
106
+ };
107
+
108
+
@@ -0,0 +1,63 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+
3
+ import { SupportedLanguages, type IQueryProps } from '../components/query_bar/QueryBar';
4
+ import '../components';
5
+ import { html } from 'lit';
6
+ import { ifDefined } from 'lit/directives/if-defined.js';
7
+ import { useArgs } from '@storybook/client-api';
8
+ import { filterByColumn } from './fixtures/data';
9
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
10
+ var code = ""
11
+
12
+ const meta = {
13
+ title: 'UI/Query',
14
+ tags: ['autodocs'],
15
+ component: "spectric-query",
16
+ render: (args) => {
17
+ const [_, updateArgs] = useArgs();
18
+ const fakevalues = async (field, text) => {
19
+ if (!args.fields.find(f => f.name === field)) {
20
+ return []
21
+ }
22
+ return filterByColumn(field, text)
23
+ }
24
+ return html`
25
+ <spectric-query
26
+ .fields=${args.fields}
27
+ .getValuesForField=${fakevalues}
28
+ @change=${(e: CustomEvent<any>) => {
29
+ code = e.detail
30
+ updateArgs({ ...args })
31
+ }}
32
+ outputLanguage=${args.outputLanguage}
33
+ >
34
+
35
+ </spectric-query>
36
+ <pre>
37
+ ${JSON.stringify(code, null, 2)}
38
+ </pre>
39
+ `},
40
+ argTypes: {
41
+
42
+ outputLanguage: {
43
+ control: { type: 'select' },
44
+ options: Object.values(SupportedLanguages),
45
+ },
46
+ },
47
+ args: {
48
+ outputLanguage: 'toDSL',
49
+ fields: [{ name: "test", type: "string" }, { name: "test_num", type: "number" }, { name: "test_bool", type: "boolean" }, { name: "modulations", type: "string" }, { name: "time_seen", type: "string", format: "date-time" }]
50
+ },
51
+
52
+ } satisfies Meta<IQueryProps>;
53
+
54
+ export default meta;
55
+ type Story = StoryObj<IQueryProps>;
56
+
57
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
58
+ export const Basic: Story = {
59
+ args: {
60
+ outputLanguage: "toCql"
61
+ },
62
+ };
63
+
@@ -0,0 +1,52 @@
1
+
2
+ import type { Meta, StoryObj } from '@storybook/web-components';
3
+ import { useArgs } from '@storybook/client-api';
4
+ import { Orientations, type SplitViewProps } from '../components/splitview/splitview';
5
+ import '../components/splitview';
6
+ import { html } from 'lit';
7
+ import { ifDefined } from 'lit/directives/if-defined.js';
8
+
9
+ const meta = {
10
+ title: 'UI/SplitView',
11
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
12
+ tags: ['autodocs'],
13
+ component: "spectric-splitview",
14
+ render: (args) => {
15
+ console.log(args)
16
+ const [_, updateArgs] = useArgs();
17
+ return html`
18
+ <spectric-splitview @change=${(e) => {
19
+ updateArgs({ percentage: e.detail.percentage })
20
+ }}
21
+ style="height:150px;display:flex"
22
+ percentage=${ifDefined(args.percentage)}
23
+ ?invisible=${args.invisible}
24
+ orientation=${args.orientation}
25
+ >
26
+ <div style="height:100%;background-color:#eeaaaa">Slot 1</div>
27
+ <div style="background-color:#bfedbf">Slot 2</div>
28
+ </spectric-splitview>
29
+ `
30
+ },
31
+ args: {
32
+ "invisible": false,
33
+ orientation: "horizontal",
34
+ "percentage": 50
35
+ },
36
+ argTypes: {
37
+ invisible: { control: { type: "boolean" } },
38
+ percentage: { control: { type: "number" } },
39
+ orientation: {
40
+ options: Object.values(Orientations),
41
+ control: { type: "inline-radio" }
42
+ },
43
+ }
44
+ } satisfies Meta<SplitViewProps>;
45
+
46
+ export default meta;
47
+ type Story = StoryObj<SplitViewProps>;
48
+
49
+ export const Default: Story = {
50
+ };
51
+
52
+
@@ -0,0 +1,15 @@
1
+ const a = Array(20000)
2
+ .fill(0)
3
+ .map(
4
+ (_, i) =>
5
+ String.fromCharCode(
6
+ i % 4 === 0
7
+ ? 85
8
+ : i % 3 === 0 || i % 2
9
+ ? i % 255
10
+ : Math.floor(Math.random() * 255)
11
+ )
12
+ )
13
+ var len = a.length;
14
+ export const ExampleBits = new Uint8Array(len);
15
+ ExampleBits.set(Array.from(a).map(v => v.charCodeAt(0)));
@@ -0,0 +1,102 @@
1
+
2
+ import { filterByColumn } from "./data";
3
+ import { ExampleBits } from "./Bits";
4
+ import { FieldTypes } from "../../components/query_bar/QueryBar";
5
+
6
+ import { html, LitElement } from 'lit';
7
+
8
+ import { customElement, property, state } from 'lit/decorators.js';
9
+ import "./lorumipsum"
10
+ type Props = {
11
+ frameWidth: number
12
+ }
13
+ @customElement('spectric-storybook-example-content')
14
+ export class SpectricStorybookExampleContent extends LitElement implements Props {
15
+ protected createRenderRoot(): HTMLElement | DocumentFragment {
16
+ return this
17
+ }
18
+ @property({ type: Number, reflect: true })
19
+ frameWidth: number = 10;
20
+ @state()
21
+ dialogOpen: boolean = false;
22
+ render() {
23
+ return html`
24
+ <spectric-dialog
25
+ ?open=${this.dialogOpen} title="Are you sure you want to delete?" ?dismissable=${true} @close=${() => {
26
+ this.dialogOpen = false;
27
+ }}>
28
+ <lorum-ipsum></lorum-ipsum>
29
+ <lorum-ipsum></lorum-ipsum>
30
+ <lorum-ipsum></lorum-ipsum>
31
+ <lorum-ipsum></lorum-ipsum>
32
+ <lorum-ipsum></lorum-ipsum>
33
+ <lorum-ipsum></lorum-ipsum>
34
+ <lorum-ipsum></lorum-ipsum>
35
+ <div slot="footer" style="display:flex;justify-content: space-around;">
36
+ <spectric-button danger @click=${() => {
37
+ this.dialogOpen = false;
38
+ setTimeout(() => alert("deleted"), 300)
39
+ }}>Delete</spectric-button><spectric-button variant="text" @click=${() => {
40
+ this.dialogOpen = false;
41
+ }}>Cancel</spectric-button>
42
+ </div>
43
+ </spectric-dialog>
44
+ <h2>Pages in Spectric UI</h2>
45
+ <p>
46
+ We recommend building UIs with a
47
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
48
+ <strong>component-driven</strong> </a
49
+ >process starting with atomic components and ending with pages.
50
+ </p>
51
+ <spectric-panel>
52
+ Query
53
+ <spectric-query
54
+ .fields=${[{ name: "modulations", type: "string" }, { name: "signal", type: "string" }] as FieldTypes[]}
55
+ .getValuesForField=${filterByColumn}
56
+ @change=${(e: CustomEvent<any>) => {
57
+ }}
58
+ outputLanguage=${"toDSL"}
59
+ >
60
+
61
+ </spectric-query>
62
+ <spectric-panel style="display:flex">
63
+ <spectric-bit-display
64
+ frameWidth=${this.frameWidth}
65
+ scale=${2}
66
+ .arrayBuffer=${ExampleBits.buffer}
67
+ width=${200}
68
+ height=${200}
69
+ >
70
+ </spectric-bit-display>
71
+ <spectric-splitview id="splitview-1">
72
+ <div style="flex-grow:1">
73
+ <h4>Main Settings here</h4>
74
+ <spectric-input variant="number" .value=${this.frameWidth} @change=${(e) => this.frameWidth = e.target.value} placeholder="frameWidth" helpertext="Adjust the framewidth" label="Frame Width" >
75
+ Input label
76
+ </spectric-input>
77
+ <spectric-button size="small" >Submit</spectric-button><spectric-button size="small" variant="secondary">Continue</spectric-button><spectric-button size="small" variant="text">Cancel</spectric-button>
78
+ </div>
79
+ <spectric-panel>
80
+ <h4>OtherSettings here</h4>
81
+
82
+ <spectric-input variant="number" .value=${this.frameWidth} @change=${(e) => this.frameWidth = e.target.value} placeholder="frameWidth" helpertext="Adjust the framewidth" label="Frame Width" style="flex-grow:1">
83
+ Input label
84
+ </spectric-input>
85
+ <spectric-button size="small" >Submit</spectric-button><spectric-button size="small" variant="secondary">Continue</spectric-button><spectric-button size="small" variant="text">Cancel</spectric-button>
86
+ </spectric-panel>
87
+ </spectric-splitview>
88
+
89
+ </spectric-panel>
90
+ <div style="display:flex">
91
+ <span style="flex-grow:1"></span>
92
+ <spectric-button size="small" danger @click=${() => {
93
+ this.dialogOpen = true
94
+ this.requestUpdate()
95
+ }}>Delete</spectric-button>
96
+ <spectric-button size="small" danger variant="secondary">Override</spectric-button>
97
+ <spectric-button size="small" danger variant="text">Disable</spectric-button>
98
+ <spectric-button size="small" variant="text">test</spectric-button>
99
+ </div></spectric-panel>
100
+ `
101
+ }
102
+ }
@@ -0,0 +1,30 @@
1
+
2
+
3
+ export const modulations = [
4
+ "AM",
5
+ "FM",
6
+ "PM",
7
+ "QAM",
8
+ "ASK",
9
+ "FSK",
10
+ "PSK",
11
+ "OFDM",
12
+ "PCM",
13
+ "DPSK"
14
+ ];
15
+ //pulled from https://www.sigidwiki.com/wiki/Category:Digital signals that don't have a space or -
16
+ 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
+ export const filterByColumn = async (field, text) => {
18
+ if (field === "modulations") {
19
+ return modulations.filter(v => v.match(new RegExp(text, "gi")))
20
+ }
21
+ if (field === "signal") {
22
+ return signals.filter(v => v.match(new RegExp(text, "gi")))
23
+ }
24
+ let ipsum = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`
25
+ let values = ['test', 'some value', '10000', ...ipsum.split(" ").map(v => `${v}`)]
26
+ if (text == "") {
27
+ return values
28
+ }
29
+ return values.filter(v => v.includes(text))
30
+ }
@@ -0,0 +1,19 @@
1
+ import { html, LitElement } from "lit-element";
2
+ import { customElement } from "lit/decorators.js";
3
+
4
+ @customElement('lorum-ipsum')
5
+ export class LorumIpsum extends LitElement {
6
+
7
+ render() {
8
+ return html`<p>Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
9
+
10
+ Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
11
+
12
+ Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
13
+
14
+ Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
15
+
16
+ Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.</p>
17
+ `
18
+ }
19
+ }