@rkosafo/cai.components 0.0.30 → 0.0.32
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/keycloak/types.d.ts +5 -5
- package/dist/layout/ComponentCanvas/Canvas.svelte +40 -0
- package/dist/layout/ComponentCanvas/Canvas.svelte.d.ts +4 -0
- package/dist/layout/ComponentCanvas/ComponentRenderer.svelte +85 -0
- package/dist/layout/ComponentCanvas/ComponentRenderer.svelte.d.ts +6 -0
- package/dist/layout/ComponentCanvas/index.d.ts +2 -0
- package/dist/layout/ComponentCanvas/index.js +2 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +17 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from './ui/tab/index.js';
|
|
|
25
25
|
export * from './ui/icons/index.js';
|
|
26
26
|
export * from './ui/box/index.js';
|
|
27
27
|
export * from './ui/breadcrumb/index.js';
|
|
28
|
+
export * from './layout/ComponentCanvas/index.js';
|
|
28
29
|
export * from './forms/input/index.js';
|
|
29
30
|
export * from './forms/label/index.js';
|
|
30
31
|
export * from './forms/datepicker/index.js';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from './ui/tab/index.js';
|
|
|
26
26
|
export * from './ui/icons/index.js';
|
|
27
27
|
export * from './ui/box/index.js';
|
|
28
28
|
export * from './ui/breadcrumb/index.js';
|
|
29
|
+
export * from './layout/ComponentCanvas/index.js';
|
|
29
30
|
export * from './forms/input/index.js';
|
|
30
31
|
export * from './forms/label/index.js';
|
|
31
32
|
export * from './forms/datepicker/index.js';
|
package/dist/keycloak/types.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export interface AuthUserInfo {
|
|
2
|
-
id: string;
|
|
3
|
-
email: string;
|
|
4
2
|
firstName: string;
|
|
5
3
|
lastName: string;
|
|
6
|
-
otherNames: string;
|
|
7
4
|
name: string;
|
|
8
|
-
username: string;
|
|
9
5
|
initials: string;
|
|
10
6
|
profileImage: string;
|
|
11
7
|
role: string;
|
|
12
8
|
roleId: number;
|
|
13
9
|
permissions: string[];
|
|
14
|
-
|
|
10
|
+
otherNames?: string;
|
|
11
|
+
status?: string;
|
|
12
|
+
username?: string;
|
|
13
|
+
id?: string | number;
|
|
14
|
+
email?: string;
|
|
15
15
|
department?: string;
|
|
16
16
|
departmentId?: number;
|
|
17
17
|
tags?: string[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { receive, type IComponentDescriptor, type IDocumentCanvasProps } from '../../index.js';
|
|
3
|
+
import { nanoid } from 'nanoid';
|
|
4
|
+
import ComponentRenderer from './ComponentRenderer.svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children = [],
|
|
8
|
+
close,
|
|
9
|
+
contextKey,
|
|
10
|
+
toggleCollapse,
|
|
11
|
+
showBackground
|
|
12
|
+
}: IDocumentCanvasProps = $props();
|
|
13
|
+
|
|
14
|
+
function updateChildren(children: IComponentDescriptor[]) {
|
|
15
|
+
return children.map((a) => {
|
|
16
|
+
if (!a.id) a.id = nanoid();
|
|
17
|
+
return a;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let toRender = $derived(updateChildren(children));
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div class="flex flex-grow flex-col gap-5">
|
|
25
|
+
{#each toRender as child (child.id)}
|
|
26
|
+
<div
|
|
27
|
+
class="flex p-3"
|
|
28
|
+
class:shadow={showBackground}
|
|
29
|
+
class:bg-white={showBackground}
|
|
30
|
+
in:receive={{ key: child.id }}
|
|
31
|
+
>
|
|
32
|
+
<ComponentRenderer descriptor={child} {contextKey} {close} {toggleCollapse} />
|
|
33
|
+
</div>
|
|
34
|
+
{/each}
|
|
35
|
+
{#if toRender.length === 0}
|
|
36
|
+
<!-- <Alert>
|
|
37
|
+
It is lonely here
|
|
38
|
+
</Alert> -->
|
|
39
|
+
{/if}
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
let mappers: ((name: string) => ConstructorOfATypedSvelteComponent)[] = [];
|
|
3
|
+
function componentNameToType(name: string) {
|
|
4
|
+
for (let i = 0; i < mappers.length; i++) {
|
|
5
|
+
let cmp = mappers[i](name);
|
|
6
|
+
if (cmp != null) return cmp;
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function addMapper(f: (name: string) => ConstructorOfATypedSvelteComponent) {
|
|
12
|
+
mappers = [f, ...mappers];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function removeMapper(f: (name: string) => ConstructorOfATypedSvelteComponent) {
|
|
16
|
+
mappers = mappers.filter((x) => x != f);
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import {
|
|
22
|
+
IconifyIcon,
|
|
23
|
+
type IComponentDescriptor,
|
|
24
|
+
type IDocumentRendererProps
|
|
25
|
+
} from '../../index.js';
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
descriptor,
|
|
29
|
+
showTitle = true,
|
|
30
|
+
contextKey,
|
|
31
|
+
toggleCollapse,
|
|
32
|
+
close
|
|
33
|
+
}: IDocumentRendererProps = $props();
|
|
34
|
+
|
|
35
|
+
function decode(descriptor: IComponentDescriptor) {
|
|
36
|
+
return {
|
|
37
|
+
compoent: componentNameToType(descriptor.type),
|
|
38
|
+
props: descriptor.props || {}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let data = $derived(decode(descriptor));
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
{#if data.compoent}
|
|
46
|
+
<div class="flex-grow">
|
|
47
|
+
{#if descriptor.title && showTitle}
|
|
48
|
+
<div class="flex items-center justify-between border-b border-dotted pb-1">
|
|
49
|
+
<h3 class="font-bold text-teal-500">
|
|
50
|
+
{descriptor.title || ''}
|
|
51
|
+
</h3>
|
|
52
|
+
<div class="flex items-center gap-2">
|
|
53
|
+
<button
|
|
54
|
+
aria-label="collapse"
|
|
55
|
+
onclick={(_) => toggleCollapse(descriptor.id!)}
|
|
56
|
+
class="grid place-content-center rounded-full p-1 hover:bg-gray-200"
|
|
57
|
+
class:hidden={!descriptor.collapsible}
|
|
58
|
+
>
|
|
59
|
+
<IconifyIcon
|
|
60
|
+
icon={descriptor.collapsed
|
|
61
|
+
? 'iconamoon:arrow-down-2-duotone'
|
|
62
|
+
: 'iconamoon:arrow-up-2-duotone'}
|
|
63
|
+
style="font-size: 20px;"
|
|
64
|
+
/>
|
|
65
|
+
</button>
|
|
66
|
+
<button
|
|
67
|
+
aria-label="close"
|
|
68
|
+
onclick={(e) => close({ id: descriptor.id!, data: e.detail })}
|
|
69
|
+
class="grid place-content-center rounded-full p-1 hover:bg-red-200 hover:text-red-400"
|
|
70
|
+
class:hidden={!descriptor.closable}
|
|
71
|
+
>
|
|
72
|
+
<iconify-icon icon="ic:round-close" style="font-size: 20px;"></iconify-icon>
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
{/if}
|
|
77
|
+
<div class:hidden={descriptor.collapsed}>
|
|
78
|
+
<data.compoent
|
|
79
|
+
{...data.props}
|
|
80
|
+
{contextKey}
|
|
81
|
+
close={(e: any) => close({ id: descriptor.id!, data: e.detail })}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
{/if}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function addMapper(f: (name: string) => ConstructorOfATypedSvelteComponent): void;
|
|
2
|
+
export declare function removeMapper(f: (name: string) => ConstructorOfATypedSvelteComponent): void;
|
|
3
|
+
import { type IDocumentRendererProps } from '../../index.js';
|
|
4
|
+
declare const ComponentRenderer: import("svelte").Component<IDocumentRendererProps, {}, "">;
|
|
5
|
+
type ComponentRenderer = ReturnType<typeof ComponentRenderer>;
|
|
6
|
+
export default ComponentRenderer;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -823,3 +823,30 @@ export interface ActionButtonProps {
|
|
|
823
823
|
kind?: keyof typeof ACTION_BUTTON_KINDS;
|
|
824
824
|
moreShadow?: boolean;
|
|
825
825
|
}
|
|
826
|
+
export interface IComponentDescriptor {
|
|
827
|
+
type: string;
|
|
828
|
+
title?: string;
|
|
829
|
+
collapsible?: boolean;
|
|
830
|
+
collapsed?: boolean;
|
|
831
|
+
closable?: boolean;
|
|
832
|
+
props?: unknown;
|
|
833
|
+
id?: string;
|
|
834
|
+
}
|
|
835
|
+
export interface IDocumentCanvasClose {
|
|
836
|
+
id: string;
|
|
837
|
+
data: any;
|
|
838
|
+
}
|
|
839
|
+
export interface IDocumentRendererProps {
|
|
840
|
+
descriptor: IComponentDescriptor;
|
|
841
|
+
showTitle?: boolean;
|
|
842
|
+
contextKey?: object;
|
|
843
|
+
toggleCollapse: (id: string) => void;
|
|
844
|
+
close: (val: IDocumentCanvasClose) => void;
|
|
845
|
+
}
|
|
846
|
+
export interface IDocumentCanvasProps {
|
|
847
|
+
children: IComponentDescriptor[];
|
|
848
|
+
showBackground?: boolean;
|
|
849
|
+
contextKey?: object;
|
|
850
|
+
close: (val: IDocumentCanvasClose) => void;
|
|
851
|
+
toggleCollapse: (id: string) => void;
|
|
852
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -6,3 +6,8 @@ export declare function cn(...inputs: ClassValue[]): string;
|
|
|
6
6
|
export declare function saveToLocalStorage<T>(key: string, data: T): void;
|
|
7
7
|
export declare function loadFromLocalStorage<T>(key: string): T | undefined;
|
|
8
8
|
export declare function extractQueryParam(queryString: string, index?: string): string;
|
|
9
|
+
export declare const send: (node: any, params: import("svelte/transition").CrossfadeParams & {
|
|
10
|
+
key: any;
|
|
11
|
+
}) => () => import("svelte/transition").TransitionConfig, receive: (node: any, params: import("svelte/transition").CrossfadeParams & {
|
|
12
|
+
key: any;
|
|
13
|
+
}) => () => import("svelte/transition").TransitionConfig;
|
package/dist/utils/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { browser } from '$app/environment';
|
|
2
2
|
import clsx, {} from 'clsx';
|
|
3
|
+
import { quintOut } from 'svelte/easing';
|
|
4
|
+
import { crossfade } from 'svelte/transition';
|
|
3
5
|
import { twMerge } from 'tailwind-merge';
|
|
4
6
|
export { default as Popper } from './Popper.svelte';
|
|
5
7
|
export * from './closeButton/index.js';
|
|
@@ -33,3 +35,18 @@ export function extractQueryParam(queryString, index = 'q') {
|
|
|
33
35
|
const warehouse = urlParams.get(index);
|
|
34
36
|
return warehouse ?? '';
|
|
35
37
|
}
|
|
38
|
+
export const [send, receive] = crossfade({
|
|
39
|
+
duration: (d) => Math.sqrt(d * 200),
|
|
40
|
+
fallback(node, params) {
|
|
41
|
+
const style = getComputedStyle(node);
|
|
42
|
+
const transform = style.transform === 'none' ? '' : style.transform;
|
|
43
|
+
return {
|
|
44
|
+
duration: 600,
|
|
45
|
+
easing: quintOut,
|
|
46
|
+
css: (t) => `
|
|
47
|
+
transform: ${transform} translateX(${(1 - t) * 100}%);
|
|
48
|
+
opacity: ${t}
|
|
49
|
+
`
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|