firstly 0.0.13 → 0.0.14

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 (104) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/esm/ROUTES.d.ts +2 -0
  3. package/esm/ROUTES.js +1 -0
  4. package/esm/api/index.d.ts +8 -0
  5. package/esm/auth/AuthController.d.ts +12 -23
  6. package/esm/auth/AuthController.js +12 -31
  7. package/esm/auth/server/AuthController.server.d.ts +11 -11
  8. package/esm/auth/server/AuthController.server.js +83 -18
  9. package/esm/auth/server/helperFirstly.d.ts +1 -1
  10. package/esm/auth/server/helperFirstly.js +1 -0
  11. package/esm/auth/server/module.d.ts +3 -6
  12. package/esm/auth/server/providers/github.d.ts +2 -1
  13. package/esm/auth/server/providers/github.js +1 -1
  14. package/esm/auth/static/assets/Page-B0XXxe0N.d.ts +6 -0
  15. package/esm/auth/static/assets/Page-B0XXxe0N.js +1 -0
  16. package/esm/auth/static/assets/Page-DdKMiUZn.d.ts +6 -0
  17. package/esm/auth/static/assets/Page-DdKMiUZn.js +20 -0
  18. package/esm/auth/static/assets/Page-UV_hqY7I.d.ts +6 -0
  19. package/esm/auth/static/assets/Page-UV_hqY7I.js +1 -0
  20. package/esm/auth/static/assets/Page-mK42zGEw.css +1 -0
  21. package/esm/auth/static/assets/index-C9jzxOBu.d.ts +151 -0
  22. package/esm/auth/static/assets/index-C9jzxOBu.js +42 -0
  23. package/esm/auth/static/index.html +2 -2
  24. package/esm/auth/types.d.ts +26 -3
  25. package/esm/bin/cmd.js +339 -139
  26. package/esm/feedback/FeedbackController.js +57 -51
  27. package/esm/feedback/server/index.d.ts +6 -15
  28. package/esm/feedback/server/index.js +4 -5
  29. package/esm/feedback/types.d.ts +14 -0
  30. package/esm/feedback/types.js +4 -0
  31. package/esm/feedback/ui/DialogIssue.svelte +78 -62
  32. package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -18
  33. package/esm/feedback/ui/DialogIssues.svelte +37 -28
  34. package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -18
  35. package/esm/feedback/ui/DialogMilestones.svelte +18 -12
  36. package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -16
  37. package/esm/feedback/ui/Feedback.svelte +11 -9
  38. package/esm/feedback/ui/Feedback.svelte.d.ts +16 -14
  39. package/esm/mail/server/index.d.ts +9 -2
  40. package/esm/mail/server/index.js +3 -1
  41. package/esm/mail/templates/DefaultMail.svelte +64 -44
  42. package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -26
  43. package/esm/server/index.d.ts +0 -0
  44. package/esm/server/index.js +1 -0
  45. package/esm/storeItem.d.ts +1 -1
  46. package/esm/storeList.d.ts +1 -1
  47. package/esm/sveltekit/server/index.d.ts +0 -9
  48. package/esm/ui/Button.svelte +79 -56
  49. package/esm/ui/Button.svelte.d.ts +34 -24
  50. package/esm/ui/Clipboardable.svelte +18 -11
  51. package/esm/ui/Clipboardable.svelte.d.ts +34 -23
  52. package/esm/ui/Field.svelte +189 -136
  53. package/esm/ui/Field.svelte.d.ts +13 -6
  54. package/esm/ui/FieldGroup.svelte +74 -53
  55. package/esm/ui/FieldGroup.svelte.d.ts +17 -6
  56. package/esm/ui/Grid.svelte +110 -86
  57. package/esm/ui/Grid.svelte.d.ts +17 -6
  58. package/esm/ui/GridLoading.svelte +10 -5
  59. package/esm/ui/GridLoading.svelte.d.ts +19 -17
  60. package/esm/ui/GridPaginate.svelte +30 -23
  61. package/esm/ui/GridPaginate.svelte.d.ts +21 -19
  62. package/esm/ui/Icon.svelte +67 -32
  63. package/esm/ui/Icon.svelte.d.ts +52 -43
  64. package/esm/ui/Loading.svelte +5 -3
  65. package/esm/ui/Loading.svelte.d.ts +29 -18
  66. package/esm/ui/Tooltip.svelte +22 -19
  67. package/esm/ui/Tooltip.svelte.d.ts +30 -20
  68. package/esm/ui/dialog/DialogForm.svelte +48 -41
  69. package/esm/ui/dialog/DialogForm.svelte.d.ts +18 -16
  70. package/esm/ui/dialog/DialogManagement.svelte.d.ts +22 -21
  71. package/esm/ui/dialog/DialogPrimitive.svelte +32 -26
  72. package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +35 -25
  73. package/esm/ui/dialog/FormEditAction.svelte +20 -12
  74. package/esm/ui/dialog/FormEditAction.svelte.d.ts +13 -6
  75. package/esm/ui/dialog/dialog.d.ts +1 -1
  76. package/esm/ui/internals/FieldContainer.svelte +13 -6
  77. package/esm/ui/internals/FieldContainer.svelte.d.ts +37 -28
  78. package/esm/ui/internals/Input.svelte +110 -76
  79. package/esm/ui/internals/Input.svelte.d.ts +34 -32
  80. package/esm/ui/internals/Textarea.svelte +39 -31
  81. package/esm/ui/internals/Textarea.svelte.d.ts +31 -28
  82. package/esm/ui/internals/select/MultiSelectMelt.svelte +174 -126
  83. package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +29 -27
  84. package/esm/ui/internals/select/SelectMelt.svelte +168 -133
  85. package/esm/ui/internals/select/SelectMelt.svelte.d.ts +34 -32
  86. package/esm/ui/internals/select/SelectRadio.svelte +17 -11
  87. package/esm/ui/internals/select/SelectRadio.svelte.d.ts +24 -22
  88. package/esm/ui/link/Link.svelte +11 -6
  89. package/esm/ui/link/Link.svelte.d.ts +31 -22
  90. package/esm/ui/link/LinkPlus.svelte +19 -16
  91. package/esm/ui/link/LinkPlus.svelte.d.ts +20 -18
  92. package/esm/vite/index.d.ts +2 -3
  93. package/esm/vite/index.js +33 -26
  94. package/package.json +5 -5
  95. package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +0 -5
  96. package/esm/auth/static/assets/Page-BUfjaN-D.js +0 -19
  97. package/esm/auth/static/assets/Page-CJ58H1vl.css +0 -1
  98. package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +0 -5
  99. package/esm/auth/static/assets/Page-CaDAqmBS.js +0 -1
  100. package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +0 -5
  101. package/esm/auth/static/assets/Page-DhdZddzJ.js +0 -1
  102. package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +0 -54
  103. package/esm/auth/static/assets/index-D-Ztdt2o.js +0 -2
  104. /package/esm/auth/static/assets/{index-BDy4A_14.css → index-DKWpA6v7.css} +0 -0
