@k-int/stripes-kint-components 4.4.3 → 4.5.1
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 +10 -4
- package/es/lib/CustomProperties/View/CustomPropertyCard.js +2 -2
- package/es/lib/QueryTypedown/QueryTypedown.js +8 -1
- package/es/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +5 -2
- package/es/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +5 -1
- package/es/lib/hooks/useHelperApp.js +11 -4
- package/es/lib/utils/parseKiwtQueryGroups.js +39 -11
- package/es/lib/utils/parseKiwtQueryGroups.test.js +54 -0
- package/es/lib/utils/selectorSafe.js +1 -1
- package/junit.xml +1492 -222
- package/package.json +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesLookup.js.html +42 -42
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesSettings.js.html +166 -88
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +57 -57
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyView.js.html +27 -27
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +53 -53
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEdit.js.html +17 -17
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEditCtx.js.html +26 -26
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesListField.js.html +90 -90
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyField.js.html +116 -116
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyFormCard.js.html +26 -26
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/index.html +64 -64
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/testResources.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilter.js.html +31 -31
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterField.js.html +47 -47
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js.html +20 -20
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterForm.js.html +17 -17
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesRule.js.html +42 -42
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/index.html +96 -96
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/testResources.js.html +5 -5
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useOperators.js.html +35 -35
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useParseActiveFilterStrings.js.html +37 -37
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useValueProps.js.html +34 -34
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesView.js.html +14 -14
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesViewCtx.js.html +43 -43
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertyCard.js.html +5 -5
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/index.html +31 -31
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/testResources.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CycleButton/CycleButton.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CycleButton/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CycleButton/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataCategoryList/EditableRefdataCategoryList.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataCategoryList/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataCategoryList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +13 -4
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +29 -20
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +37 -37
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +62 -62
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +85 -70
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +43 -43
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +21 -21
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormModal/FormModal.js.html +30 -30
- package/src/artifacts/coverage-jest/lcov-report/FormModal/index.html +21 -21
- package/src/artifacts/coverage-jest/lcov-report/FormModal/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormattedKintMessage/FormattedKintMessage.js.html +3 -3
- package/src/artifacts/coverage-jest/lcov-report/FormattedKintMessage/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormattedKintMessage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/IconSelect/IconSelect.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/IconSelect/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/IconSelect/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +23 -8
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +7 -7
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +52 -52
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +21 -21
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/ResponsiveButtonGroup.js.html +11 -2
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/index.html +7 -7
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js.html +20 -5
- package/src/artifacts/coverage-jest/lcov-report/RichSelect/RichSelect.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RichSelect/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RichSelect/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RichSelect/useSelectedOption.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/TableBody.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +12 -3
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +3 -3
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/constants/customProperties.js.html +12 -12
- package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/constants/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +34 -34
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +30 -18
- package/src/artifacts/coverage-jest/lcov-report/hooks/useIntlKey.js.html +24 -24
- package/src/artifacts/coverage-jest/lcov-report/hooks/useIntlKeyStore.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useInvalidateRefdata.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKintIntl.js.html +38 -38
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateCustomProperties.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataCategory.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useSASQQueryMeta.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/index.html +132 -132
- package/src/artifacts/coverage-jest/lcov-report/settingsHooks/index.html +3 -3
- package/src/artifacts/coverage-jest/lcov-report/settingsHooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/settingsHooks/useAppSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/settingsHooks/useSettingSection.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/settingsHooks/useSettings.js.html +9 -3
- package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +4 -4
- package/src/artifacts/coverage-jest/lcov-report/utils/groupCustomPropertiesByCtx.js.html +22 -22
- package/src/artifacts/coverage-jest/lcov-report/utils/highlightString.js.html +3 -3
- package/src/artifacts/coverage-jest/lcov-report/utils/index.html +40 -40
- package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/matchString.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/utils/parseErrorResponse.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/utils/parseKiwtQueryGroups.js.html +161 -80
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataQueryKey.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +45 -3
- package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +16 -16
- package/src/artifacts/coverage-jest/lcov-report/utils/typedownQueryKey.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/validators/index.html +19 -19
- package/src/artifacts/coverage-jest/lcov-report/validators/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/validators/validators.js.html +32 -32
- package/src/artifacts/coverage-jest/lcov.info +1272 -1226
- package/src/lib/CustomProperties/View/CustomPropertyCard.js +3 -3
- package/src/lib/QueryTypedown/QueryTypedown.js +8 -3
- package/src/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +3 -0
- package/src/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +5 -0
- package/src/lib/hooks/useHelperApp.js +14 -10
- package/src/lib/utils/parseKiwtQueryGroups.js +39 -12
- package/src/lib/utils/parseKiwtQueryGroups.test.js +60 -0
|
@@ -34,7 +34,7 @@ const CustomPropertyCard = ({
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const internalFalse = customProperty?.internal === false ||
|
|
37
|
-
|
|
37
|
+
(customProperty?.internal === undefined && customPropertyDefinition.defaultInternal === false);
|
|
38
38
|
|
|
39
39
|
const renderValue = () => {
|
|
40
40
|
if (!customProperty) {
|
|
@@ -133,8 +133,8 @@ const CustomPropertyCard = ({
|
|
|
133
133
|
}
|
|
134
134
|
>
|
|
135
135
|
{kintIntl.formatKintMessage({
|
|
136
|
-
id: 'customProperties.internalFalse',
|
|
137
|
-
overrideValue: labelOverrides.internalFalse
|
|
136
|
+
id: internalFalse ? 'customProperties.internalFalse' : 'customProperties.internalTrue',
|
|
137
|
+
overrideValue: internalFalse ? labelOverrides.internalFalse : labelOverrides.internalTrue,
|
|
138
138
|
})}
|
|
139
139
|
</KeyValue>
|
|
140
140
|
</Col>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import Typedown from '../Typedown';
|
|
@@ -12,11 +12,16 @@ const QueryTypedown = ({
|
|
|
12
12
|
}) => {
|
|
13
13
|
const [callPath, setCallPath] = useState(pathMutator(null, path));
|
|
14
14
|
const data = dataFormatter(useTypedownData(path, callPath));
|
|
15
|
+
const [userQuery, setUserQuery] = useState('');
|
|
15
16
|
|
|
16
17
|
const onType = e => {
|
|
17
|
-
|
|
18
|
+
setUserQuery(e.target.value);
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setCallPath(pathMutator(userQuery, path));
|
|
23
|
+
}, [path, pathMutator, userQuery]);
|
|
24
|
+
|
|
20
25
|
return (
|
|
21
26
|
<Typedown
|
|
22
27
|
{...rest}
|
|
@@ -29,7 +34,7 @@ const QueryTypedown = ({
|
|
|
29
34
|
QueryTypedown.propTypes = {
|
|
30
35
|
dataFormatter: PropTypes.func,
|
|
31
36
|
path: PropTypes.string,
|
|
32
|
-
pathMutator: PropTypes.func
|
|
37
|
+
pathMutator: PropTypes.func,
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
export default QueryTypedown;
|
|
@@ -19,6 +19,7 @@ const propTypes = {
|
|
|
19
19
|
className: PropTypes.string,
|
|
20
20
|
dropdownTriggerProps: PropTypes.object,
|
|
21
21
|
fullWidth: PropTypes.bool,
|
|
22
|
+
id: PropTypes.string,
|
|
22
23
|
marginBottom0: PropTypes.bool,
|
|
23
24
|
selectedIndex: PropTypes.number,
|
|
24
25
|
tagName: PropTypes.string,
|
|
@@ -47,6 +48,7 @@ const ResponsiveButtonGroup = (props) => {
|
|
|
47
48
|
className,
|
|
48
49
|
dropdownTriggerProps = {},
|
|
49
50
|
fullWidth = false, // Only bother with this when buttonGroupWidth < ContainerWidth
|
|
51
|
+
id,
|
|
50
52
|
marginBottom0, // Will ONLL control the margin of the dropdown button
|
|
51
53
|
selectedIndex,
|
|
52
54
|
tagName: Tag = 'div',
|
|
@@ -61,6 +63,7 @@ const ResponsiveButtonGroup = (props) => {
|
|
|
61
63
|
ready,
|
|
62
64
|
} = useResponsiveButtonGroupSizing({
|
|
63
65
|
buttons: childButtons,
|
|
66
|
+
id
|
|
64
67
|
});
|
|
65
68
|
|
|
66
69
|
const buttonThreshold = calculateCumulativeThreshold(cachedSizeArray, containerWidth);
|
|
@@ -5,8 +5,12 @@ import { useResizeDetector } from 'react-resize-detector';
|
|
|
5
5
|
import { debounce } from 'lodash';
|
|
6
6
|
|
|
7
7
|
const useResponsiveButtonGroupSizing = ({
|
|
8
|
+
id,
|
|
8
9
|
buttons = [],
|
|
9
10
|
}) => {
|
|
11
|
+
const eventString = 'responsive-button-group-loaded' + (id ? `-${id}` : '');
|
|
12
|
+
const loadedEvent = new Event(eventString);
|
|
13
|
+
|
|
10
14
|
const isMounted = useRef(false);
|
|
11
15
|
useEffect(() => {
|
|
12
16
|
isMounted.current = true;
|
|
@@ -46,6 +50,7 @@ const useResponsiveButtonGroupSizing = ({
|
|
|
46
50
|
if (!cachedSizeArray?.length && sizeArray?.length) {
|
|
47
51
|
setCachedSizeArray(sizeArray);
|
|
48
52
|
setReady(true);
|
|
53
|
+
document.dispatchEvent(loadedEvent);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
}, 150), [cachedSizeArray, sizeArray]);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
+
|
|
3
4
|
import queryString from 'query-string';
|
|
5
|
+
import isEqual from 'lodash/isEqual';
|
|
6
|
+
|
|
7
|
+
let helperObject = {};
|
|
4
8
|
|
|
5
9
|
const useHelperApp = (helpers) => {
|
|
6
10
|
const history = useHistory();
|
|
@@ -18,6 +22,11 @@ const useHelperApp = (helpers) => {
|
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
useEffect(() => {
|
|
25
|
+
// Keep object outside of hook to avoid redraw, oncly change when keys change
|
|
26
|
+
if (!isEqual(Object.keys(helperObject), Object.keys(helpers))) {
|
|
27
|
+
helperObject = helpers;
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
if (currentHelper !== query?.helper) {
|
|
22
31
|
const newQuery = {
|
|
23
32
|
...query,
|
|
@@ -29,12 +38,7 @@ const useHelperApp = (helpers) => {
|
|
|
29
38
|
search: `?${queryString.stringify(newQuery)}`
|
|
30
39
|
});
|
|
31
40
|
}
|
|
32
|
-
}, [
|
|
33
|
-
currentHelper,
|
|
34
|
-
history,
|
|
35
|
-
location,
|
|
36
|
-
query
|
|
37
|
-
]);
|
|
41
|
+
}, [currentHelper, helpers, history, location, query]);
|
|
38
42
|
|
|
39
43
|
// Set the HelperComponent
|
|
40
44
|
const HelperComponent = useMemo(() => ((props) => {
|
|
@@ -42,7 +46,7 @@ const useHelperApp = (helpers) => {
|
|
|
42
46
|
|
|
43
47
|
let Component = null;
|
|
44
48
|
|
|
45
|
-
Component =
|
|
49
|
+
Component = helperObject[query?.helper];
|
|
46
50
|
|
|
47
51
|
if (!Component) return null;
|
|
48
52
|
|
|
@@ -52,15 +56,15 @@ const useHelperApp = (helpers) => {
|
|
|
52
56
|
{...props}
|
|
53
57
|
/>
|
|
54
58
|
);
|
|
55
|
-
}), [handleToggleHelper, query.helper
|
|
59
|
+
}), [handleToggleHelper, query.helper]);
|
|
56
60
|
|
|
57
61
|
// Set up the helperToggleFunctions
|
|
58
62
|
const helperToggleFunctions = {};
|
|
59
|
-
Object.keys(
|
|
63
|
+
Object.keys(helperObject).forEach(h => {
|
|
60
64
|
helperToggleFunctions[h] = () => handleToggleHelper(h);
|
|
61
65
|
});
|
|
62
66
|
|
|
63
|
-
return { HelperComponent, helperToggleFunctions, isOpen };
|
|
67
|
+
return { currentHelper, HelperComponent, helperToggleFunctions, isOpen };
|
|
64
68
|
};
|
|
65
69
|
|
|
66
70
|
export default useHelperApp;
|
|
@@ -1,22 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parseKiwtQueryGroups
|
|
3
|
+
* Given a string containing query groups like
|
|
4
|
+
* (foo == bar && (bat == baz || bat == quux))
|
|
5
|
+
* parse it into a series of nested arrys like
|
|
6
|
+
* [
|
|
7
|
+
* foo == bar, &&
|
|
8
|
+
* [
|
|
9
|
+
* bat == baz, ||, bat == quux
|
|
10
|
+
* ]
|
|
11
|
+
* ]
|
|
12
|
+
* Nested groups are parsed recursively. There are four tokens:
|
|
13
|
+
* ||
|
|
14
|
+
* &&
|
|
15
|
+
* (
|
|
16
|
+
* )
|
|
17
|
+
*
|
|
18
|
+
* @param {string} query
|
|
19
|
+
* @returns [] tokenized query as a series of nested arrays
|
|
20
|
+
* @throws Error if parens are unmatched
|
|
21
|
+
*/
|
|
1
22
|
const parseKiwtQueryGroups = (query) => {
|
|
2
|
-
// Split
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
|
|
23
|
+
// Split on tokens, keeping them all in tact in the correct position.
|
|
24
|
+
// This could be handled without the filter, which omits empty-string
|
|
25
|
+
// matches, using a look-behind:
|
|
26
|
+
// query.split(/(?<=\|\||&&|\(|\))|(?=\|\||&&|\(|\))/);
|
|
27
|
+
// but Webkit hasn't implemented look-behind yet so that breaks Safari.
|
|
28
|
+
// https://bugs.webkit.org/show_bug.cgi?id=174931
|
|
29
|
+
// <sigh>
|
|
30
|
+
const splitString = query.split(/(\|\||&&|\(|\))/).filter(Boolean);
|
|
6
31
|
|
|
32
|
+
// Keep track of what to skip over when we return from each level of nesting
|
|
33
|
+
let skipCount = [0];
|
|
7
34
|
|
|
8
|
-
// Ensure
|
|
9
|
-
let
|
|
35
|
+
// Ensure parens are properly closed
|
|
36
|
+
let unclosedParens = 0;
|
|
10
37
|
const groupParser = (parseArray, nestLevel = 0) => {
|
|
11
38
|
const group = [];
|
|
12
|
-
// Iterate over each element in the array, recursively calling this when hitting
|
|
39
|
+
// Iterate over each element in the array, recursively calling this when hitting parens
|
|
13
40
|
parseArray?.every((element, index) => {
|
|
14
41
|
if (skipCount[nestLevel] > 0) {
|
|
15
42
|
skipCount[nestLevel] -= 1;
|
|
16
43
|
return true; // Equivalent to BREAK -- move onto next element
|
|
17
44
|
}
|
|
18
45
|
|
|
19
|
-
//
|
|
46
|
+
// abort: dangling close-paren
|
|
20
47
|
if (nestLevel === 0 && element === ')') {
|
|
21
48
|
throw new Error('Unexpected character \')\' found, stopping parse.');
|
|
22
49
|
}
|
|
@@ -34,13 +61,13 @@ const parseKiwtQueryGroups = (query) => {
|
|
|
34
61
|
} else if (element === ')') {
|
|
35
62
|
// Remove the corresponding skipCount level because we're going down a nesting level
|
|
36
63
|
skipCount.pop();
|
|
37
|
-
|
|
64
|
+
unclosedParens -= 1;
|
|
38
65
|
|
|
39
66
|
return false; // Equivalent to BREAK -- go up a nesting level
|
|
40
67
|
} else if (element === '(') {
|
|
41
68
|
// Add next index to skipcount for the nesting
|
|
42
69
|
skipCount.push(0);
|
|
43
|
-
|
|
70
|
+
unclosedParens += 1;
|
|
44
71
|
|
|
45
72
|
group.push(groupParser(parseArray.slice(index + 1, parseArray?.length), nestLevel + 1));
|
|
46
73
|
}
|
|
@@ -54,8 +81,8 @@ const parseKiwtQueryGroups = (query) => {
|
|
|
54
81
|
|
|
55
82
|
const outputGroups = groupParser(splitString);
|
|
56
83
|
|
|
57
|
-
//
|
|
58
|
-
if (
|
|
84
|
+
// abort: dangling open-paren
|
|
85
|
+
if (unclosedParens > 0) {
|
|
59
86
|
throw new Error('Found unclosed paretheses, stopping parse.');
|
|
60
87
|
}
|
|
61
88
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import parseKiwtQueryGroups from './parseKiwtQueryGroups';
|
|
2
|
+
|
|
3
|
+
describe('parseKiwtQueryGroups', () => {
|
|
4
|
+
it('handles simple queries without parens', () => {
|
|
5
|
+
const result = parseKiwtQueryGroups('foo==bar');
|
|
6
|
+
expect(result).toEqual(['foo==bar']);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('handles simple queries with parens', () => {
|
|
10
|
+
const result = parseKiwtQueryGroups('(foo==bar)');
|
|
11
|
+
expect(result).toEqual([['foo==bar']]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('handles conjunctions', () => {
|
|
15
|
+
const result = parseKiwtQueryGroups('(foo==bar&&bat==baz)');
|
|
16
|
+
expect(result).toEqual([['foo==bar', '&&', 'bat==baz']]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('handles disjunctions', () => {
|
|
20
|
+
const result = parseKiwtQueryGroups('(foo==bar||bat==baz)');
|
|
21
|
+
expect(result).toEqual([['foo==bar', '||', 'bat==baz']]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('handles nested clauses', () => {
|
|
25
|
+
const result = parseKiwtQueryGroups('(foo==bar&&(bat==baz||bat==quux))');
|
|
26
|
+
expect(result).toEqual([['foo==bar', '&&', ['bat==baz', '||', 'bat==quux']]]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('throws on dangling (', () => {
|
|
30
|
+
try {
|
|
31
|
+
parseKiwtQueryGroups('(foo==bar');
|
|
32
|
+
} catch (e) {
|
|
33
|
+
expect(e.message).toMatch('Found unclosed paretheses, stopping parse.');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('throws on dangling )', () => {
|
|
38
|
+
try {
|
|
39
|
+
parseKiwtQueryGroups('bat==quux)');
|
|
40
|
+
} catch (e) {
|
|
41
|
+
expect(e.message).toMatch('Unexpected character \')\' found, stopping parse.');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('throws on nested dangling (', () => {
|
|
46
|
+
try {
|
|
47
|
+
parseKiwtQueryGroups('(foo==bar&&(bat==baz||bat==quux)');
|
|
48
|
+
} catch (e) {
|
|
49
|
+
expect(e.message).toMatch('Found unclosed paretheses, stopping parse.');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('throws on nested dangling )', () => {
|
|
54
|
+
try {
|
|
55
|
+
parseKiwtQueryGroups('foo==bar&&(bat==baz||bat==quux))&&(monkey==bagel||thunder==chicken)');
|
|
56
|
+
} catch (e) {
|
|
57
|
+
expect(e.message).toMatch('Unexpected character \')\' found, stopping parse.');
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|