@esportsplus/ui 0.56.2 → 0.56.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/build/components/bento-grid/scss/index.scss +1 -1
- package/build/components/index.d.ts +3 -0
- package/build/components/index.js +3 -0
- package/build/components/navigation-menu/index.d.ts +28 -0
- package/build/components/navigation-menu/index.js +419 -0
- package/build/components/navigation-menu/scss/index.scss +2 -0
- package/build/components/plan-card/index.d.ts +36 -0
- package/build/components/plan-card/index.js +257 -0
- package/build/components/plan-card/scss/index.scss +2 -0
- package/build/components/surface-field/index.d.ts +2200 -0
- package/build/components/surface-field/index.js +474 -0
- package/build/components/surface-field/scss/index.scss +2 -0
- package/package.json +1 -1
- package/src/components/bento-grid/scss/index.scss +3 -2
- package/src/components/index.ts +3 -0
- package/src/components/navigation-menu/index.ts +608 -0
- package/src/components/navigation-menu/scss/index.scss +213 -0
- package/src/components/navigation-menu/scss/variables.scss +24 -0
- package/src/components/plan-card/index.ts +404 -0
- package/src/components/plan-card/scss/index.scss +513 -0
- package/src/components/plan-card/scss/variables.scss +33 -0
- package/src/components/surface-field/index.ts +816 -0
- package/src/components/surface-field/scss/index.scss +115 -0
- package/src/components/surface-field/scss/variables.scss +11 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@layer components {.bento-grid{--background:var(--color-white-300);--border-radius:12px;--box-shadow:0 0 0 1px oklch(from var(--color-black-300) l c h / .03), 0 2px 4px oklch(from var(--color-black-300) l c h / .05), 0 12px 24px oklch(from var(--color-black-300) l c h / .05);--description-color:var(--color-text-300);--duration:.3s;--ease:cubic-bezier(.4, 0, .2, 1);--focus-color:oklch(from var(--color-text-500) l c h / .38);--gap:16px;--icon-color:var(--color-text-400);--icon-size:48px;--link-color:var(--color-text-500);--link-font-size:calc(var(--font-size-400) * .875);--name-color:var(--color-text-400);--name-font-size:var(--font-size-500);--overlay-hover:oklch(from var(--color-black-300) l c h / .03);--padding:16px;--row-height:22rem;gap:var(--gap);grid-auto-rows:var(--row-height);grid-template-columns:repeat(3,minmax(0,1fr));width:100%;display:grid;container-type:inline-size}.bento-grid-arrow{height:16px;transition:translate var(--duration) var(--ease);flex-shrink:0;width:16px}.bento-grid-background{pointer-events:none;position:absolute;inset:0}.bento-grid-background>*{pointer-events:auto}.bento-grid-body{padding:var(--padding);z-index:1;margin-top:auto;position:relative}.bento-grid-card{background:var(--background);border-radius:var(--border-radius);box-shadow:var(--box-shadow);flex-direction:column;grid-column:span 3;justify-content:space-between;display:flex;position:relative;overflow:hidden}.bento-grid-content{pointer-events:none;transition:translate var(--duration) var(--ease);flex-direction:column;gap:4px;display:flex}.bento-grid-cta{padding:0 var(--padding) var(--padding);z-index:1;display:flex;position:relative}.bento-grid-description{color:var(--description-color);max-width:32rem;margin:0}.bento-grid-icon{color:var(--icon-color);height:var(--icon-size);transform-origin:0;transition:scale var(--duration) var(--ease);width:var(--icon-size);display:flex}.bento-grid-icon svg{width:100%;height:100%}.bento-grid-link{color:var(--link-color);font-size:var(--link-font-size);font-weight:var(--font-weight-500);outline:0 solid var(--focus-color);outline-offset:2px;text-underline-offset:4px;border-radius:4px;align-items:center;gap:8px;text-decoration:none;display:inline-flex}.bento-grid-link:focus-visible{outline-width:2px}.bento-grid-link:hover{text-decoration:underline}.bento-grid-link:hover .bento-grid-arrow{translate:2px}.bento-grid-name{color:var(--name-color);font-size:var(--name-font-size);font-weight:var(--font-weight-600);margin:0}.bento-grid-overlay{pointer-events:none;transition:background-color var(--duration) var(--ease);position:absolute;inset:0}.bento-grid-card:hover .bento-grid-overlay{background:var(--overlay-hover)}.bento-grid-card:hover .bento-grid-icon,.bento-grid-card:focus-within .bento-grid-icon{scale:.75}@container (width>=
|
|
1
|
+
@layer components {.bento-grid{--background:var(--color-white-300);--border-radius:12px;--box-shadow:0 0 0 1px oklch(from var(--color-black-300) l c h / .03), 0 2px 4px oklch(from var(--color-black-300) l c h / .05), 0 12px 24px oklch(from var(--color-black-300) l c h / .05);--description-color:var(--color-text-300);--duration:.3s;--ease:cubic-bezier(.4, 0, .2, 1);--focus-color:oklch(from var(--color-text-500) l c h / .38);--gap:16px;--icon-color:var(--color-text-400);--icon-size:48px;--link-color:var(--color-text-500);--link-font-size:calc(var(--font-size-400) * .875);--name-color:var(--color-text-400);--name-font-size:var(--font-size-500);--overlay-hover:oklch(from var(--color-black-300) l c h / .03);--padding:16px;--row-height:22rem;gap:var(--gap);grid-auto-rows:var(--row-height);grid-template-columns:repeat(3,minmax(0,1fr));width:100%;display:grid;container-type:inline-size}.bento-grid-arrow{height:16px;transition:translate var(--duration) var(--ease);flex-shrink:0;width:16px}.bento-grid-background{pointer-events:none;position:absolute;inset:0}.bento-grid-background>*{pointer-events:auto}.bento-grid-body{padding:var(--padding);z-index:1;margin-top:auto;position:relative}.bento-grid-card{background:var(--background);border-radius:var(--border-radius);box-shadow:var(--box-shadow);flex-direction:column;grid-column:span 3;justify-content:space-between;display:flex;position:relative;overflow:hidden}.bento-grid-content{pointer-events:none;transition:translate var(--duration) var(--ease);flex-direction:column;gap:4px;display:flex}.bento-grid-cta{padding:0 var(--padding) var(--padding);z-index:1;display:flex;position:relative}.bento-grid-description{color:var(--description-color);max-width:32rem;margin:0}.bento-grid-icon{color:var(--icon-color);height:var(--icon-size);transform-origin:0;transition:scale var(--duration) var(--ease);width:var(--icon-size);display:flex}.bento-grid-icon svg{width:100%;height:100%}.bento-grid-link{color:var(--link-color);font-size:var(--link-font-size);font-weight:var(--font-weight-500);outline:0 solid var(--focus-color);outline-offset:2px;text-underline-offset:4px;border-radius:4px;align-items:center;gap:8px;text-decoration:none;display:inline-flex}.bento-grid-link:focus-visible{outline-width:2px}.bento-grid-link:hover{text-decoration:underline}.bento-grid-link:hover .bento-grid-arrow{translate:2px}.bento-grid-name{color:var(--name-color);font-size:var(--name-font-size);font-weight:var(--font-weight-600);margin:0}.bento-grid-overlay{pointer-events:none;transition:background-color var(--duration) var(--ease);position:absolute;inset:0}.bento-grid-card:hover .bento-grid-overlay{background:var(--overlay-hover)}.bento-grid-card:hover .bento-grid-icon,.bento-grid-card:focus-within .bento-grid-icon{scale:.75}@container (width>=560px){.bento-grid-card{grid-column:span var(--span)}.bento-grid-cta{opacity:0;padding:var(--padding);transition:opacity var(--duration) var(--ease), translate var(--duration) var(--ease);bottom:0;position:absolute;inset-inline:0;translate:0 40px}.bento-grid-card:hover .bento-grid-content,.bento-grid-card:focus-within .bento-grid-content{translate:0 -40px}.bento-grid-card:hover .bento-grid-cta,.bento-grid-card:focus-within .bento-grid-cta{opacity:1;translate:0}}@media (prefers-reduced-motion:reduce){.bento-grid-arrow,.bento-grid-content,.bento-grid-icon{transition:none}.bento-grid-cta{translate:0!important}}}
|
|
2
2
|
/*$vite$:1*/
|
|
@@ -50,6 +50,7 @@ export { default as modal } from './modal/index.js';
|
|
|
50
50
|
export { default as morphingButton } from './morphing-button/index.js';
|
|
51
51
|
export { default as morphingNav } from './morphing-nav/index.js';
|
|
52
52
|
export { default as multiStepForm } from './multi-step-form/index.js';
|
|
53
|
+
export { default as navigationMenu } from './navigation-menu/index.js';
|
|
53
54
|
export { default as nestedMenu } from './nested-menu/index.js';
|
|
54
55
|
export { default as notificationBell } from './notification-bell/index.js';
|
|
55
56
|
export { default as number } from './number/index.js';
|
|
@@ -58,6 +59,7 @@ export { default as overlay } from './overlay/index.js';
|
|
|
58
59
|
export { default as pageDots } from './page-dots/index.js';
|
|
59
60
|
export { default as pagination } from './pagination/index.js';
|
|
60
61
|
export { default as password } from './password/index.js';
|
|
62
|
+
export { default as planCard } from './plan-card/index.js';
|
|
61
63
|
export { default as progress } from './progress/index.js';
|
|
62
64
|
export { default as pullToRefresh } from './pull-to-refresh/index.js';
|
|
63
65
|
export { default as radio } from './radio/index.js';
|
|
@@ -92,6 +94,7 @@ export { default as statusPicker } from './status-picker/index.js';
|
|
|
92
94
|
export { default as stickyHeader } from './sticky-header/index.js';
|
|
93
95
|
export { default as stickyStack } from './sticky-stack/index.js';
|
|
94
96
|
export { default as storyProgress } from './story-progress/index.js';
|
|
97
|
+
export { default as surfaceField } from './surface-field/index.js';
|
|
95
98
|
export { default as swipeDeck } from './swipe-deck/index.js';
|
|
96
99
|
export { default as switch } from './switch/index.js';
|
|
97
100
|
export { default as tagInput } from './tag-input/index.js';
|
|
@@ -50,6 +50,7 @@ export { default as modal } from './modal/index.js';
|
|
|
50
50
|
export { default as morphingButton } from './morphing-button/index.js';
|
|
51
51
|
export { default as morphingNav } from './morphing-nav/index.js';
|
|
52
52
|
export { default as multiStepForm } from './multi-step-form/index.js';
|
|
53
|
+
export { default as navigationMenu } from './navigation-menu/index.js';
|
|
53
54
|
export { default as nestedMenu } from './nested-menu/index.js';
|
|
54
55
|
export { default as notificationBell } from './notification-bell/index.js';
|
|
55
56
|
export { default as number } from './number/index.js';
|
|
@@ -58,6 +59,7 @@ export { default as overlay } from './overlay/index.js';
|
|
|
58
59
|
export { default as pageDots } from './page-dots/index.js';
|
|
59
60
|
export { default as pagination } from './pagination/index.js';
|
|
60
61
|
export { default as password } from './password/index.js';
|
|
62
|
+
export { default as planCard } from './plan-card/index.js';
|
|
61
63
|
export { default as progress } from './progress/index.js';
|
|
62
64
|
export { default as pullToRefresh } from './pull-to-refresh/index.js';
|
|
63
65
|
export { default as radio } from './radio/index.js';
|
|
@@ -92,6 +94,7 @@ export { default as statusPicker } from './status-picker/index.js';
|
|
|
92
94
|
export { default as stickyHeader } from './sticky-header/index.js';
|
|
93
95
|
export { default as stickyStack } from './sticky-stack/index.js';
|
|
94
96
|
export { default as storyProgress } from './story-progress/index.js';
|
|
97
|
+
export { default as surfaceField } from './surface-field/index.js';
|
|
95
98
|
export { default as swipeDeck } from './swipe-deck/index.js';
|
|
96
99
|
export { default as switch } from './switch/index.js';
|
|
97
100
|
export { default as tagInput } from './tag-input/index.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Attributes, type Renderable } from '@esportsplus/template';
|
|
2
|
+
import './scss/index.scss';
|
|
3
|
+
type A = Attributes & {
|
|
4
|
+
[NAVIGATION_MENU_POPUP]?: Attributes;
|
|
5
|
+
[NAVIGATION_MENU_TRIGGER]?: Attributes;
|
|
6
|
+
align?: Align;
|
|
7
|
+
items: Item[];
|
|
8
|
+
label?: string;
|
|
9
|
+
state?: State;
|
|
10
|
+
};
|
|
11
|
+
type Align = 'center' | 'end' | 'start';
|
|
12
|
+
type Item = {
|
|
13
|
+
content?: Renderable<unknown>;
|
|
14
|
+
href?: string;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
type State = {
|
|
18
|
+
active: number;
|
|
19
|
+
};
|
|
20
|
+
declare const NAVIGATION_MENU_POPUP: unique symbol;
|
|
21
|
+
declare const NAVIGATION_MENU_TRIGGER: unique symbol;
|
|
22
|
+
declare const navigationMenu: ({ align, items, label, state, ...attributes }: A) => DocumentFragment | Text;
|
|
23
|
+
declare const _default: typeof navigationMenu & {
|
|
24
|
+
readonly popup: typeof NAVIGATION_MENU_POPUP;
|
|
25
|
+
readonly trigger: typeof NAVIGATION_MENU_TRIGGER;
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|
|
28
|
+
export type { Align, Item, State };
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import * as template_u1 from '@esportsplus/template';
|
|
2
|
+
import * as reactivity_u0 from '@esportsplus/reactivity';
|
|
3
|
+
import { effect, onCleanup, untrack } from '@esportsplus/reactivity';
|
|
4
|
+
import './scss/index.scss';
|
|
5
|
+
const template_064zmt32 = template_u1.template(`<nav class='navigation-menu'><ul class='navigation-menu-list'><li aria-hidden='true' class='navigation-menu-pill'></li></ul><div class='navigation-menu-popup'><div class='navigation-menu-viewport'>`);
|
|
6
|
+
const template_064zmt39 = template_u1.template(`<li class='navigation-menu-item'>`);
|
|
7
|
+
const template_064zmt3c = template_u1.template(`<button class='navigation-menu-trigger' type='button'><!--$--><svg aria-hidden='true' class='navigation-menu-chevron' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'><path d='m8 9 4-4 4 4M16 15l-4 4-4-4' />`);
|
|
8
|
+
const template_064zmt3g = template_u1.template(`<a class='navigation-menu-trigger navigation-menu-trigger--link'>`);
|
|
9
|
+
const template_064zmt3j = template_u1.template(`<div class='navigation-menu-content'>`);
|
|
10
|
+
class ReactiveObject_064zmt30 extends reactivity_u0.ReactiveObject {
|
|
11
|
+
#active = this[reactivity_u0.SIGNAL](-1);
|
|
12
|
+
constructor() {
|
|
13
|
+
super(null);
|
|
14
|
+
}
|
|
15
|
+
get active() {
|
|
16
|
+
return reactivity_u0.read(this.#active);
|
|
17
|
+
}
|
|
18
|
+
set active(_v0) {
|
|
19
|
+
reactivity_u0.write(this.#active, _v0);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const CLOSE_GRACE = 150;
|
|
23
|
+
const COLLISION_PADDING = 16;
|
|
24
|
+
const CONTENT_EASE = 'cubic-bezier(0.32, 0.72, 0, 1)';
|
|
25
|
+
const EASE_OUT = 'cubic-bezier(0.23, 1, 0.32, 1)';
|
|
26
|
+
const FOCUSABLE = 'a[href], button:not([disabled])';
|
|
27
|
+
const NAVIGATION_MENU_POPUP = Symbol.for('@esportsplus/ui/navigation-menu.popup');
|
|
28
|
+
const NAVIGATION_MENU_TRIGGER = Symbol.for('@esportsplus/ui/navigation-menu.trigger');
|
|
29
|
+
const OPEN_INTENT = 50;
|
|
30
|
+
const SIDE_OFFSET = 8;
|
|
31
|
+
const SLIDE = 32;
|
|
32
|
+
let uid = 0;
|
|
33
|
+
function reduced() {
|
|
34
|
+
return matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
35
|
+
}
|
|
36
|
+
const navigationMenu = ({ align = 'start', items, label = 'Main', state, ...attributes }) => {
|
|
37
|
+
let closeTimer, current = -1, hiding, id = `navigation-menu-${++uid}`, inside = false, layers = [], list, nav, observer, openTimer, pill, popup, running = new Map(), s = state ?? new ReactiveObject_064zmt30(), triggers = [];
|
|
38
|
+
function animate(element, keyframes, duration, easing = CONTENT_EASE) {
|
|
39
|
+
running.get(element)?.cancel();
|
|
40
|
+
let animation = element.animate(keyframes, { duration, easing });
|
|
41
|
+
running.set(element, animation);
|
|
42
|
+
return animation;
|
|
43
|
+
}
|
|
44
|
+
function close(refocus = false) {
|
|
45
|
+
clearTimeout(openTimer);
|
|
46
|
+
clearTimeout(closeTimer);
|
|
47
|
+
let previous = current;
|
|
48
|
+
if (previous === -1) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
current = -1;
|
|
52
|
+
s.active = -1;
|
|
53
|
+
hide();
|
|
54
|
+
if (refocus) {
|
|
55
|
+
triggers[previous]?.focus();
|
|
56
|
+
}
|
|
57
|
+
if (!inside) {
|
|
58
|
+
settle();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function focusables() {
|
|
62
|
+
let layer = current === -1 ? undefined : layers[current];
|
|
63
|
+
return layer ? [...layer.querySelectorAll(FOCUSABLE)] : [];
|
|
64
|
+
}
|
|
65
|
+
function hide() {
|
|
66
|
+
let element = popup;
|
|
67
|
+
if (!element) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
hiding?.cancel();
|
|
71
|
+
let animation = element.animate([{}, reduced() ? { opacity: 0 } : { opacity: 0, transform: 'scale(0.96)' }], { duration: 160, easing: EASE_OUT, fill: 'forwards' });
|
|
72
|
+
hiding = animation;
|
|
73
|
+
animation.finished.then(() => {
|
|
74
|
+
element.classList.remove('--active');
|
|
75
|
+
animation.cancel();
|
|
76
|
+
for (let layer of layers) {
|
|
77
|
+
if (layer) {
|
|
78
|
+
layer.classList.remove('--active', '--leaving');
|
|
79
|
+
layer.inert = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, () => { });
|
|
83
|
+
}
|
|
84
|
+
function open(index) {
|
|
85
|
+
clearTimeout(openTimer);
|
|
86
|
+
clearTimeout(closeTimer);
|
|
87
|
+
let previous = current;
|
|
88
|
+
if (previous === index || !layers[index]) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
current = index;
|
|
92
|
+
s.active = index;
|
|
93
|
+
swap(previous, index);
|
|
94
|
+
place(previous === -1);
|
|
95
|
+
if (!inside) {
|
|
96
|
+
settle();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function pillTo(item) {
|
|
100
|
+
if (!list || !pill) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let bounds = list.getBoundingClientRect(), box = item.getBoundingClientRect(), element = pill, style = element.style;
|
|
104
|
+
style.height = `${box.height}px`;
|
|
105
|
+
style.top = `${box.top - bounds.top}px`;
|
|
106
|
+
style.translate = `${box.left - bounds.left}px 0`;
|
|
107
|
+
style.width = `${box.width}px`;
|
|
108
|
+
if (!element.classList.contains('--active')) {
|
|
109
|
+
element.getBoundingClientRect();
|
|
110
|
+
element.classList.add('--active');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function place(fresh) {
|
|
114
|
+
if (!nav || !popup || current === -1) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
let layer = layers[current], trigger = triggers[current];
|
|
118
|
+
if (!layer || !trigger) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let box = trigger.getBoundingClientRect(), height = layer.offsetHeight, rect = nav.getBoundingClientRect(), viewport = document.documentElement.clientWidth, width = layer.offsetWidth, x = align === 'start'
|
|
122
|
+
? box.left
|
|
123
|
+
: align === 'end'
|
|
124
|
+
? box.right - width
|
|
125
|
+
: box.left + (box.width - width) / 2;
|
|
126
|
+
x = Math.max(COLLISION_PADDING, Math.min(x, viewport - COLLISION_PADDING - width));
|
|
127
|
+
let element = popup, style = element.style, update = () => {
|
|
128
|
+
style.height = `${height}px`;
|
|
129
|
+
style.transformOrigin = `${box.left + box.width / 2 - x}px ${-SIDE_OFFSET}px`;
|
|
130
|
+
style.translate = `${x - rect.left}px ${box.bottom - rect.top + SIDE_OFFSET}px`;
|
|
131
|
+
style.width = `${width}px`;
|
|
132
|
+
};
|
|
133
|
+
if (!fresh) {
|
|
134
|
+
update();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
hiding?.cancel();
|
|
138
|
+
hiding = undefined;
|
|
139
|
+
element.classList.add('--instant');
|
|
140
|
+
update();
|
|
141
|
+
element.getBoundingClientRect();
|
|
142
|
+
element.classList.remove('--instant');
|
|
143
|
+
element.classList.add('--active');
|
|
144
|
+
if (reduced()) {
|
|
145
|
+
animate(element, [{ opacity: 0 }, { opacity: 1 }], 160, EASE_OUT);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
running.get(element)?.cancel();
|
|
149
|
+
running.set(element, element.animate([
|
|
150
|
+
{ opacity: 0, offset: 0, transform: 'perspective(600px) rotateX(-20deg) scale(0.94)' },
|
|
151
|
+
{ opacity: 1, offset: 0.53 },
|
|
152
|
+
{ opacity: 1, transform: 'none' }
|
|
153
|
+
], { duration: 300, easing: EASE_OUT }));
|
|
154
|
+
}
|
|
155
|
+
function settle() {
|
|
156
|
+
let trigger = current === -1 ? undefined : triggers[current];
|
|
157
|
+
if (trigger) {
|
|
158
|
+
pillTo(trigger);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
pill?.classList.remove('--active');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function swap(previous, next) {
|
|
165
|
+
let dir = next > previous ? 1 : -1, incoming = layers[next], outgoing = previous === -1 ? undefined : layers[previous], reduce = reduced();
|
|
166
|
+
for (let i = 0, n = layers.length; i < n; i++) {
|
|
167
|
+
let layer = layers[i];
|
|
168
|
+
if (!layer || layer === incoming || layer === outgoing) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
running.get(layer)?.cancel();
|
|
172
|
+
layer.classList.remove('--active', '--leaving');
|
|
173
|
+
layer.inert = true;
|
|
174
|
+
}
|
|
175
|
+
if (outgoing) {
|
|
176
|
+
let layer = outgoing;
|
|
177
|
+
layer.classList.remove('--active');
|
|
178
|
+
layer.classList.add('--leaving');
|
|
179
|
+
layer.inert = true;
|
|
180
|
+
animate(layer, [
|
|
181
|
+
{ opacity: 1, translate: '0 0' },
|
|
182
|
+
{ opacity: 0, translate: `${reduce ? 0 : -dir * SLIDE}px 0` }
|
|
183
|
+
], 200).onfinish = () => layer.classList.remove('--leaving');
|
|
184
|
+
}
|
|
185
|
+
if (!incoming) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
incoming.classList.remove('--leaving');
|
|
189
|
+
incoming.classList.add('--active');
|
|
190
|
+
incoming.inert = false;
|
|
191
|
+
if (!outgoing) {
|
|
192
|
+
running.get(incoming)?.cancel();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
animate(incoming, [
|
|
196
|
+
{ opacity: 0, translate: `${reduce ? 0 : dir * SLIDE}px 0` },
|
|
197
|
+
{ opacity: 1, translate: '0 0' }
|
|
198
|
+
], 200);
|
|
199
|
+
}
|
|
200
|
+
function trigger(index, e) {
|
|
201
|
+
let key = e.key;
|
|
202
|
+
if (key === 'ArrowDown' && layers[index]) {
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
open(index);
|
|
205
|
+
focusables()[0]?.focus();
|
|
206
|
+
}
|
|
207
|
+
else if (key === 'ArrowLeft' || key === 'ArrowRight') {
|
|
208
|
+
let n = triggers.length;
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
triggers[(index + (key === 'ArrowRight' ? 1 : -1) + n) % n]?.focus();
|
|
211
|
+
}
|
|
212
|
+
else if (key === 'Escape' && current !== -1) {
|
|
213
|
+
e.preventDefault();
|
|
214
|
+
close();
|
|
215
|
+
}
|
|
216
|
+
else if (key === 'Tab' && !e.shiftKey && current === index) {
|
|
217
|
+
let first = focusables()[0];
|
|
218
|
+
if (first) {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
first.focus();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
let stop = effect(() => {
|
|
225
|
+
let active = s.active;
|
|
226
|
+
untrack(() => {
|
|
227
|
+
if (active === current) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (active === -1) {
|
|
231
|
+
close();
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
open(active);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
onCleanup(() => {
|
|
239
|
+
clearTimeout(closeTimer);
|
|
240
|
+
clearTimeout(openTimer);
|
|
241
|
+
hiding?.cancel();
|
|
242
|
+
observer?.disconnect();
|
|
243
|
+
stop();
|
|
244
|
+
for (let animation of running.values()) {
|
|
245
|
+
animation.cancel();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
return (() => {
|
|
249
|
+
let root_064zmt31 = template_064zmt32(), element_064zmt33 = root_064zmt31.firstChild, element_064zmt34 = element_064zmt33.firstElementChild, element_064zmt35 = element_064zmt34.firstElementChild, element_064zmt36 = element_064zmt34.nextElementSibling, element_064zmt37 = element_064zmt36.firstElementChild;
|
|
250
|
+
template_u1.setProperties(element_064zmt33, attributes);
|
|
251
|
+
template_u1.setProperty(element_064zmt33, 'aria-label', label);
|
|
252
|
+
template_u1.ondocument(element_064zmt33, 'pointerdown', (e) => {
|
|
253
|
+
if (current !== -1 && nav && !nav.contains(e.target)) {
|
|
254
|
+
close();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
template_u1.onconnect(element_064zmt33, (element) => {
|
|
258
|
+
nav = element;
|
|
259
|
+
observer = new ResizeObserver(() => place(false));
|
|
260
|
+
observer.observe(element);
|
|
261
|
+
for (let layer of layers) {
|
|
262
|
+
if (layer) {
|
|
263
|
+
observer.observe(layer);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
template_u1.on(element_064zmt33, 'focusout', (e) => {
|
|
268
|
+
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
269
|
+
close();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
template_u1.on(element_064zmt33, 'pointerenter', (e) => {
|
|
273
|
+
if (e.pointerType !== 'touch') {
|
|
274
|
+
clearTimeout(closeTimer);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
template_u1.on(element_064zmt33, 'pointerleave', (e) => {
|
|
278
|
+
if (e.pointerType === 'touch') {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
clearTimeout(openTimer);
|
|
282
|
+
if (current !== -1) {
|
|
283
|
+
clearTimeout(closeTimer);
|
|
284
|
+
closeTimer = setTimeout(() => close(), CLOSE_GRACE);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
template_u1.on(element_064zmt34, 'pointerleave', () => {
|
|
288
|
+
inside = false;
|
|
289
|
+
settle();
|
|
290
|
+
});
|
|
291
|
+
template_u1.onrender(element_064zmt34, (element) => {
|
|
292
|
+
list = element;
|
|
293
|
+
});
|
|
294
|
+
template_u1.onrender(element_064zmt35, (element) => { pill = element; });
|
|
295
|
+
template_u1.slot(element_064zmt34, items.map((item, index) => {
|
|
296
|
+
let root_064zmt38 = template_064zmt39(), element_064zmt3a = root_064zmt38.firstChild;
|
|
297
|
+
element_064zmt3a.appendChild(item.content
|
|
298
|
+
? (() => {
|
|
299
|
+
let root_064zmt3b = template_064zmt3c(), element_064zmt3d = root_064zmt3b.firstChild, element_064zmt3e = element_064zmt3d.firstChild;
|
|
300
|
+
template_u1.setProperties(element_064zmt3d, attributes[NAVIGATION_MENU_TRIGGER]);
|
|
301
|
+
template_u1.setProperty(element_064zmt3d, 'aria-controls', () => s.active === index && `${id}-popup`);
|
|
302
|
+
template_u1.setProperty(element_064zmt3d, 'aria-expanded', () => String(s.active === index));
|
|
303
|
+
template_u1.setList(element_064zmt3d, 'class', () => s.active === index && '--active');
|
|
304
|
+
template_u1.delegate(element_064zmt3d, 'click', (e) => {
|
|
305
|
+
if (current === index && (e.detail === 0 || e.pointerType === 'touch')) {
|
|
306
|
+
close();
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
open(index);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
template_u1.on(element_064zmt3d, 'focus', (e) => {
|
|
313
|
+
pillTo(e.currentTarget);
|
|
314
|
+
if (current !== -1 && current !== index) {
|
|
315
|
+
open(index);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
template_u1.delegate(element_064zmt3d, 'keydown', (e) => trigger(index, e));
|
|
319
|
+
template_u1.on(element_064zmt3d, 'pointerenter', (e) => {
|
|
320
|
+
if (e.pointerType === 'touch') {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
inside = true;
|
|
324
|
+
pillTo(e.currentTarget);
|
|
325
|
+
clearTimeout(openTimer);
|
|
326
|
+
if (current !== -1) {
|
|
327
|
+
open(index);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
openTimer = setTimeout(() => open(index), OPEN_INTENT);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
template_u1.on(element_064zmt3d, 'pointerleave', () => {
|
|
334
|
+
if (current === -1) {
|
|
335
|
+
clearTimeout(openTimer);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
template_u1.onrender(element_064zmt3d, (element) => {
|
|
339
|
+
triggers[index] = element;
|
|
340
|
+
});
|
|
341
|
+
template_u1.slot(element_064zmt3e, item.label);
|
|
342
|
+
return root_064zmt3b;
|
|
343
|
+
})()
|
|
344
|
+
: (() => {
|
|
345
|
+
let root_064zmt3f = template_064zmt3g(), element_064zmt3h = root_064zmt3f.firstChild;
|
|
346
|
+
template_u1.setProperty(element_064zmt3h, 'href', item.href ?? '#');
|
|
347
|
+
template_u1.setProperties(element_064zmt3h, attributes[NAVIGATION_MENU_TRIGGER]);
|
|
348
|
+
template_u1.on(element_064zmt3h, 'focus', (e) => pillTo(e.currentTarget));
|
|
349
|
+
template_u1.delegate(element_064zmt3h, 'keydown', (e) => trigger(index, e));
|
|
350
|
+
template_u1.on(element_064zmt3h, 'pointerenter', (e) => {
|
|
351
|
+
if (e.pointerType === 'touch') {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
inside = true;
|
|
355
|
+
pillTo(e.currentTarget);
|
|
356
|
+
clearTimeout(openTimer);
|
|
357
|
+
if (current !== -1) {
|
|
358
|
+
clearTimeout(closeTimer);
|
|
359
|
+
closeTimer = setTimeout(() => close(), CLOSE_GRACE);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
template_u1.onrender(element_064zmt3h, (element) => {
|
|
363
|
+
triggers[index] = element;
|
|
364
|
+
});
|
|
365
|
+
template_u1.slot(element_064zmt3h, item.label, 1);
|
|
366
|
+
return root_064zmt3f;
|
|
367
|
+
})());
|
|
368
|
+
return root_064zmt38;
|
|
369
|
+
}), 2);
|
|
370
|
+
template_u1.setProperty(element_064zmt36, 'id', template_u1.interpolate([(id), "-popup"]));
|
|
371
|
+
template_u1.setProperties(element_064zmt36, attributes[NAVIGATION_MENU_POPUP]);
|
|
372
|
+
template_u1.delegate(element_064zmt36, 'click', (e) => {
|
|
373
|
+
if (e.target.closest('a')) {
|
|
374
|
+
close();
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
template_u1.delegate(element_064zmt36, 'keydown', (e) => {
|
|
378
|
+
if (current === -1) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
let list = focusables(), at = list.indexOf(document.activeElement), key = e.key;
|
|
382
|
+
if (key === 'Escape') {
|
|
383
|
+
e.preventDefault();
|
|
384
|
+
close(true);
|
|
385
|
+
}
|
|
386
|
+
else if (key === 'ArrowDown' || key === 'ArrowUp') {
|
|
387
|
+
let n = list.length;
|
|
388
|
+
e.preventDefault();
|
|
389
|
+
list[(at + (key === 'ArrowDown' ? 1 : -1) + n) % n]?.focus();
|
|
390
|
+
}
|
|
391
|
+
else if (key === 'Tab' && e.shiftKey && at === 0) {
|
|
392
|
+
e.preventDefault();
|
|
393
|
+
triggers[current]?.focus();
|
|
394
|
+
}
|
|
395
|
+
else if (key === 'Tab' && !e.shiftKey && at === list.length - 1) {
|
|
396
|
+
let next = triggers[current + 1];
|
|
397
|
+
close();
|
|
398
|
+
if (next) {
|
|
399
|
+
e.preventDefault();
|
|
400
|
+
next.focus();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
template_u1.onrender(element_064zmt36, (element) => {
|
|
405
|
+
popup = element;
|
|
406
|
+
});
|
|
407
|
+
template_u1.slot(element_064zmt37, items.map((item, index) => item.content && (() => {
|
|
408
|
+
let root_064zmt3i = template_064zmt3j(), element_064zmt3k = root_064zmt3i.firstChild;
|
|
409
|
+
template_u1.onrender(element_064zmt3k, (element) => {
|
|
410
|
+
element.inert = true;
|
|
411
|
+
layers[index] = element;
|
|
412
|
+
});
|
|
413
|
+
template_u1.slot(element_064zmt3k, item.content, 1);
|
|
414
|
+
return root_064zmt3i;
|
|
415
|
+
})()), 1);
|
|
416
|
+
return root_064zmt31;
|
|
417
|
+
})();
|
|
418
|
+
};
|
|
419
|
+
export default Object.assign(navigationMenu, { popup: NAVIGATION_MENU_POPUP, trigger: NAVIGATION_MENU_TRIGGER });
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
@layer components {.navigation-menu{--background:var(--color-white-300);--box-shadow:0 0 0 var(--border-width-400) oklch(from var(--color-black-300) l c h / .1), var(--box-shadow-300);--color:var(--color-text-500);--description-color:var(--color-text-300);--description-font-size:.875rem;--focus-color:var(--color-text-500);--font-size:.875rem;--gap:8px;--hover-background:oklch(94.5% 0 0);--link-radius:8px;--pill-duration:.25s;--pill-timing-function:cubic-bezier(.22, 1, .36, 1);--popup-duration:.2s;--popup-radius:12px;--title-font-size:.9375rem;--trigger-height:36px;--trigger-padding:12px}.navigation-menu--muted{--hover-background:var(--color-grey-400)}.navigation-menu{font-size:var(--font-size);width:max-content;max-width:100%;display:flex;position:relative}.navigation-menu-chevron{flex-shrink:0;width:12px;height:12px;margin-left:4px;position:relative;top:1px}.navigation-menu-content{visibility:hidden;width:max-content;max-width:calc(100vw - 32px);padding:4px;position:absolute;top:0;left:0}.navigation-menu-content.--active,.navigation-menu-content.--leaving{visibility:visible}.navigation-menu-content.--leaving{pointer-events:none}.navigation-menu-item{position:relative}.navigation-menu-link{border-radius:var(--link-radius);color:var(--color);text-align:left;outline:none;flex-direction:column;align-items:flex-start;gap:2px;padding:8px 12px 8px 16px;text-decoration:none;transition:background-color .15s ease-out;display:flex}.navigation-menu-link:focus-visible{outline:2px solid var(--focus-color);outline-offset:-2px}.navigation-menu-link:hover,.navigation-menu-link:focus-visible{background:var(--hover-background)}.navigation-menu-link--compact{color:var(--description-color);flex-direction:row;align-items:center;gap:6px;padding:4px 8px}.navigation-menu-link--compact:hover{color:var(--color)}.navigation-menu-link-description{color:var(--description-color);font-size:var(--description-font-size);line-height:1.625}.navigation-menu-link-title{font-size:var(--title-font-size);font-weight:var(--font-weight-600)}.navigation-menu-list{align-items:center;gap:var(--gap);flex-wrap:wrap;justify-content:center;margin:0;padding:0;list-style:none;display:flex;position:relative}.navigation-menu-pill{background:var(--hover-background);opacity:0;pointer-events:none;transition:opacity .15s var(--pill-timing-function);border-radius:999px;position:absolute;top:0;left:0}.navigation-menu-pill.--active{opacity:1;transition:opacity var(--pill-duration) var(--pill-timing-function), translate var(--pill-duration) var(--pill-timing-function), width var(--pill-duration) var(--pill-timing-function)}.navigation-menu-popup{background:var(--background);border-radius:var(--popup-radius);box-shadow:var(--box-shadow);color:var(--color);opacity:0;pointer-events:none;transition:height var(--popup-duration) cubic-bezier(.23, 1, .32, 1), translate var(--popup-duration) cubic-bezier(.23, 1, .32, 1), width var(--popup-duration) cubic-bezier(.23, 1, .32, 1);visibility:hidden;z-index:50;position:absolute;top:0;left:0}.navigation-menu-popup:before{content:"";inset-inline:0;height:10px;position:absolute;top:-10px}.navigation-menu-popup.--active{opacity:1;pointer-events:auto;visibility:visible}.navigation-menu-popup.--instant{transition:none}.navigation-menu-trigger{color:var(--color);cursor:pointer;font-size:inherit;font-weight:var(--font-weight-500);height:var(--trigger-height);padding-inline:var(--trigger-padding);touch-action:manipulation;-webkit-user-select:none;user-select:none;white-space:nowrap;background:0 0;border:0;border-radius:999px;outline:none;justify-content:center;align-items:center;text-decoration:none;display:inline-flex;position:relative}.navigation-menu-trigger:focus-visible{outline:2px solid var(--focus-color)}.navigation-menu-trigger.--active:after{content:"";inset-block:0;inset-inline:calc(var(--gap) * -1);position:absolute}.navigation-menu-trigger--link{padding-inline:10px}.navigation-menu-viewport{width:100%;height:100%;position:relative;overflow:hidden}@media (prefers-reduced-motion:reduce){.navigation-menu{--pill-duration:0s;--popup-duration:0s}}}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Attributes, type Renderable } from '@esportsplus/template';
|
|
2
|
+
import './scss/index.scss';
|
|
3
|
+
type A = Attributes & {
|
|
4
|
+
[PLAN_CARD_APPROVE]?: Attributes;
|
|
5
|
+
[PLAN_CARD_VIEW]?: Attributes;
|
|
6
|
+
autoApprove?: number;
|
|
7
|
+
description?: Renderable<unknown>;
|
|
8
|
+
icon?: Renderable<unknown>;
|
|
9
|
+
onapprove?: (auto: boolean) => void;
|
|
10
|
+
ondownload?: VoidFunction;
|
|
11
|
+
onexpand?: VoidFunction;
|
|
12
|
+
onkeydown?: never;
|
|
13
|
+
onview?: VoidFunction;
|
|
14
|
+
peek?: number;
|
|
15
|
+
state?: State;
|
|
16
|
+
title: string;
|
|
17
|
+
todos: Todo[];
|
|
18
|
+
};
|
|
19
|
+
type State = {
|
|
20
|
+
approved: boolean;
|
|
21
|
+
countdown: number;
|
|
22
|
+
expanded: boolean;
|
|
23
|
+
};
|
|
24
|
+
type Todo = {
|
|
25
|
+
done?: boolean;
|
|
26
|
+
label: string;
|
|
27
|
+
};
|
|
28
|
+
declare const PLAN_CARD_APPROVE: unique symbol;
|
|
29
|
+
declare const PLAN_CARD_VIEW: unique symbol;
|
|
30
|
+
declare const planCard: ({ autoApprove, description, icon, onapprove, ondownload, onexpand, onview, peek, state, title, todos, ...attributes }: A) => DocumentFragment | Text;
|
|
31
|
+
declare const _default: typeof planCard & {
|
|
32
|
+
readonly approve: typeof PLAN_CARD_APPROVE;
|
|
33
|
+
readonly view: typeof PLAN_CARD_VIEW;
|
|
34
|
+
};
|
|
35
|
+
export default _default;
|
|
36
|
+
export type { State, Todo };
|