@rimelight/ui 0.0.51 → 0.0.52
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/package.json +10 -8
- package/src/components/dropdown-menu/RLADropdownMenu.astro +258 -250
- package/src/components/dropdown-menu/RLSDropdownMenu.tsx +161 -140
- package/src/components/head/RLSHead.tsx +2 -7
- package/src/components/popover/RLAPopover.astro +1 -2
- package/src/components/select/RLASelect.astro +1 -1
- package/src/components/table/RLATable.astro +1692 -1044
- package/src/components/table/RLSTable.tsx +1239 -162
- package/src/components/table/table.theme.ts +20 -14
- package/src/components/table/table.ts +211 -43
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimelight/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.52",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Rimelight Entertainment's UI Package",
|
|
6
6
|
"homepage": "https://rimelight.com/docs",
|
|
@@ -54,6 +54,12 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "vp pack",
|
|
59
|
+
"prepack": "pnpm run build",
|
|
60
|
+
"astro": "astro",
|
|
61
|
+
"check": "vp check --fix && astro check"
|
|
62
|
+
},
|
|
57
63
|
"dependencies": {
|
|
58
64
|
"@unocss/vite": "66.10.2",
|
|
59
65
|
"unocss": "66.10.2"
|
|
@@ -63,7 +69,7 @@
|
|
|
63
69
|
"@astrojs/solid-js": "7.0.2",
|
|
64
70
|
"@astrojs/ts-plugin": "1.10.11",
|
|
65
71
|
"@astrojs/vue": "7.0.2",
|
|
66
|
-
"@rimelight/config": "
|
|
72
|
+
"@rimelight/config": "workspace:*",
|
|
67
73
|
"@vitejs/plugin-vue": "6.0.8",
|
|
68
74
|
"astro": "7.3.2",
|
|
69
75
|
"solid-js": "1.9.15",
|
|
@@ -95,9 +101,5 @@
|
|
|
95
101
|
"engines": {
|
|
96
102
|
"node": ">=26.8.2"
|
|
97
103
|
},
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
"astro": "astro",
|
|
101
|
-
"check": "vp check --fix && astro check"
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
+
"packageManager": "pnpm@12.4.1"
|
|
105
|
+
}
|
|
@@ -1,250 +1,258 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { DropdownMenuProps, DropdownMenuItem } from "./dropdown-menu"
|
|
3
|
-
import { dropdownMenuTheme } from "./dropdown-menu.theme"
|
|
4
|
-
import RLAIcon from "../icon/RLAIcon.astro"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{item.type
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
content.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
content.style.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
content.style.
|
|
155
|
-
content.style.
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
content.classList.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
1
|
+
---
|
|
2
|
+
import type { DropdownMenuProps, DropdownMenuItem } from "./dropdown-menu"
|
|
3
|
+
import { dropdownMenuTheme } from "./dropdown-menu.theme"
|
|
4
|
+
import RLAIcon from "../icon/RLAIcon.astro"
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
items = [],
|
|
8
|
+
label,
|
|
9
|
+
icon,
|
|
10
|
+
size = "md",
|
|
11
|
+
color = "primary",
|
|
12
|
+
arrow = false,
|
|
13
|
+
content: contentProp = {},
|
|
14
|
+
disabled = false,
|
|
15
|
+
...rest
|
|
16
|
+
} = Astro.props as DropdownMenuProps
|
|
17
|
+
|
|
18
|
+
const align = contentProp?.align || "start"
|
|
19
|
+
const side = contentProp?.side || "bottom"
|
|
20
|
+
|
|
21
|
+
const classes = dropdownMenuTheme(Astro.props)
|
|
22
|
+
|
|
23
|
+
// Standardize item groups: array of arrays vs array of items
|
|
24
|
+
const itemGroups: DropdownMenuItem[][] = Array.isArray(items) && items.length > 0 && Array.isArray(items[0])
|
|
25
|
+
? (items as DropdownMenuItem[][])
|
|
26
|
+
: [items as DropdownMenuItem[]]
|
|
27
|
+
---
|
|
28
|
+
<rla-dropdown-menu data-align={align} data-side={side} {...rest}>
|
|
29
|
+
<div class={classes.root} data-slot="root" data-dropdown-menu>
|
|
30
|
+
{Astro.slots.has("trigger") ? (
|
|
31
|
+
<div class="inline-flex cursor-pointer" data-slot="trigger" data-dropdown-trigger>
|
|
32
|
+
<slot name="trigger" />
|
|
33
|
+
</div>
|
|
34
|
+
) : (
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
class:list={[
|
|
38
|
+
classes.trigger,
|
|
39
|
+
!label && !Astro.slots.has("default") && !Astro.slots.has("trigger") && "aspect-square !px-1.5 !py-1.5 inline-flex items-center justify-center shrink-0"
|
|
40
|
+
]}
|
|
41
|
+
data-slot="trigger"
|
|
42
|
+
data-dropdown-trigger
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
>
|
|
45
|
+
<slot>
|
|
46
|
+
{icon && <span class={icon + " shrink-0"} />}
|
|
47
|
+
{label && <span>{label}</span>}
|
|
48
|
+
{!icon && !label && <RLAIcon name="i-lucide-ellipsis-vertical" class="size-4" />}
|
|
49
|
+
</slot>
|
|
50
|
+
</button>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
<div
|
|
54
|
+
class={`${classes.content} hidden`}
|
|
55
|
+
data-slot="content"
|
|
56
|
+
data-dropdown-content
|
|
57
|
+
>
|
|
58
|
+
{arrow && <div class={classes.arrow} />}
|
|
59
|
+
<div class={classes.viewport}>
|
|
60
|
+
{itemGroups.map((group, groupIdx) => (
|
|
61
|
+
<div class={classes.group}>
|
|
62
|
+
{groupIdx > 0 && <div class={classes.separator} />}
|
|
63
|
+
{group.map((item) => {
|
|
64
|
+
if (item.type === "separator") {
|
|
65
|
+
return <div class={classes.separator} />
|
|
66
|
+
}
|
|
67
|
+
if (item.type === "label") {
|
|
68
|
+
return <div class={classes.label}>{item.label}</div>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const itemColorClass = item.color === "error"
|
|
72
|
+
? "text-destructive hover:bg-destructive/10 hover:text-destructive"
|
|
73
|
+
: item.color === "primary"
|
|
74
|
+
? "text-primary hover:bg-primary/10"
|
|
75
|
+
: ""
|
|
76
|
+
|
|
77
|
+
const ItemTag = item.to ? "a" : "button"
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<ItemTag
|
|
81
|
+
href={item.to}
|
|
82
|
+
target={item.target}
|
|
83
|
+
type={item.to ? undefined : "button"}
|
|
84
|
+
class={`${classes.item} ${itemColorClass} ${item.class || ""}`}
|
|
85
|
+
data-slot="item"
|
|
86
|
+
data-dropdown-item
|
|
87
|
+
data-item-type={item.type}
|
|
88
|
+
data-item-id={item["id"] || item["label"]}
|
|
89
|
+
data-item-action={item.label}
|
|
90
|
+
disabled={item.disabled}
|
|
91
|
+
>
|
|
92
|
+
{item.type === "checkbox" && (
|
|
93
|
+
<span class="shrink-0 size-4 flex items-center justify-center border border-default rounded bg-default" data-checkbox-box>
|
|
94
|
+
<RLAIcon name="i-lucide-check" class={`size-3 text-primary ${item.checked !== false ? "" : "hidden"}`} data-checkbox-check />
|
|
95
|
+
</span>
|
|
96
|
+
)}
|
|
97
|
+
|
|
98
|
+
{item.avatar && (
|
|
99
|
+
<img src={item.avatar.src} alt={item.avatar.alt || item.label || ""} class={classes.itemLeadingAvatar} />
|
|
100
|
+
)}
|
|
101
|
+
|
|
102
|
+
{item.icon && !item.avatar && (
|
|
103
|
+
<span class={`${item.icon} ${classes.itemLeadingIcon}`} />
|
|
104
|
+
)}
|
|
105
|
+
|
|
106
|
+
<span class={classes.itemLabel}>{item.label}</span>
|
|
107
|
+
|
|
108
|
+
{(item.shortcut || (item.kbds && item.kbds.length > 0)) && (
|
|
109
|
+
<span class={classes.itemTrailing}>
|
|
110
|
+
{item.shortcut && <span class={classes.shortcut}>{item.shortcut}</span>}
|
|
111
|
+
{item.kbds && item.kbds.map(kbd => (
|
|
112
|
+
<kbd class={classes.itemTrailingKbds}>{kbd}</kbd>
|
|
113
|
+
))}
|
|
114
|
+
</span>
|
|
115
|
+
)}
|
|
116
|
+
</ItemTag>
|
|
117
|
+
)
|
|
118
|
+
})}
|
|
119
|
+
</div>
|
|
120
|
+
))}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
</rla-dropdown-menu>
|
|
125
|
+
|
|
126
|
+
<script>
|
|
127
|
+
class RLADropdownMenu extends HTMLElement {
|
|
128
|
+
private dropdownCleanup: (() => void) | null = null;
|
|
129
|
+
|
|
130
|
+
connectedCallback() {
|
|
131
|
+
this.style.display = 'inline-block';
|
|
132
|
+
const trigger = this.querySelector("[data-dropdown-trigger]") as HTMLElement | null;
|
|
133
|
+
const content = this.querySelector("[data-dropdown-content]") as HTMLElement | null;
|
|
134
|
+
|
|
135
|
+
if (!trigger || !content) return;
|
|
136
|
+
|
|
137
|
+
const updatePosition = () => {
|
|
138
|
+
if (content.classList.contains("hidden")) return;
|
|
139
|
+
const rect = trigger.getBoundingClientRect();
|
|
140
|
+
const align = this.getAttribute("data-align") || "start";
|
|
141
|
+
const side = this.getAttribute("data-side") || "bottom";
|
|
142
|
+
|
|
143
|
+
content.style.position = "fixed";
|
|
144
|
+
content.style.zIndex = "999999";
|
|
145
|
+
content.style.margin = "0";
|
|
146
|
+
|
|
147
|
+
if (side === "top") {
|
|
148
|
+
content.style.top = `${rect.top - content.offsetHeight - 4}px`;
|
|
149
|
+
} else {
|
|
150
|
+
content.style.top = `${rect.bottom + 4}px`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (align === "end") {
|
|
154
|
+
content.style.right = `${window.innerWidth - rect.right}px`;
|
|
155
|
+
content.style.left = "auto";
|
|
156
|
+
} else if (align === "center") {
|
|
157
|
+
content.style.left = `${rect.left + (rect.width / 2) - (content.offsetWidth / 2)}px`;
|
|
158
|
+
content.style.right = "auto";
|
|
159
|
+
} else {
|
|
160
|
+
content.style.left = `${rect.left}px`;
|
|
161
|
+
content.style.right = "auto";
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const toggleMenu = (e: MouseEvent) => {
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
const isHidden = content.classList.contains("hidden");
|
|
169
|
+
|
|
170
|
+
document.querySelectorAll("[data-dropdown-content]").forEach(el => {
|
|
171
|
+
if (el !== content) el.classList.add("hidden");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (isHidden) {
|
|
175
|
+
if (content.parentElement !== document.body) {
|
|
176
|
+
document.body.appendChild(content);
|
|
177
|
+
}
|
|
178
|
+
content.classList.remove("hidden");
|
|
179
|
+
updatePosition();
|
|
180
|
+
} else {
|
|
181
|
+
content.classList.add("hidden");
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
trigger.addEventListener("click", toggleMenu);
|
|
186
|
+
|
|
187
|
+
const onDocumentClick = (e: MouseEvent) => {
|
|
188
|
+
const target = e.target as Node | null;
|
|
189
|
+
if (!target) return;
|
|
190
|
+
if (trigger.contains(target) || content.contains(target)) return;
|
|
191
|
+
content.classList.add("hidden");
|
|
192
|
+
};
|
|
193
|
+
document.addEventListener("click", onDocumentClick);
|
|
194
|
+
|
|
195
|
+
const onScrollOrResize = () => {
|
|
196
|
+
if (!content.classList.contains("hidden")) {
|
|
197
|
+
updatePosition();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
window.addEventListener("scroll", onScrollOrResize, true);
|
|
201
|
+
window.addEventListener("resize", onScrollOrResize);
|
|
202
|
+
|
|
203
|
+
const onItemClick = (e: MouseEvent) => {
|
|
204
|
+
const itemEl = (e.target as HTMLElement).closest("[data-dropdown-item]") as HTMLElement | null;
|
|
205
|
+
if (itemEl && !itemEl.hasAttribute("disabled")) {
|
|
206
|
+
const itemType = itemEl.getAttribute("data-item-type");
|
|
207
|
+
if (itemType === "checkbox") {
|
|
208
|
+
e.stopPropagation();
|
|
209
|
+
const checkIcon = itemEl.querySelector("[data-checkbox-check]");
|
|
210
|
+
const isCurrentlyChecked = checkIcon ? !checkIcon.classList.contains("hidden") : false;
|
|
211
|
+
const newChecked = !isCurrentlyChecked;
|
|
212
|
+
if (checkIcon) {
|
|
213
|
+
if (newChecked) {
|
|
214
|
+
checkIcon.classList.remove("hidden");
|
|
215
|
+
} else {
|
|
216
|
+
checkIcon.classList.add("hidden");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
this.dispatchEvent(new CustomEvent("rla-dropdown-checkbox-change", {
|
|
220
|
+
detail: {
|
|
221
|
+
id: itemEl.getAttribute("data-item-id"),
|
|
222
|
+
action: itemEl.getAttribute("data-item-action"),
|
|
223
|
+
checked: newChecked,
|
|
224
|
+
event: e
|
|
225
|
+
},
|
|
226
|
+
bubbles: true
|
|
227
|
+
}));
|
|
228
|
+
} else {
|
|
229
|
+
content.classList.add("hidden");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
content.addEventListener("click", onItemClick);
|
|
234
|
+
|
|
235
|
+
this.dropdownCleanup = () => {
|
|
236
|
+
trigger.removeEventListener("click", toggleMenu);
|
|
237
|
+
document.removeEventListener("click", onDocumentClick);
|
|
238
|
+
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
239
|
+
window.removeEventListener("resize", onScrollOrResize);
|
|
240
|
+
content.removeEventListener("click", onItemClick);
|
|
241
|
+
if (content.parentElement === document.body) {
|
|
242
|
+
content.remove();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
disconnectedCallback() {
|
|
248
|
+
if (this.dropdownCleanup) {
|
|
249
|
+
this.dropdownCleanup();
|
|
250
|
+
this.dropdownCleanup = null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (!customElements.get('rla-dropdown-menu')) {
|
|
256
|
+
customElements.define('rla-dropdown-menu', RLADropdownMenu);
|
|
257
|
+
}
|
|
258
|
+
</script>
|