@k-int/stripes-kint-components 5.29.1 → 5.31.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 +21 -0
- package/es/__mocks__/@folio/stripes/components.js +3 -7
- package/es/__mocks__/@folio/stripes/core.js +4 -6
- package/es/__mocks__/@folio/stripes/smart-components.js +4 -6
- package/es/__mocks__/react-query.js +4 -6
- package/es/__mocks__/react-router-dom.js +6 -6
- package/es/index.js +8 -0
- package/es/lib/ActionList/ActionList.js +26 -33
- package/es/lib/ActionList/ActionListFieldArray.js +103 -119
- package/es/lib/ButtonTypedown/ButtonTypedown.js +58 -0
- package/es/lib/ButtonTypedown/index.js +13 -0
- package/es/lib/ComboButton/ComboButton.js +42 -47
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +11 -17
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +42 -46
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +58 -58
- package/es/lib/CustomProperties/Config/CustomPropertyForm.test.js +4 -8
- package/es/lib/CustomProperties/Config/CustomPropertyView.js +32 -33
- package/es/lib/CustomProperties/Config/CustomPropertyView.test.js +1 -1
- package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +1 -1
- package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +3 -3
- package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +29 -35
- package/es/lib/CustomProperties/Edit/CustomPropertyField.js +61 -59
- package/es/lib/CustomProperties/Edit/CustomPropertyField.test.js +20 -20
- package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +2 -2
- package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +1 -1
- package/es/lib/CustomProperties/Edit/testResources.js +11 -12
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +22 -33
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +23 -35
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +1 -1
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +6 -6
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +3 -6
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.test.js +4 -8
- package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +14 -17
- package/es/lib/CustomProperties/Filter/testResources.js +1 -2
- package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +1 -2
- package/es/lib/CustomProperties/View/CustomPropertiesView.js +1 -1
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +18 -26
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.test.js +3 -6
- package/es/lib/CustomProperties/View/CustomPropertyCard.js +7 -11
- package/es/lib/CycleButton/CycleButton.js +9 -17
- package/es/lib/FormModal/FormModal.js +24 -32
- package/es/lib/FormattedKintMessage/FormattedKintMessage.js +23 -30
- package/es/lib/IconSelect/IconSelect.js +22 -32
- package/es/lib/NoResultsMessage/NoResultsMessage.js +4 -5
- package/es/lib/NumberField/NumberField.js +17 -25
- package/es/lib/NumberField/NumberField.test.js +6 -7
- package/es/lib/QueryTypedown/QueryTypedown.js +8 -15
- package/es/lib/RefdataButtons/RefdataButtons.js +6 -9
- package/es/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +48 -60
- package/es/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +5 -6
- package/es/lib/RichSelect/RichSelect.js +31 -36
- package/es/lib/RichSelect/useSelectedOption.js +1 -2
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +91 -94
- package/es/lib/SASQLookupComponent/TableBody/TableBody.js +42 -52
- package/es/lib/SASQRoute/SASQRoute.js +25 -29
- package/es/lib/SASQViewComponent/SASQViewComponent.js +68 -76
- package/es/lib/SearchField/SearchField.js +7 -13
- package/es/lib/SearchKeyControl/SearchKeyControl.js +8 -13
- package/es/lib/SearchKeyControl/SearchKeyControl.test.js +2 -6
- package/es/lib/Settings/EditableRefdataCategoryList/EditableRefdataCategoryList.js +30 -46
- package/es/lib/Settings/EditableRefdataList/EditableRefdataList.js +33 -43
- package/es/lib/Settings/EditableSettingsList/EditableSettingsListFieldArray/EditableSettingsListFieldArray.js +7 -11
- package/es/lib/Settings/EditableSettingsList/SettingField/EditSettingValue/EditSettingValue.js +13 -20
- package/es/lib/Settings/EditableSettingsList/SettingField/RenderSettingValue/RenderSettingValue.js +10 -12
- package/es/lib/Settings/EditableSettingsList/SettingField/SettingField.js +10 -15
- package/es/lib/Settings/EditableSettingsList/SettingField/SettingField.test.js +3 -3
- package/es/lib/Settings/RefdataCategoriesSettings/RefdataCategoriesSettings.js +19 -26
- package/es/lib/Settings/SettingPage/SettingPagePane/SettingPagePane.js +2 -2
- package/es/lib/Settings/SettingsFormContainer/SettingsFormContainer.js +30 -35
- package/es/lib/Settings/StaticSettingsField/StaticSettingsField.js +5 -8
- package/es/lib/Settings/StaticSettingsField/StaticSettingsFieldComponent/StaticSettingsFieldComponent.js +18 -22
- package/es/lib/Settings/hooks/staticSettingsPages/useSettingCallout/useSettingCallout.js +2 -2
- package/es/lib/Settings/hooks/staticSettingsPages/useSettingsSectionInitalValues/useSettingsSectionInitalValues.js +1 -1
- package/es/lib/Settings/hooks/staticSettingsPages/useStaticSettingsSection.js +3 -7
- package/es/lib/Settings/hooks/useAppSettings/useAppSettings.js +7 -11
- package/es/lib/Settings/hooks/useSettingSection/useSettingSection.js +16 -22
- package/es/lib/Settings/hooks/useSettings/useSettings.js +60 -60
- package/es/lib/Tags/Tags.js +5 -8
- package/es/lib/Tags/hooks/useTags.js +1 -1
- package/es/lib/Tags/hooks/useTagsEnabled.js +34 -4
- package/es/lib/Tags/tagsConfig.js +1 -1
- package/es/lib/Typedown/Typedown.js +103 -69
- package/es/lib/constants/endpoints.js +7 -2
- package/es/lib/hooks/__mocks__/index.js +3 -7
- package/es/lib/hooks/intlHooks/useIntlKeyStore/useIntlKeyStore.js +20 -26
- package/es/lib/hooks/intlHooks/useKintIntl/useKintIntl.js +24 -34
- package/es/lib/hooks/typedownHooks/useTypedown.js +104 -81
- package/es/lib/hooks/typedownHooks/useTypedownToggle.js +2 -2
- package/es/lib/hooks/useActionListRef.js +1 -1
- package/es/lib/hooks/useActiveElement.js +1 -1
- package/es/lib/hooks/useCustomProperties.js +6 -10
- package/es/lib/hooks/useHelperApp.js +13 -16
- package/es/lib/hooks/useKiwtFieldArray.js +7 -8
- package/es/lib/hooks/useKiwtSASQuery.js +15 -19
- package/es/lib/hooks/useLocalPageStore.js +7 -10
- package/es/lib/hooks/useModConfigEntries.js +2 -2
- package/es/lib/hooks/useMutateCustomProperties/useMutateCustomProperties.js +10 -17
- package/es/lib/hooks/useMutateGeneric/useMutateGeneric.js +2 -2
- package/es/lib/hooks/useMutateModConfigEntry.js +2 -2
- package/es/lib/hooks/useMutateRefdataCategory/useMutateRefdataCategory.js +15 -21
- package/es/lib/hooks/useMutateRefdataValue/useMutateRefdataValue.js +16 -23
- package/es/lib/hooks/usePrevNextPagination.js +17 -19
- package/es/lib/hooks/useQIndex.js +11 -14
- package/es/lib/hooks/useRefdata.js +3 -3
- package/es/lib/hooks/useStandaloneSASQQueryParameter/useStandaloneSASQQueryParameter.js +9 -13
- package/es/lib/hooks/useTemplates.js +4 -4
- package/es/lib/utils/buildUrl.js +2 -3
- package/es/lib/utils/filterParsers/deparseKiwtQueryFilters.js +5 -5
- package/es/lib/utils/filterParsers/parseKiwtQueryFilters.js +2 -2
- package/es/lib/utils/filterParsers/parseKiwtQueryGroups.js +4 -5
- package/es/lib/utils/filterParsers/parseKiwtQueryString.js +1 -1
- package/es/lib/utils/generateKiwtQueryParams/generateKiwtQueryParams.js +94 -107
- package/es/lib/utils/groupCustomPropertiesByCtx.js +5 -9
- package/es/lib/utils/matchString.js +5 -7
- package/es/lib/utils/parseErrorResponse.js +3 -7
- package/es/lib/utils/selectorSafe.js +2 -3
- package/es/lib/utils/sortByLabel.js +2 -3
- package/es/lib/validators/validators.js +6 -9
- package/package.json +1 -1
- package/src/artifacts/coverage-jest/ActionList/ActionList.js.html +1 -1
- package/src/artifacts/coverage-jest/ActionList/ActionListFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/ActionList/index.html +1 -1
- package/src/artifacts/coverage-jest/ActionList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/ButtonTypedown/ButtonTypedown.js.html +241 -0
- package/src/artifacts/coverage-jest/ButtonTypedown/index.html +131 -0
- package/src/artifacts/coverage-jest/ButtonTypedown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/ComboButton/ComboButton.js.html +1 -1
- package/src/artifacts/coverage-jest/ComboButton/index.html +1 -1
- package/src/artifacts/coverage-jest/ComboButton/index.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Config/CustomPropertiesLookup.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Config/CustomPropertiesSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Config/CustomPropertyForm.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Config/CustomPropertyView.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Config/index.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Config/index.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/CustomPropertiesEdit.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/CustomPropertiesEditCtx.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/CustomPropertiesListField.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/CustomPropertyField.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/CustomPropertyFormCard.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/index.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/index.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Edit/testResources.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/CustomPropertiesFilter.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/CustomPropertiesFilterField.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/CustomPropertiesFilterForm.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/CustomPropertiesRule.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/index.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/index.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/testResources.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/useOperators.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/useParseActiveFilterStrings.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/Filter/useValueProps.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/View/CustomPropertiesView.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/View/CustomPropertiesViewCtx.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/View/CustomPropertyCard.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/View/index.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/View/index.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/View/testResources.js.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/index.html +1 -1
- package/src/artifacts/coverage-jest/CustomProperties/index.js.html +1 -1
- package/src/artifacts/coverage-jest/CycleButton/CycleButton.js.html +1 -1
- package/src/artifacts/coverage-jest/CycleButton/index.html +1 -1
- package/src/artifacts/coverage-jest/CycleButton/index.js.html +1 -1
- package/src/artifacts/coverage-jest/FieldLabel/FieldLabel.js.html +1 -1
- package/src/artifacts/coverage-jest/FieldLabel/index.html +1 -1
- package/src/artifacts/coverage-jest/FieldLabel/index.js.html +1 -1
- package/src/artifacts/coverage-jest/FormModal/FormModal.js.html +1 -1
- package/src/artifacts/coverage-jest/FormModal/index.html +1 -1
- package/src/artifacts/coverage-jest/FormModal/index.js.html +1 -1
- package/src/artifacts/coverage-jest/FormattedKintMessage/FormattedKintMessage.js.html +1 -1
- package/src/artifacts/coverage-jest/FormattedKintMessage/index.html +1 -1
- package/src/artifacts/coverage-jest/FormattedKintMessage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/IconSelect/IconSelect.js.html +1 -1
- package/src/artifacts/coverage-jest/IconSelect/index.html +1 -1
- package/src/artifacts/coverage-jest/IconSelect/index.js.html +1 -1
- package/src/artifacts/coverage-jest/NoResultsMessage/NoResultsMessage.js.html +1 -1
- package/src/artifacts/coverage-jest/NoResultsMessage/index.html +1 -1
- package/src/artifacts/coverage-jest/NoResultsMessage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/NumberField/NumberField.js.html +1 -1
- package/src/artifacts/coverage-jest/NumberField/index.html +1 -1
- package/src/artifacts/coverage-jest/NumberField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/QueryTypedown/QueryTypedown.js.html +1 -1
- package/src/artifacts/coverage-jest/QueryTypedown/index.html +1 -1
- package/src/artifacts/coverage-jest/QueryTypedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/RefdataButtons/RefdataButtons.js.html +1 -1
- package/src/artifacts/coverage-jest/RefdataButtons/index.html +1 -1
- package/src/artifacts/coverage-jest/RefdataButtons/index.js.html +1 -1
- package/src/artifacts/coverage-jest/ResponsiveButtonGroup/ResponsiveButtonGroup.js.html +1 -1
- package/src/artifacts/coverage-jest/ResponsiveButtonGroup/index.html +1 -1
- package/src/artifacts/coverage-jest/ResponsiveButtonGroup/index.js.html +1 -1
- package/src/artifacts/coverage-jest/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js.html +1 -1
- package/src/artifacts/coverage-jest/RichSelect/RichSelect.js.html +1 -1
- package/src/artifacts/coverage-jest/RichSelect/index.html +1 -1
- package/src/artifacts/coverage-jest/RichSelect/index.js.html +1 -1
- package/src/artifacts/coverage-jest/RichSelect/useSelectedOption.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQLookupComponent/SASQLookupComponent.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQLookupComponent/TableBody/TableBody.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQLookupComponent/TableBody/index.html +1 -1
- package/src/artifacts/coverage-jest/SASQLookupComponent/TableBody/index.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQLookupComponent/index.html +1 -1
- package/src/artifacts/coverage-jest/SASQLookupComponent/index.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQRoute/SASQRoute.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQRoute/index.html +1 -1
- package/src/artifacts/coverage-jest/SASQRoute/index.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQViewComponent/SASQViewComponent.js.html +1 -1
- package/src/artifacts/coverage-jest/SASQViewComponent/index.html +1 -1
- package/src/artifacts/coverage-jest/SASQViewComponent/index.js.html +1 -1
- package/src/artifacts/coverage-jest/SearchField/SearchField.js.html +1 -1
- package/src/artifacts/coverage-jest/SearchField/index.html +1 -1
- package/src/artifacts/coverage-jest/SearchField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/SearchKeyControl/SearchKeyControl.js.html +1 -1
- package/src/artifacts/coverage-jest/SearchKeyControl/index.html +1 -1
- package/src/artifacts/coverage-jest/SearchKeyControl/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableRefdataCategoryList/EditableRefdataCategoryList.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableRefdataCategoryList/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableRefdataCategoryList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableRefdataList/EditableRefdataList.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableRefdataList/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableRefdataList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/EditableSettingsList.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/EditableSettingsListFieldArray/EditableSettingsListFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/EditableSettingsListFieldArray/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/EditableSettingsListFieldArray/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/EditSettingValue/EditSettingValue.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/EditSettingValue/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/EditSettingValue/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/RenderSettingValue/RenderSettingValue.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/RenderSettingValue/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/RenderSettingValue/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/SettingField.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/SettingField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/EditableSettingsList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/RefdataCategoriesSettings/RefdataCategoriesSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/RefdataCategoriesSettings/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/RefdataCategoriesSettings/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingPage/SettingPage.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingPage/SettingPagePane/SettingPagePane.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingPage/SettingPagePane/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingPage/SettingPagePane/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingPage/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingPage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingsFormContainer/SettingsFormContainer.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingsFormContainer/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/SettingsFormContainer/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/StaticSettingsField/StaticSettingsField.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/StaticSettingsField/StaticSettingsFieldComponent/StaticSettingsFieldComponent.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/StaticSettingsField/StaticSettingsFieldComponent/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/StaticSettingsField/StaticSettingsFieldComponent/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/StaticSettingsField/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/StaticSettingsField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/constants/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/constants/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/constants/queryKeys.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/contexts/SettingsContext.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/contexts/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/contexts/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/useSettingCallout/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/useSettingCallout/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/useSettingCallout/useSettingCallout.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/useSettingsSectionInitalValues/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/useSettingsSectionInitalValues/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/useSettingsSectionInitalValues/useSettingsSectionInitalValues.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/staticSettingsPages/useStaticSettingsSection.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useAppSettings/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useAppSettings/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useAppSettings/useAppSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useSettingSection/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useSettingSection/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useSettingSection/useSettingSection.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useSettings/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useSettings/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/hooks/useSettings/useSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/Settings/index.html +1 -1
- package/src/artifacts/coverage-jest/Settings/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Tags/Tags.js.html +1 -1
- package/src/artifacts/coverage-jest/Tags/hooks/index.html +15 -15
- package/src/artifacts/coverage-jest/Tags/hooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Tags/hooks/useTags.js.html +1 -1
- package/src/artifacts/coverage-jest/Tags/hooks/useTagsEnabled.js.html +150 -12
- package/src/artifacts/coverage-jest/Tags/index.html +1 -1
- package/src/artifacts/coverage-jest/Tags/index.js.html +1 -1
- package/src/artifacts/coverage-jest/Tags/tagsConfig.js.html +1 -1
- package/src/artifacts/coverage-jest/Typedown/Typedown.js.html +219 -60
- package/src/artifacts/coverage-jest/Typedown/index.html +15 -15
- package/src/artifacts/coverage-jest/Typedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/cobertura-coverage.xml +220 -110
- package/src/artifacts/coverage-jest/constants/comparators.js.html +1 -1
- package/src/artifacts/coverage-jest/constants/customProperties.js.html +1 -1
- package/src/artifacts/coverage-jest/constants/endpoints.js.html +23 -5
- package/src/artifacts/coverage-jest/constants/eventCodes.js.html +1 -1
- package/src/artifacts/coverage-jest/constants/index.html +5 -5
- package/src/artifacts/coverage-jest/constants/pagination.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useIntlKey/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useIntlKey/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useIntlKey/useIntlKey.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useIntlKeyStore/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useIntlKeyStore/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useIntlKeyStore/useIntlKeyStore.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useKintIntl/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useKintIntl/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/intlHooks/useKintIntl/useKintIntl.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/typedownHooks/index.html +14 -14
- package/src/artifacts/coverage-jest/hooks/typedownHooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/typedownHooks/useTypedown.js.html +170 -116
- package/src/artifacts/coverage-jest/hooks/typedownHooks/useTypedownData.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/typedownHooks/useTypedownToggle.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useActionListRef.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useActiveElement.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useCustomProperties.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useHelperApp.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useInvalidateRefdata/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useInvalidateRefdata/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useInvalidateRefdata/useInvalidateRefdata.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useKiwtFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useKiwtSASQuery.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useLocalPageStore.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useLocalStorageState.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useModConfigEntries.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateCustomProperties/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateCustomProperties/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateCustomProperties/useMutateCustomProperties.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateGeneric/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateGeneric/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateGeneric/useMutateGeneric.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateModConfigEntry.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateRefdataCategory/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateRefdataCategory/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateRefdataCategory/useMutateRefdataCategory.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateRefdataValue/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateRefdataValue/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useMutateRefdataValue/useMutateRefdataValue.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/usePrevNextPagination.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useQIndex.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useRefdata.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useSASQQueryMeta.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useStandaloneSASQQueryParameter/index.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useStandaloneSASQQueryParameter/index.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useStandaloneSASQQueryParameter/useStandaloneSASQQueryParameter.js.html +1 -1
- package/src/artifacts/coverage-jest/hooks/useTemplates.js.html +1 -1
- package/src/artifacts/coverage-jest/index.html +50 -35
- package/src/artifacts/coverage-jest/utils/buildUrl.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/filterParsers/deparseKiwtQueryFilters.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/filterParsers/index.html +1 -1
- package/src/artifacts/coverage-jest/utils/filterParsers/index.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/filterParsers/parseKiwtQueryFilters.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/filterParsers/parseKiwtQueryGroups.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/filterParsers/parseKiwtQueryString.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/generateKiwtQuery.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/generateKiwtQueryParams/generateKiwtQueryParams.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/generateKiwtQueryParams/index.html +1 -1
- package/src/artifacts/coverage-jest/utils/generateKiwtQueryParams/index.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/groupCustomPropertiesByCtx.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/highlightString.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/index.html +1 -1
- package/src/artifacts/coverage-jest/utils/index.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/matchString.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/modConfigEntriesQueryKey.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/parseErrorResponse.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/parseModConfigEntry.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/refdataOptions.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/refdataQueryKey/index.html +1 -1
- package/src/artifacts/coverage-jest/utils/refdataQueryKey/index.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/refdataQueryKey/refdataQueryKey.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/selectorSafe.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/sortByLabel.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/toCamelCase.js.html +1 -1
- package/src/artifacts/coverage-jest/utils/typedownQueryKey.js.html +1 -1
- package/src/artifacts/coverage-jest/validators/index.html +1 -1
- package/src/artifacts/coverage-jest/validators/index.js.html +1 -1
- package/src/artifacts/coverage-jest/validators/validators.js.html +1 -1
- package/src/index.js +4 -0
- package/src/lib/ButtonTypedown/ButtonTypedown.js +52 -0
- package/src/lib/ButtonTypedown/README.md +53 -0
- package/src/lib/ButtonTypedown/index.js +1 -0
- package/src/lib/Tags/hooks/useTagsEnabled.js +51 -5
- package/src/lib/Typedown/README.md +24 -21
- package/src/lib/Typedown/Typedown.js +101 -48
- package/src/lib/constants/endpoints.js +7 -1
- package/src/lib/hooks/typedownHooks/useTypedown.js +105 -87
- package/styles/TypeDown.css +4 -0
package/es/lib/Tags/Tags.js
CHANGED
|
@@ -17,7 +17,6 @@ var _hooks2 = require("../hooks");
|
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
const Tags = _ref => {
|
|
20
|
-
var _entity$tags3, _entity$tags$length, _entity$tags4;
|
|
21
20
|
let {
|
|
22
21
|
invalidateLinks = [],
|
|
23
22
|
// If there are other queries that need invalidating, pass those here
|
|
@@ -60,7 +59,7 @@ const Tags = _ref => {
|
|
|
60
59
|
json: data
|
|
61
60
|
}).then(() => {
|
|
62
61
|
queryClient.invalidateQueries(link);
|
|
63
|
-
if (invalidateLinks
|
|
62
|
+
if (invalidateLinks?.length) {
|
|
64
63
|
invalidateLinks.forEach(il => queryClient.invalidateQueries(il));
|
|
65
64
|
}
|
|
66
65
|
}));
|
|
@@ -85,8 +84,7 @@ const Tags = _ref => {
|
|
|
85
84
|
// add tag to the list of entity tags
|
|
86
85
|
// istanbul ignore next
|
|
87
86
|
const saveEntityTags = tagsToSave => {
|
|
88
|
-
|
|
89
|
-
const tagListMap = ((_entity$tags = entity === null || entity === void 0 ? void 0 : entity.tags) !== null && _entity$tags !== void 0 ? _entity$tags : []).map(tag => ({
|
|
87
|
+
const tagListMap = (entity?.tags ?? []).map(tag => ({
|
|
90
88
|
'value': tag.value
|
|
91
89
|
}));
|
|
92
90
|
const tagsMap = tagsToSave.map(tag => ({
|
|
@@ -102,8 +100,7 @@ const Tags = _ref => {
|
|
|
102
100
|
saveTags(addTags);
|
|
103
101
|
};
|
|
104
102
|
const onRemove = tag => {
|
|
105
|
-
|
|
106
|
-
const tagToDelete = ((_entity$tags2 = entity === null || entity === void 0 ? void 0 : entity.tags) !== null && _entity$tags2 !== void 0 ? _entity$tags2 : []).filter(t => t.value.toLowerCase() === tag.toLowerCase());
|
|
103
|
+
const tagToDelete = (entity?.tags ?? []).filter(t => t.value.toLowerCase() === tag.toLowerCase());
|
|
107
104
|
putEntity({
|
|
108
105
|
tags: [{
|
|
109
106
|
id: tagToDelete[0].id,
|
|
@@ -111,7 +108,7 @@ const Tags = _ref => {
|
|
|
111
108
|
}]
|
|
112
109
|
});
|
|
113
110
|
};
|
|
114
|
-
const entityTags = (
|
|
111
|
+
const entityTags = (entity?.tags ?? []).map(tag => tag.value.toLowerCase());
|
|
115
112
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, {
|
|
116
113
|
defaultWidth: "20%",
|
|
117
114
|
dismissible: true,
|
|
@@ -121,7 +118,7 @@ const Tags = _ref => {
|
|
|
121
118
|
id: 'numberOfTags',
|
|
122
119
|
overrideValue: labelOverrides.numberOfTags
|
|
123
120
|
}, {
|
|
124
|
-
count:
|
|
121
|
+
count: entity?.tags?.length ?? 0
|
|
125
122
|
}),
|
|
126
123
|
paneTitle: kintIntl.formatKintMessage({
|
|
127
124
|
id: 'tags',
|
|
@@ -9,7 +9,7 @@ var _core = require("@folio/stripes/core");
|
|
|
9
9
|
var _tagsConfig = require("../tagsConfig");
|
|
10
10
|
const useTags = (namespaceArray, options) => {
|
|
11
11
|
const ky = (0, _core.useOkapiKy)();
|
|
12
|
-
const nsArray = namespaceArray
|
|
12
|
+
const nsArray = namespaceArray ?? _tagsConfig.tagNamespaceArray;
|
|
13
13
|
return (0, _reactQuery.useQuery)(nsArray, () => ky.get(_tagsConfig.defaultTagQuery).json(), options);
|
|
14
14
|
};
|
|
15
15
|
var _default = exports.default = useTags;
|
|
@@ -3,14 +3,44 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.tagsEnabledQueryKey = exports.default = void 0;
|
|
6
|
+
exports.tagsEnabledQueryKey = exports.default = exports.TAGS_ENABLED_QUERY_KEY = exports.TAGS_ENABLED_CONFIG_QUERY_KEY = exports.TAGS_ENABLED_BASE_QUERY_KEY = void 0;
|
|
7
7
|
var _core = require("@folio/stripes/core");
|
|
8
8
|
var _reactQuery = require("react-query");
|
|
9
9
|
var _endpoints = require("../../constants/endpoints");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const TAGS_ENABLED_BASE_QUERY_KEY = exports.TAGS_ENABLED_BASE_QUERY_KEY = ['stripes-kint-components', 'useTagsEnabled'];
|
|
11
|
+
const TAGS_CONFIG_QUERY = 'query=(module==TAGS and configName==tags_enabled)';
|
|
12
|
+
const TAGS_SETTINGS_QUERY = 'query=(scope==ui-tags.tags.manage and key==tags_enabled)';
|
|
13
|
+
const TAGS_ENABLED_CONFIG_QUERY_KEY = exports.TAGS_ENABLED_CONFIG_QUERY_KEY = [...TAGS_ENABLED_BASE_QUERY_KEY, _endpoints.CONFIG_ENDPOINT, TAGS_CONFIG_QUERY];
|
|
14
|
+
const TAGS_ENABLED_QUERY_KEY = exports.TAGS_ENABLED_QUERY_KEY = [...TAGS_ENABLED_BASE_QUERY_KEY, _endpoints.SETTINGS_ENDPOINT, TAGS_SETTINGS_QUERY];
|
|
15
|
+
|
|
16
|
+
// DEPRECATED This remains for backwards compatibility but may not always be applicable, see useSettings configuration for details.
|
|
17
|
+
const tagsEnabledQueryKey = exports.tagsEnabledQueryKey = TAGS_ENABLED_CONFIG_QUERY_KEY;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* useTagsEnabled
|
|
21
|
+
*
|
|
22
|
+
* By default uses mod-config, for backwards compatibility.
|
|
23
|
+
* Pass { useSettings: true } to use mod-settings instead.
|
|
24
|
+
*
|
|
25
|
+
* Returns:
|
|
26
|
+
* true if the setting is missing or true
|
|
27
|
+
* false if the setting is explicitly false
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const useTagsEnabled = function () {
|
|
31
|
+
let {
|
|
32
|
+
useSettings = false
|
|
33
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
34
|
const ky = (0, _core.useOkapiKy)();
|
|
13
|
-
const
|
|
35
|
+
const endpoint = useSettings ? _endpoints.SETTINGS_ENDPOINT : _endpoints.CONFIG_ENDPOINT;
|
|
36
|
+
const query = useSettings ? TAGS_SETTINGS_QUERY : TAGS_CONFIG_QUERY;
|
|
37
|
+
const queryKey = useSettings ? TAGS_ENABLED_QUERY_KEY : TAGS_ENABLED_CONFIG_QUERY_KEY;
|
|
38
|
+
const queryObject = (0, _reactQuery.useQuery)(queryKey, () => ky.get(`${endpoint}?${query}`).json());
|
|
39
|
+
if (useSettings) {
|
|
40
|
+
// mod-settings returns this value as a boolean instead of as a string, so the below approach !value is not applicable.
|
|
41
|
+
const value = queryObject?.data?.items?.[0]?.value;
|
|
42
|
+
return value === undefined || value === null || value;
|
|
43
|
+
}
|
|
14
44
|
const {
|
|
15
45
|
data: {
|
|
16
46
|
configs: {
|
|
@@ -7,4 +7,4 @@ exports.tagsPath = exports.tagNamespaceArray = exports.defaultTagsParams = expor
|
|
|
7
7
|
const tagNamespaceArray = exports.tagNamespaceArray = ['tags', 'stripes-kint-components', 'Tags'];
|
|
8
8
|
const tagsPath = exports.tagsPath = 'tags';
|
|
9
9
|
const defaultTagsParams = exports.defaultTagsParams = ['limit=1000', 'query=cql.allRecords%3D1%20sortby%20label'];
|
|
10
|
-
const defaultTagQuery = exports.defaultTagQuery =
|
|
10
|
+
const defaultTagQuery = exports.defaultTagQuery = `${tagsPath}?${defaultTagsParams?.join('&')}`;
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = require("react");
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var
|
|
10
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
11
11
|
var _components = require("@folio/stripes/components");
|
|
12
12
|
var _SearchField = _interopRequireDefault(require("../SearchField"));
|
|
13
13
|
var _TypeDown = _interopRequireDefault(require("../../../styles/TypeDown.css"));
|
|
@@ -15,7 +15,6 @@ var _typedownHooks = require("../hooks/typedownHooks");
|
|
|
15
15
|
var _selectorSafe = _interopRequireDefault(require("../utils/selectorSafe"));
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
18
|
const Typedown = _ref => {
|
|
20
19
|
let {
|
|
21
20
|
className,
|
|
@@ -23,6 +22,8 @@ const Typedown = _ref => {
|
|
|
23
22
|
displayClearItem = true,
|
|
24
23
|
displayValueWhileOpen = true,
|
|
25
24
|
endOfList,
|
|
25
|
+
getDisplayValue,
|
|
26
|
+
// Can overrule displayValue entirely
|
|
26
27
|
id,
|
|
27
28
|
initialOpenDelay = 800,
|
|
28
29
|
// Initial opening delay of 800ms (handles any stripes animations)
|
|
@@ -34,13 +35,16 @@ const Typedown = _ref => {
|
|
|
34
35
|
onChange,
|
|
35
36
|
onType,
|
|
36
37
|
renderFooter = null,
|
|
38
|
+
renderHeader = null,
|
|
37
39
|
renderListItem = null,
|
|
40
|
+
renderTrigger = null,
|
|
38
41
|
required,
|
|
39
42
|
selectedStyles,
|
|
40
43
|
// A way to pass any styles that need to be applied globally on selection
|
|
41
44
|
uniqueIdentificationPath = 'id'
|
|
42
45
|
} = _ref;
|
|
43
|
-
const selectedUniqueId = (0,
|
|
46
|
+
const selectedUniqueId = (0, _get.default)(input.value, uniqueIdentificationPath);
|
|
47
|
+
const [selectedValue, setSelectedValue] = (0, _react.useState)(input.value); // Track what's been selected in state as well
|
|
44
48
|
|
|
45
49
|
// Display data needs to be in line with data options but also able to react to default handleType
|
|
46
50
|
const [displayData, setDisplayData] = (0, _react.useState)(dataOptions);
|
|
@@ -53,44 +57,37 @@ const Typedown = _ref => {
|
|
|
53
57
|
}, [dataOptions]);
|
|
54
58
|
|
|
55
59
|
// Setup default handleType
|
|
56
|
-
const handleType = e => {
|
|
57
|
-
|
|
58
|
-
const regex = new RegExp("".concat(e.target.value.toLowerCase()));
|
|
60
|
+
const handleType = (0, _react.useCallback)(e => {
|
|
61
|
+
const regex = new RegExp(`${e.target.value.toLowerCase()}`);
|
|
59
62
|
if (onType) {
|
|
60
63
|
onType(e);
|
|
61
|
-
} else if (filterPath && e
|
|
62
|
-
setDisplayData(dataOptions.filter(item =>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}));
|
|
66
|
-
} else if (e !== null && e !== void 0 && (_e$target2 = e.target) !== null && _e$target2 !== void 0 && _e$target2.value) {
|
|
67
|
-
setDisplayData(dataOptions.filter(item => {
|
|
68
|
-
var _get2;
|
|
69
|
-
return (_get2 = (0, _get3.default)(item, uniqueIdentificationPath)) === null || _get2 === void 0 || (_get2 = _get2.toLowerCase()) === null || _get2 === void 0 ? void 0 : _get2.match(regex);
|
|
70
|
-
}));
|
|
64
|
+
} else if (filterPath && e?.target?.value) {
|
|
65
|
+
setDisplayData(dataOptions.filter(item => (0, _get.default)(item, filterPath)?.toLowerCase()?.match(regex)));
|
|
66
|
+
} else if (e?.target?.value) {
|
|
67
|
+
setDisplayData(dataOptions.filter(item => (0, _get.default)(item, uniqueIdentificationPath)?.toLowerCase()?.match(regex)));
|
|
71
68
|
} else {
|
|
72
69
|
setDisplayData(dataOptions);
|
|
73
70
|
}
|
|
74
71
|
setCurrentlyTyped(e.target.value);
|
|
75
|
-
if (displayData.length === 1 && (0,
|
|
72
|
+
if (displayData.length === 1 && (0, _get.default)(displayData[0], filterPath) === e.target.value) {
|
|
76
73
|
setExactMatch(true);
|
|
77
74
|
} else {
|
|
78
75
|
setExactMatch(false);
|
|
79
76
|
}
|
|
80
|
-
};
|
|
77
|
+
}, [dataOptions, displayData, filterPath, onType, uniqueIdentificationPath]);
|
|
81
78
|
|
|
82
79
|
// Hook to set up all the essentials
|
|
83
80
|
const {
|
|
84
81
|
refs: {
|
|
85
82
|
listRef,
|
|
86
83
|
triggerRef,
|
|
84
|
+
triggerComponentRef,
|
|
87
85
|
overlayRef,
|
|
88
|
-
footerRef
|
|
86
|
+
footerRef,
|
|
87
|
+
headerRef
|
|
89
88
|
},
|
|
90
89
|
handlers: {
|
|
91
|
-
handleNextFocus
|
|
92
|
-
listKeyDownHandler,
|
|
93
|
-
searchFieldKeyDownHandler
|
|
90
|
+
handleNextFocus
|
|
94
91
|
},
|
|
95
92
|
variables: {
|
|
96
93
|
open,
|
|
@@ -105,77 +102,121 @@ const Typedown = _ref => {
|
|
|
105
102
|
let optionIsSelected = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
106
103
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
107
104
|
className: _TypeDown.default.listItem,
|
|
108
|
-
children: renderListItem ? renderListItem(option, currentlyTyped, exactMatch, optionIsSelected) : (0,
|
|
105
|
+
children: renderListItem ? renderListItem(option, currentlyTyped, exactMatch, optionIsSelected, selectedValue) : (0, _get.default)(option, uniqueIdentificationPath)
|
|
109
106
|
});
|
|
110
|
-
}, [currentlyTyped, exactMatch, renderListItem, uniqueIdentificationPath]);
|
|
107
|
+
}, [currentlyTyped, exactMatch, renderListItem, selectedValue, uniqueIdentificationPath]);
|
|
111
108
|
const handleChange = (0, _react.useCallback)(value => {
|
|
112
109
|
input.onChange(value);
|
|
110
|
+
setSelectedValue(value);
|
|
113
111
|
if (typeof onChange === 'function') {
|
|
114
112
|
onChange(value);
|
|
115
113
|
}
|
|
116
114
|
}, [input, onChange]);
|
|
115
|
+
const renderTypedownTrigger = () => {
|
|
116
|
+
const triggerComponentId = `typedown-trigger-${(0, _selectorSafe.default)(input.name)}`;
|
|
117
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
118
|
+
ref: triggerRef,
|
|
119
|
+
id: `typedown-parent-${(0, _selectorSafe.default)(input.name)}-trigger`,
|
|
120
|
+
children: renderTrigger ? renderTrigger({
|
|
121
|
+
// Pass all props in that searchfield uses.
|
|
122
|
+
handleType,
|
|
123
|
+
input,
|
|
124
|
+
// Pass input? Useful when not controlled I guess
|
|
125
|
+
meta,
|
|
126
|
+
selectedValue,
|
|
127
|
+
triggerComponentId,
|
|
128
|
+
triggerComponentRef
|
|
129
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchField.default, {
|
|
130
|
+
ref: triggerComponentRef
|
|
131
|
+
// Pass meta through so correct styling gets applied to the TextField
|
|
132
|
+
,
|
|
133
|
+
id: triggerComponentId,
|
|
134
|
+
label: label,
|
|
135
|
+
marginBottom0: true,
|
|
136
|
+
meta: meta,
|
|
137
|
+
onChange: handleType,
|
|
138
|
+
required: required
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
};
|
|
117
142
|
const dropDown = (0, _react.useCallback)(() => {
|
|
118
143
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
119
144
|
className: _TypeDown.default.dropdownMenu,
|
|
120
|
-
id:
|
|
145
|
+
id: `typedown-parent-${(0, _selectorSafe.default)(input.name)}-menu`,
|
|
121
146
|
style: {
|
|
122
|
-
'--searchWidth':
|
|
147
|
+
'--searchWidth': `${searchWidth}px`
|
|
123
148
|
},
|
|
124
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
149
|
+
children: [renderHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
150
|
+
ref: headerRef,
|
|
151
|
+
className: _TypeDown.default.header,
|
|
152
|
+
id: `typedown-header-${(0, _selectorSafe.default)(input.name)}`,
|
|
153
|
+
children: renderHeader({
|
|
154
|
+
currentlyTyped,
|
|
155
|
+
displayData,
|
|
156
|
+
handleType,
|
|
157
|
+
exactMatch
|
|
158
|
+
})
|
|
159
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
125
160
|
ref: listRef,
|
|
126
161
|
className: _TypeDown.default.listContainer,
|
|
127
|
-
id: "typedown-list"
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
162
|
+
id: "typedown-list"
|
|
163
|
+
/* This is an acceptable exception to the no-static-element-interactions
|
|
164
|
+
* as we are only PREVENTING interactions, namely focus change on scrollbar click
|
|
165
|
+
* Without this, the typedown closes instantly when the scrollbar is clicked or dragged.
|
|
166
|
+
* This does NOT prevent item click, as e.propagation is not prevented.
|
|
167
|
+
*/,
|
|
168
|
+
onMouseDown: e => e.preventDefault(),
|
|
169
|
+
children: displayData?.length ? displayData?.map((d, index) => {
|
|
170
|
+
const isSelectedEval = isSelected ? isSelected(input.value, d) : (0, _get.default)(input.value, uniqueIdentificationPath) === (0, _get.default)(d, uniqueIdentificationPath);
|
|
171
|
+
const selectedCSS = selectedStyles ?? _TypeDown.default.selectedMenuButton;
|
|
131
172
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
132
173
|
className: (0, _classnames.default)(_TypeDown.default.fullWidth, _TypeDown.default.menuButton, {
|
|
133
|
-
[
|
|
174
|
+
[`${selectedCSS}`]: isSelectedEval
|
|
134
175
|
}),
|
|
135
176
|
"data-selected": isSelectedEval,
|
|
136
|
-
id:
|
|
177
|
+
id: `typedown-button-[${index}]`,
|
|
137
178
|
onClick: () => {
|
|
138
179
|
handleChange(d);
|
|
139
180
|
handleNextFocus();
|
|
140
181
|
},
|
|
141
|
-
onKeyDown: listKeyDownHandler,
|
|
142
182
|
type: "button",
|
|
143
183
|
children: renderItem(d, isSelectedEval)
|
|
144
|
-
},
|
|
184
|
+
}, `typedown-button-[${index}]`);
|
|
145
185
|
}) : endOfList || /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.EndOfList, {})
|
|
146
186
|
}), renderFooter && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
147
187
|
ref: footerRef,
|
|
148
188
|
className: _TypeDown.default.footer,
|
|
149
|
-
id:
|
|
189
|
+
id: `typedown-footer-${(0, _selectorSafe.default)(input.name)}`,
|
|
150
190
|
children: renderFooter(displayData, currentlyTyped, exactMatch)
|
|
151
191
|
})]
|
|
152
192
|
});
|
|
153
|
-
}, [currentlyTyped, displayData, endOfList, exactMatch, footerRef, handleChange, handleNextFocus, input.name, input.value, isSelected,
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
children:
|
|
159
|
-
|
|
160
|
-
,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
onChange: handleType,
|
|
166
|
-
onKeyDown: searchFieldKeyDownHandler,
|
|
167
|
-
required: required
|
|
168
|
-
})
|
|
169
|
-
});
|
|
170
|
-
};
|
|
193
|
+
}, [currentlyTyped, displayData, endOfList, exactMatch, footerRef, handleChange, handleNextFocus, handleType, headerRef, input.name, input.value, isSelected, listRef, renderFooter, renderHeader, renderItem, searchWidth, selectedStyles, uniqueIdentificationPath]);
|
|
194
|
+
const renderSelectedItem = (0, _react.useCallback)(() => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
195
|
+
className: (0, _classnames.default)(_TypeDown.default.selectedDisplay),
|
|
196
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
197
|
+
className: _TypeDown.default.selectedItem,
|
|
198
|
+
children: renderItem(input.value)
|
|
199
|
+
}), displayClearItem && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
|
|
200
|
+
className: _TypeDown.default.clearItem,
|
|
201
|
+
icon: "times-circle-solid",
|
|
202
|
+
onClick: () => handleChange()
|
|
203
|
+
})]
|
|
204
|
+
}), [displayClearItem, handleChange, input.value, renderItem]);
|
|
171
205
|
const displayValue = (0, _react.useMemo)(() => {
|
|
206
|
+
// Allow full control over whether to display the value
|
|
207
|
+
if (getDisplayValue) {
|
|
208
|
+
return getDisplayValue({
|
|
209
|
+
selectedUniqueId,
|
|
210
|
+
open
|
|
211
|
+
});
|
|
212
|
+
}
|
|
172
213
|
return !!selectedUniqueId && (!open || displayValueWhileOpen);
|
|
173
|
-
}, [displayValueWhileOpen, open, selectedUniqueId]);
|
|
214
|
+
}, [displayValueWhileOpen, getDisplayValue, open, selectedUniqueId]);
|
|
174
215
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
175
216
|
ref: resizeRef,
|
|
176
217
|
className: (0, _classnames.default)(_TypeDown.default.typedown, className),
|
|
177
|
-
id:
|
|
178
|
-
children: [
|
|
218
|
+
id: `typedown-id-${id}`,
|
|
219
|
+
children: [renderTypedownTrigger(), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Popper, {
|
|
179
220
|
anchorRef: triggerRef,
|
|
180
221
|
className: (0, _classnames.default)(_TypeDown.default.dropdown, _TypeDown.default.fullWidth),
|
|
181
222
|
isOpen: open,
|
|
@@ -199,17 +240,7 @@ const Typedown = _ref => {
|
|
|
199
240
|
overlayRef: overlayRef,
|
|
200
241
|
portal: portal,
|
|
201
242
|
children: dropDown()
|
|
202
|
-
}, "typedown-menu-toggle"), displayValue &&
|
|
203
|
-
className: (0, _classnames.default)(_TypeDown.default.selectedDisplay),
|
|
204
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
205
|
-
className: _TypeDown.default.selectedItem,
|
|
206
|
-
children: renderItem(input.value)
|
|
207
|
-
}), displayClearItem && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
|
|
208
|
-
className: _TypeDown.default.clearItem,
|
|
209
|
-
icon: "times-circle-solid",
|
|
210
|
-
onClick: () => handleChange()
|
|
211
|
-
})]
|
|
212
|
-
})]
|
|
243
|
+
}, "typedown-menu-toggle"), displayValue && renderSelectedItem()]
|
|
213
244
|
});
|
|
214
245
|
};
|
|
215
246
|
Typedown.propTypes = {
|
|
@@ -219,6 +250,7 @@ Typedown.propTypes = {
|
|
|
219
250
|
displayValueWhileOpen: _propTypes.default.bool,
|
|
220
251
|
endOfList: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node, _propTypes.default.element]),
|
|
221
252
|
filterPath: _propTypes.default.string,
|
|
253
|
+
getDisplayValue: _propTypes.default.func,
|
|
222
254
|
id: _propTypes.default.string,
|
|
223
255
|
initialOpenDelay: _propTypes.default.number,
|
|
224
256
|
input: _propTypes.default.object,
|
|
@@ -227,8 +259,10 @@ Typedown.propTypes = {
|
|
|
227
259
|
meta: _propTypes.default.object,
|
|
228
260
|
onChange: _propTypes.default.func,
|
|
229
261
|
onType: _propTypes.default.func,
|
|
262
|
+
renderHeader: _propTypes.default.func,
|
|
230
263
|
renderFooter: _propTypes.default.func,
|
|
231
264
|
renderListItem: _propTypes.default.func,
|
|
265
|
+
renderTrigger: _propTypes.default.func,
|
|
232
266
|
required: _propTypes.default.bool,
|
|
233
267
|
selectedStyles: _propTypes.default.string,
|
|
234
268
|
uniqueIdentificationPath: _propTypes.default.string
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.MOD_SETTINGS_ENDPOINT = void 0;
|
|
6
|
+
exports.SETTINGS_ENDPOINT = exports.MOD_SETTINGS_ENDPOINT = exports.CONFIG_ENDPOINT = void 0;
|
|
7
7
|
// eslint-disable-next-line import/prefer-default-export
|
|
8
|
-
const
|
|
8
|
+
const SETTINGS_ENDPOINT = exports.SETTINGS_ENDPOINT = 'settings/entries';
|
|
9
|
+
const CONFIG_ENDPOINT = exports.CONFIG_ENDPOINT = 'configurations/entries';
|
|
10
|
+
|
|
11
|
+
// DEPRECATED Here for backwards compatibility as we move from mod-config to what is now mod-settings
|
|
12
|
+
// This was always confusingly named, and will be removed in a future major version bump
|
|
13
|
+
const MOD_SETTINGS_ENDPOINT = exports.MOD_SETTINGS_ENDPOINT = CONFIG_ENDPOINT;
|
|
@@ -4,18 +4,14 @@ var _refdata = _interopRequireDefault(require("../../../../test/jest/refdata"));
|
|
|
4
4
|
var _customProperties = _interopRequireDefault(require("../../../../test/jest/customProperties"));
|
|
5
5
|
var _useKintIntl = _interopRequireDefault(require("../intlHooks/useKintIntl"));
|
|
6
6
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
7
|
/* EXAMPLE Grab actual hooks for anything not mocked here */
|
|
13
8
|
const hooks = jest.requireActual('../index');
|
|
14
9
|
|
|
15
10
|
// We have to do this up here too so that our passed useKintIntl
|
|
16
11
|
// ALSO has a mocked useIntlKeyStore... I think anyway
|
|
17
12
|
jest.mock('../intlHooks/useIntlKeyStore', () => () => () => 'ui-test-implementor');
|
|
18
|
-
module.exports =
|
|
13
|
+
module.exports = {
|
|
14
|
+
...hooks,
|
|
19
15
|
useRefdata: () => _refdata.default,
|
|
20
16
|
useTemplates: () => [],
|
|
21
17
|
// We should set up some templates to test this properly
|
|
@@ -26,4 +22,4 @@ module.exports = _objectSpread(_objectSpread({}, hooks), {}, {
|
|
|
26
22
|
useMutateCustomProperties: () => [],
|
|
27
23
|
useIntlKeyStore: () => () => () => 'ui-test-implementor',
|
|
28
24
|
useKintIntl: _useKintIntl.default // Use the "proper" useKintIntl but with a mocked intlKeyStore which returns the ui-test-implementor
|
|
29
|
-
}
|
|
25
|
+
};
|
|
@@ -6,53 +6,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _core = require("@folio/stripes/core");
|
|
8
8
|
var _zustand = require("zustand");
|
|
9
|
-
|
|
10
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // We can use hooks within zustand store functions without violating the laws of hooks
|
|
9
|
+
// We can use hooks within zustand store functions without violating the laws of hooks
|
|
16
10
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
11
|
+
|
|
17
12
|
const useIntlKeyStore = (0, _zustand.create)((set, get) => ({
|
|
18
13
|
intlKeys: {},
|
|
19
14
|
addKey: (key, namespace) => set(state => {
|
|
20
|
-
var _useNamespace;
|
|
21
15
|
let ns = namespace;
|
|
22
|
-
const folioNS = (
|
|
16
|
+
const folioNS = (0, _core.useNamespace)()?.[0];
|
|
23
17
|
if (!ns) {
|
|
24
18
|
ns = folioNS;
|
|
25
19
|
}
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
return {
|
|
21
|
+
...state,
|
|
22
|
+
intlKeys: {
|
|
23
|
+
[ns]: key,
|
|
24
|
+
...state.intlKeys
|
|
25
|
+
}
|
|
26
|
+
};
|
|
31
27
|
}),
|
|
32
28
|
removeKey: namespace => set(state => {
|
|
33
|
-
var _useNamespace2;
|
|
34
29
|
let ns = namespace;
|
|
35
|
-
const folioNS = (
|
|
30
|
+
const folioNS = (0, _core.useNamespace)()?.[0];
|
|
36
31
|
if (!ns) {
|
|
37
32
|
ns = folioNS;
|
|
38
33
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
const {
|
|
35
|
+
[ns]: _valueToRemove,
|
|
36
|
+
...newKeys
|
|
37
|
+
} = state.intlKeys;
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
45
40
|
intlKeys: newKeys
|
|
46
|
-
}
|
|
41
|
+
};
|
|
47
42
|
}),
|
|
48
43
|
getKey: namespace => {
|
|
49
|
-
var _useNamespace3, _get$intlKeys;
|
|
50
44
|
let ns = namespace;
|
|
51
|
-
const folioNS = (
|
|
45
|
+
const folioNS = (0, _core.useNamespace)()?.[0];
|
|
52
46
|
if (!ns) {
|
|
53
47
|
ns = folioNS;
|
|
54
48
|
}
|
|
55
|
-
return
|
|
49
|
+
return get().intlKeys?.[ns];
|
|
56
50
|
}
|
|
57
51
|
}));
|
|
58
52
|
var _default = exports.default = useIntlKeyStore;
|
|
@@ -6,15 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _reactIntl = require("react-intl");
|
|
8
8
|
var _useIntlKey = _interopRequireDefault(require("../useIntlKey"));
|
|
9
|
-
const _excluded = ["id", "overrideValue", "fallbackMessage"];
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
17
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
18
10
|
/* A hook to enrich the intl object we get from useIntl */
|
|
19
11
|
const useKintIntl = (passedIntlKey, passedIntlNS) => {
|
|
20
12
|
const intlObj = (0, _reactIntl.useIntl)();
|
|
@@ -23,24 +15,23 @@ const useKintIntl = (passedIntlKey, passedIntlNS) => {
|
|
|
23
15
|
// FormatKintMessage id misses out the top level key part of the path.
|
|
24
16
|
// This works analogously to FormattedKintMessage component
|
|
25
17
|
const formatKintMessage = (_ref, formatValues) => {
|
|
26
|
-
var _intlObj$messages2;
|
|
27
18
|
let {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
id,
|
|
20
|
+
overrideValue,
|
|
21
|
+
fallbackMessage,
|
|
22
|
+
...formatParams
|
|
23
|
+
} = _ref;
|
|
33
24
|
if (overrideValue) {
|
|
34
|
-
var _intlObj$messages;
|
|
35
25
|
// Version 3 is a breaking change, where labelOverrides must be strings.
|
|
36
26
|
if (typeof overrideValue !== 'string') {
|
|
37
27
|
throw new Error('Override values must be strings as of stripes-kint-components ^3.0.0');
|
|
38
28
|
}
|
|
39
|
-
if (
|
|
29
|
+
if (intlObj.messages?.[overrideValue]) {
|
|
40
30
|
// We've been passed a key as an override, use it
|
|
41
|
-
return intlObj.formatMessage(
|
|
42
|
-
id: overrideValue
|
|
43
|
-
|
|
31
|
+
return intlObj.formatMessage({
|
|
32
|
+
id: overrideValue,
|
|
33
|
+
...formatParams
|
|
34
|
+
}, formatValues);
|
|
44
35
|
}
|
|
45
36
|
// At this stage we have an overrideValue that's not a key, return it.
|
|
46
37
|
return overrideValue;
|
|
@@ -49,29 +40,28 @@ const useKintIntl = (passedIntlKey, passedIntlNS) => {
|
|
|
49
40
|
// If key does not exist in intl, and we have a specified "fallbackMessage", use that
|
|
50
41
|
|
|
51
42
|
// (FallbackMessage works like defaultMessage but with no warning)
|
|
52
|
-
if (!
|
|
53
|
-
var _intlObj$messages3;
|
|
43
|
+
if (!intlObj.messages?.[`${intlKey}.${id}`] && fallbackMessage) {
|
|
54
44
|
// Allow fallback message to be an intl key
|
|
55
|
-
if (
|
|
56
|
-
return intlObj.formatMessage(
|
|
57
|
-
id: fallbackMessage
|
|
58
|
-
|
|
45
|
+
if (intlObj.messages?.[fallbackMessage]) {
|
|
46
|
+
return intlObj.formatMessage({
|
|
47
|
+
id: fallbackMessage,
|
|
48
|
+
...formatParams
|
|
49
|
+
}, formatValues);
|
|
59
50
|
}
|
|
60
51
|
return fallbackMessage;
|
|
61
52
|
}
|
|
62
53
|
|
|
63
54
|
// After all that, render the message from key
|
|
64
|
-
return intlObj.formatMessage(
|
|
65
|
-
id:
|
|
66
|
-
|
|
55
|
+
return intlObj.formatMessage({
|
|
56
|
+
id: `${intlKey}.${id}`,
|
|
57
|
+
...formatParams
|
|
58
|
+
}, formatValues);
|
|
67
59
|
};
|
|
68
|
-
const messageExists = key => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
return _objectSpread(_objectSpread({}, intlObj), {}, {
|
|
60
|
+
const messageExists = key => !!intlObj.messages?.[`${intlKey}.${key}`];
|
|
61
|
+
return {
|
|
62
|
+
...intlObj,
|
|
73
63
|
formatKintMessage,
|
|
74
64
|
messageExists
|
|
75
|
-
}
|
|
65
|
+
};
|
|
76
66
|
};
|
|
77
67
|
var _default = exports.default = useKintIntl;
|