firstly 0.0.3 → 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/esm/KitFields.d.ts +3 -3
  3. package/esm/KitFields.js +29 -47
  4. package/esm/ROUTES.d.ts +4 -2
  5. package/esm/ROUTES.js +4 -7
  6. package/esm/auth/Adapter.js +10 -8
  7. package/esm/auth/{AuthController.d.ts → AuthController.server.d.ts} +2 -2
  8. package/esm/auth/{AuthController.js → AuthController.server.js} +6 -42
  9. package/esm/auth/README.md +13 -0
  10. package/esm/auth/{RoleController.d.ts → RoleHelpers.d.ts} +1 -3
  11. package/esm/auth/RoleHelpers.js +43 -0
  12. package/esm/auth/client/Auth.d.ts +69 -0
  13. package/esm/auth/client/Auth.js +121 -0
  14. package/esm/auth/client/index.d.ts +2 -0
  15. package/esm/auth/client/index.js +2 -0
  16. package/esm/auth/index.d.ts +2 -3
  17. package/esm/auth/index.js +27 -13
  18. package/esm/auth/static/assets/{Page-BwHye0GW.d.ts → Page-BYzkK4q3.d.ts} +1 -1
  19. package/esm/auth/static/assets/{Page-BwHye0GW.js → Page-BYzkK4q3.js} +1 -1
  20. package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +5 -0
  21. package/esm/auth/static/assets/Page-ByIhtXVt.js +18 -0
  22. package/esm/auth/static/assets/{Page-BMOLAIFx.d.ts → Page-Do7F0Mzd.d.ts} +1 -1
  23. package/esm/auth/static/assets/{Page-BMOLAIFx.js → Page-Do7F0Mzd.js} +1 -1
  24. package/esm/auth/static/assets/index-czJ1PA1n.js +2 -0
  25. package/esm/auth/static/index.html +1 -1
  26. package/esm/bin/cmd.js +7 -6
  27. package/esm/formats/strings.js +0 -11
  28. package/esm/helper.d.ts +2 -2
  29. package/esm/helper.js +1 -5
  30. package/esm/index.d.ts +3 -2
  31. package/esm/index.js +8 -1
  32. package/esm/kitCellsBuildor.d.ts +2 -2
  33. package/esm/kitCellsBuildor.js +16 -6
  34. package/esm/kitStoreItem.js +2 -2
  35. package/esm/ui/Button.svelte +6 -8
  36. package/esm/ui/Field.svelte +9 -8
  37. package/esm/ui/FieldGroup.svelte +5 -3
  38. package/esm/ui/GridPaginate.svelte +3 -6
  39. package/esm/ui/Icon.svelte +6 -7
  40. package/esm/ui/LibIcon.js +0 -2
  41. package/esm/ui/dialog/DialogForm.svelte +3 -4
  42. package/esm/ui/dialog/dialog.d.ts +2 -0
  43. package/esm/ui/dialog/dialog.js +1 -0
  44. package/esm/ui/internals/FieldContainer.svelte +1 -1
  45. package/esm/ui/internals/Input.svelte +1 -1
  46. package/esm/ui/internals/select/MultiSelectMelt.svelte +16 -19
  47. package/esm/ui/internals/select/SelectMelt.svelte +10 -14
  48. package/esm/vite/index.js +1 -1
  49. package/package.json +8 -4
  50. package/esm/auth/RoleController.js +0 -57
  51. package/esm/auth/static/assets/Page-BMFREPjF.d.ts +0 -5
  52. package/esm/auth/static/assets/Page-BMFREPjF.js +0 -18
  53. package/esm/auth/static/assets/index-CKmKKRRL.js +0 -2
  54. /package/esm/auth/static/assets/{index-CKmKKRRL.d.ts → index-czJ1PA1n.d.ts} +0 -0
package/esm/bin/cmd.js CHANGED
@@ -32,10 +32,10 @@ const res = (await p.multiselect({
32
32
  options,
33
33
  }));
34
34
  const devDependenciesPrepare = {
35
- '@kitql/eslint-config': '0.3.2',
35
+ '@kitql/eslint-config': '0.3.6',
36
36
  '@kitql/helpers': '0.8.9',
37
37
  remult: versionFirstly,
38
- pg: '8.11.3',
38
+ pg: '8.12.0',
39
39
  ...pkg.devDependencies,
40
40
  };
41
41
  // sort by name
