@realmorg/ui 0.0.0-stage → 2.0.0-alpha.2
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/LICENSE +7 -0
- package/README.md +44 -2
- package/components/accordion.html +121 -0
- package/components/alert-dialog.html +196 -0
- package/components/alert.html +69 -0
- package/components/aspect-ratio.html +23 -0
- package/components/attachment.html +84 -0
- package/components/avatar.html +127 -0
- package/components/badge.html +56 -0
- package/components/breadcrumb.html +129 -0
- package/components/bubble.html +67 -0
- package/components/button-group.html +84 -0
- package/components/button.html +188 -0
- package/components/calendar.html +170 -0
- package/components/card.html +113 -0
- package/components/carousel.html +186 -0
- package/components/chart.html +162 -0
- package/components/checkbox.html +93 -0
- package/components/code-block.html +58 -0
- package/components/collapsible.html +76 -0
- package/components/combobox.html +224 -0
- package/components/command.html +189 -0
- package/components/context-menu.html +67 -0
- package/components/dialog.html +281 -0
- package/components/direction.html +17 -0
- package/components/drawer.html +224 -0
- package/components/dropdown-menu.html +372 -0
- package/components/empty.html +106 -0
- package/components/field.html +117 -0
- package/components/hover-card.html +94 -0
- package/components/input-group.html +75 -0
- package/components/input-otp.html +139 -0
- package/components/input.html +82 -0
- package/components/item.html +170 -0
- package/components/kbd.html +35 -0
- package/components/label.html +40 -0
- package/components/marker.html +35 -0
- package/components/menubar.html +116 -0
- package/components/message-scroller.html +62 -0
- package/components/message.html +77 -0
- package/components/navigation-menu.html +204 -0
- package/components/pagination.html +154 -0
- package/components/popover.html +133 -0
- package/components/progress.html +39 -0
- package/components/radio-group.html +114 -0
- package/components/resizable.html +156 -0
- package/components/scroll-area.html +50 -0
- package/components/select.html +91 -0
- package/components/separator.html +25 -0
- package/components/sheet.html +143 -0
- package/components/sidebar.html +343 -0
- package/components/skeleton.html +30 -0
- package/components/slider.html +81 -0
- package/components/spinner.html +47 -0
- package/components/switch.html +89 -0
- package/components/table.html +75 -0
- package/components/tabs.html +164 -0
- package/components/textarea.html +68 -0
- package/components/toaster.html +128 -0
- package/components/toggle-group.html +65 -0
- package/components/toggle.html +81 -0
- package/components/tooltip.html +97 -0
- package/dist/theme.css +145 -0
- package/dist/ui.html +6944 -0
- package/package.json +40 -3
- package/theme.css +145 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<import-element from="./button.html"></import-element>
|
|
2
|
+
|
|
3
|
+
<custom-element name="ui-message-scroller">
|
|
4
|
+
<script>
|
|
5
|
+
const props = defineProps({ threshold: prop.number().min(0).default(48) });
|
|
6
|
+
|
|
7
|
+
const scroll = useState({ pinned: true });
|
|
8
|
+
|
|
9
|
+
function viewport() {
|
|
10
|
+
return refs.viewport;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function track(element) {
|
|
14
|
+
scroll.pinned = element.scrollHeight - element.scrollTop - element.clientHeight <= props.threshold;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function bottom() {
|
|
18
|
+
viewport().scrollTo({ top: viewport().scrollHeight, behavior: "smooth" });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onConnected(() => {
|
|
22
|
+
const observer = new MutationObserver(() => {
|
|
23
|
+
if (scroll.pinned) viewport().scrollTop = viewport().scrollHeight;
|
|
24
|
+
});
|
|
25
|
+
observer.observe(host, { childList: true, subtree: true, characterData: true });
|
|
26
|
+
viewport().scrollTop = viewport().scrollHeight;
|
|
27
|
+
return () => observer.disconnect();
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
:host {
|
|
33
|
+
position: relative;
|
|
34
|
+
display: block;
|
|
35
|
+
width: 100%;
|
|
36
|
+
min-height: 0;
|
|
37
|
+
}
|
|
38
|
+
:host(:state(attr-height)) {
|
|
39
|
+
height: calc(var(--spacing) * var(--attr-height));
|
|
40
|
+
}
|
|
41
|
+
.viewport {
|
|
42
|
+
height: 100%;
|
|
43
|
+
overflow-y: auto;
|
|
44
|
+
overscroll-behavior: contain;
|
|
45
|
+
scrollbar-width: thin;
|
|
46
|
+
}
|
|
47
|
+
.jump {
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 50%;
|
|
50
|
+
bottom: calc(var(--spacing) * 3);
|
|
51
|
+
translate: -50% 0;
|
|
52
|
+
}
|
|
53
|
+
:host(:state(state-scroll-pinned)) .jump {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
57
|
+
|
|
58
|
+
<div class="viewport" ref="viewport" part="viewport" role="log" aria-live="polite" onscroll="track(this)">
|
|
59
|
+
<slot></slot>
|
|
60
|
+
</div>
|
|
61
|
+
<ui-button class="jump" size="sm" variant="secondary" onclick="bottom()">Jump to latest</ui-button>
|
|
62
|
+
</custom-element>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<custom-element name="ui-message">
|
|
2
|
+
<script>
|
|
3
|
+
defineProps({ align: prop.enum(["start", "end"]).default("start") });
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<style>
|
|
7
|
+
:host {
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: calc(var(--spacing) * 2);
|
|
10
|
+
width: 100%;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
font-size: var(--text-sm);
|
|
13
|
+
}
|
|
14
|
+
:host(:state(attr-align-is-end)) {
|
|
15
|
+
flex-direction: row-reverse;
|
|
16
|
+
}
|
|
17
|
+
.content {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: calc(var(--spacing) * 2);
|
|
21
|
+
width: 100%;
|
|
22
|
+
min-width: 0;
|
|
23
|
+
}
|
|
24
|
+
:host(:state(attr-align-is-end)) .content {
|
|
25
|
+
align-items: flex-end;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
28
|
+
|
|
29
|
+
<slot name="avatar"></slot>
|
|
30
|
+
<div class="content" part="content">
|
|
31
|
+
<slot name="header"></slot>
|
|
32
|
+
<slot></slot>
|
|
33
|
+
<slot name="footer"></slot>
|
|
34
|
+
</div>
|
|
35
|
+
</custom-element>
|
|
36
|
+
|
|
37
|
+
<custom-element name="ui-message-avatar" slot="avatar">
|
|
38
|
+
<style>
|
|
39
|
+
:host {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-self: flex-end;
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
45
|
+
|
|
46
|
+
<slot></slot>
|
|
47
|
+
</custom-element>
|
|
48
|
+
|
|
49
|
+
<custom-element name="ui-message-header" slot="header">
|
|
50
|
+
<style>
|
|
51
|
+
:host {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: calc(var(--spacing) * 2);
|
|
55
|
+
padding: 0 calc(var(--spacing) * 3);
|
|
56
|
+
font-size: var(--text-xs);
|
|
57
|
+
color: var(--muted-foreground);
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
60
|
+
|
|
61
|
+
<slot></slot>
|
|
62
|
+
</custom-element>
|
|
63
|
+
|
|
64
|
+
<custom-element name="ui-message-footer" slot="footer">
|
|
65
|
+
<style>
|
|
66
|
+
:host {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: calc(var(--spacing) * 2);
|
|
70
|
+
padding: 0 calc(var(--spacing) * 3);
|
|
71
|
+
font-size: var(--text-xs);
|
|
72
|
+
color: var(--muted-foreground);
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
75
|
+
|
|
76
|
+
<slot></slot>
|
|
77
|
+
</custom-element>
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<custom-element name="ui-navigation-menu">
|
|
2
|
+
<script>
|
|
3
|
+
defineProps({ label: prop.string().default("Main") });
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<style>
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
}
|
|
10
|
+
</style>
|
|
11
|
+
|
|
12
|
+
<nav _aria-label="@label"><slot></slot></nav>
|
|
13
|
+
</custom-element>
|
|
14
|
+
|
|
15
|
+
<custom-element name="ui-navigation-menu-list">
|
|
16
|
+
<style>
|
|
17
|
+
:host {
|
|
18
|
+
display: block;
|
|
19
|
+
}
|
|
20
|
+
ul {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: calc(var(--spacing) * 1);
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
list-style: none;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
|
|
30
|
+
<ul part="list" focusgroup="toolbar inline"><slot></slot></ul>
|
|
31
|
+
</custom-element>
|
|
32
|
+
|
|
33
|
+
<custom-element name="ui-navigation-menu-item" role="listitem">
|
|
34
|
+
<script>
|
|
35
|
+
const menu = useState({ open: false });
|
|
36
|
+
|
|
37
|
+
let restoreFocus = false;
|
|
38
|
+
let timer;
|
|
39
|
+
|
|
40
|
+
function schedule(open) {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
timer = setTimeout(() => refs.panel.togglePopover(open), open ? 150 : 200);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function toggle() {
|
|
46
|
+
refs.panel.togglePopover();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function closing(event) {
|
|
50
|
+
restoreFocus = event.newState === "closed" && host.contains(host.getRootNode().activeElement);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function toggled(event) {
|
|
54
|
+
menu.open = event.newState === "open";
|
|
55
|
+
if (!menu.open && restoreFocus) host.querySelector("ui-navigation-menu-trigger")?.focus();
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<style>
|
|
60
|
+
:host {
|
|
61
|
+
position: relative;
|
|
62
|
+
display: block;
|
|
63
|
+
}
|
|
64
|
+
.anchor {
|
|
65
|
+
display: flex;
|
|
66
|
+
anchor-name: --navigation-trigger;
|
|
67
|
+
}
|
|
68
|
+
.panel {
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
min-width: calc(var(--spacing) * 64);
|
|
71
|
+
margin: calc(var(--spacing) * 1.5) 0 0;
|
|
72
|
+
padding: calc(var(--spacing) * 2);
|
|
73
|
+
border: 1px solid var(--border);
|
|
74
|
+
border-radius: var(--radius-md);
|
|
75
|
+
background: var(--popover);
|
|
76
|
+
color: var(--popover-foreground);
|
|
77
|
+
box-shadow: var(--shadow-md);
|
|
78
|
+
inset: auto;
|
|
79
|
+
position-anchor: --navigation-trigger;
|
|
80
|
+
position-area: bottom span-right;
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
83
|
+
|
|
84
|
+
<div class="anchor"><slot></slot></div>
|
|
85
|
+
<div ref="panel" class="panel" part="panel" popover="auto" onbeforetoggle="closing(event)" ontoggle="toggled(event)" onpointerenter="schedule(true)" onpointerleave="schedule(false)"><slot name="content"></slot></div>
|
|
86
|
+
</custom-element>
|
|
87
|
+
|
|
88
|
+
<custom-element name="ui-navigation-menu-trigger" delegates-focus>
|
|
89
|
+
<style>
|
|
90
|
+
:host {
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
}
|
|
93
|
+
button {
|
|
94
|
+
all: unset;
|
|
95
|
+
display: inline-flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: calc(var(--spacing) * 1);
|
|
98
|
+
height: calc(var(--spacing) * 9);
|
|
99
|
+
padding: 0 calc(var(--spacing) * 4);
|
|
100
|
+
border-radius: var(--radius-md);
|
|
101
|
+
font-size: var(--text-sm);
|
|
102
|
+
font-weight: var(--font-weight-medium);
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
}
|
|
105
|
+
button:hover,
|
|
106
|
+
button:focus-visible,
|
|
107
|
+
button[aria-expanded="true"] {
|
|
108
|
+
background: var(--accent);
|
|
109
|
+
color: var(--accent-foreground);
|
|
110
|
+
}
|
|
111
|
+
button:focus-visible {
|
|
112
|
+
box-shadow: var(--focus-ring);
|
|
113
|
+
}
|
|
114
|
+
svg {
|
|
115
|
+
width: calc(var(--spacing) * 3);
|
|
116
|
+
height: calc(var(--spacing) * 3);
|
|
117
|
+
transition: rotate var(--default-transition-duration);
|
|
118
|
+
}
|
|
119
|
+
[aria-expanded="true"] svg {
|
|
120
|
+
rotate: 180deg;
|
|
121
|
+
}
|
|
122
|
+
</style>
|
|
123
|
+
|
|
124
|
+
<button type="button" part="trigger" _aria-expanded="#menu.open" onclick="toggle()" onpointerenter="schedule(true)" onpointerleave="schedule(false)">
|
|
125
|
+
<slot></slot>
|
|
126
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6" /></svg>
|
|
127
|
+
</button>
|
|
128
|
+
</custom-element>
|
|
129
|
+
|
|
130
|
+
<custom-element name="ui-navigation-menu-content" slot="content">
|
|
131
|
+
<style>
|
|
132
|
+
:host {
|
|
133
|
+
display: grid;
|
|
134
|
+
gap: calc(var(--spacing) * 1);
|
|
135
|
+
--ui-navigation-link-display: flex;
|
|
136
|
+
--ui-navigation-link-direction: column;
|
|
137
|
+
--ui-navigation-link-align: stretch;
|
|
138
|
+
--ui-navigation-link-height: auto;
|
|
139
|
+
--ui-navigation-link-padding: calc(var(--spacing) * 2);
|
|
140
|
+
--ui-navigation-link-weight: var(--font-weight-normal);
|
|
141
|
+
}
|
|
142
|
+
:host(:state(attr-width)) {
|
|
143
|
+
width: calc(var(--spacing) * var(--attr-width));
|
|
144
|
+
}
|
|
145
|
+
:host(:state(attr-columns)) {
|
|
146
|
+
grid-template-columns: repeat(var(--attr-columns), minmax(0, 1fr));
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
149
|
+
|
|
150
|
+
<slot></slot>
|
|
151
|
+
</custom-element>
|
|
152
|
+
|
|
153
|
+
<custom-element name="ui-navigation-menu-link" delegates-focus>
|
|
154
|
+
<script>
|
|
155
|
+
const props = defineProps({ href: prop.string(), current: prop.boolean() });
|
|
156
|
+
const link = useState({
|
|
157
|
+
get current() {
|
|
158
|
+
return props.current ? "page" : null;
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
</script>
|
|
162
|
+
|
|
163
|
+
<style>
|
|
164
|
+
:host {
|
|
165
|
+
display: var(--ui-navigation-link-display, inline-flex);
|
|
166
|
+
}
|
|
167
|
+
a {
|
|
168
|
+
display: flex;
|
|
169
|
+
flex: 1;
|
|
170
|
+
flex-direction: var(--ui-navigation-link-direction, row);
|
|
171
|
+
align-items: var(--ui-navigation-link-align, center);
|
|
172
|
+
gap: calc(var(--spacing) * 1);
|
|
173
|
+
height: var(--ui-navigation-link-height, calc(var(--spacing) * 9));
|
|
174
|
+
padding: var(--ui-navigation-link-padding, 0 calc(var(--spacing) * 4));
|
|
175
|
+
border-radius: var(--radius-md);
|
|
176
|
+
color: inherit;
|
|
177
|
+
font-size: var(--text-sm);
|
|
178
|
+
font-weight: var(--ui-navigation-link-weight, var(--font-weight-medium));
|
|
179
|
+
text-decoration: none;
|
|
180
|
+
outline: none;
|
|
181
|
+
}
|
|
182
|
+
a:hover,
|
|
183
|
+
a:focus-visible,
|
|
184
|
+
a[aria-current="page"] {
|
|
185
|
+
background: var(--accent);
|
|
186
|
+
color: var(--accent-foreground);
|
|
187
|
+
}
|
|
188
|
+
a:focus-visible {
|
|
189
|
+
box-shadow: var(--focus-ring);
|
|
190
|
+
}
|
|
191
|
+
::slotted(*) {
|
|
192
|
+
margin: 0;
|
|
193
|
+
}
|
|
194
|
+
::slotted(:first-child:not(:last-child)) {
|
|
195
|
+
font-weight: var(--font-weight-medium);
|
|
196
|
+
}
|
|
197
|
+
::slotted(:last-child:not(:first-child)) {
|
|
198
|
+
color: var(--muted-foreground);
|
|
199
|
+
line-height: 1.4;
|
|
200
|
+
}
|
|
201
|
+
</style>
|
|
202
|
+
|
|
203
|
+
<a part="link" _href="@href" _aria-current="#link.current"><slot></slot></a>
|
|
204
|
+
</custom-element>
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<custom-element name="ui-pagination">
|
|
2
|
+
<script>
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
page: prop.number().int().min(1).default(1),
|
|
5
|
+
total: prop.number().int().min(1).default(1),
|
|
6
|
+
siblings: prop.number().int().min(0).default(1),
|
|
7
|
+
href: prop.string(),
|
|
8
|
+
label: prop.string().default("Pagination"),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const pages = useState({
|
|
12
|
+
get items() {
|
|
13
|
+
const { page, total, siblings } = props;
|
|
14
|
+
const keep = new Set([1, total]);
|
|
15
|
+
for (let n = page - siblings; n <= page + siblings; n++) if (n >= 1 && n <= total) keep.add(n);
|
|
16
|
+
const sorted = [...keep].sort((a, b) => a - b);
|
|
17
|
+
return sorted.flatMap((n, index) => {
|
|
18
|
+
const item = { key: `p${n}`, number: n, kind: this.kind, current: n === page ? "page" : null, url: link(n) };
|
|
19
|
+
return index > 0 && n - sorted[index - 1] > 1 ? [{ key: `gap${n}`, kind: "gap" }, item] : [item];
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
get kind() {
|
|
23
|
+
return props.href ? "link" : "button";
|
|
24
|
+
},
|
|
25
|
+
get first() {
|
|
26
|
+
return props.page <= 1;
|
|
27
|
+
},
|
|
28
|
+
get last() {
|
|
29
|
+
return props.page >= props.total;
|
|
30
|
+
},
|
|
31
|
+
get previousUrl() {
|
|
32
|
+
return this.first ? null : link(props.page - 1);
|
|
33
|
+
},
|
|
34
|
+
get nextUrl() {
|
|
35
|
+
return this.last ? null : link(props.page + 1);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function link(n) {
|
|
40
|
+
return props.href ? props.href.replace("{page}", String(n)) : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function previous(event) {
|
|
44
|
+
go(props.page - 1, event);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function next(event) {
|
|
48
|
+
go(props.page + 1, event);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function go(page, event) {
|
|
52
|
+
if (page < 1 || page > props.total || page === props.page) return;
|
|
53
|
+
if (!dispatch("change", { page })) return event?.preventDefault();
|
|
54
|
+
if (!props.href) props.page = page;
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<style>
|
|
59
|
+
:host {
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
}
|
|
63
|
+
ul {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
align-items: center;
|
|
68
|
+
gap: calc(var(--spacing) * 1);
|
|
69
|
+
margin: 0;
|
|
70
|
+
padding: 0;
|
|
71
|
+
list-style: none;
|
|
72
|
+
}
|
|
73
|
+
a,
|
|
74
|
+
button {
|
|
75
|
+
all: unset;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
gap: calc(var(--spacing) * 1);
|
|
81
|
+
min-width: calc(var(--spacing) * 9);
|
|
82
|
+
height: calc(var(--spacing) * 9);
|
|
83
|
+
padding: 0 calc(var(--spacing) * 2.5);
|
|
84
|
+
border: 1px solid transparent;
|
|
85
|
+
border-radius: var(--radius-md);
|
|
86
|
+
color: inherit;
|
|
87
|
+
font-size: var(--text-sm);
|
|
88
|
+
font-weight: var(--font-weight-medium);
|
|
89
|
+
text-decoration: none;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
}
|
|
92
|
+
:is(a, button):hover {
|
|
93
|
+
background: var(--accent);
|
|
94
|
+
}
|
|
95
|
+
:is(a, button):focus-visible {
|
|
96
|
+
border-color: var(--ring);
|
|
97
|
+
box-shadow: var(--focus-ring);
|
|
98
|
+
}
|
|
99
|
+
[aria-current="page"] {
|
|
100
|
+
border-color: var(--border);
|
|
101
|
+
box-shadow: var(--shadow-xs);
|
|
102
|
+
}
|
|
103
|
+
a:not([href]),
|
|
104
|
+
button:disabled {
|
|
105
|
+
pointer-events: none;
|
|
106
|
+
opacity: 0.5;
|
|
107
|
+
}
|
|
108
|
+
@media (width < 40rem) {
|
|
109
|
+
.label {
|
|
110
|
+
position: absolute;
|
|
111
|
+
width: 1px;
|
|
112
|
+
height: 1px;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
clip-path: inset(50%);
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
.gap {
|
|
119
|
+
display: inline-flex;
|
|
120
|
+
width: calc(var(--spacing) * 9);
|
|
121
|
+
justify-content: center;
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
124
|
+
|
|
125
|
+
<nav _aria-label="@label">
|
|
126
|
+
<ul part="list">
|
|
127
|
+
<li>
|
|
128
|
+
<is-visible when="#pages.kind" eq="link">
|
|
129
|
+
<a part="previous" _href="#pages.previousUrl" _aria-disabled="#pages.first" onclick="previous(event)">‹ <span class="label">Previous</span></a>
|
|
130
|
+
</is-visible>
|
|
131
|
+
<is-visible when="#pages.kind" eq="button">
|
|
132
|
+
<button type="button" part="previous" _disabled="#pages.first" onclick="previous(event)">‹ <span class="label">Previous</span></button>
|
|
133
|
+
</is-visible>
|
|
134
|
+
</li>
|
|
135
|
+
<li repeat="#pages.items" as="item" key="key">
|
|
136
|
+
<is-visible when="#item.kind" eq="link">
|
|
137
|
+
<a part="page" _href="#item.url" _aria-current="#item.current" onclick="go(item.number, event)"><slot name="#item.number"></slot></a>
|
|
138
|
+
</is-visible>
|
|
139
|
+
<is-visible when="#item.kind" eq="button">
|
|
140
|
+
<button type="button" part="page" _aria-current="#item.current" onclick="go(item.number, event)"><slot name="#item.number"></slot></button>
|
|
141
|
+
</is-visible>
|
|
142
|
+
<is-visible when="#item.kind" eq="gap"><span class="gap" aria-hidden="true">…</span></is-visible>
|
|
143
|
+
</li>
|
|
144
|
+
<li>
|
|
145
|
+
<is-visible when="#pages.kind" eq="link">
|
|
146
|
+
<a part="next" _href="#pages.nextUrl" _aria-disabled="#pages.last" onclick="next(event)"><span class="label">Next</span> ›</a>
|
|
147
|
+
</is-visible>
|
|
148
|
+
<is-visible when="#pages.kind" eq="button">
|
|
149
|
+
<button type="button" part="next" _disabled="#pages.last" onclick="next(event)"><span class="label">Next</span> ›</button>
|
|
150
|
+
</is-visible>
|
|
151
|
+
</li>
|
|
152
|
+
</ul>
|
|
153
|
+
</nav>
|
|
154
|
+
</custom-element>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<custom-element name="ui-popover">
|
|
2
|
+
<script>
|
|
3
|
+
let wasOpen = false;
|
|
4
|
+
|
|
5
|
+
function press() {
|
|
6
|
+
wasOpen = host.querySelector(":scope > ui-popover-content").matches(":popover-open");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function toggle(trigger) {
|
|
10
|
+
const content = host.querySelector(":scope > ui-popover-content");
|
|
11
|
+
const open = wasOpen || content.matches(":popover-open");
|
|
12
|
+
wasOpen = false;
|
|
13
|
+
if (open) content.hidePopover();
|
|
14
|
+
else {
|
|
15
|
+
trigger.firstElementChild?.focus();
|
|
16
|
+
content.showPopover({ source: trigger });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
:host {
|
|
23
|
+
display: contents;
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
26
|
+
|
|
27
|
+
<slot></slot>
|
|
28
|
+
</custom-element>
|
|
29
|
+
|
|
30
|
+
<custom-element name="ui-popover-trigger">
|
|
31
|
+
<style>
|
|
32
|
+
:host {
|
|
33
|
+
display: inline-block;
|
|
34
|
+
vertical-align: middle;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
37
|
+
|
|
38
|
+
<span part="trigger" onpointerdown="press()" onclick="toggle(host)"><slot></slot></span>
|
|
39
|
+
</custom-element>
|
|
40
|
+
|
|
41
|
+
<custom-element name="ui-popover-content">
|
|
42
|
+
<script>
|
|
43
|
+
defineProps({
|
|
44
|
+
placement: prop.enum(["bottom", "top", "left", "right"]).default("bottom"),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
attrs.popover ??= "auto";
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
:host {
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
width: calc(var(--spacing) * 72);
|
|
54
|
+
margin: calc(var(--spacing) * 1);
|
|
55
|
+
padding: calc(var(--spacing) * 4);
|
|
56
|
+
border: 1px solid var(--border);
|
|
57
|
+
border-radius: var(--radius-md);
|
|
58
|
+
background: var(--popover);
|
|
59
|
+
color: var(--popover-foreground);
|
|
60
|
+
box-shadow: var(--shadow-md);
|
|
61
|
+
inset: auto;
|
|
62
|
+
position-area: bottom;
|
|
63
|
+
position-try-fallbacks: flip-block, flip-inline;
|
|
64
|
+
}
|
|
65
|
+
:host(:popover-open) {
|
|
66
|
+
display: grid;
|
|
67
|
+
gap: calc(var(--spacing) * 4);
|
|
68
|
+
}
|
|
69
|
+
:host(:state(attr-width)) {
|
|
70
|
+
width: calc(var(--spacing) * var(--attr-width));
|
|
71
|
+
}
|
|
72
|
+
:host(:state(attr-placement-is-top)) {
|
|
73
|
+
position-area: top;
|
|
74
|
+
}
|
|
75
|
+
:host(:state(attr-placement-is-left)) {
|
|
76
|
+
position-area: left;
|
|
77
|
+
}
|
|
78
|
+
:host(:state(attr-placement-is-right)) {
|
|
79
|
+
position-area: right;
|
|
80
|
+
}
|
|
81
|
+
@supports not (position-area: bottom) {
|
|
82
|
+
:host {
|
|
83
|
+
inset: 0;
|
|
84
|
+
margin: auto;
|
|
85
|
+
height: fit-content;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
89
|
+
|
|
90
|
+
<slot></slot>
|
|
91
|
+
</custom-element>
|
|
92
|
+
|
|
93
|
+
<custom-element name="ui-popover-header">
|
|
94
|
+
<style>
|
|
95
|
+
:host {
|
|
96
|
+
display: grid;
|
|
97
|
+
gap: calc(var(--spacing) * 1);
|
|
98
|
+
}
|
|
99
|
+
</style>
|
|
100
|
+
|
|
101
|
+
<slot></slot>
|
|
102
|
+
</custom-element>
|
|
103
|
+
|
|
104
|
+
<custom-element name="ui-popover-title">
|
|
105
|
+
<style>
|
|
106
|
+
:host {
|
|
107
|
+
display: block;
|
|
108
|
+
}
|
|
109
|
+
h3 {
|
|
110
|
+
margin: 0;
|
|
111
|
+
font-size: var(--text-sm);
|
|
112
|
+
font-weight: var(--font-weight-medium);
|
|
113
|
+
line-height: 1;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
116
|
+
|
|
117
|
+
<h3 part="title"><slot></slot></h3>
|
|
118
|
+
</custom-element>
|
|
119
|
+
|
|
120
|
+
<custom-element name="ui-popover-description">
|
|
121
|
+
<style>
|
|
122
|
+
:host {
|
|
123
|
+
display: block;
|
|
124
|
+
}
|
|
125
|
+
p {
|
|
126
|
+
margin: 0;
|
|
127
|
+
font-size: var(--text-sm);
|
|
128
|
+
color: var(--muted-foreground);
|
|
129
|
+
}
|
|
130
|
+
</style>
|
|
131
|
+
|
|
132
|
+
<p part="description"><slot></slot></p>
|
|
133
|
+
</custom-element>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<custom-element name="ui-progress">
|
|
2
|
+
<script>
|
|
3
|
+
defineProps({
|
|
4
|
+
value: prop.number().min(0),
|
|
5
|
+
max: prop.number().min(1).default(100),
|
|
6
|
+
label: prop.string().attribute("aria-label"),
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
:host {
|
|
12
|
+
display: block;
|
|
13
|
+
width: 100%;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
progress {
|
|
17
|
+
appearance: none;
|
|
18
|
+
display: block;
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: calc(var(--spacing) * 2);
|
|
21
|
+
border: 0;
|
|
22
|
+
border-radius: var(--radius-full);
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
background: color-mix(in oklab, var(--primary) 20%, transparent);
|
|
25
|
+
}
|
|
26
|
+
progress::-webkit-progress-bar {
|
|
27
|
+
background: transparent;
|
|
28
|
+
}
|
|
29
|
+
progress::-webkit-progress-value {
|
|
30
|
+
background: var(--primary);
|
|
31
|
+
transition: inline-size 0.2s;
|
|
32
|
+
}
|
|
33
|
+
progress::-moz-progress-bar {
|
|
34
|
+
background: var(--primary);
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
37
|
+
|
|
38
|
+
<progress part="bar" _value="@value" _max="@max" _aria-label="@label"><slot></slot></progress>
|
|
39
|
+
</custom-element>
|