@ndla/ui 56.0.191-alpha.0 → 56.0.194-alpha.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/dist/panda.buildinfo.json +10 -0
- package/dist/styles.css +53 -1
- package/es/AnchorHeading/AnchorHeading.mjs.map +1 -1
- package/es/Article/Article.mjs +1 -1
- package/es/Article/Article.mjs.map +1 -1
- package/es/Article/ArticleByline.mjs +1 -1
- package/es/Article/ArticleByline.mjs.map +1 -1
- package/es/Article/ArticleFootNotes.mjs.map +1 -1
- package/es/Article/BadgesContainer.mjs.map +1 -1
- package/es/AudioPlayer/AudioElement.mjs.map +1 -1
- package/es/AudioPlayer/AudioPlayer.mjs.map +1 -1
- package/es/AudioPlayer/AudioProgress.mjs.map +1 -1
- package/es/AudioPlayer/CompactAudioPlayer.mjs.map +1 -1
- package/es/AudioPlayer/Controls.mjs +1 -1
- package/es/AudioPlayer/Controls.mjs.map +1 -1
- package/es/AudioPlayer/PlayButton.mjs.map +1 -1
- package/es/AudioPlayer/SpeechControl.mjs.map +1 -1
- package/es/AudioPlayer/VolumeSlider.mjs.map +1 -1
- package/es/AudioPlayer/audioUtils.mjs.map +1 -1
- package/es/AudioPlayer/useAudioControls.mjs.map +1 -1
- package/es/Breadcrumb/Breadcrumb.mjs.map +1 -1
- package/es/Breadcrumb/BreadcrumbItem.mjs.map +1 -1
- package/es/Breadcrumb/HomeBreadcrumb.mjs.map +1 -1
- package/es/CampaignBlock/CampaignBlock.mjs.map +1 -1
- package/es/CodeBlock/CodeBlock.mjs.map +1 -1
- package/es/CodeBlock/codeLanguageOptions.mjs.map +1 -1
- package/es/Concept/Concept.mjs.map +1 -1
- package/es/ContactBlock/ContactBlock.mjs.map +1 -1
- package/es/Embed/AudioEmbed.mjs.map +1 -1
- package/es/Embed/BrightcoveEmbed.mjs.map +1 -1
- package/es/Embed/CodeEmbed.mjs.map +1 -1
- package/es/Embed/ConceptEmbed.mjs +1 -1
- package/es/Embed/ConceptEmbed.mjs.map +1 -1
- package/es/Embed/ConceptInlineTriggerButton.mjs.map +1 -1
- package/es/Embed/ContentLinkEmbed.mjs.map +1 -1
- package/es/Embed/CopyrightEmbed.mjs.map +1 -1
- package/es/Embed/EmbedErrorPlaceholder.mjs.map +1 -1
- package/es/Embed/EmbedWrapper.mjs +1 -1
- package/es/Embed/EmbedWrapper.mjs.map +1 -1
- package/es/Embed/ExternalEmbed.mjs.map +1 -1
- package/es/Embed/FootnoteEmbed.mjs.map +1 -1
- package/es/Embed/GlossEmbed.mjs +1 -1
- package/es/Embed/GlossEmbed.mjs.map +1 -1
- package/es/Embed/H5pEmbed.mjs.map +1 -1
- package/es/Embed/IframeEmbed.mjs.map +1 -1
- package/es/Embed/ImageEmbed.mjs.map +1 -1
- package/es/Embed/InlineTriggerButton.mjs.map +1 -1
- package/es/Embed/RelatedContentEmbed.mjs.map +1 -1
- package/es/Embed/UnknownEmbed.mjs.map +1 -1
- package/es/Embed/UuDisclaimerEmbed.mjs +50 -15
- package/es/Embed/UuDisclaimerEmbed.mjs.map +1 -1
- package/es/FactBox/FactBox.mjs.map +1 -1
- package/es/FileList/File.mjs.map +1 -1
- package/es/FileList/FileList.mjs +1 -1
- package/es/FileList/FileList.mjs.map +1 -1
- package/es/FileList/PdfFile.mjs.map +1 -1
- package/es/Gloss/Gloss.mjs +1 -1
- package/es/Gloss/Gloss.mjs.map +1 -1
- package/es/Gloss/GlossExample.mjs.map +1 -1
- package/es/Grid/Grid.mjs.map +1 -1
- package/es/KeyFigure/KeyFigure.mjs.map +1 -1
- package/es/LicenseByline/EmbedByline.mjs.map +1 -1
- package/es/LicenseByline/LicenseLink.mjs.map +1 -1
- package/es/LinkBlock/LinkBlock.mjs.map +1 -1
- package/es/LinkBlock/LinkBlockSection.mjs.map +1 -1
- package/es/Pitch/Pitch.mjs.map +1 -1
- package/es/RelatedArticleList/RelatedArticleList.mjs.map +1 -1
- package/es/ResourceBox/ResourceBox.mjs.map +1 -1
- package/es/TagSelector/TagSelector.mjs +3 -8
- package/es/TagSelector/TagSelector.mjs.map +1 -1
- package/es/ZendeskButton/ZendeskButton.mjs.map +1 -1
- package/es/i18n/useComponentTranslations.mjs +3 -3
- package/es/i18n/useComponentTranslations.mjs.map +1 -1
- package/es/model/ContentType.mjs.map +1 -1
- package/es/model/SubjectCategories.mjs.map +1 -1
- package/es/model/SubjectTypes.mjs.map +1 -1
- package/es/model/WordClass.mjs.map +1 -1
- package/es/model/index.mjs.map +1 -1
- package/es/utils/licenseAttributes.mjs.map +1 -1
- package/es/utils/relativeUrl.mjs.map +1 -1
- package/lib/AnchorHeading/AnchorHeading.js.map +1 -1
- package/lib/Article/Article.d.ts +4 -4
- package/lib/Article/Article.js +6 -6
- package/lib/Article/Article.js.map +1 -1
- package/lib/Article/ArticleByline.js +2 -2
- package/lib/Article/ArticleByline.js.map +1 -1
- package/lib/Article/ArticleFootNotes.js.map +1 -1
- package/lib/Article/BadgesContainer.js.map +1 -1
- package/lib/AudioPlayer/AudioElement.js.map +1 -1
- package/lib/AudioPlayer/AudioPlayer.js.map +1 -1
- package/lib/AudioPlayer/AudioProgress.d.ts +1 -1
- package/lib/AudioPlayer/AudioProgress.js.map +1 -1
- package/lib/AudioPlayer/CompactAudioPlayer.js.map +1 -1
- package/lib/AudioPlayer/Controls.js +2 -2
- package/lib/AudioPlayer/Controls.js.map +1 -1
- package/lib/AudioPlayer/PlayButton.js.map +1 -1
- package/lib/AudioPlayer/SpeechControl.js.map +1 -1
- package/lib/AudioPlayer/VolumeSlider.d.ts +1 -1
- package/lib/AudioPlayer/VolumeSlider.js.map +1 -1
- package/lib/AudioPlayer/audioUtils.js.map +1 -1
- package/lib/AudioPlayer/useAudioControls.d.ts +1 -1
- package/lib/AudioPlayer/useAudioControls.js.map +1 -1
- package/lib/Breadcrumb/Breadcrumb.js.map +1 -1
- package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -1
- package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -1
- package/lib/CampaignBlock/CampaignBlock.js.map +1 -1
- package/lib/CodeBlock/CodeBlock.js.map +1 -1
- package/lib/CodeBlock/codeLanguageOptions.js.map +1 -1
- package/lib/Concept/Concept.js.map +1 -1
- package/lib/ContactBlock/ContactBlock.js.map +1 -1
- package/lib/Embed/AudioEmbed.js.map +1 -1
- package/lib/Embed/BrightcoveEmbed.js.map +1 -1
- package/lib/Embed/CodeEmbed.js.map +1 -1
- package/lib/Embed/ConceptEmbed.js +2 -2
- package/lib/Embed/ConceptEmbed.js.map +1 -1
- package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -1
- package/lib/Embed/ContentLinkEmbed.js.map +1 -1
- package/lib/Embed/CopyrightEmbed.js.map +1 -1
- package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -1
- package/lib/Embed/EmbedWrapper.d.ts +1 -1
- package/lib/Embed/EmbedWrapper.js +2 -2
- package/lib/Embed/EmbedWrapper.js.map +1 -1
- package/lib/Embed/ExternalEmbed.js.map +1 -1
- package/lib/Embed/FootnoteEmbed.js.map +1 -1
- package/lib/Embed/GlossEmbed.js +2 -2
- package/lib/Embed/GlossEmbed.js.map +1 -1
- package/lib/Embed/H5pEmbed.js.map +1 -1
- package/lib/Embed/IframeEmbed.js.map +1 -1
- package/lib/Embed/ImageEmbed.js.map +1 -1
- package/lib/Embed/InlineTriggerButton.js.map +1 -1
- package/lib/Embed/RelatedContentEmbed.js.map +1 -1
- package/lib/Embed/UnknownEmbed.js.map +1 -1
- package/lib/Embed/UuDisclaimerEmbed.js +49 -14
- package/lib/Embed/UuDisclaimerEmbed.js.map +1 -1
- package/lib/FactBox/FactBox.js.map +1 -1
- package/lib/FileList/File.js.map +1 -1
- package/lib/FileList/FileList.d.ts +2 -2
- package/lib/FileList/FileList.js +3 -3
- package/lib/FileList/FileList.js.map +1 -1
- package/lib/FileList/PdfFile.js.map +1 -1
- package/lib/Gloss/Gloss.d.ts +2 -2
- package/lib/Gloss/Gloss.js +2 -2
- package/lib/Gloss/Gloss.js.map +1 -1
- package/lib/Gloss/GlossExample.js.map +1 -1
- package/lib/Grid/Grid.js.map +1 -1
- package/lib/KeyFigure/KeyFigure.js.map +1 -1
- package/lib/LicenseByline/EmbedByline.js.map +1 -1
- package/lib/LicenseByline/LicenseLink.js.map +1 -1
- package/lib/LinkBlock/LinkBlock.js.map +1 -1
- package/lib/LinkBlock/LinkBlockSection.js.map +1 -1
- package/lib/Pitch/Pitch.js.map +1 -1
- package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -1
- package/lib/ResourceBox/ResourceBox.js.map +1 -1
- package/lib/TagSelector/TagSelector.d.ts +4 -4
- package/lib/TagSelector/TagSelector.js +6 -4
- package/lib/TagSelector/TagSelector.js.map +1 -1
- package/lib/ZendeskButton/ZendeskButton.js.map +1 -1
- package/lib/i18n/useComponentTranslations.d.ts +1 -1
- package/lib/i18n/useComponentTranslations.js +3 -3
- package/lib/i18n/useComponentTranslations.js.map +1 -1
- package/lib/model/ContentType.js.map +1 -1
- package/lib/model/SubjectCategories.js.map +1 -1
- package/lib/model/SubjectTypes.js.map +1 -1
- package/lib/model/WordClass.js.map +1 -1
- package/lib/model/index.js.map +1 -1
- package/lib/utils/licenseAttributes.js.map +1 -1
- package/lib/utils/relativeUrl.js.map +1 -1
- package/package.json +9 -9
- package/src/Article/Article.tsx +1 -1
- package/src/Article/ArticleByline.tsx +1 -1
- package/src/AudioPlayer/AudioProgress.tsx +1 -1
- package/src/AudioPlayer/Controls.tsx +1 -1
- package/src/AudioPlayer/SpeechControl.tsx +1 -1
- package/src/AudioPlayer/VolumeSlider.tsx +1 -1
- package/src/AudioPlayer/useAudioControls.ts +1 -1
- package/src/Embed/ConceptEmbed.tsx +1 -1
- package/src/Embed/EmbedWrapper.tsx +1 -1
- package/src/Embed/GlossEmbed.tsx +1 -1
- package/src/Embed/UuDisclaimerEmbed.stories.tsx +28 -1
- package/src/Embed/UuDisclaimerEmbed.tsx +32 -5
- package/src/FileList/FileList.tsx +1 -1
- package/src/Gloss/Gloss.tsx +1 -1
- package/src/TagSelector/TagSelector.stories.tsx +2 -1
- package/src/TagSelector/TagSelector.tsx +3 -1
- package/src/i18n/useComponentTranslations.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponentTranslations.js","names":[],"sources":["../../src/i18n/useComponentTranslations.ts"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { CollectionItem } from \"@ark-ui/react\";\nimport type { ComboboxRootProps, PaginationRootProps, TagsInputRootProps, DatePickerRootProps } from \"@ndla/primitives\";\nimport { useMemo } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { type TagSelectorRootProps } from \"../TagSelector/TagSelector\";\n\ntype DeepPartial<T> = {\n [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];\n};\n\nexport const useTagsInputTranslations = (\n translations?: Partial<TagsInputRootProps[\"translations\"]>,\n): TagsInputRootProps[\"translations\"] => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.tagsInput\" });\n\n return useMemo(\n () => ({\n clearTriggerLabel: t(\"clearTriggerLabel\"),\n deleteTagTriggerLabel: (tag) => t(\"deleteTagTriggerLabel\", { tag }),\n tagAdded: (tag) => t(\"tagAdded\", { tag }),\n tagsPasted: (tag) => t(\"tagsPasted\", { length: tag.length }),\n tagEdited: (tag) => t(\"tagEdited\", { tag }),\n tagUpdated: (tag) => t(\"tagUpdated\", { tag }),\n tagDeleted: (tag) => t(\"tagDeleted\", { tag }),\n tagSelected: (tag) => t(\"tagSelected\", { tag }),\n ...translations,\n }),\n [t, translations],\n );\n};\n\nexport const useComboboxTranslations = <T extends CollectionItem>(\n translations?: Partial<ComboboxRootProps<T>[\"translations\"]>,\n): ComboboxRootProps<T>[\"translations\"] => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.combobox\" });\n\n return useMemo(\n () => ({\n triggerLabel: t(\"triggerLabel\"),\n clearTriggerLabel: t(\"clearTriggerLabel\"),\n ...translations,\n }),\n [t, translations],\n );\n};\n\nexport const useTagSelectorTranslations = <T extends CollectionItem>(\n translations?: Partial<TagSelectorRootProps<T>[\"translations\"]>,\n): TagSelectorRootProps<T>[\"translations\"] => {\n const tagsInputTranslations = useTagsInputTranslations();\n const comboboxTranslations = useComboboxTranslations();\n\n return useMemo(\n () =>\n ({\n ...comboboxTranslations,\n ...tagsInputTranslations,\n ...translations,\n }) as TagSelectorRootProps<T>[\"translations\"],\n [comboboxTranslations, tagsInputTranslations, translations],\n );\n};\n\nexport const usePaginationTranslations = (\n translations?: Partial<PaginationRootProps[\"translations\"]>,\n): PaginationRootProps[\"translations\"] => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.pagination\" });\n\n return useMemo(\n () => ({\n rootLabel: t(\"rootLabel\"),\n prevTriggerLabel: t(\"prevTriggerLabel\"),\n nextTriggerLabel: t(\"nextTriggerLabel\"),\n itemLabel: (details) => {\n const lastPage = details.totalPages > 1 && details.page === details.totalPages;\n return lastPage ? t(\"lastPage\", { page: details.page }) : t(\"page\", { page: details.page });\n },\n ...translations,\n }),\n [translations, t],\n );\n};\n\n// TODO: Deduplicate this and place it somewhere smart. Maybe core?\ninterface AudioSearchTranslations {\n searchPlaceholder: string;\n searchButtonTitle: string;\n useAudio: string;\n noResults: string;\n paginationTranslations: PaginationRootProps[\"translations\"];\n}\n\ninterface VideoTranslations {\n searchPlaceholder: string;\n searchButtonTitle: string;\n loadMoreVideos: string;\n noResults: string;\n is360Video: string;\n previewVideo: string;\n addVideo: string;\n close: string;\n}\ninterface PreviewTranslations {\n creatorsLabel: string;\n license: string;\n caption: string;\n altText: string;\n modelRelease: string;\n tags: string;\n close: string;\n checkboxLabel?: string;\n missingTitleFallback?: string;\n useImageTitle: string;\n}\n\ninterface ImageSearchTranslations {\n searchPlaceholder: string;\n searchButtonTitle: string;\n imagePreview: PreviewTranslations;\n paginationTranslations: PaginationRootProps[\"translations\"];\n}\n\nexport const useImageSearchTranslations = (\n translations: DeepPartial<ImageSearchTranslations> = {},\n): ImageSearchTranslations => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.imageSearch\" });\n const paginationTranslations = usePaginationTranslations();\n\n const { imagePreview, paginationTranslations: fallbackPaginationTranslations, ...remaining } = translations;\n\n return useMemo(\n () => ({\n searchPlaceholder: t(\"searchPlaceholder\"),\n searchButtonTitle: t(\"searchButtonTitle\"),\n imagePreview: {\n creatorsLabel: t(\"imagePreview.creatorsLabel\"),\n license: t(\"imagePreview.license\"),\n caption: t(\"imagePreview.caption\"),\n altText: t(\"imagePreview.altText\"),\n modelRelease: t(\"imagePreview.modelRelease\"),\n tags: t(\"imagePreview.tags\"),\n close: t(\"close\"),\n checkboxLabel: t(\"imagePreview.checkboxLabel\"),\n useImageTitle: t(\"imagePreview.useImageTitle\"),\n ...imagePreview,\n },\n paginationTranslations: { ...paginationTranslations, ...fallbackPaginationTranslations },\n ...remaining,\n }),\n [t, paginationTranslations, imagePreview, fallbackPaginationTranslations, remaining],\n );\n};\n\nexport const useAudioSearchTranslations = (\n translations: DeepPartial<AudioSearchTranslations> = {},\n): AudioSearchTranslations => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.audioSearch\" });\n const paginationTranslations = usePaginationTranslations();\n\n const { paginationTranslations: fallbackPaginationTranslations, ...remaining } = translations;\n\n return useMemo(\n () => ({\n searchPlaceholder: t(\"searchPlaceholder\"),\n searchButtonTitle: t(\"searchButtonTitle\"),\n useAudio: t(\"useAudio\"),\n noResults: t(\"noResults\"),\n paginationTranslations: { ...paginationTranslations, ...fallbackPaginationTranslations },\n ...remaining,\n }),\n [t, paginationTranslations, fallbackPaginationTranslations, remaining],\n );\n};\n\nexport const useVideoSearchTranslations = (translations?: Partial<VideoTranslations>): VideoTranslations => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.videoSearch\" });\n\n return useMemo(\n () => ({\n searchPlaceholder: t(\"searchPlaceholder\"),\n searchButtonTitle: t(\"searchButtonTitle\"),\n loadMoreVideos: t(\"loadMoreVideos\"),\n noResults: t(\"noResults\"),\n is360Video: t(\"is360Video\"),\n previewVideo: t(\"previewVideo\"),\n addVideo: t(\"addVideo\"),\n close: t(\"close\"),\n ...translations,\n }),\n [t, translations],\n );\n};\n\nexport const useDatePickerTranslations = (\n translations?: Partial<DatePickerRootProps[\"translations\"]>,\n): NonNullable<DatePickerRootProps[\"translations\"]> => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.datePicker\" });\n\n return useMemo(\n () => ({\n dayCell: (state) => {\n if (state.unavailable) {\n return t(\"dayCell.unavailable\", { date: state.formattedDate });\n } else if (state.selected) {\n return t(\"dayCell.selected\", { date: state.formattedDate });\n } else return t(\"dayCell.select\", { date: state.formattedDate });\n },\n nextTrigger: (view) => t(`nextTrigger.${view}`),\n prevTrigger: (view) => t(`prevTrigger.${view}`),\n monthSelect: t(\"monthSelect\"),\n yearSelect: t(\"yearSelect\"),\n viewTrigger: (view) => t(`viewTrigger.${view}`),\n presetTrigger: (value) => {\n if (Array.isArray(value)) {\n return t(\"presetTrigger.range\", { start: value[0], end: value[1] });\n } else return t(\"presetTrigger.single\", { date: value });\n },\n clearTrigger: t(\"clearTrigger\"),\n trigger: (open) => t(`trigger.${open ? \"close\" : \"open\"}`),\n content: t(\"content\"),\n placeholder: (_locale) => {\n return { day: \"dd\", month: \"mm\", year: \"yyyy\" };\n },\n ...translations,\n }),\n [t, translations],\n );\n};\n"],"mappings":";;;;AAkBA,MAAa,4BACX,iBACuC;CACvC,MAAM,EAAE,OAAA,GAAA,cAAA,gBAAqB,eAAe,EAAE,WAAW,uBAAuB,CAAC;AAEjF,SAAA,GAAA,MAAA,gBACS;EACL,mBAAmB,EAAE,oBAAoB;EACzC,wBAAwB,QAAQ,EAAE,yBAAyB,EAAE,KAAK,CAAC;EACnE,WAAW,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC;E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copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { CollectionItem } from \"@ark-ui/react/collection\";\nimport type { ComboboxRootProps, PaginationRootProps, TagsInputRootProps, DatePickerRootProps } from \"@ndla/primitives\";\nimport { useMemo } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { type TagSelectorRootProps } from \"../TagSelector/TagSelector\";\n\ntype DeepPartial<T> = {\n [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];\n};\n\nexport const useTagsInputTranslations = (\n translations?: Partial<TagsInputRootProps[\"translations\"]>,\n): TagsInputRootProps[\"translations\"] => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.tagsInput\" });\n\n return useMemo(\n () => ({\n clearTriggerLabel: t(\"clearTriggerLabel\"),\n deleteTagTriggerLabel: (tag) => t(\"deleteTagTriggerLabel\", { tag }),\n tagAdded: (tag) => t(\"tagAdded\", { tag }),\n tagsPasted: (tag) => t(\"tagsPasted\", { length: tag.length }),\n tagEdited: (tag) => t(\"tagEdited\", { tag }),\n tagUpdated: (tag) => t(\"tagUpdated\", { tag }),\n tagDeleted: (tag) => t(\"tagDeleted\", { tag }),\n tagSelected: (tag) => t(\"tagSelected\", { tag }),\n ...translations,\n }),\n [t, translations],\n );\n};\n\nexport const useComboboxTranslations = <T extends CollectionItem>(\n translations?: Partial<ComboboxRootProps<T>[\"translations\"]>,\n): ComboboxRootProps<T>[\"translations\"] => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.combobox\" });\n\n return useMemo(\n () => ({\n triggerLabel: t(\"triggerLabel\"),\n clearTriggerLabel: t(\"clearTriggerLabel\"),\n ...translations,\n }),\n [t, translations],\n );\n};\n\nexport const useTagSelectorTranslations = <T extends CollectionItem>(\n translations?: Partial<TagSelectorRootProps<T>[\"translations\"]>,\n): TagSelectorRootProps<T>[\"translations\"] => {\n const tagsInputTranslations = useTagsInputTranslations();\n const comboboxTranslations = useComboboxTranslations();\n\n return useMemo(\n () =>\n ({\n ...comboboxTranslations,\n ...tagsInputTranslations,\n ...translations,\n }) as TagSelectorRootProps<T>[\"translations\"],\n [comboboxTranslations, tagsInputTranslations, translations],\n );\n};\n\nexport const usePaginationTranslations = (\n translations?: Partial<PaginationRootProps[\"translations\"]>,\n): PaginationRootProps[\"translations\"] => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.pagination\" });\n\n return useMemo(\n () => ({\n rootLabel: t(\"rootLabel\"),\n prevTriggerLabel: t(\"prevTriggerLabel\"),\n nextTriggerLabel: t(\"nextTriggerLabel\"),\n itemLabel: (details) => {\n const lastPage = details.totalPages > 1 && details.page === details.totalPages;\n return lastPage ? t(\"lastPage\", { page: details.page }) : t(\"page\", { page: details.page });\n },\n ...translations,\n }),\n [translations, t],\n );\n};\n\n// TODO: Deduplicate this and place it somewhere smart. Maybe core?\ninterface AudioSearchTranslations {\n searchPlaceholder: string;\n searchButtonTitle: string;\n useAudio: string;\n noResults: string;\n paginationTranslations: PaginationRootProps[\"translations\"];\n}\n\ninterface VideoTranslations {\n searchPlaceholder: string;\n searchButtonTitle: string;\n loadMoreVideos: string;\n noResults: string;\n is360Video: string;\n previewVideo: string;\n addVideo: string;\n close: string;\n}\ninterface PreviewTranslations {\n creatorsLabel: string;\n license: string;\n caption: string;\n altText: string;\n modelRelease: string;\n tags: string;\n close: string;\n checkboxLabel?: string;\n missingTitleFallback?: string;\n useImageTitle: string;\n}\n\ninterface ImageSearchTranslations {\n searchPlaceholder: string;\n searchButtonTitle: string;\n imagePreview: PreviewTranslations;\n paginationTranslations: PaginationRootProps[\"translations\"];\n}\n\nexport const useImageSearchTranslations = (\n translations: DeepPartial<ImageSearchTranslations> = {},\n): ImageSearchTranslations => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.imageSearch\" });\n const paginationTranslations = usePaginationTranslations();\n\n const { imagePreview, paginationTranslations: fallbackPaginationTranslations, ...remaining } = translations;\n\n return useMemo(\n () => ({\n searchPlaceholder: t(\"searchPlaceholder\"),\n searchButtonTitle: t(\"searchButtonTitle\"),\n imagePreview: {\n creatorsLabel: t(\"imagePreview.creatorsLabel\"),\n license: t(\"imagePreview.license\"),\n caption: t(\"imagePreview.caption\"),\n altText: t(\"imagePreview.altText\"),\n modelRelease: t(\"imagePreview.modelRelease\"),\n tags: t(\"imagePreview.tags\"),\n close: t(\"close\"),\n checkboxLabel: t(\"imagePreview.checkboxLabel\"),\n useImageTitle: t(\"imagePreview.useImageTitle\"),\n ...imagePreview,\n },\n paginationTranslations: { ...paginationTranslations, ...fallbackPaginationTranslations },\n ...remaining,\n }),\n [t, paginationTranslations, imagePreview, fallbackPaginationTranslations, remaining],\n );\n};\n\nexport const useAudioSearchTranslations = (\n translations: DeepPartial<AudioSearchTranslations> = {},\n): AudioSearchTranslations => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.audioSearch\" });\n const paginationTranslations = usePaginationTranslations();\n\n const { paginationTranslations: fallbackPaginationTranslations, ...remaining } = translations;\n\n return useMemo(\n () => ({\n searchPlaceholder: t(\"searchPlaceholder\"),\n searchButtonTitle: t(\"searchButtonTitle\"),\n useAudio: t(\"useAudio\"),\n noResults: t(\"noResults\"),\n paginationTranslations: { ...paginationTranslations, ...fallbackPaginationTranslations },\n ...remaining,\n }),\n [t, paginationTranslations, fallbackPaginationTranslations, remaining],\n );\n};\n\nexport const useVideoSearchTranslations = (translations?: Partial<VideoTranslations>): VideoTranslations => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.videoSearch\" });\n\n return useMemo(\n () => ({\n searchPlaceholder: t(\"searchPlaceholder\"),\n searchButtonTitle: t(\"searchButtonTitle\"),\n loadMoreVideos: t(\"loadMoreVideos\"),\n noResults: t(\"noResults\"),\n is360Video: t(\"is360Video\"),\n previewVideo: t(\"previewVideo\"),\n addVideo: t(\"addVideo\"),\n close: t(\"close\"),\n ...translations,\n }),\n [t, translations],\n );\n};\n\nexport const useDatePickerTranslations = (\n translations?: Partial<DatePickerRootProps[\"translations\"]>,\n): NonNullable<DatePickerRootProps[\"translations\"]> => {\n const { t } = useTranslation(\"translation\", { keyPrefix: \"component.datePicker\" });\n\n return useMemo(\n () => ({\n dayCell: (state) => {\n if (state.unavailable) {\n return t(\"dayCell.unavailable\", { date: state.valueText });\n } else if (state.selected) {\n return t(\"dayCell.selected\", { date: state.valueText });\n } else return t(\"dayCell.select\", { date: state.valueText });\n },\n nextTrigger: (view) => t(`nextTrigger.${view}`),\n prevTrigger: (view) => t(`prevTrigger.${view}`),\n monthSelect: t(\"monthSelect\"),\n yearSelect: t(\"yearSelect\"),\n viewTrigger: (view) => t(`viewTrigger.${view}`),\n presetTrigger: (value) => {\n if (Array.isArray(value)) {\n return t(\"presetTrigger.range\", { start: value[0], end: value[1] });\n } else return t(\"presetTrigger.single\", { date: value });\n },\n clearTrigger: t(\"clearTrigger\"),\n trigger: (open) => t(`trigger.${open ? \"close\" : \"open\"}`),\n content: t(\"content\"),\n placeholder: (_locale) => {\n return { day: \"dd\", month: \"mm\", year: \"yyyy\" };\n },\n ...translations,\n }),\n [t, translations],\n );\n};\n"],"mappings":";;;;AAkBA,MAAa,4BACX,iBACuC;CACvC,MAAM,EAAE,OAAA,GAAA,cAAA,gBAAqB,eAAe,EAAE,WAAW,sBAAsB,CAAC;CAEhF,QAAA,GAAA,MAAA,gBACS;EACL,mBAAmB,EAAE,mBAAmB;EACxC,wBAAwB,QAAQ,EAAE,yBAAyB,EAAE,IAAI,CAAC;EAClE,WAAW,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC;EACxC,aAAa,QAAQ,EAAE,cAAc,EAAE,QAAQ,IAAI,OAAO,CAAC;EAC3D,YAAY,QAAQ,EAAE,aAAa,EAAE,IAAI,CAAC;EAC1C,aAAa,QAAQ,EAAE,cAAc,EAAE,IAAI,CAAC;EAC5C,aAAa,QAAQ,EAAE,cAAc,EAAE,IAAI,CAAC;EAC5C,cAAc,QAAQ,EAAE,eAA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EA,MAAa,6BACX,iBACqD;CACrD,MAAM,EAAE,OAAA,GAAA,cAAA,gBAAqB,eAAe,EAAE,WAAW,uBAAuB,CAAC;CAEjF,QAAA,GAAA,MAAA,gBACS;EACL,UAAU,UAAU;GAClB,IAAI,MAAM,aACR,OAAO,EAAE,uBAAuB,EAAE,MAAM,MAAM,UAAU,CAAC;QACpD,IAAI,MAAM,UACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,MAAM,UAAU,CAAC;QACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,UAAU,CAAC;EAC7D;EACA,cAAc,SAAS,EAAE,eAAe,MAAM;EAC9C,cAAc,SAAS,EAAE,eAAe,MAAM;EAC9C,aAAa,EAAE,aAAa;EAC5B,YAAY,EAAE,YAAY;EAC1B,cAAc,SAAS,EAAE,eAAe,MAAM;EAC9C,gBAAgB,UAAU;GACxB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,EAAE,uBAAuB;IAAE,OAAO,MAAM;IAAI,KAAK,MAAM;GAAG,CAAC;QAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,MAAM,CAAC;EACzD;EACA,cAAc,EAAE,cAAc;EAC9B,UAAU,SAAS,EAAE,WAAW,OAAO,UAAU,QAAQ;EACzD,SAAS,EAAE,SAAS;EACpB,cAAc,YAAY;GACxB,OAAO;IAAE,KAAK;IAAM,OAAO;IAAM,MAAM;GAAO;EAChD;EACA,GAAG;CACL,IACA,CAAC,GAAG,YAAY,CAClB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentType.js","names":[],"sources":["../../src/model/ContentType.ts"],"sourcesContent":["/**\n * Copyright (c) 2017-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const SUBJECT_MATERIAL = \"subject-material\";\nexport const TASKS_AND_ACTIVITIES = \"tasks-and-activities\";\nexport const ASSESSMENT_RESOURCES = \"assessment-resources\";\nexport const SUBJECT = \"subject\";\nexport const SOURCE_MATERIAL = \"source-material\";\nexport const LEARNING_PATH = \"learning-path\";\nexport const TOPIC = \"topic\";\nexport const MULTIDISCIPLINARY = \"multidisciplinary\";\nexport const CONCEPT = \"concept\";\nexport const EXTERNAL = \"external\";\nexport const MISSING = \"missing\";\nexport const IMAGE = \"image\";\nexport const VIDEO = \"video\";\nexport const AUDIO = \"audio\";\nexport const PODCAST = \"podcast\";\nexport const GLOSS = \"gloss\";\nexport const PROGRAMME = \"programme\";\nexport const PODCAST_SERIES = \"podcast-series\";\nexport const FRONTPAGE_ARTICLE = \"frontpage-article\";\nexport const GAME = \"game\";\nexport const CASE = \"case\";\n\nexport const contentTypes = {\n SUBJECT_MATERIAL,\n TASKS_AND_ACTIVITIES,\n ASSESSMENT_RESOURCES,\n SUBJECT,\n SOURCE_MATERIAL,\n LEARNING_PATH,\n TOPIC,\n MULTIDISCIPLINARY,\n CONCEPT,\n EXTERNAL,\n MISSING,\n PROGRAMME,\n PODCAST_SERIES,\n GAME,\n CASE,\n};\n\nexport const RESOURCE_TYPE_LEARNING_PATH = \"urn:resourcetype:learningPath\";\nexport const RESOURCE_TYPE_SUBJECT_MATERIAL = \"urn:resourcetype:subjectMaterial\";\nexport const RESOURCE_TYPE_TASKS_AND_ACTIVITIES = \"urn:resourcetype:tasksAndActivities\";\nexport const RESOURCE_TYPE_ASSESSMENT_RESOURCES = \"urn:resourcetype:reviewResource\";\nexport const RESOURCE_TYPE_SOURCE_MATERIAL = \"urn:resourcetype:SourceMaterial\";\nexport const RESOURCE_TYPE_CONCEPT = \"urn:resourcetype:concept\";\nexport const RESOURCE_TYPE_GAME = \"urn:resourcetype:game\";\n\nexport const contentTypeMapping: Record<string, string> = {\n [RESOURCE_TYPE_LEARNING_PATH]: LEARNING_PATH,\n [RESOURCE_TYPE_SUBJECT_MATERIAL]: SUBJECT_MATERIAL,\n [RESOURCE_TYPE_TASKS_AND_ACTIVITIES]: TASKS_AND_ACTIVITIES,\n [RESOURCE_TYPE_ASSESSMENT_RESOURCES]: ASSESSMENT_RESOURCES,\n [RESOURCE_TYPE_SOURCE_MATERIAL]: SOURCE_MATERIAL,\n [RESOURCE_TYPE_CONCEPT]: CONCEPT,\n [RESOURCE_TYPE_GAME]: GAME,\n [MULTIDISCIPLINARY]: MULTIDISCIPLINARY,\n [CASE]: CASE,\n [TOPIC]: TOPIC,\n [FRONTPAGE_ARTICLE]: FRONTPAGE_ARTICLE,\n default: SUBJECT_MATERIAL,\n};\n\nexport const resourceEmbedTypeMapping: Record<string, string> = {\n image: \"image\",\n video: \"video\",\n concept: \"concept\",\n audio: \"audio\",\n podcast: \"podcast\",\n gloss: \"gloss\",\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,mBAAmB;AAChC,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;AACpC,MAAa,UAAU;AACvB,MAAa,kBAAkB;AAC/B,MAAa,gBAAgB;AAC7B,MAAa,QAAQ;AACrB,MAAa,oBAAoB;AACjC,MAAa,UAAU;AACvB,MAAa,WAAW;AACxB,MAAa,UAAU;AAMvB,MAAa,YAAY;AACzB,MAAa,iBAAiB;AAC9B,MAAa,oBAAoB;AACjC,MAAa,OAAO;AACpB,MAAa,OAAO;AAEpB,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"ContentType.js","names":[],"sources":["../../src/model/ContentType.ts"],"sourcesContent":["/**\n * Copyright (c) 2017-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const SUBJECT_MATERIAL = \"subject-material\";\nexport const TASKS_AND_ACTIVITIES = \"tasks-and-activities\";\nexport const ASSESSMENT_RESOURCES = \"assessment-resources\";\nexport const SUBJECT = \"subject\";\nexport const SOURCE_MATERIAL = \"source-material\";\nexport const LEARNING_PATH = \"learning-path\";\nexport const TOPIC = \"topic\";\nexport const MULTIDISCIPLINARY = \"multidisciplinary\";\nexport const CONCEPT = \"concept\";\nexport const EXTERNAL = \"external\";\nexport const MISSING = \"missing\";\nexport const IMAGE = \"image\";\nexport const VIDEO = \"video\";\nexport const AUDIO = \"audio\";\nexport const PODCAST = \"podcast\";\nexport const GLOSS = \"gloss\";\nexport const PROGRAMME = \"programme\";\nexport const PODCAST_SERIES = \"podcast-series\";\nexport const FRONTPAGE_ARTICLE = \"frontpage-article\";\nexport const GAME = \"game\";\nexport const CASE = \"case\";\n\nexport const contentTypes = {\n SUBJECT_MATERIAL,\n TASKS_AND_ACTIVITIES,\n ASSESSMENT_RESOURCES,\n SUBJECT,\n SOURCE_MATERIAL,\n LEARNING_PATH,\n TOPIC,\n MULTIDISCIPLINARY,\n CONCEPT,\n EXTERNAL,\n MISSING,\n PROGRAMME,\n PODCAST_SERIES,\n GAME,\n CASE,\n};\n\nexport const RESOURCE_TYPE_LEARNING_PATH = \"urn:resourcetype:learningPath\";\nexport const RESOURCE_TYPE_SUBJECT_MATERIAL = \"urn:resourcetype:subjectMaterial\";\nexport const RESOURCE_TYPE_TASKS_AND_ACTIVITIES = \"urn:resourcetype:tasksAndActivities\";\nexport const RESOURCE_TYPE_ASSESSMENT_RESOURCES = \"urn:resourcetype:reviewResource\";\nexport const RESOURCE_TYPE_SOURCE_MATERIAL = \"urn:resourcetype:SourceMaterial\";\nexport const RESOURCE_TYPE_CONCEPT = \"urn:resourcetype:concept\";\nexport const RESOURCE_TYPE_GAME = \"urn:resourcetype:game\";\n\nexport const contentTypeMapping: Record<string, string> = {\n [RESOURCE_TYPE_LEARNING_PATH]: LEARNING_PATH,\n [RESOURCE_TYPE_SUBJECT_MATERIAL]: SUBJECT_MATERIAL,\n [RESOURCE_TYPE_TASKS_AND_ACTIVITIES]: TASKS_AND_ACTIVITIES,\n [RESOURCE_TYPE_ASSESSMENT_RESOURCES]: ASSESSMENT_RESOURCES,\n [RESOURCE_TYPE_SOURCE_MATERIAL]: SOURCE_MATERIAL,\n [RESOURCE_TYPE_CONCEPT]: CONCEPT,\n [RESOURCE_TYPE_GAME]: GAME,\n [MULTIDISCIPLINARY]: MULTIDISCIPLINARY,\n [CASE]: CASE,\n [TOPIC]: TOPIC,\n [FRONTPAGE_ARTICLE]: FRONTPAGE_ARTICLE,\n default: SUBJECT_MATERIAL,\n};\n\nexport const resourceEmbedTypeMapping: Record<string, string> = {\n image: \"image\",\n video: \"video\",\n concept: \"concept\",\n audio: \"audio\",\n podcast: \"podcast\",\n gloss: \"gloss\",\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,mBAAmB;AAChC,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;AACpC,MAAa,UAAU;AACvB,MAAa,kBAAkB;AAC/B,MAAa,gBAAgB;AAC7B,MAAa,QAAQ;AACrB,MAAa,oBAAoB;AACjC,MAAa,UAAU;AACvB,MAAa,WAAW;AACxB,MAAa,UAAU;AAMvB,MAAa,YAAY;AACzB,MAAa,iBAAiB;AAC9B,MAAa,oBAAoB;AACjC,MAAa,OAAO;AACpB,MAAa,OAAO;AAEpB,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,8BAA8B;AAC3C,MAAa,iCAAiC;AAC9C,MAAa,qCAAqC;AAClD,MAAa,qCAAqC;AAClD,MAAa,gCAAgC;AAC7C,MAAa,wBAAwB;AACrC,MAAa,qBAAqB;AAElC,MAAa,qBAA6C;EACvD,8BAA8B;EAC9B,iCAAiC;EACjC,qCAAqC;EACrC,qCAAqC;EACrC,gCAAgC;EAChC,wBAAwB;EACxB,qBAAqB;EACrB,oBAAoB;EACpB,OAAO;EACP,QAAQ;EACR,oBAAoB;CACrB,SAAS;AACX;AAEA,MAAa,2BAAmD;CAC9D,OAAO;CACP,OAAO;CACP,SAAS;CACT,OAAO;CACP,SAAS;CACT,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubjectCategories.js","names":[],"sources":["../../src/model/SubjectCategories.ts"],"sourcesContent":["/**\n * Copyright (c) 2021-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const ACTIVE_SUBJECTS = \"active\";\nexport const ARCHIVE_SUBJECTS = \"archive\";\nexport const BETA_SUBJECTS = \"beta\";\nexport const OTHER = \"otherResources\";\n\nexport const subjectCategories = {\n ACTIVE_SUBJECTS,\n ARCHIVE_SUBJECTS,\n BETA_SUBJECTS,\n OTHER,\n};\n"],"mappings":";;;;;;;;;;;;;;;AAQA,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AAChC,MAAa,gBAAgB;AAC7B,MAAa,QAAQ;AAErB,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"SubjectCategories.js","names":[],"sources":["../../src/model/SubjectCategories.ts"],"sourcesContent":["/**\n * Copyright (c) 2021-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const ACTIVE_SUBJECTS = \"active\";\nexport const ARCHIVE_SUBJECTS = \"archive\";\nexport const BETA_SUBJECTS = \"beta\";\nexport const OTHER = \"otherResources\";\n\nexport const subjectCategories = {\n ACTIVE_SUBJECTS,\n ARCHIVE_SUBJECTS,\n BETA_SUBJECTS,\n OTHER,\n};\n"],"mappings":";;;;;;;;;;;;;;;AAQA,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AAChC,MAAa,gBAAgB;AAC7B,MAAa,QAAQ;AAErB,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubjectTypes.js","names":[],"sources":["../../src/model/SubjectTypes.ts"],"sourcesContent":["/**\n * Copyright (c) 2022-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const BETA_SUBJECT = \"betaSubject\";\nexport const SUBJECT = \"subject\";\nexport const RESOURCE_COLLECTION = \"resourceCollection\";\nexport const ARCHIVE_SUBJECT = \"archiveSubject\";\n\nexport const subjectTypes = {\n BETA_SUBJECT,\n SUBJECT,\n RESOURCE_COLLECTION,\n ARCHIVE_SUBJECT,\n};\n"],"mappings":";;;;;;;;;;;;;;;AAQA,MAAa,eAAe;AAC5B,MAAa,UAAU;AACvB,MAAa,sBAAsB;AACnC,MAAa,kBAAkB;AAE/B,MAAa,eAAe;CAC1B;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"SubjectTypes.js","names":[],"sources":["../../src/model/SubjectTypes.ts"],"sourcesContent":["/**\n * Copyright (c) 2022-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const BETA_SUBJECT = \"betaSubject\";\nexport const SUBJECT = \"subject\";\nexport const RESOURCE_COLLECTION = \"resourceCollection\";\nexport const ARCHIVE_SUBJECT = \"archiveSubject\";\n\nexport const subjectTypes = {\n BETA_SUBJECT,\n SUBJECT,\n RESOURCE_COLLECTION,\n ARCHIVE_SUBJECT,\n};\n"],"mappings":";;;;;;;;;;;;;;;AAQA,MAAa,eAAe;AAC5B,MAAa,UAAU;AACvB,MAAa,sBAAsB;AACnC,MAAa,kBAAkB;AAE/B,MAAa,eAAe;CAC1B;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WordClass.js","names":[],"sources":["../../src/model/WordClass.ts"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const wordClass = {\n adjective: \"adjective\",\n adverb: \"adverb\",\n properNoun: \"proper-noun\",\n auxiliary: \"auxiliary\",\n complement: \"complement\",\n conjunction: \"conjunction\",\n coverb: \"coverb\",\n determiner: \"determiner\",\n interjection: \"interjection\",\n quantifier: \"quantifier\",\n marker: \"marker\",\n modalVerb: \"modal-verb\",\n measureWord: \"measure-word\",\n noun: \"noun\",\n \"noun-zh\": \"noun-zh\",\n nounPhrase: \"noun-phrase\",\n onomatopoeia: \"onomatopoeia\",\n particle: \"particle\",\n demonstrative: \"demonstrative\",\n personalPronoun: \"personal-pronoun\",\n preposition: \"preposition\",\n pronoun: \"pronoun\",\n questionWord: \"question-word\",\n locationWord: \"location-word\",\n suffix: \"suffix\",\n numeral: \"numeral\",\n timeWord: \"time word\",\n timeExpression: \"time-expression\",\n stativeVerb: \"stative-verb\",\n subordinatingConjunction: \"subordinating-conjunction\",\n exclamationWord: \"exclamation-word\",\n expression: \"expression\",\n verb: \"verb\",\n verbComplement: \"verb-complement\",\n verbObject: \"verb-object\",\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,YAAY;CACvB,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,YAAY;CACZ,aAAa;CACb,QAAQ;CACR,YAAY;CACZ,cAAc;CACd,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,aAAa;CACb,MAAM;CACN,WAAW;CACX,YAAY;CACZ,cAAc;CACd,UAAU;CACV,eAAe;CACf,iBAAiB;CACjB,aAAa;CACb,SAAS;CACT,cAAc;CACd,cAAc;CACd,QAAQ;CACR,SAAS;CACT,UAAU;CACV,gBAAgB;CAChB,aAAa;CACb,0BAA0B;CAC1B,iBAAiB;CACjB,YAAY;CACZ,MAAM;CACN,gBAAgB;CAChB,YAAY;
|
|
1
|
+
{"version":3,"file":"WordClass.js","names":[],"sources":["../../src/model/WordClass.ts"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const wordClass = {\n adjective: \"adjective\",\n adverb: \"adverb\",\n properNoun: \"proper-noun\",\n auxiliary: \"auxiliary\",\n complement: \"complement\",\n conjunction: \"conjunction\",\n coverb: \"coverb\",\n determiner: \"determiner\",\n interjection: \"interjection\",\n quantifier: \"quantifier\",\n marker: \"marker\",\n modalVerb: \"modal-verb\",\n measureWord: \"measure-word\",\n noun: \"noun\",\n \"noun-zh\": \"noun-zh\",\n nounPhrase: \"noun-phrase\",\n onomatopoeia: \"onomatopoeia\",\n particle: \"particle\",\n demonstrative: \"demonstrative\",\n personalPronoun: \"personal-pronoun\",\n preposition: \"preposition\",\n pronoun: \"pronoun\",\n questionWord: \"question-word\",\n locationWord: \"location-word\",\n suffix: \"suffix\",\n numeral: \"numeral\",\n timeWord: \"time word\",\n timeExpression: \"time-expression\",\n stativeVerb: \"stative-verb\",\n subordinatingConjunction: \"subordinating-conjunction\",\n exclamationWord: \"exclamation-word\",\n expression: \"expression\",\n verb: \"verb\",\n verbComplement: \"verb-complement\",\n verbObject: \"verb-object\",\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,YAAY;CACvB,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,YAAY;CACZ,aAAa;CACb,QAAQ;CACR,YAAY;CACZ,cAAc;CACd,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,aAAa;CACb,MAAM;CACN,WAAW;CACX,YAAY;CACZ,cAAc;CACd,UAAU;CACV,eAAe;CACf,iBAAiB;CACjB,aAAa;CACb,SAAS;CACT,cAAc;CACd,cAAc;CACd,QAAQ;CACR,SAAS;CACT,UAAU;CACV,gBAAgB;CAChB,aAAa;CACb,0BAA0B;CAC1B,iBAAiB;CACjB,YAAY;CACZ,MAAM;CACN,gBAAgB;CAChB,YAAY;AACd"}
|
package/lib/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/model/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2017-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { contentTypes, contentTypeMapping, resourceEmbedTypeMapping } from \"./ContentType\";\nimport * as subjectCategories from \"./SubjectCategories\";\nimport * as subjectTypes from \"./SubjectTypes\";\nimport * as wordClass from \"./WordClass\";\n\nexport const constants = {\n contentTypes,\n subjectCategories,\n subjectTypes,\n contentTypeMapping,\n resourceEmbedTypeMapping,\n wordClass,\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,YAAY;CACvB,cAAA,oBAAA;CACA,mBAAA,0BAAA;CACA,cAAA,qBAAA;CACA,oBAAA,oBAAA;CACA,0BAAA,oBAAA;CACA,WAAA,kBAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/model/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2017-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { contentTypes, contentTypeMapping, resourceEmbedTypeMapping } from \"./ContentType\";\nimport * as subjectCategories from \"./SubjectCategories\";\nimport * as subjectTypes from \"./SubjectTypes\";\nimport * as wordClass from \"./WordClass\";\n\nexport const constants = {\n contentTypes,\n subjectCategories,\n subjectTypes,\n contentTypeMapping,\n resourceEmbedTypeMapping,\n wordClass,\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,YAAY;CACvB,cAAA,oBAAA;CACA,mBAAA,0BAAA;CACA,cAAA,qBAAA;CACA,oBAAA,oBAAA;CACA,0BAAA,oBAAA;CACA,WAAA,kBAAA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"licenseAttributes.js","names":[],"sources":["../../src/utils/licenseAttributes.ts"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { getLicenseByAbbreviation, isCreativeCommonsLicense } from \"@ndla/licenses\";\n\nexport const licenseAttributes = (license: string | undefined, lang: string | undefined, url: string | undefined) => {\n const licenseAbbr = getLicenseByAbbreviation(license ? license : \"\", lang);\n\n const licenseProps = isCreativeCommonsLicense(licenseAbbr.rights)\n ? {\n \"xmlns:cc\": \"https://creativecommons.org/ns#\",\n \"xmlns:dct\": \"http://purl.org/dc/terms/\",\n about: url ?? undefined,\n }\n : {};\n\n return licenseProps;\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,qBAAqB,SAA6B,MAA0B,QAA4B;
|
|
1
|
+
{"version":3,"file":"licenseAttributes.js","names":[],"sources":["../../src/utils/licenseAttributes.ts"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { getLicenseByAbbreviation, isCreativeCommonsLicense } from \"@ndla/licenses\";\n\nexport const licenseAttributes = (license: string | undefined, lang: string | undefined, url: string | undefined) => {\n const licenseAbbr = getLicenseByAbbreviation(license ? license : \"\", lang);\n\n const licenseProps = isCreativeCommonsLicense(licenseAbbr.rights)\n ? {\n \"xmlns:cc\": \"https://creativecommons.org/ns#\",\n \"xmlns:dct\": \"http://purl.org/dc/terms/\",\n about: url ?? undefined,\n }\n : {};\n\n return licenseProps;\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,qBAAqB,SAA6B,MAA0B,QAA4B;CAWnH,QAAA,GAAA,eAAA,2BAAA,GAAA,eAAA,0BAV6C,UAAU,UAAU,IAAI,IAEb,EAAE,MAAM,IAC5D;EACE,YAAY;EACZ,aAAa;EACb,OAAO,OAAO,KAAA;CAChB,IACA,CAAC;AAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relativeUrl.js","names":[],"sources":["../../src/utils/relativeUrl.ts"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nconst supportedTranslationLanguages = [\"nb\", \"nn\", \"en\", \"se\"] as const;\n\nconst ENV_REGEX = /(staging|test)\\.?/;\nconst LANGUAGE_REGEX = new RegExp(`^\\\\/((?:${supportedTranslationLanguages.join(\"|\")})(?:$|\\\\/))`, \"\");\n\nconst NDLA_URL = /(.*\\.)?ndla.no.*/;\nconst REPLACE_WWW = /^www\\./;\n\nexport const getPossiblyRelativeUrl = (url: string, path?: string) => {\n if (!path) return url;\n // If url is a mailto link, return url as is.\n if (url.startsWith(\"mailto:\")) return url;\n // If not on NDLA, or if url is not a NDLA url, return url as is\n if (!NDLA_URL.test(url) || !NDLA_URL.test(path)) return url;\n //Remove environment info\n const urlObj = new URL(url.replace(ENV_REGEX, \"\"));\n const pathObj = new URL(path.replace(ENV_REGEX, \"\"));\n // If the host is the same, return the relative path\n if (urlObj.hostname.replace(REPLACE_WWW, \"\") === pathObj.hostname.replace(REPLACE_WWW, \"\")) {\n // Replace the language part of the url with the language part of the path\n // Keep the search params if they exist\n const search = urlObj.search;\n // If the path language part does not exist, remove it.\n const urlMatch = urlObj.pathname.match(LANGUAGE_REGEX);\n const pathMatch = pathObj.pathname.match(LANGUAGE_REGEX);\n if (urlMatch?.[1] && urlMatch?.[1] !== pathMatch?.[1]) {\n return `${urlObj.pathname.replace(urlMatch[1], pathMatch?.[1] || \"\")}${search}`;\n }\n\n return `${urlObj.pathname}${search}`;\n }\n return url;\n};\n"],"mappings":";;;;;;;;AAQA,MAAM,gCAAgC;CAAC;CAAM;CAAM;CAAM;
|
|
1
|
+
{"version":3,"file":"relativeUrl.js","names":[],"sources":["../../src/utils/relativeUrl.ts"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nconst supportedTranslationLanguages = [\"nb\", \"nn\", \"en\", \"se\"] as const;\n\nconst ENV_REGEX = /(staging|test)\\.?/;\nconst LANGUAGE_REGEX = new RegExp(`^\\\\/((?:${supportedTranslationLanguages.join(\"|\")})(?:$|\\\\/))`, \"\");\n\nconst NDLA_URL = /(.*\\.)?ndla.no.*/;\nconst REPLACE_WWW = /^www\\./;\n\nexport const getPossiblyRelativeUrl = (url: string, path?: string) => {\n if (!path) return url;\n // If url is a mailto link, return url as is.\n if (url.startsWith(\"mailto:\")) return url;\n // If not on NDLA, or if url is not a NDLA url, return url as is\n if (!NDLA_URL.test(url) || !NDLA_URL.test(path)) return url;\n //Remove environment info\n const urlObj = new URL(url.replace(ENV_REGEX, \"\"));\n const pathObj = new URL(path.replace(ENV_REGEX, \"\"));\n // If the host is the same, return the relative path\n if (urlObj.hostname.replace(REPLACE_WWW, \"\") === pathObj.hostname.replace(REPLACE_WWW, \"\")) {\n // Replace the language part of the url with the language part of the path\n // Keep the search params if they exist\n const search = urlObj.search;\n // If the path language part does not exist, remove it.\n const urlMatch = urlObj.pathname.match(LANGUAGE_REGEX);\n const pathMatch = pathObj.pathname.match(LANGUAGE_REGEX);\n if (urlMatch?.[1] && urlMatch?.[1] !== pathMatch?.[1]) {\n return `${urlObj.pathname.replace(urlMatch[1], pathMatch?.[1] || \"\")}${search}`;\n }\n\n return `${urlObj.pathname}${search}`;\n }\n return url;\n};\n"],"mappings":";;;;;;;;AAQA,MAAM,gCAAgC;CAAC;CAAM;CAAM;CAAM;AAAI;AAE7D,MAAM,YAAY;AAClB,MAAM,iBAAiB,IAAI,OAAO,WAAW,8BAA8B,KAAK,GAAG,EAAE,cAAc,EAAE;AAErG,MAAM,WAAW;AACjB,MAAM,cAAc;AAEpB,MAAa,0BAA0B,KAAa,SAAkB;CACpE,IAAI,CAAC,MAAM,OAAO;CAElB,IAAI,IAAI,WAAW,SAAS,GAAG,OAAO;CAEtC,IAAI,CAAC,SAAS,KAAK,GAAG,KAAK,CAAC,SAAS,KAAK,IAAI,GAAG,OAAO;CAExD,MAAM,SAAS,IAAI,IAAI,IAAI,QAAQ,WAAW,EAAE,CAAC;CACjD,MAAM,UAAU,IAAI,IAAI,KAAK,QAAQ,WAAW,EAAE,CAAC;CAEnD,IAAI,OAAO,SAAS,QAAQ,aAAa,EAAE,MAAM,QAAQ,SAAS,QAAQ,aAAa,EAAE,GAAG;EAG1F,MAAM,SAAS,OAAO;EAEtB,MAAM,WAAW,OAAO,SAAS,MAAM,cAAc;EACrD,MAAM,YAAY,QAAQ,SAAS,MAAM,cAAc;EACvD,IAAI,WAAW,MAAM,WAAW,OAAO,YAAY,IACjD,OAAO,GAAG,OAAO,SAAS,QAAQ,SAAS,IAAI,YAAY,MAAM,EAAE,IAAI;EAGzE,OAAO,GAAG,OAAO,WAAW;CAC9B;CACA,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "56.0.
|
|
4
|
+
"version": "56.0.194-alpha.0",
|
|
5
5
|
"description": "UI component library for NDLA",
|
|
6
6
|
"license": "GPL-3.0",
|
|
7
7
|
"exports": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"types"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ark-ui/react": "^5.
|
|
39
|
+
"@ark-ui/react": "^5.36.2",
|
|
40
40
|
"@ndla/core": "^6.0.7-alpha.0",
|
|
41
|
-
"@ndla/icons": "^8.0.
|
|
41
|
+
"@ndla/icons": "^8.0.91-alpha.0",
|
|
42
42
|
"@ndla/licenses": "^10.0.12-alpha.0",
|
|
43
|
-
"@ndla/locales": "^0.0.
|
|
44
|
-
"@ndla/primitives": "^1.0.
|
|
45
|
-
"@ndla/safelink": "^7.0.
|
|
46
|
-
"@ndla/styled-system": "^0.0.
|
|
43
|
+
"@ndla/locales": "^0.0.5",
|
|
44
|
+
"@ndla/primitives": "^1.0.132-alpha.0",
|
|
45
|
+
"@ndla/safelink": "^7.0.135-alpha.0",
|
|
46
|
+
"@ndla/styled-system": "^0.0.51",
|
|
47
47
|
"@ndla/util": "^5.0.21-alpha.0",
|
|
48
48
|
"html-react-parser": "^6.0.0"
|
|
49
49
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react-router": ">= 7.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@ndla/preset-panda": "^0.0.
|
|
58
|
+
"@ndla/preset-panda": "^0.0.78",
|
|
59
59
|
"@ndla/types-backend": "^1.0.125",
|
|
60
60
|
"@ndla/types-embed": "^5.0.22-alpha.0",
|
|
61
61
|
"@pandacss/dev": "^1.10.0"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "759d1a57b0a7ad06e831472aae9f8fba287d552e"
|
|
67
67
|
}
|
package/src/Article/Article.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { ark, type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import { ark, type HTMLArkProps } from "@ark-ui/react/factory";
|
|
10
10
|
import { Heading, Text } from "@ndla/primitives";
|
|
11
11
|
import { cx } from "@ndla/styled-system/css";
|
|
12
12
|
import { styled } from "@ndla/styled-system/jsx";
|
|
@@ -20,7 +20,7 @@ export const SpeechControl = ({ src, title }: Props) => {
|
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<div data-embed-type="speech">
|
|
23
|
-
{/* oxlint-disable-next-line jsx-a11y/media-has-caption */}
|
|
23
|
+
{/* oxlint-disable-next-line jsx-a11y/media-has-caption oxlint-disable-next-line jsx-a11y/control-has-associated-label */}
|
|
24
24
|
<audio ref={audioRef} src={src} title={title} preload="metadata" />
|
|
25
25
|
<PlayButton variant="tertiary" onClick={togglePlay}>
|
|
26
26
|
<VolumeUpFill />
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { SliderValueChangeDetails } from "@ark-ui/react";
|
|
9
|
+
import type { SliderValueChangeDetails } from "@ark-ui/react/slider";
|
|
10
10
|
import { useCallback, useRef, useState, type ReactEventHandler } from "react";
|
|
11
11
|
|
|
12
12
|
export const useAudioControls = () => {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { Portal } from "@ark-ui/react";
|
|
9
|
+
import { Portal } from "@ark-ui/react/portal";
|
|
10
10
|
import { PopoverContent, PopoverRoot, PopoverTrigger } from "@ndla/primitives";
|
|
11
11
|
import { styled } from "@ndla/styled-system/jsx";
|
|
12
12
|
import type { ConceptMetaData } from "@ndla/types-embed";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { ark, type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import { ark, type HTMLArkProps } from "@ark-ui/react/factory";
|
|
10
10
|
import { css, cva } from "@ndla/styled-system/css";
|
|
11
11
|
import { styled } from "@ndla/styled-system/jsx";
|
|
12
12
|
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
package/src/Embed/GlossEmbed.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { Portal } from "@ark-ui/react";
|
|
9
|
+
import { Portal } from "@ark-ui/react/portal";
|
|
10
10
|
import { Figure, PopoverContent, PopoverRoot, PopoverTrigger } from "@ndla/primitives";
|
|
11
11
|
import { styled } from "@ndla/styled-system/jsx";
|
|
12
12
|
import type { ConceptMetaData } from "@ndla/types-embed";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { ExpandableBox, ExpandableBoxSummary, FramedContent, PageContent } from "@ndla/primitives";
|
|
9
|
+
import { ExpandableBox, ExpandableBoxSummary, FramedContent, PageContent, Button } from "@ndla/primitives";
|
|
10
10
|
import type { UUDisclaimerData, UuDisclaimerEmbedData } from "@ndla/types-embed";
|
|
11
11
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
12
12
|
import { AnchorHeading } from "../AnchorHeading/AnchorHeading";
|
|
@@ -199,3 +199,30 @@ export const Error: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
199
199
|
),
|
|
200
200
|
},
|
|
201
201
|
};
|
|
202
|
+
export const SkipContent: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
203
|
+
args: {
|
|
204
|
+
embed: {
|
|
205
|
+
resource: "uu-disclaimer",
|
|
206
|
+
status: "success",
|
|
207
|
+
embedData,
|
|
208
|
+
data,
|
|
209
|
+
},
|
|
210
|
+
children: (
|
|
211
|
+
<div>
|
|
212
|
+
<h2>Dette er noe ugyldig innhold</h2>
|
|
213
|
+
<Button>Denne kan hoppes over!</Button>
|
|
214
|
+
<p>
|
|
215
|
+
Innholdet kan enkelt hoppes over ved å bruke knappen skip-knappen som dukker opp når du bruker
|
|
216
|
+
tastaturnavigering inne i popoveren.
|
|
217
|
+
</p>
|
|
218
|
+
</div>
|
|
219
|
+
),
|
|
220
|
+
},
|
|
221
|
+
render: (args) => (
|
|
222
|
+
<>
|
|
223
|
+
<UuDisclaimerEmbed {...args} />
|
|
224
|
+
<h2>Dette er noe gyldig innhold</h2>
|
|
225
|
+
<Button>Denne vil ikke hoppes over</Button>
|
|
226
|
+
</>
|
|
227
|
+
),
|
|
228
|
+
};
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { Portal } from "@ark-ui/react";
|
|
9
|
+
import { Portal } from "@ark-ui/react/portal";
|
|
10
10
|
import { AccessibilityFill, ErrorWarningFill } from "@ndla/icons";
|
|
11
|
-
import { IconButton, PopoverContent, PopoverRoot, PopoverTrigger } from "@ndla/primitives";
|
|
11
|
+
import { Button, IconButton, PopoverContent, PopoverRoot, PopoverTrigger } from "@ndla/primitives";
|
|
12
12
|
import { styled } from "@ndla/styled-system/jsx";
|
|
13
|
+
import { visuallyHidden } from "@ndla/styled-system/patterns";
|
|
13
14
|
import type { UuDisclaimerMetaData } from "@ndla/types-embed";
|
|
14
|
-
import { type ReactNode } from "react";
|
|
15
|
+
import { useRef, type ReactNode } from "react";
|
|
15
16
|
import { useTranslation } from "react-i18next";
|
|
16
17
|
|
|
17
18
|
interface Props {
|
|
@@ -44,14 +45,35 @@ const StyledErrorWarningFill = styled(ErrorWarningFill, {
|
|
|
44
45
|
|
|
45
46
|
const StyledPopoverContent = styled(PopoverContent, {
|
|
46
47
|
base: {
|
|
48
|
+
display: "flex",
|
|
49
|
+
flexDirection: "column",
|
|
50
|
+
gap: "xsmall",
|
|
47
51
|
width: "surface.xlarge",
|
|
48
52
|
maxHeight: "50vh",
|
|
49
53
|
overflowY: "auto",
|
|
50
54
|
},
|
|
51
55
|
});
|
|
52
56
|
|
|
57
|
+
const HiddenButton = styled(Button, {
|
|
58
|
+
base: {
|
|
59
|
+
"&:not(:focus)": {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
width: "1px",
|
|
62
|
+
height: "1px",
|
|
63
|
+
padding: "0",
|
|
64
|
+
margin: "-1px",
|
|
65
|
+
overflow: "hidden",
|
|
66
|
+
clip: "rect(0,0,0,0)",
|
|
67
|
+
whiteSpace: "nowrap",
|
|
68
|
+
borderWidth: "0",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
53
73
|
export const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }: Props) => {
|
|
54
74
|
const { t } = useTranslation();
|
|
75
|
+
const skipRef = useRef<HTMLDivElement>(null);
|
|
76
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
55
77
|
if (embed.status === "error") {
|
|
56
78
|
return (
|
|
57
79
|
<DisclaimerWrapper>
|
|
@@ -65,8 +87,9 @@ export const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }: Pr
|
|
|
65
87
|
}
|
|
66
88
|
|
|
67
89
|
return (
|
|
90
|
+
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role
|
|
68
91
|
<DisclaimerWrapper role="region" data-embed-type="uu-disclaimer">
|
|
69
|
-
<PopoverRoot>
|
|
92
|
+
<PopoverRoot initialFocusEl={() => contentRef.current}>
|
|
70
93
|
<PopoverTrigger asChild>
|
|
71
94
|
<StyledIconButton
|
|
72
95
|
size="small"
|
|
@@ -78,12 +101,16 @@ export const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }: Pr
|
|
|
78
101
|
</StyledIconButton>
|
|
79
102
|
</PopoverTrigger>
|
|
80
103
|
<Portal>
|
|
81
|
-
<StyledPopoverContent>
|
|
104
|
+
<StyledPopoverContent ref={contentRef}>
|
|
82
105
|
<div>{transformedDisclaimer}</div>
|
|
106
|
+
<HiddenButton onClick={() => skipRef.current?.focus()}>{t("uuDisclaimer.skipContent")}</HiddenButton>
|
|
83
107
|
</StyledPopoverContent>
|
|
84
108
|
</Portal>
|
|
85
109
|
</PopoverRoot>
|
|
86
110
|
<div data-uu-content="">{children}</div>
|
|
111
|
+
<div className={visuallyHidden()} tabIndex={-1} ref={skipRef}>
|
|
112
|
+
{t("uuDisclaimer.contentCompleted")}
|
|
113
|
+
</div>
|
|
87
114
|
</DisclaimerWrapper>
|
|
88
115
|
);
|
|
89
116
|
};
|
package/src/Gloss/Gloss.tsx
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { createListCollection } from "@ark-ui/react/collection";
|
|
10
|
+
import { type ComboboxInputValueChangeDetails } from "@ark-ui/react/combobox";
|
|
10
11
|
import { CloseLine, ArrowDownShortLine, CheckLine } from "@ndla/icons";
|
|
11
12
|
import {
|
|
12
13
|
ComboboxContent,
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { type CollectionItem
|
|
9
|
+
import { type CollectionItem } from "@ark-ui/react/collection";
|
|
10
|
+
import { useComboboxContext } from "@ark-ui/react/combobox";
|
|
11
|
+
import { useTagsInputContext } from "@ark-ui/react/tags-input";
|
|
10
12
|
import { CloseLine } from "@ndla/icons";
|
|
11
13
|
import {
|
|
12
14
|
ComboboxClearTrigger,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { CollectionItem } from "@ark-ui/react";
|
|
9
|
+
import type { CollectionItem } from "@ark-ui/react/collection";
|
|
10
10
|
import type { ComboboxRootProps, PaginationRootProps, TagsInputRootProps, DatePickerRootProps } from "@ndla/primitives";
|
|
11
11
|
import { useMemo } from "react";
|
|
12
12
|
import { useTranslation } from "react-i18next";
|
|
@@ -208,10 +208,10 @@ export const useDatePickerTranslations = (
|
|
|
208
208
|
() => ({
|
|
209
209
|
dayCell: (state) => {
|
|
210
210
|
if (state.unavailable) {
|
|
211
|
-
return t("dayCell.unavailable", { date: state.
|
|
211
|
+
return t("dayCell.unavailable", { date: state.valueText });
|
|
212
212
|
} else if (state.selected) {
|
|
213
|
-
return t("dayCell.selected", { date: state.
|
|
214
|
-
} else return t("dayCell.select", { date: state.
|
|
213
|
+
return t("dayCell.selected", { date: state.valueText });
|
|
214
|
+
} else return t("dayCell.select", { date: state.valueText });
|
|
215
215
|
},
|
|
216
216
|
nextTrigger: (view) => t(`nextTrigger.${view}`),
|
|
217
217
|
prevTrigger: (view) => t(`prevTrigger.${view}`),
|