@@ -154,7 +154,7 @@ export const api = firstly({
154
154
  // 2/ uncomment imports & github() call below
155
155
  // 3/ under a button click call something like this:
156
156
  // async function oauth() {
157
- // window.location.href = await AuthController.signInOAuthGetUrl({ provider: 'github', redirect: window.location.pathname })
157
+ // window.location.href = await Auth.signInOAuthGetUrl({ provider: 'github', redirect: window.location.pathname })
158
158
  // }
159
159
  // github( { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } )
160
160
  ],
@@ -211,7 +211,7 @@ export const load = (async () => {
211
211
  `<script lang="ts">
212
212
  import { remult } from 'remult'
213
213
  import { isError } from 'firstly'
214
- import { AuthController } from 'firstly/auth'
214
+ import { Auth } from 'firstly/auth/client'
215
215
 
216
216
  import { invalidateAll } from '$app/navigation'
217
217
 
@@ -221,7 +221,7 @@ export const load = (async () => {
221
221
 
222
222
  const login = async (identif: string) => {
223
223
  try {
224
- await AuthController.signInDemo(identif)
224
+ await Auth.signInDemo(identif)
225
225
  invalidateAll()
226
226
  } catch (error) {
227
227
  if (isError(error)) {
@@ -232,7 +232,7 @@ export const load = (async () => {
232
232
 
233
233
  const logout = async () => {
234
234
  try {
235
- await AuthController.signOut()
235
+ await Auth.signOut()
236
236
  invalidateAll()
237
237
  } catch (error) {
238
238
  if (isError(error)) {
@@ -263,6 +263,7 @@ export const load = (async () => {
263
263
  <button on:click={() => login('Ermin')}>Login as Ermin</button>
264
264
  <button on:click={() => login('JYC')}>Login as JYC</button>
265
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>
266
267
  {/if}
267
268
 
268
269
  <hr />
@@ -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 { type ErrorInfo, type FieldMetadata, type Repository } from 'remult';
2
- import { type KitBaseItem } from './index.js';
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, } from 'remult';
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
- import 'remult';
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
+ };
@@ -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 {};
@@ -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.type === 'toOne') {
95
- // @ts-ignore (stting the id of the relation)
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 {
@@ -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) {
@@ -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
- isLoading && setTimeout(() => {
15
- if (isLoading) {
16
- triggerAnnimation = true;
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(
@@ -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
- if (metaType.subKind === "number" && _value === 0) {
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
- <span>{cell?.header ?? item?.caption ?? '-'}</span>
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)}
@@ -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
- isValidValue = totalCount !== void 0 && totalCount !== null;
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' }}>
@@ -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 (typeof data === "string") {
19
- if (data.toLowerCase().includes("<svg")) {
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
- cells = kitCellsBuildor(toShow.repo, toShow.cells);
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;
@@ -65,6 +65,7 @@ const createDialogManagement = () => {
65
65
  classes: options?.classes,
66
66
  noThrow: options?.noThrow,
67
67
  wDelete: options?.wDelete,
68
+ focusKey: options?.focusKey,
68
69
  topicPrefixText,
69
70
  };
70
71
  return show(detail, type);
@@ -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>
@@ -35,7 +35,7 @@ const handleInput = (e) => {
35
35
  if (e.data === "." || e.data === ",") {
36
36
  e.preventDefault();
37
37
  } else {
38
- value = +target.value;
38
+ value = target.value.toString().replaceAll(",", ".");
39
39
  }
40
40
  } else {
41
41
  value = target.value;
@@ -69,22 +69,21 @@ const debounce = (callback) => {
69
69
  );
70
70
  };
71
71
  const sync = createSync({ selected: localSelected });
72
- $:
73
- items && sync.selected(getDefaultValues(values), (v) => {
74
- const list = (v ?? []).map((c) => c.value.id);
75
- const countMap = /* @__PURE__ */ new Map();
76
- list.forEach((item) => {
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
- items && sync.selected(getDefaultValue(value), (v) => {
101
- if (v?.value?.id !== value) {
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
- filteredItems = items;
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', '$env/dynamic/private'];
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",
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.26.15",
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.2.10",
36
- "vite-plugin-kit-routes": "^0.6.2",
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"
@@ -1,57 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { BackendMethod, repo } from 'remult';
8
- import { cyan, green, Log, yellow } from '@kitql/helpers';
9
- import { KitAuthUser } from './Entities';
10
- /**
11
- * will merge the roles and remove duplicates
12
- * will return a new array & a status if the array was changed
13
- */
14
- export const mergeRoles = (existing, newOnes) => {
15
- const result = new Set(existing);
16
- let changed = false;
17
- for (const role of newOnes ?? []) {
18
- if (!result.has(role)) {
19
- result.add(role);
20
- changed = true;
21
- }
22
- }
23
- return { roles: Array.from(result), changed };
24
- };
25
- export class RoleController {
26
- // @ts-ignore (for pnpm check)
27
- static initRoleFromEnv = async (log, userEntity, envKey, role) => {
28
- // @ts-ignore (for pnpm check)
29
- const { env } = await import('$env/dynamic/private');
30
- const names = env[envKey] === undefined ? [] : (env[envKey] ?? '').split(',');
31
- for (let i = 0; i < names.length; i++) {
32
- const name = names[i].trim();
33
- if (name !== '') {
34
- let user = await repo(userEntity).findFirst({ name });
35
- if (!user) {
36
- user = repo(userEntity).create({ name, roles: [role] });
37
- await repo(userEntity).save(user);
38
- }
39
- else {
40
- if (!user.roles.includes(role)) {
41
- user.roles.push(role);
42
- await repo(userEntity).save(user);
43
- }
44
- }
45
- }
46
- }
47
- if (names.length > 0) {
48
- log.info(`${cyan(role)}: ${names.map((c) => green(c.trim())).join(', ')} added via ${yellow(envKey)}.`);
49
- }
50
- else {
51
- log.info(`${cyan(role)}: No users added via ${yellow(envKey)}.`);
52
- }
53
- };
54
- }
55
- __decorate([
56
- BackendMethod({ allowed: false })
57
- ], RoleController, "initRoleFromEnv", void 0);
@@ -1,5 +0,0 @@
1
- export { no as default };
2
- declare class no extends Je {
3
- constructor(e: any);
4
- }
5
- import { S as Je } from "./index-CKmKKRRL.js";