@k-int/stripes-kint-components 1.3.0 → 1.7.0
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/CHANGELOG.md +34 -2
- package/es/artifacts/coverage-jest/lcov-report/block-navigation.js +109 -0
- package/es/artifacts/coverage-jest/lcov-report/prettify.js +998 -0
- package/es/artifacts/coverage-jest/lcov-report/sorter.js +238 -0
- package/es/index.js +69 -17
- package/es/lib/ActionList/ActionList.js +63 -24
- package/es/lib/ActionList/ActionListFieldArray.js +158 -96
- package/es/lib/ActionList/index.js +7 -3
- package/es/lib/EditableRefdataList/EditableRefdataList.js +69 -24
- package/es/lib/EditableRefdataList/index.js +7 -3
- package/es/lib/EditableSettingsList/EditableSettingsList.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +181 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +72 -9
- package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +447 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +45 -7
- package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +495 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.js +187 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +180 -0
- package/es/lib/EditableSettingsList/SettingField/index.js +35 -0
- package/es/lib/EditableSettingsList/index.js +35 -0
- package/es/lib/NoResultsMessage/NoResultsMessage.js +122 -0
- package/es/lib/NoResultsMessage/index.js +19 -0
- package/es/lib/QueryTypedown/QueryTypedown.js +48 -9
- package/es/lib/QueryTypedown/index.js +6 -2
- package/es/lib/RefdataButtons/RefdataButtons.js +143 -0
- package/es/lib/RefdataButtons/index.js +19 -0
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +202 -131
- package/es/lib/SASQLookupComponent/index.js +6 -2
- package/es/lib/SASQRoute/SASQRoute.js +55 -18
- package/es/lib/SASQRoute/index.js +6 -2
- package/es/lib/SASQViewComponent/SASQViewComponent.js +50 -11
- package/es/lib/SASQViewComponent/index.js +6 -2
- package/es/lib/SearchField/SearchField.js +48 -13
- package/es/lib/SearchField/index.js +6 -2
- package/es/lib/SettingPage/SettingPage.js +99 -0
- package/es/lib/SettingPage/SettingPagePane.js +83 -0
- package/es/lib/SettingPage/index.js +27 -0
- package/es/lib/TypeDown/TypeDown.js +143 -101
- package/es/lib/TypeDown/index.js +6 -2
- package/es/lib/Typedown/Typedown.js +140 -96
- package/es/lib/Typedown/index.js +6 -2
- package/es/lib/constants/eventCodes.js +31 -1
- package/es/lib/contexts/SettingsContext.js +41 -0
- package/es/lib/contexts/index.js +19 -0
- package/es/lib/hooks/index.js +42 -8
- package/es/lib/hooks/settingsHooks/index.js +27 -0
- package/es/lib/hooks/settingsHooks/useSettingSection.js +74 -0
- package/es/lib/hooks/settingsHooks/useSettings.js +175 -0
- package/es/lib/hooks/typedownHooks/index.js +8 -28
- package/es/lib/hooks/typedownHooks/useTypedown.js +129 -12
- package/es/lib/hooks/typedownHooks/useTypedownData.js +35 -2
- package/es/lib/hooks/typedownHooks/useTypedownToggle.js +39 -6
- package/es/lib/hooks/useActiveElement.js +33 -2
- package/es/lib/hooks/useHelperApp.js +51 -12
- package/es/lib/hooks/useKiwtFieldArray.js +142 -0
- package/es/lib/hooks/useKiwtSASQuery.js +62 -7
- package/es/lib/hooks/useLocalStorageState.js +37 -4
- package/es/lib/hooks/useMutateRefdataValue.js +42 -9
- package/es/lib/hooks/useQIndex.js +108 -0
- package/es/lib/hooks/useRefdata.js +56 -12
- package/es/lib/hooks/useTemplates.js +36 -3
- package/es/lib/utils/buildUrl.js +43 -10
- package/es/lib/utils/generateKiwtQuery.js +31 -108
- package/es/lib/utils/generateKiwtQueryParams.js +154 -0
- package/es/lib/utils/index.js +55 -3
- package/es/lib/utils/refdataOptions.js +43 -0
- package/es/lib/utils/renderHelpText.js +109 -0
- package/es/lib/utils/selectorSafe.js +31 -2
- package/es/lib/utils/sortByLabel.js +55 -0
- package/es/lib/utils/toCamelCase.js +48 -0
- package/jest.config.js +15 -1
- package/junit.xml +79 -0
- package/package.json +17 -10
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +256 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +799 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +376 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +223 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +211 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +376 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +262 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +436 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +161 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +319 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +184 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +370 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +949 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +274 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +250 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +214 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +211 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +178 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/TypeDown.js.html +769 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +790 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/base.css +224 -0
- package/src/artifacts/coverage-jest/lcov-report/block-navigation.js +87 -0
- package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/constants/index.html +116 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +97 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +251 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +115 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +403 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +161 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +520 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +157 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +283 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +274 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +178 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +136 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +301 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +208 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +268 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +166 -0
- package/src/artifacts/coverage-jest/lcov-report/index.html +401 -0
- package/src/artifacts/coverage-jest/lcov-report/prettify.css +1 -0
- package/src/artifacts/coverage-jest/lcov-report/prettify.js +2 -0
- package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
- package/src/artifacts/coverage-jest/lcov-report/sorter.js +196 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +193 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +109 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +286 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/index.html +236 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +121 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +106 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +166 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +103 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +130 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +127 -0
- package/src/artifacts/coverage-jest/lcov.info +1999 -0
- package/src/index.js +21 -6
- package/src/lib/ActionList/ActionList.js +5 -2
- package/src/lib/ActionList/ActionListFieldArray.js +20 -8
- package/src/lib/ActionList/README.md +1 -0
- package/src/lib/ActionList/index.js +1 -1
- package/src/lib/EditableRefdataList/EditableRefdataList.js +10 -5
- package/src/lib/EditableRefdataList/index.js +1 -1
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsList.js +0 -0
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsListFieldArray.js +2 -2
- package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +111 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +24 -1
- package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +379 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +2 -1
- package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +368 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/SettingField.js +7 -7
- package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +80 -0
- package/src/lib/EditableSettingsList/SettingField/index.js +3 -0
- package/src/lib/EditableSettingsList/index.js +3 -0
- package/src/lib/NoResultsMessage/NoResultsMessage.js +78 -0
- package/src/lib/NoResultsMessage/index.js +1 -0
- package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
- package/src/lib/RefdataButtons/index.js +1 -0
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +36 -8
- package/src/lib/SASQRoute/README.md +1 -1
- package/src/lib/{Settings → SettingPage}/SettingPage.js +5 -5
- package/src/lib/{Settings → SettingPage}/SettingPagePane.js +12 -2
- package/src/lib/SettingPage/index.js +2 -0
- package/src/lib/TypeDown/README.md +1 -115
- package/src/lib/TypeDown/TypeDown.js +4 -2
- package/src/lib/Typedown/Typedown.js +2 -1
- package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
- package/src/lib/contexts/index.js +2 -0
- package/src/lib/hooks/README.md +107 -0
- package/src/lib/hooks/index.js +3 -0
- package/src/lib/hooks/settingsHooks/index.js +2 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettingSection.js +0 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettings.js +14 -6
- package/src/lib/hooks/typedownHooks/index.js +0 -3
- package/src/lib/hooks/typedownHooks/useTypedown.js +93 -11
- package/src/lib/hooks/useHelperApp.js +5 -1
- package/src/lib/hooks/useKiwtFieldArray.js +63 -0
- package/src/lib/hooks/useKiwtSASQuery.js +9 -1
- package/src/lib/hooks/useQIndex.js +41 -0
- package/src/lib/hooks/useRefdata.js +17 -6
- package/src/lib/utils/README.md +39 -1
- package/src/lib/utils/generateKiwtQuery.js +3 -62
- package/src/lib/utils/generateKiwtQueryParams.js +67 -0
- package/src/lib/utils/index.js +10 -0
- package/src/lib/utils/refdataOptions.js +7 -0
- package/src/lib/{Settings/utils → utils}/renderHelpText.js +1 -1
- package/src/lib/{Settings/utils → utils}/sortByLabel.js +1 -1
- package/src/lib/{Settings/utils → utils}/toCamelCase.js +0 -0
- package/styles/NoResultsMessage.css +38 -0
- package/test/helpers/index.js +1 -0
- package/test/helpers/translationsProperties.js +40 -0
- package/test/jest/helpers/KintHarness.js +36 -0
- package/test/jest/helpers/index.js +2 -0
- package/test/jest/helpers/renderWithKintHarness.js +15 -0
- package/test/jest/jest-transformer.js +4 -0
- package/test/jest/setupTests.js +1 -0
- package/translations/stripes-kint-components/en.json +4 -1
- package/babelOptions.js +0 -30
- package/es/lib/Settings/EditableSettingsList.js +0 -57
- package/es/lib/Settings/EditableSettingsListFieldArray.js +0 -59
- package/es/lib/Settings/RefdataButtons.js +0 -100
- package/es/lib/Settings/SettingField.js +0 -144
- package/es/lib/Settings/SettingPage.js +0 -64
- package/es/lib/Settings/SettingPagePane.js +0 -43
- package/es/lib/Settings/SettingsContext.js +0 -18
- package/es/lib/Settings/index.js +0 -71
- package/es/lib/Settings/useSettingSection.js +0 -41
- package/es/lib/Settings/useSettings.js +0 -126
- package/es/lib/Settings/utils/index.js +0 -31
- package/es/lib/Settings/utils/renderHelpText.js +0 -57
- package/es/lib/Settings/utils/sortByLabel.js +0 -26
- package/es/lib/Settings/utils/toCamelCase.js +0 -19
- package/es/lib/hooks/typedownHooks/useTypedownFooter.js +0 -47
- package/es/lib/hooks/typedownHooks/useTypedownList.js +0 -45
- package/es/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -47
- package/es/lib/utils/getFocusableElements.js +0 -132
- package/src/lib/Settings/index.js +0 -8
- package/src/lib/Settings/utils/index.js +0 -3
- package/src/lib/hooks/typedownHooks/useTypedownFooter.js +0 -43
- package/src/lib/hooks/typedownHooks/useTypedownList.js +0 -36
- package/src/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -39
- package/src/lib/utils/getFocusableElements.js +0 -99
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
+
import queryString from 'query-string';
|
|
4
|
+
|
|
5
|
+
const useQIndex = () => {
|
|
6
|
+
const history = useHistory();
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
|
|
9
|
+
const query = queryString.parse(location.search);
|
|
10
|
+
const [currentQindex, setCurrentQindex] = useState(query?.qindex);
|
|
11
|
+
|
|
12
|
+
const handleQindexChange = (newQindex) => {
|
|
13
|
+
setCurrentQindex(newQindex);
|
|
14
|
+
if (newQindex !== query?.qindex) {
|
|
15
|
+
const newQuery = {
|
|
16
|
+
...query,
|
|
17
|
+
qindex: newQindex
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
history.push({
|
|
21
|
+
pathname: location.pathname,
|
|
22
|
+
search: `?${queryString.stringify(newQuery)}`
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (currentQindex !== query?.qindex) {
|
|
29
|
+
setCurrentQindex(query?.qindex);
|
|
30
|
+
}
|
|
31
|
+
}, [
|
|
32
|
+
currentQindex,
|
|
33
|
+
history,
|
|
34
|
+
location,
|
|
35
|
+
query
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
return [currentQindex, handleQindexChange];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default useQIndex;
|
|
@@ -4,25 +4,36 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { useQuery } from 'react-query';
|
|
5
5
|
import { useOkapiKy } from '@folio/stripes/core';
|
|
6
6
|
|
|
7
|
+
import { generateKiwtQuery, refdataOptions } from '../utils';
|
|
8
|
+
|
|
7
9
|
const useRefdata = ({
|
|
8
10
|
endpoint,
|
|
9
11
|
desc,
|
|
12
|
+
options = refdataOptions,
|
|
10
13
|
queryParams,
|
|
11
|
-
returnQueryObject = false
|
|
14
|
+
returnQueryObject = false,
|
|
12
15
|
}) => {
|
|
13
16
|
const ky = useOkapiKy();
|
|
14
|
-
|
|
17
|
+
|
|
18
|
+
const nsValues = {};
|
|
19
|
+
|
|
20
|
+
/* Desc will tend to contain a '.', which will throw off generateKiwtQuery.
|
|
21
|
+
* To combat this we can insert another Desc. at the beginning to act as the filtername, so
|
|
22
|
+
* Funder.Name => Desc.desc=Funder.Name. This way "Desc" acts as the filterName, and without a filterKey
|
|
23
|
+
* "desc=Funder.Name" is passed wholesale to the query.
|
|
24
|
+
*/
|
|
15
25
|
|
|
16
26
|
if (Array.isArray(desc)) {
|
|
17
27
|
// If we have an array, append a desc filter for each desc given
|
|
18
|
-
desc.
|
|
19
|
-
path += `${index === 0 ? '?filters=' : '%7C%7C'}desc=${d}`;
|
|
20
|
-
});
|
|
28
|
+
nsValues.filters = desc.map(d => `DescKey.${d}`).join(',');
|
|
21
29
|
} else if (desc) {
|
|
22
30
|
// If we just have a string, append a single desc filter
|
|
23
|
-
|
|
31
|
+
nsValues.filters = `DescKey.${desc}`;
|
|
24
32
|
}
|
|
25
33
|
|
|
34
|
+
const query = generateKiwtQuery(options, nsValues);
|
|
35
|
+
const path = `${endpoint}${query}`;
|
|
36
|
+
|
|
26
37
|
const queryObject = useQuery(
|
|
27
38
|
['stripes-kint-components', 'useRefdata', 'refdata', desc ?? ''],
|
|
28
39
|
() => ky(path).json(),
|
package/src/lib/utils/README.md
CHANGED
|
@@ -29,5 +29,43 @@ import { generateKiwtQuery } from '@k-int/stripes-kint-components'
|
|
|
29
29
|
### Props
|
|
30
30
|
Name | Type | Description | default | required
|
|
31
31
|
--- | --- | --- | --- | ---
|
|
32
|
-
options | object | An object with keys: `searchKey`, `filterKeys`, `sortKeys` and `stats`, which maps the incoming nsValues objects to a KIWT query. | | ✓ |
|
|
32
|
+
options | object | An object with keys: `searchKey`, `filterKeys`, `sortKeys` and `stats`, which maps the incoming nsValues objects to a KIWT query. You can also pass arbitrary `key`/`value` pairs to append `key==value` onto the query. | | ✓ |
|
|
33
|
+
nsValues | object | An object containing the actual query parameters to become the mapped KIWT query | | ✓ |
|
|
34
|
+
|
|
35
|
+
## generateKiwtQueryParams
|
|
36
|
+
A util function for generating an array of "KIWT" (K-Int Web-Toolkit) style backend query parameters from a SASQ query object
|
|
37
|
+
### Basic usage
|
|
38
|
+
```
|
|
39
|
+
import { generateKiwtQueryParams } from '@k-int/stripes-kint-components'
|
|
40
|
+
...
|
|
41
|
+
const nsValues = {
|
|
42
|
+
query: 'test',
|
|
43
|
+
filters: 'requestStatus.completed,journalVolume.test1,startDate.startDate>=2021-10-28'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const options = {
|
|
47
|
+
searchKey: 'request.name',
|
|
48
|
+
filterKeys: {
|
|
49
|
+
requestStatus: 'requestStatus.value,
|
|
50
|
+
journalVolume: 'journalVolume'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const queryArray = generateKiwtQueryParams(options, nsValues)
|
|
55
|
+
|
|
56
|
+
// We'd expect queryArray === [
|
|
57
|
+
"match=request.name",
|
|
58
|
+
"term=test",
|
|
59
|
+
"filters=requestStatus.value==completed",
|
|
60
|
+
"filters=journalVolume==test1",
|
|
61
|
+
"filters=startDate%3E=2021-10-28",
|
|
62
|
+
"stats=true"
|
|
63
|
+
]
|
|
64
|
+
...
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Props
|
|
68
|
+
Name | Type | Description | default | required
|
|
69
|
+
--- | --- | --- | --- | ---
|
|
70
|
+
options | object | An object with keys: `searchKey`, `filterKeys`, `sortKeys` and `stats`, which maps the incoming nsValues objects to an KIWT query array. You can also pass arbitrary `key`/`value` pairs to append `key==value` onto the query. | | ✓ |
|
|
33
71
|
nsValues | object | An object containing the actual query parameters to become the mapped KIWT query | | ✓ |
|
|
@@ -1,66 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const { query, filters, sort } = nsValues;
|
|
3
|
-
const {
|
|
4
|
-
searchKey = '',
|
|
5
|
-
/* Assumtion made that if no filterKey is provided then the given filterValues for that key are standalaone, ie require no comparator or key */
|
|
6
|
-
filterKeys = {},
|
|
7
|
-
sortKeys = {},
|
|
8
|
-
stats = true,
|
|
9
|
-
...rest
|
|
10
|
-
} = options;
|
|
11
|
-
|
|
12
|
-
const paramsArray = [];
|
|
13
|
-
|
|
14
|
-
if (query) {
|
|
15
|
-
paramsArray.push(...searchKey.split(',')?.map(m => `match=${m}`));
|
|
16
|
-
paramsArray.push(`term=${query}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (filters) {
|
|
20
|
-
const filterMap = {};
|
|
21
|
-
filters.split(',').forEach(filter => {
|
|
22
|
-
const [filterName, ...rest] = filter.split('.');
|
|
23
|
-
const filterValue = rest.join('.');
|
|
24
|
-
|
|
25
|
-
if (filterMap[filterName] === undefined) filterMap[filterName] = [];
|
|
26
|
-
filterMap[filterName].push(filterValue);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// We now have a filterMap of shape { status: ['active', 'cancelled'], type: ['local'] }
|
|
30
|
-
Object.entries(filterMap).forEach(([filterName, filterValues]) => {
|
|
31
|
-
const filterKey = filterKeys[filterName];
|
|
32
|
-
|
|
33
|
-
if (!filterKey) {
|
|
34
|
-
// These filters have no key mapping so we just pass the values to the backend as-is.
|
|
35
|
-
paramsArray.push(...filterValues?.map(f => `filters=${f}`));
|
|
36
|
-
} else {
|
|
37
|
-
const filterString = filterValues.map(v => `${filterKey}==${v}`).join('||');
|
|
38
|
-
paramsArray.push(`filters=${filterString}`);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (sort) {
|
|
44
|
-
paramsArray.push(...sort.split(',').map(sortKey => {
|
|
45
|
-
const descending = sortKey.startsWith('-');
|
|
46
|
-
let term = sortKey.replace('-', '');
|
|
47
|
-
|
|
48
|
-
if (term in sortKeys) {
|
|
49
|
-
term = term.replace(term, sortKeys[term]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return `sort=${term};${descending ? 'desc' : 'asc'}`;
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (stats) {
|
|
57
|
-
paramsArray.push('stats=true');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
for (const [key, value] of Object.entries(rest)) {
|
|
61
|
-
paramsArray.push(`${key}=${value}`);
|
|
62
|
-
}
|
|
1
|
+
import generateKiwtQueryParams from './generateKiwtQueryParams';
|
|
63
2
|
|
|
3
|
+
const generateKiwtQuery = (options, nsValues) => {
|
|
4
|
+
const paramsArray = generateKiwtQueryParams(options, nsValues);
|
|
64
5
|
return paramsArray.length ? '?' + paramsArray.map(p => encodeURI(p)).join('&') : '';
|
|
65
6
|
};
|
|
66
7
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const generateKiwtQueryParams = (options, nsValues) => {
|
|
2
|
+
const { qindex, query, filters, sort } = nsValues;
|
|
3
|
+
const {
|
|
4
|
+
searchKey = '',
|
|
5
|
+
/* Assumtion made that if no filterKey is provided then the given filterValues for that key are standalaone, ie require no comparator or key */
|
|
6
|
+
filterKeys = {},
|
|
7
|
+
sortKeys = {},
|
|
8
|
+
stats = true,
|
|
9
|
+
...rest
|
|
10
|
+
} = options;
|
|
11
|
+
|
|
12
|
+
const paramsArray = [];
|
|
13
|
+
|
|
14
|
+
if (query) {
|
|
15
|
+
paramsArray.push(...(qindex || searchKey).split(',')?.map(m => `match=${m}`));
|
|
16
|
+
paramsArray.push(`term=${query}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (filters) {
|
|
20
|
+
const filterMap = {};
|
|
21
|
+
filters.split(',').forEach(filter => {
|
|
22
|
+
const [filterName, ...filterRest] = filter.split('.');
|
|
23
|
+
const filterValue = filterRest.join('.');
|
|
24
|
+
|
|
25
|
+
if (filterMap[filterName] === undefined) filterMap[filterName] = [];
|
|
26
|
+
filterMap[filterName].push(filterValue);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// We now have a filterMap of shape { status: ['active', 'cancelled'], type: ['local'] }
|
|
30
|
+
Object.entries(filterMap).forEach(([filterName, filterValues]) => {
|
|
31
|
+
const filterKey = filterKeys[filterName];
|
|
32
|
+
|
|
33
|
+
if (!filterKey) {
|
|
34
|
+
// These filters have no key mapping so we just pass the values to the backend as-is.
|
|
35
|
+
paramsArray.push(...filterValues?.map(f => `filters=${f}`));
|
|
36
|
+
} else {
|
|
37
|
+
const filterString = filterValues.map(v => `${filterKey}==${v}`).join('||');
|
|
38
|
+
paramsArray.push(`filters=${filterString}`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (sort) {
|
|
44
|
+
paramsArray.push(...sort.split(',').map(sortKey => {
|
|
45
|
+
const descending = sortKey.startsWith('-');
|
|
46
|
+
let term = sortKey.replace('-', '');
|
|
47
|
+
|
|
48
|
+
if (term in sortKeys) {
|
|
49
|
+
term = term.replace(term, sortKeys[term]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return `sort=${term};${descending ? 'desc' : 'asc'}`;
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (stats) {
|
|
57
|
+
paramsArray.push('stats=true');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
61
|
+
paramsArray.push(`${key}=${value}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return paramsArray;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default generateKiwtQueryParams;
|
package/src/lib/utils/index.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
export { default as generateKiwtQuery } from './generateKiwtQuery';
|
|
2
|
+
export { default as generateKiwtQueryParams } from './generateKiwtQueryParams';
|
|
3
|
+
export { default as selectorSafe } from './selectorSafe';
|
|
4
|
+
|
|
2
5
|
export { default as buildUrl } from './buildUrl';
|
|
6
|
+
|
|
7
|
+
export { default as refdataOptions } from './refdataOptions';
|
|
8
|
+
|
|
9
|
+
// Settings utils
|
|
10
|
+
export { default as renderHelpText } from './renderHelpText';
|
|
11
|
+
export { default as sortByLabel } from './sortByLabel';
|
|
12
|
+
export { default as toCamelCase } from './toCamelCase'; // I hate that this exists
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No Results Message
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@import '@folio/stripes-components/lib/variables.css';
|
|
6
|
+
|
|
7
|
+
/* Empty Message */
|
|
8
|
+
.noResultsMessage {
|
|
9
|
+
padding: 15px;
|
|
10
|
+
color: var(--color-text-p2);
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
bottom: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
background: var(--color-fill);
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.noResultsMessage,
|
|
21
|
+
.noResultsMessageLabelWrap {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.noResultsMessageLabelWrap {
|
|
28
|
+
font-size: var(--font-size-large);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.noResultsMessageIcon,
|
|
32
|
+
.noResultsMessageLabel {
|
|
33
|
+
margin: 0 4px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.noResultsMessageButton {
|
|
37
|
+
margin-top: 15px;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './translationsProperties';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import translations from '../../translations/stripes-kint-components/en';
|
|
2
|
+
|
|
3
|
+
const translationsProperties = [
|
|
4
|
+
{
|
|
5
|
+
prefix: 'stripes-kint-components',
|
|
6
|
+
translations,
|
|
7
|
+
},
|
|
8
|
+
/* Don't think we're using any of the below rn */
|
|
9
|
+
{
|
|
10
|
+
prefix: 'stripes-core',
|
|
11
|
+
translations: {
|
|
12
|
+
'label.missingRequiredField': 'Please fill this in to continue',
|
|
13
|
+
'button.save': 'Save',
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
prefix: 'stripes-components',
|
|
18
|
+
translations: {
|
|
19
|
+
'saveAndClose': 'Save and close',
|
|
20
|
+
'cancel': 'Cancel',
|
|
21
|
+
'paneMenuActionsToggleLabel': 'Actions',
|
|
22
|
+
'collapseAll': 'Collapse all',
|
|
23
|
+
'button.edit': 'Edit'
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
prefix: 'stripes-smart-components',
|
|
28
|
+
translations: {
|
|
29
|
+
'permissionError': 'Sorry - your permissions do not allow access to this page.',
|
|
30
|
+
'searchAndFilter': 'Search and filter',
|
|
31
|
+
'hideSearchPane': 'Hide search pane',
|
|
32
|
+
'search': 'Search',
|
|
33
|
+
'resetAll': 'Reset all',
|
|
34
|
+
'searchResultsCountHeader': '"{count, number} {count, plural, one {record found} other {records found}}"',
|
|
35
|
+
'new': 'New'
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export default translationsProperties;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Harness } from '@folio/stripes-erm-components/test/jest/helpers';
|
|
4
|
+
|
|
5
|
+
import { SettingsContext } from '../../../src/lib/contexts';
|
|
6
|
+
import translationsProperties from '../../helpers';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export default function KintHarness({
|
|
10
|
+
children,
|
|
11
|
+
settingsValues = {
|
|
12
|
+
intlKey: 'stripes-kint-components',
|
|
13
|
+
refdataEndpoint: 'path/to/refdata',
|
|
14
|
+
settingEndpoint: 'path/to/settings',
|
|
15
|
+
templateEndpoint: 'path/to/templates'
|
|
16
|
+
},
|
|
17
|
+
translations = translationsProperties,
|
|
18
|
+
...harnessProps
|
|
19
|
+
}) {
|
|
20
|
+
return (
|
|
21
|
+
<SettingsContext.Provider value={settingsValues}>
|
|
22
|
+
<Harness
|
|
23
|
+
translations={translations}
|
|
24
|
+
{...harnessProps}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
</Harness>
|
|
28
|
+
</SettingsContext.Provider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
KintHarness.propTypes = {
|
|
33
|
+
children: PropTypes.node,
|
|
34
|
+
settingsValues: PropTypes.object,
|
|
35
|
+
translations: PropTypes.object
|
|
36
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import KintHarness from './KintHarness';
|
|
5
|
+
|
|
6
|
+
const renderWithKintHarness = (children, context, translations, renderer = render) => renderer(
|
|
7
|
+
<KintHarness
|
|
8
|
+
settingsValues={context}
|
|
9
|
+
translations={translations}
|
|
10
|
+
>
|
|
11
|
+
{children}
|
|
12
|
+
</KintHarness>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export default renderWithKintHarness;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'regenerator-runtime/runtime';
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"settings.edit": "Edit",
|
|
5
5
|
"settings.settingLoading": "Loading",
|
|
6
6
|
"settings.finishEditing": "Finish editing",
|
|
7
|
+
"settings.valueFor": "Value for setting {name}",
|
|
7
8
|
|
|
8
9
|
"actionList.save": "Save",
|
|
9
10
|
"actionList.cancel": "Cancel",
|
|
@@ -15,5 +16,7 @@
|
|
|
15
16
|
"editableRefdataList.label": "Label",
|
|
16
17
|
"editableRefdataList.value": "Value",
|
|
17
18
|
|
|
18
|
-
"sasqLookupComponent.mainPane.found": "{total} records found"
|
|
19
|
+
"sasqLookupComponent.mainPane.found": "{total} records found",
|
|
20
|
+
|
|
21
|
+
"noResultsMessage.showFilters": "Show filters"
|
|
19
22
|
}
|
package/babelOptions.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: [
|
|
3
|
-
['@babel/preset-env'], // No preset means ES5, { targets: '> 0.25%, not dead' }],
|
|
4
|
-
// ['@babel/preset-flow', { all: true }],
|
|
5
|
-
['@babel/preset-react', {
|
|
6
|
-
// "runtime": "automatic",
|
|
7
|
-
"absoluteRuntime": false
|
|
8
|
-
}]
|
|
9
|
-
],
|
|
10
|
-
plugins: [
|
|
11
|
-
['@babel/plugin-proposal-decorators', { 'legacy': true }],
|
|
12
|
-
// when building a platform directly, i.e. outside a workspace,
|
|
13
|
-
// babel complains loudly and repeatedly that when these modules are enabled:
|
|
14
|
-
// * @babel/plugin-proposal-class-properties,
|
|
15
|
-
// * @babel/plugin-proposal-private-methods and
|
|
16
|
-
// * @babel/plugin-proposal-private-property-in-object
|
|
17
|
-
// the "loose" option must be the same for all three.
|
|
18
|
-
// but @babel/preset-env sets it to false for ...private-methods.
|
|
19
|
-
// overriding it here silences the complaint. STRWEB-12
|
|
20
|
-
['@babel/plugin-proposal-class-properties', { 'loose': true }],
|
|
21
|
-
['@babel/plugin-proposal-private-methods', { 'loose': true }],
|
|
22
|
-
['@babel/plugin-proposal-private-property-in-object', { 'loose': true }],
|
|
23
|
-
'@babel/plugin-proposal-export-namespace-from',
|
|
24
|
-
'@babel/plugin-proposal-function-sent',
|
|
25
|
-
'@babel/plugin-proposal-numeric-separator',
|
|
26
|
-
'@babel/plugin-proposal-throw-expressions',
|
|
27
|
-
'@babel/plugin-syntax-import-meta',
|
|
28
|
-
// [require.resolve('react-hot-loader/babel')],
|
|
29
|
-
],
|
|
30
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _reactFinalFormArrays = require("react-final-form-arrays");
|
|
13
|
-
|
|
14
|
-
var _reactFinalForm = require("react-final-form");
|
|
15
|
-
|
|
16
|
-
var _finalFormArrays = _interopRequireDefault(require("final-form-arrays"));
|
|
17
|
-
|
|
18
|
-
var _EditableSettingsListFieldArray = _interopRequireDefault(require("./EditableSettingsListFieldArray"));
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
|
-
var EditableSettingsList = function EditableSettingsList(_ref) {
|
|
23
|
-
var data = _ref.data,
|
|
24
|
-
initialValues = _ref.initialValues,
|
|
25
|
-
onSave = _ref.onSave;
|
|
26
|
-
return /*#__PURE__*/_react["default"].createElement(_reactFinalForm.Form, {
|
|
27
|
-
enableReinitialize: true,
|
|
28
|
-
initialValues: initialValues,
|
|
29
|
-
keepDirtyOnReinitialize: true,
|
|
30
|
-
mutators: _finalFormArrays["default"],
|
|
31
|
-
navigationCheck: true,
|
|
32
|
-
onSubmit: onSave,
|
|
33
|
-
subscription: {
|
|
34
|
-
value: true
|
|
35
|
-
}
|
|
36
|
-
}, function (_ref2) {
|
|
37
|
-
var handleSubmit = _ref2.handleSubmit;
|
|
38
|
-
return /*#__PURE__*/_react["default"].createElement("form", {
|
|
39
|
-
onSubmit: handleSubmit
|
|
40
|
-
}, /*#__PURE__*/_react["default"].createElement(_reactFinalFormArrays.FieldArray, {
|
|
41
|
-
component: _EditableSettingsListFieldArray["default"],
|
|
42
|
-
data: data,
|
|
43
|
-
name: "settings",
|
|
44
|
-
onSave: onSave
|
|
45
|
-
}));
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
EditableSettingsList.propTypes = {
|
|
50
|
-
onSave: _propTypes["default"].func,
|
|
51
|
-
data: _propTypes["default"].shape({
|
|
52
|
-
refdatavalues: _propTypes["default"].arrayOf(_propTypes["default"].object)
|
|
53
|
-
}),
|
|
54
|
-
initialValues: _propTypes["default"].object
|
|
55
|
-
};
|
|
56
|
-
var _default = EditableSettingsList;
|
|
57
|
-
exports["default"] = _default;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _reactFinalForm = require("react-final-form");
|
|
13
|
-
|
|
14
|
-
var _SettingField = _interopRequireDefault(require("./SettingField"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
|
-
var EditableSettingsListFieldArray = function EditableSettingsListFieldArray(_ref) {
|
|
25
|
-
var data = _ref.data,
|
|
26
|
-
fields = _ref.fields,
|
|
27
|
-
onSave = _ref.onSave;
|
|
28
|
-
|
|
29
|
-
var handleSave = function handleSave(index) {
|
|
30
|
-
var setting = fields.value[index];
|
|
31
|
-
return onSave(setting);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return fields.map(function (setting, i) {
|
|
35
|
-
return /*#__PURE__*/_react["default"].createElement(_reactFinalForm.Field, {
|
|
36
|
-
key: setting,
|
|
37
|
-
component: _SettingField["default"],
|
|
38
|
-
name: setting,
|
|
39
|
-
onSave: function onSave() {
|
|
40
|
-
return handleSave(i);
|
|
41
|
-
},
|
|
42
|
-
settingData: _objectSpread({
|
|
43
|
-
currentSetting: fields.value[i]
|
|
44
|
-
}, data)
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
EditableSettingsListFieldArray.propTypes = {
|
|
50
|
-
fields: _propTypes["default"].object,
|
|
51
|
-
onSave: _propTypes["default"].func,
|
|
52
|
-
data: _propTypes["default"].shape({
|
|
53
|
-
refdatavalues: _propTypes["default"].arrayOf(_propTypes["default"].object)
|
|
54
|
-
}),
|
|
55
|
-
mutators: _propTypes["default"].object,
|
|
56
|
-
initialValues: _propTypes["default"].object
|
|
57
|
-
};
|
|
58
|
-
var _default = EditableSettingsListFieldArray;
|
|
59
|
-
exports["default"] = _default;
|