@ndla/video-search 8.0.148-alpha.0 → 8.0.150-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.
@@ -4,7 +4,6 @@ import { styled } from "@ndla/styled-system/jsx";
4
4
  import { useState } from "react";
5
5
  import { getLicenseByNBTitle } from "@ndla/licenses";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
-
8
7
  //#region src/VideoListItem.tsx
9
8
  /**
10
9
  * Copyright (c) 2024-present, NDLA.
@@ -113,7 +112,7 @@ const VideoListItem = ({ video, onVideoSelect, translations, locale }) => {
113
112
  ]
114
113
  })] });
115
114
  };
116
-
117
115
  //#endregion
118
116
  export { VideoListItem };
117
+
119
118
  //# sourceMappingURL=VideoListItem.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"VideoListItem.mjs","names":[],"sources":["../src/VideoListItem.tsx"],"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 { CloseLine, PanoramaPhotosphere } from \"@ndla/icons\";\nimport { getLicenseByNBTitle, type LicenseLocaleType } from \"@ndla/licenses\";\nimport { Image, Text, ListItemContent, ListItemRoot, Button, IconButton } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { useState } from \"react\";\nimport type { VideoTranslations } from \"./VideoSearch\";\n\nconst ButtonWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"small\",\n },\n});\n\nconst PreviewIframe = styled(\"iframe\", {\n base: {\n minHeight: \"surface.xxsmall\",\n },\n});\n\nconst PreviewWrapper = styled(\"div\", {\n base: {\n display: \"grid\",\n gap: \"xsmall\",\n gridTemplateColumns: \"repeat(3,1fr)\",\n padding: \"small\",\n borderBlockEnd: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledImage = styled(Image, {\n base: {\n minWidth: \"surface.xxsmall\",\n height: \"surface.4xsmall\",\n objectFit: \"cover\",\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledVideoMeta = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n },\n});\nconst StyledListItemContent = styled(ListItemContent, {\n base: {\n alignItems: \"flex-end\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n marginLeft: \"auto\",\n },\n});\n\nconst StyledListItemRoot = styled(ListItemRoot, {\n base: {\n paddingBlock: \"medium\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\ninterface LicenseProps {\n license: LicenseLocaleType | string;\n}\nconst License = ({ license }: LicenseProps) => {\n if (typeof license === \"string\") return <Text>{license}</Text>;\n if (license.url?.length) {\n return (\n <a href={license.url} rel=\"license\">\n {license.abbreviation}\n </a>\n );\n }\n return <Text>{license.abbreviation}</Text>;\n};\n\ninterface VideoListItemProps {\n video: BrightcoveApiType;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n}\n\nexport const VideoListItem = ({ video, onVideoSelect, translations, locale }: VideoListItemProps) => {\n const [isPreviewing, setIsPreviewing] = useState(false);\n const license = video.custom_fields?.license ? getLicenseByNBTitle(video.custom_fields.license, locale) : \"\";\n\n return (\n <li>\n <StyledListItemRoot nonInteractive>\n <StyledImage src={video.images?.thumbnail?.src} alt=\"\" variant=\"rounded\" />\n <StyledListItemContent>\n <StyledVideoMeta>\n <Text textStyle=\"title.medium\">\n {video.name}\n {video.projection === \"equirectangular\" && (\n <PanoramaPhotosphere\n aria-hidden={false}\n aria-label={translations.is360Video}\n title={translations.is360Video}\n />\n )}\n </Text>\n <Text>{video.custom_fields?.licenseinfo ?? \"\"}</Text>\n <License license={license} />\n </StyledVideoMeta>\n <ButtonWrapper>\n <Button\n variant=\"secondary\"\n size=\"small\"\n onClick={() => setIsPreviewing((p) => !p)}\n aria-expanded={isPreviewing}\n aria-controls={`video-preview-${video.id}`}\n >\n {translations.previewVideo}\n </Button>\n <Button size=\"small\" onClick={() => onVideoSelect(video)}>\n {translations.addVideo}\n </Button>\n </ButtonWrapper>\n </StyledListItemContent>\n </StyledListItemRoot>\n {!!isPreviewing && (\n <PreviewWrapper id={`video-preview-${video.id}`}>\n <div />\n <PreviewIframe\n title={video.name}\n src={`//players.brightcove.net/${video.account_id}/BkLm8fT_default/index.html?videoId=${video.id}`}\n allowFullScreen\n />\n <StyledIconButton\n variant=\"secondary\"\n aria-label={translations.close}\n title={translations.close}\n onClick={() => setIsPreviewing(false)}\n >\n <CloseLine />\n </StyledIconButton>\n </PreviewWrapper>\n )}\n </li>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAM,gBAAgB,OAAO,OAAO,EAClC,MAAM;CACJ,SAAS;CACT,KAAK;CACN,EACF,CAAC;AAEF,MAAM,gBAAgB,OAAO,UAAU,EACrC,MAAM,EACJ,WAAW,mBACZ,EACF,CAAC;AAEF,MAAM,iBAAiB,OAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,KAAK;CACL,qBAAqB;CACrB,SAAS;CACT,gBAAgB;CAChB,aAAa;CACd,EACF,CAAC;AAEF,MAAM,cAAc,OAAO,OAAO,EAChC,MAAM;CACJ,UAAU;CACV,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,aAAa;CACd,EACF,CAAC;AAEF,MAAM,kBAAkB,OAAO,OAAO,EACpC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACN,EACF,CAAC;AACF,MAAM,wBAAwB,OAAO,iBAAiB,EACpD,MAAM;CACJ,YAAY;CACZ,YAAY;EACV,eAAe;EACf,YAAY;EACb;CACF,EACF,CAAC;AAEF,MAAM,mBAAmB,OAAO,YAAY,EAC1C,MAAM,EACJ,YAAY,QACb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AAM;IAC9F;KACA;GACF,oBAAC;IACC,SAAQ;IACR,cAAY,aAAa;IACzB,OAAO,aAAa;IACpB,eAAe,gBAAgB,MAAM;cAErC,oBAAC,cAAY;KACI;;GACJ,IAEhB"}
1
+ {"version":3,"file":"VideoListItem.mjs","names":[],"sources":["../src/VideoListItem.tsx"],"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 { CloseLine, PanoramaPhotosphere } from \"@ndla/icons\";\nimport { getLicenseByNBTitle, type LicenseLocaleType } from \"@ndla/licenses\";\nimport { Image, Text, ListItemContent, ListItemRoot, Button, IconButton } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { useState } from \"react\";\nimport type { VideoTranslations } from \"./types\";\n\nconst ButtonWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"small\",\n },\n});\n\nconst PreviewIframe = styled(\"iframe\", {\n base: {\n minHeight: \"surface.xxsmall\",\n },\n});\n\nconst PreviewWrapper = styled(\"div\", {\n base: {\n display: \"grid\",\n gap: \"xsmall\",\n gridTemplateColumns: \"repeat(3,1fr)\",\n padding: \"small\",\n borderBlockEnd: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledImage = styled(Image, {\n base: {\n minWidth: \"surface.xxsmall\",\n height: \"surface.4xsmall\",\n objectFit: \"cover\",\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledVideoMeta = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n },\n});\nconst StyledListItemContent = styled(ListItemContent, {\n base: {\n alignItems: \"flex-end\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n marginLeft: \"auto\",\n },\n});\n\nconst StyledListItemRoot = styled(ListItemRoot, {\n base: {\n paddingBlock: \"medium\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\ninterface LicenseProps {\n license: LicenseLocaleType | string;\n}\nconst License = ({ license }: LicenseProps) => {\n if (typeof license === \"string\") return <Text>{license}</Text>;\n if (license.url?.length) {\n return (\n <a href={license.url} rel=\"license\">\n {license.abbreviation}\n </a>\n );\n }\n return <Text>{license.abbreviation}</Text>;\n};\n\ninterface VideoListItemProps {\n video: BrightcoveApiType;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n}\n\nexport const VideoListItem = ({ video, onVideoSelect, translations, locale }: VideoListItemProps) => {\n const [isPreviewing, setIsPreviewing] = useState(false);\n const license = video.custom_fields?.license ? getLicenseByNBTitle(video.custom_fields.license, locale) : \"\";\n\n return (\n <li>\n <StyledListItemRoot nonInteractive>\n <StyledImage src={video.images?.thumbnail?.src} alt=\"\" variant=\"rounded\" />\n <StyledListItemContent>\n <StyledVideoMeta>\n <Text textStyle=\"title.medium\">\n {video.name}\n {video.projection === \"equirectangular\" && (\n <PanoramaPhotosphere\n aria-hidden={false}\n aria-label={translations.is360Video}\n title={translations.is360Video}\n />\n )}\n </Text>\n <Text>{video.custom_fields?.licenseinfo ?? \"\"}</Text>\n <License license={license} />\n </StyledVideoMeta>\n <ButtonWrapper>\n <Button\n variant=\"secondary\"\n size=\"small\"\n onClick={() => setIsPreviewing((p) => !p)}\n aria-expanded={isPreviewing}\n aria-controls={`video-preview-${video.id}`}\n >\n {translations.previewVideo}\n </Button>\n <Button size=\"small\" onClick={() => onVideoSelect(video)}>\n {translations.addVideo}\n </Button>\n </ButtonWrapper>\n </StyledListItemContent>\n </StyledListItemRoot>\n {!!isPreviewing && (\n <PreviewWrapper id={`video-preview-${video.id}`}>\n <div />\n <PreviewIframe\n title={video.name}\n src={`//players.brightcove.net/${video.account_id}/BkLm8fT_default/index.html?videoId=${video.id}`}\n allowFullScreen\n />\n <StyledIconButton\n variant=\"secondary\"\n aria-label={translations.close}\n title={translations.close}\n onClick={() => setIsPreviewing(false)}\n >\n <CloseLine />\n </StyledIconButton>\n </PreviewWrapper>\n )}\n </li>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,gBAAgB,OAAO,OAAO,EAClC,MAAM;CACJ,SAAS;CACT,KAAK;CACN,EACF,CAAC;AAEF,MAAM,gBAAgB,OAAO,UAAU,EACrC,MAAM,EACJ,WAAW,mBACZ,EACF,CAAC;AAEF,MAAM,iBAAiB,OAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,KAAK;CACL,qBAAqB;CACrB,SAAS;CACT,gBAAgB;CAChB,aAAa;CACd,EACF,CAAC;AAEF,MAAM,cAAc,OAAO,OAAO,EAChC,MAAM;CACJ,UAAU;CACV,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,aAAa;CACd,EACF,CAAC;AAEF,MAAM,kBAAkB,OAAO,OAAO,EACpC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACN,EACF,CAAC;AACF,MAAM,wBAAwB,OAAO,iBAAiB,EACpD,MAAM;CACJ,YAAY;CACZ,YAAY;EACV,eAAe;EACf,YAAY;EACb;CACF,EACF,CAAC;AAEF,MAAM,mBAAmB,OAAO,YAAY,EAC1C,MAAM,EACJ,YAAY,QACb,EACF,CAAC;AAEF,MAAM,qBAAqB,OAAO,cAAc,EAC9C,MAAM;CACJ,cAAc;CACd,YAAY;EACV,eAAe;EACf,YAAY;EACb;CACF,EACF,CAAC;AAKF,MAAM,WAAW,EAAE,cAA4B;AAC7C,KAAI,OAAO,YAAY,SAAU,QAAO,oBAAC,MAAD,EAAA,UAAO,SAAe,CAAA;AAC9D,KAAI,QAAQ,KAAK,OACf,QACE,oBAAC,KAAD;EAAG,MAAM,QAAQ;EAAK,KAAI;YACvB,QAAQ;EACP,CAAA;AAGR,QAAO,oBAAC,MAAD,EAAA,UAAO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aAAa;IACzB,OAAO,aAAa;IACpB,eAAe,gBAAgB,MAAM;cAErC,oBAAC,WAAD,EAAa,CAAA;IACI,CAAA;GACJ;IAEhB,EAAA,CAAA"}
@@ -2,7 +2,6 @@ import { VideoListItem } from "./VideoListItem.mjs";
2
2
  import { Button, Spinner, Text } from "@ndla/primitives";
3
3
  import { styled } from "@ndla/styled-system/jsx";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
-
6
5
  //#region src/VideoResultList.tsx
7
6
  /**
8
7
  * Copyright (c) 2017-present, NDLA.
@@ -39,7 +38,7 @@ const VideoResultList = ({ videos, existsMoreVideos, isLoading, translations, lo
39
38
  })
40
39
  ] });
41
40
  };
42
-
43
41
  //#endregion
44
42
  export { VideoResultList };
43
+
45
44
  //# sourceMappingURL=VideoResultList.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"VideoResultList.mjs","names":[],"sources":["../src/VideoResultList.tsx"],"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 { Text, Button, Spinner } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { VideoListItem } from \"./VideoListItem\";\nimport type { VideoTranslations } from \"./VideoSearch\";\n\nconst StyledList = styled(\"ul\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n listStyle: \"none\",\n width: \"100%\",\n },\n});\n\nconst StyledVideoResultWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n alignItems: \"center\",\n },\n});\n\ninterface Props {\n videos: BrightcoveApiType[];\n existsMoreVideos: boolean;\n isLoading: boolean;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n onShowMore: () => void;\n}\n\nexport const VideoResultList = ({\n videos,\n existsMoreVideos,\n isLoading,\n translations,\n locale,\n onVideoSelect,\n onShowMore,\n}: Props) => {\n return (\n <StyledVideoResultWrapper>\n {!videos.length && !isLoading ? (\n <Text>{translations.noResults}</Text>\n ) : (\n <StyledList>\n {videos.map((video, index) => (\n <VideoListItem\n key={`${video.id}-${index}`}\n video={video}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n />\n ))}\n </StyledList>\n )}\n {!!isLoading && <Spinner />}\n {!!existsMoreVideos && <Button onClick={onShowMore}>{translations.loadMoreVideos}</Button>}\n </StyledVideoResultWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,aAAa,OAAO,MAAM,EAC9B,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,WAAW;CACX,OAAO;CACR,EACF,CAAC;AAEF,MAAM,2BAA2B,OAAO,OAAO,EAC7C,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,YAAY;CACb,EACF,CAAC;AAYF,MAAa,mBAAmB,EAC9B,QACA,kBACA,WACA,cACA,QACA,eACA,iBACW;AACX,QACE,qBAAC;EACE,CAAC,OAAO,UAAU,CAAC,YAClB,oBAAC,kBAAM,aAAa,YAAiB,GAErC,oBAAC,wBACE,OAAO,KAAK,OAAO,UAClB,oBAAC;GAEQ;GACO;GACN;GACO;KAJV,GAAG,MAAM,GAAG,GAAG,QAKpB,CACF,GACS;EAEd,CAAC,CAAC,aAAa,oBAAC,YAAU;EAC1B,CAAC,CAAC,oBAAoB,oBAAC;GAAO,SAAS;aAAa,aAAa;IAAwB;KACjE"}
1
+ {"version":3,"file":"VideoResultList.mjs","names":[],"sources":["../src/VideoResultList.tsx"],"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 { Text, Button, Spinner } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport type { VideoTranslations } from \"./types\";\nimport { VideoListItem } from \"./VideoListItem\";\n\nconst StyledList = styled(\"ul\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n listStyle: \"none\",\n width: \"100%\",\n },\n});\n\nconst StyledVideoResultWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n alignItems: \"center\",\n },\n});\n\ninterface Props {\n videos: BrightcoveApiType[];\n existsMoreVideos: boolean;\n isLoading: boolean;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n onShowMore: () => void;\n}\n\nexport const VideoResultList = ({\n videos,\n existsMoreVideos,\n isLoading,\n translations,\n locale,\n onVideoSelect,\n onShowMore,\n}: Props) => {\n return (\n <StyledVideoResultWrapper>\n {!videos.length && !isLoading ? (\n <Text>{translations.noResults}</Text>\n ) : (\n <StyledList>\n {videos.map((video, index) => (\n <VideoListItem\n key={`${video.id}-${index}`}\n video={video}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n />\n ))}\n </StyledList>\n )}\n {!!isLoading && <Spinner />}\n {!!existsMoreVideos && <Button onClick={onShowMore}>{translations.loadMoreVideos}</Button>}\n </StyledVideoResultWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAM,aAAa,OAAO,MAAM,EAC9B,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,WAAW;CACX,OAAO;CACR,EACF,CAAC;AAEF,MAAM,2BAA2B,OAAO,OAAO,EAC7C,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,YAAY;CACb,EACF,CAAC;AAYF,MAAa,mBAAmB,EAC9B,QACA,kBACA,WACA,cACA,QACA,eACA,iBACW;AACX,QACE,qBAAC,0BAAD,EAAA,UAAA;EACG,CAAC,OAAO,UAAU,CAAC,YAClB,oBAAC,MAAD,EAAA,UAAO,aAAa,WAAiB,CAAA,GAErC,oBAAC,YAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,oBAAC,eAAD;GAES;GACO;GACN;GACO;GACf,EALK,GAAG,MAAM,GAAG,GAAG,QAKpB,CACF,EACS,CAAA;EAEd,CAAC,CAAC,aAAa,oBAAC,SAAD,EAAW,CAAA;EAC1B,CAAC,CAAC,oBAAoB,oBAAC,QAAD;GAAQ,SAAS;aAAa,aAAa;GAAwB,CAAA;EACjE,EAAA,CAAA"}
@@ -4,7 +4,6 @@ import { IconButton, Input } from "@ndla/primitives";
4
4
  import { styled } from "@ndla/styled-system/jsx";
5
5
  import { useCallback, useEffect, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
-
8
7
  //#region src/VideoSearch.tsx
9
8
  /**
10
9
  * Copyright (c) 2017-present, NDLA.
@@ -91,7 +90,7 @@ const VideoSearch = ({ onVideoSelect, searchVideos, onError, translations, local
91
90
  existsMoreVideos: videos.length === offset + VIDEO_FETCH_LIMIT
92
91
  })] });
93
92
  };
94
-
95
93
  //#endregion
96
94
  export { VideoSearch };
95
+
97
96
  //# sourceMappingURL=VideoSearch.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"VideoSearch.mjs","names":[],"sources":["../src/VideoSearch.tsx"],"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 { SearchLine } from \"@ndla/icons\";\nimport { IconButton, Input } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { type ChangeEvent, useCallback, useEffect, useState, type KeyboardEvent } from \"react\";\nimport { VideoResultList } from \"./VideoResultList\";\n\nexport interface 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}\n\ninterface Props {\n onVideoSelect: (video: BrightcoveApiType) => void;\n searchVideos: (query: VideoQueryType) => Promise<BrightcoveApiType[]>;\n onError: (e: unknown) => void;\n translations: VideoTranslations;\n locale: string;\n}\n\nexport interface VideoQueryType {\n query: string;\n offset: number;\n limit: number;\n}\n\nconst VideoSearchWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n },\n});\n\nconst InputWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"xsmall\",\n },\n});\n\nconst VIDEO_FETCH_LIMIT = 10;\n\nexport const VideoSearch = ({ onVideoSelect, searchVideos, onError, translations, locale }: Props) => {\n const [query, setQuery] = useState(\"\");\n const [offset, setOffset] = useState(0);\n const [videos, setVideos] = useState<BrightcoveApiType[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n\n const fetchVideos = useCallback(\n async (query: string, offset: number, isAppending?: boolean) => {\n setIsLoading(true);\n try {\n const results = await searchVideos({\n query,\n offset: offset,\n limit: VIDEO_FETCH_LIMIT,\n });\n setVideos((prev) => (isAppending ? prev.concat(results) : results));\n } catch (e) {\n onError(e);\n }\n setIsLoading(false);\n },\n [searchVideos, onError],\n );\n\n useEffect(() => {\n fetchVideos(\"\", 0);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const onSearch = useCallback(() => {\n setOffset(0);\n fetchVideos(query, 0);\n }, [fetchVideos, query]);\n\n const onShowMore = useCallback(() => {\n const newOffset = offset + VIDEO_FETCH_LIMIT;\n setOffset(newOffset);\n fetchVideos(query, newOffset, true);\n }, [fetchVideos, offset, query]);\n\n const onQueryChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {\n setQuery(e.target.value);\n }, []);\n\n const onEnter = (e: KeyboardEvent<HTMLInputElement | HTMLButtonElement>) => {\n if (e.key === \"Enter\") {\n onSearch();\n }\n };\n\n return (\n <VideoSearchWrapper>\n <InputWrapper role=\"search\">\n <Input\n type=\"search\"\n placeholder={translations.searchPlaceholder}\n value={query}\n onChange={onQueryChange}\n onKeyDown={onEnter}\n />\n <IconButton\n variant=\"primary\"\n type=\"submit\"\n aria-label={translations.searchButtonTitle}\n title={translations.searchButtonTitle}\n onKeyDown={onEnter}\n onClick={onSearch}\n >\n <SearchLine />\n </IconButton>\n </InputWrapper>\n <VideoResultList\n videos={videos}\n isLoading={isLoading}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n onShowMore={onShowMore}\n existsMoreVideos={videos.length === offset + VIDEO_FETCH_LIMIT}\n />\n </VideoSearchWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,qBAAqB,OAAO,OAAO,EACvC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACN,EACF,CAAC;AAEF,MAAM,eAAe,OAAO,OAAO,EACjC,MAAM;CACJ,SAAS;CACT,KAAK;CACN,EACF,CAAC;AAEF,MAAM,oBAAoB;AAE1B,MAAa,eAAe,EAAE,eAAe,cAAc,SAAS,cAAc,aAAoB;CACpG,MAAM,CAAC,OAAO,YAAY,SAAS,GAAG;CACtC,MAAM,CAAC,QAAQ,aAAa,SAAS,EAAE;CACvC,MAAM,CAAC,QAAQ,aAAa,SAA8B,EAAE,CAAC;CAC7D,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CAEjD,MAAM,cAAc,YAClB,OAAO,OAAe,QAAgB,gBAA0B;AAC9D,eAAa,KAAK;AAClB,MAAI;GACF,MAAM,UAAU,MAAM,aAAa;IACjC;IACQ;IACR,OAAO;IACR,CAAC;AACF,cAAW,SAAU,cAAc,KAAK,OAAO,QAAQ,GAAG,QAAS;WAC5D,GAAG;AACV,WAAQ,EAAE;;AAEZ,eAAa,MAAM;IAErB,CAAC,cAAc,QAAQ,CACxB;AAED,iBAAgB;AACd,cAAY,IAAI,EAAE;IAEjB,EAAE,CAAC;CAEN,MAAM,WAAW,kBAAkB;AACjC,YAAU,EAAE;AACZ,cAAY,OAAO,EAAE;IACpB,CAAC,aAAa,MAAM,CAAC;CAExB,MAAM,aAAa,kBAAkB;EACnC,MAAM,YAAY,SAAS;AAC3B,YAAU,UAAU;AACpB,cAAY,OAAO,WAAW,KAAK;IAClC;EAAC;EAAa;EAAQ;EAAM,CAAC;CAEhC,MAAM,gBAAgB,aAAa,MAAqC;AACtE,WAAS,EAAE,OAAO,MAAM;IACvB,EAAE,CAAC;CAEN,MAAM,WAAW,MAA2D;AAC1E,MAAI,EAAE,QAAQ,QACZ,WAAU;;AAId,QACE,qBAAC,iCACC,qBAAC;EAAa,MAAK;aACjB,oBAAC;GACC,MAAK;GACL,aAAa,aAAa;GAC1B,OAAO;GACP,UAAU;GACV,WAAW;IACX,EACF,oBAAC;GACC,SAAQ;GACR,MAAK;GACL,cAAY,aAAa;GACzB,OAAO,aAAa;GACpB,WAAW;GACX,SAAS;aAET,oBAAC,eAAa;IACH;GACA,EACf,oBAAC;EACS;EACG;EACG;EACN;EACO;EACH;EACZ,kBAAkB,OAAO,WAAW,SAAS;GAC7C,IACiB"}
1
+ {"version":3,"file":"VideoSearch.mjs","names":[],"sources":["../src/VideoSearch.tsx"],"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 { SearchLine } from \"@ndla/icons\";\nimport { IconButton, Input } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { type ChangeEvent, useCallback, useEffect, useState, type KeyboardEvent } from \"react\";\nimport type { VideoTranslations } from \"./types\";\nimport { VideoResultList } from \"./VideoResultList\";\n\ninterface Props {\n onVideoSelect: (video: BrightcoveApiType) => void;\n searchVideos: (query: VideoQueryType) => Promise<BrightcoveApiType[]>;\n onError: (e: unknown) => void;\n translations: VideoTranslations;\n locale: string;\n}\n\nexport interface VideoQueryType {\n query: string;\n offset: number;\n limit: number;\n}\n\nconst VideoSearchWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n },\n});\n\nconst InputWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"xsmall\",\n },\n});\n\nconst VIDEO_FETCH_LIMIT = 10;\n\nexport const VideoSearch = ({ onVideoSelect, searchVideos, onError, translations, locale }: Props) => {\n const [query, setQuery] = useState(\"\");\n const [offset, setOffset] = useState(0);\n const [videos, setVideos] = useState<BrightcoveApiType[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n\n const fetchVideos = useCallback(\n async (query: string, offset: number, isAppending?: boolean) => {\n setIsLoading(true);\n try {\n const results = await searchVideos({\n query,\n offset: offset,\n limit: VIDEO_FETCH_LIMIT,\n });\n setVideos((prev) => (isAppending ? prev.concat(results) : results));\n } catch (e) {\n onError(e);\n }\n setIsLoading(false);\n },\n [searchVideos, onError],\n );\n\n useEffect(() => {\n fetchVideos(\"\", 0);\n // oxlint-disable-next-line react/exhaustive-deps\n }, []);\n\n const onSearch = useCallback(() => {\n setOffset(0);\n fetchVideos(query, 0);\n }, [fetchVideos, query]);\n\n const onShowMore = useCallback(() => {\n const newOffset = offset + VIDEO_FETCH_LIMIT;\n setOffset(newOffset);\n fetchVideos(query, newOffset, true);\n }, [fetchVideos, offset, query]);\n\n const onQueryChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {\n setQuery(e.target.value);\n }, []);\n\n const onEnter = (e: KeyboardEvent<HTMLInputElement | HTMLButtonElement>) => {\n if (e.key === \"Enter\") {\n onSearch();\n }\n };\n\n return (\n <VideoSearchWrapper>\n <InputWrapper role=\"search\">\n <Input\n type=\"search\"\n placeholder={translations.searchPlaceholder}\n value={query}\n onChange={onQueryChange}\n onKeyDown={onEnter}\n />\n <IconButton\n variant=\"primary\"\n type=\"submit\"\n aria-label={translations.searchButtonTitle}\n title={translations.searchButtonTitle}\n onKeyDown={onEnter}\n onClick={onSearch}\n >\n <SearchLine />\n </IconButton>\n </InputWrapper>\n <VideoResultList\n videos={videos}\n isLoading={isLoading}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n onShowMore={onShowMore}\n existsMoreVideos={videos.length === offset + VIDEO_FETCH_LIMIT}\n />\n </VideoSearchWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,qBAAqB,OAAO,OAAO,EACvC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACN,EACF,CAAC;AAEF,MAAM,eAAe,OAAO,OAAO,EACjC,MAAM;CACJ,SAAS;CACT,KAAK;CACN,EACF,CAAC;AAEF,MAAM,oBAAoB;AAE1B,MAAa,eAAe,EAAE,eAAe,cAAc,SAAS,cAAc,aAAoB;CACpG,MAAM,CAAC,OAAO,YAAY,SAAS,GAAG;CACtC,MAAM,CAAC,QAAQ,aAAa,SAAS,EAAE;CACvC,MAAM,CAAC,QAAQ,aAAa,SAA8B,EAAE,CAAC;CAC7D,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CAEjD,MAAM,cAAc,YAClB,OAAO,OAAe,QAAgB,gBAA0B;AAC9D,eAAa,KAAK;AAClB,MAAI;GACF,MAAM,UAAU,MAAM,aAAa;IACjC;IACQ;IACR,OAAO;IACR,CAAC;AACF,cAAW,SAAU,cAAc,KAAK,OAAO,QAAQ,GAAG,QAAS;WAC5D,GAAG;AACV,WAAQ,EAAE;;AAEZ,eAAa,MAAM;IAErB,CAAC,cAAc,QAAQ,CACxB;AAED,iBAAgB;AACd,cAAY,IAAI,EAAE;IAEjB,EAAE,CAAC;CAEN,MAAM,WAAW,kBAAkB;AACjC,YAAU,EAAE;AACZ,cAAY,OAAO,EAAE;IACpB,CAAC,aAAa,MAAM,CAAC;CAExB,MAAM,aAAa,kBAAkB;EACnC,MAAM,YAAY,SAAS;AAC3B,YAAU,UAAU;AACpB,cAAY,OAAO,WAAW,KAAK;IAClC;EAAC;EAAa;EAAQ;EAAM,CAAC;CAEhC,MAAM,gBAAgB,aAAa,MAAqC;AACtE,WAAS,EAAE,OAAO,MAAM;IACvB,EAAE,CAAC;CAEN,MAAM,WAAW,MAA2D;AAC1E,MAAI,EAAE,QAAQ,QACZ,WAAU;;AAId,QACE,qBAAC,oBAAD,EAAA,UAAA,CACE,qBAAC,cAAD;EAAc,MAAK;YAAnB,CACE,oBAAC,OAAD;GACE,MAAK;GACL,aAAa,aAAa;GAC1B,OAAO;GACP,UAAU;GACV,WAAW;GACX,CAAA,EACF,oBAAC,YAAD;GACE,SAAQ;GACR,MAAK;GACL,cAAY,aAAa;GACzB,OAAO,aAAa;GACpB,WAAW;GACX,SAAS;aAET,oBAAC,YAAD,EAAc,CAAA;GACH,CAAA,CACA;KACf,oBAAC,iBAAD;EACU;EACG;EACG;EACN;EACO;EACH;EACZ,kBAAkB,OAAO,WAAW,SAAS;EAC7C,CAAA,CACiB,EAAA,CAAA"}
package/es/index.mjs CHANGED
@@ -1,3 +1,2 @@
1
1
  import { VideoSearch } from "./VideoSearch.mjs";
2
-
3
- export { VideoSearch };
2
+ export { VideoSearch };
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import type { BrightcoveApiType } from "@ndla/types-embed";
9
- import type { VideoTranslations } from "./VideoSearch";
9
+ import type { VideoTranslations } from "./types";
10
10
  interface VideoListItemProps {
11
11
  video: BrightcoveApiType;
12
12
  translations: VideoTranslations;
@@ -4,7 +4,6 @@ let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
4
4
  let react = require("react");
5
5
  let _ndla_licenses = require("@ndla/licenses");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
-
8
7
  //#region src/VideoListItem.tsx
9
8
  /**
10
9
  * Copyright (c) 2024-present, NDLA.
@@ -113,7 +112,7 @@ const VideoListItem = ({ video, onVideoSelect, translations, locale }) => {
113
112
  ]
114
113
  })] });
115
114
  };
116
-
117
115
  //#endregion
118
116
  exports.VideoListItem = VideoListItem;
117
+
119
118
  //# sourceMappingURL=VideoListItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VideoListItem.js","names":["Image","ListItemContent","IconButton","ListItemRoot","Text","PanoramaPhotosphere","Button","CloseLine"],"sources":["../src/VideoListItem.tsx"],"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 { CloseLine, PanoramaPhotosphere } from \"@ndla/icons\";\nimport { getLicenseByNBTitle, type LicenseLocaleType } from \"@ndla/licenses\";\nimport { Image, Text, ListItemContent, ListItemRoot, Button, IconButton } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { useState } from \"react\";\nimport type { VideoTranslations } from \"./VideoSearch\";\n\nconst ButtonWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"small\",\n },\n});\n\nconst PreviewIframe = styled(\"iframe\", {\n base: {\n minHeight: \"surface.xxsmall\",\n },\n});\n\nconst PreviewWrapper = styled(\"div\", {\n base: {\n display: \"grid\",\n gap: \"xsmall\",\n gridTemplateColumns: \"repeat(3,1fr)\",\n padding: \"small\",\n borderBlockEnd: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledImage = styled(Image, {\n base: {\n minWidth: \"surface.xxsmall\",\n height: \"surface.4xsmall\",\n objectFit: \"cover\",\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledVideoMeta = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n },\n});\nconst StyledListItemContent = styled(ListItemContent, {\n base: {\n alignItems: \"flex-end\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n marginLeft: \"auto\",\n },\n});\n\nconst StyledListItemRoot = styled(ListItemRoot, {\n base: {\n paddingBlock: \"medium\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\ninterface LicenseProps {\n license: LicenseLocaleType | string;\n}\nconst License = ({ license }: LicenseProps) => {\n if (typeof license === \"string\") return <Text>{license}</Text>;\n if (license.url?.length) {\n return (\n <a href={license.url} rel=\"license\">\n {license.abbreviation}\n </a>\n );\n }\n return <Text>{license.abbreviation}</Text>;\n};\n\ninterface VideoListItemProps {\n video: BrightcoveApiType;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n}\n\nexport const VideoListItem = ({ video, onVideoSelect, translations, locale }: VideoListItemProps) => {\n const [isPreviewing, setIsPreviewing] = useState(false);\n const license = video.custom_fields?.license ? getLicenseByNBTitle(video.custom_fields.license, locale) : \"\";\n\n return (\n <li>\n <StyledListItemRoot nonInteractive>\n <StyledImage src={video.images?.thumbnail?.src} alt=\"\" variant=\"rounded\" />\n <StyledListItemContent>\n <StyledVideoMeta>\n <Text textStyle=\"title.medium\">\n {video.name}\n {video.projection === \"equirectangular\" && (\n <PanoramaPhotosphere\n aria-hidden={false}\n aria-label={translations.is360Video}\n title={translations.is360Video}\n />\n )}\n </Text>\n <Text>{video.custom_fields?.licenseinfo ?? \"\"}</Text>\n <License license={license} />\n </StyledVideoMeta>\n <ButtonWrapper>\n <Button\n variant=\"secondary\"\n size=\"small\"\n onClick={() => setIsPreviewing((p) => !p)}\n aria-expanded={isPreviewing}\n aria-controls={`video-preview-${video.id}`}\n >\n {translations.previewVideo}\n </Button>\n <Button size=\"small\" onClick={() => onVideoSelect(video)}>\n {translations.addVideo}\n </Button>\n </ButtonWrapper>\n </StyledListItemContent>\n </StyledListItemRoot>\n {!!isPreviewing && (\n <PreviewWrapper id={`video-preview-${video.id}`}>\n <div />\n <PreviewIframe\n title={video.name}\n src={`//players.brightcove.net/${video.account_id}/BkLm8fT_default/index.html?videoId=${video.id}`}\n allowFullScreen\n />\n <StyledIconButton\n variant=\"secondary\"\n aria-label={translations.close}\n title={translations.close}\n onClick={() => setIsPreviewing(false)}\n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AE1G,QACE,4CAAC,mBACC,4CAAC;EAAmB;aAClB,2CAAC;GAAY,KAAK,MAAM,QAAQ,WAAW;GAAK,KAAI;GAAG,SAAQ;IAAY,EAC3E,4CAAC,oCACC,4CAAC;GACC,4CAACA;IAAK,WAAU;eACb,MAAM,MACN,MAAM,eAAe,qBACpB,2CAACC;KACC,eAAa;KACb,cAAY,aAAa;KACzB,OAAO,aAAa;MACpB;KAEC;GACP,2CAACD,mCAAM,MAAM,eAAe,eAAe,KAAU;GACrD,2CAAC,WAAiB,UAAW;MACb,EAClB,4CAAC,4BACC,2CAACE;GACC,SAAQ;GACR,MAAK;GACL,eAAe,iBAAiB,MAAM,CAAC,EAAE;GACzC,iBAAe;GACf,iBAAe,iBAAiB,MAAM;aAErC,aAAa;IACP,EACT,2CAACA;GAAO,MAAK;GAAQ,eAAe,cAAc,MAAM;aACrD,aAAa;IACP,IACK,IACM;GACL,EACpB,CAAC,CAAC,gBACD,4CAAC;EAAe,IAAI,iBAAiB,MAAM;;GACzC,2CAAC,UAAM;GACP,2CAAC;IACC,OAAO,MAAM;IACb,KAAK,4BAA4B,MAAM,WAAW,sCAAsC,MAAM;IAC9F;KACA;GACF,2CAAC;IACC,SAAQ;IACR,cAAY,aAAa;IACzB,OAAO,aAAa;IACpB,eAAe,gBAAgB,MAAM;cAErC,2CAACC,0BAAY;KACI;;GACJ,IAEhB"}
1
+ {"version":3,"file":"VideoListItem.js","names":["Image","ListItemContent","IconButton","ListItemRoot","Text","PanoramaPhotosphere","Button","CloseLine"],"sources":["../src/VideoListItem.tsx"],"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 { CloseLine, PanoramaPhotosphere } from \"@ndla/icons\";\nimport { getLicenseByNBTitle, type LicenseLocaleType } from \"@ndla/licenses\";\nimport { Image, Text, ListItemContent, ListItemRoot, Button, IconButton } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { useState } from \"react\";\nimport type { VideoTranslations } from \"./types\";\n\nconst ButtonWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"small\",\n },\n});\n\nconst PreviewIframe = styled(\"iframe\", {\n base: {\n minHeight: \"surface.xxsmall\",\n },\n});\n\nconst PreviewWrapper = styled(\"div\", {\n base: {\n display: \"grid\",\n gap: \"xsmall\",\n gridTemplateColumns: \"repeat(3,1fr)\",\n padding: \"small\",\n borderBlockEnd: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledImage = styled(Image, {\n base: {\n minWidth: \"surface.xxsmall\",\n height: \"surface.4xsmall\",\n objectFit: \"cover\",\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst StyledVideoMeta = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n },\n});\nconst StyledListItemContent = styled(ListItemContent, {\n base: {\n alignItems: \"flex-end\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n marginLeft: \"auto\",\n },\n});\n\nconst StyledListItemRoot = styled(ListItemRoot, {\n base: {\n paddingBlock: \"medium\",\n tabletDown: {\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n },\n },\n});\n\ninterface LicenseProps {\n license: LicenseLocaleType | string;\n}\nconst License = ({ license }: LicenseProps) => {\n if (typeof license === \"string\") return <Text>{license}</Text>;\n if (license.url?.length) {\n return (\n <a href={license.url} rel=\"license\">\n {license.abbreviation}\n </a>\n );\n }\n return <Text>{license.abbreviation}</Text>;\n};\n\ninterface VideoListItemProps {\n video: BrightcoveApiType;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n}\n\nexport const VideoListItem = ({ video, onVideoSelect, translations, locale }: VideoListItemProps) => {\n const [isPreviewing, setIsPreviewing] = useState(false);\n const license = video.custom_fields?.license ? getLicenseByNBTitle(video.custom_fields.license, locale) : \"\";\n\n return (\n <li>\n <StyledListItemRoot nonInteractive>\n <StyledImage src={video.images?.thumbnail?.src} alt=\"\" variant=\"rounded\" />\n <StyledListItemContent>\n <StyledVideoMeta>\n <Text textStyle=\"title.medium\">\n {video.name}\n {video.projection === \"equirectangular\" && (\n <PanoramaPhotosphere\n aria-hidden={false}\n aria-label={translations.is360Video}\n title={translations.is360Video}\n />\n )}\n </Text>\n <Text>{video.custom_fields?.licenseinfo ?? \"\"}</Text>\n <License license={license} />\n </StyledVideoMeta>\n <ButtonWrapper>\n <Button\n variant=\"secondary\"\n size=\"small\"\n onClick={() => setIsPreviewing((p) => !p)}\n aria-expanded={isPreviewing}\n aria-controls={`video-preview-${video.id}`}\n >\n {translations.previewVideo}\n </Button>\n <Button size=\"small\" onClick={() => onVideoSelect(video)}>\n {translations.addVideo}\n </Button>\n </ButtonWrapper>\n </StyledListItemContent>\n </StyledListItemRoot>\n {!!isPreviewing && (\n <PreviewWrapper id={`video-preview-${video.id}`}>\n <div />\n <PreviewIframe\n title={video.name}\n src={`//players.brightcove.net/${video.account_id}/BkLm8fT_default/index.html?videoId=${video.id}`}\n allowFullScreen\n />\n <StyledIconButton\n variant=\"secondary\"\n aria-label={translations.close}\n title={translations.close}\n onClick={() => setIsPreviewing(false)}\n >\n <CloseLine />\n </StyledIconButton>\n </PreviewWrapper>\n )}\n </li>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,iBAAA,GAAA,wBAAA,QAAuB,OAAO,EAClC,MAAM;CACJ,SAAS;CACT,KAAK;CACN,EACF,CAAC;AAEF,MAAM,iBAAA,GAAA,wBAAA,QAAuB,UAAU,EACrC,MAAM,EACJ,WAAW,mBACZ,EACF,CAAC;AAEF,MAAM,kBAAA,GAAA,wBAAA,QAAwB,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,KAAK;CACL,qBAAq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,KAAK,4BAA4B,MAAM,WAAW,sCAAsC,MAAM;IAC9F,iBAAA;IACA,CAAA;GACF,iBAAA,GAAA,kBAAA,KAAC,kBAAD;IACE,SAAQ;IACR,cAAY,aAAa;IACzB,OAAO,aAAa;IACpB,eAAe,gBAAgB,MAAM;cAErC,iBAAA,GAAA,kBAAA,KAACC,YAAAA,WAAD,EAAa,CAAA;IACI,CAAA;GACJ;IAEhB,EAAA,CAAA"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import type { BrightcoveApiType } from "@ndla/types-embed";
9
- import type { VideoTranslations } from "./VideoSearch";
9
+ import type { VideoTranslations } from "./types";
10
10
  interface Props {
11
11
  videos: BrightcoveApiType[];
12
12
  existsMoreVideos: boolean;
@@ -1,8 +1,7 @@
1
- const require_VideoListItem = require('./VideoListItem.js');
1
+ const require_VideoListItem = require("./VideoListItem.js");
2
2
  let _ndla_primitives = require("@ndla/primitives");
3
3
  let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
-
6
5
  //#region src/VideoResultList.tsx
7
6
  /**
8
7
  * Copyright (c) 2017-present, NDLA.
@@ -39,7 +38,7 @@ const VideoResultList = ({ videos, existsMoreVideos, isLoading, translations, lo
39
38
  })
40
39
  ] });
41
40
  };
42
-
43
41
  //#endregion
44
42
  exports.VideoResultList = VideoResultList;
43
+
45
44
  //# sourceMappingURL=VideoResultList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VideoResultList.js","names":["Text","VideoListItem","Spinner","Button"],"sources":["../src/VideoResultList.tsx"],"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 { Text, Button, Spinner } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { VideoListItem } from \"./VideoListItem\";\nimport type { VideoTranslations } from \"./VideoSearch\";\n\nconst StyledList = styled(\"ul\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n listStyle: \"none\",\n width: \"100%\",\n },\n});\n\nconst StyledVideoResultWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n alignItems: \"center\",\n },\n});\n\ninterface Props {\n videos: BrightcoveApiType[];\n existsMoreVideos: boolean;\n isLoading: boolean;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n onShowMore: () => void;\n}\n\nexport const VideoResultList = ({\n videos,\n existsMoreVideos,\n isLoading,\n translations,\n locale,\n onVideoSelect,\n onShowMore,\n}: Props) => {\n return (\n <StyledVideoResultWrapper>\n {!videos.length && !isLoading ? (\n <Text>{translations.noResults}</Text>\n ) : (\n <StyledList>\n {videos.map((video, index) => (\n <VideoListItem\n key={`${video.id}-${index}`}\n video={video}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n />\n ))}\n </StyledList>\n )}\n {!!isLoading && <Spinner />}\n {!!existsMoreVideos && <Button onClick={onShowMore}>{translations.loadMoreVideos}</Button>}\n </StyledVideoResultWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,iDAAoB,MAAM,EAC9B,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,WAAW;CACX,OAAO;CACR,EACF,CAAC;AAEF,MAAM,+DAAkC,OAAO,EAC7C,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,YAAY;CACb,EACF,CAAC;AAYF,MAAa,mBAAmB,EAC9B,QACA,kBACA,WACA,cACA,QACA,eACA,iBACW;AACX,QACE,4CAAC;EACE,CAAC,OAAO,UAAU,CAAC,YAClB,2CAACA,mCAAM,aAAa,YAAiB,GAErC,2CAAC,wBACE,OAAO,KAAK,OAAO,UAClB,2CAACC;GAEQ;GACO;GACN;GACO;KAJV,GAAG,MAAM,GAAG,GAAG,QAKpB,CACF,GACS;EAEd,CAAC,CAAC,aAAa,2CAACC,6BAAU;EAC1B,CAAC,CAAC,oBAAoB,2CAACC;GAAO,SAAS;aAAa,aAAa;IAAwB;KACjE"}
1
+ {"version":3,"file":"VideoResultList.js","names":["Text","VideoListItem","Spinner","Button"],"sources":["../src/VideoResultList.tsx"],"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 { Text, Button, Spinner } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport type { VideoTranslations } from \"./types\";\nimport { VideoListItem } from \"./VideoListItem\";\n\nconst StyledList = styled(\"ul\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xxsmall\",\n listStyle: \"none\",\n width: \"100%\",\n },\n});\n\nconst StyledVideoResultWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n alignItems: \"center\",\n },\n});\n\ninterface Props {\n videos: BrightcoveApiType[];\n existsMoreVideos: boolean;\n isLoading: boolean;\n translations: VideoTranslations;\n locale: string;\n onVideoSelect: (video: BrightcoveApiType) => void;\n onShowMore: () => void;\n}\n\nexport const VideoResultList = ({\n videos,\n existsMoreVideos,\n isLoading,\n translations,\n locale,\n onVideoSelect,\n onShowMore,\n}: Props) => {\n return (\n <StyledVideoResultWrapper>\n {!videos.length && !isLoading ? (\n <Text>{translations.noResults}</Text>\n ) : (\n <StyledList>\n {videos.map((video, index) => (\n <VideoListItem\n key={`${video.id}-${index}`}\n video={video}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n />\n ))}\n </StyledList>\n )}\n {!!isLoading && <Spinner />}\n {!!existsMoreVideos && <Button onClick={onShowMore}>{translations.loadMoreVideos}</Button>}\n </StyledVideoResultWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAM,cAAA,GAAA,wBAAA,QAAoB,MAAM,EAC9B,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,WAAW;CACX,OAAO;CACR,EACF,CAAC;AAEF,MAAM,4BAAA,GAAA,wBAAA,QAAkC,OAAO,EAC7C,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,YAAY;CACb,EACF,CAAC;AAYF,MAAa,mBAAmB,EAC9B,QACA,kBACA,WACA,cACA,QACA,eACA,iBACW;AACX,QACE,iBAAA,GAAA,kBAAA,MAAC,0BAAD,EAAA,UAAA;EACG,CAAC,OAAO,UAAU,CAAC,YAClB,iBAAA,GAAA,kBAAA,KAACA,iBAAAA,MAAD,EAAA,UAAO,aAAa,WAAiB,CAAA,GAErC,iBAAA,GAAA,kBAAA,KAAC,YAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,iBAAA,GAAA,kBAAA,KAACC,sBAAAA,eAAD;GAES;GACO;GACN;GACO;GACf,EALK,GAAG,MAAM,GAAG,GAAG,QAKpB,CACF,EACS,CAAA;EAEd,CAAC,CAAC,aAAa,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,SAAD,EAAW,CAAA;EAC1B,CAAC,CAAC,oBAAoB,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,QAAD;GAAQ,SAAS;aAAa,aAAa;GAAwB,CAAA;EACjE,EAAA,CAAA"}
@@ -6,16 +6,7 @@
6
6
  *
7
7
  */