@@ -1,139 +1,192 @@
1
- <script generics="T extends Record<any, any>">import { createEventDispatcher } from "svelte";
2
- import {} from "remult";
3
- import {} from "../";
4
- import { suffixWithS } from "../formats/strings";
5
- import {
6
- displayWithDefaultAndSuffix,
7
- getEntityDisplayValue,
8
- getFieldMetaType,
9
- getFirstInterestingField
10
- } from "../helper.js";
11
- import { tw } from "../utils/tailwind";
12
- import Clipboardable from "./Clipboardable.svelte";
13
- import Icon from "./Icon.svelte";
14
- import FieldContainer from "./internals/FieldContainer.svelte";
15
- import Input from "./internals/Input.svelte";
16
- import MultiSelectMelt from "./internals/select/MultiSelectMelt.svelte";
17
- import SelectMelt from "./internals/select/SelectMelt.svelte";
18
- import SelectRadio from "./internals/select/SelectRadio.svelte";
19
- import Textarea from "./internals/Textarea.svelte";
20
- import LinkPlus from "./link/LinkPlus.svelte";
21
- export let cell;
22
- export let value = void 0;
23
- export let cellsValues = {};
24
- export let withDedounce = false;
25
- export let error = "";
26
- export let mode = "edit";
27
- export let focus = false;
28
- export let clearable = void 0;
29
- export let disabled = false;
30
- const dispatch = createEventDispatcher();
31
- function dispatchSelected(_data) {
32
- value = _data;
33
- dispatch("selected", _data);
34
- }
35
- $: metaType = getFieldMetaType(cell.field);
36
- const isViewMode = (_mode, _field) => {
37
- return _mode === "view" || _field?.dbReadOnly || _field?.options.allowApiUpdate === false;
38
- };
39
- const common = (_field, isLight = false) => {
40
- let toRet = {
41
- id: _field?.key ?? "SOMETHING_AT_LEAST",
42
- disabled: _field?.dbReadOnly || _field?.options.allowApiUpdate === false || disabled,
43
- placeholder: _field?.options?.placeholder ?? void 0
44
- };
45
- if (isLight) {
46
- return toRet;
47
- }
48
- return {
49
- ...toRet,
50
- step: _field?.options?.step ?? void 0,
51
- name: _field?.key
52
- // required: _field?.allowNull === false,
53
- };
54
- };
55
- const toInput = (_metadata, _value) => {
56
- try {
57
- return _metadata?.valueConverter.toInput(_value, metaType.subKind);
58
- } catch (error2) {
59
- console.error(`error toInput w field '${_metadata?.key}'`, error2);
60
- }
61
- };
62
- const fromInput = (_metadata, _value) => {
63
- try {
64
- if (_metadata.allowNull && _value === null) {
65
- return null;
66
- }
67
- return _metadata?.valueConverter.fromInput(_value, metaType.subKind);
68
- } catch (error2) {
69
- console.error(`error fromInput w field '${_metadata.key}'`, error2);
70
- }
71
- };
72
- const getId = () => {
73
- return value?.id || value;
74
- };
75
- const getLoadOptions = async (cellsValues2, str) => {
76
- if (metaType.kind !== "relation") {
77
- return { items: [], totalCount: 0 };
78
- }
79
- const metaTypeObj = { ...metaType };
80
- let findToUse = {};
81
- if (metaTypeObj.repoTarget.metadata.options.searchableFind) {
82
- findToUse = metaTypeObj.repoTarget.metadata.options.searchableFind(str);
83
- } else {
84
- if (str) {
85
- const field = getFirstInterestingField(metaTypeObj.repoTarget);
86
- findToUse = { where: { [field.key]: { $contains: str } } };
87
- }
88
- }
89
- const foEdit = cell.field?.options.findOptionsForEdit;
90
- const narrowFindEditWhere = typeof foEdit === "function" ? foEdit(cellsValues2).where ?? {} : typeof foEdit === "object" ? foEdit.where ?? {} : {};
91
- const foCrud = cell.field?.options.findOptions;
92
- const narrowFindCrudWhere = typeof foCrud === "function" ? foCrud().where ?? {} : typeof foCrud === "object" ? foCrud.where ?? {} : {};
93
- findToUse = {
94
- include: { ...findToUse.include ?? {} },
95
- where: { $and: [findToUse.where, narrowFindEditWhere, narrowFindCrudWhere] }
96
- };
97
- let limit = cell.field?.options.findOptionsLimit ?? 24;
98
- const arr = [];
99
- arr.push(
100
- ...await metaTypeObj.repoTarget.find({
101
- ...findToUse,
102
- limit
103
- })
104
- );
105
- let totalCount = arr.length;
106
- if (totalCount === limit) {
107
- const agg = await metaTypeObj.repoTarget.aggregate({ where: findToUse.where });
108
- totalCount = agg.$count;
109
- }
110
- if (!cell.field?.options.multiSelect) {
111
- if (str === "" && getId() && !arr.find((r) => String(r.id) === String(getId()))) {
112
- arr.unshift(await metaTypeObj.repoTarget.findId(getId()));
113
- }
114
- }
115
- return { items: arr.map((r) => getEntityDisplayValue(metaTypeObj.repoTarget, r)), totalCount };
116
- };
117
- const getMultiValues = (value2) => {
118
- return (value2 ?? []).map((c) => c.id) || value2;
119
- };
120
- const calcSuffix = (value2) => {
121
- if (cell.field?.options.suffixEdit) {
122
- if (cell.field?.options.suffixEditWithS) {
123
- return suffixWithS(value2, cell.field?.options.suffixEdit);
124
- } else {
125
- return cell.field?.options.suffixEdit;
126
- }
127
- }
128
- if (cell.field?.options.suffix) {
129
- if (cell.field?.options.suffixWithS) {
130
- return suffixWithS(value2, cell.field?.options.suffix);
131
- } else {
132
- return cell.field?.options.suffix;
133
- }
134
- }
135
- return "";
136
- };
1
+ <script lang="ts" generics="T extends Record<any, any>">
2
+ import { createEventDispatcher } from 'svelte'
3
+ import type { HTMLInputAttributes } from 'svelte/elements'
4
+
5
+ import { type FieldMetadata, type FindOptions } from 'remult'
6
+
7
+ import { type BaseItem, type Cell } from '../'
8
+ import { suffixWithS } from '../formats/strings'
9
+ import {
10
+ displayWithDefaultAndSuffix,
11
+ getEntityDisplayValue,
12
+ getFieldMetaType,
13
+ getFirstInterestingField,
14
+ type MetaTypeRelation,
15
+ } from '../helper.js'
16
+ import { tw } from '../utils/tailwind'
17
+ import Clipboardable from './Clipboardable.svelte'
18
+ import Icon from './Icon.svelte'
19
+ import FieldContainer from './internals/FieldContainer.svelte'
20
+ import Input from './internals/Input.svelte'
21
+ import MultiSelectMelt from './internals/select/MultiSelectMelt.svelte'
22
+ import SelectMelt from './internals/select/SelectMelt.svelte'
23
+ import SelectRadio from './internals/select/SelectRadio.svelte'
24
+ import Textarea from './internals/Textarea.svelte'
25
+ import LinkPlus from './link/LinkPlus.svelte'
26
+
27
+ export let cell: Cell<T>
28
+ export let value: HTMLInputAttributes['value'] = undefined
29
+
30
+ // values of other fields in same context e.g. in form
31
+ export let cellsValues: any = {}
32
+
33
+ export let withDedounce: boolean = false
34
+
35
+ export let error = ''
36
+
37
+ export let mode: 'edit' | 'view' | 'filtre' = 'edit'
38
+
39
+ export let focus: boolean = false
40
+
41
+ export let clearable: boolean | undefined = undefined
42
+ export let disabled = false
43
+
44
+ const dispatch = createEventDispatcher()
45
+
46
+ function dispatchSelected(_data: BaseItem | BaseItem[] | undefined) {
47
+ value = _data
48
+ dispatch('selected', _data)
49
+ }
50
+ $: metaType = getFieldMetaType(cell.field!)
51
+
52
+ const isViewMode = (_mode: 'edit' | 'view' | 'filtre', _field?: FieldMetadata<any, any>) => {
53
+ return _mode === 'view' || _field?.dbReadOnly || _field?.options.allowApiUpdate === false
54
+ }
55
+
56
+ const common = (_field?: FieldMetadata<any, any>, isLight = false) => {
57
+ let toRet = {
58
+ id: _field?.key ?? 'SOMETHING_AT_LEAST',
59
+ disabled: _field?.dbReadOnly || _field?.options.allowApiUpdate === false || disabled,
60
+ placeholder: _field?.options?.placeholder ?? undefined,
61
+ }
62
+ if (isLight) {
63
+ return toRet
64
+ }
65
+ return {
66
+ ...toRet,
67
+ step: _field?.options?.step ?? undefined,
68
+ name: _field?.key,
69
+ // required: _field?.allowNull === false,
70
+ }
71
+ }
72
+
73
+ const toInput = (_metadata?: FieldMetadata<any, any>, _value?: HTMLInputAttributes['value']) => {
74
+ try {
75
+ return _metadata?.valueConverter.toInput(_value, metaType.subKind)
76
+ } catch (error) {
77
+ console.error(`error toInput w field '${_metadata?.key}'`, error)
78
+ }
79
+ }
80
+
81
+ const fromInput = (_metadata: FieldMetadata<any, any>, _value: HTMLInputAttributes['value']) => {
82
+ try {
83
+ // REMULT default for numbers ?
84
+ if (_metadata.allowNull && _value === null) {
85
+ return null
86
+ }
87
+ return _metadata?.valueConverter.fromInput(_value, metaType.subKind)
88
+ } catch (error) {
89
+ console.error(`error fromInput w field '${_metadata.key}'`, error)
90
+ }
91
+ }
92
+
93
+ // let items: any[] = []
94
+
95
+ const getId = () => {
96
+ return value?.id || value
97
+ }
98
+
99
+ const getLoadOptions = async (cellsValues: any, str: string) => {
100
+ if (metaType.kind !== 'relation') {
101
+ return { items: [], totalCount: 0 }
102
+ }
103
+ // To make TS happy
104
+ const metaTypeObj = { ...metaType } as MetaTypeRelation
105
+
106
+ let findToUse: FindOptions<any> = {}
107
+ if (metaTypeObj.repoTarget.metadata.options.searchableFind) {
108
+ // narrowFind at the end because searchableFind should not change the narrowed part!
109
+ findToUse = metaTypeObj.repoTarget.metadata.options.searchableFind(str)
110
+ } else {
111
+ if (str) {
112
+ const field = getFirstInterestingField(metaTypeObj.repoTarget)
113
+ findToUse = { where: { [field.key]: { $contains: str } } }
114
+ }
115
+ }
116
+
117
+ const foEdit = cell.field?.options.findOptionsForEdit
118
+ const narrowFindEditWhere =
119
+ typeof foEdit === 'function'
120
+ ? (foEdit(cellsValues).where ?? {})
121
+ : typeof foEdit === 'object'
122
+ ? (foEdit.where ?? {})
123
+ : {}
124
+
125
+ // @ts-ignore
126
+ const foCrud = cell.field?.options.findOptions
127
+ const narrowFindCrudWhere =
128
+ typeof foCrud === 'function'
129
+ ? (foCrud().where ?? {})
130
+ : typeof foCrud === 'object'
131
+ ? (foCrud.where ?? {})
132
+ : {}
133
+
134
+ findToUse = {
135
+ include: { ...(findToUse.include ?? {}) },
136
+ where: { $and: [findToUse.where, narrowFindEditWhere, narrowFindCrudWhere] },
137
+ }
138
+
139
+ // 24 here is a "magic number"!
140
+ let limit = cell.field?.options.findOptionsLimit ?? 24
141
+
142
+ const arr = []
143
+ arr.push(
144
+ ...(await metaTypeObj.repoTarget.find({
145
+ ...findToUse,
146
+ limit,
147
+ })),
148
+ )
149
+
150
+ let totalCount = arr.length
151
+ // If we are at the limit... there is probably more! How many?
152
+ if (totalCount === limit) {
153
+ const agg = await metaTypeObj.repoTarget.aggregate({ where: findToUse.where })
154
+ totalCount = agg.$count
155
+ }
156
+
157
+ if (!cell.field?.options.multiSelect) {
158
+ // let's get the current item if it's not in the default list (only when there is no searchFilter going on)
159
+ if (str === '' && getId() && !arr.find((r) => String(r.id) === String(getId()))) {
160
+ arr.unshift(await metaTypeObj.repoTarget.findId(getId()))
161
+ }
162
+ }
163
+
164
+ return { items: arr.map((r) => getEntityDisplayValue(metaTypeObj.repoTarget, r)), totalCount }
165
+ }
166
+
167
+ const getMultiValues = (value: any) => {
168
+ return (value ?? []).map((c: any) => c.id) || value
169
+ }
170
+
171
+ const calcSuffix = (value: any) => {
172
+ if (cell.field?.options.suffixEdit) {
173
+ if (cell.field?.options.suffixEditWithS) {
174
+ return suffixWithS(value, cell.field?.options.suffixEdit)
175
+ } else {
176
+ return cell.field?.options.suffixEdit
177
+ }
178
+ }
179
+
180
+ if (cell.field?.options.suffix) {
181
+ if (cell.field?.options.suffixWithS) {
182
+ return suffixWithS(value, cell.field?.options.suffix)
183
+ } else {
184
+ return cell.field?.options.suffix
185
+ }
186
+ }
187
+
188
+ return ''
189
+ }
137
190
  </script>
