@headless-adminapp/app 0.0.17-alpha.40 → 0.0.17-alpha.41
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/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.41",
|
|
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": "2feaed5c73b0732b74518d37af5b5f26925e89d8"
|
|
43
43
|
}
|
|
@@ -7,6 +7,7 @@ export declare function getAttributeFormattedValue<A extends Attribute = Attribu
|
|
|
7
7
|
maxCount?: number;
|
|
8
8
|
strings?: AttributeFormattedValueStringsSet;
|
|
9
9
|
dateFormat?: string;
|
|
10
|
+
timeFormat?: string;
|
|
10
11
|
locale?: string;
|
|
11
12
|
currency?: string;
|
|
12
13
|
currencySign?: 'accounting' | 'standard';
|
|
@@ -14,28 +14,30 @@ const defaultAttributeFormattedValueStrings = {
|
|
|
14
14
|
no: 'No',
|
|
15
15
|
};
|
|
16
16
|
const defaultDateFormat = 'YYYY-MM-DD';
|
|
17
|
+
const defaultTimeFormat = 'HH:mm';
|
|
17
18
|
const defaultLocale = 'en-US';
|
|
18
19
|
const defaultCurrency = 'USD';
|
|
19
20
|
const defaultCurrencySign = 'accounting';
|
|
20
21
|
const defaultCurrencyDisplay = 'symbol';
|
|
21
22
|
function getAttributeFormattedValue(attribute, value, options) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
23
24
|
if (value === null || value === undefined) {
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
26
27
|
const strings = (_a = options === null || options === void 0 ? void 0 : options.strings) !== null && _a !== void 0 ? _a : defaultAttributeFormattedValueStrings;
|
|
27
28
|
const dateFormat = (_b = options === null || options === void 0 ? void 0 : options.dateFormat) !== null && _b !== void 0 ? _b : defaultDateFormat;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
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;
|
|
32
34
|
switch (attribute.type) {
|
|
33
35
|
case 'boolean':
|
|
34
36
|
return value
|
|
35
|
-
? (
|
|
36
|
-
: (
|
|
37
|
+
? (_h = attribute.trueLabel) !== null && _h !== void 0 ? _h : strings.yes
|
|
38
|
+
: (_j = attribute.falseLabel) !== null && _j !== void 0 ? _j : strings.no;
|
|
37
39
|
case 'choice':
|
|
38
|
-
return ((
|
|
40
|
+
return ((_k = attribute.options.find((option) => option.value === value)) !== null && _k !== void 0 ? _k : {
|
|
39
41
|
label: '',
|
|
40
42
|
}).label;
|
|
41
43
|
case 'choices':
|
|
@@ -48,9 +50,16 @@ function getAttributeFormattedValue(attribute, value, options) {
|
|
|
48
50
|
})
|
|
49
51
|
.join(', ');
|
|
50
52
|
case 'date':
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
if (attribute.format === 'date') {
|
|
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
|
+
}
|
|
54
63
|
case 'daterange':
|
|
55
64
|
if (!value)
|
|
56
65
|
return null;
|
|
@@ -92,7 +101,7 @@ function getAttributeFormattedValue(attribute, value, options) {
|
|
|
92
101
|
case 'number':
|
|
93
102
|
return new Intl.NumberFormat(locale).format(value);
|
|
94
103
|
case 'attachment':
|
|
95
|
-
return (
|
|
104
|
+
return (_l = value === null || value === void 0 ? void 0 : value.url) !== null && _l !== void 0 ? _l : null;
|
|
96
105
|
default:
|
|
97
106
|
return typeof value === 'object'
|
|
98
107
|
? JSON.stringify(value)
|