revotech-ui-kit 0.0.5-beta → 0.0.7-beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. package/dist/index.ts +1 -1
  2. package/dist/rollup-plugin-html-noop.js +1 -0
  3. package/dist/sw.js +1 -1
  4. package/dist/sw.js.map +1 -1
  5. package/package.json +5 -4
  6. package/.editorconfig +0 -29
  7. package/.eslintrc +0 -10
  8. package/.github/workflows/deploy-storybook.yml +0 -107
  9. package/.storybook/main.ts +0 -17
  10. package/.storybook/preview-head.html +0 -1
  11. package/.storybook/preview.ts +0 -17
  12. package/assets/fonts/Geist/Geist-Black.otf +0 -0
  13. package/assets/fonts/Geist/Geist-Black.woff2 +0 -0
  14. package/assets/fonts/Geist/Geist-Bold.otf +0 -0
  15. package/assets/fonts/Geist/Geist-Bold.woff2 +0 -0
  16. package/assets/fonts/Geist/Geist-Light.otf +0 -0
  17. package/assets/fonts/Geist/Geist-Light.woff2 +0 -0
  18. package/assets/fonts/Geist/Geist-Medium.otf +0 -0
  19. package/assets/fonts/Geist/Geist-Medium.woff2 +0 -0
  20. package/assets/fonts/Geist/Geist-Regular.otf +0 -0
  21. package/assets/fonts/Geist/Geist-Regular.woff2 +0 -0
  22. package/assets/fonts/Geist/Geist-SemiBold.otf +0 -0
  23. package/assets/fonts/Geist/Geist-SemiBold.woff2 +0 -0
  24. package/assets/fonts/Geist/Geist-Thin.otf +0 -0
  25. package/assets/fonts/Geist/Geist-Thin.woff2 +0 -0
  26. package/assets/fonts/Geist/Geist-UltraBlack.otf +0 -0
  27. package/assets/fonts/Geist/Geist-UltraBlack.woff2 +0 -0
  28. package/assets/fonts/Geist/Geist-UltraLight.otf +0 -0
  29. package/assets/fonts/Geist/Geist-UltraLight.woff2 +0 -0
  30. package/assets/fonts/Geist/GeistVariableVF.ttf +0 -0
  31. package/assets/fonts/Geist/GeistVariableVF.woff2 +0 -0
  32. package/assets/fonts/Geist/LICENSE.TXT +0 -92
  33. package/assets/open-wc-logo.svg +0 -29
  34. package/assume_role.sh +0 -18
  35. package/index.html +0 -314
  36. package/rollup.config.js +0 -83
  37. package/src/assets/icons/arrows.icon.ts +0 -20
  38. package/src/assets/icons/index.ts +0 -3
  39. package/src/assets/icons/search.icon.ts +0 -19
  40. package/src/assets/icons/tick.icon.ts +0 -20
  41. package/src/chai-custom.d.ts +0 -0
  42. package/src/components/atoms/alert/alert-description.ts +0 -15
  43. package/src/components/atoms/alert/alert-title.ts +0 -17
  44. package/src/components/atoms/alert/alert.atom.ts +0 -55
  45. package/src/components/atoms/alert/alert.stories.ts +0 -71
  46. package/src/components/atoms/alert/alert.styles.ts +0 -21
  47. package/src/components/atoms/alert/alert.types.ts +0 -1
  48. package/src/components/atoms/badge/badge.atom.ts +0 -40
  49. package/src/components/atoms/badge/badge.stories.ts +0 -118
  50. package/src/components/atoms/badge/badge.style.ts +0 -24
  51. package/src/components/atoms/badge/badge.type.ts +0 -7
  52. package/src/components/atoms/button/button.atom.ts +0 -59
  53. package/src/components/atoms/button/button.stories.ts +0 -224
  54. package/src/components/atoms/button/button.style.ts +0 -31
  55. package/src/components/atoms/button/button.type.ts +0 -10
  56. package/src/components/atoms/card/card-content.ts +0 -15
  57. package/src/components/atoms/card/card-description.ts +0 -15
  58. package/src/components/atoms/card/card-footer.ts +0 -15
  59. package/src/components/atoms/card/card-header.ts +0 -15
  60. package/src/components/atoms/card/card-title.ts +0 -15
  61. package/src/components/atoms/card/card.atom.ts +0 -31
  62. package/src/components/atoms/card/card.stories.ts +0 -149
  63. package/src/components/atoms/checkbox/checkbox.atom.ts +0 -76
  64. package/src/components/atoms/checkbox/checkbox.stories.ts +0 -309
  65. package/src/components/atoms/checkbox/checkbox.style.ts +0 -5
  66. package/src/components/atoms/checkbox/checkbox.type.ts +0 -24
  67. package/src/components/atoms/combo-box/combo-box-input.ts +0 -33
  68. package/src/components/atoms/combo-box/combo-box-item.ts +0 -59
  69. package/src/components/atoms/combo-box/combo-box-list.ts +0 -57
  70. package/src/components/atoms/combo-box/combo-box.atom.ts +0 -187
  71. package/src/components/atoms/combo-box/combo-box.stories.ts +0 -95
  72. package/src/components/atoms/command-empty/command-empty.atom.ts +0 -44
  73. package/src/components/atoms/command-group/command-group.atom.ts +0 -60
  74. package/src/components/atoms/command-item/command-item.atom.ts +0 -74
  75. package/src/components/atoms/command-list/command-list.atom.ts +0 -37
  76. package/src/components/atoms/command-separator/command-separator.atom.ts +0 -42
  77. package/src/components/atoms/dialog/dialog-close.ts +0 -50
  78. package/src/components/atoms/dialog/dialog-content.ts +0 -71
  79. package/src/components/atoms/dialog/dialog-footer.ts +0 -22
  80. package/src/components/atoms/dialog/dialog-header.ts +0 -36
  81. package/src/components/atoms/dialog/dialog-overly.ts +0 -20
  82. package/src/components/atoms/dialog/dialog-trigger.ts +0 -54
  83. package/src/components/atoms/dialog/dialog.atom.ts +0 -78
  84. package/src/components/atoms/dialog/dialog.stories.ts +0 -93
  85. package/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.ts +0 -106
  86. package/src/components/atoms/dropdownMenu/dropdown-menu-content.ts +0 -79
  87. package/src/components/atoms/dropdownMenu/dropdown-menu-group.ts +0 -60
  88. package/src/components/atoms/dropdownMenu/dropdown-menu-item.ts +0 -74
  89. package/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.ts +0 -107
  90. package/src/components/atoms/dropdownMenu/dropdown-menu-seperator.ts +0 -44
  91. package/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.ts +0 -17
  92. package/src/components/atoms/dropdownMenu/dropdown-menu.atom.ts +0 -84
  93. package/src/components/atoms/dropdownMenu/dropdownMenu.stories.ts +0 -220
  94. package/src/components/atoms/dropdownMenu/dropdownMenu.style.ts +0 -7
  95. package/src/components/atoms/index.ts +0 -13
  96. package/src/components/atoms/input/input.atom.ts +0 -88
  97. package/src/components/atoms/input/input.stories.ts +0 -451
  98. package/src/components/atoms/input/input.styles.ts +0 -2
  99. package/src/components/atoms/input/input.type.ts +0 -58
  100. package/src/components/atoms/label/label.atom.ts +0 -64
  101. package/src/components/atoms/label/label.stories.ts +0 -102
  102. package/src/components/atoms/label/label.style.ts +0 -5
  103. package/src/components/atoms/popover/popover-content.ts +0 -58
  104. package/src/components/atoms/popover/popover-trigger.ts +0 -50
  105. package/src/components/atoms/popover/popover.atom.ts +0 -34
  106. package/src/components/atoms/popover/popover.stories.ts +0 -79
  107. package/src/components/atoms/popover/popover.style.ts +0 -25
  108. package/src/components/atoms/popover/popover.types.ts +0 -3
  109. package/src/components/atoms/toggle/defs.ts +0 -29
  110. package/src/components/atoms/toggle/toggle.atom.ts +0 -58
  111. package/src/components/atoms/toggle/toggle.stories.ts +0 -204
  112. package/src/components/atoms/toggle/toggle.style.ts +0 -22
  113. package/src/components/command/command.stories.ts +0 -154
  114. package/src/components/command/command.ts +0 -391
  115. package/src/components/index.ts +0 -2
  116. package/src/components/molecules/command/command.molecules.ts +0 -31
  117. package/src/components/molecules/command-input/command-input.atom.ts +0 -130
  118. package/src/components/molecules/dropdownMenu/dropdownMenu.molecules.ts +0 -0
  119. package/src/components/molecules/index.ts +0 -1
  120. package/src/globals.css +0 -2215
  121. package/src/helpers/base-element.ts +0 -79
  122. package/src/helpers/index.ts +0 -3
  123. package/src/helpers/mouse-conroller.helper.ts +0 -42
  124. package/src/helpers/style.helpers.ts +0 -6
  125. package/src/index.d.ts +0 -1
  126. package/src/index.ts +0 -1
  127. package/src/interfaces/actionable.interface.ts +0 -6
  128. package/src/interfaces/atomic.interface.ts +0 -6
  129. package/src/interfaces/changeable.interface.ts +0 -14
  130. package/src/interfaces/child-support-atomic.interface.ts +0 -5
  131. package/src/interfaces/index.ts +0 -6
  132. package/src/interfaces/intractable.interface.ts +0 -6
  133. package/src/interfaces/variant.interface.ts +0 -3
  134. package/src/lib/index.ts +0 -0
  135. package/src/lib/next/next.lib.ts +0 -0
  136. package/src/lib/react/react.lib.ts +0 -18
  137. package/src/lib/tw-styles.ts +0 -1957
  138. package/src/styles/index.ts +0 -1
  139. package/src/styles/tw.styles.ts +0 -2219
  140. package/src/tailwind-lib.css +0 -115
  141. package/src/wc-ui-app.ts +0 -81
  142. package/tailwind.config.js +0 -217
  143. package/test/wc-ui-app.test.ts +0 -22
  144. package/tsconfig.json +0 -30
  145. package/web-dev-server.config.mjs +0 -26
  146. package/web-test-runner.config.mjs +0 -41
