@aehrc/smart-forms-renderer 1.2.2 → 1.2.3
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/lib/hooks/useCalculatedExpressionUpdated.js +3 -1
- package/lib/hooks/useCalculatedExpressionUpdated.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useCalculatedExpressionUpdated.ts +3 -1
- package/lib/components/FormComponents/ItemParts/FadingCheckIcon.d.ts +0 -7
- package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js +0 -26
- package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js.map +0 -1
- package/lib/components/FormComponents/ItemParts/ItemLabelText.d.ts +0 -8
- package/lib/components/FormComponents/ItemParts/ItemLabelText.js +0 -63
- package/lib/components/FormComponents/ItemParts/ItemLabelText.js.map +0 -1
- package/lib/components/FormComponents/ItemParts/ItemLabelWrapper.d.ts +0 -8
- package/lib/components/FormComponents/ItemParts/ItemLabelWrapper.js +0 -53
- package/lib/components/FormComponents/ItemParts/ItemLabelWrapper.js.map +0 -1
- package/lib/components/FormComponents/RepeatGroup/DeleteItemButton.d.ts +0 -10
- package/lib/components/FormComponents/RepeatGroup/DeleteItemButton.js +0 -30
- package/lib/components/FormComponents/RepeatGroup/DeleteItemButton.js.map +0 -1
- package/lib/components/Iconify/Iconify.d.ts +0 -10
- package/lib/components/Iconify/Iconify.js +0 -26
- package/lib/components/Iconify/Iconify.js.map +0 -1
- package/lib/components/Renderer/FormBodyPage.d.ts +0 -9
- package/lib/components/Renderer/FormBodyPage.js +0 -43
- package/lib/components/Renderer/FormBodyPage.js.map +0 -1
- package/lib/components/Renderer/FormTitle.d.ts +0 -7
- package/lib/components/Renderer/FormTitle.js +0 -30
- package/lib/components/Renderer/FormTitle.js.map +0 -1
- package/lib/components/Renderer/FormTopLevelPage.d.ts +0 -9
- package/lib/components/Renderer/FormTopLevelPage.js +0 -29
- package/lib/components/Renderer/FormTopLevelPage.js.map +0 -1
- package/lib/hooks/useBooleanCalculatedExpression.d.ts +0 -12
- package/lib/hooks/useBooleanCalculatedExpression.js +0 -53
- package/lib/hooks/useBooleanCalculatedExpression.js.map +0 -1
- package/lib/hooks/useDecimalCalculatedExpression.d.ts +0 -13
- package/lib/hooks/useDecimalCalculatedExpression.js +0 -59
- package/lib/hooks/useDecimalCalculatedExpression.js.map +0 -1
- package/lib/hooks/useIntegerCalculatedExpression.d.ts +0 -12
- package/lib/hooks/useIntegerCalculatedExpression.js +0 -56
- package/lib/hooks/useIntegerCalculatedExpression.js.map +0 -1
- package/lib/hooks/useQuantityCalculatedExpression.d.ts +0 -14
- package/lib/hooks/useQuantityCalculatedExpression.js +0 -107
- package/lib/hooks/useQuantityCalculatedExpression.js.map +0 -1
- package/lib/hooks/useStringCalculatedExpression.d.ts +0 -12
- package/lib/hooks/useStringCalculatedExpression.js +0 -58
- package/lib/hooks/useStringCalculatedExpression.js.map +0 -1
- package/lib/stories/storybookWrappers/InitialiseFormWrapperForStorybook.d.ts +0 -31
- package/lib/stories/storybookWrappers/InitialiseFormWrapperForStorybook.js +0 -67
- package/lib/stories/storybookWrappers/InitialiseFormWrapperForStorybook.js.map +0 -1
- package/lib/stories/storybookWrappers/index.d.ts +0 -2
- package/lib/stories/storybookWrappers/index.js +0 -18
- package/lib/stories/storybookWrappers/index.js.map +0 -1
- package/lib/theme/Theme.d.ts +0 -44
- package/lib/theme/Theme.js +0 -43
- package/lib/theme/Theme.js.map +0 -1
- package/lib/theme/customGlobalStyles.d.ts +0 -2
- package/lib/theme/customGlobalStyles.js +0 -61
- package/lib/theme/customGlobalStyles.js.map +0 -1
- package/lib/theme/overrides/Accordion.d.ts +0 -14
- package/lib/theme/overrides/Accordion.js +0 -32
- package/lib/theme/overrides/Accordion.js.map +0 -1
- package/lib/theme/overrides/Autocomplete.d.ts +0 -10
- package/lib/theme/overrides/Autocomplete.js +0 -28
- package/lib/theme/overrides/Autocomplete.js.map +0 -1
- package/lib/theme/overrides/Button.d.ts +0 -33
- package/lib/theme/overrides/Button.js +0 -52
- package/lib/theme/overrides/Button.js.map +0 -1
- package/lib/theme/overrides/Card.d.ts +0 -35
- package/lib/theme/overrides/Card.js +0 -49
- package/lib/theme/overrides/Card.js.map +0 -1
- package/lib/theme/overrides/Input.d.ts +0 -64
- package/lib/theme/overrides/Input.js +0 -81
- package/lib/theme/overrides/Input.js.map +0 -1
- package/lib/theme/overrides/Overrides.d.ts +0 -3
- package/lib/theme/overrides/Overrides.js +0 -29
- package/lib/theme/overrides/Overrides.js.map +0 -1
- package/lib/theme/overrides/Paper.d.ts +0 -12
- package/lib/theme/overrides/Paper.js +0 -31
- package/lib/theme/overrides/Paper.js.map +0 -1
- package/lib/theme/overrides/SpeedDial.d.ts +0 -16
- package/lib/theme/overrides/SpeedDial.js +0 -34
- package/lib/theme/overrides/SpeedDial.js.map +0 -1
- package/lib/theme/overrides/Table.d.ts +0 -12
- package/lib/theme/overrides/Table.js +0 -30
- package/lib/theme/overrides/Table.js.map +0 -1
- package/lib/theme/palette.d.ts +0 -27
- package/lib/theme/palette.js +0 -63
- package/lib/theme/palette.js.map +0 -1
- package/lib/theme/shadows.d.ts +0 -2
- package/lib/theme/shadows.js +0 -52
- package/lib/theme/shadows.js.map +0 -1
- package/lib/utils/dayjsExtend.d.ts +0 -1
- package/lib/utils/dayjsExtend.js +0 -22
- package/lib/utils/dayjsExtend.js.map +0 -1
- package/lib/utils/itemControl.d.ts +0 -103
- package/lib/utils/itemControl.js +0 -350
- package/lib/utils/itemControl.js.map +0 -1
- package/lib/utils/questionnaireStoreUtils/addAdditionalVariables.d.ts +0 -2
- package/lib/utils/questionnaireStoreUtils/addAdditionalVariables.js +0 -43
- package/lib/utils/questionnaireStoreUtils/addAdditionalVariables.js.map +0 -1
- package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.d.ts +0 -3
- package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js +0 -101
- package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js.map +0 -1
- package/lib/utils/validateQuestionnaire.d.ts +0 -66
- package/lib/utils/validateQuestionnaire.js +0 -559
- package/lib/utils/validateQuestionnaire.js.map +0 -1
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { useEffect, useState } from 'react';
|
|
18
|
-
import { useQuestionnaireStore } from '../stores';
|
|
19
|
-
function useDecimalCalculatedExpression(props) {
|
|
20
|
-
const { qItem, inputValue, precision, onChangeByCalcExpressionDecimal, onChangeByCalcExpressionNull } = props;
|
|
21
|
-
const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();
|
|
22
|
-
const [calcExpUpdated, setCalcExpUpdated] = useState(false);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
var _a;
|
|
25
|
-
const calcExpression = (_a = calculatedExpressions[qItem.linkId]) === null || _a === void 0 ? void 0 : _a.find((exp) => exp.from === 'item');
|
|
26
|
-
if (!calcExpression) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
// only update if calculated value is different from current value
|
|
30
|
-
if (calcExpression.value !== inputValue &&
|
|
31
|
-
(typeof calcExpression.value === 'number' || calcExpression.value === null)) {
|
|
32
|
-
const calcExpressionValue = typeof calcExpression.value === 'number' && typeof precision === 'number'
|
|
33
|
-
? parseFloat(calcExpression.value.toFixed(precision))
|
|
34
|
-
: calcExpression.value;
|
|
35
|
-
// only update if calculated value is different from current value
|
|
36
|
-
if (calcExpressionValue !== parseFloat(inputValue)) {
|
|
37
|
-
// update ui to show calculated value changes
|
|
38
|
-
setCalcExpUpdated(true);
|
|
39
|
-
const timeoutId = setTimeout(() => {
|
|
40
|
-
setCalcExpUpdated(false);
|
|
41
|
-
}, 500);
|
|
42
|
-
// calculatedExpression value is null
|
|
43
|
-
if (calcExpressionValue === null) {
|
|
44
|
-
onChangeByCalcExpressionNull();
|
|
45
|
-
return () => clearTimeout(timeoutId);
|
|
46
|
-
}
|
|
47
|
-
// calculatedExpression value is a number
|
|
48
|
-
onChangeByCalcExpressionDecimal(calcExpressionValue);
|
|
49
|
-
return () => clearTimeout(timeoutId);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
// Only trigger this effect if calculatedExpression of item changes
|
|
54
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
-
[calculatedExpressions]);
|
|
56
|
-
return { calcExpUpdated: calcExpUpdated };
|
|
57
|
-
}
|
|
58
|
-
export default useDecimalCalculatedExpression;
|
|
59
|
-
//# sourceMappingURL=useDecimalCalculatedExpression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDecimalCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useDecimalCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAclD,SAAS,8BAA8B,CACrC,KAA0C;IAE1C,MAAM,EACJ,KAAK,EACL,UAAU,EACV,SAAS,EACT,+BAA+B,EAC/B,4BAA4B,EAC7B,GAAG,KAAK,CAAC;IAEV,MAAM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B,CAAC,mBAAmB,CAAC,CAAC;gBACrD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IACD,mEAAmE;IACnE,uDAAuD;IACvD,CAAC,qBAAqB,CAAC,CACxB,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC5C,CAAC;AAED,eAAe,8BAA8B,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { QuestionnaireItem } from 'fhir/r4';
|
|
2
|
-
interface UseIntegerCalculatedExpression {
|
|
3
|
-
calcExpUpdated: boolean;
|
|
4
|
-
}
|
|
5
|
-
interface useIntegerCalculatedExpressionProps {
|
|
6
|
-
qItem: QuestionnaireItem;
|
|
7
|
-
inputValue: string;
|
|
8
|
-
onChangeByCalcExpressionInteger: (calcExpressionValue: number) => void;
|
|
9
|
-
onChangeByCalcExpressionNull: () => void;
|
|
10
|
-
}
|
|
11
|
-
declare function useIntegerCalculatedExpression(props: useIntegerCalculatedExpressionProps): UseIntegerCalculatedExpression;
|
|
12
|
-
export default useIntegerCalculatedExpression;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { useEffect, useState } from 'react';
|
|
18
|
-
import { useQuestionnaireStore } from '../stores';
|
|
19
|
-
function useIntegerCalculatedExpression(props) {
|
|
20
|
-
const { qItem, inputValue, onChangeByCalcExpressionInteger, onChangeByCalcExpressionNull } = props;
|
|
21
|
-
const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();
|
|
22
|
-
const [calcExpUpdated, setCalcExpUpdated] = useState(false);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
var _a;
|
|
25
|
-
const calcExpression = (_a = calculatedExpressions[qItem.linkId]) === null || _a === void 0 ? void 0 : _a.find((exp) => exp.from === 'item');
|
|
26
|
-
if (!calcExpression) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
// only update if calculated value is different from current value
|
|
30
|
-
if (calcExpression.value !== inputValue &&
|
|
31
|
-
(typeof calcExpression.value === 'number' || calcExpression.value === null)) {
|
|
32
|
-
const calcExpressionValue = calcExpression.value;
|
|
33
|
-
if (calcExpressionValue !== parseInt(inputValue)) {
|
|
34
|
-
// update ui to show calculated value changes
|
|
35
|
-
setCalcExpUpdated(true);
|
|
36
|
-
const timeoutId = setTimeout(() => {
|
|
37
|
-
setCalcExpUpdated(false);
|
|
38
|
-
}, 500);
|
|
39
|
-
// calculatedExpression value is null
|
|
40
|
-
if (calcExpressionValue === null) {
|
|
41
|
-
onChangeByCalcExpressionNull();
|
|
42
|
-
return () => clearTimeout(timeoutId);
|
|
43
|
-
}
|
|
44
|
-
// calculatedExpression value is a number
|
|
45
|
-
onChangeByCalcExpressionInteger(calcExpressionValue);
|
|
46
|
-
return () => clearTimeout(timeoutId);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
// Only trigger this effect if calculatedExpression of item changes
|
|
51
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
|
-
[calculatedExpressions]);
|
|
53
|
-
return { calcExpUpdated: calcExpUpdated };
|
|
54
|
-
}
|
|
55
|
-
export default useIntegerCalculatedExpression;
|
|
56
|
-
//# sourceMappingURL=useIntegerCalculatedExpression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIntegerCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useIntegerCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAalD,SAAS,8BAA8B,CACrC,KAA0C;IAE1C,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,GACxF,KAAK,CAAC;IAER,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAEhF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,SAAS,CACP,GAAG,EAAE;;QACH,MAAM,cAAc,GAAG,MAAA,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,0CAAE,IAAI,CAC9D,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAC7B,CAAC;QAEF,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,kEAAkE;QAClE,IACE,cAAc,CAAC,KAAK,KAAK,UAAU;YACnC,CAAC,OAAO,cAAc,CAAC,KAAK,KAAK,QAAQ,IAAI,cAAc,CAAC,KAAK,KAAK,IAAI,CAAC,EAC3E,CAAC;YACD,MAAM,mBAAmB,GAAG,cAAc,CAAC,KAAK,CAAC;YAEjD,IAAI,mBAAmB,KAAK,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBACjD,6CAA6C;gBAC7C,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBACxB,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;oBAChC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;gBAER,qCAAqC;gBACrC,IAAI,mBAAmB,KAAK,IAAI,EAAE,CAAC;oBACjC,4BAA4B,EAAE,CAAC;oBAC/B,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;gBACvC,CAAC;gBAED,yCAAyC;gBACzC,+BAA+B,CAAC,mBAAmB,CAAC,CAAC;gBACrD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IACD,mEAAmE;IACnE,uDAAuD;IACvD,CAAC,qBAAqB,CAAC,CACxB,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC5C,CAAC;AAED,eAAe,8BAA8B,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { QuestionnaireItem } from 'fhir/r4';
|
|
2
|
-
interface UseQuantityCalculatedExpression {
|
|
3
|
-
calcExpUpdated: boolean;
|
|
4
|
-
}
|
|
5
|
-
interface UseQuantityCalculatedExpressionProps {
|
|
6
|
-
qItem: QuestionnaireItem;
|
|
7
|
-
inputValue: string;
|
|
8
|
-
precision: number | null;
|
|
9
|
-
onChangeByCalcExpressionDecimal: (newValue: number) => void;
|
|
10
|
-
onChangeByCalcExpressionQuantity: (newValue: number, newUnitSystem: string, newUnitCode: string, newUnitDisplay: string) => void;
|
|
11
|
-
onChangeByCalcExpressionNull: () => void;
|
|
12
|
-
}
|
|
13
|
-
declare function useQuantityCalculatedExpression(props: UseQuantityCalculatedExpressionProps): UseQuantityCalculatedExpression;
|
|
14
|
-
export default useQuantityCalculatedExpression;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { useEffect, useState } from 'react';
|
|
18
|
-
import { useQuestionnaireStore } from '../stores';
|
|
19
|
-
import { validateCodePromise } from '../utils/valueSet';
|
|
20
|
-
import { TERMINOLOGY_SERVER_URL } from '../globals';
|
|
21
|
-
function useQuantityCalculatedExpression(props) {
|
|
22
|
-
const { qItem, inputValue, precision, onChangeByCalcExpressionDecimal, onChangeByCalcExpressionQuantity, onChangeByCalcExpressionNull } = props;
|
|
23
|
-
const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();
|
|
24
|
-
const [calcExpUpdated, setCalcExpUpdated] = useState(false);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
var _a;
|
|
27
|
-
const calcExpression = (_a = calculatedExpressions[qItem.linkId]) === null || _a === void 0 ? void 0 : _a.find((exp) => exp.from === 'item');
|
|
28
|
-
if (!calcExpression) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
// only update if calculated value is different from current value
|
|
32
|
-
if (calcExpression.value !== inputValue &&
|
|
33
|
-
(typeof calcExpression.value === 'number' ||
|
|
34
|
-
typeof calcExpression.value === 'string' ||
|
|
35
|
-
calcExpression.value === null)) {
|
|
36
|
-
// Null path
|
|
37
|
-
if (calcExpression.value === null) {
|
|
38
|
-
onChangeByCalcExpressionNull();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
// Number path
|
|
42
|
-
if (typeof calcExpression.value === 'number') {
|
|
43
|
-
const calcExpressionValue = typeof precision === 'number'
|
|
44
|
-
? parseFloat(calcExpression.value.toFixed(precision))
|
|
45
|
-
: calcExpression.value;
|
|
46
|
-
// only update if calculated value is different from current value
|
|
47
|
-
if (calcExpressionValue !== parseFloat(inputValue)) {
|
|
48
|
-
// update ui to show calculated value changes
|
|
49
|
-
setCalcExpUpdated(true);
|
|
50
|
-
const timeoutId = setTimeout(() => {
|
|
51
|
-
setCalcExpUpdated(false);
|
|
52
|
-
}, 500);
|
|
53
|
-
// calculatedExpression value is null
|
|
54
|
-
if (calcExpressionValue === null) {
|
|
55
|
-
onChangeByCalcExpressionNull();
|
|
56
|
-
return () => clearTimeout(timeoutId);
|
|
57
|
-
}
|
|
58
|
-
// calculatedExpression value is a number
|
|
59
|
-
onChangeByCalcExpressionDecimal(calcExpressionValue);
|
|
60
|
-
return () => clearTimeout(timeoutId);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// String path (quantity)
|
|
64
|
-
if (typeof calcExpression.value === 'string') {
|
|
65
|
-
try {
|
|
66
|
-
const [value, unitCode] = calcExpression.value.split(' ');
|
|
67
|
-
const unitCodeFormatted = unitCode.replace(/'/g, '');
|
|
68
|
-
const ucumValueSet = 'http://hl7.org/fhir/ValueSet/ucum-units';
|
|
69
|
-
const ucumSystem = 'http://unitsofmeasure.org';
|
|
70
|
-
validateCodePromise(ucumValueSet, ucumSystem, unitCodeFormatted, TERMINOLOGY_SERVER_URL).then((validateCodeResponse) => {
|
|
71
|
-
// Return early if validate-code request fails
|
|
72
|
-
if (!validateCodeResponse) {
|
|
73
|
-
onChangeByCalcExpressionNull();
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (validateCodeResponse.parameter) {
|
|
77
|
-
const systemParameter = validateCodeResponse.parameter.find((p) => p.name === 'system');
|
|
78
|
-
const codeParameter = validateCodeResponse.parameter.find((p) => p.name === 'code');
|
|
79
|
-
const displayParameter = validateCodeResponse.parameter.find((p) => p.name === 'display');
|
|
80
|
-
if (systemParameter.valueUri &&
|
|
81
|
-
codeParameter.valueCode &&
|
|
82
|
-
displayParameter.valueString) {
|
|
83
|
-
// update ui to show calculated value changes
|
|
84
|
-
setCalcExpUpdated(true);
|
|
85
|
-
const timeoutId = setTimeout(() => {
|
|
86
|
-
setCalcExpUpdated(false);
|
|
87
|
-
}, 500);
|
|
88
|
-
onChangeByCalcExpressionQuantity(parseFloat(value), systemParameter.valueUri, codeParameter.valueCode, displayParameter.valueString);
|
|
89
|
-
return () => clearTimeout(timeoutId);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
console.error(e);
|
|
96
|
-
onChangeByCalcExpressionNull();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
// Only trigger this effect if calculatedExpression of item changes
|
|
102
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
-
[calculatedExpressions]);
|
|
104
|
-
return { calcExpUpdated: calcExpUpdated };
|
|
105
|
-
}
|
|
106
|
-
export default useQuantityCalculatedExpression;
|
|
107
|
-
//# sourceMappingURL=useQuantityCalculatedExpression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useQuantityCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useQuantityCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAyBpD,SAAS,+BAA+B,CACtC,KAA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
|
4
|
-
}
|
|
5
|
-
interface useStringCalculatedExpressionProps {
|
|
6
|
-
qItem: QuestionnaireItem;
|
|
7
|
-
inputValue: string;
|
|
8
|
-
onChangeByCalcExpressionString: (newValueString: string) => void;
|
|
9
|
-
onChangeByCalcExpressionNull: () => void;
|
|
10
|
-
}
|
|
11
|
-
declare function useStringCalculatedExpression(props: useStringCalculatedExpressionProps): UseStringCalculatedExpression;
|
|
12
|
-
export default useStringCalculatedExpression;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { useEffect, useState } from 'react';
|
|
18
|
-
import { useQuestionnaireStore } from '../stores';
|
|
19
|
-
function useStringCalculatedExpression(props) {
|
|
20
|
-
const { qItem, inputValue, onChangeByCalcExpressionString, onChangeByCalcExpressionNull } = props;
|
|
21
|
-
const calculatedExpressions = useQuestionnaireStore.use.calculatedExpressions();
|
|
22
|
-
const [calcExpUpdated, setCalcExpUpdated] = useState(false);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
var _a;
|
|
25
|
-
const calcExpression = (_a = calculatedExpressions[qItem.linkId]) === null || _a === void 0 ? void 0 : _a.find((exp) => exp.from === 'item');
|
|
26
|
-
if (!calcExpression) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
// only update if calculated value is different from current value
|
|
30
|
-
if (calcExpression.value !== inputValue &&
|
|
31
|
-
(typeof calcExpression.value === 'string' ||
|
|
32
|
-
typeof calcExpression.value === 'number' ||
|
|
33
|
-
calcExpression.value === null)) {
|
|
34
|
-
// update ui to show calculated value changes
|
|
35
|
-
setCalcExpUpdated(true);
|
|
36
|
-
const timeoutId = setTimeout(() => {
|
|
37
|
-
setCalcExpUpdated(false);
|
|
38
|
-
}, 500);
|
|
39
|
-
// calculatedExpression value is null
|
|
40
|
-
if (calcExpression.value === null) {
|
|
41
|
-
onChangeByCalcExpressionNull();
|
|
42
|
-
return () => clearTimeout(timeoutId);
|
|
43
|
-
}
|
|
44
|
-
// calculatedExpression value is a string or number
|
|
45
|
-
const newInputValue = typeof calcExpression.value === 'string'
|
|
46
|
-
? calcExpression.value
|
|
47
|
-
: calcExpression.value.toString();
|
|
48
|
-
onChangeByCalcExpressionString(newInputValue);
|
|
49
|
-
return () => clearTimeout(timeoutId);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
// Only trigger this effect if calculatedExpression of item changes
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
-
[calculatedExpressions]);
|
|
55
|
-
return { calcExpUpdated: calcExpUpdated };
|
|
56
|
-
}
|
|
57
|
-
export default useStringCalculatedExpression;
|
|
58
|
-
//# sourceMappingURL=useStringCalculatedExpression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStringCalculatedExpression.js","sourceRoot":"","sources":["../../src/hooks/useStringCalculatedExpression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAalD,SAAS,6BAA6B,CACpC,KAAyC;IAEzC,MAAM,EAAE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,CAAC,CAAC;YAC9C,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,mEAAmE;IACnE,uDAAuD;IACvD,CAAC,qBAAqB,CAAC,CACxB,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC5C,CAAC;AAED,eAAe,6BAA6B,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
3
|
-
import type Client from 'fhirclient/lib/Client';
|
|
4
|
-
export interface InitialiseFormWrapperProps {
|
|
5
|
-
questionnaire: Questionnaire;
|
|
6
|
-
questionnaireResponse?: QuestionnaireResponse;
|
|
7
|
-
readOnly?: boolean;
|
|
8
|
-
terminologyServerUrl?: string;
|
|
9
|
-
additionalVariables?: Record<string, object>;
|
|
10
|
-
fhirClient?: Client;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* This is a one-to-one replacement for the SmartFormsRenderer for demo purposes.
|
|
14
|
-
* Instead of using this React component, define your own wrapper component that uses the BaseRenderer directly.
|
|
15
|
-
* Things to note:
|
|
16
|
-
* - It is required to wrap the BaseRenderer with the QueryClientProvider to make requests.
|
|
17
|
-
* - You can wrap the BaseRenderer with the RendererThemeProvider to apply the default renderer theme used in Smart Forms. Optionally, you can define your own ThemeProvider https://mui.com/material-ui/customization/theming/.
|
|
18
|
-
* - Make your buildForm() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form.
|
|
19
|
-
* - Make your own initialiseFhirClient() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form.
|
|
20
|
-
* - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities.
|
|
21
|
-
*
|
|
22
|
-
* For button click usage examples of buildForm(), see:
|
|
23
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx
|
|
24
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx
|
|
25
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx
|
|
26
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopButtonForStorybook.tsx
|
|
27
|
-
*
|
|
28
|
-
* @author Sean Fong
|
|
29
|
-
*/
|
|
30
|
-
declare function InitialiseFormWrapperForStorybook(props: InitialiseFormWrapperProps): React.JSX.Element;
|
|
31
|
-
export default InitialiseFormWrapperForStorybook;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
import React from 'react';
|
|
19
|
-
import { BaseRenderer } from '../../components';
|
|
20
|
-
import { QueryClientProvider } from '@tanstack/react-query';
|
|
21
|
-
import RendererThemeProvider from '../../theme/Theme';
|
|
22
|
-
import useRendererQueryClient from '../../hooks/useRendererQueryClient';
|
|
23
|
-
import useInitialiseForm from '../../hooks/useInitialiseForm';
|
|
24
|
-
import Box from '@mui/material/Box';
|
|
25
|
-
import CircularProgress from '@mui/material/CircularProgress';
|
|
26
|
-
import Typography from '@mui/material/Typography';
|
|
27
|
-
/**
|
|
28
|
-
* This is a one-to-one replacement for the SmartFormsRenderer for demo purposes.
|
|
29
|
-
* Instead of using this React component, define your own wrapper component that uses the BaseRenderer directly.
|
|
30
|
-
* Things to note:
|
|
31
|
-
* - It is required to wrap the BaseRenderer with the QueryClientProvider to make requests.
|
|
32
|
-
* - You can wrap the BaseRenderer with the RendererThemeProvider to apply the default renderer theme used in Smart Forms. Optionally, you can define your own ThemeProvider https://mui.com/material-ui/customization/theming/.
|
|
33
|
-
* - Make your buildForm() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form.
|
|
34
|
-
* - Make your own initialiseFhirClient() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form.
|
|
35
|
-
* - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities.
|
|
36
|
-
*
|
|
37
|
-
* For button click usage examples of buildForm(), see:
|
|
38
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx
|
|
39
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx
|
|
40
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopWrapperForStorybook.tsx
|
|
41
|
-
* - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/PrePopButtonForStorybook.tsx
|
|
42
|
-
*
|
|
43
|
-
* @author Sean Fong
|
|
44
|
-
*/
|
|
45
|
-
function InitialiseFormWrapperForStorybook(props) {
|
|
46
|
-
const { questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables, fhirClient } = props;
|
|
47
|
-
// The renderer requires a @tanstack/react-query QueryClientProvider to make requests
|
|
48
|
-
const queryClient = useRendererQueryClient();
|
|
49
|
-
/**
|
|
50
|
-
* The useInitialiseForm hook provides initialisation logic for the form
|
|
51
|
-
* Alternatively (and recommended to do so), you can initialise your form via a button click or other event handler.
|
|
52
|
-
*
|
|
53
|
-
* @see {@link https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/BuildFormButtonForStorybook.tsx} for button click usage examples.
|
|
54
|
-
*/
|
|
55
|
-
const isInitialising = useInitialiseForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables, fhirClient);
|
|
56
|
-
// Free feel to customise your loading animation here
|
|
57
|
-
if (isInitialising) {
|
|
58
|
-
return (React.createElement(Box, { display: "flex", alignItems: "center", columnGap: 2 },
|
|
59
|
-
React.createElement(CircularProgress, null),
|
|
60
|
-
React.createElement(Typography, null, "Loading questionnaire...")));
|
|
61
|
-
}
|
|
62
|
-
return (React.createElement(RendererThemeProvider, null,
|
|
63
|
-
React.createElement(QueryClientProvider, { client: queryClient },
|
|
64
|
-
React.createElement(BaseRenderer, null))));
|
|
65
|
-
}
|
|
66
|
-
export default InitialiseFormWrapperForStorybook;
|
|
67
|
-
//# sourceMappingURL=InitialiseFormWrapperForStorybook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InitialiseFormWrapperForStorybook.js","sourceRoot":"","sources":["../../../src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,aAAa;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,qBAAqB,MAAM,mBAAmB,CAAC;AACtD,OAAO,sBAAsB,MAAM,oCAAoC,CAAC;AAExE,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAC9D,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAWlD;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,iCAAiC,CAAC,KAAiC;IAC1E,MAAM,EACJ,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACX,GAAG,KAAK,CAAC;IAEV,qFAAqF;IACrF,MAAM,WAAW,GAAG,sBAAsB,EAAE,CAAC;IAE7C;;;;;OAKG;IACH,MAAM,cAAc,GAAG,iBAAiB,CACtC,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,CACX,CAAC;IAEF,qDAAqD;IACrD,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC;YAClD,oBAAC,gBAAgB,OAAG;YACpB,oBAAC,UAAU,mCAAsC,CAC7C,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,qBAAqB;QACpB,oBAAC,mBAAmB,IAAC,MAAM,EAAE,WAAW;YACtC,oBAAC,YAAY,OAAG,CACI,CACA,CACzB,CAAC;AACJ,CAAC;AAED,eAAe,iCAAiC,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
-
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stories/storybookWrappers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC"}
|
package/lib/theme/Theme.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { ThemeOptions } from '@mui/material/styles';
|
|
4
|
-
declare module '@mui/material/styles' {
|
|
5
|
-
interface Theme {
|
|
6
|
-
customShadows: {
|
|
7
|
-
z1: string;
|
|
8
|
-
z4: string;
|
|
9
|
-
z8: string;
|
|
10
|
-
z12: string;
|
|
11
|
-
z16: string;
|
|
12
|
-
z20: string;
|
|
13
|
-
z24: string;
|
|
14
|
-
card: string;
|
|
15
|
-
dialog: string;
|
|
16
|
-
dropdown: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
interface ThemeOptions {
|
|
20
|
-
customShadows: {
|
|
21
|
-
z1: string;
|
|
22
|
-
z4: string;
|
|
23
|
-
z8: string;
|
|
24
|
-
z12: string;
|
|
25
|
-
z16: string;
|
|
26
|
-
z20: string;
|
|
27
|
-
z24: string;
|
|
28
|
-
card: string;
|
|
29
|
-
dialog: string;
|
|
30
|
-
dropdown: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export declare const themeOptions: ThemeOptions;
|
|
35
|
-
/**
|
|
36
|
-
* Default theme used by the renderer using Material UI. You can customise your own theme by defining a new ThemeProvider.
|
|
37
|
-
* @see {@link https://mui.com/material-ui/customization/theming/}
|
|
38
|
-
*
|
|
39
|
-
* @author Sean Fong
|
|
40
|
-
*/
|
|
41
|
-
export declare function RendererThemeProvider({ children }: {
|
|
42
|
-
children: ReactNode;
|
|
43
|
-
}): React.JSX.Element;
|
|
44
|
-
export default RendererThemeProvider;
|
package/lib/theme/Theme.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { alpha, createTheme, StyledEngineProvider, ThemeProvider as MUIThemeProvider } from '@mui/material/styles';
|
|
3
|
-
import palette from './palette';
|
|
4
|
-
import typography from './typography';
|
|
5
|
-
import CustomGlobalStyles from './customGlobalStyles';
|
|
6
|
-
import componentsOverride from './overrides/Overrides';
|
|
7
|
-
import { grey } from '@mui/material/colors';
|
|
8
|
-
// ----------------------------------------------------------------------
|
|
9
|
-
const transparent = alpha(grey[500], 0.16);
|
|
10
|
-
export const themeOptions = {
|
|
11
|
-
palette,
|
|
12
|
-
shape: { borderRadius: 6 },
|
|
13
|
-
typography,
|
|
14
|
-
customShadows: {
|
|
15
|
-
z1: `0 1px 2px 0 ${transparent}`,
|
|
16
|
-
z4: `0 4px 8px 0 ${transparent}`,
|
|
17
|
-
z8: `0 8px 16px 0 ${transparent}`,
|
|
18
|
-
z12: `0 12px 24px -4px ${transparent}`,
|
|
19
|
-
z16: `0 16px 32px -4px ${transparent}`,
|
|
20
|
-
z20: `0 20px 40px -4px ${transparent}`,
|
|
21
|
-
z24: `0 24px 48px 0 ${transparent}`,
|
|
22
|
-
//
|
|
23
|
-
card: `0 0 2px 0 ${alpha(grey[500], 0.2)}, 0 12px 24px -4px ${alpha(grey[500], 0.12)}`,
|
|
24
|
-
dialog: `-40px 40px 80px -8px ${alpha(grey[500], 0.24)}`,
|
|
25
|
-
dropdown: `0 0 2px 0 ${alpha(grey[500], 0.24)}, -20px 20px 40px -4px ${alpha(grey[500], 0.24)}`
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Default theme used by the renderer using Material UI. You can customise your own theme by defining a new ThemeProvider.
|
|
30
|
-
* @see {@link https://mui.com/material-ui/customization/theming/}
|
|
31
|
-
*
|
|
32
|
-
* @author Sean Fong
|
|
33
|
-
*/
|
|
34
|
-
export function RendererThemeProvider({ children }) {
|
|
35
|
-
const theme = createTheme(themeOptions);
|
|
36
|
-
theme.components = componentsOverride(theme);
|
|
37
|
-
return (React.createElement(StyledEngineProvider, { injectFirst: true },
|
|
38
|
-
React.createElement(MUIThemeProvider, { theme: theme },
|
|
39
|
-
React.createElement(CustomGlobalStyles, null),
|
|
40
|
-
children)));
|
|
41
|
-
}
|
|
42
|
-
export default RendererThemeProvider;
|
|
43
|
-
//# sourceMappingURL=Theme.js.map
|
package/lib/theme/Theme.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Theme.js","sourceRoot":"","sources":["../../src/theme/Theme.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,KAAK,EACL,WAAW,EACX,oBAAoB,EACpB,aAAa,IAAI,gBAAgB,EAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAsC5C,yEAAyE;AAEzE,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,OAAO;IACP,KA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