@softwareone/spi-sv5-library 1.5.8 → 1.5.10
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/Avatar/Avatar.svelte +19 -5
- package/dist/Avatar/Avatar.svelte.d.ts +1 -0
- package/dist/Header/Header.svelte +7 -1
- package/dist/HighlightPanel/HighlightPanel.svelte +1 -1
- package/dist/HighlightPanel/highlightPanelState.svelte.d.ts +12 -2
- package/dist/Home/Home.svelte +1 -1
- package/dist/Menu/Menu.svelte +1 -1
- package/dist/Menu/Menu.svelte.d.ts +1 -1
- package/dist/Menu/MenuItem.svelte +5 -3
- package/dist/Menu/MenuItem.svelte.d.ts +1 -1
- package/dist/Menu/MenuState.svelte.d.ts +22 -0
- package/dist/Menu/MenuState.svelte.js +7 -0
- package/dist/Menu/Sidebar.svelte +46 -36
- package/dist/Menu/Sidebar.svelte.d.ts +4 -8
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/package.json +1 -1
- package/dist/Home/homeState.svelte.d.ts +0 -4
- package/dist/Home/homeState.svelte.js +0 -1
- package/dist/Menu/SidebarState.svelte.d.ts +0 -6
- package/dist/Menu/SidebarState.svelte.js +0 -1
|
@@ -6,15 +6,29 @@
|
|
|
6
6
|
text: string;
|
|
7
7
|
backgroundColor?: BackgroundColor;
|
|
8
8
|
textColor?: TextColor;
|
|
9
|
+
keepOrder?: boolean;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
let {
|
|
12
|
+
let {
|
|
13
|
+
text,
|
|
14
|
+
backgroundColor = '#25282D',
|
|
15
|
+
textColor = '#FFFFFF',
|
|
16
|
+
keepOrder = false
|
|
17
|
+
}: AvatarProps = $props();
|
|
12
18
|
|
|
13
|
-
const avatarSrc = (
|
|
19
|
+
const avatarSrc = (text: string): string => {
|
|
14
20
|
const defaultValue = 'SO';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const trimmedText = text.trim();
|
|
22
|
+
|
|
23
|
+
if (!trimmedText) return defaultValue;
|
|
24
|
+
|
|
25
|
+
const [first, second] = trimmedText.split(/\s+/);
|
|
26
|
+
|
|
27
|
+
if (!second) return first[0].toUpperCase();
|
|
28
|
+
|
|
29
|
+
const initials = keepOrder ? `${first[0]}${second[0]}` : `${second[0]}${first[0]}`;
|
|
30
|
+
|
|
31
|
+
return initials.toUpperCase();
|
|
18
32
|
};
|
|
19
33
|
</script>
|
|
20
34
|
|
|
@@ -72,7 +72,13 @@
|
|
|
72
72
|
<Waffle items={waffleItems} bind:showWaffle />
|
|
73
73
|
{/if}
|
|
74
74
|
{#if menuItems}
|
|
75
|
-
<button
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
class={[showMenu && 'active', 'header-button']}
|
|
78
|
+
onclick={toggleMenu}
|
|
79
|
+
aria-label="menu button"
|
|
80
|
+
aria-expanded={showMenu}
|
|
81
|
+
>
|
|
76
82
|
<span class="material-icons icon-span menu-icon">menu</span>
|
|
77
83
|
</button>
|
|
78
84
|
<Menu {menuItems} bind:showMenu />
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
{#if iconType === ImageType.Default}
|
|
45
45
|
<img src={content} alt="icon" />
|
|
46
46
|
{:else if iconType === ImageType.Avatar}
|
|
47
|
-
<Avatar text={content} />
|
|
47
|
+
<Avatar text={content} keepOrder={column.keepOrder} />
|
|
48
48
|
{:else if iconType === ImageType.Material}
|
|
49
49
|
<span class="material-icons">{content}</span>
|
|
50
50
|
{/if}
|
|
@@ -22,12 +22,22 @@ type Link = BaseColumn & {
|
|
|
22
22
|
type: ColumnType.Link;
|
|
23
23
|
url: string;
|
|
24
24
|
};
|
|
25
|
-
type
|
|
25
|
+
type BaseIcon = BaseColumn & {
|
|
26
26
|
type: ColumnType.Image;
|
|
27
|
-
iconType: ImageType;
|
|
28
27
|
content: string;
|
|
29
28
|
alignTextRight?: boolean;
|
|
30
29
|
};
|
|
30
|
+
type AvatarIcon = BaseIcon & {
|
|
31
|
+
iconType: ImageType.Avatar;
|
|
32
|
+
keepOrder?: boolean;
|
|
33
|
+
};
|
|
34
|
+
type ImageIcon = BaseIcon & {
|
|
35
|
+
iconType: ImageType.Default;
|
|
36
|
+
};
|
|
37
|
+
type MaterialIcon = BaseIcon & {
|
|
38
|
+
iconType: ImageType.Material;
|
|
39
|
+
};
|
|
40
|
+
type Icon = AvatarIcon | ImageIcon | MaterialIcon;
|
|
31
41
|
type Status = BaseColumn & {
|
|
32
42
|
type: ColumnType.Status;
|
|
33
43
|
chipType: ChipType;
|
package/dist/Home/Home.svelte
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<section class="home-container grid">
|
|
17
17
|
{#each homeItems as homeItem}
|
|
18
18
|
<a href={homeItem.url} class="home-item">
|
|
19
|
-
<img src={homeItem.
|
|
19
|
+
<img src={homeItem.homeIcon} alt={homeItem.text} />
|
|
20
20
|
<div>
|
|
21
21
|
<h2>{homeItem.text}</h2>
|
|
22
22
|
<p>{homeItem.detail}</p>
|
package/dist/Menu/Menu.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Tooltip } from '../index.js';
|
|
3
|
-
import type { MenuItem } from './
|
|
3
|
+
import type { MenuItem } from './MenuState.svelte.js';
|
|
4
4
|
|
|
5
5
|
interface MenuItemProps {
|
|
6
6
|
item: MenuItem;
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
]}
|
|
24
24
|
onclick={() => onClick?.(item)}
|
|
25
25
|
>
|
|
26
|
+
|
|
26
27
|
<span class="material-icons-outlined icon-span">{item.icon}</span>
|
|
27
28
|
<h2 class="item-name-span" class:hidden={isCollapsed}>{item.text}</h2>
|
|
28
29
|
</a>
|
|
@@ -88,12 +89,13 @@
|
|
|
88
89
|
background-color: #f4f6f8;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
.active-collapsed
|
|
92
|
+
.active-collapsed {
|
|
92
93
|
background-color: #eaecff;
|
|
94
|
+
border-radius: 50%;
|
|
93
95
|
color: #472aff;
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
.active-collapsed
|
|
98
|
+
.active-collapsed:hover {
|
|
97
99
|
background-color: #eaecff;
|
|
98
100
|
cursor: default;
|
|
99
101
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type BaseMenu = {
|
|
2
|
+
text: string;
|
|
3
|
+
url: string;
|
|
4
|
+
};
|
|
5
|
+
export type MenuItem = BaseMenu & {
|
|
6
|
+
icon?: string;
|
|
7
|
+
};
|
|
8
|
+
export type HomeItem = BaseMenu & {
|
|
9
|
+
homeIcon?: string;
|
|
10
|
+
detail?: string;
|
|
11
|
+
};
|
|
12
|
+
export type MainMenu = HomeItem & {
|
|
13
|
+
icon?: string;
|
|
14
|
+
roles?: string[];
|
|
15
|
+
children?: SidebarItem[];
|
|
16
|
+
};
|
|
17
|
+
export interface SidebarItem {
|
|
18
|
+
category: string;
|
|
19
|
+
menuItems: MenuItem[];
|
|
20
|
+
}
|
|
21
|
+
export declare const getSidebarItemsFromMenu: (items: MainMenu[], url: string, excludedRoutes?: string[]) => SidebarItem[];
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const getSidebarItemsFromMenu = (items, url, excludedRoutes) => {
|
|
2
|
+
if (excludedRoutes?.includes(url))
|
|
3
|
+
return [];
|
|
4
|
+
const matchedPath = /^\/[^/]+/.exec(url);
|
|
5
|
+
const urlValue = matchedPath?.[0] ?? '';
|
|
6
|
+
return items.find((menu) => menu.url === urlValue)?.children ?? [];
|
|
7
|
+
};
|
package/dist/Menu/Sidebar.svelte
CHANGED
|
@@ -1,52 +1,62 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { page } from '$app/state';
|
|
2
3
|
import { fade } from 'svelte/transition';
|
|
3
|
-
|
|
4
|
+
|
|
4
5
|
import MenuItemSidebar from './MenuItem.svelte';
|
|
6
|
+
import type { MenuItem, SidebarItem } from './MenuState.svelte.js';
|
|
5
7
|
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
menuItems: MenuItem[];
|
|
8
|
+
interface Props {
|
|
9
|
+
sidebarItems: SidebarItem[];
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
let { sidebarItems
|
|
12
|
-
|
|
13
|
-
let
|
|
12
|
+
let { sidebarItems = [] }: Props = $props();
|
|
13
|
+
|
|
14
|
+
let hasItems: boolean = $derived(!!sidebarItems.length);
|
|
15
|
+
let isCollapsed: boolean = $state(true);
|
|
16
|
+
let selectedItem: MenuItem | undefined = $derived(
|
|
17
|
+
sidebarItems
|
|
18
|
+
.flatMap((item) => item.menuItems)
|
|
19
|
+
.find(
|
|
20
|
+
(menuItem) =>
|
|
21
|
+
page.url.pathname === menuItem.url || page.url.pathname.startsWith(menuItem.url + '/')
|
|
22
|
+
)
|
|
23
|
+
);
|
|
14
24
|
|
|
15
25
|
const toggleSidebar = () => {
|
|
16
26
|
isCollapsed = !isCollapsed;
|
|
17
27
|
};
|
|
18
28
|
</script>
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
<
|
|
28
|
-
<div class="menu">
|
|
29
|
-
<
|
|
30
|
+
{#if hasItems}
|
|
31
|
+
<aside
|
|
32
|
+
class={['side-menu', isCollapsed ? 'collapsed' : 'expanded']}
|
|
33
|
+
transition:fade|global={{ delay: 50, duration: 200 }}
|
|
34
|
+
>
|
|
35
|
+
<section class="menu-content">
|
|
36
|
+
<header class="header">
|
|
37
|
+
<section class="menu-header">
|
|
38
|
+
<div class="menu-title" class:hidden={isCollapsed}>
|
|
39
|
+
<div class="menu">
|
|
40
|
+
<h2 class="menu-span">Menu</h2>
|
|
41
|
+
</div>
|
|
30
42
|
</div>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</
|
|
37
|
-
</
|
|
38
|
-
</
|
|
39
|
-
</
|
|
40
|
-
</header>
|
|
43
|
+
<div class="category-items">
|
|
44
|
+
<button class="button" onclick={toggleSidebar}>
|
|
45
|
+
<span class="material-icons-outlined icon-span">
|
|
46
|
+
{isCollapsed ? 'menu' : 'menu_open'}
|
|
47
|
+
</span>
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
</section>
|
|
51
|
+
</header>
|
|
41
52
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{#each sidebarItems as element}
|
|
53
|
+
<section class="content">
|
|
54
|
+
{#each sidebarItems as item}
|
|
45
55
|
<section class="category-content">
|
|
46
|
-
<h2 class="category-span" class:hidden={isCollapsed}>{
|
|
56
|
+
<h2 class="category-span" class:hidden={isCollapsed}>{item.category}</h2>
|
|
47
57
|
<menu class="category-items-details">
|
|
48
|
-
{#if
|
|
49
|
-
{#each
|
|
58
|
+
{#if item.menuItems}
|
|
59
|
+
{#each item.menuItems as menuItem}
|
|
50
60
|
<MenuItemSidebar
|
|
51
61
|
item={menuItem}
|
|
52
62
|
{isCollapsed}
|
|
@@ -58,10 +68,10 @@
|
|
|
58
68
|
</menu>
|
|
59
69
|
</section>
|
|
60
70
|
{/each}
|
|
61
|
-
|
|
71
|
+
</section>
|
|
62
72
|
</section>
|
|
63
|
-
</
|
|
64
|
-
|
|
73
|
+
</aside>
|
|
74
|
+
{/if}
|
|
65
75
|
|
|
66
76
|
<style>
|
|
67
77
|
.side-menu {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
interface
|
|
3
|
-
|
|
4
|
-
menuItems: MenuItem[];
|
|
1
|
+
import type { SidebarItem } from './MenuState.svelte.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
sidebarItems: SidebarItem[];
|
|
5
4
|
}
|
|
6
|
-
|
|
7
|
-
sidebarItems: sidebarProps[];
|
|
8
|
-
};
|
|
9
|
-
declare const Sidebar: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
5
|
+
declare const Sidebar: import("svelte").Component<Props, {}, "">;
|
|
10
6
|
type Sidebar = ReturnType<typeof Sidebar>;
|
|
11
7
|
export default Sidebar;
|
package/dist/index.d.ts
CHANGED
|
@@ -41,11 +41,12 @@ import { addToast } from './Toast/toastState.svelte';
|
|
|
41
41
|
import { setFormContext, getFormContext } from './Form/FormController/context.js';
|
|
42
42
|
import { validateSchema } from './Form/FormController/helper.js';
|
|
43
43
|
import { createZodString } from './Form/FormController/zod-validations.js';
|
|
44
|
+
import { getSidebarItemsFromMenu } from './Menu/MenuState.svelte';
|
|
44
45
|
import type { BreadcrumbsNameMap } from './Breadcrumbs/breadcrumbsState.svelte.js';
|
|
45
46
|
import type { FormError, FormContext } from './Form/FormController/types.js';
|
|
46
47
|
import type { HighlightPanelColumn } from './HighlightPanel/highlightPanelState.svelte.js';
|
|
47
|
-
import type { HomeItem } from './
|
|
48
|
-
import type { MenuItem } from './Menu/
|
|
48
|
+
import type { HomeItem } from './Menu/MenuState.svelte.js';
|
|
49
|
+
import type { MainMenu, MenuItem, SidebarItem } from './Menu/MenuState.svelte.js';
|
|
49
50
|
import type { ModalProps } from './Modal/modalState.svelte.js';
|
|
50
51
|
import type { ProgressWizardStep } from './ProgressWizard/progressWizardState.svelte.js';
|
|
51
52
|
import type { SwitcherOption } from './Switcher/switcherState.svelte.js';
|
|
@@ -53,4 +54,4 @@ import type { SelectOption } from './Form/Select/selectState.svelte.js';
|
|
|
53
54
|
import type { Tab } from './Tabs/tabsState.svelte.js';
|
|
54
55
|
import type { Toast } from './Toast/toastState.svelte';
|
|
55
56
|
import type { WaffleItem } from './Waffle/waffleState.svelte.js';
|
|
56
|
-
export { Accordion, Avatar, Breadcrumbs, Button, Card, Chips, ErrorPage, Footer, Form, Header, HeaderAccount, HeaderLoader, HeaderLogo, HighlightPanel, Home, Input, Link, Menu, Modal, Notification, Processing, ProgressPage, ProgressWizard, Search, Select, Sidebar, Spinner, Switcher, Tabs, TextArea, Toaster, Toggle, Tooltip, Waffle, addBreadcrumbsNameMap, addToast, getProgressWizardContext, setProgressWizardStepsContext, setStepValidity, setFormContext, getFormContext, validateSchema, createZodString, ChipType, ColumnType, ImageType, type BreadcrumbsNameMap, type HighlightPanelColumn, type HomeItem, type MenuItem, type ModalProps, type ProgressWizardStep, type SelectOption, type SwitcherOption, type Tab, type Toast, type WaffleItem, type FormError, type FormContext };
|
|
57
|
+
export { Accordion, Avatar, Breadcrumbs, Button, Card, Chips, ErrorPage, Footer, Form, Header, HeaderAccount, HeaderLoader, HeaderLogo, HighlightPanel, Home, Input, Link, Menu, Modal, Notification, Processing, ProgressPage, ProgressWizard, Search, Select, Sidebar, Spinner, Switcher, Tabs, TextArea, Toaster, Toggle, Tooltip, Waffle, addBreadcrumbsNameMap, addToast, getProgressWizardContext, setProgressWizardStepsContext, setStepValidity, setFormContext, getFormContext, validateSchema, createZodString, getSidebarItemsFromMenu, ChipType, ColumnType, ImageType, type BreadcrumbsNameMap, type HighlightPanelColumn, type HomeItem, type MainMenu, type MenuItem, type ModalProps, type ProgressWizardStep, type SelectOption, type SwitcherOption, type Tab, type Toast, type WaffleItem, type FormError, type FormContext, type SidebarItem };
|
package/dist/index.js
CHANGED
|
@@ -43,10 +43,11 @@ import { addToast } from './Toast/toastState.svelte';
|
|
|
43
43
|
import { setFormContext, getFormContext } from './Form/FormController/context.js';
|
|
44
44
|
import { validateSchema } from './Form/FormController/helper.js';
|
|
45
45
|
import { createZodString } from './Form/FormController/zod-validations.js';
|
|
46
|
+
import { getSidebarItemsFromMenu } from './Menu/MenuState.svelte';
|
|
46
47
|
export {
|
|
47
48
|
// Components
|
|
48
49
|
Accordion, Avatar, Breadcrumbs, Button, Card, Chips, ErrorPage, Footer, Form, Header, HeaderAccount, HeaderLoader, HeaderLogo, HighlightPanel, Home, Input, Link, Menu, Modal, Notification, Processing, ProgressPage, ProgressWizard, Search, Select, Sidebar, Spinner, Switcher, Tabs, TextArea, Toaster, Toggle, Tooltip, Waffle,
|
|
49
50
|
// Functions and helpers
|
|
50
|
-
addBreadcrumbsNameMap, addToast, getProgressWizardContext, setProgressWizardStepsContext, setStepValidity, setFormContext, getFormContext, validateSchema, createZodString,
|
|
51
|
+
addBreadcrumbsNameMap, addToast, getProgressWizardContext, setProgressWizardStepsContext, setStepValidity, setFormContext, getFormContext, validateSchema, createZodString, getSidebarItemsFromMenu,
|
|
51
52
|
// Enums
|
|
52
53
|
ChipType, ColumnType, ImageType };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {} from '../index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|