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.
- package/CHANGELOG.md +8 -0
- package/esm/ROUTES.d.ts +2 -0
- package/esm/ROUTES.js +1 -0
- package/esm/api/index.d.ts +8 -0
- package/esm/auth/AuthController.d.ts +12 -23
- package/esm/auth/AuthController.js +12 -31
- package/esm/auth/server/AuthController.server.d.ts +11 -11
- package/esm/auth/server/AuthController.server.js +83 -18
- package/esm/auth/server/helperFirstly.d.ts +1 -1
- package/esm/auth/server/helperFirstly.js +1 -0
- package/esm/auth/server/module.d.ts +3 -6
- package/esm/auth/server/providers/github.d.ts +2 -1
- package/esm/auth/server/providers/github.js +1 -1
- package/esm/auth/static/assets/Page-B0XXxe0N.d.ts +6 -0
- package/esm/auth/static/assets/Page-B0XXxe0N.js +1 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.d.ts +6 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.js +20 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.d.ts +6 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.js +1 -0
- package/esm/auth/static/assets/Page-mK42zGEw.css +1 -0
- package/esm/auth/static/assets/index-C9jzxOBu.d.ts +151 -0
- package/esm/auth/static/assets/index-C9jzxOBu.js +42 -0
- package/esm/auth/static/index.html +2 -2
- package/esm/auth/types.d.ts +26 -3
- package/esm/bin/cmd.js +339 -139
- package/esm/feedback/FeedbackController.js +57 -51
- package/esm/feedback/server/index.d.ts +6 -15
- package/esm/feedback/server/index.js +4 -5
- package/esm/feedback/types.d.ts +14 -0
- package/esm/feedback/types.js +4 -0
- package/esm/feedback/ui/DialogIssue.svelte +78 -62
- package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogIssues.svelte +37 -28
- package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogMilestones.svelte +18 -12
- package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -16
- package/esm/feedback/ui/Feedback.svelte +11 -9
- package/esm/feedback/ui/Feedback.svelte.d.ts +16 -14
- package/esm/mail/server/index.d.ts +9 -2
- package/esm/mail/server/index.js +3 -1
- package/esm/mail/templates/DefaultMail.svelte +64 -44
- package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -26
- package/esm/server/index.d.ts +0 -0
- package/esm/server/index.js +1 -0
- package/esm/storeItem.d.ts +1 -1
- package/esm/storeList.d.ts +1 -1
- package/esm/sveltekit/server/index.d.ts +0 -9
- package/esm/ui/Button.svelte +79 -56
- package/esm/ui/Button.svelte.d.ts +34 -24
- package/esm/ui/Clipboardable.svelte +18 -11
- package/esm/ui/Clipboardable.svelte.d.ts +34 -23
- package/esm/ui/Field.svelte +189 -136
- package/esm/ui/Field.svelte.d.ts +13 -6
- package/esm/ui/FieldGroup.svelte +74 -53
- package/esm/ui/FieldGroup.svelte.d.ts +17 -6
- package/esm/ui/Grid.svelte +110 -86
- package/esm/ui/Grid.svelte.d.ts +17 -6
- package/esm/ui/GridLoading.svelte +10 -5
- package/esm/ui/GridLoading.svelte.d.ts +19 -17
- package/esm/ui/GridPaginate.svelte +30 -23
- package/esm/ui/GridPaginate.svelte.d.ts +21 -19
- package/esm/ui/Icon.svelte +67 -32
- package/esm/ui/Icon.svelte.d.ts +52 -43
- package/esm/ui/Loading.svelte +5 -3
- package/esm/ui/Loading.svelte.d.ts +29 -18
- package/esm/ui/Tooltip.svelte +22 -19
- package/esm/ui/Tooltip.svelte.d.ts +30 -20
- package/esm/ui/dialog/DialogForm.svelte +48 -41
- package/esm/ui/dialog/DialogForm.svelte.d.ts +18 -16
- package/esm/ui/dialog/DialogManagement.svelte.d.ts +22 -21
- package/esm/ui/dialog/DialogPrimitive.svelte +32 -26
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +35 -25
- package/esm/ui/dialog/FormEditAction.svelte +20 -12
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +13 -6
- package/esm/ui/dialog/dialog.d.ts +1 -1
- package/esm/ui/internals/FieldContainer.svelte +13 -6
- package/esm/ui/internals/FieldContainer.svelte.d.ts +37 -28
- package/esm/ui/internals/Input.svelte +110 -76
- package/esm/ui/internals/Input.svelte.d.ts +34 -32
- package/esm/ui/internals/Textarea.svelte +39 -31
- package/esm/ui/internals/Textarea.svelte.d.ts +31 -28
- package/esm/ui/internals/select/MultiSelectMelt.svelte +174 -126
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +29 -27
- package/esm/ui/internals/select/SelectMelt.svelte +168 -133
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +34 -32
- package/esm/ui/internals/select/SelectRadio.svelte +17 -11
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +24 -22
- package/esm/ui/link/Link.svelte +11 -6
- package/esm/ui/link/Link.svelte.d.ts +31 -22
- package/esm/ui/link/LinkPlus.svelte +19 -16
- package/esm/ui/link/LinkPlus.svelte.d.ts +20 -18
- package/esm/vite/index.d.ts +2 -3
- package/esm/vite/index.js +33 -26
- package/package.json +5 -5
- package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +0 -5
- package/esm/auth/static/assets/Page-BUfjaN-D.js +0 -19
- package/esm/auth/static/assets/Page-CJ58H1vl.css +0 -1
- package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +0 -5
- package/esm/auth/static/assets/Page-CaDAqmBS.js +0 -1
- package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +0 -5
- package/esm/auth/static/assets/Page-DhdZddzJ.js +0 -1
- package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +0 -54
- package/esm/auth/static/assets/index-D-Ztdt2o.js +0 -2
- /package/esm/auth/static/assets/{index-BDy4A_14.css → index-DKWpA6v7.css} +0 -0
package/esm/ui/Field.svelte
CHANGED
|
@@ -1,139 +1,192 @@
|
|
|
1
|
-
<script generics="T extends Record<any, any>">
|
|
2
|
-
import {} from
|
|
3
|
-
import {} from
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export let
|
|
28
|
-
export let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
package/esm/ui/Field.svelte.d.ts
CHANGED
|
@@ -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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
35
|
+
declare const Field: $$IsomorphicComponent;
|
|
36
|
+
type Field<T extends Record<any, any>> = InstanceType<typeof Field<T>>;
|
|
37
|
+
export default Field;
|
package/esm/ui/FieldGroup.svelte
CHANGED
|
@@ -1,56 +1,77 @@
|
|
|
1
|
-
<script generics="T extends Record<any, any>">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
39
|
+
declare const FieldGroup: $$IsomorphicComponent;
|
|
40
|
+
type FieldGroup<T extends Record<any, any>> = InstanceType<typeof FieldGroup<T>>;
|
|
41
|
+
export default FieldGroup;
|