138
191
 
139
192
  <FieldContainer
@@ -1,4 +1,3 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { HTMLInputAttributes } from 'svelte/elements';
3
2
  import { type Cell } from '../';
4
3
  declare class __sveltets_Render<T extends Record<any, any>> {
@@ -21,10 +20,18 @@ declare class __sveltets_Render<T extends Record<any, any>> {
21
20
  [evt: string]: CustomEvent<any>;
22
21
  };
23
22
  slots(): {};
23
+ bindings(): string;
24
+ exports(): {};
24
25
  }
25
- export type FieldProps<T extends Record<any, any>> = ReturnType<__sveltets_Render<T>['props']>;
26
- export type FieldEvents<T extends Record<any, any>> = ReturnType<__sveltets_Render<T>['events']>;
27
- export type FieldSlots<T extends Record<any, any>> = ReturnType<__sveltets_Render<T>['slots']>;
28
- export default class Field<T extends Record<any, any>> extends SvelteComponent<FieldProps<T>, FieldEvents<T>, FieldSlots<T>> {
26
+ interface $$IsomorphicComponent {
27
+ new <T extends Record<any, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
28
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
29
+ } & ReturnType<__sveltets_Render<T>['exports']>;
30
+ <T extends Record<any, any>>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {
31
+ $$events?: ReturnType<__sveltets_Render<T>['events']>;
32
+ }): ReturnType<__sveltets_Render<T>['exports']>;
33
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
29
34
  }
