@headless-adminapp/app 0.0.17-alpha.42 → 0.0.17-alpha.47
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/board/hooks/useSearchText.js +4 -4
- package/dataform/hooks/index.d.ts +1 -0
- package/dataform/hooks/index.js +1 -0
- package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
- package/dataform/hooks/useProcessFlowSteps.js +44 -0
- package/dataform/hooks/useRecordTitle.d.ts +1 -1
- package/dataform/hooks/useRecordTitle.js +9 -2
- package/dataform/utils/index.js +75 -28
- package/package.json +2 -2
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/utils/getAttributeFormattedValue.d.ts +1 -1
- package/utils/getAttributeFormattedValue.js +102 -67
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSearchText = useSearchText;
|
|
4
|
+
const context_1 = require("@headless-adminapp/app/mutable/context");
|
|
4
5
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
6
|
-
const context_2 = require("@headless-adminapp/app/mutable/context");
|
|
6
|
+
const context_2 = require("../context");
|
|
7
7
|
function useSearchText() {
|
|
8
|
-
const searchText = (0,
|
|
9
|
-
const setValue = (0,
|
|
8
|
+
const searchText = (0, context_1.useContextSelector)(context_2.BoardContext, (context) => context.searchText);
|
|
9
|
+
const setValue = (0, context_1.useContextSetValue)(context_2.BoardContext);
|
|
10
10
|
const setSearchText = (0, react_1.useCallback)((value) => {
|
|
11
11
|
setValue({ searchText: value });
|
|
12
12
|
}, [setValue]);
|
package/dataform/hooks/index.js
CHANGED
|
@@ -26,3 +26,4 @@ __exportStar(require("./useRecordId"), exports);
|
|
|
26
26
|
__exportStar(require("./useRecordTitle"), exports);
|
|
27
27
|
__exportStar(require("./useSelectedForm"), exports);
|
|
28
28
|
__exportStar(require("./useLoadFormGridPage"), exports);
|
|
29
|
+
__exportStar(require("./useProcessFlowSteps"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useProcessFlowSteps(): import("@headless-adminapp/core/experience/form/ProcessFlowInfo").ProcessFlowStep[] | null | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useProcessFlowSteps = useProcessFlowSteps;
|
|
4
|
+
const command_1 = require("@headless-adminapp/app/command");
|
|
5
|
+
const context_1 = require("../../mutable/context");
|
|
6
|
+
const context_2 = require("../context");
|
|
7
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
8
|
+
const useFormIsReadonly_1 = require("./useFormIsReadonly");
|
|
9
|
+
const useFormRecord_1 = require("./useFormRecord");
|
|
10
|
+
const useFormSchema_1 = require("./useFormSchema");
|
|
11
|
+
const useRecordId_1 = require("./useRecordId");
|
|
12
|
+
const useSelectedForm_1 = require("./useSelectedForm");
|
|
13
|
+
function useFormControlContext() {
|
|
14
|
+
var _a;
|
|
15
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
16
|
+
const form = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
17
|
+
const originalData = (0, useFormRecord_1.useFormRecord)();
|
|
18
|
+
const recordId = (0, useRecordId_1.useRecordId)();
|
|
19
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
20
|
+
const readonly = (_a = (0, useFormIsReadonly_1.useFormIsReadonly)()) !== null && _a !== void 0 ? _a : false;
|
|
21
|
+
const data = formInstance.watch();
|
|
22
|
+
return {
|
|
23
|
+
data,
|
|
24
|
+
logicalName: schema.logicalName,
|
|
25
|
+
schema,
|
|
26
|
+
form,
|
|
27
|
+
formId: form.id,
|
|
28
|
+
originalData: originalData !== null && originalData !== void 0 ? originalData : null,
|
|
29
|
+
recordId,
|
|
30
|
+
readonly,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function useProcessFlowInfoContext() {
|
|
34
|
+
const primaryControl = useFormControlContext();
|
|
35
|
+
const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
|
|
36
|
+
return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
|
|
37
|
+
}
|
|
38
|
+
function useProcessFlowSteps() {
|
|
39
|
+
var _a;
|
|
40
|
+
const formConfig = (0, useSelectedForm_1.useSelectedForm)();
|
|
41
|
+
const context = useProcessFlowInfoContext();
|
|
42
|
+
const steps = (_a = formConfig.experience.processFlow) === null || _a === void 0 ? void 0 : _a.getSteps(context);
|
|
43
|
+
return steps;
|
|
44
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useRecordTitle():
|
|
1
|
+
export declare function useRecordTitle(): any;
|
|
@@ -5,11 +5,18 @@ const useFormInstance_1 = require("./useFormInstance");
|
|
|
5
5
|
const useFormSchema_1 = require("./useFormSchema");
|
|
6
6
|
const useRecordId_1 = require("./useRecordId");
|
|
7
7
|
function useRecordTitle() {
|
|
8
|
-
var _a;
|
|
9
8
|
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
10
9
|
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
11
10
|
const recordId = (0, useRecordId_1.useRecordId)();
|
|
12
|
-
|
|
11
|
+
let primaryAttributeValue = formInstance.watch(schema.primaryAttribute);
|
|
12
|
+
const primaryAttribute = schema.attributes[schema.primaryAttribute];
|
|
13
|
+
if ((primaryAttribute === null || primaryAttribute === void 0 ? void 0 : primaryAttribute.type) === 'lookup') {
|
|
14
|
+
// Handle lookup attribute as primary
|
|
15
|
+
primaryAttributeValue = primaryAttributeValue === null || primaryAttributeValue === void 0 ? void 0 : primaryAttributeValue.name;
|
|
16
|
+
}
|
|
17
|
+
if (primaryAttributeValue && typeof primaryAttributeValue !== 'string') {
|
|
18
|
+
return String(primaryAttributeValue);
|
|
19
|
+
}
|
|
13
20
|
if (primaryAttributeValue) {
|
|
14
21
|
return primaryAttributeValue;
|
|
15
22
|
}
|
package/dataform/utils/index.js
CHANGED
|
@@ -303,7 +303,7 @@ exports.generateValidationSchema = (0, lodash_1.memoize)(function generateValida
|
|
|
303
303
|
strings,
|
|
304
304
|
readonlyAttributes,
|
|
305
305
|
}));
|
|
306
|
-
|
|
306
|
+
function createAttributeValidationSchema(attribute) {
|
|
307
307
|
let validationSchema;
|
|
308
308
|
switch (attribute.type) {
|
|
309
309
|
case 'string':
|
|
@@ -321,44 +321,91 @@ exports.generateAttributeValidationSchema = (0, lodash_1.memoize)(function gener
|
|
|
321
321
|
validationSchema = yup.mixed().nullable();
|
|
322
322
|
break;
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
return validationSchema;
|
|
325
|
+
}
|
|
326
|
+
function extendAttributeRequiredValidationSchema({ attribute, validationSchema, label, strings, }) {
|
|
325
327
|
if (attribute.required) {
|
|
326
328
|
validationSchema = validationSchema.required(`${label}: ${strings.required}`);
|
|
327
329
|
}
|
|
330
|
+
return validationSchema;
|
|
331
|
+
}
|
|
332
|
+
function extendAttributeValidationSchema({ attribute, validationSchema, label, strings, }) {
|
|
328
333
|
switch (attribute.type) {
|
|
329
334
|
case 'string':
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
if (attribute.pattern) {
|
|
337
|
-
validationSchema = validationSchema.matches(new RegExp(attribute.pattern), `${label}: ${strings.invalidFormat}`);
|
|
338
|
-
}
|
|
339
|
-
if (attribute.format === 'email') {
|
|
340
|
-
validationSchema = validationSchema.email(`${label}: ${strings.invalidEmail}`);
|
|
341
|
-
}
|
|
342
|
-
else if (attribute.format === 'phone') {
|
|
343
|
-
validationSchema = validationSchema.matches(/^(\+\d{1,2}\s?)?\d{10}$/, `${label}: ${strings.invalidPhoneNumber}`);
|
|
344
|
-
}
|
|
335
|
+
validationSchema = extendAttributeStringValidationSchema({
|
|
336
|
+
attribute,
|
|
337
|
+
validationSchema: validationSchema,
|
|
338
|
+
label,
|
|
339
|
+
strings,
|
|
340
|
+
});
|
|
345
341
|
break;
|
|
346
342
|
case 'attachments':
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
return value.every((file) => (file === null || file === void 0 ? void 0 : file.size) && file.size <= attribute.maxSize);
|
|
356
|
-
});
|
|
357
|
-
}
|
|
343
|
+
validationSchema = extendAttributeAttachmentsValidationSchema({
|
|
344
|
+
attribute,
|
|
345
|
+
validationSchema: validationSchema,
|
|
346
|
+
label,
|
|
347
|
+
strings,
|
|
348
|
+
});
|
|
358
349
|
break;
|
|
359
350
|
default:
|
|
360
351
|
break;
|
|
361
352
|
}
|
|
353
|
+
return validationSchema;
|
|
354
|
+
}
|
|
355
|
+
function extendAttributeStringValidationSchema({ attribute, validationSchema, label, strings, }) {
|
|
356
|
+
if (attribute.maxLength) {
|
|
357
|
+
// extend the validation schema with the max length
|
|
358
|
+
validationSchema = validationSchema.max(attribute.maxLength, `${label}: ${strings.maxLength}`);
|
|
359
|
+
}
|
|
360
|
+
if (attribute.minLength) {
|
|
361
|
+
// extend the validation schema with the min length
|
|
362
|
+
validationSchema = validationSchema.min(attribute.minLength, `${label}: ${strings.minLength}`);
|
|
363
|
+
}
|
|
364
|
+
if (attribute.pattern) {
|
|
365
|
+
// extend the validation schema with the pattern
|
|
366
|
+
validationSchema = validationSchema.matches(new RegExp(attribute.pattern), `${label}: ${strings.invalidFormat}`);
|
|
367
|
+
}
|
|
368
|
+
if (attribute.format === 'email') {
|
|
369
|
+
// extend the validation schema with the email format
|
|
370
|
+
validationSchema = validationSchema.email(`${label}: ${strings.invalidEmail}`);
|
|
371
|
+
}
|
|
372
|
+
else if (attribute.format === 'phone') {
|
|
373
|
+
// extend the validation schema with the phone format
|
|
374
|
+
validationSchema = validationSchema.matches(/^(\+\d{1,2}\s?)?\d{10}$/, `${label}: ${strings.invalidPhoneNumber}`);
|
|
375
|
+
}
|
|
376
|
+
return validationSchema;
|
|
377
|
+
}
|
|
378
|
+
function extendAttributeAttachmentsValidationSchema({ attribute, validationSchema, label, strings, }) {
|
|
379
|
+
if (attribute.required) {
|
|
380
|
+
// extend the validation schema with the min length
|
|
381
|
+
validationSchema = validationSchema.min(1, `${label}: ${strings.required}`);
|
|
382
|
+
}
|
|
383
|
+
if (attribute.maxSize) {
|
|
384
|
+
// extend the validation schema with the max size
|
|
385
|
+
validationSchema = validationSchema.test('fileSize', `${label}: ${strings.fileSizeExceeded}`, (value) => {
|
|
386
|
+
if (!value) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
return value.every((file) => (file === null || file === void 0 ? void 0 : file.size) && file.size <= attribute.maxSize);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
return validationSchema;
|
|
393
|
+
}
|
|
394
|
+
exports.generateAttributeValidationSchema = (0, lodash_1.memoize)(function generateAttributeValidationSchema(attribute, language, strings) {
|
|
395
|
+
let validationSchema = createAttributeValidationSchema(attribute);
|
|
396
|
+
const label = (0, utils_1.localizedLabel)(language, attribute);
|
|
397
|
+
validationSchema = extendAttributeRequiredValidationSchema({
|
|
398
|
+
attribute,
|
|
399
|
+
validationSchema,
|
|
400
|
+
label,
|
|
401
|
+
strings,
|
|
402
|
+
});
|
|
403
|
+
validationSchema = extendAttributeValidationSchema({
|
|
404
|
+
attribute,
|
|
405
|
+
validationSchema,
|
|
406
|
+
label,
|
|
407
|
+
strings,
|
|
408
|
+
});
|
|
362
409
|
validationSchema = validationSchema.transform((value) => {
|
|
363
410
|
if (value === '') {
|
|
364
411
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.47",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"react-hook-form": "7.52.2",
|
|
40
40
|
"yup": "^1.4.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "749a69f512d51c82f33fe27f8bbe5046fdeab4c5"
|
|
43
43
|
}
|
|
@@ -11,7 +11,7 @@ interface UseRetriveRecordProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
|
11
11
|
expand?: Partial<Record<string, string[]>>;
|
|
12
12
|
maxRecords: number;
|
|
13
13
|
}
|
|
14
|
-
export declare function useRetrieveRecordsKey<S extends SchemaAttributes = SchemaAttributes>({ schema, search, filter, sorting, columns, expand, maxRecords, }: UseRetriveRecordProps<S>): (string | number |
|
|
14
|
+
export declare function useRetrieveRecordsKey<S extends SchemaAttributes = SchemaAttributes>({ schema, search, filter, sorting, columns, expand, maxRecords, }: UseRetriveRecordProps<S>): (string | number | string[] | Filter | Partial<Record<string, string[]>> | SortingState<S> | null | undefined)[];
|
|
15
15
|
export declare function useClearDataExceptFirstPage(queryKey: QueryKey): void;
|
|
16
16
|
export declare function useRetriveRecords<S extends SchemaAttributes = SchemaAttributes>(queryKey: QueryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }: UseRetriveRecordProps): {
|
|
17
17
|
data: {
|
|
@@ -13,5 +13,5 @@ export declare function getAttributeFormattedValue<A extends Attribute = Attribu
|
|
|
13
13
|
currencySign?: 'accounting' | 'standard';
|
|
14
14
|
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code';
|
|
15
15
|
timezone?: string;
|
|
16
|
-
}): string | null
|
|
16
|
+
}): string | null;
|
|
17
17
|
export {};
|
|
@@ -19,89 +19,124 @@ const defaultLocale = 'en-US';
|
|
|
19
19
|
const defaultCurrency = 'USD';
|
|
20
20
|
const defaultCurrencySign = 'accounting';
|
|
21
21
|
const defaultCurrencyDisplay = 'symbol';
|
|
22
|
+
function getAttributeLookupsFormattedValue(value, options) {
|
|
23
|
+
const items = value === null || value === void 0 ? void 0 : value.map((v) => v.name);
|
|
24
|
+
if ((options === null || options === void 0 ? void 0 : options.maxCount) && (items === null || items === void 0 ? void 0 : items.length) > options.maxCount) {
|
|
25
|
+
return (items.slice(0, options.maxCount).join(', ') +
|
|
26
|
+
` (+${items.length - options.maxCount})`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return items === null || items === void 0 ? void 0 : items.join(', ');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getAttributeAttachmentFormattedValue(value) {
|
|
33
|
+
var _a;
|
|
34
|
+
return (_a = value === null || value === void 0 ? void 0 : value.url) !== null && _a !== void 0 ? _a : null;
|
|
35
|
+
}
|
|
36
|
+
function getAttributeDateFormattedValue(attribute, value, options) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const dateFormat = (_a = options === null || options === void 0 ? void 0 : options.dateFormat) !== null && _a !== void 0 ? _a : defaultDateFormat;
|
|
39
|
+
const timeFormat = (_b = options === null || options === void 0 ? void 0 : options.timeFormat) !== null && _b !== void 0 ? _b : defaultTimeFormat;
|
|
40
|
+
if (attribute.format === 'datetime') {
|
|
41
|
+
return (0, dayjs_1.default)(value)
|
|
42
|
+
.tz(options === null || options === void 0 ? void 0 : options.timezone)
|
|
43
|
+
.format(dateFormat + ' ' + timeFormat);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return (0, dayjs_1.default)(value)
|
|
47
|
+
.tz(options === null || options === void 0 ? void 0 : options.timezone)
|
|
48
|
+
.format(dateFormat);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function getAttributeDateRangeFormattedValue(value, options) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (!value)
|
|
54
|
+
return null;
|
|
55
|
+
const dateFormat = (_a = options === null || options === void 0 ? void 0 : options.dateFormat) !== null && _a !== void 0 ? _a : defaultDateFormat;
|
|
56
|
+
const from = value[0];
|
|
57
|
+
const to = value[1];
|
|
58
|
+
if (!from && !to) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (from && to) {
|
|
62
|
+
return ((0, dayjs_1.default)(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat) +
|
|
63
|
+
' - ' +
|
|
64
|
+
(0, dayjs_1.default)(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat));
|
|
65
|
+
}
|
|
66
|
+
if (from) {
|
|
67
|
+
return 'After ' + (0, dayjs_1.default)(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
|
|
68
|
+
}
|
|
69
|
+
if (to) {
|
|
70
|
+
return 'Before ' + (0, dayjs_1.default)(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function getAttributeBooleanFormattedValue(attribute, value, options) {
|
|
75
|
+
var _a, _b, _c;
|
|
76
|
+
const strings = (_a = options === null || options === void 0 ? void 0 : options.strings) !== null && _a !== void 0 ? _a : defaultAttributeFormattedValueStrings;
|
|
77
|
+
return value
|
|
78
|
+
? (_b = attribute.trueLabel) !== null && _b !== void 0 ? _b : strings.yes
|
|
79
|
+
: (_c = attribute.falseLabel) !== null && _c !== void 0 ? _c : strings.no;
|
|
80
|
+
}
|
|
81
|
+
function getAttributeChoiceFormattedValue(attribute, value) {
|
|
82
|
+
var _a;
|
|
83
|
+
return ((_a = attribute.options.find((option) => option.value === value)) !== null && _a !== void 0 ? _a : {
|
|
84
|
+
label: '',
|
|
85
|
+
}).label;
|
|
86
|
+
}
|
|
87
|
+
function getAttributeChoicesFormattedValue(attribute, value) {
|
|
88
|
+
return value
|
|
89
|
+
.map((v) => {
|
|
90
|
+
var _a;
|
|
91
|
+
return ((_a = attribute.options.find((option) => option.value === v)) !== null && _a !== void 0 ? _a : {
|
|
92
|
+
label: '',
|
|
93
|
+
}).label;
|
|
94
|
+
})
|
|
95
|
+
.join(', ');
|
|
96
|
+
}
|
|
97
|
+
function getAttributeLookupFormattedValue(value) {
|
|
98
|
+
return value === null || value === void 0 ? void 0 : value.name;
|
|
99
|
+
}
|
|
100
|
+
function getAttributeMoneyFormattedValue(value, options) {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
const locale = (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : defaultLocale;
|
|
103
|
+
const currency = (_b = options === null || options === void 0 ? void 0 : options.currency) !== null && _b !== void 0 ? _b : defaultCurrency;
|
|
104
|
+
const currencySign = (_c = options === null || options === void 0 ? void 0 : options.currencySign) !== null && _c !== void 0 ? _c : defaultCurrencySign;
|
|
105
|
+
const currencyDisplay = (_d = options === null || options === void 0 ? void 0 : options.currencyDisplay) !== null && _d !== void 0 ? _d : defaultCurrencyDisplay;
|
|
106
|
+
return new Intl.NumberFormat(locale, {
|
|
107
|
+
style: 'currency',
|
|
108
|
+
currency,
|
|
109
|
+
currencySign,
|
|
110
|
+
currencyDisplay,
|
|
111
|
+
}).format(value);
|
|
112
|
+
}
|
|
22
113
|
function getAttributeFormattedValue(attribute, value, options) {
|
|
23
|
-
var _a
|
|
114
|
+
var _a;
|
|
24
115
|
if (value === null || value === undefined) {
|
|
25
116
|
return null;
|
|
26
117
|
}
|
|
27
|
-
const
|
|
28
|
-
const dateFormat = (_b = options === null || options === void 0 ? void 0 : options.dateFormat) !== null && _b !== void 0 ? _b : defaultDateFormat;
|
|
29
|
-
const timeFormat = (_c = options === null || options === void 0 ? void 0 : options.timeFormat) !== null && _c !== void 0 ? _c : defaultTimeFormat;
|
|
30
|
-
const locale = (_d = options === null || options === void 0 ? void 0 : options.locale) !== null && _d !== void 0 ? _d : defaultLocale;
|
|
31
|
-
const currency = (_e = options === null || options === void 0 ? void 0 : options.currency) !== null && _e !== void 0 ? _e : defaultCurrency;
|
|
32
|
-
const currencySign = (_f = options === null || options === void 0 ? void 0 : options.currencySign) !== null && _f !== void 0 ? _f : defaultCurrencySign;
|
|
33
|
-
const currencyDisplay = (_g = options === null || options === void 0 ? void 0 : options.currencyDisplay) !== null && _g !== void 0 ? _g : defaultCurrencyDisplay;
|
|
118
|
+
const locale = (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : defaultLocale;
|
|
34
119
|
switch (attribute.type) {
|
|
35
120
|
case 'boolean':
|
|
36
|
-
return value
|
|
37
|
-
? (_h = attribute.trueLabel) !== null && _h !== void 0 ? _h : strings.yes
|
|
38
|
-
: (_j = attribute.falseLabel) !== null && _j !== void 0 ? _j : strings.no;
|
|
121
|
+
return getAttributeBooleanFormattedValue(attribute, value, options);
|
|
39
122
|
case 'choice':
|
|
40
|
-
return (
|
|
41
|
-
label: '',
|
|
42
|
-
}).label;
|
|
123
|
+
return getAttributeChoiceFormattedValue(attribute, value);
|
|
43
124
|
case 'choices':
|
|
44
|
-
return value
|
|
45
|
-
.map((v) => {
|
|
46
|
-
var _a;
|
|
47
|
-
return ((_a = attribute.options.find((option) => option.value === v)) !== null && _a !== void 0 ? _a : {
|
|
48
|
-
label: '',
|
|
49
|
-
}).label;
|
|
50
|
-
})
|
|
51
|
-
.join(', ');
|
|
125
|
+
return getAttributeChoicesFormattedValue(attribute, value);
|
|
52
126
|
case 'date':
|
|
53
|
-
|
|
54
|
-
return (0, dayjs_1.default)(value)
|
|
55
|
-
.tz(options === null || options === void 0 ? void 0 : options.timezone)
|
|
56
|
-
.format(dateFormat + ' ' + timeFormat);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return (0, dayjs_1.default)(value)
|
|
60
|
-
.tz(options === null || options === void 0 ? void 0 : options.timezone)
|
|
61
|
-
.format(dateFormat);
|
|
62
|
-
}
|
|
127
|
+
return getAttributeDateFormattedValue(attribute, value, options);
|
|
63
128
|
case 'daterange':
|
|
64
|
-
|
|
65
|
-
return null;
|
|
66
|
-
const from = value[0];
|
|
67
|
-
const to = value[1];
|
|
68
|
-
if (!from && !to) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
if (from && to) {
|
|
72
|
-
return ((0, dayjs_1.default)(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat) +
|
|
73
|
-
' - ' +
|
|
74
|
-
(0, dayjs_1.default)(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat));
|
|
75
|
-
}
|
|
76
|
-
if (from) {
|
|
77
|
-
return 'After ' + (0, dayjs_1.default)(from).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
|
|
78
|
-
}
|
|
79
|
-
if (to) {
|
|
80
|
-
return 'Before ' + (0, dayjs_1.default)(to).tz(options === null || options === void 0 ? void 0 : options.timezone).format(dateFormat);
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
129
|
+
return getAttributeDateRangeFormattedValue(value, options);
|
|
83
130
|
case 'lookup':
|
|
84
|
-
return value
|
|
131
|
+
return getAttributeLookupFormattedValue(value);
|
|
85
132
|
case 'lookups':
|
|
86
|
-
|
|
87
|
-
if ((options === null || options === void 0 ? void 0 : options.maxCount) && (items === null || items === void 0 ? void 0 : items.length) > options.maxCount) {
|
|
88
|
-
return (items.slice(0, options.maxCount).join(', ') +
|
|
89
|
-
` (+${items.length - options.maxCount})`);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
return items === null || items === void 0 ? void 0 : items.join(', ');
|
|
93
|
-
}
|
|
133
|
+
return getAttributeLookupsFormattedValue(value, options);
|
|
94
134
|
case 'money':
|
|
95
|
-
return
|
|
96
|
-
style: 'currency',
|
|
97
|
-
currency,
|
|
98
|
-
currencySign,
|
|
99
|
-
currencyDisplay,
|
|
100
|
-
}).format(value);
|
|
135
|
+
return getAttributeMoneyFormattedValue(value, options);
|
|
101
136
|
case 'number':
|
|
102
137
|
return new Intl.NumberFormat(locale).format(value);
|
|
103
138
|
case 'attachment':
|
|
104
|
-
return (
|
|
139
|
+
return getAttributeAttachmentFormattedValue(value);
|
|
105
140
|
default:
|
|
106
141
|
return typeof value === 'object'
|
|
107
142
|
? JSON.stringify(value)
|