@medyll/idae-machine 0.128.0 → 0.135.2
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/LICENSE +21 -21
- package/README.md +360 -393
- package/cli.js +46 -0
- package/dist/demo/dbSchema.d.ts +446 -0
- package/dist/demo/dbSchema.js +449 -0
- package/dist/demo/testScheme.d.ts +56 -0
- package/dist/demo/testScheme.js +42 -0
- package/dist/form/CreateUpdate.svelte +219 -0
- package/dist/{demo/form → form}/CreateUpdate.svelte.d.ts +5 -7
- package/dist/form/DataProvider.svelte +23 -0
- package/dist/form/DataProvider.svelte.d.ts +7 -0
- package/dist/form/FieldInPlace.svelte +98 -0
- package/dist/form/FieldInPlace.svelte.d.ts +14 -0
- package/dist/form/FieldValue.svelte +148 -0
- package/dist/{demo/form → form}/FieldValue.svelte.d.ts +8 -9
- package/dist/fragments/Confirm.svelte +73 -58
- package/dist/fragments/Confirm.svelte.d.ts +4 -8
- package/dist/fragments/Frame.svelte +19 -19
- package/dist/fragments/InfoLine.svelte +21 -21
- package/dist/fragments/Selector.svelte +26 -26
- package/dist/fragments/Skeleton.svelte +21 -21
- package/dist/index.d.ts +20 -28
- package/dist/index.js +20 -28
- package/dist/main/machine/MachineError.d.ts +33 -0
- package/dist/main/machine/MachineError.js +49 -0
- package/dist/main/machine/MachineErrorValidation.d.ts +19 -0
- package/dist/main/machine/MachineErrorValidation.js +24 -0
- package/dist/main/machine/MachineFieldType.d.ts +121 -0
- package/dist/main/machine/MachineFieldType.js +250 -0
- package/dist/main/machine/MachineScheme.d.ts +84 -0
- package/dist/main/machine/MachineScheme.js +146 -0
- package/dist/main/machine/MachineSchemeField.d.ts +19 -0
- package/dist/main/machine/MachineSchemeField.js +51 -0
- package/dist/main/machine/MachineSchemeFieldForge.d.ts +84 -0
- package/dist/main/machine/MachineSchemeFieldForge.js +128 -0
- package/dist/main/machine/MachineSchemeFieldValues.d.ts +69 -0
- package/dist/main/machine/MachineSchemeFieldValues.js +94 -0
- package/dist/main/machine/MachineSchemeValidate.d.ts +51 -0
- package/dist/main/machine/MachineSchemeValidate.js +120 -0
- package/dist/main/machine/MachineSchemeValues.d.ts +109 -0
- package/dist/main/machine/{IDbCollectionValues.js → MachineSchemeValues.js} +116 -41
- package/dist/main/machine/SchemeFieldDefaultValues.d.ts +74 -0
- package/dist/main/machine/SchemeFieldDefaultValues.js +98 -0
- package/dist/main/machine.d.ts +71 -44
- package/dist/main/machine.js +74 -43
- package/dist/main/machineDb.d.ts +14 -56
- package/dist/main/machineDb.js +15 -98
- package/dist/main/{machineForge.d.ts → machineParserForge.d.ts} +15 -25
- package/dist/main/{machineForge.js → machineParserForge.js} +16 -10
- package/dist/ui/CollectionButton.svelte +29 -26
- package/dist/ui/CollectionButton.svelte.d.ts +3 -3
- package/dist/ui/CollectionFks.svelte +24 -24
- package/dist/ui/CollectionFks.svelte.d.ts +2 -2
- package/dist/ui/CollectionList.svelte +100 -95
- package/dist/ui/CollectionList.svelte.d.ts +1 -2
- package/dist/ui/CollectionListFieldValues.svelte +59 -0
- package/dist/ui/CollectionListFieldValues.svelte.d.ts +9 -0
- package/dist/ui/CollectionListMenu.svelte +39 -47
- package/dist/ui/CollectionListMenu.svelte.d.ts +1 -1
- package/dist/ui/CollectionReverseFks.svelte +37 -56
- package/dist/ui/CollectionReverseFks.svelte.d.ts +4 -8
- package/package.json +18 -5
- package/dist/db/dbSchema.d.ts +0 -201
- package/dist/db/dbSchema.js +0 -205
- package/dist/db/fieldTypes.d.ts +0 -13
- package/dist/db/fieldTypes.js +0 -67
- package/dist/db/types.d.ts +0 -124
- package/dist/demo/form/CreateUpdate.svelte +0 -198
- package/dist/demo/form/CrudZone.svelte +0 -22
- package/dist/demo/form/CrudZone.svelte.d.ts +0 -29
- package/dist/demo/form/DataProvider.svelte +0 -20
- package/dist/demo/form/DataProvider.svelte.d.ts +0 -9
- package/dist/demo/form/FieldInPlace.svelte +0 -49
- package/dist/demo/form/FieldInPlace.svelte.d.ts +0 -11
- package/dist/demo/form/FieldValue.svelte +0 -212
- package/dist/demo/form/types.js +0 -1
- package/dist/demo/testDbSchema.d.ts +0 -6
- package/dist/demo/testDbSchema.js +0 -58
- package/dist/demo/types.d.ts +0 -140
- package/dist/demo/types.js +0 -1
- package/dist/fragments/List.svelte +0 -21
- package/dist/fragments/List.svelte.d.ts +0 -38
- package/dist/main/machine/IDbCollection.d.ts +0 -71
- package/dist/main/machine/IDbCollection.js +0 -102
- package/dist/main/machine/IDbCollectionFieldForge.d.ts +0 -42
- package/dist/main/machine/IDbCollectionFieldForge.js +0 -74
- package/dist/main/machine/IDbCollectionFieldValues.d.ts +0 -57
- package/dist/main/machine/IDbCollectionFieldValues.js +0 -82
- package/dist/main/machine/IDbCollectionValues.d.ts +0 -78
- package/dist/main/machine/IDbError.d.ts +0 -6
- package/dist/main/machine/IDbError.js +0 -61
- package/dist/main/machine/IDbFormValidate.d.ts +0 -55
- package/dist/main/machine/IDbFormValidate.js +0 -183
- package/dist/main/machine/IDbValidationError.d.ts +0 -19
- package/dist/main/machine/IDbValidationError.js +0 -24
- package/dist/main/machine/types.d.ts +0 -1
- package/dist/main/machine/types.js +0 -1
- package/dist/ui/CollectionFieldGuess.svelte +0 -29
- package/dist/ui/CollectionFieldGuess.svelte.d.ts +0 -11
- /package/dist/{demo/form → form}/types.d.ts +0 -0
- /package/dist/{db → form}/types.js +0 -0
|
@@ -1,95 +1,100 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
<!--
|
|
2
|
+
CollectionList.svelte
|
|
3
|
+
Svelte 5 collection list with Looper
|
|
4
|
+
@role ui-list
|
|
5
|
+
@prop {string} collection - Collection name
|
|
6
|
+
@prop {object} [data] - Data object
|
|
7
|
+
@prop {object} [menuListProps] - Menu props
|
|
8
|
+
@prop {string} [target] - HTML target
|
|
9
|
+
@prop {string} [style] - Custom style
|
|
10
|
+
@prop {object} [where] - Query filter
|
|
11
|
+
@prop {string} [displayMode] - Display mode
|
|
12
|
+
@slot children (let:item) - Custom item rendering
|
|
13
|
+
@slot loopTitle - Custom title rendering
|
|
14
|
+
@event click - Emitted on item click
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<script lang="ts" generics="COL = Record<string,any>">
|
|
19
|
+
import {
|
|
20
|
+
type MenuListProps,
|
|
21
|
+
Looper
|
|
22
|
+
} from '@medyll/idae-slotui-svelte';
|
|
23
|
+
import CreateUpdate from '../form/CreateUpdate.svelte';
|
|
24
|
+
import { hydrate } from 'svelte';
|
|
25
|
+
import type { Where } from '@medyll/idae-idbql';
|
|
26
|
+
import { machine } from '../main/machine.js';
|
|
27
|
+
import CollectionListFieldValues from './CollectionListFieldValues.svelte';
|
|
28
|
+
|
|
29
|
+
interface CollectionListProps {
|
|
30
|
+
collection: string;
|
|
31
|
+
target?: string;
|
|
32
|
+
data?: COL;
|
|
33
|
+
menuListProps?: MenuListProps;
|
|
34
|
+
style?: string;
|
|
35
|
+
displayMode?: 'line' | 'grid';
|
|
36
|
+
where?: Where<COL>;
|
|
37
|
+
children?: any;
|
|
38
|
+
onclick?: (data: COL, index: number | string) => void;
|
|
39
|
+
}
|
|
40
|
+
let {
|
|
41
|
+
collection,
|
|
42
|
+
target,
|
|
43
|
+
onclick,
|
|
44
|
+
where,
|
|
45
|
+
children: _children,
|
|
46
|
+
} = $props<CollectionListProps>();
|
|
47
|
+
|
|
48
|
+
let logic = machine.logic;
|
|
49
|
+
let store = machine.store;
|
|
50
|
+
let fieldValues = $derived(logic.collection(collection).collectionValues);
|
|
51
|
+
let index = $derived(logic.collection(collection).template.index);
|
|
52
|
+
let query = $derived(where ? store[collection].where(where) : store[collection]?.getAll());
|
|
53
|
+
|
|
54
|
+
$inspect('CollectionList', { collection, query });
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
function load(event: CustomEvent, indexV: number | string) {
|
|
59
|
+
openCrud(event[index]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function openCrud(id: any) {
|
|
63
|
+
// mount on target, returns component
|
|
64
|
+
let mounted = hydrate(CreateUpdate, {
|
|
65
|
+
target: document.querySelector(`[data-target-zone="${target}"]`),
|
|
66
|
+
props: { collection: collection, dataId: id, mode: 'show' }
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return mounted;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const _onclick = (data: COL, index: number | string) => {
|
|
73
|
+
console.log('onclick', data, index);
|
|
74
|
+
|
|
75
|
+
if (onclick) {
|
|
76
|
+
onclick(data, index);
|
|
77
|
+
} else {
|
|
78
|
+
load(data, index);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
<div class="grid grid-cols-3 gap-3 p-3">
|
|
86
|
+
<Looper data={query}>
|
|
87
|
+
{#snippet loopTitle()}
|
|
88
|
+
<!-- Default: nothing -->
|
|
89
|
+
{/snippet}
|
|
90
|
+
{#snippet children({item, idx})}
|
|
91
|
+
<div class="flex aspect-square flex-col rounded-2xl border border-gray-300 p-2">
|
|
92
|
+
<CollectionListFieldValues
|
|
93
|
+
collection={collection}
|
|
94
|
+
data={item}
|
|
95
|
+
mode="show"
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
{/snippet}
|
|
99
|
+
</Looper>
|
|
100
|
+
</div>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type MenuListProps } from '@medyll/idae-slotui-svelte';
|
|
2
|
-
import { type Snippet } from 'svelte';
|
|
3
2
|
import type { Where } from '@medyll/idae-idbql';
|
|
4
3
|
declare function $$render<COL = Record<string, any>>(): {
|
|
5
4
|
props: {
|
|
@@ -10,7 +9,7 @@ declare function $$render<COL = Record<string, any>>(): {
|
|
|
10
9
|
style?: string;
|
|
11
10
|
displayMode?: "line" | "grid";
|
|
12
11
|
where?: Where<COL>;
|
|
13
|
-
children?:
|
|
12
|
+
children?: any;
|
|
14
13
|
onclick?: (data: COL, index: number | string) => void;
|
|
15
14
|
};
|
|
16
15
|
exports: {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* @component
|
|
4
|
+
* Iterates over a collection's fields and renders a FieldValue for each.
|
|
5
|
+
* Supports filtering via `showFields` and dynamic discovery via `scheme` or `data`.
|
|
6
|
+
*/
|
|
7
|
+
import FieldValue from "../form/FieldValue.svelte";
|
|
8
|
+
import { machine } from "../main/machine.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} Props
|
|
12
|
+
* @property {string} collection - The name of the collection being rendered.
|
|
13
|
+
* @property {Record<string, any>} data - The data object for the fields (bindable).
|
|
14
|
+
* @property {"show" | "edit"} [mode="show"] - Display mode of the fields.
|
|
15
|
+
* @property {MachineScheme} [scheme] - The machine scheme defining field metadata.
|
|
16
|
+
* @property {string[]} [showFields] - Optional whitelist of field names to display.
|
|
17
|
+
*/
|
|
18
|
+
let {
|
|
19
|
+
collection,
|
|
20
|
+
data = $bindable(),
|
|
21
|
+
mode = "show",
|
|
22
|
+
showFields
|
|
23
|
+
} = $props<{
|
|
24
|
+
collection: string;
|
|
25
|
+
data: Record<string, any>;
|
|
26
|
+
mode?: "show" | "edit";
|
|
27
|
+
showFields?: string[];
|
|
28
|
+
}>();
|
|
29
|
+
|
|
30
|
+
// Svelte 5: $derived must be called as a function in template
|
|
31
|
+
const scheme = $derived(machine.logic.collection(collection));
|
|
32
|
+
const fieldNames = $derived(() => {
|
|
33
|
+
const fields = scheme?.template?.fields;
|
|
34
|
+
if (fields) {
|
|
35
|
+
let keys = Object.keys(fields);
|
|
36
|
+
if (showFields && Array.isArray(showFields)) {
|
|
37
|
+
return keys.filter((key) => showFields.includes(key));
|
|
38
|
+
}
|
|
39
|
+
return keys;
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Map 'edit' to 'update' for FieldValue
|
|
45
|
+
const fieldMode = $derived(() => mode === 'edit' ? 'update' : mode);
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
{#if scheme && fieldNames()?.length}
|
|
49
|
+
{#each fieldNames() as fieldName}
|
|
50
|
+
{#if scheme.template?.fields && scheme.template.fields[fieldName]}
|
|
51
|
+
<FieldValue
|
|
52
|
+
{collection}
|
|
53
|
+
{fieldName}
|
|
54
|
+
bind:data={data}
|
|
55
|
+
mode={fieldMode()}
|
|
56
|
+
/>
|
|
57
|
+
{/if}
|
|
58
|
+
{/each}
|
|
59
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
collection: string;
|
|
3
|
+
data: Record<string, any>;
|
|
4
|
+
mode?: "show" | "edit";
|
|
5
|
+
showFields?: string[];
|
|
6
|
+
};
|
|
7
|
+
declare const CollectionListFieldValues: import("svelte").Component<$$ComponentProps, {}, "data">;
|
|
8
|
+
type CollectionListFieldValues = ReturnType<typeof CollectionListFieldValues>;
|
|
9
|
+
export default CollectionListFieldValues;
|
|
@@ -1,47 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let { collection, target, data, menuListProps, onclick, style, where }
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<MenuList {style} onclick={onclick ?? load} data={qy} {...menuListProps}>
|
|
44
|
-
{#snippet children({ item })}
|
|
45
|
-
<MenuListItem data={item}>{fieldValues.presentation(item)}</MenuListItem>
|
|
46
|
-
{/snippet}
|
|
47
|
-
</MenuList>
|
|
1
|
+
<!--
|
|
2
|
+
CollectionListMenu.svelte
|
|
3
|
+
Svelte 5 menu list for a collection
|
|
4
|
+
@role ui-menu
|
|
5
|
+
@prop {string} collection - Collection name
|
|
6
|
+
@prop {object} [data] - Data object
|
|
7
|
+
@prop {object} [menuListProps] - Menu props
|
|
8
|
+
@prop {string} [target] - HTML target
|
|
9
|
+
@prop {string} [style] - Custom style
|
|
10
|
+
@prop {object} [where] - Query filter
|
|
11
|
+
@slot children (let:item) - Custom menu item rendering
|
|
12
|
+
@event click - Emitted on item click
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
<script lang="ts" generics="COL = Record<string,any>">
|
|
16
|
+
import { type MenuListProps, MenuList, MenuListItem } from '@medyll/idae-slotui-svelte';
|
|
17
|
+
import CreateUpdate from '../form/CreateUpdate.svelte';
|
|
18
|
+
import { hydrate } from 'svelte';
|
|
19
|
+
import type { Where } from '@medyll/idae-idbql';
|
|
20
|
+
let { collection, target, data, menuListProps, onclick, style, where } = $props<{ collection: string; target?: string; data?: COL[]; menuListProps?: MenuListProps; style?: string; where?: Where<COL>; onclick?: (event: CustomEvent, index: number) => void }>();
|
|
21
|
+
// If data is provided, use it directly. Otherwise, expect parent to provide data via prop or slot.
|
|
22
|
+
let items = data ?? [];
|
|
23
|
+
function load(event: CustomEvent, indexV: number) {
|
|
24
|
+
openCrud(event[index]);
|
|
25
|
+
}
|
|
26
|
+
function openCrud(id: any) {
|
|
27
|
+
let mounted = hydrate(CreateUpdate, {
|
|
28
|
+
target: document.querySelector(`[data-target-zone="${target}"]`),
|
|
29
|
+
props: { collection, dataId: id, mode: 'update' }
|
|
30
|
+
});
|
|
31
|
+
return mounted;
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<MenuList {style} onclick={onclick ?? load} data={items} {...menuListProps}>
|
|
36
|
+
{#snippet children(item)}
|
|
37
|
+
<MenuListItem data={item}>{item && item.name ? item.name : ''}</MenuListItem>
|
|
38
|
+
{/snippet}
|
|
39
|
+
</MenuList>
|
|
@@ -1,56 +1,37 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
showTitle
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return showTitle ? `Related ${collection}` : '';
|
|
39
|
-
}
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<Looper data={Object.entries(fks)}>
|
|
43
|
-
{#snippet children({ item })}
|
|
44
|
-
{#if showTitle}
|
|
45
|
-
<div class="p2 font-bold">{item?.[0]}</div>
|
|
46
|
-
{/if}
|
|
47
|
-
{#if component}
|
|
48
|
-
<svelte:component this={component} collection={item[0]} template={item[1]} {...componentProps} />
|
|
49
|
-
{:else}
|
|
50
|
-
{@render child({
|
|
51
|
-
collection: item[0],
|
|
52
|
-
template: item[1]
|
|
53
|
-
})}
|
|
54
|
-
{/if}
|
|
55
|
-
{/snippet}
|
|
56
|
-
</Looper>
|
|
1
|
+
<!--
|
|
2
|
+
CollectionReverseFks.svelte
|
|
3
|
+
Svelte 5 reverse FK relation viewer for a collection
|
|
4
|
+
@role ui-fragment
|
|
5
|
+
@prop {string} collection - Collection name
|
|
6
|
+
@prop {any} [collectionId] - Optional collection id
|
|
7
|
+
@prop {object} [where] - Optional filter
|
|
8
|
+
@prop {boolean|string} [showTitle] - Show or override title
|
|
9
|
+
@prop {typeof SvelteComponent} [component] - Custom component
|
|
10
|
+
@prop {object} [componentProps] - Props for custom component
|
|
11
|
+
@slot children (let:collection, let:template) - Custom reverse FK rendering
|
|
12
|
+
-->
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import type { Tpl, TplCollectionName, Where } from '@medyll/idae-idbql';
|
|
15
|
+
import { Looper } from '@medyll/idae-slotui-svelte';
|
|
16
|
+
import type { SvelteComponent } from 'svelte';
|
|
17
|
+
import { machine } from '../main/machine.js';
|
|
18
|
+
let { collection, showTitle = false, component, componentProps = {}, children: child } = $props<{ collection: TplCollectionName; collectionId?: any; where?: Where; showTitle?: boolean | string; component?: typeof SvelteComponent; componentProps?: Record<string, any>; children?: any }>();
|
|
19
|
+
const reverseFks = $derived(machine.logic.collection(collection).parseReverseFks());
|
|
20
|
+
function getTitle() {
|
|
21
|
+
if (typeof showTitle === 'string') return showTitle;
|
|
22
|
+
return showTitle ? `Related ${collection}` : '';
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Looper data={Object.entries(reverseFks)}>
|
|
27
|
+
{#snippet children(collection, template)}
|
|
28
|
+
{#if showTitle}
|
|
29
|
+
<div class="p2 font-bold">{collection}</div>
|
|
30
|
+
{/if}
|
|
31
|
+
{#if component}
|
|
32
|
+
<svelte:component this={component} collection={collection} template={template} {...componentProps} />
|
|
33
|
+
{:else}
|
|
34
|
+
{@render child(collection, template)}
|
|
35
|
+
{/if}
|
|
36
|
+
{/snippet}
|
|
37
|
+
</Looper>
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
type CollectionFksProps = {
|
|
2
|
+
import type { TplCollectionName, Where } from '@medyll/idae-idbql';
|
|
3
|
+
type $$ComponentProps = {
|
|
5
4
|
collection: TplCollectionName;
|
|
6
5
|
collectionId?: any;
|
|
7
6
|
where?: Where;
|
|
8
|
-
children: Snippet<[{
|
|
9
|
-
collection: string;
|
|
10
|
-
template: Tpl;
|
|
11
|
-
}]>;
|
|
12
7
|
showTitle?: boolean | string;
|
|
13
8
|
component?: typeof SvelteComponent;
|
|
14
9
|
componentProps?: Record<string, any>;
|
|
10
|
+
children?: any;
|
|
15
11
|
};
|
|
16
|
-
declare const CollectionReverseFks: import("svelte").Component
|
|
12
|
+
declare const CollectionReverseFks: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
17
13
|
type CollectionReverseFks = ReturnType<typeof CollectionReverseFks>;
|
|
18
14
|
export default CollectionReverseFks;
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medyll/idae-machine",
|
|
3
|
-
"
|
|
3
|
+
"bin": {
|
|
4
|
+
"idae-machine": "./cli.js"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.135.2",
|
|
4
7
|
"files": [
|
|
5
8
|
"dist",
|
|
6
9
|
"!dist/**/*.test.*",
|
|
@@ -12,6 +15,11 @@
|
|
|
12
15
|
"svelte": "./dist/index.js",
|
|
13
16
|
"types": "./dist/index.d.ts",
|
|
14
17
|
"type": "module",
|
|
18
|
+
"author": "Lebrun Meddy",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/medyll/idae.git"
|
|
22
|
+
},
|
|
15
23
|
"exports": {
|
|
16
24
|
".": {
|
|
17
25
|
"types": "./dist/index.d.ts",
|
|
@@ -21,9 +29,14 @@
|
|
|
21
29
|
"peerDependencies": {
|
|
22
30
|
"svelte": "^5.0.0"
|
|
23
31
|
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"directory": "."
|
|
35
|
+
},
|
|
24
36
|
"devDependencies": {
|
|
25
37
|
"@eslint/compat": "^1.2.7",
|
|
26
38
|
"@eslint/js": "^9.23.0",
|
|
39
|
+
"@semantic-release/github": "^10.3.5",
|
|
27
40
|
"@sveltejs/adapter-auto": "^5.0.0",
|
|
28
41
|
"@sveltejs/kit": "^2.20.2",
|
|
29
42
|
"@sveltejs/package": "^2.3.10",
|
|
@@ -44,13 +57,13 @@
|
|
|
44
57
|
"typescript-eslint": "^8.28.0",
|
|
45
58
|
"vite": "^6.2.3",
|
|
46
59
|
"vitest": "^3.0.9",
|
|
47
|
-
"@medyll/idae-
|
|
60
|
+
"@medyll/idae-eslint-config": "0.1.5"
|
|
48
61
|
},
|
|
49
62
|
"scope": "@medyll",
|
|
50
63
|
"dependencies": {
|
|
51
64
|
"@huggingface/prettier-plugin-vertical-align": "^0.2.3",
|
|
52
|
-
"@medyll/idae-slotui-svelte": "0.181.
|
|
53
|
-
"@medyll/idae-idbql": "0.
|
|
65
|
+
"@medyll/idae-slotui-svelte": "0.181.4",
|
|
66
|
+
"@medyll/idae-idbql": "0.185.2"
|
|
54
67
|
},
|
|
55
68
|
"scripts": {
|
|
56
69
|
"dev": "vite dev",
|
|
@@ -62,6 +75,6 @@
|
|
|
62
75
|
"lint": "prettier --check . && eslint .",
|
|
63
76
|
"test:unit": "vitest",
|
|
64
77
|
"test": "npm run test:unit -- --run",
|
|
65
|
-
"
|
|
78
|
+
"prepackage": "node scripts/package-pre.js"
|
|
66
79
|
}
|
|
67
80
|
}
|