30
- export {};
35
+ declare const Field: $$IsomorphicComponent;
36
+ type Field<T extends Record<any, any>> = InstanceType<typeof Field<T>>;
37
+ export default Field;
@@ -1,56 +1,77 @@
1
- <script generics="T extends Record<any, any>">import { createEventDispatcher } from "svelte";
2
- import { getRelationFieldInfo } from "remult/internals";
3
- import { tw } from "../";
4
- import Field from "./Field.svelte";
5
- import FieldContainer from "./internals/FieldContainer.svelte";
6
- import Loading from "./Loading.svelte";
7
- export let mode = "edit";
8
- export let cells;
9
- export let store;
10
- export let focusKey = null;
11
- const getError = (errors, field) => {
12
- const fo = getRelationFieldInfo(field);
13
- const keyToUse = fo?.options?.field;
14
- if (errors && keyToUse && errors[keyToUse]) {
15
- return errors[keyToUse];
16
- } else if (errors && errors[field.key]) {
17
- return errors[field.key];
18
- }
19
- return void 0;
20
- };
21
- const shouldHide = (c, mode2) => {
22
- if (mode2 === "edit" && c.modeEdit === "hide") {
23
- return true;
24
- }
25
- if (mode2 === "view" && c.modeView === "hide") {
26
- return true;
27
- }
28
- return false;
29
- };
30
- const modeToUse = (c, mode2) => {
31
- if (mode2 === "edit" && c.modeEdit === "view") {
32
- return "view";
33
- }
34
- if (mode2 === "view" && c.modeView === "edit") {
35
- return "edit";
36
- }
37
- return mode2;
38
- };
39
- const dispatch = createEventDispatcher();
40
- function dispatchChanged(_data) {
41
- dispatch("changed", _data);
42
- }
43
- $: dispatchChanged($store.item);
44
- let size = ["", "w-1/2", "w-1/3", "w-1/4", "w-1/5", "w-1/6"];
45
- function isToFocus(currentKey, focusKey2, i) {
46
- if (focusKey2 === null || focusKey2 === void 0) {
47
- if (i === 0) {
48
- return true;
49
- }
50
- return false;
51
- }
52
- return focusKey2 === currentKey;
53
- }
1
+ <script lang="ts" generics="T extends Record<any, any>">
2
+ import { createEventDispatcher } from 'svelte'
3
+
4
+ import type { FieldMetadata } from 'remult'
5
+ import { getRelationFieldInfo } from 'remult/internals'
6
+
7
+ import { tw, type StoreItem } from '../'
8
+ import type { Cell } from '../cellsBuildor'
9
+ import Field from './Field.svelte'
10
+ import FieldContainer from './internals/FieldContainer.svelte'
11
+ import Loading from './Loading.svelte'
12
+
13
+ type Mode = 'edit' | 'view' | 'filtre'
14
+ export let mode: Mode = 'edit'
15
+
16
+ export let cells: Cell<T>[]
17
+ export let store: StoreItem<T>
18
+
19
+ export let focusKey: string | null | undefined = null
20
+
21
+ const getError = (errors: any, field: FieldMetadata<any, any>) => {
22
+ const fo = getRelationFieldInfo(field)
23
+ const keyToUse = fo?.options?.field
24
+ if (errors && keyToUse && errors[keyToUse]) {
25
+ return errors[keyToUse]
26
+ } else if (errors && errors[field.key]) {
27
+ return errors[field.key]
28
+ }
29
+ return undefined
30
+ }
31
+
32
+ const shouldHide = (c: Cell<T>, mode: Mode) => {
33
+ if (mode === 'edit' && c.modeEdit === 'hide') {
34
+ return true
35
+ }
36
+ if (mode === 'view' && c.modeView === 'hide') {
37
+ return true
38
+ }
39
+ return false
40
+ }
41
+
42
+ const modeToUse = (c: Cell<T>, mode: Mode) => {
43
+ if (mode === 'edit' && c.modeEdit === 'view') {
44
+ return 'view'
45
+ }
46
+ if (mode === 'view' && c.modeView === 'edit') {
47
+ return 'edit'
48
+ }
49
+ return mode
50
+ }
51
+
52
+ const dispatch = createEventDispatcher()
53
+
54
+ function dispatchChanged(_data: T | undefined) {
55
+ dispatch('changed', _data)
56
+ }
57
+
58
+ $: dispatchChanged($store.item)
59
+
60
+ let size = ['', 'w-1/2', 'w-1/3', 'w-1/4', 'w-1/5', 'w-1/6']
61
+
62
+ function isToFocus(
63
+ currentKey: string | undefined,
64
+ focusKey: string | null | undefined,
65
+ i: number,
66
+ ): boolean {
67
+ if (focusKey === null || focusKey === undefined) {
68
+ if (i === 0) {
69
+ return true
70
+ }
71
+ return false
72
+ }
73
+ return focusKey === currentKey
74
+ }
54
75
  </script>
