firstly 0.2.1 → 0.4.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/CHANGELOG.md +65 -0
- package/esm/SqlDatabase/FF_LogToConsole.js +9 -14
- package/esm/carbone/CarboneController.js +2 -1
- package/esm/changeLog/index.d.ts +0 -10
- package/esm/{internals → core}/BaseEnum.d.ts +1 -1
- package/esm/core/FF_Entity.js +5 -0
- package/esm/core/helper.d.ts +2 -0
- package/esm/core/helper.js +3 -0
- package/esm/core/index.d.ts +0 -0
- package/esm/core/index.js +5 -0
- package/esm/core/tailwind.d.ts +21 -0
- package/esm/core/tailwind.js +22 -0
- package/esm/core/tryCatch.d.ts +44 -0
- package/esm/core/tryCatch.js +34 -0
- package/esm/cron/server/index.js +1 -1
- package/esm/feedback/FeedbackController.js +3 -2
- package/esm/feedback/index.d.ts +7 -2
- package/esm/feedback/index.js +1 -2
- package/esm/feedback/server/index.d.ts +0 -5
- package/esm/feedback/server/index.js +1 -1
- package/esm/formats/strings.js +2 -2
- package/esm/index.d.ts +16 -0
- package/esm/index.js +13 -0
- package/esm/svelte/FF_Repo.svelte.d.ts +9 -2
- package/esm/svelte/FF_Repo.svelte.js +40 -17
- package/esm/svelte/class/SP.svelte.js +14 -2
- package/esm/svelte/helpers/debounce.js +1 -1
- package/esm/svelte/index.d.ts +2 -24
- package/esm/svelte/index.js +2 -22
- package/esm/{ui → svelte/ui}/Icon.svelte +1 -1
- package/esm/virtual/StateDemoEnum.d.ts +3 -3
- package/esm/virtual/StateDemoEnum.js +3 -3
- package/esm/virtual/UIEntity.js +1 -2
- package/package.json +8 -39
- package/esm/auth/AuthController.d.ts +0 -58
- package/esm/auth/AuthController.js +0 -114
- package/esm/auth/Entities.d.ts +0 -47
- package/esm/auth/Entities.js +0 -182
- package/esm/auth/README.md +0 -3
- package/esm/auth/index.d.ts +0 -5
- package/esm/auth/index.js +0 -5
- package/esm/auth/server/AuthController.server.d.ts +0 -58
- package/esm/auth/server/AuthController.server.js +0 -518
- package/esm/auth/server/handleAuth.d.ts +0 -4
- package/esm/auth/server/handleAuth.js +0 -142
- package/esm/auth/server/handleGuard.d.ts +0 -22
- package/esm/auth/server/handleGuard.js +0 -34
- package/esm/auth/server/helperDb.d.ts +0 -10
- package/esm/auth/server/helperDb.js +0 -56
- package/esm/auth/server/helperFirstly.d.ts +0 -1
- package/esm/auth/server/helperFirstly.js +0 -9
- package/esm/auth/server/helperOslo.d.ts +0 -7
- package/esm/auth/server/helperOslo.js +0 -24
- package/esm/auth/server/helperRemultServer.d.ts +0 -5
- package/esm/auth/server/helperRemultServer.js +0 -44
- package/esm/auth/server/helperRole.d.ts +0 -19
- package/esm/auth/server/helperRole.js +0 -57
- package/esm/auth/server/index.d.ts +0 -8
- package/esm/auth/server/index.js +0 -8
- package/esm/auth/server/module.d.ts +0 -300
- package/esm/auth/server/module.js +0 -230
- package/esm/auth/server/providers/github.d.ts +0 -33
- package/esm/auth/server/providers/github.js +0 -87
- package/esm/auth/server/providers/helperProvider.d.ts +0 -1
- package/esm/auth/server/providers/helperProvider.js +0 -25
- package/esm/auth/static/assets/Page-BHW08QWz.css +0 -1
- package/esm/auth/static/assets/Page-BRNWcY5Z.d.ts +0 -2
- package/esm/auth/static/assets/Page-BRNWcY5Z.js +0 -1
- package/esm/auth/static/assets/Page-CFcEsGK8.d.ts +0 -2
- package/esm/auth/static/assets/Page-CFcEsGK8.js +0 -7
- package/esm/auth/static/assets/Page-tLVs5slF.d.ts +0 -2
- package/esm/auth/static/assets/Page-tLVs5slF.js +0 -1
- package/esm/auth/static/assets/index-D38rqu4x.d.ts +0 -201
- package/esm/auth/static/assets/index-D38rqu4x.js +0 -2
- package/esm/auth/static/assets/index-DKWpA6v7.css +0 -4
- package/esm/auth/static/favicon.svg +0 -79
- package/esm/auth/static/index.html +0 -13
- package/esm/auth/types.d.ts +0 -73
- package/esm/bin/cmd.d.ts +0 -1
- package/esm/bin/cmd.js +0 -793
- package/esm/feedback/ui/DialogIssue.svelte +0 -149
- package/esm/feedback/ui/DialogIssue.svelte.d.ts +0 -22
- package/esm/feedback/ui/DialogIssues.svelte +0 -114
- package/esm/feedback/ui/DialogIssues.svelte.d.ts +0 -22
- package/esm/feedback/ui/DialogMilestones.svelte +0 -43
- package/esm/feedback/ui/DialogMilestones.svelte.d.ts +0 -20
- package/esm/feedback/ui/Feedback.svelte +0 -16
- package/esm/feedback/ui/Feedback.svelte.d.ts +0 -18
- package/esm/internals/FF_Entity.d.ts +0 -2
- package/esm/internals/FF_Entity.js +0 -21
- package/esm/internals/FF_Fields.d.ts +0 -11
- package/esm/internals/FF_Fields.js +0 -144
- package/esm/internals/cellsBuildor.d.ts +0 -47
- package/esm/internals/cellsBuildor.js +0 -140
- package/esm/internals/helper.d.ts +0 -49
- package/esm/internals/helper.js +0 -162
- package/esm/internals/index.d.ts +0 -82
- package/esm/internals/index.js +0 -45
- package/esm/internals/storeItem.d.ts +0 -28
- package/esm/internals/storeItem.js +0 -176
- package/esm/internals/storeList.d.ts +0 -34
- package/esm/internals/storeList.js +0 -108
- package/esm/internals/theme.d.ts +0 -4
- package/esm/internals/theme.js +0 -4
- package/esm/server/index.d.ts +0 -52
- package/esm/server/index.js +0 -87
- package/esm/svelte/FF_Cell.svelte +0 -103
- package/esm/svelte/FF_Cell.svelte.d.ts +0 -33
- package/esm/svelte/FF_Cell_Caption.svelte +0 -20
- package/esm/svelte/FF_Cell_Caption.svelte.d.ts +0 -31
- package/esm/svelte/FF_Cell_Display.svelte +0 -61
- package/esm/svelte/FF_Cell_Display.svelte.d.ts +0 -29
- package/esm/svelte/FF_Cell_Edit.svelte +0 -104
- package/esm/svelte/FF_Cell_Edit.svelte.d.ts +0 -32
- package/esm/svelte/FF_Cell_Error.svelte +0 -20
- package/esm/svelte/FF_Cell_Error.svelte.d.ts +0 -31
- package/esm/svelte/FF_Cell_Hint.svelte +0 -20
- package/esm/svelte/FF_Cell_Hint.svelte.d.ts +0 -31
- package/esm/svelte/FF_Config.svelte +0 -29
- package/esm/svelte/FF_Config.svelte.d.ts +0 -9
- package/esm/svelte/FF_Form.svelte +0 -155
- package/esm/svelte/FF_Form.svelte.d.ts +0 -37
- package/esm/svelte/FF_Grid.svelte +0 -257
- package/esm/svelte/FF_Grid.svelte.d.ts +0 -37
- package/esm/svelte/FF_Layout.svelte +0 -62
- package/esm/svelte/FF_Layout.svelte.d.ts +0 -31
- package/esm/svelte/actions/intersection.d.ts +0 -6
- package/esm/svelte/actions/intersection.js +0 -17
- package/esm/svelte/customField.d.ts +0 -69
- package/esm/svelte/customField.js +0 -4
- package/esm/svelte/dialog/DialogManagement.svelte +0 -98
- package/esm/svelte/dialog/DialogManagement.svelte.d.ts +0 -18
- package/esm/svelte/dialog/DialogPrimitive.svelte +0 -156
- package/esm/svelte/dialog/DialogPrimitive.svelte.d.ts +0 -38
- package/esm/svelte/dialog/dialog.d.ts +0 -58
- package/esm/svelte/dialog/dialog.js +0 -130
- package/esm/svelte/ff_Config.svelte.d.ts +0 -91
- package/esm/svelte/ff_Config.svelte.js +0 -111
- package/esm/svelte/firstly.css +0 -14
- package/esm/svelte/helpers.d.ts +0 -30
- package/esm/svelte/helpers.js +0 -38
- package/esm/svelte/tryCatch.d.ts +0 -12
- package/esm/svelte/tryCatch.js +0 -18
- package/esm/sveltekit/server/index.d.ts +0 -5
- package/esm/sveltekit/server/index.js +0 -24
- package/esm/ui/Button.svelte +0 -138
- package/esm/ui/Button.svelte.d.ts +0 -13
- package/esm/ui/Clipboardable.svelte +0 -25
- package/esm/ui/Clipboardable.svelte.d.ts +0 -12
- package/esm/ui/Field.svelte +0 -382
- package/esm/ui/Field.svelte.d.ts +0 -40
- package/esm/ui/FieldGroup.svelte +0 -117
- package/esm/ui/FieldGroup.svelte.d.ts +0 -44
- package/esm/ui/Grid.svelte +0 -265
- package/esm/ui/Grid.svelte.d.ts +0 -57
- package/esm/ui/Grid2.svelte +0 -293
- package/esm/ui/Grid2.svelte.d.ts +0 -57
- package/esm/ui/GridLoading.svelte +0 -58
- package/esm/ui/GridLoading.svelte.d.ts +0 -23
- package/esm/ui/GridPaginate.svelte +0 -69
- package/esm/ui/GridPaginate.svelte.d.ts +0 -23
- package/esm/ui/GridPaginate2.svelte +0 -25
- package/esm/ui/GridPaginate2.svelte.d.ts +0 -7
- package/esm/ui/Loading.svelte +0 -16
- package/esm/ui/Loading.svelte.d.ts +0 -31
- package/esm/ui/Tooltip.svelte +0 -45
- package/esm/ui/Tooltip.svelte.d.ts +0 -32
- package/esm/ui/dialog/DialogForm.svelte +0 -76
- package/esm/ui/dialog/DialogForm.svelte.d.ts +0 -21
- package/esm/ui/dialog/DialogManagement.svelte +0 -96
- package/esm/ui/dialog/DialogManagement.svelte.d.ts +0 -26
- package/esm/ui/dialog/DialogPrimitive.svelte +0 -90
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +0 -38
- package/esm/ui/dialog/FormEditAction.svelte +0 -62
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +0 -31
- package/esm/ui/dialog/dialog.d.ts +0 -60
- package/esm/ui/dialog/dialog.js +0 -100
- package/esm/ui/index.d.ts +0 -6
- package/esm/ui/index.js +0 -20
- package/esm/ui/internals/FieldContainer.svelte +0 -39
- package/esm/ui/internals/FieldContainer.svelte.d.ts +0 -18
- package/esm/ui/internals/Input.svelte +0 -143
- package/esm/ui/internals/Input.svelte.d.ts +0 -37
- package/esm/ui/internals/Textarea.svelte +0 -66
- package/esm/ui/internals/Textarea.svelte.d.ts +0 -33
- package/esm/ui/internals/select/MultiSelectMelt.svelte +0 -260
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +0 -32
- package/esm/ui/internals/select/Select2.svelte +0 -88
- package/esm/ui/internals/select/Select2.svelte.d.ts +0 -12
- package/esm/ui/internals/select/SelectMelt.svelte +0 -280
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +0 -40
- package/esm/ui/internals/select/SelectRadio.svelte +0 -43
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +0 -27
- package/esm/ui/link/Link.svelte +0 -33
- package/esm/ui/link/Link.svelte.d.ts +0 -33
- package/esm/ui/link/LinkPlus.svelte +0 -63
- package/esm/ui/link/LinkPlus.svelte.d.ts +0 -9
- package/esm/utils/tailwind.d.ts +0 -2
- package/esm/utils/tailwind.js +0 -3
- package/esm/utils/transition.d.ts +0 -9
- package/esm/utils/transition.js +0 -33
- package/esm/utils/types.js +0 -1
- /package/esm/{internals → core}/BaseEnum.js +0 -0
- /package/esm/{internals → core}/common.d.ts +0 -0
- /package/esm/{internals → core}/common.js +0 -0
- /package/esm/{utils → core}/types.d.ts +0 -0
- /package/esm/{auth → core}/types.js +0 -0
- /package/esm/{ui → svelte/ui}/Icon.svelte.d.ts +0 -0
- /package/esm/{ui → svelte/ui}/LibIcon.d.ts +0 -0
- /package/esm/{ui → svelte/ui}/LibIcon.js +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { FindOptions, GroupByOptions, MembersOnly, Repository } from 'remult';
|
|
2
|
-
type TheStoreList<T> = {
|
|
3
|
-
items: T[];
|
|
4
|
-
loading: boolean;
|
|
5
|
-
totalCount: number | undefined;
|
|
6
|
-
agg: any | undefined;
|
|
7
|
-
};
|
|
8
|
-
export type FF_FindOptions<T> = FindOptions<T> & {
|
|
9
|
-
withCount?: boolean;
|
|
10
|
-
withItems?: boolean;
|
|
11
|
-
aggregate?: GroupByOptions<T, (keyof MembersOnly<T>)[], any, any, any, any, any>;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @param repo remult repository to listen to
|
|
15
|
-
* @param initValues usually the data coming from SSR
|
|
16
|
-
* @returns a store with the initial values and a listen() method to subscribe to changes
|
|
17
|
-
*
|
|
18
|
-
* Example
|
|
19
|
-
* ```ts
|
|
20
|
-
* // get the repo
|
|
21
|
-
* const taskRepo = repo(Task)
|
|
22
|
-
*
|
|
23
|
-
* const tasks = kitStore(taskRepo, data.tasks)
|
|
24
|
-
* $: browser && tasks.listen(data.options)
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const storeList: <T>(repo: Repository<T>, initValues?: TheStoreList<T>) => {
|
|
28
|
-
subscribe: (this: void, run: import("svelte/store").Subscriber<TheStoreList<T>>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
29
|
-
manualSet: (info: TheStoreList<T>) => void;
|
|
30
|
-
fetch: (options?: FF_FindOptions<T>, onNewData?: (items?: T[], totalCount?: number) => void) => Promise<void>;
|
|
31
|
-
listen: (options?: FF_FindOptions<T>) => Promise<void>;
|
|
32
|
-
getRepo: () => Repository<T>;
|
|
33
|
-
};
|
|
34
|
-
export {};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { BROWSER } from 'esm-env';
|
|
2
|
-
import { onDestroy } from 'svelte';
|
|
3
|
-
import { writable } from 'svelte/store';
|
|
4
|
-
/**
|
|
5
|
-
* @param repo remult repository to listen to
|
|
6
|
-
* @param initValues usually the data coming from SSR
|
|
7
|
-
* @returns a store with the initial values and a listen() method to subscribe to changes
|
|
8
|
-
*
|
|
9
|
-
* Example
|
|
10
|
-
* ```ts
|
|
11
|
-
* // get the repo
|
|
12
|
-
* const taskRepo = repo(Task)
|
|
13
|
-
*
|
|
14
|
-
* const tasks = kitStore(taskRepo, data.tasks)
|
|
15
|
-
* $: browser && tasks.listen(data.options)
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export const storeList = (repo, initValues = { items: [], loading: true, totalCount: undefined, agg: undefined }) => {
|
|
19
|
-
const { subscribe, set, update } = writable(initValues);
|
|
20
|
-
let unSub = null;
|
|
21
|
-
onDestroy(async () => {
|
|
22
|
-
await plzUnSub();
|
|
23
|
-
});
|
|
24
|
-
// if we already have a subscription, unsubscribe (on option update for example)
|
|
25
|
-
const plzUnSub = async () => {
|
|
26
|
-
if (unSub) {
|
|
27
|
-
await unSub();
|
|
28
|
-
unSub = null;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return {
|
|
32
|
-
subscribe,
|
|
33
|
-
// set,
|
|
34
|
-
manualSet: (info) => {
|
|
35
|
-
set(info);
|
|
36
|
-
},
|
|
37
|
-
fetch: async (options, onNewData) => {
|
|
38
|
-
if (BROWSER) {
|
|
39
|
-
update((s) => ({ ...s, loading: true }));
|
|
40
|
-
const withCount = options?.withCount ?? false;
|
|
41
|
-
const withItems = options?.withItems ?? true;
|
|
42
|
-
if (!withItems && !withCount) {
|
|
43
|
-
throw new Error(`xxx.fetch() withItems and withCount can't be both false!`);
|
|
44
|
-
}
|
|
45
|
-
else if (!withItems && withCount) {
|
|
46
|
-
let optionsToUse = { where: options?.where };
|
|
47
|
-
if (options?.aggregate) {
|
|
48
|
-
optionsToUse = { ...options.aggregate, where: options?.where };
|
|
49
|
-
}
|
|
50
|
-
// const agg = await repo.aggregate({ ...options?.aggregate, where: options?.where })
|
|
51
|
-
const agg = await repo.aggregate(optionsToUse);
|
|
52
|
-
set({ loading: false, items: [], totalCount: agg.$count, agg });
|
|
53
|
-
if (onNewData) {
|
|
54
|
-
onNewData(undefined, agg.$count);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else if (withItems && !withCount) {
|
|
58
|
-
const items = await repo.find(options);
|
|
59
|
-
set({ loading: false, items, totalCount: undefined, agg: undefined });
|
|
60
|
-
if (onNewData) {
|
|
61
|
-
onNewData(items, undefined);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
let optionsToUse = { where: options?.where };
|
|
66
|
-
if (options?.aggregate) {
|
|
67
|
-
optionsToUse = { ...options.aggregate, where: options?.where };
|
|
68
|
-
}
|
|
69
|
-
const [items, agg] = await Promise.all([
|
|
70
|
-
repo.find({ ...options }),
|
|
71
|
-
repo.aggregate(optionsToUse),
|
|
72
|
-
]);
|
|
73
|
-
set({ loading: false, items, totalCount: agg.$count, agg });
|
|
74
|
-
if (onNewData) {
|
|
75
|
-
onNewData(items, agg.$count);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
listen: async (options) => {
|
|
81
|
-
if (BROWSER) {
|
|
82
|
-
await plzUnSub();
|
|
83
|
-
unSub = repo.liveQuery({ ...options }).subscribe(async (info) => {
|
|
84
|
-
const withCount = options?.withCount ?? false;
|
|
85
|
-
let totalCount = undefined;
|
|
86
|
-
if (withCount) {
|
|
87
|
-
const agg = await repo.aggregate({ where: options?.where });
|
|
88
|
-
totalCount = agg.$count;
|
|
89
|
-
}
|
|
90
|
-
update((c) => {
|
|
91
|
-
return { ...c, items: info.items, loading: false, ...(withCount ? { totalCount } : {}) };
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
throw new Error(`xxx.listen() Too early!
|
|
97
|
-
|
|
98
|
-
You should do like:
|
|
99
|
-
let tasks = tasksStore<Task>(taskRepo, data.tasks)
|
|
100
|
-
$: browser && tasks.listen()
|
|
101
|
-
`);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
getRepo: () => {
|
|
105
|
-
return repo;
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
};
|
package/esm/internals/theme.d.ts
DELETED
package/esm/internals/theme.js
DELETED
package/esm/server/index.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
-
import { type ClassType } from 'remult';
|
|
3
|
-
import { type RemultServerOptions } from 'remult/server';
|
|
4
|
-
import { Log } from '@kitql/helpers';
|
|
5
|
-
type ModuleInput = {
|
|
6
|
-
/**
|
|
7
|
-
* The name of the module (usefull for logging and debugging purposes)
|
|
8
|
-
*/
|
|
9
|
-
name: string;
|
|
10
|
-
priority?: number;
|
|
11
|
-
entities?: ClassType<any>[];
|
|
12
|
-
controllers?: ClassType<any>[];
|
|
13
|
-
initApi?: RemultServerOptions<RequestEvent>['initApi'];
|
|
14
|
-
initRequest?: RemultServerOptions<RequestEvent>['initRequest'];
|
|
15
|
-
/** @deprecated use `remult` modules instead */
|
|
16
|
-
modulesFF?: ModuleFF[];
|
|
17
|
-
};
|
|
18
|
-
export declare class ModuleFF {
|
|
19
|
-
name: string;
|
|
20
|
-
log: Log;
|
|
21
|
-
priority?: number;
|
|
22
|
-
entities?: ClassType<any>[];
|
|
23
|
-
controllers?: ClassType<any>[];
|
|
24
|
-
initApi?: RemultServerOptions<RequestEvent>['initApi'];
|
|
25
|
-
initRequest?: RemultServerOptions<RequestEvent>['initRequest'];
|
|
26
|
-
/** @deprecated use `remult` modules instead */
|
|
27
|
-
modulesFF?: ModuleFF[];
|
|
28
|
-
constructor(input: ModuleInput);
|
|
29
|
-
}
|
|
30
|
-
type Options = RemultServerOptions<RequestEvent<Partial<Record<string, string>>, any>> & {
|
|
31
|
-
/** @deprecated use `remult` modules instead */
|
|
32
|
-
modulesFF?: ModuleFF[] | undefined;
|
|
33
|
-
};
|
|
34
|
-
declare module 'remult' {
|
|
35
|
-
interface RemultContext {
|
|
36
|
-
request: RequestEvent;
|
|
37
|
-
setHeaders(headers: Record<string, string>): void;
|
|
38
|
-
setCookie(...args: Parameters<RequestEvent['cookies']['set']>): void;
|
|
39
|
-
deleteCookie(...args: Parameters<RequestEvent['cookies']['delete']>): void;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export declare let entities: ClassType<any>[];
|
|
43
|
-
/**
|
|
44
|
-
* it's basically `remultSveltekit` with the `modules` option
|
|
45
|
-
* @deprecated will be done directly in remult when modules will be in 😉
|
|
46
|
-
*/
|
|
47
|
-
export declare const firstly: (o: Options) => import("remult/remult-sveltekit").RemultSveltekitServer;
|
|
48
|
-
/**
|
|
49
|
-
* Full flat and ordered list by index and concatenaining the modules name
|
|
50
|
-
*/
|
|
51
|
-
export declare const modulesFlatAndOrdered: (modules: ModuleFF[]) => ModuleFF[];
|
|
52
|
-
export {};
|
package/esm/server/index.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {} from 'remult';
|
|
2
|
-
import { remultApi } from 'remult/remult-sveltekit';
|
|
3
|
-
import { Module } from 'remult/server';
|
|
4
|
-
import { Log } from '@kitql/helpers';
|
|
5
|
-
import { sveltekit } from '../sveltekit/server';
|
|
6
|
-
export class ModuleFF {
|
|
7
|
-
name;
|
|
8
|
-
log;
|
|
9
|
-
priority;
|
|
10
|
-
entities;
|
|
11
|
-
controllers;
|
|
12
|
-
initApi;
|
|
13
|
-
initRequest;
|
|
14
|
-
/** @deprecated use `remult` modules instead */
|
|
15
|
-
modulesFF;
|
|
16
|
-
constructor(input) {
|
|
17
|
-
this.name = input.name;
|
|
18
|
-
this.log = new Log(`firstly | ${this.name}`);
|
|
19
|
-
this.priority = input.priority;
|
|
20
|
-
this.entities = input.entities;
|
|
21
|
-
this.controllers = input.controllers;
|
|
22
|
-
this.initApi = input.initApi;
|
|
23
|
-
this.initRequest = input.initRequest;
|
|
24
|
-
this.modulesFF = input.modulesFF;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export let entities = [];
|
|
28
|
-
/**
|
|
29
|
-
* it's basically `remultSveltekit` with the `modules` option
|
|
30
|
-
* @deprecated will be done directly in remult when modules will be in 😉
|
|
31
|
-
*/
|
|
32
|
-
export const firstly = (o) => {
|
|
33
|
-
const modulesSorted = modulesFlatAndOrdered([...[...(o.modulesFF ?? []), sveltekit()]]);
|
|
34
|
-
const ffModulesToRemult = modulesSorted.map((m) => {
|
|
35
|
-
return new Module({
|
|
36
|
-
key: m.name,
|
|
37
|
-
entities: m.entities ?? [],
|
|
38
|
-
controllers: m.controllers ?? [],
|
|
39
|
-
initApi: m.initApi,
|
|
40
|
-
initRequest: m.initRequest,
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
// REMULT P1: With Generate Migrations it's a bit hard to get all entities from all modules.
|
|
44
|
-
entities = [
|
|
45
|
-
...modulesSorted.flatMap((m) => m.entities ?? []),
|
|
46
|
-
...(o.entities ?? []),
|
|
47
|
-
//Managing only the first level... should be ok for now...
|
|
48
|
-
...(o?.modules?.flatMap((m) => m.entities ?? []) ?? []),
|
|
49
|
-
];
|
|
50
|
-
return remultApi({
|
|
51
|
-
// Changing the default default of remult
|
|
52
|
-
logApiEndPoints: false,
|
|
53
|
-
admin: true,
|
|
54
|
-
defaultGetLimit: 25,
|
|
55
|
-
error: o.error
|
|
56
|
-
? o.error
|
|
57
|
-
: async (e) => {
|
|
58
|
-
// REMULT P2: validation error should probably be 409
|
|
59
|
-
// if 400 we move to 409
|
|
60
|
-
if (e.httpStatusCode == 400) {
|
|
61
|
-
e.sendError(409, e.responseBody);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
// Add user configuration
|
|
65
|
-
...o,
|
|
66
|
-
// native remult modules
|
|
67
|
-
modules: [...(o.modules ?? []), ...ffModulesToRemult],
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Full flat and ordered list by index and concatenaining the modules name
|
|
72
|
-
*/
|
|
73
|
-
export const modulesFlatAndOrdered = (modules) => {
|
|
74
|
-
const flattenModules = (modules, parentName = '') => {
|
|
75
|
-
return modules.reduce((acc, module) => {
|
|
76
|
-
const fullName = parentName ? `${parentName}-${module.name}` : module.name;
|
|
77
|
-
// Create a new module object without the 'modules' property
|
|
78
|
-
const { modulesFF: _, ...flatModule } = module;
|
|
79
|
-
const newModule = { ...flatModule, name: fullName };
|
|
80
|
-
const subModules = module.modulesFF ? flattenModules(module.modulesFF, fullName) : [];
|
|
81
|
-
return [...acc, newModule, ...subModules];
|
|
82
|
-
}, []);
|
|
83
|
-
};
|
|
84
|
-
const flatModules = flattenModules(modules);
|
|
85
|
-
flatModules.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
86
|
-
return flatModules;
|
|
87
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="valueType = unknown, entityType = unknown">
|
|
2
|
-
import { deepMerge, FF_Cell, FF_Repo } from './'
|
|
3
|
-
import type { CellMetadata } from './customField'
|
|
4
|
-
import FF_Cell_Caption from './FF_Cell_Caption.svelte'
|
|
5
|
-
import FF_Cell_Display from './FF_Cell_Display.svelte'
|
|
6
|
-
import FF_Cell_Edit from './FF_Cell_Edit.svelte'
|
|
7
|
-
import FF_Cell_Error from './FF_Cell_Error.svelte'
|
|
8
|
-
import FF_Cell_Hint from './FF_Cell_Hint.svelte'
|
|
9
|
-
|
|
10
|
-
const default_uid = $props.id()
|
|
11
|
-
|
|
12
|
-
interface Props<valueType = unknown, entityType = unknown> {
|
|
13
|
-
cell: CellMetadata<valueType, entityType>
|
|
14
|
-
r?: FF_Repo<entityType>
|
|
15
|
-
class?: string
|
|
16
|
-
value?: valueType
|
|
17
|
-
error?: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let { value = $bindable(), error, ...props }: Props<valueType, entityType> = $props()
|
|
21
|
-
|
|
22
|
-
// let classes = $derived(getClasses('field', props.classes))
|
|
23
|
-
|
|
24
|
-
let key = $derived(props.cell.key ?? props.cell.field?.key ?? default_uid)
|
|
25
|
-
let caption = $derived(props.cell.caption ?? props.cell.field?.caption)
|
|
26
|
-
let hint = $derived(props.cell.field?.options.ui?.hint ?? props.cell.ui?.hint)
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
let ui = $derived(deepMerge(props.cell.field?.options.ui ?? {}, props.cell.ui ?? {}))
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<!-- Snippets sections -->
|
|
32
|
-
{#snippet cellsChildren(isForm: boolean = false)}
|
|
33
|
-
<div data-ff-cells>
|
|
34
|
-
{#each props.cell.cells ?? [] as children}
|
|
35
|
-
<FF_Cell cell={children} />
|
|
36
|
-
{/each}
|
|
37
|
-
</div>
|
|
38
|
-
{/snippet}
|
|
39
|
-
|
|
40
|
-
<!-- Main section -->
|
|
41
|
-
<div
|
|
42
|
-
data-ff-cell
|
|
43
|
-
data-ff-cells={props.cell.cells}
|
|
44
|
-
style:--width={ui?.width ?? 100}
|
|
45
|
-
style:--margin-left={ui?.marginLeft ?? 0}
|
|
46
|
-
style:--margin-right={ui?.marginRight ?? 0}
|
|
47
|
-
style:--width-mobile={ui?.mobile?.width ?? 100}
|
|
48
|
-
style:--margin-left-mobile={ui?.mobile?.marginLeft ?? 0}
|
|
49
|
-
style:--margin-right-mobile={ui?.mobile?.marginRight ?? 0}
|
|
50
|
-
class={[key, props.class]}
|
|
51
|
-
>
|
|
52
|
-
<FF_Cell_Caption {ui} {caption} {key} />
|
|
53
|
-
<FF_Cell_Error {ui} {error} {key} />
|
|
54
|
-
{#if props.cell.field}
|
|
55
|
-
{#if props.cell.mode === 'edit'}
|
|
56
|
-
<FF_Cell_Edit field={props.cell.field} {error} bind:value />
|
|
57
|
-
{:else}
|
|
58
|
-
<FF_Cell_Display field={props.cell.field} {error} {value} />
|
|
59
|
-
{/if}
|
|
60
|
-
{/if}
|
|
61
|
-
<FF_Cell_Hint {ui} {hint} {key} />
|
|
62
|
-
|
|
63
|
-
{#if props.cell.type === 'form'}
|
|
64
|
-
<form>
|
|
65
|
-
{@render cellsChildren(true)}
|
|
66
|
-
<button type="submit">Submit</button>
|
|
67
|
-
</form>
|
|
68
|
-
{:else}
|
|
69
|
-
{@render cellsChildren()}
|
|
70
|
-
{/if}
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<style>
|
|
74
|
-
[data-ff-cells] {
|
|
75
|
-
width: 100%;
|
|
76
|
-
display: flex;
|
|
77
|
-
flex-wrap: wrap;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
[data-ff-cell] {
|
|
81
|
-
display: flex;
|
|
82
|
-
flex-direction: column;
|
|
83
|
-
box-sizing: border-box;
|
|
84
|
-
padding: var(--ff-spacing);
|
|
85
|
-
flex: 1 1 calc(var(--width, 100) * 1%);
|
|
86
|
-
max-width: calc(var(--width, 100) * 1%);
|
|
87
|
-
margin-left: calc(var(--margin-left, 0) * 1%);
|
|
88
|
-
margin-right: calc(var(--margin-right, 0) * 1%);
|
|
89
|
-
|
|
90
|
-
/* For debugging purposes - outline that doesn't affect layout */
|
|
91
|
-
outline: 1px solid rgba(255, 0, 0, 0.5);
|
|
92
|
-
outline-offset: -1px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@media screen and (max-width: 40rem) {
|
|
96
|
-
[data-ff-cell] {
|
|
97
|
-
flex: 1 1 calc(var(--width-mobile, 100) * 1%);
|
|
98
|
-
max-width: calc(var(--width-mobile, 100) * 1%);
|
|
99
|
-
margin-left: calc(var(--margin-left-mobile, 0) * 1%);
|
|
100
|
-
margin-right: calc(var(--margin-right-mobile, 0) * 1%);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
</style>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { FF_Repo } from './';
|
|
2
|
-
import type { CellMetadata } from './customField';
|
|
3
|
-
interface Props<valueType = unknown, entityType = unknown> {
|
|
4
|
-
cell: CellMetadata<valueType, entityType>;
|
|
5
|
-
r?: FF_Repo<entityType>;
|
|
6
|
-
class?: string;
|
|
7
|
-
value?: valueType;
|
|
8
|
-
error?: string;
|
|
9
|
-
}
|
|
10
|
-
declare function $$render<valueType = unknown, entityType = unknown>(): {
|
|
11
|
-
props: Props<valueType, entityType>;
|
|
12
|
-
exports: {};
|
|
13
|
-
bindings: "value";
|
|
14
|
-
slots: {};
|
|
15
|
-
events: {};
|
|
16
|
-
};
|
|
17
|
-
declare class __sveltets_Render<valueType = unknown, entityType = unknown> {
|
|
18
|
-
props(): ReturnType<typeof $$render<valueType, entityType>>['props'];
|
|
19
|
-
events(): ReturnType<typeof $$render<valueType, entityType>>['events'];
|
|
20
|
-
slots(): ReturnType<typeof $$render<valueType, entityType>>['slots'];
|
|
21
|
-
bindings(): "value";
|
|
22
|
-
exports(): {};
|
|
23
|
-
}
|
|
24
|
-
interface $$IsomorphicComponent {
|
|
25
|
-
new <valueType = unknown, entityType = unknown>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<valueType, entityType>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<valueType, entityType>['props']>, ReturnType<__sveltets_Render<valueType, entityType>['events']>, ReturnType<__sveltets_Render<valueType, entityType>['slots']>> & {
|
|
26
|
-
$$bindings?: ReturnType<__sveltets_Render<valueType, entityType>['bindings']>;
|
|
27
|
-
} & ReturnType<__sveltets_Render<valueType, entityType>['exports']>;
|
|
28
|
-
<valueType = unknown, entityType = unknown>(internal: unknown, props: ReturnType<__sveltets_Render<valueType, entityType>['props']> & {}): ReturnType<__sveltets_Render<valueType, entityType>['exports']>;
|
|
29
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
30
|
-
}
|
|
31
|
-
declare const FfCell: $$IsomorphicComponent;
|
|
32
|
-
type FfCell<valueType = unknown, entityType = unknown> = InstanceType<typeof FfCell<valueType, entityType>>;
|
|
33
|
-
export default FfCell;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="valueType = unknown, entityType = unknown">
|
|
2
|
-
import type { CellMetadata } from './customField'
|
|
3
|
-
|
|
4
|
-
interface Props<valueType = unknown, entityType = unknown> {
|
|
5
|
-
key: string
|
|
6
|
-
ui: CellMetadata<valueType, entityType>['ui']
|
|
7
|
-
caption?: string
|
|
8
|
-
class?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let { ui, key, class: localClass, caption }: Props<valueType, entityType> = $props()
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
{#if ui?.component?.caption === undefined || ui?.component?.caption === 'show'}
|
|
15
|
-
<label data-ff-cell-caption for={key} class={localClass}>{@html caption}</label>
|
|
16
|
-
{:else if ui?.component?.caption === 'remove'}
|
|
17
|
-
<!-- Nothing -->
|
|
18
|
-
{:else if ui?.component?.caption === 'hide'}
|
|
19
|
-
<span data-ff-cell-caption class={localClass}></span>
|
|
20
|
-
{/if}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { CellMetadata } from './customField';
|
|
2
|
-
interface Props<valueType = unknown, entityType = unknown> {
|
|
3
|
-
key: string;
|
|
4
|
-
ui: CellMetadata<valueType, entityType>['ui'];
|
|
5
|
-
caption?: string;
|
|
6
|
-
class?: string;
|
|
7
|
-
}
|
|
8
|
-
declare function $$render<valueType = unknown, entityType = unknown>(): {
|
|
9
|
-
props: Props<valueType, entityType>;
|
|
10
|
-
exports: {};
|
|
11
|
-
bindings: "";
|
|
12
|
-
slots: {};
|
|
13
|
-
events: {};
|
|
14
|
-
};
|
|
15
|
-
declare class __sveltets_Render<valueType = unknown, entityType = unknown> {
|
|
16
|
-
props(): ReturnType<typeof $$render<valueType, entityType>>['props'];
|
|
17
|
-
events(): ReturnType<typeof $$render<valueType, entityType>>['events'];
|
|
18
|
-
slots(): ReturnType<typeof $$render<valueType, entityType>>['slots'];
|
|
19
|
-
bindings(): "";
|
|
20
|
-
exports(): {};
|
|
21
|
-
}
|
|
22
|
-
interface $$IsomorphicComponent {
|
|
23
|
-
new <valueType = unknown, entityType = unknown>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<valueType, entityType>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<valueType, entityType>['props']>, ReturnType<__sveltets_Render<valueType, entityType>['events']>, ReturnType<__sveltets_Render<valueType, entityType>['slots']>> & {
|
|
24
|
-
$$bindings?: ReturnType<__sveltets_Render<valueType, entityType>['bindings']>;
|
|
25
|
-
} & ReturnType<__sveltets_Render<valueType, entityType>['exports']>;
|
|
26
|
-
<valueType = unknown, entityType = unknown>(internal: unknown, props: ReturnType<__sveltets_Render<valueType, entityType>['props']> & {}): ReturnType<__sveltets_Render<valueType, entityType>['exports']>;
|
|
27
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
28
|
-
}
|
|
29
|
-
declare const FfCellCaption: $$IsomorphicComponent;
|
|
30
|
-
type FfCellCaption<valueType = unknown, entityType = unknown> = InstanceType<typeof FfCellCaption<valueType, entityType>>;
|
|
31
|
-
export default FfCellCaption;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="valueType = unknown, entityType = unknown">
|
|
2
|
-
import { getClasses, getDynamicCustomField, type DisplayTheme } from '.'
|
|
3
|
-
import { isComponentObject, type CustomFieldDefaultProps } from './customField'
|
|
4
|
-
|
|
5
|
-
interface Props extends CustomFieldDefaultProps {
|
|
6
|
-
classes?: DisplayTheme
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let { field, value, error, classes: localClasses = {} }: Props = $props()
|
|
10
|
-
|
|
11
|
-
// let valueList = getValueList(field) as { id: string; caption: string }[] | undefined
|
|
12
|
-
|
|
13
|
-
let classes = $derived(getClasses('display', localClasses))
|
|
14
|
-
const dynamicCustomField = getDynamicCustomField()?.({ field, value, error, mode: 'display' })
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
{#if field.options.ui?.component?.display}
|
|
18
|
-
{@const customField = field.options.ui?.component?.display}
|
|
19
|
-
{#if isComponentObject(customField)}
|
|
20
|
-
{@const Component = customField.component}
|
|
21
|
-
<Component {field} bind:value {error} {...customField.props} />
|
|
22
|
-
{:else}
|
|
23
|
-
{@const Component = customField}
|
|
24
|
-
<Component {field} bind:value {error} />
|
|
25
|
-
{/if}
|
|
26
|
-
{:else if dynamicCustomField}
|
|
27
|
-
{#if isComponentObject(dynamicCustomField)}
|
|
28
|
-
{@const Component = dynamicCustomField.component}
|
|
29
|
-
<Component {field} bind:value {error} {...dynamicCustomField.props} />
|
|
30
|
-
{:else}
|
|
31
|
-
{@const Component = dynamicCustomField}
|
|
32
|
-
<Component {field} bind:value {error} />
|
|
33
|
-
{/if}
|
|
34
|
-
{:else if field.inputType === 'checkbox'}
|
|
35
|
-
<input
|
|
36
|
-
disabled
|
|
37
|
-
data-ff-display-checkbox
|
|
38
|
-
class={classes?.checkbox}
|
|
39
|
-
type="checkbox"
|
|
40
|
-
checked={value as boolean}
|
|
41
|
-
/>
|
|
42
|
-
{:else if field.displayValue}
|
|
43
|
-
<div data-ff-display>
|
|
44
|
-
{field.displayValue({ [field.key]: value } as Partial<entityType>)}
|
|
45
|
-
</div>
|
|
46
|
-
{:else}
|
|
47
|
-
<div data-ff-display>
|
|
48
|
-
{value} NOT READY JYC!
|
|
49
|
-
</div>
|
|
50
|
-
{/if}
|
|
51
|
-
|
|
52
|
-
<style>
|
|
53
|
-
[data-ff-display-checkbox] {
|
|
54
|
-
display: block;
|
|
55
|
-
margin: 0 auto;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
[data-ff-display] {
|
|
59
|
-
min-height: 20px;
|
|
60
|
-
}
|
|
61
|
-
</style>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type DisplayTheme } from '.';
|
|
2
|
-
import { type CustomFieldDefaultProps } from './customField';
|
|
3
|
-
interface Props extends CustomFieldDefaultProps {
|
|
4
|
-
classes?: DisplayTheme;
|
|
5
|
-
}
|
|
6
|
-
declare function $$render<valueType = unknown, entityType = unknown>(): {
|
|
7
|
-
props: Props;
|
|
8
|
-
exports: {};
|
|
9
|
-
bindings: "";
|
|
10
|
-
slots: {};
|
|
11
|
-
events: {};
|
|
12
|
-
};
|
|
13
|
-
declare class __sveltets_Render<valueType = unknown, entityType = unknown> {
|
|
14
|
-
props(): ReturnType<typeof $$render<valueType, entityType>>['props'];
|
|
15
|
-
events(): ReturnType<typeof $$render<valueType, entityType>>['events'];
|
|
16
|
-
slots(): ReturnType<typeof $$render<valueType, entityType>>['slots'];
|
|
17
|
-
bindings(): "";
|
|
18
|
-
exports(): {};
|
|
19
|
-
}
|
|
20
|
-
interface $$IsomorphicComponent {
|
|
21
|
-
new <valueType = unknown, entityType = unknown>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<valueType, entityType>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<valueType, entityType>['props']>, ReturnType<__sveltets_Render<valueType, entityType>['events']>, ReturnType<__sveltets_Render<valueType, entityType>['slots']>> & {
|
|
22
|
-
$$bindings?: ReturnType<__sveltets_Render<valueType, entityType>['bindings']>;
|
|
23
|
-
} & ReturnType<__sveltets_Render<valueType, entityType>['exports']>;
|
|
24
|
-
<valueType = unknown, entityType = unknown>(internal: unknown, props: ReturnType<__sveltets_Render<valueType, entityType>['props']> & {}): ReturnType<__sveltets_Render<valueType, entityType>['exports']>;
|
|
25
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
26
|
-
}
|
|
27
|
-
declare const FfCellDisplay: $$IsomorphicComponent;
|
|
28
|
-
type FfCellDisplay<valueType = unknown, entityType = unknown> = InstanceType<typeof FfCellDisplay<valueType, entityType>>;
|
|
29
|
-
export default FfCellDisplay;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="valueType = unknown, entityType = unknown">
|
|
2
|
-
import { getValueList, type FieldMetadata } from 'remult'
|
|
3
|
-
|
|
4
|
-
import { getClasses, getDynamicCustomField } from '.'
|
|
5
|
-
import type { EditTheme } from '.'
|
|
6
|
-
import { isComponentObject } from './customField'
|
|
7
|
-
|
|
8
|
-
const default_uid = $props.id()
|
|
9
|
-
|
|
10
|
-
interface Props {
|
|
11
|
-
uid?: string
|
|
12
|
-
field: FieldMetadata<valueType, entityType>
|
|
13
|
-
value: valueType
|
|
14
|
-
error?: string
|
|
15
|
-
classes?: EditTheme
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let {
|
|
19
|
-
uid = default_uid,
|
|
20
|
-
field,
|
|
21
|
-
value = $bindable(),
|
|
22
|
-
error,
|
|
23
|
-
classes: localClasses = {},
|
|
24
|
-
}: Props = $props()
|
|
25
|
-
|
|
26
|
-
let valueList = getValueList(field) as { id: string; caption: string }[] | undefined
|
|
27
|
-
|
|
28
|
-
let classes = $derived(getClasses('edit', localClasses))
|
|
29
|
-
const dynamicCustomField = getDynamicCustomField()?.({ field, value, error, mode: 'edit' })
|
|
30
|
-
|
|
31
|
-
const fromInput = (val: any) => {
|
|
32
|
-
// console.log(`fromInput`, val)
|
|
33
|
-
const res = field.valueConverter.fromInput(val)
|
|
34
|
-
// if (res && field.inputType === 'datetime-local') {
|
|
35
|
-
// const date = new Date(res)
|
|
36
|
-
// date.setMinutes(date.getMinutes() - date.getTimezoneOffset())
|
|
37
|
-
// return date.toISOString().slice(0, 16)
|
|
38
|
-
// }
|
|
39
|
-
return res
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const toInput = (val: any) => {
|
|
43
|
-
// console.log(`toInput1`, val)
|
|
44
|
-
const res = field.valueConverter.toInput(val)
|
|
45
|
-
// console.log(`toInput2`, res)
|
|
46
|
-
return res
|
|
47
|
-
}
|
|
48
|
-
</script>
|
|
49
|
-
|
|
50
|
-
{#if field.options.ui?.component?.edit}
|
|
51
|
-
{@const customField = field.options.ui?.component?.edit}
|
|
52
|
-
{#if isComponentObject(customField)}
|
|
53
|
-
{@const Component = customField.component}
|
|
54
|
-
<Component {field} bind:value {error} {...customField.props} />
|
|
55
|
-
{:else}
|
|
56
|
-
{@const Component = customField}
|
|
57
|
-
<Component {field} bind:value {error} />
|
|
58
|
-
{/if}
|
|
59
|
-
{:else if dynamicCustomField}
|
|
60
|
-
{#if isComponentObject(dynamicCustomField)}
|
|
61
|
-
{@const Component = dynamicCustomField.component}
|
|
62
|
-
<Component {field} bind:value {error} {...dynamicCustomField.props} />
|
|
63
|
-
{:else}
|
|
64
|
-
{@const Component = dynamicCustomField}
|
|
65
|
-
<Component {field} bind:value {error} />
|
|
66
|
-
{/if}
|
|
67
|
-
{:else if valueList}
|
|
68
|
-
<select data-ff-cell-edit-select class={classes?.select} id={uid} bind:value>
|
|
69
|
-
{#each valueList as item (item.id)}
|
|
70
|
-
<option value={item}>{item.caption}</option>
|
|
71
|
-
{/each}
|
|
72
|
-
</select>
|
|
73
|
-
{:else if field.inputType === 'checkbox'}
|
|
74
|
-
<div style="display: flex; align-items: center; height: 3rem;">
|
|
75
|
-
<input
|
|
76
|
-
data-ff-cell-edit-checkbox
|
|
77
|
-
class={classes?.checkbox}
|
|
78
|
-
id={uid}
|
|
79
|
-
type="checkbox"
|
|
80
|
-
bind:checked={value as boolean}
|
|
81
|
-
/>
|
|
82
|
-
</div>
|
|
83
|
-
{:else}
|
|
84
|
-
<input
|
|
85
|
-
autocomplete="off"
|
|
86
|
-
data-ff-cell-edit-input
|
|
87
|
-
class={classes?.input}
|
|
88
|
-
id={uid}
|
|
89
|
-
type={field.options.inputType}
|
|
90
|
-
placeholder={field.options.ui?.placeholder}
|
|
91
|
-
bind:value={() => fromInput(value as any), (v) => (value = toInput(v) as valueType)}
|
|
92
|
-
step={field.options.ui?.step}
|
|
93
|
-
/>
|
|
94
|
-
{/if}
|
|
95
|
-
|
|
96
|
-
<style>
|
|
97
|
-
input[data-ff-cell-edit-input] {
|
|
98
|
-
width: 100%;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
select[data-ff-cell-edit-select] {
|
|
102
|
-
width: 100%;
|
|
103
|
-
}
|
|
104
|
-
</style>
|