revotech-ui-kit 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +29 -0
- package/.eslintrc +10 -0
- package/.storybook/main.ts +17 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.ts +17 -0
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/assets/fonts/Geist/Geist-Black.otf +0 -0
- package/assets/fonts/Geist/Geist-Black.woff2 +0 -0
- package/assets/fonts/Geist/Geist-Bold.otf +0 -0
- package/assets/fonts/Geist/Geist-Bold.woff2 +0 -0
- package/assets/fonts/Geist/Geist-Light.otf +0 -0
- package/assets/fonts/Geist/Geist-Light.woff2 +0 -0
- package/assets/fonts/Geist/Geist-Medium.otf +0 -0
- package/assets/fonts/Geist/Geist-Medium.woff2 +0 -0
- package/assets/fonts/Geist/Geist-Regular.otf +0 -0
- package/assets/fonts/Geist/Geist-Regular.woff2 +0 -0
- package/assets/fonts/Geist/Geist-SemiBold.otf +0 -0
- package/assets/fonts/Geist/Geist-SemiBold.woff2 +0 -0
- package/assets/fonts/Geist/Geist-Thin.otf +0 -0
- package/assets/fonts/Geist/Geist-Thin.woff2 +0 -0
- package/assets/fonts/Geist/Geist-UltraBlack.otf +0 -0
- package/assets/fonts/Geist/Geist-UltraBlack.woff2 +0 -0
- package/assets/fonts/Geist/Geist-UltraLight.otf +0 -0
- package/assets/fonts/Geist/Geist-UltraLight.woff2 +0 -0
- package/assets/fonts/Geist/GeistVariableVF.ttf +0 -0
- package/assets/fonts/Geist/GeistVariableVF.woff2 +0 -0
- package/assets/fonts/Geist/LICENSE.TXT +92 -0
- package/assets/open-wc-logo.svg +29 -0
- package/index.html +362 -0
- package/package.json +117 -0
- package/rollup.config.js +71 -0
- package/src/components/atoms/button/button.atom.ts +39 -0
- package/src/components/atoms/button/button.stories.ts +186 -0
- package/src/components/atoms/button/button.style.ts +31 -0
- package/src/components/atoms/button/button.type.ts +10 -0
- package/src/components/atoms/checkbox/checkbox.atom.ts +62 -0
- package/src/components/atoms/checkbox/checkbox.stories.ts +42 -0
- package/src/components/atoms/command-empty/command-empty.atom.ts +44 -0
- package/src/components/atoms/command-group/command-group.atom.ts +60 -0
- package/src/components/atoms/command-item/command-item.atom.ts +74 -0
- package/src/components/atoms/command-list/command-list.atom.ts +37 -0
- package/src/components/atoms/command-separator/command-separator.atom.ts +42 -0
- package/src/components/atoms/dialog/dialog.atom.ts +301 -0
- package/src/components/atoms/dialog/dialog.stories.ts +86 -0
- package/src/components/atoms/index.ts +10 -0
- package/src/components/atoms/input/input.atom.ts +34 -0
- package/src/components/atoms/input/input.stories.ts +89 -0
- package/src/components/atoms/input/input.type.ts +24 -0
- package/src/components/atoms/label/label.atom.ts +40 -0
- package/src/components/atoms/label/label.stories.ts +18 -0
- package/src/components/atoms/label/label.style.ts +5 -0
- package/src/components/command/command.stories.ts +154 -0
- package/src/components/command/command.ts +391 -0
- package/src/components/index.ts +2 -0
- package/src/components/molecules/command/command.molecules.ts +31 -0
- package/src/components/molecules/command-input/command-input.atom.ts +130 -0
- package/src/components/molecules/index.ts +1 -0
- package/src/components/popover.ts +247 -0
- package/src/globals.css +1806 -0
- package/src/helpers/index.ts +2 -0
- package/src/helpers/mouse-conroller.helper.ts +42 -0
- package/src/helpers/style.helpers.ts +6 -0
- package/src/interfaces/actionable.interface.ts +6 -0
- package/src/interfaces/atomic.interface.ts +6 -0
- package/src/interfaces/changeable.interface.ts +14 -0
- package/src/interfaces/child-support-atomic.interface.ts +5 -0
- package/src/interfaces/index.ts +6 -0
- package/src/interfaces/intractable.interface.ts +6 -0
- package/src/interfaces/variant.interface.ts +3 -0
- package/src/lib/index.ts +0 -0
- package/src/lib/next/next.lib.ts +0 -0
- package/src/lib/react/react.lib.ts +0 -0
- package/src/styles/index.ts +1 -0
- package/src/styles/tw.styles.ts +1867 -0
- package/src/tailwind-lib.css +95 -0
- package/src/wc-ui-app.ts +81 -0
- package/tailwind.config.js +81 -0
- package/test/wc-ui-app.test.ts +22 -0
- package/tsconfig.json +25 -0
- package/web-dev-server.config.mjs +26 -0
- package/web-test-runner.config.mjs +41 -0
@@ -0,0 +1,186 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
2
|
+
import { action } from '@storybook/addon-actions';
|
3
|
+
import { html } from 'lit';
|
4
|
+
import './button.atom';
|
5
|
+
|
6
|
+
const meta: Meta = {
|
7
|
+
component: 'components/button',
|
8
|
+
tags: ['autodocs'],
|
9
|
+
argTypes: {
|
10
|
+
variant: {
|
11
|
+
control: {
|
12
|
+
type: 'select',
|
13
|
+
},
|
14
|
+
options: [
|
15
|
+
'default',
|
16
|
+
'destructive',
|
17
|
+
'outline',
|
18
|
+
'secondary',
|
19
|
+
'ghost',
|
20
|
+
'link',
|
21
|
+
],
|
22
|
+
},
|
23
|
+
size: {
|
24
|
+
control: {
|
25
|
+
type: 'select',
|
26
|
+
},
|
27
|
+
options: ['default', 'sm', 'lg', 'icon'],
|
28
|
+
},
|
29
|
+
disabled: { control: 'boolean' },
|
30
|
+
onClick: { action: 'button-click' },
|
31
|
+
},
|
32
|
+
};
|
33
|
+
export default meta;
|
34
|
+
type Story = StoryObj;
|
35
|
+
|
36
|
+
const logger = () => {
|
37
|
+
console.log('Btn Clicked!');
|
38
|
+
};
|
39
|
+
|
40
|
+
export const Default: Story = {
|
41
|
+
args: {
|
42
|
+
label: 'Default',
|
43
|
+
variant: 'default',
|
44
|
+
size: 'lg',
|
45
|
+
disabled: false,
|
46
|
+
},
|
47
|
+
|
48
|
+
render: ({ label, variant, size, disabled }) =>
|
49
|
+
html`<rtg-button
|
50
|
+
.onClick=${action('button-click')}
|
51
|
+
variant=${variant}
|
52
|
+
size=${size}
|
53
|
+
?disabled=${disabled}
|
54
|
+
>
|
55
|
+
${label}</rtg-button
|
56
|
+
>`,
|
57
|
+
};
|
58
|
+
|
59
|
+
export const Primary: Story = {
|
60
|
+
args: {
|
61
|
+
label: 'Primary',
|
62
|
+
variant: 'default',
|
63
|
+
size: 'lg',
|
64
|
+
disabled: false,
|
65
|
+
},
|
66
|
+
render: ({ label, variant, size, disabled }) =>
|
67
|
+
html`<rtg-button
|
68
|
+
.onClick=${logger}
|
69
|
+
variant=${variant}
|
70
|
+
size=${size}
|
71
|
+
?disabled=${disabled}
|
72
|
+
>${label}</rtg-button
|
73
|
+
> `,
|
74
|
+
};
|
75
|
+
|
76
|
+
export const Destructive: Story = {
|
77
|
+
args: {
|
78
|
+
label: 'Destructive',
|
79
|
+
variant: 'destructive',
|
80
|
+
size: 'lg',
|
81
|
+
disabled: false,
|
82
|
+
},
|
83
|
+
render: ({ label, variant, size, disabled }) =>
|
84
|
+
html`<rtg-button
|
85
|
+
.onClick=${logger}
|
86
|
+
variant=${variant}
|
87
|
+
size=${size}
|
88
|
+
?disabled=${disabled}
|
89
|
+
>${label}</rtg-button
|
90
|
+
> `,
|
91
|
+
};
|
92
|
+
|
93
|
+
export const Outline: Story = {
|
94
|
+
args: {
|
95
|
+
label: 'Outline',
|
96
|
+
variant: 'outline',
|
97
|
+
size: 'lg',
|
98
|
+
disabled: false,
|
99
|
+
},
|
100
|
+
render: ({ label, variant, size, disabled }) =>
|
101
|
+
html`<rtg-button
|
102
|
+
.onClick=${logger}
|
103
|
+
variant=${variant}
|
104
|
+
size=${size}
|
105
|
+
?disabled=${disabled}
|
106
|
+
>${label}</rtg-button
|
107
|
+
> `,
|
108
|
+
};
|
109
|
+
|
110
|
+
export const Ghost: Story = {
|
111
|
+
args: {
|
112
|
+
variant: 'ghost',
|
113
|
+
label: 'Ghost',
|
114
|
+
size: 'lg',
|
115
|
+
disabled: false,
|
116
|
+
},
|
117
|
+
render: ({ label, variant, size, disabled }) =>
|
118
|
+
html`<rtg-button
|
119
|
+
.onClick=${logger}
|
120
|
+
variant=${variant}
|
121
|
+
size=${size}
|
122
|
+
?disabled=${disabled}
|
123
|
+
>${label}</rtg-button
|
124
|
+
> `,
|
125
|
+
};
|
126
|
+
|
127
|
+
export const Link: Story = {
|
128
|
+
args: {
|
129
|
+
variant: 'link',
|
130
|
+
label: 'Link',
|
131
|
+
size: 'lg',
|
132
|
+
disabled: false,
|
133
|
+
},
|
134
|
+
render: ({ label, variant, size, disabled }) =>
|
135
|
+
html`<rtg-button
|
136
|
+
.onClick=${logger}
|
137
|
+
variant=${variant}
|
138
|
+
size=${size}
|
139
|
+
?disabled=${disabled}
|
140
|
+
>${label}</rtg-button
|
141
|
+
> `,
|
142
|
+
};
|
143
|
+
|
144
|
+
export const IconButton: Story = {
|
145
|
+
args: {
|
146
|
+
variant: 'outline',
|
147
|
+
size: 'icon',
|
148
|
+
disabled: false,
|
149
|
+
},
|
150
|
+
render: ({ variant, size }) =>
|
151
|
+
html`<rtg-button .onClick=${logger} variant=${variant} size=${size}>
|
152
|
+
<iconify-icon icon="mdi:home"></iconify-icon>
|
153
|
+
</rtg-button> `,
|
154
|
+
};
|
155
|
+
|
156
|
+
export const ButtonWithIcon: Story = {
|
157
|
+
args: {
|
158
|
+
label: 'Home Page',
|
159
|
+
variant: 'default',
|
160
|
+
size: 'default',
|
161
|
+
disabled: false,
|
162
|
+
},
|
163
|
+
render: ({ variant, label, size, disabled }) =>
|
164
|
+
html`
|
165
|
+
<rtg-button varian=${variant} ?disabled=${disabled} size=${size}
|
166
|
+
><iconify-icon class="mr-2" icon="mdi:home"></iconify-icon>
|
167
|
+
${label}</rtg-button
|
168
|
+
>
|
169
|
+
`,
|
170
|
+
};
|
171
|
+
|
172
|
+
export const animationButton: Story = {
|
173
|
+
args: {
|
174
|
+
label: 'Home Page',
|
175
|
+
variant: 'default',
|
176
|
+
size: 'default',
|
177
|
+
disabled: true,
|
178
|
+
},
|
179
|
+
render: ({ variant, label, size, disabled }) =>
|
180
|
+
html`
|
181
|
+
<rtg-button varian=${variant} ?disabled=${disabled} size=${size}
|
182
|
+
><iconify-icon class="mr-2 animate-spin" icon="mdi:home"></iconify-icon>
|
183
|
+
${label}</rtg-button
|
184
|
+
>
|
185
|
+
`,
|
186
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
2
|
+
|
3
|
+
export const buttonStyle = cva(
|
4
|
+
'inline-flex items-center justify-center whitespace-nowrap rounded-sm text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
|
5
|
+
{
|
6
|
+
variants: {
|
7
|
+
variant: {
|
8
|
+
default:
|
9
|
+
'bg-primary text-primary-foreground shadow hover:bg-primary/90',
|
10
|
+
destructive:
|
11
|
+
'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
|
12
|
+
outline:
|
13
|
+
'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
|
14
|
+
secondary:
|
15
|
+
'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
|
16
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
17
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
18
|
+
},
|
19
|
+
size: {
|
20
|
+
default: 'h-8 px-4 py-2',
|
21
|
+
sm: 'h-7 rounded-sm px-3 text-xs',
|
22
|
+
lg: 'h-9 rounded-sm px-8',
|
23
|
+
icon: 'h-8 w-8',
|
24
|
+
},
|
25
|
+
},
|
26
|
+
defaultVariants: {
|
27
|
+
variant: 'default',
|
28
|
+
size: 'default',
|
29
|
+
},
|
30
|
+
}
|
31
|
+
);
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { LitElement, html, css, nothing } from 'lit';
|
2
|
+
import { property, customElement } from 'lit/decorators.js';
|
3
|
+
import { cn } from '@/helpers';
|
4
|
+
import { TWStyles } from '@/styles';
|
5
|
+
|
6
|
+
@customElement('rtg-checkbox')
|
7
|
+
export class Checkbox extends LitElement {
|
8
|
+
@property({ type: Boolean }) disabled = false;
|
9
|
+
|
10
|
+
@property({ type: Boolean }) checked = false;
|
11
|
+
|
12
|
+
static styles = [css``, TWStyles];
|
13
|
+
|
14
|
+
private _onClick(e: Event) {
|
15
|
+
if (e.defaultPrevented) return;
|
16
|
+
this.checked = !this.checked;
|
17
|
+
}
|
18
|
+
|
19
|
+
public click() {
|
20
|
+
this.checked = !this.checked;
|
21
|
+
}
|
22
|
+
|
23
|
+
//
|
24
|
+
render() {
|
25
|
+
return html`
|
26
|
+
<button
|
27
|
+
type="button"
|
28
|
+
role="checkbox"
|
29
|
+
aria-checked="${this.checked}"
|
30
|
+
data-state="${this.checked ? 'checked' : 'unchecked'}"
|
31
|
+
value="on"
|
32
|
+
?disabled=${this.disabled}
|
33
|
+
@click="${this._onClick}"
|
34
|
+
class="${cn(
|
35
|
+
'peer h-4 w-4 align-middle shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
|
36
|
+
this.className
|
37
|
+
)}"
|
38
|
+
>
|
39
|
+
${this.checked
|
40
|
+
? html`<span
|
41
|
+
data-state="checked"
|
42
|
+
class="flex items-center justify-center text-current"
|
43
|
+
style="pointer-events: none;"
|
44
|
+
><svg
|
45
|
+
xmlns="http://www.w3.org/2000/svg"
|
46
|
+
width="24"
|
47
|
+
height="24"
|
48
|
+
viewBox="0 0 24 24"
|
49
|
+
fill="none"
|
50
|
+
stroke="currentColor"
|
51
|
+
stroke-width="3"
|
52
|
+
stroke-linecap="round"
|
53
|
+
stroke-linejoin="round"
|
54
|
+
class="h-4 w-4"
|
55
|
+
>
|
56
|
+
<polyline points="20 6 9 17 4 12"></polyline></svg
|
57
|
+
></span>`
|
58
|
+
: nothing}
|
59
|
+
</button>
|
60
|
+
`;
|
61
|
+
}
|
62
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/web-components';
|
2
|
+
import { html } from 'lit';
|
3
|
+
import './checkbox.atom';
|
4
|
+
|
5
|
+
export default {
|
6
|
+
title: 'Components/Checkbox',
|
7
|
+
component: 'rtg-checkbox',
|
8
|
+
tags: ['autodocs'],
|
9
|
+
argTypes: {
|
10
|
+
disabled: { control: 'boolean' },
|
11
|
+
checked: { control: 'boolean' },
|
12
|
+
},
|
13
|
+
} as Meta;
|
14
|
+
|
15
|
+
const Template: StoryFn = (args: any) =>
|
16
|
+
html` <rtg-checkbox
|
17
|
+
id="terms"
|
18
|
+
?disabled=${args.disabled}
|
19
|
+
?checked=${args.checked}
|
20
|
+
></rtg-checkbox>
|
21
|
+
<rtg-label for="terms">${args.label}</rtg-label>`;
|
22
|
+
|
23
|
+
export const Default = Template.bind({});
|
24
|
+
Default.args = {
|
25
|
+
disabled: false,
|
26
|
+
checked: false,
|
27
|
+
label: 'Accept terms and conditions',
|
28
|
+
};
|
29
|
+
|
30
|
+
export const Checked = Template.bind({});
|
31
|
+
Checked.args = {
|
32
|
+
disabled: false,
|
33
|
+
checked: true,
|
34
|
+
label: 'Checked',
|
35
|
+
};
|
36
|
+
|
37
|
+
export const Disabled = Template.bind({});
|
38
|
+
Disabled.args = {
|
39
|
+
disabled: true,
|
40
|
+
checked: false,
|
41
|
+
label: 'Disabled',
|
42
|
+
};
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { LitElement, html, css, nothing } from 'lit';
|
2
|
+
import { property, customElement } from 'lit/decorators.js';
|
3
|
+
import { cn } from '@/helpers';
|
4
|
+
import { TWStyles } from '@/styles';
|
5
|
+
|
6
|
+
@customElement('rtg-command-empty')
|
7
|
+
export class CommandEmpty extends LitElement {
|
8
|
+
@property({ type: String }) _id = '';
|
9
|
+
|
10
|
+
@property({ attribute: 'aria-hidden', type: String }) _hidden = 'true';
|
11
|
+
|
12
|
+
private static _counter = 0;
|
13
|
+
|
14
|
+
static styles = [css``, TWStyles];
|
15
|
+
|
16
|
+
private get identifier() {
|
17
|
+
if (this._id !== '') {
|
18
|
+
return this._id;
|
19
|
+
}
|
20
|
+
const parent =
|
21
|
+
this.parentElement?.shadowRoot?.querySelector('div[rtgcmd-list]');
|
22
|
+
if (parent) {
|
23
|
+
this._id = `${parent.getAttribute('id')}e${CommandEmpty._counter++}`;
|
24
|
+
} else {
|
25
|
+
this._id = `rtgcmdrxlxe${CommandEmpty._counter++}`;
|
26
|
+
}
|
27
|
+
return this._id;
|
28
|
+
}
|
29
|
+
|
30
|
+
render() {
|
31
|
+
return html`${this._hidden === 'true'
|
32
|
+
? nothing
|
33
|
+
: html`
|
34
|
+
<div
|
35
|
+
class="${cn('py-6 text-center text-sm', this.className)}"
|
36
|
+
rtgcmd-empty
|
37
|
+
role="presentation"
|
38
|
+
id="${this.identifier}"
|
39
|
+
>
|
40
|
+
<slot></slot>
|
41
|
+
</div>
|
42
|
+
`}`;
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { LitElement, html, css, nothing } from 'lit';
|
2
|
+
import { property, customElement } from 'lit/decorators.js';
|
3
|
+
import { TWStyles } from '@/styles';
|
4
|
+
|
5
|
+
@customElement('rtg-command-group')
|
6
|
+
export class CommandGroup extends LitElement {
|
7
|
+
@property({ type: String }) heading = '';
|
8
|
+
|
9
|
+
@property({ attribute: 'id', type: String }) _id = '';
|
10
|
+
|
11
|
+
@property({ attribute: 'aria-hidden', type: String }) _hidden = '';
|
12
|
+
|
13
|
+
private static _counter = 0;
|
14
|
+
|
15
|
+
static styles = [css``, TWStyles];
|
16
|
+
|
17
|
+
private get identifier() {
|
18
|
+
if (this._id !== '') {
|
19
|
+
return this._id;
|
20
|
+
}
|
21
|
+
const parent =
|
22
|
+
this.parentElement?.shadowRoot?.querySelector('div[rtgcmd-list]');
|
23
|
+
if (parent) {
|
24
|
+
this._id = `${parent.getAttribute('id')}g${CommandGroup._counter++}`;
|
25
|
+
} else {
|
26
|
+
this._id = `rtgcmdrxlxg${CommandGroup._counter++}`;
|
27
|
+
}
|
28
|
+
return this._id;
|
29
|
+
}
|
30
|
+
|
31
|
+
render() {
|
32
|
+
const className =
|
33
|
+
'overflow-hidden p-1 text-foreground [&_[rtgcmd-group-heading]]:px-2 [&_[rtgcmd-group-heading]]:py-1.5 [&_[rtgcmd-group-heading]]:text-xs [&_[rtgcmd-group-heading]]:font-medium [&_[rtgcmd-group-heading]]:text-muted-foreground';
|
34
|
+
return html`${this._hidden === 'true'
|
35
|
+
? nothing
|
36
|
+
: html`
|
37
|
+
<div
|
38
|
+
class="${className}"
|
39
|
+
rtgcmd-group
|
40
|
+
role="presentation"
|
41
|
+
id="${this.identifier}"
|
42
|
+
>
|
43
|
+
<div
|
44
|
+
rtgcmd-group-heading
|
45
|
+
aria-hidden="true"
|
46
|
+
id="${this.identifier}h"
|
47
|
+
>
|
48
|
+
${this.heading}
|
49
|
+
</div>
|
50
|
+
<div
|
51
|
+
rtgcmd-group-items
|
52
|
+
role="group"
|
53
|
+
aria-labelledby="${this.identifier}h"
|
54
|
+
>
|
55
|
+
<slot></slot>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
`}`;
|
59
|
+
}
|
60
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import { LitElement, html, css, nothing } from 'lit';
|
2
|
+
import {
|
3
|
+
property,
|
4
|
+
customElement,
|
5
|
+
queryAssignedElements,
|
6
|
+
} from 'lit/decorators.js';
|
7
|
+
import { cn } from '@/helpers';
|
8
|
+
import { TWStyles } from '@/styles';
|
9
|
+
|
10
|
+
@customElement('rtg-command-item')
|
11
|
+
export class CommandItem extends LitElement {
|
12
|
+
@property({ type: String }) _id = '';
|
13
|
+
|
14
|
+
@property({ attribute: 'aria-hidden', type: String }) _hidden = '';
|
15
|
+
|
16
|
+
private static _counter = 0;
|
17
|
+
|
18
|
+
static styles = [css``, TWStyles];
|
19
|
+
|
20
|
+
private get identifier() {
|
21
|
+
if (this._id !== '') {
|
22
|
+
return this._id;
|
23
|
+
}
|
24
|
+
const parent =
|
25
|
+
this.parentElement?.shadowRoot?.querySelector('div[rtgcmd-group]');
|
26
|
+
if (parent) {
|
27
|
+
this._id = `${parent.getAttribute('id')}li${CommandItem._counter++}`;
|
28
|
+
} else {
|
29
|
+
this._id = `rtgcmdrxgxli${CommandItem._counter++}`;
|
30
|
+
}
|
31
|
+
return this._id;
|
32
|
+
}
|
33
|
+
|
34
|
+
@property({ attribute: 'data-value', type: String })
|
35
|
+
public get value() {
|
36
|
+
return this.textContent?.trim() || '';
|
37
|
+
}
|
38
|
+
|
39
|
+
@property({ type: Boolean }) selected = false;
|
40
|
+
|
41
|
+
private handleMouseEvent(e: Event) {
|
42
|
+
if (e.type === 'mouseover' || e.type === 'focus') {
|
43
|
+
this.selected = true;
|
44
|
+
}
|
45
|
+
if (e.type === 'mouseleave') {
|
46
|
+
this.selected = false;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
render() {
|
51
|
+
return html` ${this._hidden === 'true'
|
52
|
+
? nothing
|
53
|
+
: html`
|
54
|
+
<div
|
55
|
+
class="${cn(
|
56
|
+
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
57
|
+
this.className
|
58
|
+
)}"
|
59
|
+
@mouseover="${this.handleMouseEvent}"
|
60
|
+
@mouseleave="${this.handleMouseEvent}"
|
61
|
+
@focus="${this.handleMouseEvent}"
|
62
|
+
rtgcmd-item
|
63
|
+
role="option"
|
64
|
+
aria-selected="${this.selected}"
|
65
|
+
data-selected="${this.selected}"
|
66
|
+
data-value="${this.value}"
|
67
|
+
id="${this.identifier}"
|
68
|
+
aria-hidden="${this.hidden}"
|
69
|
+
>
|
70
|
+
<slot></slot>
|
71
|
+
</div>
|
72
|
+
`}`;
|
73
|
+
}
|
74
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
3
|
+
import { cn } from '@/helpers';
|
4
|
+
import { TWStyles } from '@/styles';
|
5
|
+
|
6
|
+
@customElement('rtg-command-list')
|
7
|
+
export class CommandList extends LitElement {
|
8
|
+
static styles = [css``, TWStyles];
|
9
|
+
|
10
|
+
private get identifier() {
|
11
|
+
const parent =
|
12
|
+
this.parentElement?.shadowRoot?.querySelector('div[rtgcmd-root]');
|
13
|
+
if (parent) {
|
14
|
+
return `${parent.getAttribute('id')}l`;
|
15
|
+
}
|
16
|
+
return `rtgcmdrxl`;
|
17
|
+
}
|
18
|
+
|
19
|
+
render() {
|
20
|
+
return html`
|
21
|
+
<div
|
22
|
+
class="${cn(
|
23
|
+
'max-h-[300px] overflow-y-auto overflow-x-hidden',
|
24
|
+
this.className
|
25
|
+
)}"
|
26
|
+
role="listbox"
|
27
|
+
id="${this.identifier}"
|
28
|
+
style="--rtgcmd-list-height: 265.0px;"
|
29
|
+
rtgcmd-list
|
30
|
+
>
|
31
|
+
<div>
|
32
|
+
<slot></slot>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
`;
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { LitElement, html, css, nothing } from 'lit';
|
2
|
+
import { property, customElement } from 'lit/decorators.js';
|
3
|
+
import { cn } from '@/helpers';
|
4
|
+
import { TWStyles } from '@/styles';
|
5
|
+
|
6
|
+
@customElement('rtg-command-separator')
|
7
|
+
export class CommandSeparator extends LitElement {
|
8
|
+
@property({ type: String }) _id = '';
|
9
|
+
|
10
|
+
@property({ attribute: 'aria-hidden', type: String }) _hidden = '';
|
11
|
+
|
12
|
+
private static _counter = 0;
|
13
|
+
|
14
|
+
static styles = [css``, TWStyles];
|
15
|
+
|
16
|
+
private get identifier() {
|
17
|
+
if (this._id !== '') {
|
18
|
+
return this._id;
|
19
|
+
}
|
20
|
+
const parent =
|
21
|
+
this.parentElement?.shadowRoot?.querySelector('div[rtgcmd-list]');
|
22
|
+
if (parent) {
|
23
|
+
this._id = `${parent.getAttribute('id')}s${CommandSeparator._counter++}`;
|
24
|
+
} else {
|
25
|
+
this._id = `rtgcmdrxlxs${CommandSeparator._counter++}`;
|
26
|
+
}
|
27
|
+
return this._id;
|
28
|
+
}
|
29
|
+
|
30
|
+
render() {
|
31
|
+
return html`${this._hidden === 'true'
|
32
|
+
? nothing
|
33
|
+
: html`
|
34
|
+
<div
|
35
|
+
class="${cn('-mx-1 h-px bg-border', this.className)}"
|
36
|
+
rtgcmd-separator
|
37
|
+
role="separator"
|
38
|
+
id="${this.identifier}"
|
39
|
+
></div>
|
40
|
+
`}`;
|
41
|
+
}
|
42
|
+
}
|