@headless-adminapp/app 0.0.17-alpha.34 → 0.0.17-alpha.38
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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightExpereince, InsightLookup } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
export declare function InsightsProvider<SA extends SchemaAttributes = SchemaAttributes>({ children, experience, insightLookup, onInsightSelect, }: PropsWithChildren<{
|
|
5
|
+
experience: InsightExpereince<SA>;
|
|
6
|
+
insightLookup: InsightLookup[];
|
|
7
|
+
onInsightSelect: (id: string) => void;
|
|
8
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsightsProvider = InsightsProvider;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const mutable_1 = require("../mutable");
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
function InsightsProvider({ children, experience, insightLookup, onInsightSelect, }) {
|
|
9
|
+
const onInsightSelectRef = (0, react_1.useRef)(onInsightSelect);
|
|
10
|
+
onInsightSelectRef.current = onInsightSelect;
|
|
11
|
+
const onInsightSelectInternal = (0, react_1.useCallback)((id) => {
|
|
12
|
+
onInsightSelectRef.current(id);
|
|
13
|
+
}, [onInsightSelectRef]);
|
|
14
|
+
const insightsValues = (0, mutable_1.useCreateContextStore)({
|
|
15
|
+
experience,
|
|
16
|
+
data: experience.defaultData,
|
|
17
|
+
insightLookup: insightLookup,
|
|
18
|
+
onInsightSelect: onInsightSelectInternal,
|
|
19
|
+
});
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
insightsValues.setValue({
|
|
22
|
+
experience,
|
|
23
|
+
data: experience.defaultData,
|
|
24
|
+
});
|
|
25
|
+
}, [experience, insightLookup]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(context_1.InsightsContext.Provider, { value: insightsValues, children: children }));
|
|
27
|
+
}
|
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.38",
|
|
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": "cf5abc4c56618fcc873bd31e3a26a84a9509edfa"
|
|
43
43
|
}
|
|
@@ -19,7 +19,7 @@ const defaultCurrency = 'USD';
|
|
|
19
19
|
const defaultCurrencySign = 'accounting';
|
|
20
20
|
const defaultCurrencyDisplay = 'symbol';
|
|
21
21
|
function getAttributeFormattedValue(attribute, value, options) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
23
23
|
if (value === null || value === undefined) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
@@ -91,6 +91,8 @@ function getAttributeFormattedValue(attribute, value, options) {
|
|
|
91
91
|
}).format(value);
|
|
92
92
|
case 'number':
|
|
93
93
|
return new Intl.NumberFormat(locale).format(value);
|
|
94
|
+
case 'attachment':
|
|
95
|
+
return (_k = value === null || value === void 0 ? void 0 : value.url) !== null && _k !== void 0 ? _k : null;
|
|
94
96
|
default:
|
|
95
97
|
return typeof value === 'object'
|
|
96
98
|
? JSON.stringify(value)
|