@@ -1,57 +0,0 @@
1
- import { LitElement, PropertyValues, css, html } from 'lit';
2
- import { customElement, property, state } from 'lit/decorators.js';
3
- import { searchIcon } from '../../../assets/icons';
4
- import { TWStyles } from '../../../styles';
5
- import { STATE_CLOSED, STATE_OPEN } from '../popover/popover.types';
6
- import { ComboBox } from './combo-box.atom';
7
-
8
- @customElement('combo-box-list')
9
- export class ComboBoxList extends LitElement {
10
- static styles = [css``, TWStyles];
11
- @property({ attribute: 'data-state', type: String }) state = STATE_CLOSED;
12
-
13
- @state() isOpen = false;
14
- get _popover(): ComboBox | null {
15
- let parent = this.parentElement;
16
- // Traverse up the DOM tree to find the parent `Popover`
17
- while (parent && !(parent instanceof ComboBox)) {
18
- parent = parent.parentElement;
19
- }
20
- return parent;
21
- }
22
-
23
- render() {
24
- console.log('this.state', this.state);
25
- // @keydown="${this.handleKeyDown}"
26
-
27
- // @input="${this.handleSearch}"
28
- // @keydown="${this.handleKeyDown}"
29
- return html`
30
- <div
31
- class="absolute z-50 w-full max-h-72 p-1 bg-white border border-gray-200 rounded-lg overflow-hidden overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500 dark:bg-neutral-900 dark:border-neutral-700"
32
- data-hs-combo-box-output=""
33
- style="display: ${this.state === STATE_OPEN
34
- ? 'block'
35
- : 'none'}; top:115%"
36
- >
37
- <div
38
- class="flex items-center justify-center px-3 border-b border-gray-300 mb-1"
39
- >
40
- ${searchIcon()}
41
- <input
42
- type="text"
43
- class="w-full px-2 py-2 rounded focus:outline-none"
44
- placeholder="Search..."
45
- autocomplete="off"
46
- autocorrect="off"
47
- spellcheck="false"
48
- aria-autocomplete="list"
49
- aria-expanded="true"
50
- role="combobox"
51
- />
52
- </div>
53
- <slot></slot>
54
- </div>
55
- `;
56
- }
57
- }
@@ -1,187 +0,0 @@
1
- import { css, html, LitElement, PropertyValues } from 'lit';
2
- import { customElement, property, state } from 'lit/decorators.js';
3
- import { TWStyles } from '../../../styles';
4
- import { arrowsIcon, searchIcon } from '../../../assets/icons';
5
- import './combo-box-input';
6
- import './combo-box-item';
7
-
8
- @customElement('rtg-combo-box')
9
- class ComboBox extends LitElement {
10
- static styles = [css``, TWStyles];
11
-
12
- @state() isOpen = false;
13
- @state() selectedValue = '';
14
- @state() searchTerm = '';
15
- @state() focusedIndex = -1;
16
- @state() filteredItems: string[] = [];
17
- @property({ type: String }) label: string = 'Select an item';
18
- @property({ type: Array }) items = [];
19
- protected firstUpdated(_changedProperties: PropertyValues): void {
20
- if (this.items && this.items.length > 0)
21
- this.filteredItems = this.items.filter((item: string) =>
22
- item.toLowerCase().includes(this.searchTerm)
23
- );
24
- }
25
- toggleDropdown() {
26
- this.isOpen = !this.isOpen;
27
- this.focusedIndex = -1;
28
- }
29
-
30
- selectItem(event: Event) {
31
- const target = event.target as EventTarget;
32
- if (target instanceof HTMLElement) {
33
- const closestItem = target.closest(
34
- 'combo-box-item'
35
- ) as HTMLElement | null;
36
- if (closestItem) {
37
- this.selectedValue =
38
- closestItem.getAttribute('data-hs-combo-box-value') || '';
39
- this.isOpen = false;
40
- } else {
41
- console.log('No valid combo-box-item found');
42
- }
43
- } else {
44
- console.log('Event target is not an HTMLElement');
45
- }
46
- }
47
-
48
- handleInputClick() {
49
- this.toggleDropdown();
50
- }
51
-
52
- handleSearch(event: Event) {
53
- const input = event.target as HTMLInputElement;
54
- this.searchTerm = input.value;
55
- this.filteredItems = this.items.filter((item: string) =>
56
- item.toLowerCase().includes(this.searchTerm)
57
- );
58
- }
59
-
60
- handleKeyDown(event: KeyboardEvent) {
61
- const filteredLength = this.filteredItems.length;
62
-
63
- switch (event.key) {
64
- case 'ArrowDown':
65
- event.preventDefault();
66
- this.focusedIndex = (this.focusedIndex + 1) % filteredLength;
67
- break;
68
- case 'ArrowUp':
69
- event.preventDefault();
70
- this.focusedIndex =
71
- (this.focusedIndex - 1 + filteredLength) % filteredLength;
72
- break;
73
- case 'Enter':
74
- if (this.focusedIndex >= 0 && this.focusedIndex < filteredLength) {
75
- this.selectedValue = this.filteredItems[this.focusedIndex];
76
- this.isOpen = false;
77
- }
78
- break;
79
- default:
80
- break;
81
- }
82
- }
83
-
84
- handleMouseOver(event: Event, index: number) {
85
- event.preventDefault();
86
- this.focusedIndex = index;
87
- }
88
-
89
- updateFocus() {
90
- if (!this.shadowRoot) return;
91
-
92
- const items =
93
- this.shadowRoot.querySelectorAll<HTMLElement>('combo-box-item');
94
- items.forEach((item, index) => {
95
- if (index === this.focusedIndex) {
96
- item.classList.add('bg-gray-100');
97
- } else {
98
- item.classList.remove('bg-gray-100');
99
- }
100
- });
101
- }
102
-
103
- render() {
104
- return html`
105
- <div class="relative" data-hs-combo-box="">
106
- <div class="relative">
107
- <input
108
- class="inline-flex justify-between items-center w-full h-10 px-4 py-2 whitespace-nowrap rounded-md
109
- text-sm font-medium border border-input cursor-pointer
110
- ring-offset-background
111
- transition-colors disabled:pointer-events-none
112
- disabled:opacity-50
113
- bg-background hover:bg-accent
114
- hover:text-accent-foreground
115
- outline-none"
116
- role="combobox"
117
- aria-expanded=${this.isOpen}
118
- readonly
119
- .value=${this.selectedValue || this.label}
120
- @click="${this.handleInputClick}"
121
- @keydown="${this.handleKeyDown}"
122
- />
123
- <div
124
- class="absolute top-1/2 end-3 -translate-y-1/2 cursor-pointer"
125
- aria-expanded=${this.isOpen}
126
- data-hs-combo-box-toggle=""
127
- @click="${this.toggleDropdown}"
128
- >
129
- ${arrowsIcon()}
130
- </div>
131
- </div>
132
- <div
133
- class="absolute z-50 w-full max-h-72 p-1 bg-white border border-gray-200 rounded-lg overflow-hidden overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500 dark:bg-neutral-900 dark:border-neutral-700"
134
- style="display: ${this.isOpen ? 'block' : 'none'}; top:115%"
135
- data-hs-combo-box-output=""
136
- @keydown="${this.handleKeyDown}"
137
- >
138
- <div
139
- class="flex items-center justify-center px-3 border-b border-gray-300 mb-1"
140
- >
141
- ${searchIcon()}
142
- <input
143
- type="text"
144
- class="w-full px-2 py-2 rounded focus:outline-none"
145
- placeholder="Search..."
146
- autocomplete="off"
147
- autocorrect="off"
148
- spellcheck="false"
149
- aria-autocomplete="list"
150
- role="combobox"
151
- @input="${this.handleSearch}"
152
- @keydown="${this.handleKeyDown}"
153
- />
154
- </div>
155
- ${this.filteredItems.length === 0
156
- ? html`
157
- <div
158
- class="py-6 text-center text-sm"
159
- cmdk-empty=""
160
- role="presentation"
161
- >
162
- No item found.
163
- </div>
164
- `
165
- : html`
166
- ${this.filteredItems.map((item, index) => {
167
- return html`
168
- <combo-box-item
169
- .searchText=${item}
170
- .value=${item}
171
- data-hs-combo-box-value=${item}
172
- tabIndex=${index}
173
- @click="${(event: Event) => this.selectItem(event)}"
174
- @mouseover="${(event: Event) =>
175
- this.handleMouseOver(event, index)}"
176
- ?isSelected=${item === this.selectedValue}
177
- ></combo-box-item>
178
- `;
179
- })}
180
- `}
181
- </div>
182
- </div>
183
- `;
184
- }
185
- }
186
-
187
- export { ComboBox };
@@ -1,95 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/web-components';
2
- import { html } from 'lit';
3
- import { expect, within, userEvent, waitFor, fn } from '@storybook/test';
4
- import './combo-box.atom';
5
- import './combo-box-list';
6
- import './combo-box-item';
7
-
8
- const frameworks = [
9
- {
10
- value: 'next.js',
11
- label: 'Next.js',
12
- },
13
- {
14
- value: 'sveltekit',
15
- label: 'SvelteKit',
16
- },
17
- {
18
- value: 'nuxt.js',
19
- label: 'Nuxt.js',
20
- },
21
- {
22
- value: 'remix',
23
- label: 'Remix',
24
- },
25
- {
26
- value: 'astro',
27
- label: 'Astro',
28
- },
29
- ];
30
-
31
- const meta: Meta = {
32
- component: 'components/combo-box',
33
- tags: ['autodocs'],
34
- argTypes: {
35
- items: {
36
- control: 'select',
37
- description:
38
- 'An array of items to display in the dropdown menu. Each item should be a string representing the option text.',
39
- table: {
40
- defaultValue: { summary: '["Option 1", "Option 2", "Option 3"]' },
41
- },
42
- },
43
- label: {
44
- control: 'text',
45
- description:
46
- 'The text displayed on the dropdown. This text is shown to users when the dropdown is closed.',
47
- type: 'string',
48
- table: {
49
- defaultValue: { summary: 'Select an item' },
50
- },
51
- },
52
- },
53
- };
54
- export default meta;
55
- type Story = StoryObj;
56
- // Base story
57
- export const basicComboBox: Story = {
58
- name: 'Basic Usage',
59
- args: {
60
- items: ['Argentina', 'Brazil', 'China', 'USA', 'Italy', 'Iran', 'UAE'],
61
- label: 'Select an item',
62
- },
63
- render: ({ label, items }) => {
64
- return html`
65
- <rtg-combo-box label="${label}" .items=${items}>
66
- <combo-box-list>
67
- ${frameworks.map(
68
- (item, index) => html`
69
- <combo-box-item
70
- .searchText="${item.label}"
71
- .value="${item.value}"
72
- data-hs-combo-box-value="${item.value}"
73
- tabIndex="${index}"
74
- ></combo-box-item>
75
- `
76
- )}
77
- </combo-box-list>
78
- </rtg-combo-box>
79
- `;
80
- },
81
- };
82
-
83
- // Story for empty items array
84
- export const emptyComboBox: Story = {
85
- name: 'Empty Items',
86
- args: {
87
- items: [],
88
- label: 'Select an item',
89
- },
90
- render: ({ label, items }) => {
91
- return html`
92
- <rtg-combo-box label=${label}" .items=${items}> </rtg-combo-box>
93
- `;
94
- },
95
- };
@@ -1,44 +0,0 @@
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
- }
@@ -1,60 +0,0 @@
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
- }
@@ -1,74 +0,0 @@
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
- }
@@ -1,37 +0,0 @@
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
- }
@@ -1,42 +0,0 @@
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
- }
@@ -1,50 +0,0 @@
1
- import { TWStyles } from '../../../styles';
2
- import { css, html, LitElement, PropertyValueMap } from 'lit';
3
- import { customElement } from 'lit/decorators.js';
4
- import { Dialog } from './dialog.atom';
5
-
6
- const STATE_OPEN = 'open';
7
- const STATE_CLOSED = 'closed';
8
-
9
- @customElement('rtg-dialog-close')
10
- export class DialogClose extends LitElement {
11
- static styles = [css``, TWStyles];
12
-
13
- private get _dialog(): Dialog | null {
14
- let parent = this.parentElement;
15
-
16
- while (parent) {
17
- if (parent instanceof Dialog) {
18
- return parent;
19
- }
20
- parent = parent.parentElement;
21
- }
22
- return parent;
23
- }
24
-
25
- protected firstUpdated(
26
- _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>
27
- ): void {
28
- super.firstUpdated(_changedProperties);
29
- const slot = this.shadowRoot?.querySelector('slot');
30
- const children = slot?.assignedElements();
31
- if (children && children.length > 0) {
32
- const button = children[0];
33
-
34
- button.addEventListener('click', () => {
35
- const dialog = this._dialog;
36
- if (dialog) {
37
- dialog.dataset.state = STATE_CLOSED;
38
- }
39
- });
40
- }
41
- }
42
-
43
- render() {
44
- return html`
45
- <div>
46
- <slot></slot>
47
- </div>
48
- `;
49
- }
50
- }