@medyll/idae-machine 0.87.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/README.md +230 -0
- package/dist/db/dataModel.d.ts +23 -0
- package/dist/db/dataModel.js +40 -0
- package/dist/db/dbFields.d.ts +130 -0
- package/dist/db/dbFields.js +606 -0
- package/dist/db/dbSchema.d.ts +456 -0
- package/dist/db/dbSchema.js +456 -0
- package/dist/form/CollectionButton.svelte +26 -0
- package/dist/form/CollectionButton.svelte.d.ts +22 -0
- package/dist/form/CollectionFieldGuess.svelte +29 -0
- package/dist/form/CollectionFieldGuess.svelte.d.ts +11 -0
- package/dist/form/CollectionFks.svelte +24 -0
- package/dist/form/CollectionFks.svelte.d.ts +9 -0
- package/dist/form/CollectionList.svelte +93 -0
- package/dist/form/CollectionList.svelte.d.ts +30 -0
- package/dist/form/CollectionListMenu.svelte +46 -0
- package/dist/form/CollectionListMenu.svelte.d.ts +27 -0
- package/dist/form/CollectionReverseFks.svelte +56 -0
- package/dist/form/CollectionReverseFks.svelte.d.ts +18 -0
- package/dist/form/CreateUpdate.svelte +191 -0
- package/dist/form/CreateUpdate.svelte.d.ts +20 -0
- package/dist/form/CrudZone.svelte +23 -0
- package/dist/form/CrudZone.svelte.d.ts +22 -0
- package/dist/form/DataProvider.svelte +20 -0
- package/dist/form/DataProvider.svelte.d.ts +9 -0
- package/dist/form/FieldInPlace.svelte +49 -0
- package/dist/form/FieldInPlace.svelte.d.ts +11 -0
- package/dist/form/FieldValue.svelte +213 -0
- package/dist/form/FieldValue.svelte.d.ts +28 -0
- package/dist/form/types.d.ts +17 -0
- package/dist/form/types.js +1 -0
- package/dist/fragments/Confirm.svelte +58 -0
- package/dist/fragments/Confirm.svelte.d.ts +11 -0
- package/dist/fragments/Frame.svelte +19 -0
- package/dist/fragments/Frame.svelte.d.ts +32 -0
- package/dist/fragments/InfoLine.svelte +21 -0
- package/dist/fragments/InfoLine.svelte.d.ts +35 -0
- package/dist/fragments/List.svelte +21 -0
- package/dist/fragments/List.svelte.d.ts +38 -0
- package/dist/fragments/Selector.svelte +26 -0
- package/dist/fragments/Selector.svelte.d.ts +38 -0
- package/dist/fragments/Skeleton.svelte +21 -0
- package/dist/fragments/Skeleton.svelte.d.ts +20 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +23 -0
- package/dist/types/appschemeTypes.d.ts +71 -0
- package/dist/types/appschemeTypes.js +83 -0
- package/package.json +63 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type MenuListProps } from '@medyll/idae-slotui-svelte';
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
import type { Where } from '@medyll/idae-idbql';
|
|
4
|
+
declare class __sveltets_Render<COL = Record<string, any>> {
|
|
5
|
+
props(): {
|
|
6
|
+
collection: string;
|
|
7
|
+
target?: string;
|
|
8
|
+
data?: COL | undefined;
|
|
9
|
+
menuListProps?: MenuListProps;
|
|
10
|
+
style?: string;
|
|
11
|
+
displayMode?: "line" | "grid";
|
|
12
|
+
where?: Where<COL> | undefined;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
onclick?: ((data: COL, index: number | string) => void) | undefined;
|
|
15
|
+
};
|
|
16
|
+
events(): {};
|
|
17
|
+
slots(): {};
|
|
18
|
+
bindings(): "";
|
|
19
|
+
exports(): {};
|
|
20
|
+
}
|
|
21
|
+
interface $$IsomorphicComponent {
|
|
22
|
+
new <COL = Record<string, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<COL>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<COL>['props']>, ReturnType<__sveltets_Render<COL>['events']>, ReturnType<__sveltets_Render<COL>['slots']>> & {
|
|
23
|
+
$$bindings?: ReturnType<__sveltets_Render<COL>['bindings']>;
|
|
24
|
+
} & ReturnType<__sveltets_Render<COL>['exports']>;
|
|
25
|
+
<COL = Record<string, any>>(internal: unknown, props: ReturnType<__sveltets_Render<COL>['props']> & {}): ReturnType<__sveltets_Render<COL>['exports']>;
|
|
26
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
27
|
+
}
|
|
28
|
+
declare const CollectionList: $$IsomorphicComponent;
|
|
29
|
+
type CollectionList<COL = Record<string, any>> = InstanceType<typeof CollectionList<COL>>;
|
|
30
|
+
export default CollectionList;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts" generics="COL = Record<string,any>">
|
|
2
|
+
import { type MenuListProps, Button, MenuList, MenuListItem, openWindow, type Props } from '@medyll/idae-slotui-svelte';
|
|
3
|
+
import CreateUpdate from '$components/form/CreateUpdate.svelte';
|
|
4
|
+
import { idbqlState } from '../db/dbSchema';
|
|
5
|
+
import { IDbCollections, IDbCollectionValues } from '../db/dbFields';
|
|
6
|
+
import { hydrate } from 'svelte';
|
|
7
|
+
import type { Where } from '@medyll/idae-idbql';
|
|
8
|
+
|
|
9
|
+
interface DataListMenuProps {
|
|
10
|
+
collection: string;
|
|
11
|
+
target?: string; // html target
|
|
12
|
+
data?: COL;
|
|
13
|
+
menuListProps?: MenuListProps;
|
|
14
|
+
style?: string;
|
|
15
|
+
where?: Where<COL>;
|
|
16
|
+
onclick?: (event: CustomEvent, index: number) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let { collection, target, data, menuListProps, onclick, style, where }: DataListMenuProps = $props();
|
|
20
|
+
|
|
21
|
+
let test = new IDbCollections();
|
|
22
|
+
let fieldValues = new IDbCollectionValues(collection);
|
|
23
|
+
let index = test.getIndexName(collection);
|
|
24
|
+
|
|
25
|
+
let qy = $derived(where ? idbqlState[collection].where(where) : idbqlState[collection].getAll());
|
|
26
|
+
|
|
27
|
+
function load(event: CustomEvent, indexV: number) {
|
|
28
|
+
openCrud(event[index]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function openCrud(id: any) {
|
|
32
|
+
// mount on target, returns component
|
|
33
|
+
let mounted = hydrate(CreateUpdate, {
|
|
34
|
+
target: document.querySelector(`[data-target-zone="${target}"]`),
|
|
35
|
+
props: { collection: collection, dataId: id, mode: 'update' }
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return mounted;
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<MenuList {style} onclick={onclick ?? load} data={qy} {...menuListProps}>
|
|
43
|
+
{#snippet children({ item })}
|
|
44
|
+
<MenuListItem data={item}>{fieldValues.presentation(item)}</MenuListItem>
|
|
45
|
+
{/snippet}
|
|
46
|
+
</MenuList>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type MenuListProps } from '@medyll/idae-slotui-svelte';
|
|
2
|
+
import type { Where } from '@medyll/idae-idbql';
|
|
3
|
+
declare class __sveltets_Render<COL = Record<string, any>> {
|
|
4
|
+
props(): {
|
|
5
|
+
collection: string;
|
|
6
|
+
target?: string;
|
|
7
|
+
data?: COL | undefined;
|
|
8
|
+
menuListProps?: MenuListProps;
|
|
9
|
+
style?: string;
|
|
10
|
+
where?: Where<COL> | undefined;
|
|
11
|
+
onclick?: ((event: CustomEvent, index: number) => void) | undefined;
|
|
12
|
+
};
|
|
13
|
+
events(): {};
|
|
14
|
+
slots(): {};
|
|
15
|
+
bindings(): "";
|
|
16
|
+
exports(): {};
|
|
17
|
+
}
|
|
18
|
+
interface $$IsomorphicComponent {
|
|
19
|
+
new <COL = Record<string, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<COL>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<COL>['props']>, ReturnType<__sveltets_Render<COL>['events']>, ReturnType<__sveltets_Render<COL>['slots']>> & {
|
|
20
|
+
$$bindings?: ReturnType<__sveltets_Render<COL>['bindings']>;
|
|
21
|
+
} & ReturnType<__sveltets_Render<COL>['exports']>;
|
|
22
|
+
<COL = Record<string, any>>(internal: unknown, props: ReturnType<__sveltets_Render<COL>['props']> & {}): ReturnType<__sveltets_Render<COL>['exports']>;
|
|
23
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
24
|
+
}
|
|
25
|
+
declare const CollectionListMenu: $$IsomorphicComponent;
|
|
26
|
+
type CollectionListMenu<COL = Record<string, any>> = InstanceType<typeof CollectionListMenu<COL>>;
|
|
27
|
+
export default CollectionListMenu;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Component CollectionReverseFks.svelte : to display a list of reverse foreign keys for a specific collection.
|
|
3
|
+
D:\boulot\python\wollama\src\components\form\CollectionReverseFks.svelte
|
|
4
|
+
|
|
5
|
+
(alias) type Tpl<T = TplCollectionFields> = {
|
|
6
|
+
index: string;
|
|
7
|
+
presentation: string | number | symbol;
|
|
8
|
+
fields: { [K in keyof T]: TplFieldRules; };
|
|
9
|
+
fks: { [K in TplCollectionName]?: {
|
|
10
|
+
code: K;
|
|
11
|
+
multiple: boolean;
|
|
12
|
+
rules: CombinedArgs;
|
|
13
|
+
}; };
|
|
14
|
+
}
|
|
15
|
+
-->
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import { IDbCollections } from '../db/dbFields';
|
|
18
|
+
import { schemeModel, idbqlState } from '../db/dbSchema';
|
|
19
|
+
import type { Tpl, TplCollectionName, Where } from '@medyll/idae-idbql';
|
|
20
|
+
import { Looper } from '@medyll/idae-slotui-svelte';
|
|
21
|
+
import type { Snippet, SvelteComponent } from 'svelte';
|
|
22
|
+
|
|
23
|
+
type CollectionFksProps = {
|
|
24
|
+
collection: TplCollectionName;
|
|
25
|
+
collectionId?: any;
|
|
26
|
+
where?: Where;
|
|
27
|
+
children: Snippet<[{ collection: string; template: Tpl }]>;
|
|
28
|
+
showTitle?: boolean | string;
|
|
29
|
+
component?: typeof SvelteComponent;
|
|
30
|
+
componentProps?: Record<string, any>;
|
|
31
|
+
};
|
|
32
|
+
let { collection, children: child, showTitle = false, component, componentProps = {} }: CollectionFksProps = $props();
|
|
33
|
+
const dbFields = new IDbCollections(schemeModel);
|
|
34
|
+
const fks = $derived(dbFields.reverseFks(collection));
|
|
35
|
+
|
|
36
|
+
function getTitle() {
|
|
37
|
+
if (typeof showTitle === 'string') return showTitle;
|
|
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>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Tpl, TplCollectionName, Where } from '@medyll/idae-idbql';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
type CollectionFksProps = {
|
|
5
|
+
collection: TplCollectionName;
|
|
6
|
+
collectionId?: any;
|
|
7
|
+
where?: Where;
|
|
8
|
+
children: Snippet<[{
|
|
9
|
+
collection: string;
|
|
10
|
+
template: Tpl;
|
|
11
|
+
}]>;
|
|
12
|
+
showTitle?: boolean | string;
|
|
13
|
+
component?: typeof SvelteComponent;
|
|
14
|
+
componentProps?: Record<string, any>;
|
|
15
|
+
};
|
|
16
|
+
declare const CollectionReverseFks: import("svelte").Component<CollectionFksProps, {}, "">;
|
|
17
|
+
type CollectionReverseFks = ReturnType<typeof CollectionReverseFks>;
|
|
18
|
+
export default CollectionReverseFks;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Component CreateUpdate : to open a CreateUpdateShow window for a specific collection.
|
|
3
|
+
Button validate and cancel is in the Window component.
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<script lang="ts" generics="COL = Record<string,any>">
|
|
7
|
+
import { IDbCollections as DbFields, IDbFormValidate } from '../db/dbFields';
|
|
8
|
+
import { idbql, idbqlState, schemeModel } from '../db/dbSchema';
|
|
9
|
+
import type { CreateUpdateProps } from './types';
|
|
10
|
+
import CollectionReverseFks from './CollectionReverseFks.svelte';
|
|
11
|
+
import FieldInput from './FieldValue.svelte';
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
collection,
|
|
15
|
+
data = {},
|
|
16
|
+
dataId,
|
|
17
|
+
mode = 'show',
|
|
18
|
+
withData,
|
|
19
|
+
showFields,
|
|
20
|
+
inPlaceEdit,
|
|
21
|
+
displayMode = 'wrap',
|
|
22
|
+
afterCreate,
|
|
23
|
+
showFks = false
|
|
24
|
+
}: CreateUpdateProps = $props();
|
|
25
|
+
let inputForm = `form-${String(collection)}-${mode}`;
|
|
26
|
+
let dbFields = new DbFields(schemeModel);
|
|
27
|
+
let indexName = dbFields.getIndexName(collection);
|
|
28
|
+
let formFields = showFields
|
|
29
|
+
? Object.fromEntries(
|
|
30
|
+
Object.entries(dbFields.parseRawCollection(collection) ?? {}).filter(([key]) => showFields.includes(key))
|
|
31
|
+
)
|
|
32
|
+
: (dbFields.parseRawCollection(collection) ?? {});
|
|
33
|
+
|
|
34
|
+
let qy: any = $derived(dataId && indexName ? idbqlState[collection].where({ [indexName]: { eq: dataId } }) : {});
|
|
35
|
+
|
|
36
|
+
let formData = $state<Record<string, any>>({ ...data, ...withData, ...$state.snapshot(qy)[0] });
|
|
37
|
+
|
|
38
|
+
$effect.pre(() => {
|
|
39
|
+
setFormDataDefaultFieldValues();
|
|
40
|
+
});
|
|
41
|
+
let ds = Object.keys(data).length > 0 ? data : qy[0];
|
|
42
|
+
|
|
43
|
+
let formValidator = new IDbFormValidate(collection);
|
|
44
|
+
let validationErrors: Record<string, string> = {};
|
|
45
|
+
|
|
46
|
+
const validateFormData = (formData: Record<string, any> = {}) => {
|
|
47
|
+
const { isValid, errors } = formValidator.validateForm(formData, {
|
|
48
|
+
ignoreFields: mode == 'create' ? [indexName] : undefined
|
|
49
|
+
});
|
|
50
|
+
validationErrors = errors;
|
|
51
|
+
|
|
52
|
+
return isValid;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const submit = async (event: FormDataEvent) => {
|
|
56
|
+
if (!validateFormData($state.snapshot(formData))) {
|
|
57
|
+
Object.entries(validationErrors).forEach(([fieldName, errorMessage]) => {
|
|
58
|
+
// Trouver l'élément input correspondant dans le formulaire
|
|
59
|
+
const inputElement = document.querySelector(
|
|
60
|
+
`[name="${fieldName}"][form="${inputForm}"]`
|
|
61
|
+
) as HTMLInputElement | null;
|
|
62
|
+
console.log({ inputElement });
|
|
63
|
+
|
|
64
|
+
if (inputElement) {
|
|
65
|
+
// Ajouter une classe d'erreur à l'élément input
|
|
66
|
+
inputElement.classList.add('input-error');
|
|
67
|
+
|
|
68
|
+
// Créer ou mettre à jour un message d'erreur
|
|
69
|
+
let errorElement = inputElement.nextElementSibling as HTMLElement;
|
|
70
|
+
if (!errorElement || !errorElement.classList.contains('error-message')) {
|
|
71
|
+
errorElement = document.createElement('div');
|
|
72
|
+
errorElement.classList.add('error-message');
|
|
73
|
+
inputElement.parentNode?.insertBefore(errorElement, inputElement.nextSibling);
|
|
74
|
+
}
|
|
75
|
+
errorElement.textContent = errorMessage;
|
|
76
|
+
|
|
77
|
+
// Optionnel : Ajouter un attribut aria pour l'accessibilité
|
|
78
|
+
inputElement.setAttribute('aria-invalid', 'true');
|
|
79
|
+
inputElement.setAttribute('aria-describedby', `error-${fieldName}`);
|
|
80
|
+
errorElement.id = `error-${fieldName}`;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
let datadb = $state.snapshot(formData);
|
|
86
|
+
switch (mode) {
|
|
87
|
+
case 'create':
|
|
88
|
+
if (!dataId) {
|
|
89
|
+
await idbql[collection].add({ ...datadb, ...withData });
|
|
90
|
+
mode = 'show';
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case 'update':
|
|
94
|
+
if (dataId) {
|
|
95
|
+
await idbqlState[collection].update(dataId, datadb);
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
function setFormDataDefaultFieldValues() {
|
|
102
|
+
Object.entries(formFields).forEach(([fieldName, field]) => {
|
|
103
|
+
if (formData[fieldName] === undefined && getDefaultValue(field?.fieldType)) {
|
|
104
|
+
formData[fieldName] = getDefaultValue(field?.fieldType);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// déplacer qqpart ?
|
|
110
|
+
function getDefaultValue(fieldType?: string) {
|
|
111
|
+
if (mode !== 'create') return undefined;
|
|
112
|
+
switch (fieldType) {
|
|
113
|
+
case 'timestamp':
|
|
114
|
+
return Date.now();
|
|
115
|
+
case 'date':
|
|
116
|
+
return new Date().toISOString().split('T')[0];
|
|
117
|
+
case 'datetime':
|
|
118
|
+
return new Date().toISOString();
|
|
119
|
+
case 'time':
|
|
120
|
+
return new Date().toISOString().split('T')[1].split('.')[0];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<form
|
|
126
|
+
id={inputForm}
|
|
127
|
+
name={inputForm}
|
|
128
|
+
onchange={(event) => {
|
|
129
|
+
console.log('Form changed', event);
|
|
130
|
+
}}
|
|
131
|
+
onsubmit={(event) => {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
// onSubmit(event);
|
|
134
|
+
}}
|
|
135
|
+
></form>
|
|
136
|
+
|
|
137
|
+
<div style="width:750px;display:flex;">
|
|
138
|
+
<div class="crud {displayMode}">
|
|
139
|
+
{#each Object.entries(formFields) as [fieldName, fieldInfo]}
|
|
140
|
+
<FieldInput
|
|
141
|
+
{collection}
|
|
142
|
+
{fieldName}
|
|
143
|
+
{mode}
|
|
144
|
+
editInPlace={inPlaceEdit === true || (Array.isArray(inPlaceEdit) && inPlaceEdit.includes(fieldName))}
|
|
145
|
+
bind:data={formData}
|
|
146
|
+
{inputForm}
|
|
147
|
+
/>
|
|
148
|
+
{/each}
|
|
149
|
+
</div>
|
|
150
|
+
{#if showFks && (mode === 'show' || mode === 'update')}
|
|
151
|
+
<div>
|
|
152
|
+
<CollectionReverseFks showTitle={true} {collection} collectionId={dataId}>
|
|
153
|
+
{#snippet children({ collection, template })}
|
|
154
|
+
<div class="p2">presentation</div>
|
|
155
|
+
{/snippet}
|
|
156
|
+
</CollectionReverseFks>
|
|
157
|
+
</div>
|
|
158
|
+
{/if}
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<style>
|
|
162
|
+
@reference "../../styles/references.css";
|
|
163
|
+
|
|
164
|
+
:global(.crud) {
|
|
165
|
+
min-width: 32rem;
|
|
166
|
+
padding: 2rem;
|
|
167
|
+
|
|
168
|
+
&.wrap {
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-wrap: wrap;
|
|
171
|
+
gap: 0.5rem;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&.inline {
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-direction: row;
|
|
177
|
+
gap: 1rem;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
[aria-invalid='true'] {
|
|
182
|
+
background-color: #ffeeee;
|
|
183
|
+
border-color: red;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.error-message {
|
|
187
|
+
color: red;
|
|
188
|
+
font-size: 0.8em;
|
|
189
|
+
margin-top: 0.2em;
|
|
190
|
+
}
|
|
191
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CreateUpdateProps } from './types';
|
|
2
|
+
declare class __sveltets_Render<COL = Record<string, any>> {
|
|
3
|
+
props(): CreateUpdateProps<string>;
|
|
4
|
+
events(): {};
|
|
5
|
+
slots(): {};
|
|
6
|
+
bindings(): "";
|
|
7
|
+
exports(): {
|
|
8
|
+
submit: (event: FormDataEvent) => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface $$IsomorphicComponent {
|
|
12
|
+
new <COL = Record<string, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<COL>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<COL>['props']>, ReturnType<__sveltets_Render<COL>['events']>, ReturnType<__sveltets_Render<COL>['slots']>> & {
|
|
13
|
+
$$bindings?: ReturnType<__sveltets_Render<COL>['bindings']>;
|
|
14
|
+
} & ReturnType<__sveltets_Render<COL>['exports']>;
|
|
15
|
+
<COL = Record<string, any>>(internal: unknown, props: ReturnType<__sveltets_Render<COL>['props']> & {}): ReturnType<__sveltets_Render<COL>['exports']>;
|
|
16
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
17
|
+
}
|
|
18
|
+
declare const CreateUpdate: $$IsomorphicComponent;
|
|
19
|
+
type CreateUpdate<COL = Record<string, any>> = InstanceType<typeof CreateUpdate<COL>>;
|
|
20
|
+
export default CreateUpdate;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts" generics="T = Record<string, any>">
|
|
2
|
+
import { Button, openWindow, type Props } from '@medyll/idae-slotui-svelte';
|
|
3
|
+
import CreateUpdate from '$components/form/CreateUpdate.svelte';
|
|
4
|
+
import { idbqlState } from '../db/dbSchema';
|
|
5
|
+
import CrudDataList from './DataListMenu.svelte';
|
|
6
|
+
|
|
7
|
+
interface CrudZoneProps {
|
|
8
|
+
collection: string;
|
|
9
|
+
data?: Record<string, any>;
|
|
10
|
+
style?: ElementCSSInlineStyle;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let { collection, style }: CrudZoneProps = $props();
|
|
14
|
+
|
|
15
|
+
let qy = idbqlState[collection].getAll();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div style="max-height:100%;height:350px;min-width:750px; {style}" class="flex border">
|
|
19
|
+
<div class="w-48 border">
|
|
20
|
+
<CrudDataList {collection} target="red" />
|
|
21
|
+
</div>
|
|
22
|
+
<div data-target-zone="red">ss</div>
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface CrudZoneProps {
|
|
2
|
+
collection: string;
|
|
3
|
+
data?: Record<string, any>;
|
|
4
|
+
style?: ElementCSSInlineStyle;
|
|
5
|
+
}
|
|
6
|
+
declare class __sveltets_Render<T = Record<string, any>> {
|
|
7
|
+
props(): CrudZoneProps;
|
|
8
|
+
events(): {};
|
|
9
|
+
slots(): {};
|
|
10
|
+
bindings(): "";
|
|
11
|
+
exports(): {};
|
|
12
|
+
}
|
|
13
|
+
interface $$IsomorphicComponent {
|
|
14
|
+
new <T = Record<string, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
15
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
16
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
17
|
+
<T = Record<string, any>>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
18
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
19
|
+
}
|
|
20
|
+
declare const CrudZone: $$IsomorphicComponent;
|
|
21
|
+
type CrudZone<T = Record<string, any>> = InstanceType<typeof CrudZone<T>>;
|
|
22
|
+
export default CrudZone;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { setContext } from 'svelte';
|
|
4
|
+
|
|
5
|
+
interface PROPS {
|
|
6
|
+
collection: string;
|
|
7
|
+
data: Record<string, any>[];
|
|
8
|
+
children: Snippet;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { collection, children, data = $bindable() }: PROPS = $props();
|
|
12
|
+
let _data = $derived(data);
|
|
13
|
+
|
|
14
|
+
setContext('collection', collection);
|
|
15
|
+
|
|
16
|
+
setContext('data', data);
|
|
17
|
+
$inspect('data.provider', _data); // Corrected to reference others.data directly
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
{@render children?.()}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface PROPS {
|
|
3
|
+
collection: string;
|
|
4
|
+
data: Record<string, any>[];
|
|
5
|
+
children: Snippet;
|
|
6
|
+
}
|
|
7
|
+
declare const DataProvider: import("svelte").Component<PROPS, {}, "data">;
|
|
8
|
+
type DataProvider = ReturnType<typeof DataProvider>;
|
|
9
|
+
export default DataProvider;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon } from '@medyll/idae-slotui-svelte';
|
|
3
|
+
|
|
4
|
+
interface FieldInPProps {
|
|
5
|
+
collection: string;
|
|
6
|
+
field: string;
|
|
7
|
+
validate: Function;
|
|
8
|
+
message?: string | undefined;
|
|
9
|
+
initial?: import('svelte').Snippet;
|
|
10
|
+
children?: import('svelte').Snippet;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let { validate, message = undefined, initial, children }: FieldInPProps = $props();
|
|
14
|
+
|
|
15
|
+
let status = $state('default');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div class="line-gap-2 w-full">
|
|
19
|
+
{@render initial?.()}
|
|
20
|
+
{#if status === 'default'}
|
|
21
|
+
<button
|
|
22
|
+
class="line-gap-2"
|
|
23
|
+
hidden={status !== 'default'}
|
|
24
|
+
onclick={() => {
|
|
25
|
+
status = 'show_confirm';
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{@render children?.()}
|
|
29
|
+
</button>
|
|
30
|
+
{/if}
|
|
31
|
+
{#if status === 'show_confirm'}
|
|
32
|
+
<button
|
|
33
|
+
onclick={() => {
|
|
34
|
+
validate?.();
|
|
35
|
+
status = 'default';
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{message ?? ''}
|
|
39
|
+
<Icon class="color-success md text-green-800" icon="mdi:done" />
|
|
40
|
+
</button>
|
|
41
|
+
<button
|
|
42
|
+
onclick={() => {
|
|
43
|
+
status = 'default';
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<Icon icon="typcn:cancel" style="color: red" class="md fill-red-800 " />
|
|
47
|
+
</button>
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface FieldInPProps {
|
|
2
|
+
collection: string;
|
|
3
|
+
field: string;
|
|
4
|
+
validate: Function;
|
|
5
|
+
message?: string | undefined;
|
|
6
|
+
initial?: import('svelte').Snippet;
|
|
7
|
+
children?: import('svelte').Snippet;
|
|
8
|
+
}
|
|
9
|
+
declare const FieldInPlace: import("svelte").Component<FieldInPProps, {}, "">;
|
|
10
|
+
type FieldInPlace = ReturnType<typeof FieldInPlace>;
|
|
11
|
+
export default FieldInPlace;
|