@warkypublic/svelix 0.1.46 → 0.2.1
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 +93 -33
- package/dist/components/BetterMenu/BetterMenu.svelte +21 -37
- package/dist/components/BetterMenu/BetterMenuAsyncButton.svelte +21 -31
- package/dist/components/BetterMenu/BetterMenuPreview.svelte +27 -29
- package/dist/components/BetterMenu/MenuRenderer.svelte +40 -51
- package/dist/components/Boxer/Boxer.svelte +492 -602
- package/dist/components/Boxer/BoxerTarget.svelte +6 -46
- package/dist/components/Boxer/BoxerTarget.svelte.d.ts +1 -0
- package/dist/components/Boxer/types.d.ts +0 -1
- package/dist/components/Button.svelte +19 -43
- package/dist/components/ButtonPreview.svelte +2 -11
- package/dist/components/CardGrid/CardGrid.svelte +489 -614
- package/dist/components/CardGrid/CardGrid.svelte.d.ts +4 -0
- package/dist/components/CardGrid/CardGridFilterPanel.svelte +111 -90
- package/dist/components/CardGrid/DefaultCard.svelte +86 -97
- package/dist/components/CardGrid/DefaultCard.svelte.d.ts +1 -0
- package/dist/components/CardGrid/ImageCardStory.svelte +87 -36
- package/dist/components/CardGrid/cardGrid.d.ts +24 -0
- package/dist/components/CardGrid/cardGrid.js +20 -0
- package/dist/components/ContentEditor/CollaboraInsertTextDemo.svelte +5 -10
- package/dist/components/ContentEditor/ContentEditor.svelte +24 -50
- package/dist/components/ContentEditor/subcomponents/AudioPlayer.svelte +17 -17
- package/dist/components/ContentEditor/subcomponents/CollaboraEditor.svelte +244 -309
- package/dist/components/ContentEditor/subcomponents/EmailViewer.svelte +2 -3
- package/dist/components/ContentEditor/subcomponents/ImageViewer.svelte +14 -15
- package/dist/components/ContentEditor/subcomponents/MarkdownViewer.svelte +74 -90
- package/dist/components/ContentEditor/subcomponents/MonacoEditor.svelte +75 -103
- package/dist/components/ContentEditor/subcomponents/Office365Editor.svelte +234 -297
- package/dist/components/ContentEditor/subcomponents/PdfViewer.svelte +14 -20
- package/dist/components/ContentEditor/subcomponents/TextEditor.svelte +122 -150
- package/dist/components/ContentEditor/subcomponents/UnknownFile.svelte +105 -126
- package/dist/components/ContentEditor/subcomponents/VideoPlayer.svelte +17 -17
- package/dist/components/ContentEditor/subcomponents/ZipViewer.svelte +2 -3
- package/dist/components/ErrorBoundary/ErrorBoundary.svelte +41 -58
- package/dist/components/ErrorBoundary/ErrorBoundaryPreview.svelte +8 -16
- package/dist/components/Former/Former.svelte +306 -424
- package/dist/components/Former/FormerButtonArea.svelte +17 -68
- package/dist/components/Former/FormerDrawer.svelte +16 -80
- package/dist/components/Former/FormerDrawerPreview.svelte +99 -89
- package/dist/components/Former/FormerModal.svelte +16 -74
- package/dist/components/Former/FormerModalPreview.svelte +99 -89
- package/dist/components/Former/FormerPreview.svelte +76 -78
- package/dist/components/Former/FormerRestApiPreview.svelte +55 -48
- package/dist/components/Former/formerOverlayHelpers.svelte.d.ts +11 -0
- package/dist/components/Former/formerOverlayHelpers.svelte.js +38 -0
- package/dist/components/Former/index.d.ts +1 -0
- package/dist/components/Former/index.js +1 -0
- package/dist/components/FormerControllers/ButtonCtrl.svelte +13 -49
- package/dist/components/FormerControllers/CtrlFieldShell.svelte +15 -0
- package/dist/components/FormerControllers/CtrlFieldShell.svelte.d.ts +12 -0
- package/dist/components/FormerControllers/DateTimeCtrl/DateTimeCtrl.svelte +285 -457
- package/dist/components/FormerControllers/DateTimeCtrl/DateTimeCtrlCalendar.svelte +95 -136
- package/dist/components/FormerControllers/DateTimeCtrl/DateTimeCtrlPickerPanel.svelte +3 -62
- package/dist/components/FormerControllers/DateTimeCtrl/DateTimeCtrlTimeFields.svelte +143 -217
- package/dist/components/FormerControllers/IconButtonCtrl.svelte +13 -47
- package/dist/components/FormerControllers/InlineWrapper.svelte +12 -41
- package/dist/components/FormerControllers/InlineWrapperPreview.svelte +4 -26
- package/dist/components/FormerControllers/NativeSelectCtrl.svelte +7 -39
- package/dist/components/FormerControllers/NumberInputCtrl.svelte +21 -43
- package/dist/components/FormerControllers/PasswordInputCtrl.svelte +8 -33
- package/dist/components/FormerControllers/SwitchCtrl.svelte +4 -20
- package/dist/components/FormerControllers/TextAreaCtrl.svelte +7 -34
- package/dist/components/FormerControllers/TextInputCtrl.svelte +7 -34
- package/dist/components/FormerControllers/ctrlLoading.svelte.d.ts +8 -0
- package/dist/components/FormerControllers/ctrlLoading.svelte.js +43 -0
- package/dist/components/FormerControllers/index.d.ts +2 -0
- package/dist/components/FormerControllers/index.js +2 -0
- package/dist/components/FormerControllers/utils.d.ts +1 -0
- package/dist/components/FormerControllers/utils.js +3 -0
- package/dist/components/GlobalStateStore/GlobalStateStoreProvider.svelte +73 -120
- package/dist/components/Gridler/components/Gridler.svelte +344 -442
- package/dist/components/Gridler/components/GridlerCanvas.svelte +720 -1115
- package/dist/components/Gridler/components/GridlerEditor.svelte +2 -15
- package/dist/components/Gridler/components/GridlerFull.svelte +521 -841
- package/dist/components/Gridler/components/GridlerFull.svelte.d.ts +1 -1
- package/dist/components/Gridler/components/GridlerFullWithFormerPreview.svelte +194 -147
- package/dist/components/Gridler/components/GridlerSearch.svelte +7 -16
- package/dist/components/Gridler/components/GridlerSearchToggle.svelte +7 -19
- package/dist/components/Gridler/types.d.ts +1 -1
- package/dist/components/Gridler/utils/serverPaging.d.ts +1 -0
- package/dist/components/Gridler/utils/serverPaging.js +7 -0
- package/dist/components/Icons/IconAdd.svelte +1 -3
- package/dist/components/Icons/IconAlertCircle.svelte +1 -3
- package/dist/components/Icons/IconAlertTriangle.svelte +1 -3
- package/dist/components/Icons/IconCamera.svelte +1 -3
- package/dist/components/Icons/IconClose.svelte +1 -3
- package/dist/components/Icons/IconEdit.svelte +1 -3
- package/dist/components/Icons/IconFilter.svelte +1 -3
- package/dist/components/Icons/IconSearch.svelte +1 -3
- package/dist/components/Icons/IconSort.svelte +1 -3
- package/dist/components/Icons/IconTrash.svelte +1 -3
- package/dist/components/Portal/Portal.svelte +14 -38
- package/dist/components/Screenshot/Screenshot.svelte +7 -13
- package/dist/components/Svark/Svark.svelte +680 -852
- package/dist/components/Svark/SvarkContextMenu.svelte +44 -63
- package/dist/components/Svark/SvarkInfiniteLoader.svelte +2 -6
- package/dist/components/Svark/SvarkPager.svelte +2 -28
- package/dist/components/Svark/SvarkSelectionDemo.svelte +4 -8
- package/dist/components/Svark/SvarkTopBar.svelte +9 -74
- package/dist/components/SvarkGrid/SvarkGrid.svelte +877 -1123
- package/dist/components/SvarkGrid/components/SvarkColumnFilterForm.svelte +45 -58
- package/dist/components/SvarkGrid/components/SvarkContextMenu.svelte +44 -63
- package/dist/components/SvarkGrid/components/SvarkHeaderFilterCell.svelte +41 -75
- package/dist/components/SvarkGrid/components/SvarkInfiniteLoader.svelte +2 -6
- package/dist/components/SvarkGrid/components/SvarkPager.svelte +2 -28
- package/dist/components/SvarkGrid/components/SvarkSearchPopover.svelte +8 -16
- package/dist/components/SvarkGrid/components/SvarkTopBar.svelte +6 -62
- package/dist/components/SvarkGrid/internal/SvarkGridView.svelte +345 -507
- package/dist/components/VTree/VTree.svelte +454 -431
- package/dist/components/VTree/VTree.utils.d.ts +23 -0
- package/dist/components/VTree/VTree.utils.js +73 -0
- package/dist/components/VTree/VTreeContextMenu.svelte +21 -33
- package/dist/components/VTree/VTreeControlledSelectionDemo.svelte +20 -0
- package/dist/components/VTree/VTreeControlledSelectionDemo.svelte.d.ts +18 -0
- package/dist/components/VTree/VTreeCustomizationDemo.svelte +23 -0
- package/dist/components/VTree/VTreeCustomizationDemo.svelte.d.ts +18 -0
- package/dist/components/VTree/VTreeEventsDemo.svelte +48 -58
- package/dist/components/VTree/VTreeInteractionDemo.svelte +29 -0
- package/dist/components/VTree/VTreeInteractionDemo.svelte.d.ts +18 -0
- package/dist/components/VTree/VTreeMultiSelectDemo.svelte +27 -0
- package/dist/components/VTree/VTreeMultiSelectDemo.svelte.d.ts +18 -0
- package/dist/components/VTree/VTreeRow.svelte +77 -115
- package/dist/components/VTree/VTreeRow.svelte.d.ts +34 -18
- package/dist/components/VTree/VTreeSearch.svelte +6 -13
- package/dist/components/VTree/VTreeVirtualViewport.svelte +54 -143
- package/dist/components/VTree/VTreeVirtualViewport.svelte.d.ts +35 -18
- package/dist/components/VTree/types.d.ts +39 -1
- package/llm/COMPONENT_GUIDE.md +25 -0
- package/package.json +51 -50
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Svelix
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@warkypublic/svelix` — a Svelte 5 component library built on Skeleton UI and Tailwind CSS v4, focused on workflow-heavy UI, data-rich views, and content tooling.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,45 +8,105 @@ Svelix is a Svelte 5 component library focused on workflow-heavy UI, data-rich v
|
|
|
8
8
|
pnpm add @warkypublic/svelix
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## LLM Documentation
|
|
18
|
-
|
|
19
|
-
The repository includes an `llm/` folder with project context and implementation docs.
|
|
20
|
-
|
|
21
|
-
### In this repository
|
|
22
|
-
|
|
23
|
-
- [llm/README.md](./llm/README.md)
|
|
24
|
-
- [llm/ARCHITECTURE.md](./llm/ARCHITECTURE.md)
|
|
25
|
-
- [llm/SETUP.md](./llm/SETUP.md)
|
|
26
|
-
- [llm/COMPONENT_GUIDE.md](./llm/COMPONENT_GUIDE.md)
|
|
27
|
-
- [llm/IMPLEMENTATION_PLAN.md](./llm/IMPLEMENTATION_PLAN.md)
|
|
28
|
-
- [llm/ROADMAP.md](./llm/ROADMAP.md)
|
|
29
|
-
- [llm/ESLINT_GUIDE.md](./llm/ESLINT_GUIDE.md)
|
|
30
|
-
- [llm/tools/SVAR.md](./llm/tools/SVAR.md)
|
|
31
|
-
- [llm/tools/resolvespec-js.md](./llm/tools/resolvespec-js.md)
|
|
32
|
-
|
|
33
|
-
### After install
|
|
13
|
+
```ts
|
|
14
|
+
import { Button, Former, Gridler } from '@warkypublic/svelix';
|
|
15
|
+
```
|
|
34
16
|
|
|
35
|
-
|
|
17
|
+
## Components
|
|
18
|
+
|
|
19
|
+
### Layout & Structure
|
|
20
|
+
| Export | Description |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `Boxer`, `BoxerTarget` | Adaptive layout container with data-adapter support |
|
|
23
|
+
| `Portal` | Renders children outside the current DOM subtree |
|
|
24
|
+
| `ErrorBoundary` | Catches and displays component errors |
|
|
25
|
+
|
|
26
|
+
### Forms
|
|
27
|
+
| Export | Description |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `Former`, `FormerButtonArea`, `FormerDrawer`, `FormerModal` | Form builder with modal/drawer variants |
|
|
30
|
+
| `createFormerState` | Reactive form state factory |
|
|
31
|
+
| `FormerResolveSpecAPI`, `FormerRestHeadSpecAPI` | API adapters for form data sources |
|
|
32
|
+
| `ButtonCtrl`, `IconButtonCtrl` | Button and icon-button form controls |
|
|
33
|
+
| `TextInputCtrl`, `TextAreaCtrl`, `PasswordInputCtrl` | Text input controls |
|
|
34
|
+
| `NumberInputCtrl`, `NativeSelectCtrl` | Number and select controls |
|
|
35
|
+
| `SwitchCtrl`, `DateTimeCtrl` | Toggle and date/time picker controls |
|
|
36
|
+
| `InlineWrapper` | Inline layout wrapper for form controls |
|
|
37
|
+
|
|
38
|
+
### Data Grids
|
|
39
|
+
| Export | Description |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `Gridler`, `GridlerFull` | Feature-rich data grid / table |
|
|
42
|
+
| `GridlerResolveSpecAdapter`, `GridlerRestHeaderSpecAdapter` | Data adapters for Gridler |
|
|
43
|
+
| `SvarkGrid` | SVAR-based grid with context menus and column mapping |
|
|
44
|
+
| `SvarkResolveSpecAdapter`, `SvarkRestHeaderSpecAdapter` | Data adapters for SvarkGrid |
|
|
45
|
+
|
|
46
|
+
### Card Grid
|
|
47
|
+
| Export | Description |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `CardGrid`, `DefaultCard`, `CardGridFilterPanel` | Filterable, sortable card grid |
|
|
50
|
+
|
|
51
|
+
### Menus & Overlays
|
|
52
|
+
| Export | Description |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `BetterMenu`, `MenuRenderer` | Enhanced dropdown menu |
|
|
55
|
+
| `createBetterMenuStore` | Store factory for menu state |
|
|
56
|
+
| `OverlayStack` | Stacked modal/overlay manager |
|
|
57
|
+
|
|
58
|
+
### Content & Markup
|
|
59
|
+
| Export | Description |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `ContentEditor` | Rich content editor (Carta Markdown + Monaco) |
|
|
62
|
+
|
|
63
|
+
### Trees
|
|
64
|
+
| Export | Description |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `VTree` | Virtualised tree view |
|
|
67
|
+
| `VTreeResolveSpecAdapter` | Data adapter for VTree |
|
|
68
|
+
|
|
69
|
+
### Global State
|
|
70
|
+
| Export | Description |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `GlobalStateStoreProvider` | App-level state provider |
|
|
73
|
+
| `useGlobalStateStoreContext` | Context accessor |
|
|
74
|
+
| `t`, `_T`, `loadTranslations`, `appendTranslations`, etc. | i18n helpers |
|
|
75
|
+
|
|
76
|
+
### Utilities & Misc
|
|
77
|
+
| Export | Description |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `Button` | Base button component |
|
|
80
|
+
| `CaptureScreenshotComponent`, `CaptureScreen` | Screenshot capture |
|
|
81
|
+
| `errorManager` | Global error manager |
|
|
82
|
+
| `IconAdd`, `IconClose`, `IconEdit`, `IconSearch`, etc. | SVG icon components |
|
|
83
|
+
|
|
84
|
+
## CSS Assets
|
|
85
|
+
|
|
86
|
+
Tailwind CSS source and theme files are published under `@warkypublic/svelix/css/`:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import '@warkypublic/svelix/css/tailwind-source.css';
|
|
90
|
+
import '@warkypublic/svelix/css/svelix_orange.css';
|
|
91
|
+
```
|
|
36
92
|
|
|
37
|
-
|
|
38
|
-
- package subpath: `@warkypublic/svelix/llm/...`
|
|
93
|
+
## LLM Documentation
|
|
39
94
|
|
|
40
|
-
|
|
95
|
+
Extended architecture and implementation docs are published with the package under `@warkypublic/svelix/llm/`:
|
|
41
96
|
|
|
42
|
-
```
|
|
97
|
+
```
|
|
43
98
|
node_modules/@warkypublic/svelix/llm/README.md
|
|
44
99
|
node_modules/@warkypublic/svelix/llm/ARCHITECTURE.md
|
|
100
|
+
node_modules/@warkypublic/svelix/llm/COMPONENT_GUIDE.md
|
|
45
101
|
```
|
|
46
102
|
|
|
47
|
-
|
|
48
|
-
@warkypublic/svelix/llm/README.md
|
|
49
|
-
@warkypublic/svelix/llm/ARCHITECTURE.md
|
|
50
|
-
```
|
|
103
|
+
## Development
|
|
51
104
|
|
|
52
|
-
|
|
105
|
+
```bash
|
|
106
|
+
pnpm dev # SvelteKit dev server
|
|
107
|
+
pnpm storybook # Storybook on port 6006
|
|
108
|
+
pnpm build # Build package
|
|
109
|
+
pnpm test # Run unit tests
|
|
110
|
+
pnpm check # Type-check .svelte files
|
|
111
|
+
pnpm lint # ESLint
|
|
112
|
+
```
|
|
@@ -1,41 +1,25 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
providerID?: string;
|
|
12
|
-
width?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const { children, disablePortal = false, providerID, width }: Props = $props();
|
|
16
|
-
|
|
17
|
-
// providerID intentionally uses initial value - stores are created once per provider instance
|
|
18
|
-
const store = createBetterMenuStore(providerID);
|
|
19
|
-
|
|
20
|
-
$effect(() => {
|
|
21
|
-
if (width !== undefined) {
|
|
22
|
-
store.setWidth(width);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
setContext('betterMenuStore', store);
|
|
27
|
-
|
|
28
|
-
export function show(id: string, options?: Partial<Omit<BetterMenuInstance, 'id'>>) {
|
|
29
|
-
store.show(id, options);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function set(id: string, options?: Partial<Omit<BetterMenuInstance, 'id'>>) {
|
|
33
|
-
store.set(id, options);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function hide(id: string) {
|
|
37
|
-
store.hide(id);
|
|
1
|
+
<script lang="ts">import { setContext } from "svelte";
|
|
2
|
+
import { createBetterMenuStore } from "./store";
|
|
3
|
+
import MenuRenderer from "./MenuRenderer.svelte";
|
|
4
|
+
const { children, disablePortal = false, providerID, width } = $props();
|
|
5
|
+
// providerID intentionally uses initial value - stores are created once per provider instance
|
|
6
|
+
// svelte-ignore state_referenced_locally
|
|
7
|
+
const store = createBetterMenuStore(providerID);
|
|
8
|
+
$effect(() => {
|
|
9
|
+
if (width !== undefined) {
|
|
10
|
+
store.setWidth(width);
|
|
38
11
|
}
|
|
12
|
+
});
|
|
13
|
+
setContext("betterMenuStore", store);
|
|
14
|
+
export function show(id, options) {
|
|
15
|
+
store.show(id, options);
|
|
16
|
+
}
|
|
17
|
+
export function set(id, options) {
|
|
18
|
+
store.set(id, options);
|
|
19
|
+
}
|
|
20
|
+
export function hide(id) {
|
|
21
|
+
store.hide(id);
|
|
22
|
+
}
|
|
39
23
|
</script>
|
|
40
24
|
|
|
41
25
|
<MenuRenderer {disablePortal} />
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (item.onClickAsync) {
|
|
23
|
-
loading = true;
|
|
24
|
-
try {
|
|
25
|
-
await item.onClickAsync(e);
|
|
26
|
-
} finally {
|
|
27
|
-
loading = false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
onClose();
|
|
31
|
-
}
|
|
1
|
+
<script lang="ts">const { item, onClose } = $props();
|
|
2
|
+
let loading = $state(false);
|
|
3
|
+
function isSnippet(value) {
|
|
4
|
+
return typeof value === "function";
|
|
5
|
+
}
|
|
6
|
+
function isSvg(value) {
|
|
7
|
+
return value?.trimStart?.().startsWith?.("<svg");
|
|
8
|
+
}
|
|
9
|
+
async function handleClick(e) {
|
|
10
|
+
item.onClick?.(e);
|
|
11
|
+
if (item.onClickAsync) {
|
|
12
|
+
loading = true;
|
|
13
|
+
try {
|
|
14
|
+
await item.onClickAsync(e);
|
|
15
|
+
} finally {
|
|
16
|
+
loading = false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
onClose();
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
32
22
|
</script>
|
|
33
23
|
|
|
34
24
|
<button
|
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]
|
|
28
|
-
});
|
|
29
|
-
}
|
|
1
|
+
<script lang="ts">import BetterMenu from "./BetterMenu.svelte";
|
|
2
|
+
const { providerID = "storybook-menu", width } = $props();
|
|
3
|
+
let betterMenuRef = $state();
|
|
4
|
+
let buttonRef = $state(null);
|
|
5
|
+
function showMenu() {
|
|
6
|
+
if (betterMenuRef && buttonRef) {
|
|
7
|
+
const rect = buttonRef.getBoundingClientRect();
|
|
8
|
+
betterMenuRef.show("example-menu", {
|
|
9
|
+
x: rect.left,
|
|
10
|
+
y: rect.bottom + 8,
|
|
11
|
+
items: [
|
|
12
|
+
{
|
|
13
|
+
label: "Option 1",
|
|
14
|
+
onClick: () => { /* Option 1 selected */}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: "Option 2",
|
|
18
|
+
onClick: () => { /* Option 2 selected */}
|
|
19
|
+
},
|
|
20
|
+
{ isDivider: true },
|
|
21
|
+
{
|
|
22
|
+
label: "Option 3",
|
|
23
|
+
onClick: () => { /* Option 3 selected */}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
});
|
|
30
27
|
}
|
|
28
|
+
}
|
|
31
29
|
</script>
|
|
32
30
|
|
|
33
31
|
<BetterMenu bind:this={betterMenuRef} {providerID} {width}>
|
|
@@ -1,56 +1,45 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let backdropZ = $state(1090);
|
|
19
|
-
let menuZ = $state(1100);
|
|
20
|
-
let submenuZ = $state(1110);
|
|
21
|
-
|
|
22
|
-
$effect(() => {
|
|
23
|
-
return store.subscribe((s) => {
|
|
24
|
-
menuState = s;
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
$effect(() => {
|
|
29
|
-
if (!hasVisibleMenus) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const overlay = registerOverlay({
|
|
34
|
-
kind: 'menu',
|
|
35
|
-
mount: disablePortal ? 'inline' : 'portal',
|
|
36
|
-
});
|
|
37
|
-
backdropZ = overlay.layer.backdrop;
|
|
38
|
-
menuZ = overlay.layer.content;
|
|
39
|
-
submenuZ = overlay.layer.floating;
|
|
40
|
-
|
|
41
|
-
return () => {
|
|
42
|
-
overlay.unregister();
|
|
43
|
-
backdropZ = 1090;
|
|
44
|
-
menuZ = 1100;
|
|
45
|
-
submenuZ = 1110;
|
|
46
|
-
};
|
|
1
|
+
<script lang="ts">import { getContext } from "svelte";
|
|
2
|
+
import BetterMenuAsyncButton from "./BetterMenuAsyncButton.svelte";
|
|
3
|
+
import { registerOverlay } from "../OverlayStack";
|
|
4
|
+
import Portal from "../Portal/Portal.svelte";
|
|
5
|
+
const { disablePortal = false } = $props();
|
|
6
|
+
const store = getContext("betterMenuStore");
|
|
7
|
+
let menuState = $state({
|
|
8
|
+
menus: [],
|
|
9
|
+
providerID: ""
|
|
10
|
+
});
|
|
11
|
+
const hasVisibleMenus = $derived(menuState.menus.some((menu) => menu.visible));
|
|
12
|
+
let backdropZ = $state(1090);
|
|
13
|
+
let menuZ = $state(1100);
|
|
14
|
+
let submenuZ = $state(1110);
|
|
15
|
+
$effect(() => {
|
|
16
|
+
return store.subscribe((s) => {
|
|
17
|
+
menuState = s;
|
|
47
18
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
store.setInstanceState(id, 'visible', false);
|
|
19
|
+
});
|
|
20
|
+
$effect(() => {
|
|
21
|
+
if (!hasVisibleMenus) {
|
|
22
|
+
return;
|
|
53
23
|
}
|
|
24
|
+
const overlay = registerOverlay({
|
|
25
|
+
kind: "menu",
|
|
26
|
+
mount: disablePortal ? "inline" : "portal"
|
|
27
|
+
});
|
|
28
|
+
backdropZ = overlay.layer.backdrop;
|
|
29
|
+
menuZ = overlay.layer.content;
|
|
30
|
+
submenuZ = overlay.layer.floating;
|
|
31
|
+
return () => {
|
|
32
|
+
overlay.unregister();
|
|
33
|
+
backdropZ = 1090;
|
|
34
|
+
menuZ = 1100;
|
|
35
|
+
submenuZ = 1110;
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
function hideMenu(id) {
|
|
39
|
+
const menu = menuState.menus.find((m) => m.id === id);
|
|
40
|
+
menu?.onHide?.();
|
|
41
|
+
store.setInstanceState(id, "visible", false);
|
|
42
|
+
}
|
|
54
43
|
</script>
|
|
55
44
|
|
|
56
45
|
{#snippet menuItem(item: BetterMenuInstanceItem, onClose: () => void)}
|