55
76
 
56
77
  {#each cells as cell, i}
@@ -1,4 +1,3 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { FieldMetadata } from 'remult';
3
2
  import { type StoreItem } from '../';
4
3
  import type { Cell } from '../cellsBuildor';
@@ -21,10 +20,22 @@ declare class __sveltets_Render<T extends Record<any, any>> {
21
20
  focus: typeof focus;
22
21
  };
23
22
  };
23
+ bindings(): string;
24
+ exports(): {};
24
25
  }
25
- export type FieldGroupProps<T extends Record<any, any>> = ReturnType<__sveltets_Render<T>['props']>;
26
- export type FieldGroupEvents<T extends Record<any, any>> = ReturnType<__sveltets_Render<T>['events']>;
27
- export type FieldGroupSlots<T extends Record<any, any>> = ReturnType<__sveltets_Render<T>['slots']>;
28
- export default class FieldGroup<T extends Record<any, any>> extends SvelteComponent<FieldGroupProps<T>, FieldGroupEvents<T>, FieldGroupSlots<T>> {
26
+ interface $$IsomorphicComponent {
27
+ new <T extends Record<any, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']> & {
28
+ children?: any;
29
+ }>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
30
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
31
+ } & ReturnType<__sveltets_Render<T>['exports']>;
32
+ <T extends Record<any, any>>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {
33
+ $$events?: ReturnType<__sveltets_Render<T>['events']>;
34
+ $$slots?: ReturnType<__sveltets_Render<T>['slots']>;
35
+ children?: any;
36
+ }): ReturnType<__sveltets_Render<T>['exports']>;
37
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
29
38
  }
30
- export {};
39
+ declare const FieldGroup: $$IsomorphicComponent;
40
+ type FieldGroup<T extends Record<any, any>> = InstanceType<typeof FieldGroup<T>>;
41
+ export default FieldGroup;