@dev-crew-berlin/enter-js-utils 0.46.1 → 0.47.1
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/dist/models/field-group.d.ts +3 -10
- package/dist/models/field-group.js +12 -17
- package/dist/models/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2,18 +2,11 @@ import { components } from '../generated/api-schema';
|
|
|
2
2
|
import { Field } from './field';
|
|
3
3
|
export declare type Dictionary<T> = Record<string, T>;
|
|
4
4
|
export declare type FieldGroup = components['schemas']['FieldGroup'];
|
|
5
|
-
export declare type FieldLabels = Record<string, FieldTitle | undefined>;
|
|
6
|
-
export declare type FieldMap = Map<string, Field & {
|
|
7
|
-
group: string;
|
|
8
|
-
}>;
|
|
9
|
-
declare type FieldTitle = string | Dictionary<string>;
|
|
10
5
|
export declare class FieldGroups {
|
|
11
|
-
|
|
12
|
-
get
|
|
13
|
-
get fields():
|
|
6
|
+
private _groups;
|
|
7
|
+
get groups(): Map<string, FieldGroup>;
|
|
8
|
+
get fields(): Map<string, Field>;
|
|
14
9
|
constructor(json: FieldGroup[]);
|
|
15
10
|
toJSON(): FieldGroup[];
|
|
16
|
-
getFieldLabels(): FieldLabels;
|
|
17
11
|
getLabelForField(fieldKey: string, language: string): string;
|
|
18
12
|
}
|
|
19
|
-
export {};
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
export class FieldGroups {
|
|
2
|
-
get
|
|
3
|
-
|
|
2
|
+
get groups() {
|
|
3
|
+
const groups = new Map();
|
|
4
|
+
for (const [index, group] of this._groups.entries()) {
|
|
5
|
+
groups.set(index.toString(), group);
|
|
6
|
+
}
|
|
7
|
+
return groups;
|
|
4
8
|
}
|
|
5
9
|
get fields() {
|
|
6
10
|
const fields = new Map();
|
|
7
|
-
for (const
|
|
11
|
+
for (const group of this._groups) {
|
|
8
12
|
for (const field of group.questions) {
|
|
9
|
-
fields.set(field.name,
|
|
10
|
-
...field,
|
|
11
|
-
group: groupIndex.toString()
|
|
12
|
-
});
|
|
13
|
+
fields.set(field.name, field);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
return fields;
|
|
16
17
|
}
|
|
17
18
|
constructor(json) {
|
|
18
|
-
this.
|
|
19
|
+
this._groups = json;
|
|
19
20
|
}
|
|
20
21
|
toJSON() {
|
|
21
|
-
return this.
|
|
22
|
-
}
|
|
23
|
-
getFieldLabels() {
|
|
24
|
-
const labels = {};
|
|
25
|
-
for (const [fieldKey, field] of this.fields.entries()) {
|
|
26
|
-
labels[fieldKey] = field.title ?? field.name;
|
|
27
|
-
}
|
|
28
|
-
return labels;
|
|
22
|
+
return this._groups;
|
|
29
23
|
}
|
|
30
24
|
getLabelForField(fieldKey, language) {
|
|
31
|
-
const
|
|
25
|
+
const field = this.fields.get(fieldKey);
|
|
26
|
+
const fieldLabel = field?.title ?? field?.name ?? fieldKey;
|
|
32
27
|
const translatedLabel = fieldLabel === undefined || typeof fieldLabel === 'string' ? fieldLabel : fieldLabel[language];
|
|
33
28
|
return translatedLabel ?? fieldKey;
|
|
34
29
|
}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { CheckinJSON } from './checkin';
|
|
|
6
6
|
export { Checkins } from './checkins';
|
|
7
7
|
export type { CheckinsJSON } from './checkins';
|
|
8
8
|
export type { Event, AttendeeUpdatedEvent, AttendeeCreatedEvent, AttendeeRespondedEvent, AttendeeDeletedEvent, CheckinCreatedEvent, CheckinDeletedEvent, PaymentPaidEvent, } from './event';
|
|
9
|
-
export type { FieldGroup
|
|
9
|
+
export type { FieldGroup } from './field-group';
|
|
10
10
|
export { FieldGroups } from './field-group';
|
|
11
11
|
export type { FieldValue } from './field-value';
|
|
12
12
|
export type { StaticField, TextField, EmailField, NumberField, CheckboxField, SingleCheckboxField, RadioField, SingleRadioField, SelectField, Field, } from './field';
|