firstly 0.0.2 → 0.0.4
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 +15 -0
- package/README.md +1 -1
- package/esm/KitFields.d.ts +3 -3
- package/esm/KitFields.js +29 -47
- package/esm/ROUTES.d.ts +4 -2
- package/esm/ROUTES.js +4 -7
- package/esm/auth/Adapter.js +10 -8
- package/esm/auth/{AuthController.d.ts → AuthController.server.d.ts} +2 -2
- package/esm/auth/{AuthController.js → AuthController.server.js} +6 -42
- package/esm/auth/README.md +13 -0
- package/esm/auth/{RoleController.d.ts → RoleHelpers.d.ts} +1 -3
- package/esm/auth/RoleHelpers.js +43 -0
- package/esm/auth/client/Auth.d.ts +69 -0
- package/esm/auth/client/Auth.js +121 -0
- package/esm/auth/client/index.d.ts +2 -0
- package/esm/auth/client/index.js +2 -0
- package/esm/auth/index.d.ts +2 -3
- package/esm/auth/index.js +28 -13
- package/esm/auth/static/assets/{Page-BwHye0GW.d.ts → Page-BYzkK4q3.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-BwHye0GW.js → Page-BYzkK4q3.js} +1 -1
- package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +5 -0
- package/esm/auth/static/assets/Page-ByIhtXVt.js +18 -0
- package/esm/auth/static/assets/{Page-BMOLAIFx.d.ts → Page-Do7F0Mzd.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-BMOLAIFx.js → Page-Do7F0Mzd.js} +1 -1
- package/esm/auth/static/assets/index-czJ1PA1n.js +2 -0
- package/esm/auth/static/index.html +1 -1
- package/esm/bin/cmd.js +19 -8
- package/esm/formats/strings.js +0 -11
- package/esm/helper.d.ts +2 -2
- package/esm/helper.js +1 -5
- package/esm/index.d.ts +3 -2
- package/esm/index.js +8 -1
- package/esm/kitCellsBuildor.d.ts +2 -2
- package/esm/kitCellsBuildor.js +16 -6
- package/esm/kitStoreItem.js +2 -2
- package/esm/ui/Button.svelte +6 -8
- package/esm/ui/Field.svelte +9 -8
- package/esm/ui/FieldGroup.svelte +5 -3
- package/esm/ui/GridPaginate.svelte +3 -6
- package/esm/ui/Icon.svelte +6 -7
- package/esm/ui/LibIcon.js +0 -2
- package/esm/ui/dialog/DialogForm.svelte +3 -4
- package/esm/ui/dialog/dialog.d.ts +2 -0
- package/esm/ui/dialog/dialog.js +1 -0
- package/esm/ui/internals/FieldContainer.svelte +1 -1
- package/esm/ui/internals/Input.svelte +1 -1
- package/esm/ui/internals/select/MultiSelectMelt.svelte +16 -19
- package/esm/ui/internals/select/SelectMelt.svelte +10 -14
- package/esm/vite/index.js +1 -1
- package/package.json +8 -4
- package/esm/auth/RoleController.js +0 -57
- package/esm/auth/static/assets/Page-BMFREPjF.d.ts +0 -5
- package/esm/auth/static/assets/Page-BMFREPjF.js +0 -18
- package/esm/auth/static/assets/index-CKmKKRRL.js +0 -2
- /package/esm/auth/static/assets/{index-CKmKKRRL.d.ts → index-czJ1PA1n.d.ts} +0 -0
package/esm/bin/cmd.js
CHANGED
|
@@ -3,6 +3,8 @@ import { bold, cyan, gray, green, italic, Log } from '@kitql/helpers';
|
|
|
3
3
|
import { read, write } from '@kitql/internals';
|
|
4
4
|
// Need this trick to be be replaced by the real lib alias here ;)
|
|
5
5
|
const libAlias = '$' + 'lib';
|
|
6
|
+
const pkgFirstly = JSON.parse(read('./node_modules/firstly/package.json') ?? '{}');
|
|
7
|
+
const versionFirstly = pkgFirstly?.peerDependencies?.['remult'] ?? 'latest';
|
|
6
8
|
const pkg = JSON.parse(read('./package.json') ?? '{}');
|
|
7
9
|
const version = pkg.devDependencies?.['firstly'] ?? pkg.dependencies?.['firstly'] ?? '???';
|
|
8
10
|
console.info('');
|
|
@@ -29,13 +31,21 @@ const res = (await p.multiselect({
|
|
|
29
31
|
message: 'You can generate different things here',
|
|
30
32
|
options,
|
|
31
33
|
}));
|
|
32
|
-
|
|
33
|
-
'@kitql/eslint-config': '0.3.
|
|
34
|
+
const devDependenciesPrepare = {
|
|
35
|
+
'@kitql/eslint-config': '0.3.6',
|
|
34
36
|
'@kitql/helpers': '0.8.9',
|
|
35
|
-
remult:
|
|
36
|
-
pg: '8.
|
|
37
|
+
remult: versionFirstly,
|
|
38
|
+
pg: '8.12.0',
|
|
37
39
|
...pkg.devDependencies,
|
|
38
40
|
};
|
|
41
|
+
// sort by name
|
|
42
|
+
const devDependenciesSorted = Object.keys(devDependenciesPrepare)
|
|
43
|
+
.sort()
|
|
44
|
+
.reduce((acc, key) => {
|
|
45
|
+
acc[key] = devDependenciesPrepare[key];
|
|
46
|
+
return acc;
|
|
47
|
+
}, {});
|
|
48
|
+
pkg.devDependencies = devDependenciesSorted;
|
|
39
49
|
pkg.scripts = {
|
|
40
50
|
...pkg.scripts,
|
|
41
51
|
'//// ---- BEST PRACTICES ---- ////': '',
|
|
@@ -144,7 +154,7 @@ export const api = firstly({
|
|
|
144
154
|
// 2/ uncomment imports & github() call below
|
|
145
155
|
// 3/ under a button click call something like this:
|
|
146
156
|
// async function oauth() {
|
|
147
|
-
// window.location.href = await
|
|
157
|
+
// window.location.href = await Auth.signInOAuthGetUrl({ provider: 'github', redirect: window.location.pathname })
|
|
148
158
|
// }
|
|
149
159
|
// github( { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } )
|
|
150
160
|
],
|
|
@@ -201,7 +211,7 @@ export const load = (async () => {
|
|
|
201
211
|
`<script lang="ts">
|
|
202
212
|
import { remult } from 'remult'
|
|
203
213
|
import { isError } from 'firstly'
|
|
204
|
-
import {
|
|
214
|
+
import { Auth } from 'firstly/auth/client'
|
|
205
215
|
|
|
206
216
|
import { invalidateAll } from '$app/navigation'
|
|
207
217
|
|
|
@@ -211,7 +221,7 @@ export const load = (async () => {
|
|
|
211
221
|
|
|
212
222
|
const login = async (identif: string) => {
|
|
213
223
|
try {
|
|
214
|
-
await
|
|
224
|
+
await Auth.signInDemo(identif)
|
|
215
225
|
invalidateAll()
|
|
216
226
|
} catch (error) {
|
|
217
227
|
if (isError(error)) {
|
|
@@ -222,7 +232,7 @@ export const load = (async () => {
|
|
|
222
232
|
|
|
223
233
|
const logout = async () => {
|
|
224
234
|
try {
|
|
225
|
-
await
|
|
235
|
+
await Auth.signOut()
|
|
226
236
|
invalidateAll()
|
|
227
237
|
} catch (error) {
|
|
228
238
|
if (isError(error)) {
|
|
@@ -253,6 +263,7 @@ export const load = (async () => {
|
|
|
253
263
|
<button on:click={() => login('Ermin')}>Login as Ermin</button>
|
|
254
264
|
<button on:click={() => login('JYC')}>Login as JYC</button>
|
|
255
265
|
<button on:click={() => login('Noam')}>Login as Noam</button>
|
|
266
|
+
<a href="/fly/auth/sign-in">Have a look also this integrated Auth UI !</a>
|
|
256
267
|
{/if}
|
|
257
268
|
|
|
258
269
|
<hr />
|
package/esm/formats/strings.js
CHANGED
|
@@ -16,17 +16,6 @@ const formatPhone = (phone) => {
|
|
|
16
16
|
return '';
|
|
17
17
|
}
|
|
18
18
|
return phone;
|
|
19
|
-
// TODO: Let's be smart one day... and add a ton of tests!
|
|
20
|
-
// const replaced = phone.replaceAll(' ', '').replaceAll('.', '')
|
|
21
|
-
// let formatted: string = replaced
|
|
22
|
-
// if (replaced.charAt(0) === '+') {
|
|
23
|
-
// return formatted
|
|
24
|
-
// } else if (replaced.slice(0, 2) === '00') {
|
|
25
|
-
// return `+${formatted.slice(2)}`
|
|
26
|
-
// } else if (replaced.length > 10) {
|
|
27
|
-
// formatted = replaced.slice(0, 10)
|
|
28
|
-
// }
|
|
29
|
-
// return `+33${formatted.slice(1)}`
|
|
30
19
|
};
|
|
31
20
|
export const arrToStr = (arr) => {
|
|
32
21
|
if (!arr)
|
package/esm/helper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ErrorInfo, FieldMetadata, Repository } from 'remult';
|
|
2
|
+
import type { KitBaseItem } from './index.js';
|
|
3
3
|
export declare function isError<T>(object: any): object is ErrorInfo<T>;
|
|
4
4
|
export declare const getFirstInterestingField: <Entity>(repo: Repository<Entity>) => FieldMetadata<any, Entity>;
|
|
5
5
|
export declare const getEntityDisplayValue: <Entity>(repo: Repository<Entity>, row: Entity) => KitBaseItem;
|
package/esm/helper.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { dbNamesOf, getEntityRef
|
|
1
|
+
import { dbNamesOf, getEntityRef } from 'remult';
|
|
2
2
|
import { getRelationFieldInfo } from 'remult/internals';
|
|
3
3
|
import { suffixWithS } from './formats/strings.js';
|
|
4
|
-
import {} from './index.js';
|
|
5
4
|
export function isError(object) {
|
|
6
5
|
return object;
|
|
7
6
|
}
|
|
@@ -87,9 +86,6 @@ export const getFieldMetaType = (field) => {
|
|
|
87
86
|
};
|
|
88
87
|
export const displayWithDefaultAndSuffix = (field, value) => {
|
|
89
88
|
const toRet = [];
|
|
90
|
-
// TODO: This method should be reviewed. Specifically, server expression & Field.date have
|
|
91
|
-
// valueConverter by defualt, so we can't use displayValue if checking for valueConverter
|
|
92
|
-
// Hummm... JYC: I didn't understand the above comment.
|
|
93
89
|
if (field && field.valueConverter?.displayValue && !field.isServerExpression) {
|
|
94
90
|
toRet.push(field.valueConverter?.displayValue(value) ?? '-');
|
|
95
91
|
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { FindOptionsBase, Repository } from 'remult';
|
|
2
|
-
import 'remult';
|
|
3
1
|
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { FieldMetadata, FindOptionsBase, Repository } from 'remult';
|
|
4
3
|
import { Log } from '@kitql/helpers';
|
|
5
4
|
import type { KitBaseEnum, KitBaseEnumOptions, KitIcon } from './KitBaseEnum.js';
|
|
6
5
|
import type { KitCellsInput as KitCellsInputForExport } from './kitCellsBuildor.js';
|
|
@@ -84,6 +83,7 @@ declare module 'remult' {
|
|
|
84
83
|
createOptionWhenNoResult?: boolean;
|
|
85
84
|
multiSelect?: boolean;
|
|
86
85
|
skipForDefaultField?: boolean;
|
|
86
|
+
isHidden?: (item: entityType) => boolean;
|
|
87
87
|
}
|
|
88
88
|
interface EntityOptions<entityType> {
|
|
89
89
|
searchableFind?: (str: string) => FindOptionsBase<entityType>;
|
|
@@ -101,3 +101,4 @@ declare module 'remult' {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
+
export declare const isHidden: (fm: FieldMetadata, row: any) => boolean;
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// I'm not sure I can remove this or not ?
|
|
2
|
+
// import 'remult'
|
|
2
3
|
import { Log } from '@kitql/helpers';
|
|
3
4
|
import { kitStoreItem } from './kitStoreItem.js';
|
|
4
5
|
import { kitStoreList } from './kitStoreList.js';
|
|
@@ -40,3 +41,9 @@ export { displayPhone, arrToStr } from './formats/strings.js';
|
|
|
40
41
|
export { displayCurrency } from './formats/numbers.js';
|
|
41
42
|
export { tw } from './utils/tailwind.js';
|
|
42
43
|
export { litOrStr } from './utils/types.js';
|
|
44
|
+
export const isHidden = (fm, row) => {
|
|
45
|
+
if (fm.options.isHidden) {
|
|
46
|
+
return fm.options.isHidden(row);
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
package/esm/kitCellsBuildor.d.ts
CHANGED
|
@@ -40,6 +40,6 @@ export declare function kitCellsBuildor<Entity>(repo: Repository<Entity>, inputB
|
|
|
40
40
|
export declare function kitCellBuildor<Entity>(repo: Repository<Entity>, inputBuildor: UnArray<KitCellsInput<Entity>>): KitCell<Entity>;
|
|
41
41
|
export declare const fieldsOf: <Entity>(b: KitCell<Entity>[]) => FieldMetadata<any, Entity>[];
|
|
42
42
|
export declare const getPlaceholder: <Entity>(fields: FieldMetadata<any, Entity>[]) => string;
|
|
43
|
-
export declare const buildSearchWhere: <Entity>(fields: FieldMetadata<any, Entity>[], search?: string | null) => EntityFilter<Entity>[];
|
|
44
|
-
export declare const buildWhere: <Entity>(defaultWhere: EntityFilter<Entity> | undefined, fields_filter: FieldMetadata<any, Entity>[], fields_search: FieldMetadata<any, Entity>[], obj: Record<string, string>) => EntityFilter<Entity>;
|
|
43
|
+
export declare const buildSearchWhere: <Entity>(entity: Entity | undefined, fields: FieldMetadata<any, Entity>[], search?: string | null) => EntityFilter<Entity>[];
|
|
44
|
+
export declare const buildWhere: <Entity>(entity: Entity | undefined, defaultWhere: EntityFilter<Entity> | undefined, fields_filter: FieldMetadata<any, Entity>[], fields_search: FieldMetadata<any, Entity>[], obj: Record<string, string>) => EntityFilter<Entity>;
|
|
45
45
|
export {};
|
package/esm/kitCellsBuildor.js
CHANGED
|
@@ -47,13 +47,23 @@ export const fieldsOf = (b) => {
|
|
|
47
47
|
export const getPlaceholder = (fields) => {
|
|
48
48
|
return fields.map((c) => c.caption).join(', ');
|
|
49
49
|
};
|
|
50
|
-
export const buildSearchWhere = (fields, search) => {
|
|
50
|
+
export const buildSearchWhere = (entity, fields, search) => {
|
|
51
51
|
if (!search) {
|
|
52
52
|
return [];
|
|
53
53
|
}
|
|
54
54
|
const f = [
|
|
55
55
|
{
|
|
56
56
|
$or: fields.map((f) => {
|
|
57
|
+
if (f.isServerExpression) {
|
|
58
|
+
// check if this field has a specific filter function
|
|
59
|
+
const fnName = f.key + 'Filter';
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
if (entity && entity[fnName]) {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
return entity[fnName](search);
|
|
64
|
+
}
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
57
67
|
if (f.inputType === 'number') {
|
|
58
68
|
return { [f.key]: search };
|
|
59
69
|
}
|
|
@@ -66,18 +76,18 @@ export const buildSearchWhere = (fields, search) => {
|
|
|
66
76
|
];
|
|
67
77
|
return f;
|
|
68
78
|
};
|
|
69
|
-
export const buildWhere = (defaultWhere, fields_filter, fields_search, obj) => {
|
|
79
|
+
export const buildWhere = (entity, defaultWhere, fields_filter, fields_search, obj) => {
|
|
70
80
|
const and = [];
|
|
71
81
|
if (defaultWhere) {
|
|
72
82
|
and.push(defaultWhere);
|
|
73
83
|
}
|
|
74
84
|
if (obj.search) {
|
|
75
|
-
and.push(...buildSearchWhere(fields_search, obj.search));
|
|
85
|
+
and.push(...buildSearchWhere(entity, fields_search, obj.search));
|
|
76
86
|
}
|
|
77
87
|
for (const field of fields_filter) {
|
|
78
|
-
const rfi = getRelationFieldInfo(field);
|
|
79
88
|
// if there is a value
|
|
80
89
|
if (obj[field.key]) {
|
|
90
|
+
const rfi = getRelationFieldInfo(field);
|
|
81
91
|
if (field.inputType === 'checkbox') {
|
|
82
92
|
// @ts-ignore
|
|
83
93
|
and.push({ [field.key]: obj[field.key] });
|
|
@@ -91,8 +101,8 @@ export const buildWhere = (defaultWhere, fields_filter, fields_search, obj) => {
|
|
|
91
101
|
// @ts-ignore
|
|
92
102
|
and.push({ [field.key]: wheretoUse });
|
|
93
103
|
}
|
|
94
|
-
else if (rfi
|
|
95
|
-
// @ts-ignore (
|
|
104
|
+
else if (rfi?.type === 'toOne') {
|
|
105
|
+
// @ts-ignore (setting the id of the relation)
|
|
96
106
|
and.push({ [field.key]: obj[field.key] });
|
|
97
107
|
}
|
|
98
108
|
else {
|
package/esm/kitStoreItem.js
CHANGED
|
@@ -56,12 +56,12 @@ export const kitStoreItem = (repo, initValues = {
|
|
|
56
56
|
internalStore.update((s) => ({
|
|
57
57
|
...s,
|
|
58
58
|
loading: false,
|
|
59
|
-
item,
|
|
59
|
+
item: item ?? {},
|
|
60
60
|
errors: undefined,
|
|
61
61
|
globalError: undefined,
|
|
62
62
|
}));
|
|
63
63
|
if (onNewData) {
|
|
64
|
-
onNewData(item);
|
|
64
|
+
onNewData(item ?? {});
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
package/esm/ui/Button.svelte
CHANGED
|
@@ -7,15 +7,13 @@ let className = void 0;
|
|
|
7
7
|
export { className as class };
|
|
8
8
|
export let permission = void 0;
|
|
9
9
|
let permissionDisabled = false;
|
|
10
|
-
$:
|
|
11
|
-
disabled = $$restProps.disabled || permissionDisabled || isLoading;
|
|
10
|
+
$: disabled = $$restProps.disabled || permissionDisabled || isLoading;
|
|
12
11
|
let triggerAnnimation = false;
|
|
13
|
-
$:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, 200);
|
|
12
|
+
$: isLoading && setTimeout(() => {
|
|
13
|
+
if (isLoading) {
|
|
14
|
+
triggerAnnimation = true;
|
|
15
|
+
}
|
|
16
|
+
}, 200);
|
|
19
17
|
let updates = (param) => {
|
|
20
18
|
if (param && param.permission) {
|
|
21
19
|
permissionDisabled = !remult.isAllowed(
|
package/esm/ui/Field.svelte
CHANGED
|
@@ -31,8 +31,7 @@ function dispatchSelected(_data) {
|
|
|
31
31
|
value = _data;
|
|
32
32
|
dispatch("selected", _data);
|
|
33
33
|
}
|
|
34
|
-
$:
|
|
35
|
-
metaType = getFieldMetaType(cell.field);
|
|
34
|
+
$: metaType = getFieldMetaType(cell.field);
|
|
36
35
|
const isViewMode = (_mode, _field) => {
|
|
37
36
|
return _mode === "view" || _field?.dbReadOnly || _field?.options.allowApiUpdate === false;
|
|
38
37
|
};
|
|
@@ -61,11 +60,7 @@ const toInput = (_metadata, _value) => {
|
|
|
61
60
|
};
|
|
62
61
|
const fromInput = (_metadata, _value) => {
|
|
63
62
|
try {
|
|
64
|
-
|
|
65
|
-
return 0;
|
|
66
|
-
}
|
|
67
|
-
const val = _metadata?.valueConverter.fromInput(_value, metaType.subKind);
|
|
68
|
-
return val;
|
|
63
|
+
return _metadata?.valueConverter.fromInput(_value, metaType.subKind);
|
|
69
64
|
} catch (error2) {
|
|
70
65
|
console.error(`error fromInput w field '${_metadata.key}'`, error2);
|
|
71
66
|
}
|
|
@@ -161,7 +156,13 @@ const calcSuffix = (value2) => {
|
|
|
161
156
|
{#if item && item?.icon}
|
|
162
157
|
<Icon {...item.icon} />
|
|
163
158
|
{/if}
|
|
164
|
-
<
|
|
159
|
+
<div class="grid grid-cols-1">
|
|
160
|
+
<span>{cell?.header ?? item?.caption ?? '-'}</span>
|
|
161
|
+
<!-- && captionSubStyle === 'inline' -->
|
|
162
|
+
{#if item?.captionSub}
|
|
163
|
+
<span class="text-base-content/70 text-xs italic">{item.captionSub}</span>
|
|
164
|
+
{/if}
|
|
165
|
+
</div>
|
|
165
166
|
</div>
|
|
166
167
|
{:else if metaType.kind === 'enum'}
|
|
167
168
|
{@const v = displayWithDefaultAndSuffix(cell.field, value)}
|
package/esm/ui/FieldGroup.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script generics="T extends Record<any, any>">import { createEventDispatcher } from "svelte";
|
|
2
2
|
import { getRelationFieldInfo } from "remult/internals";
|
|
3
|
-
import { tw } from "..";
|
|
3
|
+
import { isHidden, tw } from "..";
|
|
4
4
|
import Field from "./Field.svelte";
|
|
5
5
|
import FieldContainer from "./internals/FieldContainer.svelte";
|
|
6
6
|
import Loading from "./Loading.svelte";
|
|
@@ -38,8 +38,7 @@ const dispatch = createEventDispatcher();
|
|
|
38
38
|
function dispatchChanged(_data) {
|
|
39
39
|
dispatch("changed", _data);
|
|
40
40
|
}
|
|
41
|
-
$:
|
|
42
|
-
dispatchChanged($store.item);
|
|
41
|
+
$: dispatchChanged($store.item);
|
|
43
42
|
let size = ["", "w-1/2", "w-1/3", "w-1/4", "w-1/5", "w-1/6"];
|
|
44
43
|
function isToFocus(currentKey, focusKey2, i) {
|
|
45
44
|
if (focusKey2 === null || focusKey2 === void 0) {
|
|
@@ -56,6 +55,9 @@ function isToFocus(currentKey, focusKey2, i) {
|
|
|
56
55
|
{@const focus = isToFocus(cell.field?.key, focusKey, i)}
|
|
57
56
|
{#if shouldHide(cell, mode)}
|
|
58
57
|
<!-- Do nothing -->
|
|
58
|
+
{:else if cell.field && isHidden(cell.field, $store.item)}
|
|
59
|
+
<!-- Do nothing, but keep the class... -->
|
|
60
|
+
<div class={cell.class}></div>
|
|
59
61
|
{:else}
|
|
60
62
|
<div class={cell.class}>
|
|
61
63
|
{#if cell.kind === 'header'}
|
|
@@ -18,12 +18,9 @@ const update = (op) => {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
$:
|
|
22
|
-
|
|
23
|
-
$:
|
|
24
|
-
needPaginate = isValidValue && (totalCount ?? 0) > pageSize;
|
|
25
|
-
$:
|
|
26
|
-
canGoNext = isValidValue && needPaginate && page < Math.ceil((totalCount ?? 0) / pageSize);
|
|
21
|
+
$: isValidValue = totalCount !== void 0 && totalCount !== null;
|
|
22
|
+
$: needPaginate = isValidValue && (totalCount ?? 0) > pageSize;
|
|
23
|
+
$: canGoNext = isValidValue && needPaginate && page < Math.ceil((totalCount ?? 0) / pageSize);
|
|
27
24
|
</script>
|
|
28
25
|
|
|
29
26
|
<FieldContainer {label} forId="paginate" classes={{ label: 'justify-end' }}>
|
package/esm/ui/Icon.svelte
CHANGED
|
@@ -14,16 +14,15 @@ let height = size;
|
|
|
14
14
|
let viewBox = "0 0 24 24";
|
|
15
15
|
let svg = "";
|
|
16
16
|
let path = "";
|
|
17
|
-
$:
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
svg = data.replace(/width="[^"]*"/, `width="${width}"`).replace(/height="[^"]*"/, `height="${height}"`);
|
|
21
|
-
} else {
|
|
22
|
-
path = data;
|
|
23
|
-
}
|
|
17
|
+
$: if (typeof data === "string") {
|
|
18
|
+
if (data.toLowerCase().includes("<svg")) {
|
|
19
|
+
svg = data.replace(/width="[^"]*"/, `width="${width}"`).replace(/height="[^"]*"/, `height="${height}"`);
|
|
24
20
|
} else {
|
|
25
21
|
path = data;
|
|
26
22
|
}
|
|
23
|
+
} else {
|
|
24
|
+
path = data;
|
|
25
|
+
}
|
|
27
26
|
const getInfoProps = (props, i = 0) => {
|
|
28
27
|
if (Array.isArray(props)) {
|
|
29
28
|
return props[i] ?? "";
|
package/esm/ui/LibIcon.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// Lib Icons
|
|
2
2
|
// https://icones.js.org/ and https://pictogrammers.com/library/mdi/
|
|
3
|
-
// Lib or App let's not grow to much here !
|
|
4
|
-
// TODO : check code spliting...
|
|
5
3
|
import { mdiAccountTie, mdiAccountTieWoman, mdiCancel, mdiCheck, mdiCheckAll, mdiChevronDown, mdiChevronLeft, mdiChevronRight, mdiChevronUp, mdiCloseCircleOutline, mdiCogOutline, mdiContentSaveEdit, mdiDelete, mdiLoading, mdiMagnify, mdiPencil, mdiPlusBoxMultiple, mdiPlusCircle, mdiSend, mdiSort, mdiSortReverseVariant, mdiSortVariant, } from '@mdi/js';
|
|
6
4
|
export const LibIcon_Empty = ``;
|
|
7
5
|
export const LibIcon_Forbidden = mdiCancel;
|
|
@@ -4,10 +4,8 @@ import { dialog } from "./dialog";
|
|
|
4
4
|
import DialogPrimitive from "./DialogPrimitive.svelte";
|
|
5
5
|
import FormEditAction from "./FormEditAction.svelte";
|
|
6
6
|
export let toShow;
|
|
7
|
-
$:
|
|
8
|
-
|
|
9
|
-
$:
|
|
10
|
-
store = toShow.store ?? kitStoreItem(toShow.repo);
|
|
7
|
+
$: cells = kitCellsBuildor(toShow.repo, toShow.cells);
|
|
8
|
+
$: store = toShow.store ?? kitStoreItem(toShow.repo);
|
|
11
9
|
$: {
|
|
12
10
|
if (toShow.type === "update" || toShow.type === "view") {
|
|
13
11
|
store.set({ item: toShow.defaults, errors: {}, loading: false, globalError: void 0 });
|
|
@@ -52,6 +50,7 @@ const onDelete = async () => {
|
|
|
52
50
|
<form on:submit|preventDefault={onInsert}>
|
|
53
51
|
<div class="grid {toShow.classes?.formGrid ?? ''} gap-4 pb-4">
|
|
54
52
|
<FieldGroup
|
|
53
|
+
focusKey={toShow.focusKey}
|
|
55
54
|
{cells}
|
|
56
55
|
{store}
|
|
57
56
|
mode={toShow.type === 'view' ? 'view' : 'edit'}
|
|
@@ -21,6 +21,7 @@ export type DialogMetaData<entityType = any> = {
|
|
|
21
21
|
children?: any;
|
|
22
22
|
noThrow?: boolean;
|
|
23
23
|
wDelete?: boolean;
|
|
24
|
+
focusKey?: string;
|
|
24
25
|
topicPrefixText?: string;
|
|
25
26
|
};
|
|
26
27
|
type ResultClose<entityType = any> = {
|
|
@@ -42,6 +43,7 @@ export declare const dialog: {
|
|
|
42
43
|
noThrow?: boolean;
|
|
43
44
|
wDelete?: boolean;
|
|
44
45
|
topicPrefixText?: string;
|
|
46
|
+
focusKey?: string;
|
|
45
47
|
}) => Promise<ResultClose<any>>;
|
|
46
48
|
show: (dialog: DialogMetaData) => Promise<ResultClose<any>>;
|
|
47
49
|
close: (id: number, result: ResultClose) => void;
|
package/esm/ui/dialog/dialog.js
CHANGED
|
@@ -12,7 +12,7 @@ export let classes = {};
|
|
|
12
12
|
{label}{required ? ' *' : ''}
|
|
13
13
|
</span>
|
|
14
14
|
{#if error}
|
|
15
|
-
<!-- TODO hover popup if too long? -->
|
|
15
|
+
<!-- TODO Ermin? hover popup if too long? -->
|
|
16
16
|
<span class="label-text-alt text-error truncate">{error}</span>
|
|
17
17
|
{/if}
|
|
18
18
|
</label>
|
|
@@ -69,22 +69,21 @@ const debounce = (callback) => {
|
|
|
69
69
|
);
|
|
70
70
|
};
|
|
71
71
|
const sync = createSync({ selected: localSelected });
|
|
72
|
-
$:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
countMap.set(item, (countMap.get(item) || 0) + 1);
|
|
78
|
-
});
|
|
79
|
-
const uniqueList = list.filter((item) => countMap.get(item) === 1);
|
|
80
|
-
const newIds = uniqueList.sort().join(",");
|
|
81
|
-
const oldSelectedValues = (values ?? []).sort().join(",");
|
|
82
|
-
if (newIds !== oldSelectedValues) {
|
|
83
|
-
dispatchSelectedValues(
|
|
84
|
-
v === void 0 ? void 0 : v.filter((c) => uniqueList.includes(c.value.id)).map((c) => c.value)
|
|
85
|
-
);
|
|
86
|
-
}
|
|
72
|
+
$: items && sync.selected(getDefaultValues(values), (v) => {
|
|
73
|
+
const list = (v ?? []).map((c) => c.value.id);
|
|
74
|
+
const countMap = /* @__PURE__ */ new Map();
|
|
75
|
+
list.forEach((item) => {
|
|
76
|
+
countMap.set(item, (countMap.get(item) || 0) + 1);
|
|
87
77
|
});
|
|
78
|
+
const uniqueList = list.filter((item) => countMap.get(item) === 1);
|
|
79
|
+
const newIds = uniqueList.sort().join(",");
|
|
80
|
+
const oldSelectedValues = (values ?? []).sort().join(",");
|
|
81
|
+
if (newIds !== oldSelectedValues) {
|
|
82
|
+
dispatchSelectedValues(
|
|
83
|
+
v === void 0 ? void 0 : v.filter((c) => uniqueList.includes(c.value.id)).map((c) => c.value)
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
88
87
|
const labelToDisplayInInput = (_localSelected) => {
|
|
89
88
|
if (_localSelected === void 0 || _localSelected.length === 0) {
|
|
90
89
|
return "";
|
|
@@ -94,8 +93,7 @@ const labelToDisplayInInput = (_localSelected) => {
|
|
|
94
93
|
}
|
|
95
94
|
return `${_localSelected.length} \xE9l\xE9ments`;
|
|
96
95
|
};
|
|
97
|
-
$:
|
|
98
|
-
$inputValue = labelToDisplayInInput($localSelected);
|
|
96
|
+
$: $inputValue = labelToDisplayInInput($localSelected);
|
|
99
97
|
const iconToDisplayInInput = (_localSelected) => {
|
|
100
98
|
if (_localSelected === void 0 || _localSelected.length === 0) {
|
|
101
99
|
return { data: LibIcon_Search };
|
|
@@ -125,8 +123,7 @@ const calcFilteredItems = (touched, str, values2) => {
|
|
|
125
123
|
filteredItems = items;
|
|
126
124
|
}
|
|
127
125
|
};
|
|
128
|
-
$:
|
|
129
|
-
calcFilteredItems($touchedInput, $inputValue, values);
|
|
126
|
+
$: calcFilteredItems($touchedInput, $inputValue, values);
|
|
130
127
|
</script>
|
|
131
128
|
|
|
132
129
|
<div class="input input-bordered flex min-w-0 items-center">
|
|
@@ -96,19 +96,16 @@ const debounce = (callback) => {
|
|
|
96
96
|
);
|
|
97
97
|
};
|
|
98
98
|
const sync = createSync({ selected: localSelected });
|
|
99
|
-
$:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
dispatchSelectedValue(v?.value);
|
|
103
|
-
}
|
|
104
|
-
value = v?.value?.id;
|
|
105
|
-
});
|
|
106
|
-
$:
|
|
107
|
-
if (!$open) {
|
|
108
|
-
$inputValue = $localSelected?.label ?? "";
|
|
99
|
+
$: items && sync.selected(getDefaultValue(value), (v) => {
|
|
100
|
+
if (v?.value?.id !== value) {
|
|
101
|
+
dispatchSelectedValue(v?.value);
|
|
109
102
|
}
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
value = v?.value?.id;
|
|
104
|
+
});
|
|
105
|
+
$: if (!$open) {
|
|
106
|
+
$inputValue = $localSelected?.label ?? "";
|
|
107
|
+
}
|
|
108
|
+
$: filteredItems = items;
|
|
112
109
|
$: {
|
|
113
110
|
if (items.length === 1 && default_select_if_one_item) {
|
|
114
111
|
sync.selected(toOption(items[0]));
|
|
@@ -133,8 +130,7 @@ const updateFilteredItems = async (normalizedInput) => {
|
|
|
133
130
|
});
|
|
134
131
|
}
|
|
135
132
|
};
|
|
136
|
-
$:
|
|
137
|
-
calcFilteredItems($touchedInput, $inputValue, value);
|
|
133
|
+
$: calcFilteredItems($touchedInput, $inputValue, value);
|
|
138
134
|
</script>
|
|
139
135
|
|
|
140
136
|
<div class="input input-bordered flex min-w-0 items-center {disabled && 'opacity-40'}">
|
package/esm/vite/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { mergeConfig } from 'vite';
|
|
|
2
2
|
import { kitRoutes } from 'vite-plugin-kit-routes';
|
|
3
3
|
import { stripper } from 'vite-plugin-stripper';
|
|
4
4
|
// import { Log } from '@kitql/helpers'
|
|
5
|
-
const toRemove = ['oslo/password', 'oslo', '@kitql/internals'
|
|
5
|
+
const toRemove = ['oslo/password', 'oslo', '@kitql/internals'];
|
|
6
6
|
export function firstly(options) {
|
|
7
7
|
// const log = new Log('firstly')
|
|
8
8
|
return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firstly",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Firstly, an opinionated Remult setup!",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@sveltejs/kit": ">=1.0.0 <3.0.0",
|
|
17
|
-
"remult": "0.
|
|
17
|
+
"remult": "0.27.3",
|
|
18
18
|
"svelte": ">=4.0.1"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"oslo": "^1.2.0",
|
|
33
33
|
"tailwind-merge": "^2.3.0",
|
|
34
34
|
"tailwindcss": "^3.4.3",
|
|
35
|
-
"vite": "^5.
|
|
36
|
-
"vite-plugin-kit-routes": "^0.6.
|
|
35
|
+
"vite": "^5.4.1",
|
|
36
|
+
"vite-plugin-kit-routes": "^0.6.5",
|
|
37
37
|
"vite-plugin-stripper": "^0.5.0"
|
|
38
38
|
},
|
|
39
39
|
"sideEffects": false,
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"types": "./esm/auth/index.d.ts",
|
|
68
68
|
"default": "./esm/auth/index.js"
|
|
69
69
|
},
|
|
70
|
+
"./auth/client": {
|
|
71
|
+
"types": "./esm/auth/client/index.d.ts",
|
|
72
|
+
"default": "./esm/auth/client/index.js"
|
|
73
|
+
},
|
|
70
74
|
"./auth/providers": {
|
|
71
75
|
"types": "./esm/auth/providers/index.d.ts",
|
|
72
76
|
"default": "./esm/auth/providers/index.js"
|