@ndla/ui 56.0.192-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/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/AudioPlayer/AudioProgress.mjs.map +1 -1
- package/es/AudioPlayer/Controls.mjs +1 -1
- package/es/AudioPlayer/Controls.mjs.map +1 -1
- package/es/AudioPlayer/VolumeSlider.mjs.map +1 -1
- package/es/AudioPlayer/useAudioControls.mjs.map +1 -1
- package/es/Embed/ConceptEmbed.mjs +1 -1
- package/es/Embed/ConceptEmbed.mjs.map +1 -1
- package/es/Embed/EmbedWrapper.mjs +1 -1
- package/es/Embed/EmbedWrapper.mjs.map +1 -1
- package/es/Embed/GlossEmbed.mjs +1 -1
- package/es/Embed/GlossEmbed.mjs.map +1 -1
- package/es/Embed/UuDisclaimerEmbed.mjs +50 -15
- package/es/Embed/UuDisclaimerEmbed.mjs.map +1 -1
- package/es/FileList/FileList.mjs +1 -1
- package/es/FileList/FileList.mjs.map +1 -1
- package/es/Gloss/Gloss.mjs +1 -1
- package/es/Gloss/Gloss.mjs.map +1 -1
- package/es/TagSelector/TagSelector.mjs +3 -8
- package/es/TagSelector/TagSelector.mjs.map +1 -1
- package/es/i18n/useComponentTranslations.mjs +3 -3
- package/es/i18n/useComponentTranslations.mjs.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/AudioPlayer/AudioProgress.d.ts +1 -1
- package/lib/AudioPlayer/AudioProgress.js.map +1 -1
- package/lib/AudioPlayer/Controls.js +2 -2
- package/lib/AudioPlayer/Controls.js.map +1 -1
- package/lib/AudioPlayer/VolumeSlider.d.ts +1 -1
- package/lib/AudioPlayer/VolumeSlider.js.map +1 -1
- package/lib/AudioPlayer/useAudioControls.d.ts +1 -1
- package/lib/AudioPlayer/useAudioControls.js.map +1 -1
- package/lib/Embed/ConceptEmbed.js +2 -2
- package/lib/Embed/ConceptEmbed.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/GlossEmbed.js +2 -2
- package/lib/Embed/GlossEmbed.js.map +1 -1
- package/lib/Embed/UuDisclaimerEmbed.js +49 -14
- package/lib/Embed/UuDisclaimerEmbed.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/Gloss/Gloss.d.ts +2 -2
- package/lib/Gloss/Gloss.js +2 -2
- package/lib/Gloss/Gloss.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/i18n/useComponentTranslations.d.ts +1 -1
- package/lib/i18n/useComponentTranslations.js +3 -3
- package/lib/i18n/useComponentTranslations.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/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 +31 -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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type HTMLArkProps } from "@ark-ui/react";
|
|
8
|
+
import { type HTMLArkProps } from "@ark-ui/react/factory";
|
|
9
9
|
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
10
10
|
declare const embedWrapperRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
11
11
|
noClear: {
|
|
@@ -2,8 +2,8 @@ require("../_virtual/_rolldown/runtime.js");
|
|
|
2
2
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
-
let _ark_ui_react = require("@ark-ui/react");
|
|
6
5
|
let _ndla_styled_system_css = require("@ndla/styled-system/css");
|
|
6
|
+
let _ark_ui_react_factory = require("@ark-ui/react/factory");
|
|
7
7
|
//#region src/Embed/EmbedWrapper.tsx
|
|
8
8
|
/**
|
|
9
9
|
* Copyright (c) 2024-present, NDLA.
|
|
@@ -20,7 +20,7 @@ const embedWrapperRecipe = (0, _ndla_styled_system_css.cva)({
|
|
|
20
20
|
false: { clear: "both" }
|
|
21
21
|
} }
|
|
22
22
|
});
|
|
23
|
-
const StyledEmbedWrapper = (0, _ndla_styled_system_jsx.styled)(
|
|
23
|
+
const StyledEmbedWrapper = (0, _ndla_styled_system_jsx.styled)(_ark_ui_react_factory.ark.div, {}, { baseComponent: true });
|
|
24
24
|
const EmbedWrapper = (0, react.forwardRef)(({ noClear, css: cssProp, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledEmbedWrapper, {
|
|
25
25
|
css: _ndla_styled_system_css.css.raw(embedWrapperRecipe.raw({ noClear }), cssProp),
|
|
26
26
|
"data-embed-wrapper": "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbedWrapper.js","names":["ark","css"],"sources":["../../src/Embed/EmbedWrapper.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 { ark, type HTMLArkProps } from \"@ark-ui/react\";\nimport { css, cva } from \"@ndla/styled-system/css\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledProps, RecipeVariantProps } from \"@ndla/styled-system/types\";\nimport { forwardRef } from \"react\";\n\nconst embedWrapperRecipe = cva({\n base: {\n position: \"relative\",\n },\n defaultVariants: {\n noClear: false,\n },\n variants: {\n noClear: {\n true: {\n \"& + [data-embed-wrapper]\": {\n clear: \"both\",\n },\n },\n false: {\n clear: \"both\",\n },\n },\n },\n});\n\nexport type EmbedWrapperVariantProps = NonNullable<RecipeVariantProps<typeof embedWrapperRecipe>>;\n\nexport interface EmbedWrapperProps extends HTMLArkProps<\"div\">, StyledProps, EmbedWrapperVariantProps {}\n\nconst StyledEmbedWrapper = styled(ark.div, {}, { baseComponent: true });\n\nexport const EmbedWrapper = forwardRef<HTMLDivElement, EmbedWrapperProps>(\n ({ noClear, css: cssProp, ...props }, ref) => (\n <StyledEmbedWrapper\n css={css.raw(embedWrapperRecipe.raw({ noClear }), cssProp)}\n data-embed-wrapper=\"\"\n {...props}\n ref={ref}\n />\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,sBAAA,GAAA,wBAAA,KAAyB;CAC7B,MAAM,EACJ,UAAU,WACZ;CACA,iBAAiB,EACf,SAAS,MACX;CACA,UAAU,EACR,SAAS;EACP,MAAM,EACJ,4BAA4B,EAC1B,OAAO,OACT,EACF;EACA,OAAO,EACL,OAAO,OACT;CACF,EACF;AACF,CAAC;AAMD,MAAM,sBAAA,GAAA,wBAAA,QAA4BA,
|
|
1
|
+
{"version":3,"file":"EmbedWrapper.js","names":["ark","css"],"sources":["../../src/Embed/EmbedWrapper.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 { ark, type HTMLArkProps } from \"@ark-ui/react/factory\";\nimport { css, cva } from \"@ndla/styled-system/css\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledProps, RecipeVariantProps } from \"@ndla/styled-system/types\";\nimport { forwardRef } from \"react\";\n\nconst embedWrapperRecipe = cva({\n base: {\n position: \"relative\",\n },\n defaultVariants: {\n noClear: false,\n },\n variants: {\n noClear: {\n true: {\n \"& + [data-embed-wrapper]\": {\n clear: \"both\",\n },\n },\n false: {\n clear: \"both\",\n },\n },\n },\n});\n\nexport type EmbedWrapperVariantProps = NonNullable<RecipeVariantProps<typeof embedWrapperRecipe>>;\n\nexport interface EmbedWrapperProps extends HTMLArkProps<\"div\">, StyledProps, EmbedWrapperVariantProps {}\n\nconst StyledEmbedWrapper = styled(ark.div, {}, { baseComponent: true });\n\nexport const EmbedWrapper = forwardRef<HTMLDivElement, EmbedWrapperProps>(\n ({ noClear, css: cssProp, ...props }, ref) => (\n <StyledEmbedWrapper\n css={css.raw(embedWrapperRecipe.raw({ noClear }), cssProp)}\n data-embed-wrapper=\"\"\n {...props}\n ref={ref}\n />\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,sBAAA,GAAA,wBAAA,KAAyB;CAC7B,MAAM,EACJ,UAAU,WACZ;CACA,iBAAiB,EACf,SAAS,MACX;CACA,UAAU,EACR,SAAS;EACP,MAAM,EACJ,4BAA4B,EAC1B,OAAO,OACT,EACF;EACA,OAAO,EACL,OAAO,OACT;CACF,EACF;AACF,CAAC;AAMD,MAAM,sBAAA,GAAA,wBAAA,QAA4BA,sBAAAA,IAAI,KAAK,CAAC,GAAG,EAAE,eAAe,KAAK,CAAC;AAEtE,MAAa,gBAAA,GAAA,MAAA,aACV,EAAE,SAAS,KAAK,SAAS,GAAG,SAAS,QACpC,iBAAA,GAAA,kBAAA,KAAC,oBAAD;CACE,KAAKC,wBAAAA,IAAI,IAAI,mBAAmB,IAAI,EAAE,QAAQ,CAAC,GAAG,OAAO;CACzD,sBAAmB;CACnB,GAAI;CACC;AACN,CAAA,CAEL"}
|
package/lib/Embed/GlossEmbed.js
CHANGED
|
@@ -6,7 +6,7 @@ let _ndla_primitives = require("@ndla/primitives");
|
|
|
6
6
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
-
let
|
|
9
|
+
let _ark_ui_react_portal = require("@ark-ui/react/portal");
|
|
10
10
|
//#region src/Embed/GlossEmbed.tsx
|
|
11
11
|
/**
|
|
12
12
|
* Copyright (c) 2024-present, NDLA.
|
|
@@ -30,7 +30,7 @@ const GlossEmbed = ({ embed, children }) => {
|
|
|
30
30
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_primitives.PopoverTrigger, {
|
|
31
31
|
asChild: true,
|
|
32
32
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ConceptInlineTriggerButton.ConceptInlineTriggerButton, { children })
|
|
33
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ark_ui_react_portal.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledPopoverContent, {
|
|
34
34
|
ref: contentRef,
|
|
35
35
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_primitives.Figure, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Gloss.Gloss, {
|
|
36
36
|
glossData: concept.glossData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlossEmbed.js","names":["PopoverContent","EmbedErrorPlaceholder","PopoverRoot","PopoverTrigger","ConceptInlineTriggerButton","Portal","Figure","Gloss"],"sources":["../../src/Embed/GlossEmbed.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 { Portal } from \"@ark-ui/react\";\nimport { Figure, PopoverContent, PopoverRoot, PopoverTrigger } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { ConceptMetaData } from \"@ndla/types-embed\";\nimport { useRef, type ReactNode } from \"react\";\nimport { Gloss } from \"../Gloss/Gloss\";\nimport { ConceptInlineTriggerButton } from \"./ConceptInlineTriggerButton\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: ConceptMetaData;\n children?: ReactNode;\n}\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n width: \"surface.xlarge\",\n },\n});\n\nexport const GlossEmbed = ({ embed, children }: Props) => {\n const contentRef = useRef<HTMLDivElement>(null);\n if (embed.status === \"error\" && embed.embedData.type === \"inline\") {\n return <span>{children}</span>;\n }\n if (embed.status === \"error\" || !embed.data.concept.glossData) {\n return <EmbedErrorPlaceholder type=\"gloss\" />;\n }\n\n const { concept, visualElement } = embed.data;\n\n const audio =\n visualElement?.status === \"success\" && visualElement.resource === \"audio\"\n ? {\n src: visualElement.data.audioFile.url,\n title: visualElement.data.title.title,\n }\n : undefined;\n\n if (embed.embedData.type === \"inline\") {\n return (\n <PopoverRoot initialFocusEl={() => contentRef.current}>\n <PopoverTrigger asChild>\n <ConceptInlineTriggerButton>{children}</ConceptInlineTriggerButton>\n </PopoverTrigger>\n <Portal>\n <StyledPopoverContent ref={contentRef}>\n <Figure>\n <Gloss\n glossData={concept.glossData}\n title={concept.title}\n audio={audio}\n exampleIds={embed.embedData.exampleIds}\n exampleLangs={embed.embedData.exampleLangs}\n />\n </Figure>\n </StyledPopoverContent>\n </Portal>\n </PopoverRoot>\n );\n }\n\n return (\n <Figure data-embed-type=\"gloss\">\n <Gloss\n glossData={concept.glossData}\n title={concept.title}\n audio={audio}\n exampleIds={embed.embedData.exampleIds}\n exampleLangs={embed.embedData.exampleLangs}\n variant=\"bordered\"\n />\n </Figure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,MAAM,wBAAA,GAAA,wBAAA,QAA8BA,iBAAAA,gBAAgB,EAClD,MAAM,EACJ,OAAO,iBACT,EACF,CAAC;AAED,MAAa,cAAc,EAAE,OAAO,eAAsB;CACxD,MAAM,cAAA,GAAA,MAAA,QAAoC,IAAI;CAC9C,IAAI,MAAM,WAAW,WAAW,MAAM,UAAU,SAAS,UACvD,OAAO,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAO,SAAe,CAAA;CAE/B,IAAI,MAAM,WAAW,WAAW,CAAC,MAAM,KAAK,QAAQ,WAClD,OAAO,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,uBAAD,EAAuB,MAAK,QAAS,CAAA;CAG9C,MAAM,EAAE,SAAS,kBAAkB,MAAM;CAEzC,MAAM,QACJ,eAAe,WAAW,aAAa,cAAc,aAAa,UAC9D;EACE,KAAK,cAAc,KAAK,UAAU;EAClC,OAAO,cAAc,KAAK,MAAM;CAClC,IACA,KAAA;CAEN,IAAI,MAAM,UAAU,SAAS,UAC3B,OACE,iBAAA,GAAA,kBAAA,MAACC,iBAAAA,aAAD;EAAa,sBAAsB,WAAW;YAA9C,CACE,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,gBAAD;GAAgB,SAAA;aACd,iBAAA,GAAA,kBAAA,KAACC,mCAAAA,4BAAD,EAA6B,SAAqC,CAAA;EACpD,CAAA,GAChB,iBAAA,GAAA,kBAAA,KAACC,
|
|
1
|
+
{"version":3,"file":"GlossEmbed.js","names":["PopoverContent","EmbedErrorPlaceholder","PopoverRoot","PopoverTrigger","ConceptInlineTriggerButton","Portal","Figure","Gloss"],"sources":["../../src/Embed/GlossEmbed.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 { Portal } from \"@ark-ui/react/portal\";\nimport { Figure, PopoverContent, PopoverRoot, PopoverTrigger } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { ConceptMetaData } from \"@ndla/types-embed\";\nimport { useRef, type ReactNode } from \"react\";\nimport { Gloss } from \"../Gloss/Gloss\";\nimport { ConceptInlineTriggerButton } from \"./ConceptInlineTriggerButton\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: ConceptMetaData;\n children?: ReactNode;\n}\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n width: \"surface.xlarge\",\n },\n});\n\nexport const GlossEmbed = ({ embed, children }: Props) => {\n const contentRef = useRef<HTMLDivElement>(null);\n if (embed.status === \"error\" && embed.embedData.type === \"inline\") {\n return <span>{children}</span>;\n }\n if (embed.status === \"error\" || !embed.data.concept.glossData) {\n return <EmbedErrorPlaceholder type=\"gloss\" />;\n }\n\n const { concept, visualElement } = embed.data;\n\n const audio =\n visualElement?.status === \"success\" && visualElement.resource === \"audio\"\n ? {\n src: visualElement.data.audioFile.url,\n title: visualElement.data.title.title,\n }\n : undefined;\n\n if (embed.embedData.type === \"inline\") {\n return (\n <PopoverRoot initialFocusEl={() => contentRef.current}>\n <PopoverTrigger asChild>\n <ConceptInlineTriggerButton>{children}</ConceptInlineTriggerButton>\n </PopoverTrigger>\n <Portal>\n <StyledPopoverContent ref={contentRef}>\n <Figure>\n <Gloss\n glossData={concept.glossData}\n title={concept.title}\n audio={audio}\n exampleIds={embed.embedData.exampleIds}\n exampleLangs={embed.embedData.exampleLangs}\n />\n </Figure>\n </StyledPopoverContent>\n </Portal>\n </PopoverRoot>\n );\n }\n\n return (\n <Figure data-embed-type=\"gloss\">\n <Gloss\n glossData={concept.glossData}\n title={concept.title}\n audio={audio}\n exampleIds={embed.embedData.exampleIds}\n exampleLangs={embed.embedData.exampleLangs}\n variant=\"bordered\"\n />\n </Figure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,MAAM,wBAAA,GAAA,wBAAA,QAA8BA,iBAAAA,gBAAgB,EAClD,MAAM,EACJ,OAAO,iBACT,EACF,CAAC;AAED,MAAa,cAAc,EAAE,OAAO,eAAsB;CACxD,MAAM,cAAA,GAAA,MAAA,QAAoC,IAAI;CAC9C,IAAI,MAAM,WAAW,WAAW,MAAM,UAAU,SAAS,UACvD,OAAO,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAO,SAAe,CAAA;CAE/B,IAAI,MAAM,WAAW,WAAW,CAAC,MAAM,KAAK,QAAQ,WAClD,OAAO,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,uBAAD,EAAuB,MAAK,QAAS,CAAA;CAG9C,MAAM,EAAE,SAAS,kBAAkB,MAAM;CAEzC,MAAM,QACJ,eAAe,WAAW,aAAa,cAAc,aAAa,UAC9D;EACE,KAAK,cAAc,KAAK,UAAU;EAClC,OAAO,cAAc,KAAK,MAAM;CAClC,IACA,KAAA;CAEN,IAAI,MAAM,UAAU,SAAS,UAC3B,OACE,iBAAA,GAAA,kBAAA,MAACC,iBAAAA,aAAD;EAAa,sBAAsB,WAAW;YAA9C,CACE,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,gBAAD;GAAgB,SAAA;aACd,iBAAA,GAAA,kBAAA,KAACC,mCAAAA,4BAAD,EAA6B,SAAqC,CAAA;EACpD,CAAA,GAChB,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,QAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,sBAAD;GAAsB,KAAK;aACzB,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,QAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;IACE,WAAW,QAAQ;IACnB,OAAO,QAAQ;IACR;IACP,YAAY,MAAM,UAAU;IAC5B,cAAc,MAAM,UAAU;GAC/B,CAAA,EACK,CAAA;EACY,CAAA,EAChB,CAAA,CACG;;CAIjB,OACE,iBAAA,GAAA,kBAAA,KAACD,iBAAAA,QAAD;EAAQ,mBAAgB;YACtB,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;GACE,WAAW,QAAQ;GACnB,OAAO,QAAQ;GACR;GACP,YAAY,MAAM,UAAU;GAC5B,cAAc,MAAM,UAAU;GAC9B,SAAQ;EACT,CAAA;CACK,CAAA;AAEZ"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
require("../_virtual/_rolldown/runtime.js");
|
|
2
2
|
let _ndla_primitives = require("@ndla/primitives");
|
|
3
3
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
4
|
-
require("react");
|
|
4
|
+
let react = require("react");
|
|
5
5
|
let react_i18next = require("react-i18next");
|
|
6
6
|
let _ndla_icons = require("@ndla/icons");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
-
let
|
|
8
|
+
let _ndla_styled_system_patterns = require("@ndla/styled-system/patterns");
|
|
9
|
+
let _ark_ui_react_portal = require("@ark-ui/react/portal");
|
|
9
10
|
//#region src/Embed/UuDisclaimerEmbed.tsx
|
|
10
11
|
/**
|
|
11
12
|
* Copyright (c) 2024-present, NDLA.
|
|
@@ -26,12 +27,28 @@ const StyledErrorWarningFill = (0, _ndla_styled_system_jsx.styled)(_ndla_icons.E
|
|
|
26
27
|
fill: "icon.subtle"
|
|
27
28
|
} });
|
|
28
29
|
const StyledPopoverContent = (0, _ndla_styled_system_jsx.styled)(_ndla_primitives.PopoverContent, { base: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
flexDirection: "column",
|
|
32
|
+
gap: "xsmall",
|
|
29
33
|
width: "surface.xlarge",
|
|
30
34
|
maxHeight: "50vh",
|
|
31
35
|
overflowY: "auto"
|
|
32
36
|
} });
|
|
37
|
+
const HiddenButton = (0, _ndla_styled_system_jsx.styled)(_ndla_primitives.Button, { base: { "&:not(:focus)": {
|
|
38
|
+
position: "absolute",
|
|
39
|
+
width: "1px",
|
|
40
|
+
height: "1px",
|
|
41
|
+
padding: "0",
|
|
42
|
+
margin: "-1px",
|
|
43
|
+
overflow: "hidden",
|
|
44
|
+
clip: "rect(0,0,0,0)",
|
|
45
|
+
whiteSpace: "nowrap",
|
|
46
|
+
borderWidth: "0"
|
|
47
|
+
} } });
|
|
33
48
|
const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }) => {
|
|
34
49
|
const { t } = (0, react_i18next.useTranslation)();
|
|
50
|
+
const skipRef = (0, react.useRef)(null);
|
|
51
|
+
const contentRef = (0, react.useRef)(null);
|
|
35
52
|
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DisclaimerWrapper, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledErrorWarningFill, {
|
|
36
53
|
"aria-label": t("embed.embedError", { type: t("embed.type.disclaimer") }),
|
|
37
54
|
title: t("embed.embedError", { type: t("embed.type.disclaimer") })
|
|
@@ -39,19 +56,37 @@ const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }) => {
|
|
|
39
56
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DisclaimerWrapper, {
|
|
40
57
|
role: "region",
|
|
41
58
|
"data-embed-type": "uu-disclaimer",
|
|
42
|
-
children: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_ndla_primitives.PopoverRoot, {
|
|
61
|
+
initialFocusEl: () => contentRef.current,
|
|
62
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_primitives.PopoverTrigger, {
|
|
63
|
+
asChild: true,
|
|
64
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledIconButton, {
|
|
65
|
+
size: "small",
|
|
66
|
+
variant: "secondary",
|
|
67
|
+
"aria-label": t("uuDisclaimer.title"),
|
|
68
|
+
title: t("uuDisclaimer.title"),
|
|
69
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_icons.AccessibilityFill, {})
|
|
70
|
+
})
|
|
71
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ark_ui_react_portal.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledPopoverContent, {
|
|
72
|
+
ref: contentRef,
|
|
73
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: transformedDisclaimer }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HiddenButton, {
|
|
74
|
+
onClick: () => skipRef.current?.focus(),
|
|
75
|
+
children: t("uuDisclaimer.skipContent")
|
|
76
|
+
})]
|
|
77
|
+
}) })]
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
80
|
+
"data-uu-content": "",
|
|
81
|
+
children
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
84
|
+
className: (0, _ndla_styled_system_patterns.visuallyHidden)(),
|
|
85
|
+
tabIndex: -1,
|
|
86
|
+
ref: skipRef,
|
|
87
|
+
children: t("uuDisclaimer.contentCompleted")
|
|
50
88
|
})
|
|
51
|
-
|
|
52
|
-
"data-uu-content": "",
|
|
53
|
-
children
|
|
54
|
-
})]
|
|
89
|
+
]
|
|
55
90
|
});
|
|
56
91
|
};
|
|
57
92
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UuDisclaimerEmbed.js","names":["IconButton","ErrorWarningFill","PopoverContent","PopoverRoot","PopoverTrigger","AccessibilityFill","Portal"],"sources":["../../src/Embed/UuDisclaimerEmbed.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 { Portal } from \"@ark-ui/react\";\nimport { AccessibilityFill, ErrorWarningFill } from \"@ndla/icons\";\nimport { IconButton, PopoverContent, PopoverRoot, PopoverTrigger } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { UuDisclaimerMetaData } from \"@ndla/types-embed\";\nimport { type ReactNode } from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\ninterface Props {\n embed: UuDisclaimerMetaData;\n transformedDisclaimer: ReactNode;\n children?: ReactNode;\n}\n\nconst DisclaimerWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"3xsmall\",\n clear: \"both\",\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n alignSelf: \"flex-end\",\n },\n});\n\nconst StyledErrorWarningFill = styled(ErrorWarningFill, {\n base: {\n alignSelf: \"flex-end\",\n fill: \"icon.subtle\",\n },\n});\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n width: \"surface.xlarge\",\n maxHeight: \"50vh\",\n overflowY: \"auto\",\n },\n});\n\nexport const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }: Props) => {\n const { t } = useTranslation();\n if (embed.status === \"error\") {\n return (\n <DisclaimerWrapper>\n <StyledErrorWarningFill\n aria-label={t(\"embed.embedError\", { type: t(\"embed.type.disclaimer\") })}\n title={t(\"embed.embedError\", { type: t(\"embed.type.disclaimer\") })}\n />\n {children}\n </DisclaimerWrapper>\n );\n }\n\n return (\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n <DisclaimerWrapper role=\"region\" data-embed-type=\"uu-disclaimer\">\n <PopoverRoot>\n <PopoverTrigger asChild>\n <StyledIconButton\n size=\"small\"\n variant=\"secondary\"\n aria-label={t(\"uuDisclaimer.title\")}\n title={t(\"uuDisclaimer.title\")}\n >\n <AccessibilityFill />\n </StyledIconButton>\n </PopoverTrigger>\n <Portal>\n <StyledPopoverContent>\n <div>{transformedDisclaimer}</div>\n </StyledPopoverContent>\n </Portal>\n </PopoverRoot>\n <div data-uu-content=\"\">{children}</div>\n </DisclaimerWrapper>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UuDisclaimerEmbed.js","names":["IconButton","ErrorWarningFill","PopoverContent","Button","PopoverRoot","PopoverTrigger","AccessibilityFill","Portal"],"sources":["../../src/Embed/UuDisclaimerEmbed.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 { Portal } from \"@ark-ui/react/portal\";\nimport { AccessibilityFill, ErrorWarningFill } from \"@ndla/icons\";\nimport { Button, IconButton, PopoverContent, PopoverRoot, PopoverTrigger } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { visuallyHidden } from \"@ndla/styled-system/patterns\";\nimport type { UuDisclaimerMetaData } from \"@ndla/types-embed\";\nimport { useRef, type ReactNode } from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\ninterface Props {\n embed: UuDisclaimerMetaData;\n transformedDisclaimer: ReactNode;\n children?: ReactNode;\n}\n\nconst DisclaimerWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"3xsmall\",\n clear: \"both\",\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n alignSelf: \"flex-end\",\n },\n});\n\nconst StyledErrorWarningFill = styled(ErrorWarningFill, {\n base: {\n alignSelf: \"flex-end\",\n fill: \"icon.subtle\",\n },\n});\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n width: \"surface.xlarge\",\n maxHeight: \"50vh\",\n overflowY: \"auto\",\n },\n});\n\nconst HiddenButton = styled(Button, {\n base: {\n \"&:not(:focus)\": {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n margin: \"-1px\",\n overflow: \"hidden\",\n clip: \"rect(0,0,0,0)\",\n whiteSpace: \"nowrap\",\n borderWidth: \"0\",\n },\n },\n});\n\nexport const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }: Props) => {\n const { t } = useTranslation();\n const skipRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n if (embed.status === \"error\") {\n return (\n <DisclaimerWrapper>\n <StyledErrorWarningFill\n aria-label={t(\"embed.embedError\", { type: t(\"embed.type.disclaimer\") })}\n title={t(\"embed.embedError\", { type: t(\"embed.type.disclaimer\") })}\n />\n {children}\n </DisclaimerWrapper>\n );\n }\n\n return (\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n <DisclaimerWrapper role=\"region\" data-embed-type=\"uu-disclaimer\">\n <PopoverRoot initialFocusEl={() => contentRef.current}>\n <PopoverTrigger asChild>\n <StyledIconButton\n size=\"small\"\n variant=\"secondary\"\n aria-label={t(\"uuDisclaimer.title\")}\n title={t(\"uuDisclaimer.title\")}\n >\n <AccessibilityFill />\n </StyledIconButton>\n </PopoverTrigger>\n <Portal>\n <StyledPopoverContent ref={contentRef}>\n <div>{transformedDisclaimer}</div>\n <HiddenButton onClick={() => skipRef.current?.focus()}>{t(\"uuDisclaimer.skipContent\")}</HiddenButton>\n </StyledPopoverContent>\n </Portal>\n </PopoverRoot>\n <div data-uu-content=\"\">{children}</div>\n <div className={visuallyHidden()} tabIndex={-1} ref={skipRef}>\n {t(\"uuDisclaimer.contentCompleted\")}\n </div>\n </DisclaimerWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAM,qBAAA,GAAA,wBAAA,QAA2B,OAAO,EACtC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,OAAO;AACT,EACF,CAAC;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A;eACd,iBAAA,GAAA,kBAAA,KAAC,kBAAD;MACE,MAAK;MACL,SAAQ;MACR,cAAY,EAAE,oBAAoB;MAClC,OAAO,EAAE,oBAAoB;gBAE7B,iBAAA,GAAA,kBAAA,KAACC,YAAAA,mBAAD,CAAoB,CAAA;KACJ,CAAA;IACJ,CAAA,GAChB,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,QAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,MAAC,sBAAD;KAAsB,KAAK;eAA3B,CACE,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAA,UAAM,sBAA2B,CAAA,GACjC,iBAAA,GAAA,kBAAA,KAAC,cAAD;MAAc,eAAe,QAAQ,SAAS,MAAM;gBAAI,EAAE,0BAA0B;KAAgB,CAAA,CAChF;OAChB,CAAA,CACG;;GACb,iBAAA,GAAA,kBAAA,KAAC,OAAD;IAAK,mBAAgB;IAAI;GAAc,CAAA;GACvC,iBAAA,GAAA,kBAAA,KAAC,OAAD;IAAK,YAAA,GAAA,6BAAA,gBAA0B;IAAG,UAAU;IAAI,KAAK;cAClD,EAAE,+BAA+B;GAC/B,CAAA;EACY;;AAEvB"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { type ComponentPropsWithoutRef } from "react";
|
|
9
9
|
interface Props extends ComponentPropsWithoutRef<"ul"> {
|
|
10
10
|
}
|
|
11
|
-
export declare const FileListWrapper: import("@ndla/styled-system/types").StyledComponent<import("react").ForwardRefExoticComponent<import("react").ClassAttributes<HTMLUListElement> & import("react").HTMLAttributes<HTMLUListElement> & import("@ark-ui/react").PolymorphicProps>, {}>;
|
|
12
|
-
export declare const FileListItem: import("@ndla/styled-system/types").StyledComponent<import("react").ForwardRefExoticComponent<import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement> & import("@ark-ui/react").PolymorphicProps>, {}>;
|
|
11
|
+
export declare const FileListWrapper: import("@ndla/styled-system/types").StyledComponent<import("react").ForwardRefExoticComponent<import("react").ClassAttributes<HTMLUListElement> & import("react").HTMLAttributes<HTMLUListElement> & import("@ark-ui/react/factory").PolymorphicProps>, {}>;
|
|
12
|
+
export declare const FileListItem: import("@ndla/styled-system/types").StyledComponent<import("react").ForwardRefExoticComponent<import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement> & import("@ark-ui/react/factory").PolymorphicProps>, {}>;
|
|
13
13
|
export declare const FileListEmbed: ({ children, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export {};
|
package/lib/FileList/FileList.js
CHANGED
|
@@ -2,7 +2,7 @@ require("../_virtual/_rolldown/runtime.js");
|
|
|
2
2
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
3
3
|
require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
-
let
|
|
5
|
+
let _ark_ui_react_factory = require("@ark-ui/react/factory");
|
|
6
6
|
//#region src/FileList/FileList.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Copyright (c) 2023-present, NDLA.
|
|
@@ -11,13 +11,13 @@ let _ark_ui_react = require("@ark-ui/react");
|
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
|
-
const FileListWrapper = (0, _ndla_styled_system_jsx.styled)(
|
|
14
|
+
const FileListWrapper = (0, _ndla_styled_system_jsx.styled)(_ark_ui_react_factory.ark.ul, { base: {
|
|
15
15
|
display: "flex",
|
|
16
16
|
flexDirection: "column",
|
|
17
17
|
gap: "xsmall",
|
|
18
18
|
clear: "both"
|
|
19
19
|
} }, { baseComponent: true });
|
|
20
|
-
const FileListItem = (0, _ndla_styled_system_jsx.styled)(
|
|
20
|
+
const FileListItem = (0, _ndla_styled_system_jsx.styled)(_ark_ui_react_factory.ark.li, { base: {
|
|
21
21
|
listStyle: "none",
|
|
22
22
|
background: "surface.infoSubtle",
|
|
23
23
|
borderBlockEnd: "1px solid",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileList.js","names":["ark"],"sources":["../../src/FileList/FileList.tsx"],"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\nimport { ark } from \"@ark-ui/react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ComponentPropsWithoutRef } from \"react\";\n\ninterface Props extends ComponentPropsWithoutRef<\"ul\"> {}\n\nexport const FileListWrapper = styled(\n ark.ul,\n {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n clear: \"both\",\n },\n },\n { baseComponent: true },\n);\n\nexport const FileListItem = styled(\n ark.li,\n {\n base: {\n listStyle: \"none\",\n background: \"surface.infoSubtle\",\n borderBlockEnd: \"1px solid\",\n borderColor: \"stroke.default\",\n display: \"flex\",\n justifyContent: \"space-between\",\n\n _hover: {\n backgroundColor: \"surface.infoSubtle.hover\",\n },\n },\n },\n { baseComponent: true },\n);\n\nexport const FileListEmbed = ({ children, ...rest }: Props) => {\n return (\n <FileListWrapper {...rest} data-embed-type=\"file-list\">\n {children}\n </FileListWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,mBAAA,GAAA,wBAAA,QACXA,
|
|
1
|
+
{"version":3,"file":"FileList.js","names":["ark"],"sources":["../../src/FileList/FileList.tsx"],"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\nimport { ark } from \"@ark-ui/react/factory\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ComponentPropsWithoutRef } from \"react\";\n\ninterface Props extends ComponentPropsWithoutRef<\"ul\"> {}\n\nexport const FileListWrapper = styled(\n ark.ul,\n {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n clear: \"both\",\n },\n },\n { baseComponent: true },\n);\n\nexport const FileListItem = styled(\n ark.li,\n {\n base: {\n listStyle: \"none\",\n background: \"surface.infoSubtle\",\n borderBlockEnd: \"1px solid\",\n borderColor: \"stroke.default\",\n display: \"flex\",\n justifyContent: \"space-between\",\n\n _hover: {\n backgroundColor: \"surface.infoSubtle.hover\",\n },\n },\n },\n { baseComponent: true },\n);\n\nexport const FileListEmbed = ({ children, ...rest }: Props) => {\n return (\n <FileListWrapper {...rest} data-embed-type=\"file-list\">\n {children}\n </FileListWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,mBAAA,GAAA,wBAAA,QACXA,sBAAAA,IAAI,IACJ,EACE,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,OAAO;AACT,EACF,GACA,EAAE,eAAe,KAAK,CACxB;AAEA,MAAa,gBAAA,GAAA,wBAAA,QACXA,sBAAAA,IAAI,IACJ,EACE,MAAM;CACJ,WAAW;CACX,YAAY;CACZ,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,gBAAgB;CAEhB,QAAQ,EACN,iBAAiB,2BACnB;AACF,EACF,GACA,EAAE,eAAe,KAAK,CACxB;AAEA,MAAa,iBAAiB,EAAE,UAAU,GAAG,WAAkB;CAC7D,OACE,iBAAA,GAAA,kBAAA,KAAC,iBAAD;EAAiB,GAAI;EAAM,mBAAgB;EACxC;CACc,CAAA;AAErB"}
|
package/lib/Gloss/Gloss.d.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { StyledVariantProps } from "@ndla/styled-system/types";
|
|
9
9
|
import type { ConceptTitleDTO, GlossDataDTO } from "@ndla/types-backend/concept-api";
|
|
10
|
-
declare const StyledAccordionItem: import("@ndla/styled-system/types").StyledComponent<import("react").ComponentClass<import("@ndla/styled-system/types").JsxHTMLProps<import("@ark-ui/react").AccordionItemProps & import("react").RefAttributes<HTMLDivElement> & import("@ndla/styled-system/jsx").UnstyledProps & import("@ndla/styled-system/types").AsProps, import("@ndla/styled-system/types").JsxStyleProps>, any>, {
|
|
10
|
+
declare const StyledAccordionItem: import("@ndla/styled-system/types").StyledComponent<import("react").ComponentClass<import("@ndla/styled-system/types").JsxHTMLProps<import("@ark-ui/react/accordion").AccordionItemProps & import("react").RefAttributes<HTMLDivElement> & import("@ndla/styled-system/jsx").UnstyledProps & import("@ndla/styled-system/types").AsProps, import("@ndla/styled-system/types").JsxStyleProps>, any>, {
|
|
11
11
|
variant?: "simple" | "bordered" | undefined;
|
|
12
|
-
}> | import("@ndla/styled-system/types").StyledComponent<import("react").FunctionComponent<import("@ndla/styled-system/types").JsxHTMLProps<import("@ark-ui/react").AccordionItemProps & import("react").RefAttributes<HTMLDivElement> & import("@ndla/styled-system/jsx").UnstyledProps & import("@ndla/styled-system/types").AsProps, import("@ndla/styled-system/types").JsxStyleProps>>, {
|
|
12
|
+
}> | import("@ndla/styled-system/types").StyledComponent<import("react").FunctionComponent<import("@ndla/styled-system/types").JsxHTMLProps<import("@ark-ui/react/accordion").AccordionItemProps & import("react").RefAttributes<HTMLDivElement> & import("@ndla/styled-system/jsx").UnstyledProps & import("@ndla/styled-system/types").AsProps, import("@ndla/styled-system/types").JsxStyleProps>>, {
|
|
13
13
|
variant?: "simple" | "bordered" | undefined;
|
|
14
14
|
}>;
|
|
15
15
|
type GlossVariantProps = StyledVariantProps<typeof StyledAccordionItem>;
|
package/lib/Gloss/Gloss.js
CHANGED
|
@@ -9,7 +9,7 @@ html_react_parser = require_runtime.__toESM(html_react_parser);
|
|
|
9
9
|
let react_i18next = require("react-i18next");
|
|
10
10
|
let _ndla_icons = require("@ndla/icons");
|
|
11
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
-
let
|
|
12
|
+
let _ark_ui_react_accordion = require("@ark-ui/react/accordion");
|
|
13
13
|
//#region src/Gloss/Gloss.tsx
|
|
14
14
|
/**
|
|
15
15
|
* Copyright (c) 2023-present, NDLA.
|
|
@@ -122,7 +122,7 @@ const Gloss = ({ title, glossData, audio, exampleIds, exampleLangs, variant }) =
|
|
|
122
122
|
lang: title.language,
|
|
123
123
|
children: parsedTitle
|
|
124
124
|
})
|
|
125
|
-
}), !!filteredExamples.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
125
|
+
}), !!filteredExamples.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ark_ui_react_accordion.AccordionItemTrigger, {
|
|
126
126
|
asChild: true,
|
|
127
127
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_primitives.IconButton, {
|
|
128
128
|
variant: "tertiary",
|
package/lib/Gloss/Gloss.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gloss.js","names":["AccordionItemContent","AccordionItem","AccordionRoot","Text","SpeechControl","AccordionItemTrigger","IconButton","AccordionItemIndicator","ArrowDownShortLine","GlossExample"],"sources":["../../src/Gloss/Gloss.tsx"],"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\nimport { AccordionItemTrigger } from \"@ark-ui/react\";\nimport { ArrowDownShortLine } from \"@ndla/icons\";\nimport {\n AccordionItem,\n AccordionItemContent,\n AccordionItemIndicator,\n AccordionRoot,\n IconButton,\n Text,\n} from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledVariantProps } from \"@ndla/styled-system/types\";\nimport type { ConceptTitleDTO, GlossDataDTO, GlossExampleDTO } from \"@ndla/types-backend/concept-api\";\nimport parse from \"html-react-parser\";\nimport { useMemo } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { SpeechControl } from \"../AudioPlayer/SpeechControl\";\nimport { GlossExample } from \"./GlossExample\";\n\n// TODO: Figure out padding between bordered and simple variant.\n// The design says that the content above the accordion content should have enough padding to align with the accordion content.\n// When a gloss is bordered there's way too much padding.\n\nconst getFilteredExamples = (\n glossData: GlossDataDTO | undefined,\n exampleIds: string | undefined,\n exampleLangs: string | undefined,\n): GlossExampleDTO[][] => {\n if (exampleIds !== undefined || exampleLangs !== undefined) {\n const exampleIdsList = exampleIds?.toString()?.split(\",\") ?? [];\n const exampleLangsList = exampleLangs?.split(\",\") ?? [];\n\n const filteredExamples =\n glossData?.examples?.map((examples, i) => {\n if (exampleIdsList.includes(i.toString())) {\n return examples.filter((e) => exampleLangsList.includes(e.language));\n }\n return [];\n }) ?? [];\n const examplesWithoutEmpty = filteredExamples.filter((el) => !!el.length);\n return examplesWithoutEmpty;\n }\n return glossData?.examples ?? [];\n};\n\nconst Container = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n});\n\nconst TextWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"small\",\n },\n});\n\nconst StyledAccordionItemContent = styled(AccordionItemContent, {\n base: {\n paddingInline: \"0\",\n },\n});\n\nconst StyledContainer = styled(Container, {\n base: {\n marginBlockStart: \"3xsmall\",\n },\n});\n\nconst StyledAccordionItem = styled(AccordionItem, {\n base: {\n paddingBlock: \"small\",\n paddingInline: \"medium\",\n },\n defaultVariants: {\n variant: \"simple\",\n },\n variants: {\n variant: {\n simple: {},\n bordered: {\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n },\n },\n },\n});\n\ntype GlossVariantProps = StyledVariantProps<typeof StyledAccordionItem>;\n\nexport interface Props {\n title: ConceptTitleDTO;\n glossData?: GlossDataDTO;\n audio?: {\n title: string;\n src?: string;\n };\n exampleIds?: string;\n exampleLangs?: string;\n}\n\nexport const Gloss = ({ title, glossData, audio, exampleIds, exampleLangs, variant }: Props & GlossVariantProps) => {\n const { t } = useTranslation();\n\n const parsedTitle = useMemo(() => parse(title.htmlTitle), [title.htmlTitle]);\n\n const filteredExamples = useMemo(\n () => getFilteredExamples(glossData, exampleIds, exampleLangs),\n [exampleIds, exampleLangs, glossData],\n );\n\n if (!glossData) return null;\n\n return (\n <AccordionRoot multiple variant=\"clean\">\n <StyledAccordionItem value=\"gloss\" variant={variant}>\n <Container>\n <TextWrapper>\n <Text textStyle=\"label.medium\" fontWeight=\"bold\" asChild consumeCss lang={glossData.originalLanguage}>\n <span>{glossData.gloss}</span>\n </Text>\n {!!glossData.transcriptions.traditional && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span\n key={t(\"gloss.transcriptions.traditional\")}\n aria-label={t(\"gloss.transcriptions.traditional\")}\n lang={glossData.originalLanguage}\n >\n {glossData.transcriptions.traditional}\n </span>\n </Text>\n )}\n {!!glossData.transcriptions.pinyin && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span\n data-pinyin=\"\"\n key={t(\"gloss.transcriptions.pinyin\")}\n aria-label={t(\"gloss.transcriptions.pinyin\")}\n lang={glossData.originalLanguage}\n >\n {glossData.transcriptions.pinyin}\n </span>\n </Text>\n )}\n {!!glossData.wordClass && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span aria-label={t(\"gloss.wordClass\")}>\n {glossData.wordClass.map((wc) => t(`wordClass.${wc}`).toLowerCase()).join(\" / \")}\n </span>\n </Text>\n )}\n </TextWrapper>\n {!!audio?.src && <SpeechControl src={audio.src} title={audio.title} />}\n </Container>\n <StyledContainer>\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span lang={title.language}>{parsedTitle}</span>\n </Text>\n {!!filteredExamples.length && (\n <AccordionItemTrigger asChild>\n <IconButton variant=\"tertiary\" aria-label={t(\"gloss.showExamples\")} title={t(\"gloss.showExamples\")}>\n <AccordionItemIndicator asChild>\n <ArrowDownShortLine size=\"medium\" />\n </AccordionItemIndicator>\n </IconButton>\n </AccordionItemTrigger>\n )}\n </StyledContainer>\n <StyledAccordionItemContent>\n {filteredExamples.map((examples, index) => (\n <GlossExample\n key={`gloss-example-${index}`}\n examples={examples}\n originalLanguage={glossData.originalLanguage}\n />\n ))}\n </StyledAccordionItemContent>\n </StyledAccordionIt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KhC;KACF,CAAA;KAEP,CAAC,CAAC,UAAU,aACX,iBAAA,GAAA,kBAAA,KAACA,iBAAAA,MAAD;MAAM,WAAU;MAAe,SAAA;MAAQ,YAAA;gBACrC,iBAAA,GAAA,kBAAA,KAAC,QAAD;OAAM,cAAY,EAAE,iBAAiB;iBAClC,UAAU,UAAU,KAAK,OAAO,EAAE,aAAa,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,KAAK;MAC3E,CAAA;KACF,CAAA;IAEG,EAAA,CAAA,GACZ,CAAC,CAAC,OAAO,OAAO,iBAAA,GAAA,kBAAA,KAACC,sBAAAA,eAAD;KAAe,KAAK,MAAM;KAAK,OAAO,MAAM;IAAQ,CAAA,CAC5D,EAAA,CAAA;IACX,iBAAA,GAAA,kBAAA,MAAC,iBAAD,EAAA,UAAA,CACE,iBAAA,GAAA,kBAAA,KAACD,iBAAAA,MAAD;KAAM,WAAU;KAAe,SAAA;KAAQ,YAAA;eACrC,iBAAA,GAAA,kBAAA,KAAC,QAAD;MAAM,MAAM,MAAM;gBAAW;KAAkB,CAAA;IAC3C,CAAA,GACL,CAAC,CAAC,iBAAiB,UAClB,iBAAA,GAAA,kBAAA,KAACE,
|
|
1
|
+
{"version":3,"file":"Gloss.js","names":["AccordionItemContent","AccordionItem","AccordionRoot","Text","SpeechControl","AccordionItemTrigger","IconButton","AccordionItemIndicator","ArrowDownShortLine","GlossExample"],"sources":["../../src/Gloss/Gloss.tsx"],"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\nimport { AccordionItemTrigger } from \"@ark-ui/react/accordion\";\nimport { ArrowDownShortLine } from \"@ndla/icons\";\nimport {\n AccordionItem,\n AccordionItemContent,\n AccordionItemIndicator,\n AccordionRoot,\n IconButton,\n Text,\n} from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledVariantProps } from \"@ndla/styled-system/types\";\nimport type { ConceptTitleDTO, GlossDataDTO, GlossExampleDTO } from \"@ndla/types-backend/concept-api\";\nimport parse from \"html-react-parser\";\nimport { useMemo } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { SpeechControl } from \"../AudioPlayer/SpeechControl\";\nimport { GlossExample } from \"./GlossExample\";\n\n// TODO: Figure out padding between bordered and simple variant.\n// The design says that the content above the accordion content should have enough padding to align with the accordion content.\n// When a gloss is bordered there's way too much padding.\n\nconst getFilteredExamples = (\n glossData: GlossDataDTO | undefined,\n exampleIds: string | undefined,\n exampleLangs: string | undefined,\n): GlossExampleDTO[][] => {\n if (exampleIds !== undefined || exampleLangs !== undefined) {\n const exampleIdsList = exampleIds?.toString()?.split(\",\") ?? [];\n const exampleLangsList = exampleLangs?.split(\",\") ?? [];\n\n const filteredExamples =\n glossData?.examples?.map((examples, i) => {\n if (exampleIdsList.includes(i.toString())) {\n return examples.filter((e) => exampleLangsList.includes(e.language));\n }\n return [];\n }) ?? [];\n const examplesWithoutEmpty = filteredExamples.filter((el) => !!el.length);\n return examplesWithoutEmpty;\n }\n return glossData?.examples ?? [];\n};\n\nconst Container = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n});\n\nconst TextWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"small\",\n },\n});\n\nconst StyledAccordionItemContent = styled(AccordionItemContent, {\n base: {\n paddingInline: \"0\",\n },\n});\n\nconst StyledContainer = styled(Container, {\n base: {\n marginBlockStart: \"3xsmall\",\n },\n});\n\nconst StyledAccordionItem = styled(AccordionItem, {\n base: {\n paddingBlock: \"small\",\n paddingInline: \"medium\",\n },\n defaultVariants: {\n variant: \"simple\",\n },\n variants: {\n variant: {\n simple: {},\n bordered: {\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n },\n },\n },\n});\n\ntype GlossVariantProps = StyledVariantProps<typeof StyledAccordionItem>;\n\nexport interface Props {\n title: ConceptTitleDTO;\n glossData?: GlossDataDTO;\n audio?: {\n title: string;\n src?: string;\n };\n exampleIds?: string;\n exampleLangs?: string;\n}\n\nexport const Gloss = ({ title, glossData, audio, exampleIds, exampleLangs, variant }: Props & GlossVariantProps) => {\n const { t } = useTranslation();\n\n const parsedTitle = useMemo(() => parse(title.htmlTitle), [title.htmlTitle]);\n\n const filteredExamples = useMemo(\n () => getFilteredExamples(glossData, exampleIds, exampleLangs),\n [exampleIds, exampleLangs, glossData],\n );\n\n if (!glossData) return null;\n\n return (\n <AccordionRoot multiple variant=\"clean\">\n <StyledAccordionItem value=\"gloss\" variant={variant}>\n <Container>\n <TextWrapper>\n <Text textStyle=\"label.medium\" fontWeight=\"bold\" asChild consumeCss lang={glossData.originalLanguage}>\n <span>{glossData.gloss}</span>\n </Text>\n {!!glossData.transcriptions.traditional && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span\n key={t(\"gloss.transcriptions.traditional\")}\n aria-label={t(\"gloss.transcriptions.traditional\")}\n lang={glossData.originalLanguage}\n >\n {glossData.transcriptions.traditional}\n </span>\n </Text>\n )}\n {!!glossData.transcriptions.pinyin && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span\n data-pinyin=\"\"\n key={t(\"gloss.transcriptions.pinyin\")}\n aria-label={t(\"gloss.transcriptions.pinyin\")}\n lang={glossData.originalLanguage}\n >\n {glossData.transcriptions.pinyin}\n </span>\n </Text>\n )}\n {!!glossData.wordClass && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span aria-label={t(\"gloss.wordClass\")}>\n {glossData.wordClass.map((wc) => t(`wordClass.${wc}`).toLowerCase()).join(\" / \")}\n </span>\n </Text>\n )}\n </TextWrapper>\n {!!audio?.src && <SpeechControl src={audio.src} title={audio.title} />}\n </Container>\n <StyledContainer>\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span lang={title.language}>{parsedTitle}</span>\n </Text>\n {!!filteredExamples.length && (\n <AccordionItemTrigger asChild>\n <IconButton variant=\"tertiary\" aria-label={t(\"gloss.showExamples\")} title={t(\"gloss.showExamples\")}>\n <AccordionItemIndicator asChild>\n <ArrowDownShortLine size=\"medium\" />\n </AccordionItemIndicator>\n </IconButton>\n </AccordionItemTrigger>\n )}\n </StyledContainer>\n <StyledAccordionItemContent>\n {filteredExamples.map((examples, index) => (\n <GlossExample\n key={`gloss-example-${index}`}\n examples={examples}\n originalLanguage={glossData.originalLanguage}\n />\n ))}\n </StyledAccordionItemContent>\n </StyledAccordionItem>\n </AccordionRoot>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,uBACJ,WACA,YACA,iBACwB;CACxB,IAAI,eAAe,KAAA,KAAa,iBAAiB,KAAA,GAAW;EAC1D,MAAM,iBAAiB,YAAY,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;EAC9D,MAAM,mBAAmB,cAAc,MAAM,GAAG,KAAK,CAAC;EAUtD,QAPE,WAAW,UAAU,KAAK,UAAU,MAAM;GACxC,IAAI,eAAe,SAAS,EAAE,SAAS,CAAC,GACtC,OAAO,SAAS,QAAQ,MAAM,iBAAiB,SAAS,EAAE,QAAQ,CAAC;GAErE,OAAO,CAAC;EACV,CAAC,KAAK,CAAC,GACqC,QAAQ,OAAO,CAAC,CAAC,GAAG,MACxC;CAC5B;CACA,OAAO,WAAW,YAAY,CAAC;AACjC;AAEA,MAAM,aAAA,GAAA,wBAAA,QAAmB,OAAO,EAC9B,MAAM;CACJ,SAAS;CACT,YAAY;CACZ,gBAAgB;AAClB,EACF,CAAC;AAED,MAAM,eAAA,GAAA,wBAAA,QAAqB,OAAO,EAChC,MAAM;CACJ,SAAS;CACT,KAAK;AACP,EACF,CAAC;AAED,MAAM,8BAAA,GAAA,wBAAA,QAAoCA,iBAAAA,sBAAsB,EAC9D,MAAM,EACJ,eAAe,IACjB,EACF,CAAC;AAED,MAAM,mBAAA,GAAA,wBAAA,QAAyB,WAAW,EACxC,MAAM,EACJ,kBAAkB,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,iBAAAA,wBAAD;OAAwB,SAAA;iBACtB,iBAAA,GAAA,kBAAA,KAACC,YAAAA,oBAAD,EAAoB,MAAK,SAAU,CAAA;MACb,CAAA;KACd,CAAA;IACQ,CAAA,CAET,EAAA,CAAA;IACjB,iBAAA,GAAA,kBAAA,KAAC,4BAAD,EAAA,UACG,iBAAiB,KAAK,UAAU,UAC/B,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,cAAD;KAEY;KACV,kBAAkB,UAAU;IAC7B,GAHM,iBAAiB,OAGvB,CACF,EACyB,CAAA;GACT;;CACR,CAAA;AAEnB"}
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type CollectionItem } from "@ark-ui/react";
|
|
8
|
+
import { type CollectionItem } from "@ark-ui/react/collection";
|
|
9
9
|
import { type ComboboxControlProps, type ComboboxInputProps, type ComboboxRootProps, type TagsInputControlProps, type TagsInputInputProps, type TagsInputRootProps } from "@ndla/primitives";
|
|
10
10
|
export type TagSelectorRootProps<T extends CollectionItem> = ComboboxRootProps<T> & TagsInputRootProps;
|
|
11
11
|
export declare const TagSelectorRoot: <T extends CollectionItem>({ allowCustomValue, multiple, selectionBehavior, editable, addOnPaste, onValueChange, children, value, translations, ...rest }: TagSelectorRootProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export type TagSelectorControlProps = ComboboxControlProps & TagsInputControlProps;
|
|
13
13
|
export declare const TagSelectorLabel: ({ textStyle, fontWeight, ...props }: import("@ndla/primitives").ComboboxLabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const TagSelectorItemInput: import("@ndla/styled-system/jsx").StyleContextConsumer<import("react").ForwardRefExoticComponent<import("@ark-ui/react").TagsInputItemInputProps & import("react").RefAttributes<HTMLInputElement>>>;
|
|
15
|
-
export declare const TagSelectorTrigger: import("@ndla/styled-system/jsx").StyleContextConsumer<import("react").ForwardRefExoticComponent<import("@ark-ui/react").ComboboxTriggerProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
14
|
+
export declare const TagSelectorItemInput: import("@ndla/styled-system/jsx").StyleContextConsumer<import("react").ForwardRefExoticComponent<import("@ark-ui/react/tags-input").TagsInputItemInputProps & import("react").RefAttributes<HTMLInputElement>>>;
|
|
15
|
+
export declare const TagSelectorTrigger: import("@ndla/styled-system/jsx").StyleContextConsumer<import("react").ForwardRefExoticComponent<import("@ark-ui/react/combobox").ComboboxTriggerProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
16
16
|
export declare const TagSelectorControl: import("react").ForwardRefExoticComponent<ComboboxControlProps & TagsInputControlProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
-
export declare const TagSelectorClearTrigger: import("@ndla/styled-system/jsx").StyleContextConsumer<import("react").ForwardRefExoticComponent<import("@ark-ui/react").ComboboxClearTriggerProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
17
|
+
export declare const TagSelectorClearTrigger: import("@ndla/styled-system/jsx").StyleContextConsumer<import("react").ForwardRefExoticComponent<import("@ark-ui/react/combobox").ComboboxClearTriggerProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
18
18
|
export type TagSelectorInputProps = ComboboxInputProps & TagsInputInputProps;
|
|
19
19
|
export declare const TagSelectorInputBase: import("react").ForwardRefExoticComponent<ComboboxInputProps & TagsInputInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
20
20
|
export declare const TagSelectorInput: import("react").ForwardRefExoticComponent<ComboboxInputProps & TagsInputInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -4,7 +4,9 @@ let react = require("react");
|
|
|
4
4
|
let _ndla_icons = require("@ndla/icons");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
let _ndla_util = require("@ndla/util");
|
|
7
|
-
|
|
7
|
+
require("@ark-ui/react/collection");
|
|
8
|
+
let _ark_ui_react_combobox = require("@ark-ui/react/combobox");
|
|
9
|
+
let _ark_ui_react_tags_input = require("@ark-ui/react/tags-input");
|
|
8
10
|
//#region src/TagSelector/TagSelector.tsx
|
|
9
11
|
/**
|
|
10
12
|
* Copyright (c) 2024-present, NDLA.
|
|
@@ -48,7 +50,7 @@ const TagSelectorRoot = ({ allowCustomValue = true, multiple = true, selectionBe
|
|
|
48
50
|
});
|
|
49
51
|
};
|
|
50
52
|
const TagSelectorTagsInputRoot = (0, react.forwardRef)((props, ref) => {
|
|
51
|
-
const comboboxApi = (0,
|
|
53
|
+
const comboboxApi = (0, _ark_ui_react_combobox.useComboboxContext)();
|
|
52
54
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_primitives.TagsInputRoot, {
|
|
53
55
|
ref,
|
|
54
56
|
onInputValueChange: (details) => comboboxApi.setInputValue(details.inputValue),
|
|
@@ -70,7 +72,7 @@ const TagSelectorControl = (0, react.forwardRef)(({ children, ...props }, ref) =
|
|
|
70
72
|
});
|
|
71
73
|
const TagSelectorClearTrigger = _ndla_primitives.ComboboxClearTrigger;
|
|
72
74
|
const TagSelectorInputBase = (0, react.forwardRef)(({ children, ...props }, ref) => {
|
|
73
|
-
const tagsApi = (0,
|
|
75
|
+
const tagsApi = (0, _ark_ui_react_tags_input.useTagsInputContext)();
|
|
74
76
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_primitives.ComboboxInput, {
|
|
75
77
|
ref,
|
|
76
78
|
asChild: true,
|
|
@@ -84,7 +86,7 @@ const TagSelectorInputBase = (0, react.forwardRef)(({ children, ...props }, ref)
|
|
|
84
86
|
});
|
|
85
87
|
});
|
|
86
88
|
const TagSelectorInput = (0, react.forwardRef)(({ children, ...props }, ref) => {
|
|
87
|
-
const tagsApi = (0,
|
|
89
|
+
const tagsApi = (0, _ark_ui_react_tags_input.useTagsInputContext)();
|
|
88
90
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [tagsApi.value.map((value, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_ndla_primitives.TagsInputItem, {
|
|
89
91
|
index,
|
|
90
92
|
value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagSelector.js","names":["ComboboxRoot","TagsInputRoot","ComboboxLabel","TagsInputItemInput","ComboboxTrigger","ComboboxControl","TagsInputControl","ComboboxClearTrigger","ComboboxInput","TagsInputInput","TagsInputItem","TagsInputItemPreview","TagsInputItemText","TagsInputItemDeleteTrigger","CloseLine"],"sources":["../../src/TagSelector/TagSelector.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 { type CollectionItem
|
|
1
|
+
{"version":3,"file":"TagSelector.js","names":["ComboboxRoot","TagsInputRoot","ComboboxLabel","TagsInputItemInput","ComboboxTrigger","ComboboxControl","TagsInputControl","ComboboxClearTrigger","ComboboxInput","TagsInputInput","TagsInputItem","TagsInputItemPreview","TagsInputItemText","TagsInputItemDeleteTrigger","CloseLine"],"sources":["../../src/TagSelector/TagSelector.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 { type CollectionItem } from \"@ark-ui/react/collection\";\nimport { useComboboxContext } from \"@ark-ui/react/combobox\";\nimport { useTagsInputContext } from \"@ark-ui/react/tags-input\";\nimport { CloseLine } from \"@ndla/icons\";\nimport {\n ComboboxClearTrigger,\n ComboboxControl,\n type ComboboxControlProps,\n ComboboxInput,\n type ComboboxInputProps,\n ComboboxLabel,\n ComboboxRoot,\n type ComboboxRootProps,\n ComboboxTrigger,\n TagsInputControl,\n type TagsInputControlProps,\n TagsInputInput,\n type TagsInputInputProps,\n TagsInputItem,\n TagsInputItemDeleteTrigger,\n TagsInputItemPreview,\n TagsInputItemText,\n TagsInputRoot,\n type TagsInputRootProps,\n TagsInputItemInput,\n} from \"@ndla/primitives\";\nimport { contains } from \"@ndla/util\";\nimport { forwardRef, useEffect, useId, useRef } from \"react\";\n\nexport type TagSelectorRootProps<T extends CollectionItem> = ComboboxRootProps<T> & TagsInputRootProps;\n\nexport const TagSelectorRoot = <T extends CollectionItem>({\n allowCustomValue = true,\n multiple = true,\n selectionBehavior = \"clear\",\n editable,\n addOnPaste = false,\n onValueChange,\n children,\n value,\n translations,\n ...rest\n}: TagSelectorRootProps<T>) => {\n const ids = {\n root: useId(),\n input: useId(),\n control: useId(),\n };\n\n const controlRef = useRef<HTMLDivElement | undefined>(undefined);\n\n useEffect(() => {\n if (!controlRef.current) {\n controlRef.current = document.getElementById(ids.control) as HTMLDivElement | undefined;\n }\n }, [ids.control]);\n\n return (\n <ComboboxRoot\n ids={ids}\n asChild\n allowCustomValue={allowCustomValue}\n multiple={multiple}\n selectionBehavior={selectionBehavior}\n onValueChange={onValueChange}\n translations={translations}\n onPointerDownOutside={(event) => {\n if (contains(controlRef.current, event.detail.originalEvent.target)) {\n event.preventDefault();\n }\n }}\n value={value}\n {...rest}\n >\n <TagSelectorTagsInputRoot\n ids={ids}\n value={value}\n editable={editable}\n onValueChange={onValueChange}\n addOnPaste={addOnPaste}\n translations={translations}\n >\n {children}\n </TagSelectorTagsInputRoot>\n </ComboboxRoot>\n );\n};\n\nconst TagSelectorTagsInputRoot = forwardRef<HTMLDivElement, TagsInputRootProps>((props, ref) => {\n const comboboxApi = useComboboxContext();\n return (\n <TagsInputRoot\n ref={ref}\n onInputValueChange={(details) => comboboxApi.setInputValue(details.inputValue)}\n {...props}\n />\n );\n});\n\nexport type TagSelectorControlProps = ComboboxControlProps & TagsInputControlProps;\n\nexport const TagSelectorLabel = ComboboxLabel;\n\nexport const TagSelectorItemInput = TagsInputItemInput;\n\nexport const TagSelectorTrigger = ComboboxTrigger;\n\nexport const TagSelectorControl = forwardRef<HTMLDivElement, TagSelectorControlProps>(({ children, ...props }, ref) => {\n return (\n <ComboboxControl ref={ref} asChild>\n <TagsInputControl {...props}>{children}</TagsInputControl>\n </ComboboxControl>\n );\n});\n\nexport const TagSelectorClearTrigger = ComboboxClearTrigger;\n\nexport type TagSelectorInputProps = ComboboxInputProps & TagsInputInputProps;\n\n// If you need to modify the TagsInputItem, you can use this.\nexport const TagSelectorInputBase = forwardRef<HTMLInputElement, TagSelectorInputProps>(\n ({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n );\n },\n);\n\nexport const TagSelectorInput = forwardRef<HTMLInputElement, TagSelectorInputProps>(({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <>\n {tagsApi.value.map((value, index) => (\n <TagsInputItem index={index} value={value} key={value}>\n <TagsInputItemPreview>\n <TagsInputItemText>{value}</TagsInputItemText>\n <TagsInputItemDeleteTrigger>\n <CloseLine />\n </TagsInputItemDeleteTrigger>\n </TagsInputItemPreview>\n <TagsInputItemInput />\n </TagsInputItem>\n ))}\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n </>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAa,mBAA6C,EACxD,mBAAmB,MACnB,WAAW,MACX,oBAAoB,SACpB,UACA,aAAa,OACb,eACA,UACA,OACA,cACA,GAAG,WAC0B;CAC7B,MAAM,MAAM;EACV,OAAA,GAAA,MAAA,OAAY;EACZ,QAAA,GAAA,MAAA,OAAa;EACb,UAAA,GAAA,MAAA,OAAe;CACjB;CAEA,MAAM,cAAA,GAAA,MAAA,QAAgD,KAAA,CAAS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EAAK,SAAA;YACvB,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,gBAAD;GACE,YAAY,UAAU;IACpB,IAAI,MAAM,QAAQ,SAChB,QAAQ,SAAS,QAAQ,UAAU;GAEvC;GACA,GAAI;GAEH;EACa,CAAA;CACH,CAAA;AAEnB,CACF;AAEA,MAAa,oBAAA,GAAA,MAAA,aAAwE,EAAE,UAAU,GAAG,SAAS,QAAQ;CACnH,MAAM,WAAA,GAAA,yBAAA,qBAA8B;CAEpC,OACE,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CACG,QAAQ,MAAM,KAAK,OAAO,UACzB,iBAAA,GAAA,kBAAA,MAACC,iBAAAA,eAAD;EAAsB;EAAc;YAApC,CACE,iBAAA,GAAA,kBAAA,MAACC,iBAAAA,sBAAD,EAAA,UAAA,CACE,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,mBAAD,EAAA,UAAoB,MAAyB,CAAA,GAC7C,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,4BAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,WAAD,CAAY,CAAA,EACc,CAAA,CACR,EAAA,CAAA,GACtB,iBAAA,GAAA,kBAAA,KAACX,iBAAAA,oBAAD,CAAqB,CAAA,CACR;IARiC,KAQjC,CAChB,GACD,iBAAA,GAAA,kBAAA,KAACK,iBAAAA,eAAD;EAAoB;EAAK,SAAA;YACvB,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,gBAAD;GACE,YAAY,UAAU;IACpB,IAAI,MAAM,QAAQ,SAChB,QAAQ,SAAS,QAAQ,UAAU;GAEvC;GACA,GAAI;GAEH;EACa,CAAA;CACH,CAAA,CACf,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { CollectionItem } from "@ark-ui/react";
|
|
8
|
+
import type { CollectionItem } from "@ark-ui/react/collection";
|
|
9
9
|
import type { ComboboxRootProps, PaginationRootProps, TagsInputRootProps, DatePickerRootProps } from "@ndla/primitives";
|
|
10
10
|
import { type TagSelectorRootProps } from "../TagSelector/TagSelector";
|
|
11
11
|
type DeepPartial<T> = {
|
|
@@ -120,9 +120,9 @@ const useDatePickerTranslations = (translations) => {
|
|
|
120
120
|
const { t } = (0, react_i18next.useTranslation)("translation", { keyPrefix: "component.datePicker" });
|
|
121
121
|
return (0, react.useMemo)(() => ({
|
|
122
122
|
dayCell: (state) => {
|
|
123
|
-
if (state.unavailable) return t("dayCell.unavailable", { date: state.
|
|
124
|
-
else if (state.selected) return t("dayCell.selected", { date: state.
|
|
125
|
-
else return t("dayCell.select", { date: state.
|
|
123
|
+
if (state.unavailable) return t("dayCell.unavailable", { date: state.valueText });
|
|
124
|
+
else if (state.selected) return t("dayCell.selected", { date: state.valueText });
|
|
125
|
+
else return t("dayCell.select", { date: state.valueText });
|
|
126
126
|
},
|
|
127
127
|
nextTrigger: (view) => t(`nextTrigger.${view}`),
|
|
128
128
|
prevTrigger: (view) => t(`prevTrigger.${view}`),
|
|
@@ -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,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,eAAe,EAAE,IAAI,CAAC;EAC9C,GAAG;CACL,IACA,CAAC,GAAG,YAAY,CAClB;AACF;AAEA,MAAa,2BACX,iBACyC;CACzC,MAAM,EAAE,OAAA,GAAA,cAAA,gBAAqB,eAAe,EAAE,WAAW,qBAAqB,CAAC;CAE/E,QAAA,GAAA,MAAA,gBACS;EACL,cAAc,EAAE,cAAc;EAC9B,mBAAmB,EAAE,mBAAmB;EACxC,GAAG;CACL,IACA,CAAC,GAAG,YAAY,CAClB;AACF;AAEA,MAAa,8BACX,iBAC4C;CAC5C,MAAM,wBAAwB,yBAAyB;CACvD,MAAM,uBAAuB,wBAAwB;CAErD,QAAA,GAA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,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
|
+
{"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/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,eAAe,EAAE,IAAI,CAAC;EAC9C,GAAG;CACL,IACA,CAAC,GAAG,YAAY,CAClB;AACF;AAEA,MAAa,2BACX,iBACyC;CACzC,MAAM,EAAE,OAAA,GAAA,cAAA,gBAAqB,eAAe,EAAE,WAAW,qBAAqB,CAAC;CAE/E,QAAA,GAAA,MAAA,gBACS;EACL,cAAc,EAAE,cAAc;EAC9B,mBAAmB,EAAE,mBAAmB;EACxC,GAAG;CACL,IACA,CAAC,GAAG,YAAY,CAClB;AACF;AAEA,MAAa,8BACX,iBAC4C;CAC5C,MAAM,wBAAwB,yBAAyB;CACvD,MAAM,uBAAuB,wBAAwB;CAErD,QAAA,GAAA,MAAA,gBAEK;EACC,GAAG;EACH,GAAG;EACH,GAAG;CACL,IACF;EAAC;EAAsB;EAAuB;CAAY,CAC5D;AACF;AAEA,MAAa,6BACX,iBACwC;CACxC,MAAM,EAAE,OAAA,GAAA,cAAA,gBAAqB,eAAe,EAAE,WAAW,uBAAuB,CAAC;CAEjF,QAAA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,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"}
|
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";
|