@k-int/stripes-kint-components 3.2.1 → 4.2.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 +13 -4
- package/es/__mocks__/@folio/stripes/components.js +26 -0
- package/es/__mocks__/@folio/stripes/core.js +10 -0
- package/es/__mocks__/@folio/stripes/smart-components.js +10 -0
- package/es/__mocks__/currency-codes/data.js +6 -0
- package/es/__mocks__/react-query.js +10 -0
- package/es/__mocks__/react-router-dom.js +10 -0
- package/es/__mocks__/stripes-config.js +4 -0
- package/es/index.js +72 -108
- package/es/lib/ActionList/ActionList.js +3 -1
- package/es/lib/ActionList/ActionListFieldArray.js +16 -10
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +5 -2
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.test.js +0 -1
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +6 -4
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.test.js +1 -2
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +1 -1
- package/es/lib/CustomProperties/Config/CustomPropertyForm.test.js +7 -6
- package/es/lib/CustomProperties/Config/CustomPropertyView.test.js +1 -2
- package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.test.js +0 -1
- package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.test.js +0 -1
- package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +5 -3
- package/es/lib/CustomProperties/Edit/CustomPropertiesListField.test.js +3 -4
- package/es/lib/CustomProperties/Edit/CustomPropertyField.js +3 -1
- package/es/lib/CustomProperties/Edit/CustomPropertyField.test.js +11 -10
- package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +0 -1
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +5 -2
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.test.js +1 -2
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +5 -2
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +2 -3
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.test.js +3 -4
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +4 -1
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.test.js +5 -4
- package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +4 -1
- package/es/lib/CustomProperties/Filter/CustomPropertiesRule.test.js +3 -4
- package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +1 -1
- package/es/lib/CustomProperties/View/CustomPropertiesView.test.js +0 -1
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +1 -1
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.test.js +4 -2
- package/es/lib/CycleButton/CycleButton.js +5 -2
- package/es/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +6 -4
- package/es/lib/EditableRefdataList/EditableRefdataList.js +6 -4
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +4 -1
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +6 -7
- package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +10 -11
- package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +1 -2
- package/es/lib/EditableSettingsList/SettingField/SettingField.js +4 -2
- package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +4 -5
- package/es/lib/FormModal/FormModal.js +4 -1
- package/es/lib/FormattedKintMessage/FormattedKintMessage.js +4 -1
- package/es/lib/IconSelect/IconSelect.js +4 -2
- package/es/lib/QueryTypedown/QueryTypedown.js +4 -2
- package/es/lib/RefdataButtons/RefdataButtons.js +4 -1
- package/es/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +19 -9
- package/es/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +1 -1
- package/es/lib/RichSelect/RichSelect.js +5 -2
- package/es/lib/RichSelect/useSelectedOption.js +1 -1
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +5 -2
- package/es/lib/SASQLookupComponent/TableBody/TableBody.js +4 -1
- package/es/lib/SASQRoute/SASQRoute.js +4 -1
- package/es/lib/SASQViewComponent/SASQViewComponent.js +4 -1
- package/es/lib/SearchField/SearchField.js +4 -1
- package/es/lib/Typedown/Typedown.js +1 -1
- package/es/lib/hooks/settingsHooks/useSettings.js +4 -1
- package/es/lib/hooks/typedownHooks/useTypedownData.js +1 -1
- package/es/lib/hooks/typedownHooks/useTypedownToggle.js +1 -1
- package/es/lib/hooks/useActiveElement.js +1 -1
- package/es/lib/hooks/useCustomProperties.js +4 -1
- package/es/lib/hooks/useHelperApp.js +4 -2
- package/es/lib/hooks/useIntlKeyStore.js +4 -4
- package/es/lib/hooks/useKintIntl.js +4 -1
- package/es/lib/hooks/useKiwtFieldArray.js +5 -2
- package/es/lib/hooks/useKiwtSASQuery.js +4 -2
- package/es/lib/hooks/useLocalStorageState.js +1 -1
- package/es/lib/hooks/useMutateCustomProperties.js +1 -1
- package/es/lib/hooks/useMutateRefdataCategory.js +4 -2
- package/es/lib/hooks/useMutateRefdataValue.js +1 -1
- package/es/lib/hooks/useQIndex.js +4 -2
- package/es/lib/utils/generateKiwtQuery.js +3 -4
- package/es/lib/utils/generateKiwtQueryParams.js +74 -30
- package/es/lib/utils/groupCustomPropertiesByCtx.js +4 -1
- package/es/lib/utils/highlightString.js +1 -1
- package/es/lib/utils/index.js +7 -0
- package/es/lib/utils/parseErrorResponse.js +23 -19
- package/es/lib/utils/parseKiwtQueryGroups.js +66 -0
- package/jest.config.js +1 -1
- package/junit.xml +144 -144
- package/package.json +3 -3
- package/src/__mocks__/@folio/stripes/components.js +11 -0
- package/src/__mocks__/@folio/stripes/core.js +6 -0
- package/src/__mocks__/@folio/stripes/smart-components.js +6 -0
- package/src/__mocks__/currency-codes/data.js +4 -0
- package/src/__mocks__/react-query.js +6 -0
- package/src/__mocks__/react-router-dom.js +7 -0
- package/src/__mocks__/stripes-config.js +3 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +49 -7
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +7 -7
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyView.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/testResources.js.html +793 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEdit.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEditCtx.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesListField.js.html +6 -9
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyField.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyFormCard.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/index.html +10 -10
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterField.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterForm.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesRule.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/index.html +1 -1
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useOperators.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useParseActiveFilterStrings.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useValueProps.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesView.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesViewCtx.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertyCard.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/index.html +1 -1
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormModal/FormModal.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormModal/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormModal/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormattedKintMessage/FormattedKintMessage.js.html +1 -1
- 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 +28 -22
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/ResponsiveButtonGroup.js.html +36 -12
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/index.html +9 -9
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RichSelect/RichSelect.js.html +5 -2
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useAppSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.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/useAvailableCustomProperties.js.html +205 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useIntlKey.js.html +1 -1
- 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 +1 -1
- 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 +31 -31
- package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +8 -8
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +196 -46
- package/src/artifacts/coverage-jest/lcov-report/utils/groupCustomPropertiesByCtx.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/highlightString.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/index.html +44 -29
- package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +8 -2
- package/src/artifacts/coverage-jest/lcov-report/utils/matchString.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/parseErrorResponse.js.html +11 -8
- package/src/artifacts/coverage-jest/lcov-report/utils/parseKiwtQueryGroups.js.html +280 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataQueryKey.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +166 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/typedownQueryKey.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/validators.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov.info +476 -345
- package/src/index.js +2 -25
- package/src/lib/ActionList/ActionListFieldArray.js +16 -2
- package/src/lib/CustomProperties/Config/CustomPropertiesLookup.test.js +1 -1
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.test.js +1 -1
- package/src/lib/CustomProperties/Config/CustomPropertyForm.test.js +2 -2
- package/src/lib/CustomProperties/Config/CustomPropertyView.test.js +1 -1
- package/src/lib/CustomProperties/Edit/CustomPropertiesEdit.test.js +1 -1
- package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.test.js +1 -1
- package/src/lib/CustomProperties/Edit/CustomPropertiesListField.js +0 -1
- package/src/lib/CustomProperties/Edit/CustomPropertiesListField.test.js +2 -2
- package/src/lib/CustomProperties/Edit/CustomPropertyField.test.js +2 -2
- package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +1 -1
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.test.js +1 -1
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +2 -2
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.test.js +2 -2
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.test.js +1 -1
- package/src/lib/CustomProperties/Filter/CustomPropertiesRule.test.js +2 -2
- package/src/lib/CustomProperties/View/CustomPropertiesView.test.js +1 -1
- package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.test.js +1 -1
- package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +2 -2
- package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +2 -2
- package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +1 -1
- package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +2 -2
- package/src/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +13 -5
- package/src/lib/utils/README.md +3 -1
- package/src/lib/utils/generateKiwtQuery.js +3 -3
- package/src/lib/utils/generateKiwtQueryParams.js +78 -28
- package/src/lib/utils/index.js +2 -0
- package/src/lib/utils/parseErrorResponse.js +3 -2
- package/src/lib/utils/parseKiwtQueryGroups.js +65 -0
- package/styles/ResponsiveButtonGroup.css +12 -1
- package/test/helpers/translationsProperties.js +3 -34
- package/test/jest/helpers/KintHarness.js +1 -1
- package/yarn-error.log +0 -147
package/src/index.js
CHANGED
|
@@ -20,31 +20,8 @@ export {
|
|
|
20
20
|
useSASQQueryMeta
|
|
21
21
|
} from './lib/hooks';
|
|
22
22
|
|
|
23
|
-
// Useful utility
|
|
24
|
-
export
|
|
25
|
-
boldString,
|
|
26
|
-
generateKiwtQuery,
|
|
27
|
-
generateKiwtQueryParams,
|
|
28
|
-
groupCustomPropertiesByCtx,
|
|
29
|
-
highlightString,
|
|
30
|
-
matchString,
|
|
31
|
-
refdataOptions,
|
|
32
|
-
refdataQueryKey,
|
|
33
|
-
selectorSafe,
|
|
34
|
-
typedownQueryKey,
|
|
35
|
-
parseErrorResponse,
|
|
36
|
-
} from './lib/utils';
|
|
37
|
-
|
|
38
|
-
// Validators
|
|
39
|
-
export {
|
|
40
|
-
composeValidators,
|
|
41
|
-
composeValidatorsWithArgs,
|
|
42
|
-
invalidNumber,
|
|
43
|
-
rangeOverflow,
|
|
44
|
-
rangeUnderflow,
|
|
45
|
-
required,
|
|
46
|
-
requiredObject,
|
|
47
|
-
} from './lib/utils';
|
|
23
|
+
// Useful utility stuff
|
|
24
|
+
export * from './lib/utils';
|
|
48
25
|
|
|
49
26
|
// Contexts
|
|
50
27
|
export {
|
|
@@ -280,7 +280,14 @@ const ActionListFieldArray = forwardRef(({
|
|
|
280
280
|
aria-describedby={ariaIds.sub}
|
|
281
281
|
aria-labelledby={ariaIds.text}
|
|
282
282
|
disabled={editing}
|
|
283
|
-
onClick={
|
|
283
|
+
onClick={e => {
|
|
284
|
+
e.stopPropagation();
|
|
285
|
+
if (actionFunction) {
|
|
286
|
+
return actionFunction();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return null;
|
|
290
|
+
}}
|
|
284
291
|
to={action.to}
|
|
285
292
|
/>
|
|
286
293
|
)}
|
|
@@ -295,7 +302,14 @@ const ActionListFieldArray = forwardRef(({
|
|
|
295
302
|
action={action}
|
|
296
303
|
ariaLabel={ariaLabel}
|
|
297
304
|
disabled={editing}
|
|
298
|
-
onClick={
|
|
305
|
+
onClick={e => {
|
|
306
|
+
e.stopPropagation();
|
|
307
|
+
if (actionFunction) {
|
|
308
|
+
return actionFunction();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return null;
|
|
312
|
+
}}
|
|
299
313
|
to={action.to}
|
|
300
314
|
/>
|
|
301
315
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { TextArea, TextField } from '@folio/stripes-testing';
|
|
4
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
4
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
5
5
|
|
|
6
6
|
import refdata from '../../../../test/jest/refdata';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Button, KeyValue } from '@folio/stripes-testing';
|
|
4
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
4
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
5
5
|
import { waitFor } from '@testing-library/react';
|
|
6
6
|
|
|
7
7
|
import { initialValues } from './testResources';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { TextArea, MultiSelect, TextInput, Datepicker } from '@folio/stripes-testing';
|
|
4
4
|
|
|
5
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
5
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
6
6
|
import CustomPropertyField from './CustomPropertyField';
|
|
7
7
|
|
|
8
8
|
import { availableCustomProperties, customProperties, renderWithKintHarness } from '../../../../test/jest';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldArray } from 'react-final-form-arrays';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
4
|
+
|
|
5
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
6
6
|
import { MemoryRouter } from 'react-router-dom';
|
|
7
7
|
|
|
8
8
|
import CustomPropertiesFilterField from './CustomPropertiesFilterField';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
2
|
+
|
|
3
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
4
4
|
import { waitFor } from '@testing-library/react';
|
|
5
5
|
import { Button } from '@folio/stripes-testing';
|
|
6
6
|
import { FieldArray } from 'react-final-form-arrays';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { MemoryRouter } from 'react-router-dom';
|
|
4
4
|
import { Select } from '@folio/stripes-testing';
|
|
5
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
5
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
6
6
|
|
|
7
7
|
import CustomPropertiesRule from './CustomPropertiesRule';
|
|
8
8
|
import { renderWithKintHarness } from '../../../../test/jest';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
2
|
+
|
|
3
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
4
4
|
import { FieldArray } from 'react-final-form-arrays';
|
|
5
5
|
import EditableSettingsListFieldArray from './EditableSettingsListFieldArray';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
3
|
+
|
|
4
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
5
5
|
|
|
6
6
|
import EditSettingValue from './EditSettingValue';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
|
|
4
4
|
import { waitFor } from '@testing-library/react';
|
|
5
5
|
|
|
6
|
-
import { TestForm } from '@folio/stripes-erm-
|
|
6
|
+
import { TestForm } from '@folio/stripes-erm-testing';
|
|
7
7
|
import { Button } from '@folio/stripes-testing';
|
|
8
8
|
import { Field } from 'react-final-form';
|
|
9
9
|
import SettingField from './SettingField';
|
|
@@ -18,6 +18,7 @@ const propTypes = {
|
|
|
18
18
|
children: PropTypes.node,
|
|
19
19
|
className: PropTypes.string,
|
|
20
20
|
fullWidth: PropTypes.bool,
|
|
21
|
+
marginBottom0: PropTypes.bool,
|
|
21
22
|
selectedIndex: PropTypes.number,
|
|
22
23
|
tagName: PropTypes.string,
|
|
23
24
|
};
|
|
@@ -44,6 +45,7 @@ const ResponsiveButtonGroup = (props) => {
|
|
|
44
45
|
children: childButtons, // These MUST consist only of Button components
|
|
45
46
|
className,
|
|
46
47
|
fullWidth = false, // Only bother with this when buttonGroupWidth < ContainerWidth
|
|
48
|
+
marginBottom0, // Will ONLL control the margin of the dropdown button
|
|
47
49
|
selectedIndex,
|
|
48
50
|
tagName: Tag = 'div',
|
|
49
51
|
...rest
|
|
@@ -61,12 +63,18 @@ const ResponsiveButtonGroup = (props) => {
|
|
|
61
63
|
|
|
62
64
|
const buttonThreshold = calculateCumulativeThreshold(cachedSizeArray, containerWidth);
|
|
63
65
|
|
|
64
|
-
const renderActionMenuToggle = useCallback(({ onToggle, triggerRef, keyHandler, open, ariaProps, getTriggerProps }) => (
|
|
66
|
+
const renderActionMenuToggle = useCallback(({ displayButtons, onToggle, triggerRef, keyHandler, open, ariaProps, getTriggerProps }) => (
|
|
65
67
|
<Button
|
|
66
68
|
ref={triggerRef}
|
|
67
|
-
buttonClass={
|
|
69
|
+
buttonClass={
|
|
70
|
+
classnames(
|
|
71
|
+
css.width100,
|
|
72
|
+
{ [`${css.dropdownButtonClass}`]: (displayButtons?.length ?? 0) > 0 },
|
|
73
|
+
{ [`${css.marginBottom}`]: !marginBottom0 },
|
|
74
|
+
{ [`${css.marginBottom0}`]: marginBottom0 }
|
|
75
|
+
)
|
|
76
|
+
}
|
|
68
77
|
buttonStyle={selectedIndex > buttonThreshold ? 'primary' : 'default'}
|
|
69
|
-
marginBottom0
|
|
70
78
|
onClick={onToggle}
|
|
71
79
|
onKeyDown={keyHandler}
|
|
72
80
|
type="button"
|
|
@@ -75,7 +83,7 @@ const ResponsiveButtonGroup = (props) => {
|
|
|
75
83
|
>
|
|
76
84
|
<Icon icon={open ? 'triangle-up' : 'triangle-down'} iconPosition="end" />
|
|
77
85
|
</Button>
|
|
78
|
-
), [buttonThreshold, selectedIndex]);
|
|
86
|
+
), [buttonThreshold, marginBottom0, selectedIndex]);
|
|
79
87
|
|
|
80
88
|
const displayButtons = useMemo(() => (
|
|
81
89
|
buttons?.slice(0, buttonThreshold + 1)?.map((button, index) => {
|
|
@@ -110,7 +118,7 @@ const ResponsiveButtonGroup = (props) => {
|
|
|
110
118
|
key="responsiveButtonGroup-dropdown-toggle"
|
|
111
119
|
className={css.dropdownClass}
|
|
112
120
|
renderMenu={renderActionMenuContent}
|
|
113
|
-
renderTrigger={renderActionMenuToggle}
|
|
121
|
+
renderTrigger={(triggerProps) => renderActionMenuToggle({ displayButtons, ...triggerProps })}
|
|
114
122
|
/>
|
|
115
123
|
]
|
|
116
124
|
), [displayButtons, renderActionMenuContent, renderActionMenuToggle]);
|
package/src/lib/utils/README.md
CHANGED
|
@@ -31,6 +31,7 @@ Name | Type | Description | default | required
|
|
|
31
31
|
--- | --- | --- | --- | ---
|
|
32
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
33
|
nsValues | object | An object containing the actual query parameters to become the mapped KIWT query | | ✓ |
|
|
34
|
+
encode | boolean | A boolean prop which determines if each query param chunk will be encoded using encodeURIComponent or not | true | ✕ |
|
|
34
35
|
|
|
35
36
|
## generateKiwtQueryParams
|
|
36
37
|
A util function for generating an array of "KIWT" (K-Int Web-Toolkit) style backend query parameters from a SASQ query object
|
|
@@ -68,4 +69,5 @@ import { generateKiwtQueryParams } from '@k-int/stripes-kint-components'
|
|
|
68
69
|
Name | Type | Description | default | required
|
|
69
70
|
--- | --- | --- | --- | ---
|
|
70
71
|
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. | | ✓ |
|
|
71
|
-
nsValues | object | An object containing the actual query parameters to become the mapped KIWT query | | ✓ |
|
|
72
|
+
nsValues | object | An object containing the actual query parameters to become the mapped KIWT query | | ✓ |
|
|
73
|
+
encode | boolean | A boolean prop which determines if each query param chunk will be encoded using encodeURIComponent or not | true | ✕ |
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import generateKiwtQueryParams from './generateKiwtQueryParams';
|
|
2
2
|
|
|
3
|
-
const generateKiwtQuery = (options, nsValues) => {
|
|
4
|
-
const paramsArray = generateKiwtQueryParams(options, nsValues);
|
|
5
|
-
return paramsArray.length ? '?' + paramsArray.
|
|
3
|
+
const generateKiwtQuery = (options, nsValues, encode = true) => {
|
|
4
|
+
const paramsArray = generateKiwtQueryParams(options, nsValues, encode);
|
|
5
|
+
return paramsArray.length ? '?' + paramsArray.join('&') : '';
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export default generateKiwtQuery;
|
|
@@ -1,4 +1,55 @@
|
|
|
1
|
-
const
|
|
1
|
+
const conditionalEncodeURIComponent = (str, encode = true) => {
|
|
2
|
+
if (encode) {
|
|
3
|
+
return encodeURIComponent(str);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return str;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const buildFilterOptionBlock = (opf, isNested = false, encode = true) => {
|
|
10
|
+
if (opf?.groupValues) {
|
|
11
|
+
const groupValues = opf.groupValues;
|
|
12
|
+
|
|
13
|
+
// Small utility function to add negation and brackets to the options block where necessary
|
|
14
|
+
const negationAndNesting = (str) => `${groupValues?.NOT ? '!' : ''}${(isNested || groupValues?.NOT) ? '(' : ''}${str}${(isNested || groupValues?.NOT) ? ')' : ''}`;
|
|
15
|
+
|
|
16
|
+
// First check whether groupValues is ANDed or ORed together
|
|
17
|
+
if (
|
|
18
|
+
(groupValues?.AND && Array.isArray(groupValues.AND)) ||
|
|
19
|
+
(groupValues?.OR && Array.isArray(groupValues.OR))
|
|
20
|
+
) {
|
|
21
|
+
// AND takes precedence
|
|
22
|
+
if (groupValues.AND) {
|
|
23
|
+
return negationAndNesting(groupValues?.AND?.map(gvo => buildFilterOptionBlock(gvo, true, encode))?.join('&&'));
|
|
24
|
+
}
|
|
25
|
+
return negationAndNesting(groupValues?.OR?.map(gvo => buildFilterOptionBlock(gvo, true, encode))?.join('||'));
|
|
26
|
+
}
|
|
27
|
+
// If neither valid OR nor AND exist, ignore the block
|
|
28
|
+
} else if (opf?.values) {
|
|
29
|
+
// Build the values filter block
|
|
30
|
+
const innerFilters = [];
|
|
31
|
+
opf.values.forEach(opfv => {
|
|
32
|
+
if (opf.path) {
|
|
33
|
+
innerFilters.push(`${opf.path}${opf.comparator ?? '=='}${opfv}`);
|
|
34
|
+
} else {
|
|
35
|
+
innerFilters.push(opfv);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return conditionalEncodeURIComponent(innerFilters.join('||'), encode);
|
|
40
|
+
} else if (opf?.value) { // If no value OR values, then ignore
|
|
41
|
+
if (opf.path) {
|
|
42
|
+
const filterString = `${opf.path}${opf.comparator ?? '=='}${opf.value}`;
|
|
43
|
+
return conditionalEncodeURIComponent(filterString, encode);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return conditionalEncodeURIComponent(opf.value, encode);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const generateKiwtQueryParams = (options, nsValues, encode = true) => {
|
|
2
53
|
const { qindex, query, filters, sort } = nsValues;
|
|
3
54
|
const {
|
|
4
55
|
searchKey = '',
|
|
@@ -18,7 +69,13 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
18
69
|
path: 'this.is.some.path'
|
|
19
70
|
comparator: '=='
|
|
20
71
|
value: 'this is a value' //OR
|
|
21
|
-
values: ['value1', 'value2']
|
|
72
|
+
values: ['value1', 'value2'] //OR
|
|
73
|
+
groupValues: { // This is an object containing objects either in groups of AND or OR. AND takes precedence
|
|
74
|
+
AND: [
|
|
75
|
+
// Objects of the same shape as an individual filters object, recursively.
|
|
76
|
+
],
|
|
77
|
+
NOT: true // When this is set to true, the entire group is negated
|
|
78
|
+
}
|
|
22
79
|
},
|
|
23
80
|
...
|
|
24
81
|
]
|
|
@@ -27,6 +84,9 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
27
84
|
* If no comparator is passed, it assumes '=='
|
|
28
85
|
* Values overwrites value and will construct "filters=this.is.some.path==value1||this.is.some.path==value2"
|
|
29
86
|
* Values WITHOUT path will construct "filters=value1||value2"
|
|
87
|
+
*
|
|
88
|
+
* GroupValues will override everything above, and group into brackets.
|
|
89
|
+
*
|
|
30
90
|
* If more complex query building is desired, this should be done externally and passed in as a standalone 'value'
|
|
31
91
|
*/
|
|
32
92
|
filters: optionsFilters,
|
|
@@ -36,29 +96,16 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
36
96
|
const paramsArray = [];
|
|
37
97
|
|
|
38
98
|
if (query) {
|
|
39
|
-
paramsArray.push(...(qindex || searchKey).split(',')?.map(m => `match=${m}`));
|
|
40
|
-
paramsArray.push(`term=${query}`);
|
|
99
|
+
paramsArray.push(...(qindex || searchKey).split(',')?.map(m => `match=${conditionalEncodeURIComponent(m, encode)}`));
|
|
100
|
+
paramsArray.push(`term=${conditionalEncodeURIComponent(query, encode)}`);
|
|
41
101
|
}
|
|
42
102
|
|
|
103
|
+
// Actually build the optionsFilters block (Moved logic to its own function to allow recursion)
|
|
43
104
|
if (optionsFilters) {
|
|
44
105
|
optionsFilters.forEach(opf => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
opf.values.forEach(opfv => {
|
|
49
|
-
if (opf.path) {
|
|
50
|
-
innerFilters.push(`${opf.path}${opf.comparator ?? '=='}${opfv}`);
|
|
51
|
-
} else {
|
|
52
|
-
innerFilters.push(opfv);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
paramsArray.push(`filters=${innerFilters.join('||')}`);
|
|
56
|
-
} else if (opf?.value) { // If no value OR values, then ignore
|
|
57
|
-
if (opf.path) {
|
|
58
|
-
paramsArray.push(`filters=${opf.path}${opf.comparator ?? '=='}${opf.value}`);
|
|
59
|
-
} else {
|
|
60
|
-
paramsArray.push(`filters=${opf.value}`);
|
|
61
|
-
}
|
|
106
|
+
const optionsBlock = buildFilterOptionBlock(opf, false, encode);
|
|
107
|
+
if (optionsBlock) {
|
|
108
|
+
paramsArray.push(`filters=${optionsBlock}`);
|
|
62
109
|
}
|
|
63
110
|
});
|
|
64
111
|
}
|
|
@@ -84,13 +131,13 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
84
131
|
return `${filterName}==${fceValue ?? v}`;
|
|
85
132
|
}).join('||');
|
|
86
133
|
|
|
87
|
-
paramsArray.push(`filters=${filterString}`);
|
|
134
|
+
paramsArray.push(`filters=${conditionalEncodeURIComponent(filterString, encode)}`);
|
|
88
135
|
} else if (!filterKey) {
|
|
89
136
|
// These filters have no key mapping so we just pass the values to the backend as-is.
|
|
90
|
-
paramsArray.push(...filterValues?.map(f => `filters=${f}`));
|
|
137
|
+
paramsArray.push(...filterValues?.map(f => `filters=${conditionalEncodeURIComponent(f, encode)}`));
|
|
91
138
|
} else {
|
|
92
139
|
const filterString = filterValues.map(v => `${filterKey}==${v}`).join('||');
|
|
93
|
-
paramsArray.push(`filters=${filterString}`);
|
|
140
|
+
paramsArray.push(`filters=${conditionalEncodeURIComponent(filterString, encode)}`);
|
|
94
141
|
}
|
|
95
142
|
});
|
|
96
143
|
}
|
|
@@ -98,9 +145,10 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
98
145
|
if (optionsSort && optionsSort.length > 0) {
|
|
99
146
|
optionsSort.forEach(os => {
|
|
100
147
|
if (os.value) {
|
|
101
|
-
paramsArray.push(`sort=${os.value}`);
|
|
148
|
+
paramsArray.push(`sort=${conditionalEncodeURIComponent(os.value, encode)}`);
|
|
102
149
|
} else if (os.path) { // If no path then ignore
|
|
103
|
-
|
|
150
|
+
const sortString = `${os.path};${os.direction ?? 'asc'}`;
|
|
151
|
+
paramsArray.push(`sort=${conditionalEncodeURIComponent(sortString, encode)}`);
|
|
104
152
|
}
|
|
105
153
|
});
|
|
106
154
|
}
|
|
@@ -114,7 +162,9 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
114
162
|
term = term.replace(term, sortKeys[term]);
|
|
115
163
|
}
|
|
116
164
|
|
|
117
|
-
|
|
165
|
+
const sortString = `${term};${descending ? 'desc' : 'asc'}`;
|
|
166
|
+
|
|
167
|
+
return `sort=${conditionalEncodeURIComponent(sortString, encode)}`;
|
|
118
168
|
}));
|
|
119
169
|
}
|
|
120
170
|
|
|
@@ -123,7 +173,7 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
123
173
|
}
|
|
124
174
|
|
|
125
175
|
for (const [key, value] of Object.entries(rest)) {
|
|
126
|
-
paramsArray.push(`${key}=${value}`);
|
|
176
|
+
paramsArray.push(`${key}=${conditionalEncodeURIComponent(value, encode)}`);
|
|
127
177
|
}
|
|
128
178
|
|
|
129
179
|
return paramsArray;
|
package/src/lib/utils/index.js
CHANGED
|
@@ -19,6 +19,8 @@ export { default as toCamelCase } from './toCamelCase'; // I hate that this exis
|
|
|
19
19
|
export { default as matchString } from './matchString';
|
|
20
20
|
export { boldString, highlightString } from './highlightString';
|
|
21
21
|
|
|
22
|
+
export { default as parseKiwtQueryGroups } from './parseKiwtQueryGroups';
|
|
23
|
+
|
|
22
24
|
// HTTP Utils
|
|
23
25
|
export { default as parseErrorResponse } from './parseErrorResponse';
|
|
24
26
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
const parseErrorResponse = async (responseObj) => {
|
|
2
2
|
let errorResp;
|
|
3
|
+
const code = responseObj?.status;
|
|
3
4
|
const contentType = [...responseObj?.headers]?.find(header => header[0] === 'content-type')?.[1];
|
|
4
5
|
|
|
5
6
|
if (contentType.includes('json')) {
|
|
6
7
|
errorResp = await responseObj.json();
|
|
7
8
|
} else {
|
|
8
9
|
try {
|
|
9
|
-
errorResp = { message: await responseObj.text() };
|
|
10
|
+
errorResp = { code, message: await responseObj.text() };
|
|
10
11
|
} catch {
|
|
11
|
-
errorResp = { message: 'something went wrong' };
|
|
12
|
+
errorResp = { code, message: 'something went wrong' };
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const parseKiwtQueryGroups = (query) => {
|
|
2
|
+
// Split out all operators and brackets, but keeping them all intact in the correct potition.
|
|
3
|
+
const splitString = query.split(/(?<=\|\||&&|\(|\))|(?=\|\||&&|\(|\))/);
|
|
4
|
+
// Keep track of what to skip over when wereturn from each level of nesting
|
|
5
|
+
let skipCount = [0];
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// Ensure brackets are properly closed
|
|
9
|
+
let unclosedBrackets = 0;
|
|
10
|
+
const groupParser = (parseArray, nestLevel = 0) => {
|
|
11
|
+
const group = [];
|
|
12
|
+
// Iterate over each element in the array, recursively calling this when hitting brackets
|
|
13
|
+
parseArray?.every((element, index) => {
|
|
14
|
+
if (skipCount[nestLevel] > 0) {
|
|
15
|
+
skipCount[nestLevel] -= 1;
|
|
16
|
+
return true; // Equivalent to BREAK -- move onto next element
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Deal with unexpected extra closure
|
|
20
|
+
if (nestLevel === 0 && element === ')') {
|
|
21
|
+
throw new Error('Unexpected character \')\' found, stopping parse.');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// At the levels below all of the following will need
|
|
25
|
+
skipCount = skipCount?.map((n, i) => {
|
|
26
|
+
if (i < nestLevel) {
|
|
27
|
+
return n + 1;
|
|
28
|
+
}
|
|
29
|
+
return n;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (element !== '(' && element !== ')') {
|
|
33
|
+
group?.push(element);
|
|
34
|
+
} else if (element === ')') {
|
|
35
|
+
// Remove the corresponding skipCount level because we're going down a nesting level
|
|
36
|
+
skipCount.pop();
|
|
37
|
+
unclosedBrackets -= 1;
|
|
38
|
+
|
|
39
|
+
return false; // Equivalent to BREAK -- go up a nesting level
|
|
40
|
+
} else if (element === '(') {
|
|
41
|
+
// Add next index to skipcount for the nesting
|
|
42
|
+
skipCount.push(0);
|
|
43
|
+
unclosedBrackets += 1;
|
|
44
|
+
|
|
45
|
+
group.push(groupParser(parseArray.slice(index + 1, parseArray?.length), nestLevel + 1));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// If all is well, continue on parsing
|
|
49
|
+
return true;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return group;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const outputGroups = groupParser(splitString);
|
|
56
|
+
|
|
57
|
+
// Deal with unclosed parentheses
|
|
58
|
+
if (unclosedBrackets > 0) {
|
|
59
|
+
throw new Error('Found unclosed paretheses, stopping parse.');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return outputGroups;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default parseKiwtQueryGroups;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
@import '@folio/stripes-components/lib/variables.css';
|
|
2
2
|
|
|
3
|
+
.width100 {
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.marginBottom {
|
|
8
|
+
margin-bottom: var(--gutter);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.marginBottom0 {
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
.buttonGroup {
|
|
4
16
|
display: inline-flex;
|
|
5
17
|
justify-content: space-between;
|
|
@@ -66,7 +78,6 @@
|
|
|
66
78
|
.dropdownButtonClass {
|
|
67
79
|
border-top-left-radius: 0;
|
|
68
80
|
border-bottom-left-radius: 0;
|
|
69
|
-
width: 100%;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
.dropdownButtonClass::before {
|