8
8
  import type { BrightcoveApiType } from "@ndla/types-embed";
9
- export interface VideoTranslations {
10
- searchPlaceholder: string;
11
- searchButtonTitle: string;
12
- loadMoreVideos: string;
13
- noResults: string;
14
- is360Video: string;
15
- previewVideo: string;
16
- addVideo: string;
17
- close: string;
18
- }
9
+ import type { VideoTranslations } from "./types";
19
10
  interface Props {
20
11
  onVideoSelect: (video: BrightcoveApiType) => void;
21
12
  searchVideos: (query: VideoQueryType) => Promise<BrightcoveApiType[]>;
@@ -1,10 +1,9 @@
1
- const require_VideoResultList = require('./VideoResultList.js');
1
+ const require_VideoResultList = require("./VideoResultList.js");
2
2
  let _ndla_icons = require("@ndla/icons");
3
3
  let _ndla_primitives = require("@ndla/primitives");
4
4
  let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
5
5
  let react = require("react");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
-
8
7
  //#region src/VideoSearch.tsx
9
8
  /**
10
9
  * Copyright (c) 2017-present, NDLA.
@@ -91,7 +90,7 @@ const VideoSearch = ({ onVideoSelect, searchVideos, onError, translations, local
91
90
  existsMoreVideos: videos.length === offset + VIDEO_FETCH_LIMIT
92
91
  })] });
93
92
  };
94
-
95
93
  //#endregion
96
94
  exports.VideoSearch = VideoSearch;
95
+
97
96
  //# sourceMappingURL=VideoSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VideoSearch.js","names":["Input","IconButton","SearchLine","VideoResultList"],"sources":["../src/VideoSearch.tsx"],"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 { SearchLine } from \"@ndla/icons\";\nimport { IconButton, Input } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { type ChangeEvent, useCallback, useEffect, useState, type KeyboardEvent } from \"react\";\nimport { VideoResultList } from \"./VideoResultList\";\n\nexport interface 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}\n\ninterface Props {\n onVideoSelect: (video: BrightcoveApiType) => void;\n searchVideos: (query: VideoQueryType) => Promise<BrightcoveApiType[]>;\n onError: (e: unknown) => void;\n translations: VideoTranslations;\n locale: string;\n}\n\nexport interface VideoQueryType {\n query: string;\n offset: number;\n limit: number;\n}\n\nconst VideoSearchWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n },\n});\n\nconst InputWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"xsmall\",\n },\n});\n\nconst VIDEO_FETCH_LIMIT = 10;\n\nexport const VideoSearch = ({ onVideoSelect, searchVideos, onError, translations, locale }: Props) => {\n const [query, setQuery] = useState(\"\");\n const [offset, setOffset] = useState(0);\n const [videos, setVideos] = useState<BrightcoveApiType[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n\n const fetchVideos = useCallback(\n async (query: string, offset: number, isAppending?: boolean) => {\n setIsLoading(true);\n try {\n const results = await searchVideos({\n query,\n offset: offset,\n limit: VIDEO_FETCH_LIMIT,\n });\n setVideos((prev) => (isAppending ? prev.concat(results) : results));\n } catch (e) {\n onError(e);\n }\n setIsLoading(false);\n },\n [searchVideos, onError],\n );\n\n useEffect(() => {\n fetchVideos(\"\", 0);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const onSearch = useCallback(() => {\n setOffset(0);\n fetchVideos(query, 0);\n }, [fetchVideos, query]);\n\n const onShowMore = useCallback(() => {\n const newOffset = offset + VIDEO_FETCH_LIMIT;\n setOffset(newOffset);\n fetchVideos(query, newOffset, true);\n }, [fetchVideos, offset, query]);\n\n const onQueryChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {\n setQuery(e.target.value);\n }, []);\n\n const onEnter = (e: KeyboardEvent<HTMLInputElement | HTMLButtonElement>) => {\n if (e.key === \"Enter\") {\n onSearch();\n }\n };\n\n return (\n <VideoSearchWrapper>\n <InputWrapper role=\"search\">\n <Input\n type=\"search\"\n placeholder={translations.searchPlaceholder}\n value={query}\n onChange={onQueryChange}\n onKeyDown={onEnter}\n />\n <IconButton\n variant=\"primary\"\n type=\"submit\"\n aria-label={translations.searchButtonTitle}\n title={translations.searchButtonTitle}\n onKeyDown={onEnter}\n onClick={onSearch}\n >\n <SearchLine />\n </IconButton>\n </InputWrapper>\n <VideoResultList\n videos={videos}\n isLoading={isLoading}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n onShowMore={onShowMore}\n existsMoreVideos={videos.length === offset + VIDEO_FETCH_LIMIT}\n />\n </VideoSearchWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,yDAA4B,OAAO,EACvC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACN,EACF,CAAC;AAEF,MAAM,mDAAsB,OAAO,EACjC,MAAM;CACJ,SAAS;CACT,KAAK;CACN,EACF,CAAC;AAEF,MAAM,oBAAoB;AAE1B,MAAa,eAAe,EAAE,eAAe,cAAc,SAAS,cAAc,aAAoB;CACpG,MAAM,CAAC,OAAO,gCAAqB,GAAG;CACtC,MAAM,CAAC,QAAQ,iCAAsB,EAAE;CACvC,MAAM,CAAC,QAAQ,iCAA2C,EAAE,CAAC;CAC7D,MAAM,CAAC,WAAW,oCAAyB,MAAM;CAEjD,MAAM,qCACJ,OAAO,OAAe,QAAgB,gBAA0B;AAC9D,eAAa,KAAK;AAClB,MAAI;GACF,MAAM,UAAU,MAAM,aAAa;IACjC;IACQ;IACR,OAAO;IACR,CAAC;AACF,cAAW,SAAU,cAAc,KAAK,OAAO,QAAQ,GAAG,QAAS;WAC5D,GAAG;AACV,WAAQ,EAAE;;AAEZ,eAAa,MAAM;IAErB,CAAC,cAAc,QAAQ,CACxB;AAED,4BAAgB;AACd,cAAY,IAAI,EAAE;IAEjB,EAAE,CAAC;CAEN,MAAM,wCAA6B;AACjC,YAAU,EAAE;AACZ,cAAY,OAAO,EAAE;IACpB,CAAC,aAAa,MAAM,CAAC;CAExB,MAAM,0CAA+B;EACnC,MAAM,YAAY,SAAS;AAC3B,YAAU,UAAU;AACpB,cAAY,OAAO,WAAW,KAAK;IAClC;EAAC;EAAa;EAAQ;EAAM,CAAC;CAEhC,MAAM,wCAA6B,MAAqC;AACtE,WAAS,EAAE,OAAO,MAAM;IACvB,EAAE,CAAC;CAEN,MAAM,WAAW,MAA2D;AAC1E,MAAI,EAAE,QAAQ,QACZ,WAAU;;AAId,QACE,4CAAC,iCACC,4CAAC;EAAa,MAAK;aACjB,2CAACA;GACC,MAAK;GACL,aAAa,aAAa;GAC1B,OAAO;GACP,UAAU;GACV,WAAW;IACX,EACF,2CAACC;GACC,SAAQ;GACR,MAAK;GACL,cAAY,aAAa;GACzB,OAAO,aAAa;GACpB,WAAW;GACX,SAAS;aAET,2CAACC,2BAAa;IACH;GACA,EACf,2CAACC;EACS;EACG;EACG;EACN;EACO;EACH;EACZ,kBAAkB,OAAO,WAAW,SAAS;GAC7C,IACiB"}
1
+ {"version":3,"file":"VideoSearch.js","names":["Input","IconButton","SearchLine","VideoResultList"],"sources":["../src/VideoSearch.tsx"],"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 { SearchLine } from \"@ndla/icons\";\nimport { IconButton, Input } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveApiType } from \"@ndla/types-embed\";\nimport { type ChangeEvent, useCallback, useEffect, useState, type KeyboardEvent } from \"react\";\nimport type { VideoTranslations } from \"./types\";\nimport { VideoResultList } from \"./VideoResultList\";\n\ninterface Props {\n onVideoSelect: (video: BrightcoveApiType) => void;\n searchVideos: (query: VideoQueryType) => Promise<BrightcoveApiType[]>;\n onError: (e: unknown) => void;\n translations: VideoTranslations;\n locale: string;\n}\n\nexport interface VideoQueryType {\n query: string;\n offset: number;\n limit: number;\n}\n\nconst VideoSearchWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n },\n});\n\nconst InputWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"xsmall\",\n },\n});\n\nconst VIDEO_FETCH_LIMIT = 10;\n\nexport const VideoSearch = ({ onVideoSelect, searchVideos, onError, translations, locale }: Props) => {\n const [query, setQuery] = useState(\"\");\n const [offset, setOffset] = useState(0);\n const [videos, setVideos] = useState<BrightcoveApiType[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n\n const fetchVideos = useCallback(\n async (query: string, offset: number, isAppending?: boolean) => {\n setIsLoading(true);\n try {\n const results = await searchVideos({\n query,\n offset: offset,\n limit: VIDEO_FETCH_LIMIT,\n });\n setVideos((prev) => (isAppending ? prev.concat(results) : results));\n } catch (e) {\n onError(e);\n }\n setIsLoading(false);\n },\n [searchVideos, onError],\n );\n\n useEffect(() => {\n fetchVideos(\"\", 0);\n // oxlint-disable-next-line react/exhaustive-deps\n }, []);\n\n const onSearch = useCallback(() => {\n setOffset(0);\n fetchVideos(query, 0);\n }, [fetchVideos, query]);\n\n const onShowMore = useCallback(() => {\n const newOffset = offset + VIDEO_FETCH_LIMIT;\n setOffset(newOffset);\n fetchVideos(query, newOffset, true);\n }, [fetchVideos, offset, query]);\n\n const onQueryChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {\n setQuery(e.target.value);\n }, []);\n\n const onEnter = (e: KeyboardEvent<HTMLInputElement | HTMLButtonElement>) => {\n if (e.key === \"Enter\") {\n onSearch();\n }\n };\n\n return (\n <VideoSearchWrapper>\n <InputWrapper role=\"search\">\n <Input\n type=\"search\"\n placeholder={translations.searchPlaceholder}\n value={query}\n onChange={onQueryChange}\n onKeyDown={onEnter}\n />\n <IconButton\n variant=\"primary\"\n type=\"submit\"\n aria-label={translations.searchButtonTitle}\n title={translations.searchButtonTitle}\n onKeyDown={onEnter}\n onClick={onSearch}\n >\n <SearchLine />\n </IconButton>\n </InputWrapper>\n <VideoResultList\n videos={videos}\n isLoading={isLoading}\n translations={translations}\n locale={locale}\n onVideoSelect={onVideoSelect}\n onShowMore={onShowMore}\n existsMoreVideos={videos.length === offset + VIDEO_FETCH_LIMIT}\n />\n </VideoSearchWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,sBAAA,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AW,MAA2D;AAC1E,MAAI,EAAE,QAAQ,QACZ,WAAU;;AAId,QACE,iBAAA,GAAA,kBAAA,MAAC,oBAAD,EAAA,UAAA,CACE,iBAAA,GAAA,kBAAA,MAAC,cAAD;EAAc,MAAK;YAAnB,CACE,iBAAA,GAAA,kBAAA,KAACA,iBAAAA,OAAD;GACE,MAAK;GACL,aAAa,aAAa;GAC1B,OAAO;GACP,UAAU;GACV,WAAW;GACX,CAAA,EACF,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,YAAD;GACE,SAAQ;GACR,MAAK;GACL,cAAY,aAAa;GACzB,OAAO,aAAa;GACpB,WAAW;GACX,SAAS;aAET,iBAAA,GAAA,kBAAA,KAACC,YAAAA,YAAD,EAAc,CAAA;GACH,CAAA,CACA;KACf,iBAAA,GAAA,kBAAA,KAACC,wBAAAA,iBAAD;EACU;EACG;EACG;EACN;EACO;EACH;EACZ,kBAAkB,OAAO,WAAW,SAAS;EAC7C,CAAA,CACiB,EAAA,CAAA"}
package/lib/index.js CHANGED
@@ -1,4 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_VideoSearch = require('./VideoSearch.js');
3
-
4
- exports.VideoSearch = require_VideoSearch.VideoSearch;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_VideoSearch = require("./VideoSearch.js");
3
+ exports.VideoSearch = require_VideoSearch.VideoSearch;
package/lib/types.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2026-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export interface VideoTranslations {
9
+ searchPlaceholder: string;
10
+ searchButtonTitle: string;
11
+ loadMoreVideos: string;
12
+ noResults: string;
13
+ is360Video: string;
14
+ previewVideo: string;
15
+ addVideo: string;
16
+ close: string;
17
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ndla/video-search",
3
3
  "type": "module",
4
- "version": "8.0.148-alpha.0",
4
+ "version": "8.0.150-alpha.0",
5
5
  "description": "A simple library for searching NDLA videos",
6
6
  "license": "GPL-3.0",
7
7
  "exports": {
@@ -30,9 +30,9 @@
30
30
  "es"
31
31
  ],
32
32
  "dependencies": {
33
- "@ndla/icons": "^8.0.86-alpha.0",
33
+ "@ndla/icons": "^8.0.87-alpha.0",
34
34
  "@ndla/licenses": "^10.0.11-alpha.0",
35
- "@ndla/primitives": "^1.0.124-alpha.0",
35
+ "@ndla/primitives": "^1.0.125-alpha.0",
36
36
  "@ndla/styled-system": "^0.0.47"
37
37
  },
38
38
  "devDependencies": {
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "fe541cbce620512c29a43e1f87f5fc2c2822766b"
50
+ "gitHead": "9e92080763987460f8009550db77bfd2b9709fe3"
51
51
  }