@streamscloud/kit 0.38.2 → 0.40.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/dist/core/utils/filter-helper.d.ts +8 -0
- package/dist/core/utils/filter-helper.js +25 -0
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/core/utils/index.js +1 -0
- package/dist/ui/page-layout/cmp.page-panel-sidebars.svelte +11 -18
- package/dist/ui/page-layout/cmp.page-panel-sidebars.svelte.d.ts +7 -8
- package/dist/ui/page-layout/index.d.ts +1 -1
- package/dist/ui/page-layout/index.js +1 -1
- package/dist/ui/page-layout/panel-state.svelte.d.ts +33 -0
- package/dist/ui/page-layout/panel-state.svelte.js +46 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class FilterHelper {
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether `filters` differs from its empty/default state.
|
|
4
|
+
* Strings are compared trimmed; arrays and any key present in `empty` via {@link Utils.areEqual} (deep);
|
|
5
|
+
* a key absent from `empty` is considered applied when its value isn't `null`/`undefined`.
|
|
6
|
+
*/
|
|
7
|
+
static isApplied<T extends Record<string, unknown>>(filters: T, empty?: Partial<T>): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Utils } from './utils';
|
|
2
|
+
export class FilterHelper {
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether `filters` differs from its empty/default state.
|
|
5
|
+
* Strings are compared trimmed; arrays and any key present in `empty` via {@link Utils.areEqual} (deep);
|
|
6
|
+
* a key absent from `empty` is considered applied when its value isn't `null`/`undefined`.
|
|
7
|
+
*/
|
|
8
|
+
static isApplied(filters, empty = {}) {
|
|
9
|
+
const keys = new Set([...Object.keys(filters), ...Object.keys(empty)]);
|
|
10
|
+
return [...keys].some((key) => {
|
|
11
|
+
const value = filters[key];
|
|
12
|
+
const probe = value ?? empty[key];
|
|
13
|
+
if (typeof probe === 'string') {
|
|
14
|
+
return (value ?? '').trim() !== (empty[key] ?? '').trim();
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(probe)) {
|
|
17
|
+
return !Utils.areEqual(value ?? [], empty[key] ?? []);
|
|
18
|
+
}
|
|
19
|
+
if (key in empty) {
|
|
20
|
+
return !Utils.areEqual(value, empty[key]);
|
|
21
|
+
}
|
|
22
|
+
return value !== null && value !== undefined;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -5,6 +5,7 @@ export * from './base64-serializer';
|
|
|
5
5
|
export * from './browser';
|
|
6
6
|
export * from './date-helper';
|
|
7
7
|
export * from './dom-helper';
|
|
8
|
+
export * from './filter-helper';
|
|
8
9
|
export * from './href-validator';
|
|
9
10
|
export * from './html-helper';
|
|
10
11
|
export * from './image-preloader';
|
package/dist/core/utils/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from './base64-serializer';
|
|
|
5
5
|
export * from './browser';
|
|
6
6
|
export * from './date-helper';
|
|
7
7
|
export * from './dom-helper';
|
|
8
|
+
export * from './filter-helper';
|
|
8
9
|
export * from './href-validator';
|
|
9
10
|
export * from './html-helper';
|
|
10
11
|
export * from './image-preloader';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">import { slideHorizontally, transitionDuration } from '../../core/transitions';
|
|
2
2
|
import PagePanel from './cmp.page-panel.svelte';
|
|
3
3
|
import { untrack } from 'svelte';
|
|
4
|
-
const { panelState, children, sidebarLeft, sidebarRight, sidebarLeftIsValid = true, sidebarRightIsValid = true, title, actionsLeft, actionsCenter, actionsRight, balanceHeaderCenter = false } = $props();
|
|
4
|
+
const { panelState, children, sidebarLeft, sidebarRight, sidebarLeftIsValid = true, sidebarRightIsValid = true, title, actionsLeft, actionsCenter, actionsRight, balanceHeaderCenter = false, toggle } = $props();
|
|
5
5
|
let leftPanel = $state(null);
|
|
6
6
|
let rightPanel = $state(null);
|
|
7
7
|
$effect(() => {
|
|
@@ -31,21 +31,13 @@ $effect(() => {
|
|
|
31
31
|
const collapseButtons = $derived([leftPanel?.id, rightPanel?.id].filter((id) => id !== null && id !== undefined));
|
|
32
32
|
const leftCollapsed = $derived(leftPanel?.entry.collapsed ?? false);
|
|
33
33
|
const rightCollapsed = $derived(rightPanel?.entry.collapsed ?? false);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function toggleBoth() {
|
|
42
|
-
const entries = [leftPanel?.entry, rightPanel?.entry].filter((entry) => !!entry);
|
|
43
|
-
if (entries.length === 0) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const allCollapsed = entries.every((entry) => entry.collapsed);
|
|
47
|
-
entries.forEach((entry) => entry.setCollapsed(!allCollapsed));
|
|
48
|
-
}
|
|
34
|
+
$effect(() => {
|
|
35
|
+
const attached = toggle;
|
|
36
|
+
attached?.attach(leftPanel?.entry ?? null, rightPanel?.entry ?? null);
|
|
37
|
+
return () => {
|
|
38
|
+
attached?.attach(null, null);
|
|
39
|
+
};
|
|
40
|
+
});
|
|
49
41
|
$effect(() => {
|
|
50
42
|
if (leftPanel) {
|
|
51
43
|
leftPanel.entry.isValid = sidebarLeftIsValid;
|
|
@@ -101,8 +93,9 @@ PagePanelSidebars — a `PagePanel` whose body has collapsible left / right side
|
|
|
101
93
|
fictional left/right panels in the shared `PanelState` so the standard collapse buttons in the
|
|
102
94
|
header can target them. Sidebars slide horizontally on collapse / expand.
|
|
103
95
|
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
Pass a `SidebarsToggle` instance as `toggle` to drive an external "collapse both" control (e.g. a
|
|
97
|
+
top-bar button) without `bind:this` or a local collapsed flag — read `toggleBoth` / `allCollapsed`
|
|
98
|
+
off that same instance.
|
|
106
99
|
|
|
107
100
|
### CSS Custom Properties
|
|
108
101
|
| Property | Description | Default |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PanelState } from './panel-state.svelte';
|
|
1
|
+
import type { PanelState, SidebarsToggle } from './panel-state.svelte';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
type Props = {
|
|
4
4
|
/** The shared `PanelState` instance the inner panel + sidebars register with. */
|
|
@@ -14,24 +14,23 @@ type Props = {
|
|
|
14
14
|
actionsRight?: Snippet;
|
|
15
15
|
/** Lay the inner panel header out as a 3-column grid so `actionsCenter` is centered against the panel width. @default false */
|
|
16
16
|
balanceHeaderCenter?: boolean;
|
|
17
|
+
/** Shared collapse target for an external "collapse both sidebars" control (e.g. `PageLayout`'s `editorControls.panelsToggle`). */
|
|
18
|
+
toggle?: SidebarsToggle;
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* PagePanelSidebars — a `PagePanel` whose body has collapsible left / right sidebars. Registers
|
|
20
22
|
* fictional left/right panels in the shared `PanelState` so the standard collapse buttons in the
|
|
21
23
|
* header can target them. Sidebars slide horizontally on collapse / expand.
|
|
22
24
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* Pass a `SidebarsToggle` instance as `toggle` to drive an external "collapse both" control (e.g. a
|
|
26
|
+
* top-bar button) without `bind:this` or a local collapsed flag — read `toggleBoth` / `allCollapsed`
|
|
27
|
+
* off that same instance.
|
|
25
28
|
*
|
|
26
29
|
* ### CSS Custom Properties
|
|
27
30
|
* | Property | Description | Default |
|
|
28
31
|
* |---|---|---|
|
|
29
32
|
* | `--sc-kit--page-panel-sidebars--border-color` | Sidebar divider color | `--sc-kit--color--border` |
|
|
30
33
|
*/
|
|
31
|
-
declare const Cmp: import("svelte").Component<Props, {
|
|
32
|
-
toggleLeft: () => void;
|
|
33
|
-
toggleRight: () => void;
|
|
34
|
-
toggleBoth: () => void;
|
|
35
|
-
}, "">;
|
|
34
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
36
35
|
type Cmp = ReturnType<typeof Cmp>;
|
|
37
36
|
export default Cmp;
|
|
@@ -4,5 +4,5 @@ export { default as PagePanelSidebars } from './cmp.page-panel-sidebars.svelte';
|
|
|
4
4
|
export { default as PagePanels } from './cmp.page-panels.svelte';
|
|
5
5
|
export { default as PanelCollapseButton } from './cmp.panel-collapse-button.svelte';
|
|
6
6
|
export { default as PanelContent } from './cmp.panel-content.svelte';
|
|
7
|
-
export { PanelEntry, PanelState } from './panel-state.svelte';
|
|
7
|
+
export { PanelEntry, PanelState, SidebarsToggle } from './panel-state.svelte';
|
|
8
8
|
export type { EditorControls, PageLayoutAction, PanelBorder, PanelResizingSettings } from './types';
|
|
@@ -4,4 +4,4 @@ export { default as PagePanelSidebars } from './cmp.page-panel-sidebars.svelte';
|
|
|
4
4
|
export { default as PagePanels } from './cmp.page-panels.svelte';
|
|
5
5
|
export { default as PanelCollapseButton } from './cmp.panel-collapse-button.svelte';
|
|
6
6
|
export { default as PanelContent } from './cmp.panel-content.svelte';
|
|
7
|
-
export { PanelEntry, PanelState } from './panel-state.svelte';
|
|
7
|
+
export { PanelEntry, PanelState, SidebarsToggle } from './panel-state.svelte';
|
|
@@ -47,4 +47,37 @@ export declare class PanelState {
|
|
|
47
47
|
get: (id: string) => PanelEntry | null;
|
|
48
48
|
unregister: (id: string, entry: PanelEntry) => void;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Shared collapse target for a `PagePanelSidebars`'s left/right sidebar pair. Create one instance
|
|
52
|
+
* and pass it to `PagePanelSidebars`'s `toggle` prop, then read `toggleBoth` / `allCollapsed` from
|
|
53
|
+
* this instance wherever the external control lives (e.g. `PageLayout`'s `editorControls`) — no
|
|
54
|
+
* `bind:this` or extra local state needed on the consumer side.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const panels = new PanelState();
|
|
59
|
+
* const sidebarsToggle = new SidebarsToggle();
|
|
60
|
+
* ```
|
|
61
|
+
* ```svelte
|
|
62
|
+
* <PageLayout editorControls={{ panelsToggle: { active: sidebarsToggle.allCollapsed, onClick: sidebarsToggle.toggleBoth }, close: {...} }}>
|
|
63
|
+
* <PagePanels>
|
|
64
|
+
* <PagePanelSidebars panelState={panels} toggle={sidebarsToggle}>...</PagePanelSidebars>
|
|
65
|
+
* </PagePanels>
|
|
66
|
+
* </PageLayout>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare class SidebarsToggle {
|
|
70
|
+
private _left;
|
|
71
|
+
private _right;
|
|
72
|
+
/**
|
|
73
|
+
* True when every attached sidebar is currently collapsed.
|
|
74
|
+
* @remarks False both when there are no sidebars attached and before `PagePanelSidebars` mounts —
|
|
75
|
+
* an external toggle button reads this as "not active" in either case.
|
|
76
|
+
*/
|
|
77
|
+
get allCollapsed(): boolean;
|
|
78
|
+
/** Wired automatically by the paired `PagePanelSidebars`'s `toggle` prop. Not for direct use. */
|
|
79
|
+
attach(left: PanelEntry | null, right: PanelEntry | null): void;
|
|
80
|
+
/** Collapses both sidebars, or expands both when they are already all collapsed. */
|
|
81
|
+
toggleBoth: () => void;
|
|
82
|
+
}
|
|
50
83
|
export {};
|
|
@@ -59,3 +59,49 @@ export class PanelState {
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Shared collapse target for a `PagePanelSidebars`'s left/right sidebar pair. Create one instance
|
|
64
|
+
* and pass it to `PagePanelSidebars`'s `toggle` prop, then read `toggleBoth` / `allCollapsed` from
|
|
65
|
+
* this instance wherever the external control lives (e.g. `PageLayout`'s `editorControls`) — no
|
|
66
|
+
* `bind:this` or extra local state needed on the consumer side.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const panels = new PanelState();
|
|
71
|
+
* const sidebarsToggle = new SidebarsToggle();
|
|
72
|
+
* ```
|
|
73
|
+
* ```svelte
|
|
74
|
+
* <PageLayout editorControls={{ panelsToggle: { active: sidebarsToggle.allCollapsed, onClick: sidebarsToggle.toggleBoth }, close: {...} }}>
|
|
75
|
+
* <PagePanels>
|
|
76
|
+
* <PagePanelSidebars panelState={panels} toggle={sidebarsToggle}>...</PagePanelSidebars>
|
|
77
|
+
* </PagePanels>
|
|
78
|
+
* </PageLayout>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export class SidebarsToggle {
|
|
82
|
+
_left = $state(null);
|
|
83
|
+
_right = $state(null);
|
|
84
|
+
/**
|
|
85
|
+
* True when every attached sidebar is currently collapsed.
|
|
86
|
+
* @remarks False both when there are no sidebars attached and before `PagePanelSidebars` mounts —
|
|
87
|
+
* an external toggle button reads this as "not active" in either case.
|
|
88
|
+
*/
|
|
89
|
+
get allCollapsed() {
|
|
90
|
+
const entries = [this._left, this._right].filter((entry) => !!entry);
|
|
91
|
+
return entries.length > 0 && entries.every((entry) => entry.collapsed);
|
|
92
|
+
}
|
|
93
|
+
/** Wired automatically by the paired `PagePanelSidebars`'s `toggle` prop. Not for direct use. */
|
|
94
|
+
attach(left, right) {
|
|
95
|
+
this._left = left;
|
|
96
|
+
this._right = right;
|
|
97
|
+
}
|
|
98
|
+
/** Collapses both sidebars, or expands both when they are already all collapsed. */
|
|
99
|
+
toggleBoth = () => {
|
|
100
|
+
const entries = [this._left, this._right].filter((entry) => !!entry);
|
|
101
|
+
if (entries.length === 0) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const collapsed = entries.every((entry) => entry.collapsed);
|
|
105
|
+
entries.forEach((entry) => entry.setCollapsed(!collapsed));
|
|
106
|
+
};
|
|
107
|
+
}
|