create-dalila 1.1.13 → 1.2.0
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 +1 -1
- package/template/src/components/ui/accordion/accordion.css +90 -0
- package/template/src/components/ui/accordion/index.ts +121 -0
- package/template/src/components/ui/alert/alert.css +78 -0
- package/template/src/components/ui/avatar/avatar.css +45 -0
- package/template/src/components/ui/badge/badge.css +71 -0
- package/template/src/components/ui/breadcrumb/breadcrumb.css +41 -0
- package/template/src/components/ui/button/button.css +135 -0
- package/template/src/components/ui/calendar/calendar.css +96 -0
- package/template/src/components/ui/calendar/index.ts +157 -0
- package/template/src/components/ui/card/card.css +93 -0
- package/template/src/components/ui/checkbox/checkbox.css +57 -0
- package/template/src/components/ui/chip/chip.css +62 -0
- package/template/src/components/ui/collapsible/collapsible.css +61 -0
- package/template/src/components/ui/combobox/combobox.css +85 -0
- package/template/src/components/ui/combobox/index.ts +181 -0
- package/template/src/components/ui/dalila/dalila.css +42 -0
- package/template/src/components/ui/dalila-core/dalila-core.css +14 -0
- package/template/src/components/ui/dialog/dialog.css +125 -0
- package/template/src/components/ui/dialog/index.ts +68 -0
- package/template/src/components/ui/drawer/drawer.css +122 -0
- package/template/src/components/ui/drawer/index.ts +53 -0
- package/template/src/components/ui/dropdown/dropdown.css +87 -0
- package/template/src/components/ui/dropdown/index.ts +57 -0
- package/template/src/components/ui/dropzone/dropzone.css +47 -0
- package/template/src/components/ui/dropzone/index.ts +114 -0
- package/template/src/components/ui/empty-state/empty-state.css +33 -0
- package/template/src/components/ui/env.ts +4 -0
- package/template/src/components/ui/form/form.css +44 -0
- package/template/src/components/ui/index.ts +13 -0
- package/template/src/components/ui/input/input.css +106 -0
- package/template/src/components/ui/layout/layout.css +62 -0
- package/template/src/components/ui/pagination/pagination.css +55 -0
- package/template/src/components/ui/popover/index.ts +185 -0
- package/template/src/components/ui/popover/popover.css +55 -0
- package/template/src/components/ui/radio/radio.css +56 -0
- package/template/src/components/ui/runtime.ts +514 -0
- package/template/src/components/ui/separator/separator.css +38 -0
- package/template/src/components/ui/skeleton/skeleton.css +57 -0
- package/template/src/components/ui/slider/slider.css +60 -0
- package/template/src/components/ui/spinner/spinner.css +38 -0
- package/template/src/components/ui/table/table.css +54 -0
- package/template/src/components/ui/tabs/index.ts +128 -0
- package/template/src/components/ui/tabs/tabs.css +74 -0
- package/template/src/components/ui/toast/index.ts +144 -0
- package/template/src/components/ui/toast/toast.css +100 -0
- package/template/src/components/ui/toggle/toggle.css +90 -0
- package/template/src/components/ui/tokens/tokens.css +161 -0
- package/template/src/components/ui/tooltip/tooltip.css +53 -0
- package/template/src/components/ui/typography/typography.css +81 -0
- package/template/src/components/ui/ui-types.ts +238 -0
- package/template/src/components/ui/validate.ts +83 -0
- package/template/src/style.css +13 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Dalila UI — All components
|
|
3
|
+
* Import this single file to get everything.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* <link rel="stylesheet" href="dalila.css" />
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
@import "./tokens.css";
|
|
10
|
+
@import "./typography.css";
|
|
11
|
+
@import "./layout.css";
|
|
12
|
+
@import "./button.css";
|
|
13
|
+
@import "./input.css";
|
|
14
|
+
@import "./checkbox.css";
|
|
15
|
+
@import "./radio.css";
|
|
16
|
+
@import "./slider.css";
|
|
17
|
+
@import "./toggle.css";
|
|
18
|
+
@import "./form.css";
|
|
19
|
+
@import "./card.css";
|
|
20
|
+
@import "./badge.css";
|
|
21
|
+
@import "./chip.css";
|
|
22
|
+
@import "./avatar.css";
|
|
23
|
+
@import "./alert.css";
|
|
24
|
+
@import "./toast.css";
|
|
25
|
+
@import "./tooltip.css";
|
|
26
|
+
@import "./popover.css";
|
|
27
|
+
@import "./dropdown.css";
|
|
28
|
+
@import "./combobox.css";
|
|
29
|
+
@import "./tabs.css";
|
|
30
|
+
@import "./accordion.css";
|
|
31
|
+
@import "./collapsible.css";
|
|
32
|
+
@import "./dialog.css";
|
|
33
|
+
@import "./drawer.css";
|
|
34
|
+
@import "./table.css";
|
|
35
|
+
@import "./pagination.css";
|
|
36
|
+
@import "./breadcrumb.css";
|
|
37
|
+
@import "./separator.css";
|
|
38
|
+
@import "./skeleton.css";
|
|
39
|
+
@import "./spinner.css";
|
|
40
|
+
@import "./empty-state.css";
|
|
41
|
+
@import "./calendar.css";
|
|
42
|
+
@import "./dropzone.css";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Dalila UI — Core (minimal)
|
|
3
|
+
* Tokens + typography + layout + button + input + form.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* <link rel="stylesheet" href="dalila-core.css" />
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
@import "./tokens.css";
|
|
10
|
+
@import "./typography.css";
|
|
11
|
+
@import "./layout.css";
|
|
12
|
+
@import "./button.css";
|
|
13
|
+
@import "./input.css";
|
|
14
|
+
@import "./form.css";
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/* Dalila UI — Dialog */
|
|
2
|
+
|
|
3
|
+
.d-dialog::backdrop {
|
|
4
|
+
background: var(--d-surface-overlay);
|
|
5
|
+
backdrop-filter: blur(4px);
|
|
6
|
+
-webkit-backdrop-filter: blur(4px);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.d-dialog {
|
|
10
|
+
position: fixed;
|
|
11
|
+
inset: 0;
|
|
12
|
+
margin: auto;
|
|
13
|
+
max-width: min(28rem, calc(100vw - var(--d-space-8)));
|
|
14
|
+
max-height: calc(100vh - var(--d-space-8));
|
|
15
|
+
width: 100%;
|
|
16
|
+
|
|
17
|
+
padding: 0;
|
|
18
|
+
border: 1px solid var(--d-border-color);
|
|
19
|
+
border-radius: var(--d-radius-lg);
|
|
20
|
+
background: var(--d-surface-card);
|
|
21
|
+
color: var(--d-text-primary);
|
|
22
|
+
|
|
23
|
+
box-shadow: var(--d-shadow-lg);
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
|
|
26
|
+
opacity: 0;
|
|
27
|
+
transform: scale(0.97) translateY(8px);
|
|
28
|
+
transition:
|
|
29
|
+
opacity var(--d-duration-slow) var(--d-ease),
|
|
30
|
+
transform var(--d-duration-slow) var(--d-ease),
|
|
31
|
+
overlay var(--d-duration-slow) var(--d-ease) allow-discrete,
|
|
32
|
+
display var(--d-duration-slow) var(--d-ease) allow-discrete;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.d-dialog[open] {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
transform: scale(1) translateY(0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@starting-style {
|
|
41
|
+
.d-dialog[open] {
|
|
42
|
+
opacity: 0;
|
|
43
|
+
transform: scale(0.97) translateY(8px);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.d-dialog-header {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: flex-start;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
gap: var(--d-space-4);
|
|
52
|
+
padding: var(--d-space-6) var(--d-space-6) var(--d-space-3);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.d-dialog-title {
|
|
56
|
+
margin: 0;
|
|
57
|
+
font-family: var(--d-font-sans);
|
|
58
|
+
font-size: var(--d-text-xl);
|
|
59
|
+
font-weight: var(--d-font-semibold);
|
|
60
|
+
color: var(--d-text-primary);
|
|
61
|
+
line-height: 1.3;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.d-dialog-body {
|
|
65
|
+
padding: var(--d-space-3) var(--d-space-6);
|
|
66
|
+
font-size: var(--d-text-base);
|
|
67
|
+
color: var(--d-text-secondary);
|
|
68
|
+
line-height: var(--d-leading);
|
|
69
|
+
overflow-y: auto;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.d-dialog-footer {
|
|
73
|
+
display: flex;
|
|
74
|
+
justify-content: flex-end;
|
|
75
|
+
gap: var(--d-space-3);
|
|
76
|
+
padding: var(--d-space-4) var(--d-space-6) var(--d-space-6);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.d-dialog-close {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
|
|
85
|
+
width: 2rem;
|
|
86
|
+
height: 2rem;
|
|
87
|
+
|
|
88
|
+
font-size: var(--d-text-xl);
|
|
89
|
+
color: var(--d-text-muted);
|
|
90
|
+
|
|
91
|
+
background: none;
|
|
92
|
+
border: 1px solid transparent;
|
|
93
|
+
border-radius: var(--d-radius-sm);
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
transition: color var(--d-duration-fast) ease, border-color var(--d-duration-fast) ease;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.d-dialog-close:hover {
|
|
99
|
+
color: var(--d-text-primary);
|
|
100
|
+
border-color: var(--d-border-color);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.d-dialog-sm { max-width: min(22rem, calc(100vw - var(--d-space-8))); }
|
|
104
|
+
.d-dialog-lg { max-width: min(36rem, calc(100vw - var(--d-space-8))); }
|
|
105
|
+
.d-dialog-xl { max-width: min(48rem, calc(100vw - var(--d-space-8))); }
|
|
106
|
+
|
|
107
|
+
@media (max-width: 640px) {
|
|
108
|
+
.d-dialog {
|
|
109
|
+
margin: auto 0 0;
|
|
110
|
+
max-width: 100%;
|
|
111
|
+
max-height: 85vh;
|
|
112
|
+
border-radius: var(--d-radius-lg) var(--d-radius-lg) 0 0;
|
|
113
|
+
transform: translateY(100%);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.d-dialog[open] {
|
|
117
|
+
transform: translateY(0);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@starting-style {
|
|
121
|
+
.d-dialog[open] {
|
|
122
|
+
transform: translateY(100%);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { signal, type Signal } from "../../../core/signal.js";
|
|
2
|
+
import { getCurrentScope } from "../../../core/scope.js";
|
|
3
|
+
import type { Dialog, DialogOptions } from "../ui-types.js";
|
|
4
|
+
import { validateDialogOptions } from "../validate.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shared dialog behavior — used by both createDialog and createDrawer.
|
|
8
|
+
*/
|
|
9
|
+
export function _attachDialogBehavior(
|
|
10
|
+
el: HTMLDialogElement,
|
|
11
|
+
open: Signal<boolean>,
|
|
12
|
+
closeFn: () => void,
|
|
13
|
+
opts: { closeOnBackdrop: boolean; closeOnEscape: boolean }
|
|
14
|
+
): void {
|
|
15
|
+
const scope = getCurrentScope();
|
|
16
|
+
|
|
17
|
+
// Sync signal → native dialog
|
|
18
|
+
const unsub = open.on((isOpen) => {
|
|
19
|
+
if (isOpen && !el.open) el.showModal();
|
|
20
|
+
else if (!isOpen && el.open) el.close();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Native close event → sync signal
|
|
24
|
+
const onClose = () => open.set(false);
|
|
25
|
+
el.addEventListener("close", onClose);
|
|
26
|
+
|
|
27
|
+
// Backdrop click
|
|
28
|
+
const onBackdropClick = (e: MouseEvent) => {
|
|
29
|
+
if (opts.closeOnBackdrop && e.target === el) closeFn();
|
|
30
|
+
};
|
|
31
|
+
el.addEventListener("click", onBackdropClick);
|
|
32
|
+
|
|
33
|
+
// Escape key
|
|
34
|
+
if (!opts.closeOnEscape) {
|
|
35
|
+
const onCancel = (e: Event) => e.preventDefault();
|
|
36
|
+
el.addEventListener("cancel", onCancel);
|
|
37
|
+
if (scope) {
|
|
38
|
+
scope.onCleanup(() => el.removeEventListener("cancel", onCancel));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ARIA
|
|
43
|
+
el.setAttribute("aria-modal", "true");
|
|
44
|
+
|
|
45
|
+
if (scope) {
|
|
46
|
+
scope.onCleanup(() => {
|
|
47
|
+
unsub();
|
|
48
|
+
el.removeEventListener("close", onClose);
|
|
49
|
+
el.removeEventListener("click", onBackdropClick);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function createDialog(options: DialogOptions = {}): Dialog {
|
|
55
|
+
validateDialogOptions(options as Record<string, unknown>);
|
|
56
|
+
const { closeOnBackdrop = true, closeOnEscape = true } = options;
|
|
57
|
+
const open = signal(false);
|
|
58
|
+
|
|
59
|
+
const show = () => open.set(true);
|
|
60
|
+
const close = () => open.set(false);
|
|
61
|
+
const toggle = () => open.update((v) => !v);
|
|
62
|
+
|
|
63
|
+
const _attachTo = (el: HTMLDialogElement) => {
|
|
64
|
+
_attachDialogBehavior(el, open, close, { closeOnBackdrop, closeOnEscape });
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return { open, show, close, toggle, _attachTo };
|
|
68
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* Dalila UI — Drawer & Sheet */
|
|
2
|
+
|
|
3
|
+
.d-drawer::backdrop {
|
|
4
|
+
background: var(--d-surface-overlay);
|
|
5
|
+
backdrop-filter: blur(4px);
|
|
6
|
+
-webkit-backdrop-filter: blur(4px);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.d-drawer {
|
|
10
|
+
position: fixed;
|
|
11
|
+
margin: 0;
|
|
12
|
+
border: none;
|
|
13
|
+
padding: 0;
|
|
14
|
+
max-height: 100vh;
|
|
15
|
+
height: 100%;
|
|
16
|
+
background: var(--d-surface-card);
|
|
17
|
+
color: var(--d-text-primary);
|
|
18
|
+
box-shadow: var(--d-shadow-lg);
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
|
|
21
|
+
inset: 0 0 0 auto;
|
|
22
|
+
width: min(24rem, 85vw);
|
|
23
|
+
border-left: 1px solid var(--d-border-color);
|
|
24
|
+
|
|
25
|
+
opacity: 0;
|
|
26
|
+
transform: translateX(1rem);
|
|
27
|
+
transition:
|
|
28
|
+
transform var(--d-duration-slow) var(--d-ease),
|
|
29
|
+
opacity var(--d-duration-slow) var(--d-ease),
|
|
30
|
+
overlay var(--d-duration-slow) var(--d-ease) allow-discrete,
|
|
31
|
+
display var(--d-duration-slow) var(--d-ease) allow-discrete;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.d-drawer[open] {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
opacity: 1;
|
|
38
|
+
transform: translateX(0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@starting-style {
|
|
42
|
+
.d-drawer[open] {
|
|
43
|
+
opacity: 0;
|
|
44
|
+
transform: translateX(1rem);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Left variant */
|
|
49
|
+
.d-drawer-left {
|
|
50
|
+
inset: 0 auto 0 0;
|
|
51
|
+
border-left: none;
|
|
52
|
+
border-right: 1px solid var(--d-border-color);
|
|
53
|
+
transform: translateX(-1rem);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.d-drawer-left[open] {
|
|
57
|
+
transform: translateX(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@starting-style {
|
|
61
|
+
.d-drawer-left[open] {
|
|
62
|
+
opacity: 0;
|
|
63
|
+
transform: translateX(-1rem);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.d-drawer-header {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
gap: var(--d-space-4);
|
|
72
|
+
padding: var(--d-space-6);
|
|
73
|
+
border-bottom: 1px solid var(--d-border-color);
|
|
74
|
+
flex-shrink: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.d-drawer-title {
|
|
78
|
+
margin: 0;
|
|
79
|
+
font-family: var(--d-font-sans);
|
|
80
|
+
font-size: var(--d-text-xl);
|
|
81
|
+
font-weight: var(--d-font-semibold);
|
|
82
|
+
color: var(--d-text-primary);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.d-drawer-body {
|
|
86
|
+
padding: var(--d-space-6);
|
|
87
|
+
overflow-y: auto;
|
|
88
|
+
flex: 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.d-drawer-footer {
|
|
92
|
+
display: flex;
|
|
93
|
+
justify-content: flex-end;
|
|
94
|
+
gap: var(--d-space-3);
|
|
95
|
+
padding: var(--d-space-4) var(--d-space-6);
|
|
96
|
+
border-top: 1px solid var(--d-border-color);
|
|
97
|
+
flex-shrink: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Sheet variant (bottom) */
|
|
101
|
+
.d-sheet {
|
|
102
|
+
inset: auto 0 0 0;
|
|
103
|
+
width: 100%;
|
|
104
|
+
height: auto;
|
|
105
|
+
max-height: 85vh;
|
|
106
|
+
border-left: none;
|
|
107
|
+
border-top: 1px solid var(--d-border-color);
|
|
108
|
+
border-radius: var(--d-radius-lg) var(--d-radius-lg) 0 0;
|
|
109
|
+
transform: translateY(100%);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.d-sheet[open] {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
transform: translateY(0);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@starting-style {
|
|
119
|
+
.d-sheet[open] {
|
|
120
|
+
transform: translateY(100%);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { signal } from "../../../core/signal.js";
|
|
2
|
+
import { getCurrentScope } from "../../../core/scope.js";
|
|
3
|
+
import { _attachDialogBehavior } from "../dialog/index.js";
|
|
4
|
+
import type { Drawer, DrawerOptions, DrawerSide } from "../ui-types.js";
|
|
5
|
+
import { validateDrawerOptions } from "../validate.js";
|
|
6
|
+
|
|
7
|
+
const SIDE_CLASSES: Record<DrawerSide, string> = {
|
|
8
|
+
right: "",
|
|
9
|
+
left: "d-drawer-left",
|
|
10
|
+
bottom: "d-sheet",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function createDrawer(options: DrawerOptions = {}): Drawer {
|
|
14
|
+
validateDrawerOptions(options as Record<string, unknown>);
|
|
15
|
+
const {
|
|
16
|
+
closeOnBackdrop = true,
|
|
17
|
+
closeOnEscape = true,
|
|
18
|
+
side: initialSide = "right",
|
|
19
|
+
} = options;
|
|
20
|
+
|
|
21
|
+
const open = signal(false);
|
|
22
|
+
const side = signal<DrawerSide>(initialSide);
|
|
23
|
+
|
|
24
|
+
const show = () => open.set(true);
|
|
25
|
+
const close = () => open.set(false);
|
|
26
|
+
const toggle = () => open.update((v) => !v);
|
|
27
|
+
|
|
28
|
+
const _attachTo = (el: HTMLDialogElement) => {
|
|
29
|
+
const scope = getCurrentScope();
|
|
30
|
+
|
|
31
|
+
// Shared dialog behavior (open sync, backdrop, escape, ARIA)
|
|
32
|
+
_attachDialogBehavior(el, open, close, { closeOnBackdrop, closeOnEscape });
|
|
33
|
+
|
|
34
|
+
// Apply initial side class
|
|
35
|
+
const initial = SIDE_CLASSES[side()];
|
|
36
|
+
if (initial) el.classList.add(initial);
|
|
37
|
+
|
|
38
|
+
// React to side changes
|
|
39
|
+
const unsub = side.on((s) => {
|
|
40
|
+
for (const cls of Object.values(SIDE_CLASSES)) {
|
|
41
|
+
if (cls) el.classList.remove(cls);
|
|
42
|
+
}
|
|
43
|
+
const cls = SIDE_CLASSES[s];
|
|
44
|
+
if (cls) el.classList.add(cls);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (scope) {
|
|
48
|
+
scope.onCleanup(() => unsub());
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return { open, side, show, close, toggle, _attachTo };
|
|
53
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* Dalila UI — Dropdown & Menu */
|
|
2
|
+
|
|
3
|
+
.d-dropdown {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.d-menu {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: calc(100% + 4px);
|
|
11
|
+
left: 0;
|
|
12
|
+
z-index: var(--d-z-dropdown);
|
|
13
|
+
min-width: 12rem;
|
|
14
|
+
padding: var(--d-space-1) 0;
|
|
15
|
+
background: var(--d-surface-card);
|
|
16
|
+
border: 1px solid var(--d-border-color);
|
|
17
|
+
border-radius: var(--d-radius-md);
|
|
18
|
+
box-shadow: var(--d-shadow-md);
|
|
19
|
+
|
|
20
|
+
opacity: 0;
|
|
21
|
+
visibility: hidden;
|
|
22
|
+
transform: translateY(-4px);
|
|
23
|
+
transition: all var(--d-duration-fast) ease;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.d-dropdown.open .d-menu,
|
|
27
|
+
.d-menu.open {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
visibility: visible;
|
|
30
|
+
transform: translateY(0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.d-menu-right {
|
|
34
|
+
left: auto;
|
|
35
|
+
right: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.d-menu-item {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: var(--d-space-2);
|
|
42
|
+
width: 100%;
|
|
43
|
+
padding: var(--d-space-2) var(--d-space-3);
|
|
44
|
+
font-family: var(--d-font-sans);
|
|
45
|
+
font-size: var(--d-text-sm);
|
|
46
|
+
color: var(--d-text-primary);
|
|
47
|
+
background: none;
|
|
48
|
+
border: none;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
transition: background var(--d-duration-fast) ease;
|
|
51
|
+
text-align: left;
|
|
52
|
+
text-decoration: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.d-menu-item:hover {
|
|
56
|
+
background: var(--d-surface-raised);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.d-menu-item-danger {
|
|
60
|
+
color: var(--d-error);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.d-menu-item-danger:hover {
|
|
64
|
+
background: var(--d-error-light);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.d-menu-item:disabled,
|
|
68
|
+
.d-menu-item[aria-disabled="true"] {
|
|
69
|
+
opacity: 0.5;
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.d-menu-separator {
|
|
74
|
+
height: 1px;
|
|
75
|
+
background: var(--d-border-color);
|
|
76
|
+
margin: var(--d-space-1) 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.d-menu-label {
|
|
80
|
+
padding: var(--d-space-2) var(--d-space-3);
|
|
81
|
+
font-family: var(--d-font-sans);
|
|
82
|
+
font-size: var(--d-text-xs);
|
|
83
|
+
font-weight: var(--d-font-semibold);
|
|
84
|
+
color: var(--d-text-muted);
|
|
85
|
+
text-transform: uppercase;
|
|
86
|
+
letter-spacing: 0.05em;
|
|
87
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { signal } from "../../../core/signal.js";
|
|
2
|
+
import { getCurrentScope } from "../../../core/scope.js";
|
|
3
|
+
import type { Dropdown, DropdownOptions } from "../ui-types.js";
|
|
4
|
+
import { isBrowser } from "../env.js";
|
|
5
|
+
|
|
6
|
+
export function createDropdown(options: DropdownOptions = {}): Dropdown {
|
|
7
|
+
const { closeOnSelect = true } = options;
|
|
8
|
+
const open = signal(false);
|
|
9
|
+
|
|
10
|
+
const toggle = (ev?: Event) => {
|
|
11
|
+
if (ev) ev.stopPropagation();
|
|
12
|
+
open.update((v) => !v);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const close = () => open.set(false);
|
|
16
|
+
|
|
17
|
+
const select = (ev?: Event) => {
|
|
18
|
+
if (ev) ev.stopPropagation();
|
|
19
|
+
if (closeOnSelect) close();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const _attachTo = (el: HTMLElement) => {
|
|
23
|
+
const scope = getCurrentScope();
|
|
24
|
+
|
|
25
|
+
// ARIA
|
|
26
|
+
const trigger = el.querySelector<HTMLElement>(
|
|
27
|
+
"button, [role='button'], [data-d-tag='d-button']"
|
|
28
|
+
);
|
|
29
|
+
const menu = el.querySelector<HTMLElement>(
|
|
30
|
+
"[data-d-tag='d-menu'], .d-menu"
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (menu) menu.setAttribute("role", "menu");
|
|
34
|
+
if (trigger) {
|
|
35
|
+
trigger.setAttribute("aria-haspopup", "true");
|
|
36
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const unsubAria = open.on((isOpen) => {
|
|
40
|
+
trigger?.setAttribute("aria-expanded", String(isOpen));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const onDocClick = (e: MouseEvent) => {
|
|
44
|
+
if (!el.contains(e.target as Node)) close();
|
|
45
|
+
};
|
|
46
|
+
if (isBrowser) document.addEventListener("click", onDocClick);
|
|
47
|
+
|
|
48
|
+
if (scope) {
|
|
49
|
+
scope.onCleanup(() => {
|
|
50
|
+
unsubAria();
|
|
51
|
+
if (isBrowser) document.removeEventListener("click", onDocClick);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return { open, toggle, close, select, _attachTo };
|
|
57
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* Dalila UI — Dropzone / File Upload */
|
|
2
|
+
|
|
3
|
+
.d-dropzone {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
gap: var(--d-space-3);
|
|
9
|
+
padding: var(--d-space-8);
|
|
10
|
+
background: var(--d-surface-page);
|
|
11
|
+
border: 2px dashed var(--d-border-color);
|
|
12
|
+
border-radius: var(--d-radius-lg);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
transition: all var(--d-duration-fast) ease;
|
|
15
|
+
text-align: center;
|
|
16
|
+
font-family: var(--d-font-sans);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.d-dropzone:hover,
|
|
20
|
+
.d-dropzone.dragover {
|
|
21
|
+
border-color: var(--d-accent);
|
|
22
|
+
background: rgba(37, 99, 235, 0.04);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.d-dropzone-icon {
|
|
26
|
+
font-size: 2rem;
|
|
27
|
+
color: var(--d-text-muted);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.d-dropzone-text {
|
|
31
|
+
font-size: var(--d-text-sm);
|
|
32
|
+
color: var(--d-text-muted);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.d-dropzone-text strong {
|
|
36
|
+
color: var(--d-accent);
|
|
37
|
+
font-weight: var(--d-font-medium);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.d-dropzone-hint {
|
|
41
|
+
font-size: var(--d-text-xs);
|
|
42
|
+
color: var(--d-text-muted);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.d-dropzone input[type="file"] {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|