@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.
- package/.gitlab-ci.yml +28 -0
- package/.nvmrc +1 -0
- package/.storybook/analyze.sh +4 -0
- package/.storybook/main.ts +55 -0
- package/.storybook/preview.ts +42 -0
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +41 -0
- package/README.MD +50 -0
- package/html-include.png +0 -0
- package/package.json +33 -0
- package/src/classes/BitArray.ts +48 -0
- package/src/classes/DisposibleElement.ts +108 -0
- package/src/components/Banner.ts +102 -0
- package/src/components/Bitdisplay.ts +383 -0
- package/src/components/Button.ts +121 -0
- package/src/components/Header.ts +125 -0
- package/src/components/Page.ts +157 -0
- package/src/components/Panel.ts +56 -0
- package/src/components/ThemeProvider.ts +251 -0
- package/src/components/button.css.ts +160 -0
- package/src/components/configurations/classifications.ts +194 -0
- package/src/components/dialog/dialog.css.ts +50 -0
- package/src/components/dialog/dialog.ts +163 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/header.css.ts +38 -0
- package/src/components/index.ts +10 -0
- package/src/components/input.css +75 -0
- package/src/components/input.ts +312 -0
- package/src/components/page.css.ts +158 -0
- package/src/components/panel.css.ts +44 -0
- package/src/components/query_bar/QueryBar.css +48 -0
- package/src/components/query_bar/QueryBar.ts +378 -0
- package/src/components/query_bar/index.ts +2 -0
- package/src/components/query_bar/querylanguage/kuery/ast/_generated_/kuery.js +3186 -0
- package/src/components/query_bar/querylanguage/kuery/ast/ast.ts +113 -0
- package/src/components/query_bar/querylanguage/kuery/ast/index.ts +31 -0
- package/src/components/query_bar/querylanguage/kuery/ast/kuery.peg +417 -0
- package/src/components/query_bar/querylanguage/kuery/functions/and.ts +55 -0
- package/src/components/query_bar/querylanguage/kuery/functions/exists.ts +62 -0
- package/src/components/query_bar/querylanguage/kuery/functions/index.ts +47 -0
- package/src/components/query_bar/querylanguage/kuery/functions/is.ts +211 -0
- package/src/components/query_bar/querylanguage/kuery/functions/nested.ts +63 -0
- package/src/components/query_bar/querylanguage/kuery/functions/not.ts +53 -0
- package/src/components/query_bar/querylanguage/kuery/functions/or.ts +56 -0
- package/src/components/query_bar/querylanguage/kuery/functions/range.ts +163 -0
- package/src/components/query_bar/querylanguage/kuery/functions/utils/get_fields.ts +49 -0
- package/src/components/query_bar/querylanguage/kuery/functions/utils/get_full_field_name_node.ts +87 -0
- package/src/components/query_bar/querylanguage/kuery/index.ts +38 -0
- package/src/components/query_bar/querylanguage/kuery/kuery_syntax_error.ts +76 -0
- package/src/components/query_bar/querylanguage/kuery/node_types/function.ts +75 -0
- package/src/components/query_bar/querylanguage/kuery/node_types/index.ts +46 -0
- package/src/components/query_bar/querylanguage/kuery/node_types/literal.ts +42 -0
- package/src/components/query_bar/querylanguage/kuery/node_types/named_arg.ts +47 -0
- package/src/components/query_bar/querylanguage/kuery/node_types/types.ts +108 -0
- package/src/components/query_bar/querylanguage/kuery/node_types/wildcard.ts +80 -0
- package/src/components/query_bar/querylanguage/kuery/types.ts +52 -0
- package/src/components/query_bar/querylanguage/outputTypes/toCQL.ts +122 -0
- package/src/components/query_bar/querylanguage/outputTypes/toMongo.ts +103 -0
- package/src/components/query_bar/querylanguage/utils.ts +35 -0
- package/src/components/query_bar/types.ts +59 -0
- package/src/components/splitview/index.ts +1 -0
- package/src/components/splitview/splitview.css.ts +66 -0
- package/src/components/splitview/splitview.ts +183 -0
- package/src/components/types.ts +35 -0
- package/src/index.ts +1 -0
- package/src/stories/Banner.stories.ts +46 -0
- package/src/stories/BitDisplay.stories.ts +68 -0
- package/src/stories/Button.stories.ts +138 -0
- package/src/stories/Header.stories.ts +55 -0
- package/src/stories/Page.stories.ts +108 -0
- package/src/stories/QueryBar.stories.ts +63 -0
- package/src/stories/Splitview.stories.ts +52 -0
- package/src/stories/fixtures/Bits.ts +15 -0
- package/src/stories/fixtures/ExampleContent.ts +102 -0
- package/src/stories/fixtures/data.ts +30 -0
- package/src/stories/fixtures/lorumipsum.ts +19 -0
- package/src/stories/input.stories.ts +77 -0
- package/src/stories/tsconfig.json +35 -0
- package/src/utils/debounce.ts +18 -0
- package/src/utils/spread.ts +71 -0
- package/src/vite-env.d.ts +1 -0
- package/test/__init__.py +9 -0
- package/test/elastic.py +9 -0
- package/test/interface.py +16 -0
- package/tsconfig.json +29 -0
- package/vite.config.js +34 -0
- package/vue-example.png +0 -0
- package/vue-include.png +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
|
|
3
|
+
import type { InputProps } from '../components/input';
|
|
4
|
+
import { InputVariants } from "../components/input"
|
|
5
|
+
import '../components';
|
|
6
|
+
import { html } from 'lit';
|
|
7
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
8
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'UI/Input',
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
component: "spectric-input",
|
|
13
|
+
render: (args) => html`
|
|
14
|
+
<spectric-input
|
|
15
|
+
label=${ifDefined(args.label)}
|
|
16
|
+
placeholder=${ifDefined(args.placeholder)}
|
|
17
|
+
helperText=${ifDefined(args.helperText)}
|
|
18
|
+
pattern=${ifDefined(args.pattern)}
|
|
19
|
+
name=${ifDefined(args.name)}
|
|
20
|
+
invalidText=${ifDefined(args.invalidText)}
|
|
21
|
+
maxCount=${ifDefined(args.maxCount)}
|
|
22
|
+
@input=${(e) => { console.log(e) }}
|
|
23
|
+
@change=${e => console.log(e)}
|
|
24
|
+
?showPasswordVisibilityToggle=${args.showPasswordVisibilityToggle}
|
|
25
|
+
?readonly=${args.readonly}
|
|
26
|
+
?disabled=${args.disabled}
|
|
27
|
+
variant=${ifDefined(args.variant)}
|
|
28
|
+
>
|
|
29
|
+
</spectric-input>
|
|
30
|
+
`,
|
|
31
|
+
args: {
|
|
32
|
+
label: 'Input label',
|
|
33
|
+
},
|
|
34
|
+
argTypes: { variant: { options: Object.values(InputVariants) } }
|
|
35
|
+
|
|
36
|
+
} satisfies Meta<InputProps>;
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
type Story = StoryObj<InputProps>;
|
|
40
|
+
|
|
41
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
42
|
+
export const Basic: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
label: 'Input label',
|
|
45
|
+
placeholder: "Type here",
|
|
46
|
+
readonly: false,
|
|
47
|
+
helperText: "Input any text"
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const variants: InputProps['variant'][] = Object.values(InputVariants)
|
|
51
|
+
function toTitleCase(str) {
|
|
52
|
+
return str.replace(
|
|
53
|
+
/\w\S*/g,
|
|
54
|
+
text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase()
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
export const Variants: Story = {
|
|
58
|
+
render: (args) => html`
|
|
59
|
+
${variants.map(v => {
|
|
60
|
+
return html`
|
|
61
|
+
<spectric-input
|
|
62
|
+
label=${ifDefined(toTitleCase(v + " Input"))}
|
|
63
|
+
?disabled=${args.disabled}
|
|
64
|
+
variant=${v}
|
|
65
|
+
|
|
66
|
+
@change=${(e) => { console.log(e) }}
|
|
67
|
+
>
|
|
68
|
+
${v}
|
|
69
|
+
</spectric-input>`
|
|
70
|
+
})}
|
|
71
|
+
`,
|
|
72
|
+
args: {
|
|
73
|
+
showPasswordVisibilityToggle: true,
|
|
74
|
+
variant: "text",
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2021",
|
|
4
|
+
"experimentalDecorators": true,
|
|
5
|
+
"useDefineForClassFields": false,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"lib": [
|
|
8
|
+
"ES2021",
|
|
9
|
+
"DOM",
|
|
10
|
+
"DOM.Iterable"
|
|
11
|
+
],
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
/* Bundler mode */
|
|
14
|
+
"moduleResolution": "Bundler",
|
|
15
|
+
"allowImportingTsExtensions": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
|
+
"moduleDetection": "force",
|
|
18
|
+
"noEmit": true,
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": false,
|
|
21
|
+
/* Linting */
|
|
22
|
+
"strict": true,
|
|
23
|
+
"noUnusedLocals": true,
|
|
24
|
+
"noUnusedParameters": true,
|
|
25
|
+
"noFallthroughCasesInSwitch": true
|
|
26
|
+
},
|
|
27
|
+
"include": [
|
|
28
|
+
"."
|
|
29
|
+
],
|
|
30
|
+
"exclude": [
|
|
31
|
+
"**/*test*"
|
|
32
|
+
],
|
|
33
|
+
"declaration": true,
|
|
34
|
+
"pretty": false
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const debounce = (func: Function, wait: number) => {
|
|
2
|
+
let timeout: number;
|
|
3
|
+
return (...args: any[]) => {
|
|
4
|
+
clearTimeout(timeout);
|
|
5
|
+
timeout = window.setTimeout(() => func.apply(this, args), wait);
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export const debounceAnimation = (func: Function) => {
|
|
9
|
+
var animationFrame: number;
|
|
10
|
+
return (...args: any[]) => {
|
|
11
|
+
if (animationFrame) {
|
|
12
|
+
cancelAnimationFrame(animationFrame)
|
|
13
|
+
}
|
|
14
|
+
animationFrame = requestAnimationFrame(() => {
|
|
15
|
+
func.apply(this, args)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ElementPart, Part } from 'lit';
|
|
2
|
+
import { nothing } from 'lit';
|
|
3
|
+
import { AsyncDirective, directive } from 'lit/async-directive.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { html, render } from 'lit';
|
|
10
|
+
* import { spreadProps } from '@open-wc/lit-helpers';
|
|
11
|
+
*
|
|
12
|
+
* render(
|
|
13
|
+
* html`
|
|
14
|
+
* <div
|
|
15
|
+
* ${spreadProps({
|
|
16
|
+
* prop1: 'prop1',
|
|
17
|
+
* prop2: ['Prop', '2'],
|
|
18
|
+
* prop3: {
|
|
19
|
+
* prop: 3,
|
|
20
|
+
* }
|
|
21
|
+
* })}
|
|
22
|
+
* ></div>
|
|
23
|
+
* `,
|
|
24
|
+
* document.body,
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
export class SpreadPropsDirective extends AsyncDirective {
|
|
28
|
+
host!: EventTarget | object | Element;
|
|
29
|
+
element!: Element;
|
|
30
|
+
prevData: any = {};
|
|
31
|
+
|
|
32
|
+
render(_spreadData: any) {
|
|
33
|
+
return nothing;
|
|
34
|
+
}
|
|
35
|
+
update(part: Part, [spreadData]: Parameters<this['render']>) {
|
|
36
|
+
if (this.element !== (part as ElementPart).element) {
|
|
37
|
+
this.element = (part as ElementPart).element;
|
|
38
|
+
}
|
|
39
|
+
this.host = part.options?.host || this.element;
|
|
40
|
+
this.apply(spreadData);
|
|
41
|
+
this.groom(spreadData);
|
|
42
|
+
this.prevData = { ...spreadData };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
apply(data: any) {
|
|
46
|
+
if (!data) return;
|
|
47
|
+
const { prevData, element } = this;
|
|
48
|
+
for (const key in data) {
|
|
49
|
+
const value = data[key];
|
|
50
|
+
if (value === prevData[key]) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
element[key] = value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
groom(data: any) {
|
|
59
|
+
const { prevData, element } = this;
|
|
60
|
+
if (!prevData) return;
|
|
61
|
+
for (const key in prevData) {
|
|
62
|
+
//@ts-ignore
|
|
63
|
+
if (!data || (!(key in data) && element[key] === prevData[key])) {
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
element[key] = undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const spreadProps = directive(SpreadPropsDirective);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/test/__init__.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from test.elastic import ElasticPersistance
|
|
2
|
+
from typing import Generic,TypeVar,Any
|
|
3
|
+
T = TypeVar("T",callable)
|
|
4
|
+
|
|
5
|
+
config = {"type":"elastic","host":"elastic"}
|
|
6
|
+
def get_persistance(locator:str,cls:T):
|
|
7
|
+
if config['type'] == "elastic":
|
|
8
|
+
return ElasticPersistance[T]({**config,"index":locator},cls)
|
|
9
|
+
raise ValueError("unknown persistance type")
|
package/test/elastic.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from typing import Generic,TypeVar,Any
|
|
2
|
+
|
|
3
|
+
from test import T
|
|
4
|
+
|
|
5
|
+
class IPersistance(Generic[T]):
|
|
6
|
+
def __init__(self,config:Any,cls:T):
|
|
7
|
+
"""
|
|
8
|
+
init function
|
|
9
|
+
"""
|
|
10
|
+
pass
|
|
11
|
+
def get_one_by_id(self,id:str) -> T|None:
|
|
12
|
+
"""
|
|
13
|
+
gets data from database
|
|
14
|
+
"""
|
|
15
|
+
pass
|
|
16
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2021",
|
|
4
|
+
"experimentalDecorators": true,
|
|
5
|
+
"useDefineForClassFields": false,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"lib": ["ES2021", "DOM", "DOM.Iterable"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "Bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"declaration": false,
|
|
18
|
+
|
|
19
|
+
/* Linting */
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true,
|
|
23
|
+
"noFallthroughCasesInSwitch": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["src"],
|
|
26
|
+
"exclude": ["src/stories","**/*test*"],
|
|
27
|
+
"declaration": true,
|
|
28
|
+
"pretty":false
|
|
29
|
+
}
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
import run from "vite-plugin-run";
|
|
5
|
+
// add dts() to the plugins array
|
|
6
|
+
//plugins: [react(), dts()],
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins:[dts({ tsconfigPath: './tsconfig.json' }), run(
|
|
9
|
+
{
|
|
10
|
+
silent:false,
|
|
11
|
+
name: 'Create vscode webcomponent json',
|
|
12
|
+
run: ['npx', 'web-component-analyzer', 'src', '-f', 'vscode', '--outFiles','dist/custom-elements.json'],
|
|
13
|
+
},
|
|
14
|
+
)],
|
|
15
|
+
build: {
|
|
16
|
+
lib: {
|
|
17
|
+
entry: path.resolve(__dirname, 'src'),
|
|
18
|
+
name: 'Spectric-UI',
|
|
19
|
+
fileName: (format) => `index.${format}.js`
|
|
20
|
+
},
|
|
21
|
+
rollupOptions: {
|
|
22
|
+
// make sure to externalize deps that shouldn't be bundled
|
|
23
|
+
// into your library
|
|
24
|
+
//external: ['vue'],
|
|
25
|
+
output: {
|
|
26
|
+
// Provide global variables to use in the UMD build
|
|
27
|
+
// for externalized deps
|
|
28
|
+
// globals: {
|
|
29
|
+
// vue: 'Vue'
|
|
30
|
+
// }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
package/vue-example.png
ADDED
|
Binary file
|
package/vue-include.png
ADDED
|
Binary file
|