@svelte-thing/primitives 0.0.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/README.md +1 -0
- package/dist/button/index.d.mts +9 -0
- package/dist/button/index.mjs +6 -0
- package/dist/chunk-D7D4PA-g.mjs +13 -0
- package/dist/context-BJAwVB1S.mjs +5 -0
- package/dist/context-D77KIx26.mjs +5 -0
- package/dist/context-DwEoOJU2.mjs +5 -0
- package/dist/createInput.svelte-DTz79zNF.d.mts +9 -0
- package/dist/createInput.svelte-DzcT9u1t.mjs +92 -0
- package/dist/field/date/index.d.mts +2 -0
- package/dist/field/date/index.mjs +27 -0
- package/dist/field/error/index.d.mts +2 -0
- package/dist/field/error/index.mjs +10 -0
- package/dist/field/index.d.mts +13 -0
- package/dist/field/index.mjs +25 -0
- package/dist/field/input/index.d.mts +2 -0
- package/dist/field/input/index.mjs +2 -0
- package/dist/field/label/index.d.mts +2 -0
- package/dist/field/label/index.mjs +15 -0
- package/dist/field/password/index.d.mts +2 -0
- package/dist/field/password/index.mjs +61 -0
- package/dist/field/root/index.d.mts +2 -0
- package/dist/field/root/index.mjs +79 -0
- package/dist/index-07sbgO0w.d.mts +9 -0
- package/dist/index-B-PBb_8h.d.mts +14 -0
- package/dist/index-BLb5EVhG.d.mts +35 -0
- package/dist/index-BVVgDSdq.d.mts +1 -0
- package/dist/index-Boej-mdy.d.mts +25 -0
- package/dist/index-C-ME1Tk9.d.mts +9 -0
- package/dist/index-CA_POIj_.d.mts +9 -0
- package/dist/index-CbchmhrC.d.mts +9 -0
- package/dist/index-D2vzMU8o.d.mts +13 -0
- package/dist/index-DAHEDQQS.d.mts +9 -0
- package/dist/index-OI9KlY5x.d.mts +9 -0
- package/dist/index-j-8eH9nJ.d.mts +29 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/menu/index.d.mts +5 -0
- package/dist/menu/index.mjs +6 -0
- package/dist/menu/item/index.d.mts +14 -0
- package/dist/menu/item/index.mjs +86 -0
- package/dist/menu/popup/index.d.mts +19 -0
- package/dist/menu/popup/index.mjs +121 -0
- package/dist/menu/root/index.d.mts +28 -0
- package/dist/menu/root/index.mjs +69 -0
- package/dist/menu/trigger/index.d.mts +13 -0
- package/dist/menu/trigger/index.mjs +27 -0
- package/dist/pagination/content/index.d.mts +9 -0
- package/dist/pagination/content/index.mjs +6 -0
- package/dist/pagination/ellipsis/index.d.mts +9 -0
- package/dist/pagination/ellipsis/index.mjs +6 -0
- package/dist/pagination/index.d.mts +6 -0
- package/dist/pagination/index.mjs +6 -0
- package/dist/pagination/item/index.d.mts +9 -0
- package/dist/pagination/item/index.mjs +6 -0
- package/dist/pagination/link/index.d.mts +13 -0
- package/dist/pagination/link/index.mjs +13 -0
- package/dist/pagination/root/index.d.mts +9 -0
- package/dist/pagination/root/index.mjs +9 -0
- package/dist/tab/index.d.mts +13 -0
- package/dist/tab/index.mjs +21 -0
- package/dist/tab/indicator/index.d.mts +2 -0
- package/dist/tab/indicator/index.mjs +42 -0
- package/dist/tab/list/index.d.mts +2 -0
- package/dist/tab/list/index.mjs +20 -0
- package/dist/tab/panel/index.d.mts +2 -0
- package/dist/tab/panel/index.mjs +28 -0
- package/dist/tab/root/index.d.mts +2 -0
- package/dist/tab/root/index.mjs +57 -0
- package/dist/tab/title/index.d.mts +2 -0
- package/dist/tab/title/index.mjs +18 -0
- package/dist/tab/trigger/index.d.mts +2 -0
- package/dist/tab/trigger/index.mjs +94 -0
- package/dist/table/index.d.mts +2 -0
- package/dist/table/index.mjs +2 -0
- package/dist/table/row/index.d.mts +17 -0
- package/dist/table/row/index.mjs +17 -0
- package/package.json +64 -0
- package/src/button/createButton.svelte.ts +11 -0
- package/src/button/index.ts +1 -0
- package/src/field/date/createPicker.svelte.ts +41 -0
- package/src/field/date/index.ts +1 -0
- package/src/field/error/createError.svelte.ts +21 -0
- package/src/field/error/index.ts +1 -0
- package/src/field/index.ts +6 -0
- package/src/field/input/createInput.svelte.ts +136 -0
- package/src/field/input/index.ts +1 -0
- package/src/field/label/createLabel.svelte.ts +24 -0
- package/src/field/label/index.ts +1 -0
- package/src/field/password/context.ts +5 -0
- package/src/field/password/createPassword.svelte.ts +43 -0
- package/src/field/password/createShow.svelte.ts +47 -0
- package/src/field/password/index.ts +3 -0
- package/src/field/root/context.ts +5 -0
- package/src/field/root/createRoot.svelte.ts +113 -0
- package/src/field/root/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/menu/index.ts +4 -0
- package/src/menu/item/createItem.svelte.ts +123 -0
- package/src/menu/item/index.ts +1 -0
- package/src/menu/popup/createPopup.svelte.ts +186 -0
- package/src/menu/popup/index.ts +1 -0
- package/src/menu/root/context.ts +5 -0
- package/src/menu/root/createRoot.svelte.ts +96 -0
- package/src/menu/root/index.ts +2 -0
- package/src/menu/trigger/createTrigger.svelte.ts +44 -0
- package/src/menu/trigger/index.ts +1 -0
- package/src/pagination/content/createContent.svelte.ts +11 -0
- package/src/pagination/content/index.ts +1 -0
- package/src/pagination/ellipsis/createEllipsis.svelte.ts +13 -0
- package/src/pagination/ellipsis/index.ts +1 -0
- package/src/pagination/index.ts +5 -0
- package/src/pagination/item/createItem.svelte.ts +11 -0
- package/src/pagination/item/index.ts +1 -0
- package/src/pagination/link/createLink.svelte.ts +23 -0
- package/src/pagination/link/index.ts +1 -0
- package/src/pagination/root/createRoot.svelte.ts +14 -0
- package/src/pagination/root/index.ts +1 -0
- package/src/style.css +10 -0
- package/src/tab/index.ts +6 -0
- package/src/tab/indicator/createIndicator.svelte.ts +79 -0
- package/src/tab/indicator/index.ts +1 -0
- package/src/tab/list/createList.svelte.ts +27 -0
- package/src/tab/list/index.ts +1 -0
- package/src/tab/panel/createPanel.svelte.ts +42 -0
- package/src/tab/panel/index.ts +1 -0
- package/src/tab/root/context.ts +5 -0
- package/src/tab/root/createRoot.svelte.ts +85 -0
- package/src/tab/root/index.ts +2 -0
- package/src/tab/title/createTitle.svelte.ts +27 -0
- package/src/tab/title/index.ts +1 -0
- package/src/tab/trigger/createTrigger.svelte.ts +129 -0
- package/src/tab/trigger/index.ts +1 -0
- package/src/table/index.ts +1 -0
- package/src/table/row/context.ts +5 -0
- package/src/table/row/createRow.svelte.ts +26 -0
- package/src/table/row/index.ts +2 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { t as getRoot } from "../../context-BJAwVB1S.mjs";
|
|
2
|
+
import { flushSync } from "svelte";
|
|
3
|
+
import { uid } from "uid";
|
|
4
|
+
import { createAttachmentKey } from "svelte/attachments";
|
|
5
|
+
//#region src/menu/item/createItem.svelte.ts
|
|
6
|
+
function createItem(props) {
|
|
7
|
+
const root = getRoot();
|
|
8
|
+
const itemId = $derived(props.id ?? `menuitem-${uid()}`);
|
|
9
|
+
return { props: {
|
|
10
|
+
"data-menu-item": "",
|
|
11
|
+
get "aria-disabled"() {
|
|
12
|
+
return props.disabled ? "true" : void 0;
|
|
13
|
+
},
|
|
14
|
+
get "data-disabled"() {
|
|
15
|
+
return props.disabled ? "" : void 0;
|
|
16
|
+
},
|
|
17
|
+
get "data-id"() {
|
|
18
|
+
return itemId;
|
|
19
|
+
},
|
|
20
|
+
get "data-root-id"() {
|
|
21
|
+
return root.id;
|
|
22
|
+
},
|
|
23
|
+
get id() {
|
|
24
|
+
return itemId;
|
|
25
|
+
},
|
|
26
|
+
get tabindex() {
|
|
27
|
+
return root.highlightedItemId === itemId ? 0 : -1;
|
|
28
|
+
},
|
|
29
|
+
onkeydown(event) {
|
|
30
|
+
if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
|
|
31
|
+
let preventDefault = false;
|
|
32
|
+
let pendingHighlighted = null;
|
|
33
|
+
const item = event.currentTarget;
|
|
34
|
+
const items = [...document.querySelectorAll(`[data-menu-item][data-root-id="${root.id}"]:not([data-disabled])`)];
|
|
35
|
+
const currentIndex = items.indexOf(item);
|
|
36
|
+
const nextKeyName = root.orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
37
|
+
const previousKeyName = root.orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
|
|
38
|
+
switch (event.key) {
|
|
39
|
+
case previousKeyName:
|
|
40
|
+
pendingHighlighted = items[currentIndex === 0 ? items.length - 1 : currentIndex - 1]?.dataset.id ?? null;
|
|
41
|
+
preventDefault = true;
|
|
42
|
+
break;
|
|
43
|
+
case nextKeyName:
|
|
44
|
+
pendingHighlighted = items[(currentIndex + 1) % items.length]?.dataset.id ?? null;
|
|
45
|
+
preventDefault = true;
|
|
46
|
+
break;
|
|
47
|
+
case "Home":
|
|
48
|
+
pendingHighlighted = items[0]?.dataset.id ?? null;
|
|
49
|
+
preventDefault = true;
|
|
50
|
+
break;
|
|
51
|
+
case "End":
|
|
52
|
+
pendingHighlighted = items.at(-1)?.dataset.id ?? null;
|
|
53
|
+
preventDefault = true;
|
|
54
|
+
break;
|
|
55
|
+
default: break;
|
|
56
|
+
}
|
|
57
|
+
if (pendingHighlighted !== null) {
|
|
58
|
+
root.highlightedItemId = pendingHighlighted;
|
|
59
|
+
flushSync();
|
|
60
|
+
items.find((el) => el.dataset.id === pendingHighlighted)?.focus();
|
|
61
|
+
}
|
|
62
|
+
if (preventDefault) {
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
onmouseover: (event) => {
|
|
68
|
+
if (root.shouldHighlightOnHover) {
|
|
69
|
+
root.highlightedItemId = itemId;
|
|
70
|
+
flushSync();
|
|
71
|
+
event.currentTarget.focus();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onmouseleave: () => {
|
|
75
|
+
if (root.shouldHighlightOnHover && root.highlightedItemId === itemId) root.highlightedItemId = null;
|
|
76
|
+
},
|
|
77
|
+
role: "menuitem",
|
|
78
|
+
[createAttachmentKey()]: () => {
|
|
79
|
+
return () => {
|
|
80
|
+
if (root.highlightedItemId === itemId) root.highlightedItemId = null;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
} };
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { createItem };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
|
|
3
|
+
//#region src/menu/popup/createPopup.svelte.d.ts
|
|
4
|
+
type Side = 'left' | 'right' | 'bottom' | 'top' | 'inline-end' | 'inline-start';
|
|
5
|
+
type Align = 'start' | 'end' | 'center';
|
|
6
|
+
interface CreatePopupProps {
|
|
7
|
+
popover: HTMLAttributes<HTMLElement>['popover'] | null | undefined;
|
|
8
|
+
align: Align | undefined;
|
|
9
|
+
side: Side | undefined;
|
|
10
|
+
alignOffset: number | undefined;
|
|
11
|
+
positionAnchor: string | null | undefined;
|
|
12
|
+
sideOffset: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface PopupState {
|
|
15
|
+
props: HTMLAttributes<HTMLElement>;
|
|
16
|
+
}
|
|
17
|
+
declare function createPopup(props: CreatePopupProps): PopupState;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { CreatePopupProps, PopupState, createPopup };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { t as getRoot } from "../../context-BJAwVB1S.mjs";
|
|
2
|
+
import { flushSync, untrack } from "svelte";
|
|
3
|
+
import { createAttachmentKey } from "svelte/attachments";
|
|
4
|
+
import { assertNever } from "@svelte-thing/type-utils";
|
|
5
|
+
import { on } from "svelte/events";
|
|
6
|
+
//#region src/menu/popup/createPopup.svelte.ts
|
|
7
|
+
function createPopup(props) {
|
|
8
|
+
const root = getRoot();
|
|
9
|
+
return { props: {
|
|
10
|
+
"data-menu-popup": "",
|
|
11
|
+
get "data-root-id"() {
|
|
12
|
+
return root.id;
|
|
13
|
+
},
|
|
14
|
+
get "data-open"() {
|
|
15
|
+
return root.isOpen ? "" : void 0;
|
|
16
|
+
},
|
|
17
|
+
get "data-closed"() {
|
|
18
|
+
return root.isOpen ? void 0 : "";
|
|
19
|
+
},
|
|
20
|
+
get "data-side"() {
|
|
21
|
+
return props.side ?? "bottom";
|
|
22
|
+
},
|
|
23
|
+
get "data-align"() {
|
|
24
|
+
return props.align ?? "center";
|
|
25
|
+
},
|
|
26
|
+
get popover() {
|
|
27
|
+
return props.popover ?? "";
|
|
28
|
+
},
|
|
29
|
+
get id() {
|
|
30
|
+
return root.popupId;
|
|
31
|
+
},
|
|
32
|
+
get style() {
|
|
33
|
+
const positionAnchor = props.positionAnchor === void 0 ? root.anchorName : props.positionAnchor;
|
|
34
|
+
const styles = [positionAnchor === null ? void 0 : `position-anchor: ${positionAnchor}`, `justify-self: anchor-${props.align ?? "center"}`];
|
|
35
|
+
const side = props.side ?? "bottom";
|
|
36
|
+
const sideOffset = props.sideOffset ?? 0;
|
|
37
|
+
if (side === "bottom") styles.push(`top: calc(anchor(bottom) + ${sideOffset}px);`);
|
|
38
|
+
else if (side === "top") styles.push(`bottom: calc(anchor(top) + ${sideOffset}px);`);
|
|
39
|
+
else if (side === "left") styles.push(`right: calc(anchor(left) + ${sideOffset}px);`);
|
|
40
|
+
else if (side === "right") styles.push(`left: calc(anchor(right) + ${sideOffset}px);`);
|
|
41
|
+
else if (side === "inline-end") styles.push(`inset-inline-end: calc(anchor(end) + ${sideOffset}px);`);
|
|
42
|
+
else if (side === "inline-start") styles.push(`inset-inline-start: calc(anchor(start) + ${sideOffset}px);`);
|
|
43
|
+
else assertNever(side);
|
|
44
|
+
return styles.filter(Boolean).join("; ");
|
|
45
|
+
},
|
|
46
|
+
get tabindex() {
|
|
47
|
+
return root.isOpen ? -1 : void 0;
|
|
48
|
+
},
|
|
49
|
+
[createAttachmentKey()](element) {
|
|
50
|
+
const update = (event) => {
|
|
51
|
+
if (event && event.newState !== "open") return;
|
|
52
|
+
root.isOpen = event ? true : element.matches(":popover-open");
|
|
53
|
+
flushSync();
|
|
54
|
+
if (root.isOpen) element.focus();
|
|
55
|
+
};
|
|
56
|
+
const open = () => {
|
|
57
|
+
element.showPopover();
|
|
58
|
+
};
|
|
59
|
+
const close = () => {
|
|
60
|
+
element.hidePopover();
|
|
61
|
+
};
|
|
62
|
+
root.open = open;
|
|
63
|
+
root.close = close;
|
|
64
|
+
$effect(() => {
|
|
65
|
+
if (root._propIsOpen === true && !element.matches(":popover-open")) element.showPopover();
|
|
66
|
+
else if (root._propIsOpen === false && element.matches(":popover-open")) element.hidePopover();
|
|
67
|
+
untrack(() => {
|
|
68
|
+
update();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
update();
|
|
72
|
+
const offBefore = on(element, "beforetoggle", update);
|
|
73
|
+
const offAfter = on(element, "toggle", update);
|
|
74
|
+
return () => {
|
|
75
|
+
offBefore();
|
|
76
|
+
offAfter();
|
|
77
|
+
root.open = () => {
|
|
78
|
+
throw new Error("Attempted to open before popup initialization");
|
|
79
|
+
};
|
|
80
|
+
root.close = () => {
|
|
81
|
+
throw new Error("Attempted to close before popup initialization");
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
onkeydown(event) {
|
|
86
|
+
if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
|
|
87
|
+
const popup = event.currentTarget;
|
|
88
|
+
if (document.activeElement !== popup) return;
|
|
89
|
+
let preventDefault = false;
|
|
90
|
+
let pendingHighlighted = null;
|
|
91
|
+
const items = [...document.querySelectorAll(`[data-menu-item][data-root-id="${root.id}"]:not([data-disabled])`)];
|
|
92
|
+
const nextKeyName = root.orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
93
|
+
const previousKeyName = root.orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
|
|
94
|
+
switch (event.key) {
|
|
95
|
+
case previousKeyName:
|
|
96
|
+
case "End":
|
|
97
|
+
pendingHighlighted = items.at(-1)?.dataset.id ?? null;
|
|
98
|
+
preventDefault = true;
|
|
99
|
+
break;
|
|
100
|
+
case nextKeyName:
|
|
101
|
+
case "Home":
|
|
102
|
+
pendingHighlighted = items[0]?.dataset.id ?? null;
|
|
103
|
+
preventDefault = true;
|
|
104
|
+
break;
|
|
105
|
+
default: break;
|
|
106
|
+
}
|
|
107
|
+
if (pendingHighlighted !== null) {
|
|
108
|
+
root.highlightedItemId = pendingHighlighted;
|
|
109
|
+
flushSync();
|
|
110
|
+
items.find((el) => el.dataset.id === pendingHighlighted)?.focus();
|
|
111
|
+
}
|
|
112
|
+
if (preventDefault) {
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
role: "menu"
|
|
118
|
+
} };
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { createPopup };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/menu/root/createRoot.svelte.d.ts
|
|
2
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
3
|
+
interface CreateRootProps {
|
|
4
|
+
anchorName: string | undefined;
|
|
5
|
+
id: string | null | undefined;
|
|
6
|
+
isOpen: boolean | undefined;
|
|
7
|
+
orientation: Orientation | undefined;
|
|
8
|
+
shouldHighlightOnHover: boolean | undefined;
|
|
9
|
+
}
|
|
10
|
+
interface RootState {
|
|
11
|
+
anchorName: string;
|
|
12
|
+
close: () => void;
|
|
13
|
+
highlightedItemId: string | null;
|
|
14
|
+
id: string;
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
open: () => void;
|
|
17
|
+
orientation: Orientation;
|
|
18
|
+
popupId: string;
|
|
19
|
+
shouldHighlightOnHover: boolean;
|
|
20
|
+
triggerId: string;
|
|
21
|
+
_propIsOpen: boolean | undefined;
|
|
22
|
+
}
|
|
23
|
+
declare function createRoot(props: CreateRootProps): RootState;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/menu/root/context.d.ts
|
|
26
|
+
declare const getRoot: () => RootState, setRoot: (context: RootState) => RootState;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { CreateRootProps, Orientation, RootState, createRoot, getRoot, setRoot };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { n as setRoot, t as getRoot } from "../../context-BJAwVB1S.mjs";
|
|
2
|
+
import { uid } from "uid";
|
|
3
|
+
//#region src/menu/root/createRoot.svelte.ts
|
|
4
|
+
function createRoot(props) {
|
|
5
|
+
const id = $derived(props.id ?? uid());
|
|
6
|
+
const anchorName = $derived(props.anchorName ?? `--${id}-anchor`);
|
|
7
|
+
const popupId = $derived(`${id}-popup`);
|
|
8
|
+
const triggerId = $derived(`${id}-trigger`);
|
|
9
|
+
const orientation = $derived(props.orientation ?? "vertical");
|
|
10
|
+
let isOpen = $state(false);
|
|
11
|
+
let highlightedItemId = $state(null);
|
|
12
|
+
let open = () => {
|
|
13
|
+
throw new Error("Attempted to open before popup initialization");
|
|
14
|
+
};
|
|
15
|
+
let close = () => {
|
|
16
|
+
throw new Error("Attempted to close before popup initialization");
|
|
17
|
+
};
|
|
18
|
+
const root = {
|
|
19
|
+
get anchorName() {
|
|
20
|
+
return anchorName;
|
|
21
|
+
},
|
|
22
|
+
get highlightedItemId() {
|
|
23
|
+
return highlightedItemId;
|
|
24
|
+
},
|
|
25
|
+
set highlightedItemId(value) {
|
|
26
|
+
highlightedItemId = value;
|
|
27
|
+
},
|
|
28
|
+
get id() {
|
|
29
|
+
return id;
|
|
30
|
+
},
|
|
31
|
+
get isOpen() {
|
|
32
|
+
return isOpen;
|
|
33
|
+
},
|
|
34
|
+
set isOpen(value) {
|
|
35
|
+
isOpen = value;
|
|
36
|
+
},
|
|
37
|
+
get orientation() {
|
|
38
|
+
return orientation;
|
|
39
|
+
},
|
|
40
|
+
get popupId() {
|
|
41
|
+
return popupId;
|
|
42
|
+
},
|
|
43
|
+
get shouldHighlightOnHover() {
|
|
44
|
+
return props.shouldHighlightOnHover ?? true;
|
|
45
|
+
},
|
|
46
|
+
get _propIsOpen() {
|
|
47
|
+
return props.isOpen;
|
|
48
|
+
},
|
|
49
|
+
get triggerId() {
|
|
50
|
+
return triggerId;
|
|
51
|
+
},
|
|
52
|
+
get close() {
|
|
53
|
+
return close;
|
|
54
|
+
},
|
|
55
|
+
set close(value) {
|
|
56
|
+
close = value;
|
|
57
|
+
},
|
|
58
|
+
get open() {
|
|
59
|
+
return open;
|
|
60
|
+
},
|
|
61
|
+
set open(value) {
|
|
62
|
+
open = value;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
setRoot(root);
|
|
66
|
+
return root;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { createRoot, getRoot, setRoot };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exact } from "@svelte-thing/type-utils";
|
|
2
|
+
import { HTMLButtonAttributes } from "svelte/elements";
|
|
3
|
+
|
|
4
|
+
//#region src/menu/trigger/createTrigger.svelte.d.ts
|
|
5
|
+
interface CreateTriggerProps {
|
|
6
|
+
anchorName: string | null | undefined;
|
|
7
|
+
}
|
|
8
|
+
interface TriggerState {
|
|
9
|
+
props: HTMLButtonAttributes;
|
|
10
|
+
}
|
|
11
|
+
declare function createTrigger<T extends CreateTriggerProps>(props: Exact<CreateTriggerProps, T>): TriggerState;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CreateTriggerProps, TriggerState, createTrigger };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { t as getRoot } from "../../context-BJAwVB1S.mjs";
|
|
2
|
+
//#region src/menu/trigger/createTrigger.svelte.ts
|
|
3
|
+
function createTrigger(props) {
|
|
4
|
+
const root = getRoot();
|
|
5
|
+
return { props: {
|
|
6
|
+
"data-menu-trigger": "",
|
|
7
|
+
get "data-root-id"() {
|
|
8
|
+
return root.id;
|
|
9
|
+
},
|
|
10
|
+
get commandfor() {
|
|
11
|
+
return root.popupId;
|
|
12
|
+
},
|
|
13
|
+
get command() {
|
|
14
|
+
return "toggle-popover";
|
|
15
|
+
},
|
|
16
|
+
get id() {
|
|
17
|
+
return root.triggerId;
|
|
18
|
+
},
|
|
19
|
+
get style() {
|
|
20
|
+
const anchorName = props.anchorName === void 0 ? root.anchorName : props.anchorName;
|
|
21
|
+
if (anchorName === null) return;
|
|
22
|
+
return `anchor-name: ${anchorName};`;
|
|
23
|
+
}
|
|
24
|
+
} };
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createTrigger };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
|
|
3
|
+
//#region src/pagination/content/createContent.svelte.d.ts
|
|
4
|
+
interface ContentState {
|
|
5
|
+
props: HTMLAttributes<HTMLUListElement>;
|
|
6
|
+
}
|
|
7
|
+
declare function createContent(): ContentState;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ContentState, createContent };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
|
|
3
|
+
//#region src/pagination/ellipsis/createEllipsis.svelte.d.ts
|
|
4
|
+
interface EllipsisState {
|
|
5
|
+
props: HTMLAttributes<HTMLSpanElement>;
|
|
6
|
+
}
|
|
7
|
+
declare function createEllipsis(): EllipsisState;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { EllipsisState, createEllipsis };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContentState, createContent } from "./content/index.mjs";
|
|
2
|
+
import { EllipsisState, createEllipsis } from "./ellipsis/index.mjs";
|
|
3
|
+
import { ItemState, createItem } from "./item/index.mjs";
|
|
4
|
+
import { CreateLinkProps, LinkState, createLink } from "./link/index.mjs";
|
|
5
|
+
import { RootState, createRoot } from "./root/index.mjs";
|
|
6
|
+
export { ContentState, CreateLinkProps, EllipsisState, ItemState, LinkState, RootState, createContent, createEllipsis, createItem, createLink, createRoot };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createContent } from "./content/index.mjs";
|
|
2
|
+
import { createEllipsis } from "./ellipsis/index.mjs";
|
|
3
|
+
import { createItem } from "./item/index.mjs";
|
|
4
|
+
import { createLink } from "./link/index.mjs";
|
|
5
|
+
import { createRoot } from "./root/index.mjs";
|
|
6
|
+
export { createContent, createEllipsis, createItem, createLink, createRoot };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exact } from "@svelte-thing/type-utils";
|
|
2
|
+
import { HTMLAnchorAttributes } from "svelte/elements";
|
|
3
|
+
|
|
4
|
+
//#region src/pagination/link/createLink.svelte.d.ts
|
|
5
|
+
interface CreateLinkProps {
|
|
6
|
+
isActive?: boolean | null | undefined;
|
|
7
|
+
}
|
|
8
|
+
interface LinkState {
|
|
9
|
+
props: HTMLAnchorAttributes;
|
|
10
|
+
}
|
|
11
|
+
declare function createLink<T extends CreateLinkProps>(props: Exact<CreateLinkProps, T>): LinkState;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CreateLinkProps, LinkState, createLink };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/pagination/link/createLink.svelte.ts
|
|
2
|
+
function createLink(props) {
|
|
3
|
+
return { props: {
|
|
4
|
+
get "aria-current"() {
|
|
5
|
+
return props.isActive ? "page" : void 0;
|
|
6
|
+
},
|
|
7
|
+
get "data-active"() {
|
|
8
|
+
return props.isActive;
|
|
9
|
+
}
|
|
10
|
+
} };
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createLink };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
|
|
3
|
+
//#region src/pagination/root/createRoot.svelte.d.ts
|
|
4
|
+
interface RootState {
|
|
5
|
+
props: HTMLAttributes<HTMLElement>;
|
|
6
|
+
}
|
|
7
|
+
declare function createRoot(): RootState;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { RootState, createRoot };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as createIndicator, t as IndicatorState } from "../index-07sbgO0w.mjs";
|
|
2
|
+
import { n as createList, t as ListState } from "../index-CbchmhrC.mjs";
|
|
3
|
+
import { n as PanelState, r as createPanel, t as CreatePanelProps } from "../index-D2vzMU8o.mjs";
|
|
4
|
+
import { a as Orientation, c as createRoot, i as Direction, n as setRoot, o as RootState, r as CreateRootProps, s as TValue, t as getRoot } from "../index-j-8eH9nJ.mjs";
|
|
5
|
+
import { n as createTitle, t as TitleState } from "../index-DAHEDQQS.mjs";
|
|
6
|
+
import { n as TriggerState, r as createTrigger, t as CreateTriggerProps } from "../index-B-PBb_8h.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/tab/index.d.ts
|
|
9
|
+
declare namespace index_d_exports {
|
|
10
|
+
export { CreatePanelProps, CreateRootProps, CreateTriggerProps, Direction, IndicatorState, ListState, Orientation, PanelState, RootState, TValue, TitleState, TriggerState, createIndicator, createList, createPanel, createRoot, createTitle, createTrigger, getRoot, setRoot };
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CreatePanelProps, CreateRootProps, CreateTriggerProps, Direction, IndicatorState, ListState, Orientation, PanelState, RootState, TValue, TitleState, TriggerState, createIndicator, createList, createPanel, createRoot, createTitle, createTrigger, getRoot, setRoot, index_d_exports as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-D7D4PA-g.mjs";
|
|
2
|
+
import { n as setRoot, t as getRoot } from "../context-DwEoOJU2.mjs";
|
|
3
|
+
import { createIndicator } from "./indicator/index.mjs";
|
|
4
|
+
import { createList } from "./list/index.mjs";
|
|
5
|
+
import { createPanel } from "./panel/index.mjs";
|
|
6
|
+
import { createRoot } from "./root/index.mjs";
|
|
7
|
+
import { createTitle } from "./title/index.mjs";
|
|
8
|
+
import { createTrigger } from "./trigger/index.mjs";
|
|
9
|
+
//#region src/tab/index.ts
|
|
10
|
+
var tab_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
createIndicator: () => createIndicator,
|
|
12
|
+
createList: () => createList,
|
|
13
|
+
createPanel: () => createPanel,
|
|
14
|
+
createRoot: () => createRoot,
|
|
15
|
+
createTitle: () => createTitle,
|
|
16
|
+
createTrigger: () => createTrigger,
|
|
17
|
+
getRoot: () => getRoot,
|
|
18
|
+
setRoot: () => setRoot
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createIndicator, createList, createPanel, createRoot, createTitle, createTrigger, getRoot, setRoot, tab_exports as t };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { t as getRoot } from "../../context-DwEoOJU2.mjs";
|
|
2
|
+
import { createAttachmentKey } from "svelte/attachments";
|
|
3
|
+
//#region src/tab/indicator/createIndicator.svelte.ts
|
|
4
|
+
function createIndicator() {
|
|
5
|
+
const root = getRoot();
|
|
6
|
+
const tabListSelector = $derived(`[data-tabs-list][id="${root.id}-list"]`);
|
|
7
|
+
const id = $derived(`${root.id}-indicator`);
|
|
8
|
+
const indicatorSelector = $derived(`[data-tabs-indicator][id="${id}"]`);
|
|
9
|
+
let resizeTick = $state(0);
|
|
10
|
+
return { props: {
|
|
11
|
+
"data-tabs-indicator": "",
|
|
12
|
+
get id() {
|
|
13
|
+
return id;
|
|
14
|
+
},
|
|
15
|
+
[createAttachmentKey()](element) {
|
|
16
|
+
const tabList = element.closest(tabListSelector);
|
|
17
|
+
if (!tabList) return;
|
|
18
|
+
const observer = new ResizeObserver(() => {
|
|
19
|
+
resizeTick += 1;
|
|
20
|
+
});
|
|
21
|
+
observer.observe(tabList);
|
|
22
|
+
return () => {
|
|
23
|
+
observer.disconnect();
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
get style() {
|
|
27
|
+
if (typeof document === "undefined") return;
|
|
28
|
+
const { value, direction, id } = root;
|
|
29
|
+
const tabList = document.querySelector(indicatorSelector)?.closest(tabListSelector) ?? null;
|
|
30
|
+
const selectedTab = tabList?.querySelector(`[data-tabs-trigger][id="${id}-trigger-${value}"]`);
|
|
31
|
+
if (!tabList || value === null || !selectedTab) return;
|
|
32
|
+
const rect = selectedTab.getBoundingClientRect();
|
|
33
|
+
const width = Math.floor(rect.width);
|
|
34
|
+
const height = Math.floor(rect.height);
|
|
35
|
+
const right = direction === "ltr" ? tabList.scrollWidth - selectedTab.offsetLeft - width - tabList.clientLeft : selectedTab.offsetLeft - tabList.clientLeft;
|
|
36
|
+
const bottom = tabList.scrollHeight - selectedTab.offsetTop - height - tabList.clientTop;
|
|
37
|
+
return `--active-tab-left: ${selectedTab.offsetLeft - tabList.clientLeft}px;--active-tab-top: ${selectedTab.offsetTop - tabList.clientTop}px;--active-tab-width: ${width}px;--active-tab-height: ${height}px;--active-tab-right: ${right}px;--active-tab-bottom: ${bottom}px;`;
|
|
38
|
+
}
|
|
39
|
+
} };
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { createIndicator };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as getRoot } from "../../context-DwEoOJU2.mjs";
|
|
2
|
+
//#region src/tab/list/createList.svelte.ts
|
|
3
|
+
function createList() {
|
|
4
|
+
const root = getRoot();
|
|
5
|
+
return { props: {
|
|
6
|
+
get id() {
|
|
7
|
+
return `${root.id}-list`;
|
|
8
|
+
},
|
|
9
|
+
get "aria-labelledby"() {
|
|
10
|
+
return root.hasTitle ? `${root.id}-title` : void 0;
|
|
11
|
+
},
|
|
12
|
+
get "data-orientation"() {
|
|
13
|
+
return root.orientation;
|
|
14
|
+
},
|
|
15
|
+
"data-tabs-list": "",
|
|
16
|
+
role: "tablist"
|
|
17
|
+
} };
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { createList };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { t as getRoot } from "../../context-DwEoOJU2.mjs";
|
|
2
|
+
//#region src/tab/panel/createPanel.svelte.ts
|
|
3
|
+
function createPanel(props) {
|
|
4
|
+
const root = getRoot();
|
|
5
|
+
const isSelected = $derived(root.panel === props.value);
|
|
6
|
+
return { props: {
|
|
7
|
+
get "aria-labelledby"() {
|
|
8
|
+
return `${root.id}-trigger-${props.value}`;
|
|
9
|
+
},
|
|
10
|
+
get "data-orientation"() {
|
|
11
|
+
return root.orientation;
|
|
12
|
+
},
|
|
13
|
+
get "data-hidden"() {
|
|
14
|
+
return isSelected ? void 0 : "";
|
|
15
|
+
},
|
|
16
|
+
get hidden() {
|
|
17
|
+
return isSelected ? void 0 : "";
|
|
18
|
+
},
|
|
19
|
+
get id() {
|
|
20
|
+
return `${root.id}-panel-${props.value}`;
|
|
21
|
+
},
|
|
22
|
+
"data-tab-panel": "",
|
|
23
|
+
role: "tabpanel",
|
|
24
|
+
tabindex: 0
|
|
25
|
+
} };
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createPanel };
|