@ndla/primitives 1.0.122-alpha.0 → 1.0.124-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 +3 -3
- package/dist/styles.css +6 -6
- package/es/Accordion.mjs +7 -0
- package/es/Accordion.mjs.map +1 -1
- package/es/ArticleLists.mjs +7 -0
- package/es/ArticleLists.mjs.map +1 -1
- package/es/Badge.mjs +7 -0
- package/es/Badge.mjs.map +1 -1
- package/es/BlockQuote.mjs +7 -0
- package/es/BlockQuote.mjs.map +1 -1
- package/es/Button.mjs +7 -0
- package/es/Button.mjs.map +1 -1
- package/es/Card/Card.mjs +7 -0
- package/es/Card/Card.mjs.map +1 -1
- package/es/Checkbox.mjs +7 -0
- package/es/Checkbox.mjs.map +1 -1
- package/es/Combobox.mjs +7 -0
- package/es/Combobox.mjs.map +1 -1
- package/es/DatePicker.mjs.map +1 -1
- package/es/Dialog.mjs +7 -0
- package/es/Dialog.mjs.map +1 -1
- package/es/ErrorMessage/ErrorMessage.mjs +7 -0
- package/es/ErrorMessage/ErrorMessage.mjs.map +1 -1
- package/es/ExpandableBox.mjs +7 -0
- package/es/ExpandableBox.mjs.map +1 -1
- package/es/Field.mjs +7 -0
- package/es/Field.mjs.map +1 -1
- package/es/FieldErrorMessage.mjs +7 -0
- package/es/FieldErrorMessage.mjs.map +1 -1
- package/es/FieldHelper.mjs +7 -0
- package/es/FieldHelper.mjs.map +1 -1
- package/es/Figure.mjs +7 -0
- package/es/Figure.mjs.map +1 -1
- package/es/FileUpload.mjs +7 -0
- package/es/FileUpload.mjs.map +1 -1
- package/es/FramedContent.mjs +7 -0
- package/es/FramedContent.mjs.map +1 -1
- package/es/Hero.mjs +8 -0
- package/es/Hero.mjs.map +1 -1
- package/es/Image.mjs +7 -0
- package/es/Image.mjs.map +1 -1
- package/es/Input.mjs +7 -0
- package/es/Input.mjs.map +1 -1
- package/es/Label.mjs +7 -0
- package/es/Label.mjs.map +1 -1
- package/es/Layout/PageContainer.mjs.map +1 -1
- package/es/Layout/PageContent.mjs +7 -0
- package/es/Layout/PageContent.mjs.map +1 -1
- package/es/ListItem/ListItem.mjs +7 -0
- package/es/ListItem/ListItem.mjs.map +1 -1
- package/es/Menu.mjs +10 -3
- package/es/Menu.mjs.map +1 -1
- package/es/MessageBox.mjs +7 -0
- package/es/MessageBox.mjs.map +1 -1
- package/es/NdlaLogo.mjs +7 -0
- package/es/NdlaLogo.mjs.map +1 -1
- package/es/Pagination.mjs +7 -0
- package/es/Pagination.mjs.map +1 -1
- package/es/Popover.mjs +7 -0
- package/es/Popover.mjs.map +1 -1
- package/es/RadioGroup.mjs +7 -0
- package/es/RadioGroup.mjs.map +1 -1
- package/es/Select.mjs +7 -0
- package/es/Select.mjs.map +1 -1
- package/es/Skeleton.mjs +7 -0
- package/es/Skeleton.mjs.map +1 -1
- package/es/Slider.mjs +7 -0
- package/es/Slider.mjs.map +1 -1
- package/es/Spinner.mjs +7 -0
- package/es/Spinner.mjs.map +1 -1
- package/es/Switch.mjs +7 -0
- package/es/Switch.mjs.map +1 -1
- package/es/Table.mjs +7 -0
- package/es/Table.mjs.map +1 -1
- package/es/Tabs.mjs +7 -0
- package/es/Tabs.mjs.map +1 -1
- package/es/TagsInput.mjs +7 -0
- package/es/TagsInput.mjs.map +1 -1
- package/es/Text.mjs +7 -0
- package/es/Text.mjs.map +1 -1
- package/es/Toast.mjs +7 -0
- package/es/Toast.mjs.map +1 -1
- package/es/ToggleGroup.mjs +7 -0
- package/es/ToggleGroup.mjs.map +1 -1
- package/es/Tooltip.mjs +7 -0
- package/es/Tooltip.mjs.map +1 -1
- package/es/Tree/Tree.mjs +7 -0
- package/es/Tree/Tree.mjs.map +1 -1
- package/lib/Accordion.d.ts +1 -1
- package/lib/Accordion.js +7 -0
- package/lib/Accordion.js.map +1 -1
- package/lib/ArticleLists.d.ts +1 -1
- package/lib/ArticleLists.js +7 -0
- package/lib/ArticleLists.js.map +1 -1
- package/lib/Badge.d.ts +1 -1
- package/lib/Badge.js +7 -0
- package/lib/Badge.js.map +1 -1
- package/lib/BlockQuote.d.ts +1 -1
- package/lib/BlockQuote.js +7 -0
- package/lib/BlockQuote.js.map +1 -1
- package/lib/Button.d.ts +1 -1
- package/lib/Button.js +7 -0
- package/lib/Button.js.map +1 -1
- package/lib/Card/Card.d.ts +1 -1
- package/lib/Card/Card.js +7 -0
- package/lib/Card/Card.js.map +1 -1
- package/lib/Checkbox.d.ts +1 -1
- package/lib/Checkbox.js +7 -0
- package/lib/Checkbox.js.map +1 -1
- package/lib/Combobox.d.ts +1 -1
- package/lib/Combobox.js +7 -0
- package/lib/Combobox.js.map +1 -1
- package/lib/DatePicker.d.ts +1 -1
- package/lib/DatePicker.js.map +1 -1
- package/lib/Dialog.d.ts +1 -1
- package/lib/Dialog.js +7 -0
- package/lib/Dialog.js.map +1 -1
- package/lib/ErrorMessage/ErrorMessage.d.ts +1 -1
- package/lib/ErrorMessage/ErrorMessage.js +7 -0
- package/lib/ErrorMessage/ErrorMessage.js.map +1 -1
- package/lib/ExpandableBox.d.ts +1 -1
- package/lib/ExpandableBox.js +7 -0
- package/lib/ExpandableBox.js.map +1 -1
- package/lib/Field.js +7 -0
- package/lib/Field.js.map +1 -1
- package/lib/FieldErrorMessage.d.ts +1 -1
- package/lib/FieldErrorMessage.js +7 -0
- package/lib/FieldErrorMessage.js.map +1 -1
- package/lib/FieldHelper.d.ts +1 -1
- package/lib/FieldHelper.js +7 -0
- package/lib/FieldHelper.js.map +1 -1
- package/lib/Figure.d.ts +1 -1
- package/lib/Figure.js +7 -0
- package/lib/Figure.js.map +1 -1
- package/lib/FileUpload.d.ts +1 -1
- package/lib/FileUpload.js +7 -0
- package/lib/FileUpload.js.map +1 -1
- package/lib/FramedContent.d.ts +1 -1
- package/lib/FramedContent.js +7 -0
- package/lib/FramedContent.js.map +1 -1
- package/lib/Hero.d.ts +11 -1
- package/lib/Hero.js +8 -0
- package/lib/Hero.js.map +1 -1
- package/lib/Image.js +7 -0
- package/lib/Image.js.map +1 -1
- package/lib/Input.d.ts +1 -1
- package/lib/Input.js +7 -0
- package/lib/Input.js.map +1 -1
- package/lib/Label.d.ts +1 -1
- package/lib/Label.js +7 -0
- package/lib/Label.js.map +1 -1
- package/lib/Layout/PageContainer.d.ts +1 -1
- package/lib/Layout/PageContainer.js +7 -0
- package/lib/Layout/PageContainer.js.map +1 -1
- package/lib/Layout/PageContent.d.ts +1 -1
- package/lib/Layout/PageContent.js +7 -0
- package/lib/Layout/PageContent.js.map +1 -1
- package/lib/ListItem/ListItem.d.ts +1 -1
- package/lib/ListItem/ListItem.js +7 -0
- package/lib/ListItem/ListItem.js.map +1 -1
- package/lib/Menu.d.ts +4 -4
- package/lib/Menu.js +10 -3
- package/lib/Menu.js.map +1 -1
- package/lib/MessageBox.d.ts +1 -1
- package/lib/MessageBox.js +7 -0
- package/lib/MessageBox.js.map +1 -1
- package/lib/NdlaLogo.js +7 -0
- package/lib/NdlaLogo.js.map +1 -1
- package/lib/Pagination.d.ts +1 -1
- package/lib/Pagination.js +7 -0
- package/lib/Pagination.js.map +1 -1
- package/lib/Popover.d.ts +1 -1
- package/lib/Popover.js +7 -0
- package/lib/Popover.js.map +1 -1
- package/lib/RadioGroup.d.ts +2 -2
- package/lib/RadioGroup.js +7 -0
- package/lib/RadioGroup.js.map +1 -1
- package/lib/Select.d.ts +1 -1
- package/lib/Select.js +7 -0
- package/lib/Select.js.map +1 -1
- package/lib/Skeleton.d.ts +1 -1
- package/lib/Skeleton.js +7 -0
- package/lib/Skeleton.js.map +1 -1
- package/lib/Slider.d.ts +2 -2
- package/lib/Slider.js +7 -0
- package/lib/Slider.js.map +1 -1
- package/lib/Spinner.d.ts +1 -1
- package/lib/Spinner.js +7 -0
- package/lib/Spinner.js.map +1 -1
- package/lib/Switch.d.ts +2 -2
- package/lib/Switch.js +7 -0
- package/lib/Switch.js.map +1 -1
- package/lib/Table.d.ts +1 -1
- package/lib/Table.js +7 -0
- package/lib/Table.js.map +1 -1
- package/lib/Tabs.d.ts +2 -2
- package/lib/Tabs.js +7 -0
- package/lib/Tabs.js.map +1 -1
- package/lib/TagsInput.d.ts +1 -1
- package/lib/TagsInput.js +7 -0
- package/lib/TagsInput.js.map +1 -1
- package/lib/Text.d.ts +1 -1
- package/lib/Text.js +7 -0
- package/lib/Text.js.map +1 -1
- package/lib/Toast.d.ts +1 -1
- package/lib/Toast.js +7 -0
- package/lib/Toast.js.map +1 -1
- package/lib/ToggleGroup.d.ts +1 -1
- package/lib/ToggleGroup.js +7 -0
- package/lib/ToggleGroup.js.map +1 -1
- package/lib/Tooltip.d.ts +1 -1
- package/lib/Tooltip.js +7 -0
- package/lib/Tooltip.js.map +1 -1
- package/lib/Tree/Tree.d.ts +1 -1
- package/lib/Tree/Tree.js +7 -0
- package/lib/Tree/Tree.js.map +1 -1
- package/package.json +4 -4
package/lib/Image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","names":["styled","ark"],"sources":["../src/Image.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 { StyledProps, StyledVariantProps } from \"@ndla/styled-system/types\";\nimport type { ImageVariantDTO, ImageVariantSize } from \"@ndla/types-backend/image-api\";\nimport { ark } from \"@ark-ui/react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ComponentPropsWithRef, type ReactNode, forwardRef, useEffect, useState } from \"react\";\n\nexport interface ImageCrop {\n startX: number;\n startY: number;\n endX: number;\n endY: number;\n}\n\nexport interface ImageFocalPoint {\n x: number;\n y: number;\n}\n\ninterface SrcQueryStringOptions {\n width?: number;\n crop?: ImageCrop;\n focalPoint?: ImageFocalPoint;\n imageLanguage?: string;\n}\n\nexport const makeSrcQueryString = ({ width, crop, focalPoint, imageLanguage }: SrcQueryStringOptions) => {\n const params = [];\n if (width) {\n params.push(`width=${width}`);\n }\n if (crop) {\n params.push(`cropStartX=${crop.startX}&cropEndX=${crop.endX}&cropStartY=${crop.startY}&cropEndY=${crop.endY}`);\n }\n if (focalPoint) {\n params.push(`focalX=${focalPoint.x}&focalY=${focalPoint.y}`);\n }\n if (imageLanguage) {\n params.push(`language=${imageLanguage}`);\n }\n return params.join(\"&\");\n};\n\ninterface SrcSetOptions {\n crop?: ImageCrop;\n focalPoint?: ImageFocalPoint;\n imageLanguage?: string;\n src?: string;\n}\n\nexport const VAR_WIDTHS: Record<ImageVariantSize, number> = {\n icon: 240,\n xsmall: 480,\n small: 800,\n medium: 1080,\n large: 1440,\n xlarge: 1920,\n xxlarge: 2560,\n};\n\nconst IMAGE_WIDTHS = [2720, 2080, 1760, 1440, 1120, 1000, 960, 800, 640, 480, 320, 240, 180];\n\nexport const getVariantSrcSet = (variants: ImageVariantDTO[]) => {\n return variants\n .map((variant) => {\n return `${variant.variantUrl} ${VAR_WIDTHS[variant.size]}w`;\n })\n .join(\", \");\n};\n\nexport const getVariantSizes = (variants: ImageVariantDTO[]) => {\n return variants\n .map((variant, i) => {\n if (i === variants.length - 1) {\n return `${VAR_WIDTHS[variant.size]}px`;\n }\n return `(max-width: ${VAR_WIDTHS[variant.size]}px) ${VAR_WIDTHS[variant.size]}px`;\n })\n .join(\", \");\n};\n\nexport const getSrcSet = ({ src, crop, focalPoint, imageLanguage }: SrcSetOptions) => {\n if (!src) return undefined;\n return IMAGE_WIDTHS.map((width) => {\n const queryString = makeSrcQueryString({ width, crop, focalPoint, imageLanguage });\n const query = queryString.length ? `?${queryString}` : \"\";\n return `${src}${query} ${width}w`;\n }).join(\", \");\n};\n\nconst FALLBACK_WIDTH = 1024;\n\nconst FALLBACK_SIZES = \"(min-width: 1024px) 1024px, 100vw\";\n\nexport interface PictureProps extends StyledProps, ComponentPropsWithRef<\"picture\"> {\n src: string;\n sizes?: string;\n contentType?: string;\n srcSet?: string;\n crop?: ImageCrop;\n focalPoint?: ImageFocalPoint;\n imageLanguage?: string;\n}\n\nexport const Picture = forwardRef<HTMLPictureElement, PictureProps>(\n (\n {\n children,\n srcSet: srcSetProp,\n crop,\n focalPoint,\n src,\n imageLanguage,\n contentType,\n sizes = FALLBACK_SIZES,\n ...props\n },\n ref,\n ) => {\n const srcSet = srcSetProp ?? getSrcSet({ src, crop, focalPoint, imageLanguage });\n\n return (\n <styled.picture {...props} ref={ref}>\n {contentType !== \"image/gif\" && <source type={contentType} srcSet={srcSet} sizes={sizes} />}\n {children}\n </styled.picture>\n );\n },\n);\n\nconst StyledImage = styled(\"img\", {\n defaultVariants: { variant: \"regular\" },\n variants: {\n variant: {\n regular: {},\n rounded: {\n borderRadius: \"xsmall\",\n },\n },\n },\n});\n\nconst StyledFallbackElement = styled(\n ark.div,\n {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n },\n { baseComponent: true },\n);\n\ntype ImageVariantProps = StyledVariantProps<typeof StyledImage>;\n\nexport interface ImgProps extends StyledProps, ComponentPropsWithRef<\"img\">, ImageVariantProps {\n alt: string;\n src: string;\n fallbackWidth?: number;\n contentType?: string;\n crop?: ImageCrop;\n imageLanguage?: string;\n focalPoint?: ImageFocalPoint;\n}\n\nexport const Img = forwardRef<HTMLImageElement, ImgProps>(\n ({ fallbackWidth = FALLBACK_WIDTH, crop, focalPoint, imageLanguage, contentType, src, alt, ...props }, ref) => {\n const queryString = makeSrcQueryString({ width: fallbackWidth, crop, focalPoint, imageLanguage });\n const srcWithParms = queryString ? `${src}?${queryString}` : src;\n return <StyledImage alt={alt} src={contentType === \"image/gif\" ? src : srcWithParms} {...props} ref={ref} />;\n },\n);\n\nexport interface ImageProps extends StyledProps, ComponentPropsWithRef<\"img\">, ImageVariantProps {\n alt: string;\n src?: string;\n sizes?: string;\n fallbackWidth?: number;\n contentType?: string;\n imageLanguage?: string;\n crop?: ImageCrop;\n fallbackElement?: ReactNode;\n focalPoint?: ImageFocalPoint;\n variants?: ImageVariantDTO[];\n}\n\nexport const Image = forwardRef<HTMLImageElement, ImageProps>(\n (\n {\n srcSet: srcSetProp,\n crop,\n focalPoint,\n src,\n contentType,\n imageLanguage,\n fallbackWidth = FALLBACK_WIDTH,\n sizes: sizesProp,\n alt,\n fallbackElement,\n variants,\n ...props\n },\n ref,\n ) => {\n const [hasError, setHasError] = useState(false);\n\n useEffect(() => {\n setHasError(false);\n }, [src, srcSetProp, sizesProp, variants]);\n\n if (!src?.length && !variants?.length && fallbackElement) {\n return (\n <StyledFallbackElement {...props} ref={ref}>\n {fallbackElement}\n </StyledFallbackElement>\n );\n }\n\n const queryString = makeSrcQueryString({ width: fallbackWidth, crop, focalPoint, imageLanguage });\n const fallbackSrc = src && queryString ? `${src}?${queryString}` : src;\n\n return (\n <picture>\n {!!variants?.length && !crop && !focalPoint && contentType !== \"image/gif\" && (\n <source\n type={\"image/webp\"}\n srcSet={getVariantSrcSet(variants)}\n sizes={sizesProp ?? getVariantSizes(variants)}\n />\n )}\n {contentType !== \"image/gif\" && (\n <source\n type={contentType}\n srcSet={getSrcSet({ src, crop, focalPoint, imageLanguage })}\n sizes={sizesProp ?? FALLBACK_SIZES}\n />\n )}\n <StyledImage\n alt={alt}\n src={contentType === \"image/gif\" ? src : fallbackSrc}\n {...props}\n ref={ref}\n data-error={hasError ? \"\" : undefined}\n onError={(e) => {\n setHasError(true);\n props.onError?.(e);\n }}\n onLoad={(e) => {\n setHasError(false);\n props.onLoad?.(e);\n }}\n />\n </picture>\n );\n },\n);\n"],"mappings":";;;;;;AAiCA,MAAa,sBAAsB,EAAE,OAAO,MAAM,YAAY,oBAA2C;CACvG,MAAM,SAAS,EAAE;AACjB,KAAI,MACF,QAAO,KAAK,SAAS,QAAQ;AAE/B,KAAI,KACF,QAAO,KAAK,cAAc,KAAK,OAAO,YAAY,KAAK,KAAK,cAAc,KAAK,OAAO,YAAY,KAAK,OAAO;AAEhH,KAAI,WACF,QAAO,KAAK,UAAU,WAAW,EAAE,UAAU,WAAW,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eACf,2CAAC;GACC,MAAM;GACN,QAAQ,UAAU;IAAE;IAAK;IAAM;IAAY;IAAe,CAAC;GAC3D,OAAO,aAAa;IACpB;EAEJ,2CAAC;GACM;GACL,KAAK,gBAAgB,cAAc,MAAM;GACzC,GAAI;GACC;GACL,cAAY,WAAW,KAAK;GAC5B,UAAU,MAAM;AACd,gBAAY,KAAK;AACjB,UAAM,UAAU,EAAE;;GAEpB,SAAS,MAAM;AACb,gBAAY,MAAM;AAClB,UAAM,SAAS,EAAE;;IAEnB;KACM;EAGf"}
|
|
1
|
+
{"version":3,"file":"Image.js","names":["styled","ark"],"sources":["../src/Image.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 } from \"@ark-ui/react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledProps, StyledVariantProps } from \"@ndla/styled-system/types\";\nimport type { ImageVariantDTO, ImageVariantSize } from \"@ndla/types-backend/image-api\";\nimport { type ComponentPropsWithRef, type ReactNode, forwardRef, useEffect, useState } from \"react\";\n\nexport interface ImageCrop {\n startX: number;\n startY: number;\n endX: number;\n endY: number;\n}\n\nexport interface ImageFocalPoint {\n x: number;\n y: number;\n}\n\ninterface SrcQueryStringOptions {\n width?: number;\n crop?: ImageCrop;\n focalPoint?: ImageFocalPoint;\n imageLanguage?: string;\n}\n\nexport const makeSrcQueryString = ({ width, crop, focalPoint, imageLanguage }: SrcQueryStringOptions) => {\n const params = [];\n if (width) {\n params.push(`width=${width}`);\n }\n if (crop) {\n params.push(`cropStartX=${crop.startX}&cropEndX=${crop.endX}&cropStartY=${crop.startY}&cropEndY=${crop.endY}`);\n }\n if (focalPoint) {\n params.push(`focalX=${focalPoint.x}&focalY=${focalPoint.y}`);\n }\n if (imageLanguage) {\n params.push(`language=${imageLanguage}`);\n }\n return params.join(\"&\");\n};\n\ninterface SrcSetOptions {\n crop?: ImageCrop;\n focalPoint?: ImageFocalPoint;\n imageLanguage?: string;\n src?: string;\n}\n\nexport const VAR_WIDTHS: Record<ImageVariantSize, number> = {\n icon: 240,\n xsmall: 480,\n small: 800,\n medium: 1080,\n large: 1440,\n xlarge: 1920,\n xxlarge: 2560,\n};\n\nconst IMAGE_WIDTHS = [2720, 2080, 1760, 1440, 1120, 1000, 960, 800, 640, 480, 320, 240, 180];\n\nexport const getVariantSrcSet = (variants: ImageVariantDTO[]) => {\n return variants\n .map((variant) => {\n return `${variant.variantUrl} ${VAR_WIDTHS[variant.size]}w`;\n })\n .join(\", \");\n};\n\nexport const getVariantSizes = (variants: ImageVariantDTO[]) => {\n return variants\n .map((variant, i) => {\n if (i === variants.length - 1) {\n return `${VAR_WIDTHS[variant.size]}px`;\n }\n return `(max-width: ${VAR_WIDTHS[variant.size]}px) ${VAR_WIDTHS[variant.size]}px`;\n })\n .join(\", \");\n};\n\nexport const getSrcSet = ({ src, crop, focalPoint, imageLanguage }: SrcSetOptions) => {\n if (!src) return undefined;\n return IMAGE_WIDTHS.map((width) => {\n const queryString = makeSrcQueryString({ width, crop, focalPoint, imageLanguage });\n const query = queryString.length ? `?${queryString}` : \"\";\n return `${src}${query} ${width}w`;\n }).join(\", \");\n};\n\nconst FALLBACK_WIDTH = 1024;\n\nconst FALLBACK_SIZES = \"(min-width: 1024px) 1024px, 100vw\";\n\nexport interface PictureProps extends StyledProps, ComponentPropsWithRef<\"picture\"> {\n src: string;\n sizes?: string;\n contentType?: string;\n srcSet?: string;\n crop?: ImageCrop;\n focalPoint?: ImageFocalPoint;\n imageLanguage?: string;\n}\n\nexport const Picture = forwardRef<HTMLPictureElement, PictureProps>(\n (\n {\n children,\n srcSet: srcSetProp,\n crop,\n focalPoint,\n src,\n imageLanguage,\n contentType,\n sizes = FALLBACK_SIZES,\n ...props\n },\n ref,\n ) => {\n const srcSet = srcSetProp ?? getSrcSet({ src, crop, focalPoint, imageLanguage });\n\n return (\n <styled.picture {...props} ref={ref}>\n {contentType !== \"image/gif\" && <source type={contentType} srcSet={srcSet} sizes={sizes} />}\n {children}\n </styled.picture>\n );\n },\n);\n\nconst StyledImage = styled(\"img\", {\n defaultVariants: { variant: \"regular\" },\n variants: {\n variant: {\n regular: {},\n rounded: {\n borderRadius: \"xsmall\",\n },\n },\n },\n});\n\nconst StyledFallbackElement = styled(\n ark.div,\n {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n },\n { baseComponent: true },\n);\n\ntype ImageVariantProps = StyledVariantProps<typeof StyledImage>;\n\nexport interface ImgProps extends StyledProps, ComponentPropsWithRef<\"img\">, ImageVariantProps {\n alt: string;\n src: string;\n fallbackWidth?: number;\n contentType?: string;\n crop?: ImageCrop;\n imageLanguage?: string;\n focalPoint?: ImageFocalPoint;\n}\n\nexport const Img = forwardRef<HTMLImageElement, ImgProps>(\n ({ fallbackWidth = FALLBACK_WIDTH, crop, focalPoint, imageLanguage, contentType, src, alt, ...props }, ref) => {\n const queryString = makeSrcQueryString({ width: fallbackWidth, crop, focalPoint, imageLanguage });\n const srcWithParms = queryString ? `${src}?${queryString}` : src;\n return <StyledImage alt={alt} src={contentType === \"image/gif\" ? src : srcWithParms} {...props} ref={ref} />;\n },\n);\n\nexport interface ImageProps extends StyledProps, ComponentPropsWithRef<\"img\">, ImageVariantProps {\n alt: string;\n src?: string;\n sizes?: string;\n fallbackWidth?: number;\n contentType?: string;\n imageLanguage?: string;\n crop?: ImageCrop;\n fallbackElement?: ReactNode;\n focalPoint?: ImageFocalPoint;\n variants?: ImageVariantDTO[];\n}\n\nexport const Image = forwardRef<HTMLImageElement, ImageProps>(\n (\n {\n srcSet: srcSetProp,\n crop,\n focalPoint,\n src,\n contentType,\n imageLanguage,\n fallbackWidth = FALLBACK_WIDTH,\n sizes: sizesProp,\n alt,\n fallbackElement,\n variants,\n ...props\n },\n ref,\n ) => {\n const [hasError, setHasError] = useState(false);\n\n useEffect(() => {\n setHasError(false);\n }, [src, srcSetProp, sizesProp, variants]);\n\n if (!src?.length && !variants?.length && fallbackElement) {\n return (\n <StyledFallbackElement {...props} ref={ref}>\n {fallbackElement}\n </StyledFallbackElement>\n );\n }\n\n const queryString = makeSrcQueryString({ width: fallbackWidth, crop, focalPoint, imageLanguage });\n const fallbackSrc = src && queryString ? `${src}?${queryString}` : src;\n\n return (\n <picture>\n {!!variants?.length && !crop && !focalPoint && contentType !== \"image/gif\" && (\n <source\n type={\"image/webp\"}\n srcSet={getVariantSrcSet(variants)}\n sizes={sizesProp ?? getVariantSizes(variants)}\n />\n )}\n {contentType !== \"image/gif\" && (\n <source\n type={contentType}\n srcSet={getSrcSet({ src, crop, focalPoint, imageLanguage })}\n sizes={sizesProp ?? FALLBACK_SIZES}\n />\n )}\n <StyledImage\n alt={alt}\n src={contentType === \"image/gif\" ? src : fallbackSrc}\n {...props}\n ref={ref}\n data-error={hasError ? \"\" : undefined}\n onError={(e) => {\n setHasError(true);\n props.onError?.(e);\n }}\n onLoad={(e) => {\n setHasError(false);\n props.onLoad?.(e);\n }}\n />\n </picture>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;AAiCA,MAAa,sBAAsB,EAAE,OAAO,MAAM,YAAY,oBAA2C;CACvG,MAAM,SAAS,EAAE;AACjB,KAAI,MACF,QAAO,KAAK,SAAS,QAAQ;AAE/B,KAAI,KACF,QAAO,KAAK,cAAc,KAAK,OAAO,YAAY,KAAK,KAAK,cAAc,KAAK,OAAO,YAAY,KAAK,OAAO;AAEhH,KAAI,WACF,QAAO,KAAK,UAAU,WAAW,EAAE,UAAU,WAAW,IAAI;AAE9D,KAAI,cACF,QAAO,KAAK,YAAY,gBAAgB;AAE1C,QAAO,OAAO,KAAK,IAAI;;AAUzB,MAAa,aAA+C;CAC1D,MAAM;CACN,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,SAAS;CACV;AAED,MAAM,eAAe;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAA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;;GAEpB,SAAS,MAAM;AACb,gBAAY,MAAM;AAClB,UAAM,SAAS,EAAE;;IAEnB;KACM;EAGf"}
|
package/lib/Input.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { RecipeVariantProps, StyledProps } from "@ndla/styled-system/types";
|
|
9
8
|
import { type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import type { RecipeVariantProps, StyledProps } from "@ndla/styled-system/types";
|
|
10
10
|
interface InputContainerProps extends HTMLArkProps<"div">, StyledProps {
|
|
11
11
|
}
|
|
12
12
|
export declare const InputContainer: import("react").ForwardRefExoticComponent<InputContainerProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/lib/Input.js
CHANGED
|
@@ -6,6 +6,13 @@ let react = require("react");
|
|
|
6
6
|
let _ndla_util = require("@ndla/util");
|
|
7
7
|
|
|
8
8
|
//#region src/Input.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) 2024-present, NDLA.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
9
16
|
const InputContext = (0, react.createContext)(void 0);
|
|
10
17
|
const inputCss = _ndla_styled_system_css.css.raw({
|
|
11
18
|
boxShadowColor: "stroke.subtle",
|
package/lib/Input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":["css","ark","Field"],"sources":["../src/Input.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
|
|
1
|
+
{"version":3,"file":"Input.js","names":["css","ark","Field"],"sources":["../src/Input.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 { Field, type HTMLArkProps, ark } from \"@ark-ui/react\";\nimport { css, cva } from \"@ndla/styled-system/css\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { RecipeVariantProps, StyledProps } from \"@ndla/styled-system/types\";\nimport { composeRefs } from \"@ndla/util\";\nimport { createContext, forwardRef, useCallback, useContext, useEffect, useRef } from \"react\";\n\ninterface InputContextType {}\n\nconst InputContext = createContext<InputContextType | undefined>(undefined);\n\nconst inputCss = css.raw({\n boxShadowColor: \"stroke.subtle\",\n boxShadow: \"inset 0 0 0 1px var(--shadow-color)\",\n background: \"background.default\",\n borderRadius: \"xsmall\",\n _ariaInvalid: {\n boxShadowColor: \"stroke.error\",\n _hover: {\n boxShadowColor: \"stroke.error\",\n },\n _focusWithin: {\n boxShadowColor: \"stroke.error\",\n _hover: {\n boxShadowColor: \"stroke.error\",\n },\n },\n },\n _hover: {\n boxShadowColor: \"stroke.hover\",\n },\n _focusWithin: {\n boxShadow: \"inset 0 0 0 2px var(--shadow-color)\",\n boxShadowColor: \"stroke.default\",\n _hover: {\n boxShadowColor: \"stroke.default\",\n },\n },\n \"&:disabled, &:has(:disabled)\": {\n boxShadowColor: \"stroke.subtle\",\n _hover: {\n boxShadowColor: \"stroke.subtle\",\n },\n },\n});\n\nconst StyledInputContainer = styled(\n ark.div,\n {\n base: {\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n \"& svg\": {\n width: \"medium\",\n height: \"medium\",\n },\n \"&:not(:has(input:first-child,textarea:first-child))\": {\n paddingInlineStart: \"xsmall\",\n },\n \"&:not(:has(input:last-child,textarea:last-child))\": {\n paddingInlineEnd: \"xsmall\",\n },\n },\n },\n { baseComponent: true },\n);\n\ninterface InputContainerProps extends HTMLArkProps<\"div\">, StyledProps {}\n\nexport const InputContainer = forwardRef<HTMLDivElement, InputContainerProps>(\n ({ children, css: cssProp, ...rest }, ref) => (\n <InputContext.Provider value={{}}>\n <StyledInputContainer css={css.raw(inputCss, cssProp)} {...rest} ref={ref}>\n {children}\n </StyledInputContainer>\n </InputContext.Provider>\n ),\n);\n\nconst baseInputCss = css.raw({\n width: \"100%\",\n color: \"text.default\",\n outline: \"none\",\n background: \"none\",\n border: \"0\",\n _disabled: {\n cursor: \"not-allowed\",\n },\n // Chrome messes with input styling when autofilling. Having a really long transitions cancels this out.\n _autofill: {\n transition: \"background-color 600000s 0s, color 600000s 0s\",\n },\n _focus: {\n appearance: \"none\",\n },\n _placeholder: {\n color: \"text.subtle\",\n },\n});\n\nconst baseTextAreaCss = css.raw({\n padding: \"xsmall\",\n minHeight: \"xxlarge\",\n height: \"xxlarge\",\n resize: \"none\",\n overflowY: \"hidden\",\n});\n\nconst StyledInput = styled(ark.input, {}, { baseComponent: true });\n\nconst inputRecipe = cva({\n defaultVariants: {\n componentSize: \"medium\",\n },\n variants: {\n componentSize: {\n small: {\n paddingBlock: \"4xsmall\",\n paddingInline: \"xsmall\",\n },\n medium: {\n minHeight: \"xxlarge\",\n padding: \"xsmall\",\n },\n },\n },\n});\n\ntype InputVariantProps = NonNullable<RecipeVariantProps<typeof inputRecipe>>;\n\nexport interface InputProps extends HTMLArkProps<\"input\">, StyledProps, InputVariantProps {}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(({ css: cssProp, componentSize, ...props }, ref) => {\n const context = useContext(InputContext);\n return (\n <StyledInput\n css={css.raw(inputRecipe.raw({ componentSize }), baseInputCss, context ? undefined : inputCss, cssProp)}\n ref={ref}\n {...props}\n />\n );\n});\n\nexport const FieldInput = forwardRef<HTMLInputElement, InputProps>((props, ref) => (\n <Field.Input asChild {...props} ref={ref}>\n <Input />\n </Field.Input>\n));\n\ninterface TextAreaProps extends HTMLArkProps<\"textarea\">, StyledProps {\n autoResize?: boolean;\n}\n\nconst StyledTextArea = styled(ark.textarea, {}, { baseComponent: true });\n\nexport const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n ({ css: cssProp, autoResize = true, ...props }, ref) => {\n const context = useContext(InputContext);\n const localRef = useRef<HTMLTextAreaElement>(null);\n\n // Automatically resize a textarea based on its content\n const resize = useCallback(() => {\n if (!localRef.current) return;\n localRef.current.style.height = \"0\";\n // TODO: Figure out if we need to add the 3 extra pixels, maybe related to scroll?\n localRef.current.style.height = `${localRef.current.scrollHeight + 3}px`;\n }, []);\n\n useEffect(() => {\n if (!autoResize) return;\n window.addEventListener(\"input\", resize);\n window.addEventListener(\"resize\", resize);\n resize();\n return () => {\n window.removeEventListener(\"input\", resize);\n window.removeEventListener(\"resize\", resize);\n };\n }, [resize, autoResize]);\n\n return (\n <StyledTextArea\n css={css.raw(baseInputCss, context ? undefined : inputCss, baseTextAreaCss, cssProp)}\n ref={composeRefs(ref, localRef)}\n {...props}\n />\n );\n },\n);\n\nexport const FieldTextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>((props, ref) => (\n <Field.Textarea asChild {...props} ref={ref}>\n <TextArea />\n </Field.Textarea>\n));\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,wCAA2D,OAAU;AAE3E,MAAM,WAAWA,4BAAI,IAAI;CACvB,gBAAgB;CAChB,WAAW;CACX,YAAY;CACZ,cAAc;CACd,cAAc;EACZ,gBAAgB;EAChB,QAAQ,EACN,gBAAgB,gBACjB;EACD,cAAc;GACZ,gBAAgB;GAChB,QAAQ,EACN,gBAAgB,gBACjB;GACF;EACF;CACD,QAAQ,EACN,gBAAgB,gBACjB;CACD,cAAc;EACZ,WAAW;EACX,gBAAgB;EAChB,QAAQ,EACN,gBAAgB,kBACjB;EACF;CACD,gCAAgC;EAC9B,gBAAgB;EAChB,QAAQ,EACN,gBAAgB,iBACjB;EACF;CACF,CAAC;AAEF,MAAM,2DACJC,kBAAI,KACJ,EACE,MAAM;CACJ,OAAO;CACP,SAAS;CACT,YAAY;CACZ,SAAS;EACP,OAAO;EACP,QAAQ;EACT;CACD,uDAAuD,EACrD,oBAAoB,UACrB;CACD,qDA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V,EAAE,KAAK,SAAS,aAAa,MAAM,GAAG,SAAS,QAAQ;CACtD,MAAM,gCAAqB,aAAa;CACxC,MAAM,6BAAuC,KAAK;CAGlD,MAAM,sCAA2B;AAC/B,MAAI,CAAC,SAAS,QAAS;AACvB,WAAS,QAAQ,MAAM,SAAS;AAEhC,WAAS,QAAQ,MAAM,SAAS,GAAG,SAAS,QAAQ,eAAe,EAAE;IACpE,EAAE,CAAC;AAEN,4BAAgB;AACd,MAAI,CAAC,WAAY;AACjB,SAAO,iBAAiB,SAAS,OAAO;AACxC,SAAO,iBAAiB,UAAU,OAAO;AACzC,UAAQ;AACR,eAAa;AACX,UAAO,oBAAoB,SAAS,OAAO;AAC3C,UAAO,oBAAoB,UAAU,OAAO;;IAE7C,CAAC,QAAQ,WAAW,CAAC;AAExB,QACE,2CAAC;EACC,KAAKD,4BAAI,IAAI,cAAc,UAAU,SAAY,UAAU,iBAAiB,QAAQ;EACpF,iCAAiB,KAAK,SAAS;EAC/B,GAAI;GACJ;EAGP;AAED,MAAa,uCAAgE,OAAO,QAClF,2CAACE,oBAAM;CAAS;CAAQ,GAAI;CAAY;WACtC,2CAAC,aAAW;EACG,CACjB"}
|
package/lib/Label.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { StyledProps } from "@ndla/styled-system/types";
|
|
9
8
|
import { Fieldset, type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import type { StyledProps } from "@ndla/styled-system/types";
|
|
10
10
|
import { type TextProps } from "./Text";
|
|
11
11
|
export interface LegendProps extends Omit<HTMLArkProps<"legend">, "color">, StyledProps, TextProps {
|
|
12
12
|
}
|
package/lib/Label.js
CHANGED
|
@@ -5,6 +5,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
7
|
//#region src/Label.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) 2024-present, NDLA.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
8
15
|
const StyledLegend = (0, _ndla_styled_system_jsx.styled)(_ark_ui_react.ark.legend, { base: {
|
|
9
16
|
float: "left",
|
|
10
17
|
width: "inherit",
|
package/lib/Label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","names":["ark","css","Fieldset","Field"],"sources":["../src/Label.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
|
|
1
|
+
{"version":3,"file":"Label.js","names":["ark","css","Fieldset","Field"],"sources":["../src/Label.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 { Field, Fieldset, type HTMLArkProps, ark } from \"@ark-ui/react\";\nimport { css } from \"@ndla/styled-system/css\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledProps } from \"@ndla/styled-system/types\";\nimport { forwardRef } from \"react\";\nimport { type TextProps } from \"./Text\";\n\nconst StyledLegend = styled(\n ark.legend,\n {\n base: {\n float: \"left\",\n width: \"inherit\",\n _disabled: {\n color: \"text.subtle\",\n },\n },\n },\n { baseComponent: true },\n);\n\nexport interface LegendProps extends Omit<HTMLArkProps<\"legend\">, \"color\">, StyledProps, TextProps {}\n\nexport const Legend = forwardRef<HTMLLegendElement, LegendProps>(\n ({ textStyle = \"label.medium\", fontWeight = \"bold\", css: cssProp, srOnly, color, ...rest }, ref) => (\n <StyledLegend css={css.raw({ textStyle, fontWeight, srOnly, color }, cssProp)} {...rest} ref={ref} />\n ),\n);\n\nexport interface FieldsetLegendProps extends Omit<Fieldset.LegendProps, \"color\">, TextProps, StyledProps {}\n\nexport const FieldsetLegend = forwardRef<HTMLLegendElement, LegendProps>(({ children, ...props }, ref) => (\n <Fieldset.Legend asChild {...props} ref={ref}>\n <Legend>{children}</Legend>\n </Fieldset.Legend>\n));\n\nconst StyledLabel = styled(\n ark.label,\n {\n base: {\n display: \"inline-block\",\n _disabled: {\n color: \"text.subtle\",\n },\n },\n },\n { baseComponent: true },\n);\n\nexport interface LabelProps extends Omit<HTMLArkProps<\"label\">, \"color\">, TextProps, StyledProps {}\n\nexport const Label = forwardRef<HTMLLabelElement, LabelProps>(\n ({ textStyle = \"label.medium\", fontWeight = \"bold\", css: cssProp, srOnly, color, ...rest }, ref) => (\n <StyledLabel css={css.raw({ textStyle, fontWeight, srOnly, color }, cssProp)} {...rest} ref={ref} />\n ),\n);\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, LabelProps>(({ children, ...props }, ref) => (\n <Field.Label asChild {...props} ref={ref}>\n <Label>{children}</Label>\n </Field.Label>\n));\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,mDACJA,kBAAI,QACJ,EACE,MAAM;CACJ,OAAO;CACP,OAAO;CACP,WAAW,EACT,OAAO,eACR;CACF,EACF,EACD,EAAE,eAAe,MAAM,CACxB;AAID,MAAa,gCACV,EAAE,YAAY,gBAAgB,aAAa,QAAQ,KAAK,SAAS,QAAQ,OAAO,GAAG,QAAQ,QAC1F,2CAAC;CAAa,KAAKC,4BAAI,IAAI;EAAE;EAAW;EAAY;EAAQ;EAAO,EAAE,QAAQ;CAAE,GAAI;CAAW;EAAO,CAExG;AAID,MAAa,wCAA6D,EAAE,UAAU,GAAG,SAAS,QAChG,2CAACC,uBAAS;CAAO;CAAQ,GAAI;CAAY;WACvC,2CAAC,UAAQ,WAAkB;EACX,CAClB;AAEF,MAAM,kDACJF,kBAAI,OACJ,EACE,MAAM;CACJ,SAAS;CACT,WAAW,EACT,OAAO,eACR;CACF,EACF,EACD,EAAE,eAAe,MAAM,CACxB;AAID,MAAa,+BACV,EAAE,YAAY,gBAAgB,aAAa,QAAQ,KAAK,SAAS,QAAQ,OAAO,GAAG,QAAQ,QAC1F,2CAAC;CAAY,KAAKC,4BAAI,IAAI;EAAE;EAAW;EAAY;EAAQ;EAAO,EAAE,QAAQ;CAAE,GAAI;CAAW;EAAO,CAEvG;AAED,MAAa,oCAAuD,EAAE,UAAU,GAAG,SAAS,QAC1F,2CAACE,oBAAM;CAAM;CAAQ,GAAI;CAAY;WACnC,2CAAC,SAAO,WAAiB;EACb,CACd"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
9
8
|
import { type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
10
10
|
import { type PageContentVariantProps } from "./PageContent";
|
|
11
11
|
declare const pageContainerRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
12
12
|
padding: {
|
|
@@ -5,6 +5,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
7
|
//#region src/Layout/PageContainer.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) 2024-present, NDLA.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
8
15
|
const pageContainerRecipe = (0, _ndla_styled_system_css.cva)({
|
|
9
16
|
defaultVariants: { padding: "medium" },
|
|
10
17
|
variants: { padding: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageContainer.js","names":["PageContent","css"],"sources":["../../src/Layout/PageContainer.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
|
|
1
|
+
{"version":3,"file":"PageContainer.js","names":["PageContent","css"],"sources":["../../src/Layout/PageContainer.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 HTMLArkProps } from \"@ark-ui/react\";\nimport { css, cva } from \"@ndla/styled-system/css\";\nimport type { StyledProps, RecipeVariantProps } from \"@ndla/styled-system/types\";\nimport { forwardRef } from \"react\";\nimport { PageContent, type PageContentVariantProps } from \"./PageContent\";\n\nconst pageContainerRecipe = cva({\n defaultVariants: {\n padding: \"medium\",\n },\n variants: {\n padding: {\n none: {},\n small: {\n paddingBlockStart: \"medium\",\n paddingBlockEnd: \"5xlarge\",\n },\n medium: {\n paddingBlockStart: \"xxlarge\",\n paddingBlockEnd: \"5xlarge\",\n },\n large: {\n paddingBlockStart: \"4xlarge\",\n paddingBlockEnd: \"5xlarge\",\n },\n },\n },\n});\n\nexport type PageContainerVariantProps = NonNullable<RecipeVariantProps<typeof pageContainerRecipe>>;\n\nexport interface PageContainerProps\n extends HTMLArkProps<\"div\">, StyledProps, PageContentVariantProps, PageContainerVariantProps {}\n\nexport const PageContainer = forwardRef<HTMLDivElement, PageContainerProps>(\n ({ padding, css: cssProp, ...props }, ref) => (\n <PageContent css={css.raw(pageContainerRecipe.raw({ padding }), cssProp)} {...props} ref={ref} />\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,uDAA0B;CAC9B,iBAAiB,EACf,SAAS,UACV;CACD,UAAU,EACR,SAAS;EACP,MAAM,EAAE;EACR,OAAO;GACL,mBAAmB;GACnB,iBAAiB;GAClB;EACD,QAAQ;GACN,mBAAmB;GACnB,iBAAiB;GAClB;EACD,OAAO;GACL,mBAAmB;GACnB,iBAAiB;GAClB;EACF,EACF;CACF,CAAC;AAOF,MAAa,uCACV,EAAE,SAAS,KAAK,SAAS,GAAG,SAAS,QACpC,2CAACA;CAAY,KAAKC,4BAAI,IAAI,oBAAoB,IAAI,EAAE,SAAS,CAAC,EAAE,QAAQ;CAAE,GAAI;CAAY;EAAO,CAEpG"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
9
8
|
import { type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
10
10
|
declare const pageRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
11
11
|
variant: {
|
|
12
12
|
content: {
|
|
@@ -5,6 +5,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
7
|
//#region src/Layout/PageContent.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) 2024-present, NDLA.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
8
15
|
const pageRecipe = (0, _ndla_styled_system_css.cva)({
|
|
9
16
|
base: {
|
|
10
17
|
display: "grid",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageContent.js","names":["ark","css"],"sources":["../../src/Layout/PageContent.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
|
|
1
|
+
{"version":3,"file":"PageContent.js","names":["ark","css"],"sources":["../../src/Layout/PageContent.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 HTMLArkProps, ark } 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 pageRecipe = cva({\n base: {\n display: \"grid\",\n transitionProperty: \"all\",\n transitionDuration: \"default\",\n transitionTimingFunction: \"default\",\n alignContent: \"start\",\n /**\n * var(--size) is the max width of the content\n * calc(100% - (var(--gutter, 0) * 2)) is the max width of the page, minus the gutters (inline padding without being actual padding).\n * In effect, this will center the content on the page, and constrain it to either the content width or the page width, whichever is smaller.\n */\n gridColumnGap: \"var(--gutter, 0)\",\n gridTemplateColumns: \"1fr min(var(--size), calc(100% - (var(--gutter, 0) * 2))) 1fr\",\n \"& > *\": {\n gridColumnStart: \"2\",\n gridColumnEnd: \"2\",\n },\n },\n defaultVariants: {\n variant: \"page\",\n gutters: \"always\",\n },\n variants: {\n variant: {\n content: {\n \"--size\": \"sizes.surface.contentMax\",\n },\n article: {\n \"--size\": \"sizes.surface.articleMax\",\n },\n page: {\n \"--size\": \"sizes.surface.pageMax\",\n },\n wide: {\n \"--size\": \"sizes.surface.wideMax\",\n },\n },\n gutters: {\n never: {\n \"--gutter\": \"0px\",\n },\n mobileUp: {\n \"--gutter\": \"0px\",\n mobileWide: {\n \"--gutter\": \"spacing.medium\",\n },\n },\n tabletUp: {\n \"--gutter\": \"0px\",\n tablet: {\n \"--gutter\": \"spacing.medium\",\n },\n },\n always: {\n \"--gutter\": \"spacing.small\",\n tablet: {\n \"--gutter\": \"spacing.medium\",\n },\n },\n },\n },\n});\n\nconst StyledPageContent = styled(ark.div, {}, { baseComponent: true });\n\nexport type PageContentVariantProps = NonNullable<RecipeVariantProps<typeof pageRecipe>>;\n\nexport interface PageContentProps extends HTMLArkProps<\"div\">, StyledProps, PageContentVariantProps {}\n\nexport const PageContent = forwardRef<HTMLDivElement, PageContentProps>(\n ({ variant, gutters, css: cssProp, ...props }, ref) => (\n <StyledPageContent css={css.raw(pageRecipe.raw({ variant, gutters }), cssProp)} ref={ref} {...props} />\n ),\n);\n\nexport const BleedPageContent = styled(\n ark.div,\n {\n base: {\n \"& \": {\n width: \"100%\",\n gridColumnStart: \"1\",\n gridColumnEnd: \"-1\",\n },\n },\n },\n { baseComponent: true },\n);\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,8CAAiB;CACrB,MAAM;EACJ,SAAS;EACT,oBAAoB;EACpB,oBAAoB;EACpB,0BAA0B;EAC1B,cAAc;EAMd,eAAe;EACf,qBAAqB;EACrB,SAAS;GACP,iBAAiB;GACjB,eAAe;GAChB;EACF;CACD,iBAAiB;EACf,SAAS;EACT,SAAS;EACV;CACD,UAAU;EACR,SAAS;GACP,SAAS,EACP,UAAU,4BACX;GACD,SAAS,EACP,UAAU,4BACX;GACD,MAAM,EACJ,UAAU,yBACX;GACD,MAAM,EACJ,UAAU,yBACX;GACF;EACD,SAAS;GACP,OAAO,EACL,YAAY,OACb;GACD,UAAU;IACR,YAAY;IACZ,YAAY,EACV,YAAY,kBACb;IACF;GACD,UAAU;IACR,YAAY;IACZ,QAAQ,EACN,YAAY,kBACb;IACF;GACD,QAAQ;IACN,YAAY;IACZ,QAAQ,EACN,YAAY,kBACb;IACF;GACF;EACF;CACF,CAAC;AAEF,MAAM,wDAA2BA,kBAAI,KAAK,EAAE,EAAE,EAAE,eAAe,MAAM,CAAC;AAMtE,MAAa,qCACV,EAAE,SAAS,SAAS,KAAK,SAAS,GAAG,SAAS,QAC7C,2CAAC;CAAkB,KAAKC,4BAAI,IAAI,WAAW,IAAI;EAAE;EAAS;EAAS,CAAC,EAAE,QAAQ;CAAO;CAAK,GAAI;EAAS,CAE1G;AAED,MAAa,uDACXD,kBAAI,KACJ,EACE,MAAM,EACJ,MAAM;CACJ,OAAO;CACP,iBAAiB;CACjB,eAAe;CAChB,EACF,EACF,EACD,EAAE,eAAe,MAAM,CACxB"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
9
8
|
import { type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
10
10
|
import { type ImageProps } from "../Image";
|
|
11
11
|
import { type TextProps } from "../Text";
|
|
12
12
|
export declare const listItemRecipe: import("@ndla/styled-system/types").SlotRecipeRuntimeFn<"root" | "content" | "title" | "image", {
|
package/lib/ListItem/ListItem.js
CHANGED
|
@@ -7,6 +7,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
|
|
9
9
|
//#region src/ListItem/ListItem.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) 2024-present, NDLA.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
10
17
|
const listItemRecipe = (0, _ndla_styled_system_css.sva)({
|
|
11
18
|
slots: [
|
|
12
19
|
"root",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["ark","Heading","Image"],"sources":["../../src/ListItem/ListItem.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
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["ark","Heading","Image"],"sources":["../../src/ListItem/ListItem.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 HTMLArkProps, ark } from \"@ark-ui/react\";\nimport { sva } from \"@ndla/styled-system/css\";\nimport { createStyleContext } from \"@ndla/styled-system/jsx\";\nimport type { StyledProps, RecipeVariantProps } from \"@ndla/styled-system/types\";\nimport { forwardRef } from \"react\";\nimport { Image, type ImageProps } from \"../Image\";\nimport { Heading, type TextProps } from \"../Text\";\n\nexport const listItemRecipe = sva({\n slots: [\"root\", \"title\", \"content\", \"image\"],\n base: {\n root: {\n minHeight: \"3xlarge\",\n borderStyle: \"solid\",\n borderWidth: \"1px\",\n borderColor: \"stroke.subtle\",\n backgroundColor: \"background.default\",\n color: \"text.default\",\n position: \"relative\",\n display: \"flex\",\n gap: \"small\",\n alignItems: \"center\",\n paddingBlock: \"xsmall\",\n paddingInline: \"xxsmall\",\n transitionProperty: \"background-color, border-color, color\",\n transitionDuration: \"superFast\",\n transitionTimingFunction: \"ease-in-out\",\n boxShadow: \"xsmall\",\n },\n content: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: \"xsmall\",\n width: \"100%\",\n },\n image: {\n minHeight: \"50px\",\n maxHeight: \"50px\",\n minWidth: \"70px\",\n maxWidth: \"70px\",\n objectFit: \"cover\",\n },\n },\n defaultVariants: {\n nonInteractive: false,\n },\n variants: {\n nonInteractive: {\n false: {\n root: {\n _highlighted: {\n borderColor: \"stroke.hover\",\n backgroundColor: \"surface.hover\",\n },\n _hover: {\n borderColor: \"stroke.hover\",\n backgroundColor: \"surface.hover\",\n },\n _active: {\n borderColor: \"stroke.hover\",\n backgroundColor: \"surface.active\",\n },\n },\n title: {\n textDecoration: \"underline\",\n _hover: {\n textDecoration: \"none\",\n },\n },\n },\n },\n },\n});\n\nconst { withProvider, withContext } = createStyleContext(listItemRecipe);\n\nexport type ListItemVariantProps = NonNullable<RecipeVariantProps<typeof listItemRecipe>>;\n\nexport interface ListItemProps extends HTMLArkProps<\"div\">, StyledProps, ListItemVariantProps {}\n\nexport const ListItemRoot = withProvider(ark.div, \"root\", { baseComponent: true });\n\ninterface ListItemHeadingProps extends Omit<HTMLArkProps<\"p\">, \"color\">, TextProps {}\n\nconst InternalListItemHeading = forwardRef<HTMLHeadingElement, ListItemHeadingProps>(\n ({ textStyle = \"label.medium\", fontWeight = \"bold\", ...props }, ref) => (\n <Heading textStyle={textStyle} fontWeight={fontWeight} {...props} ref={ref} />\n ),\n);\n\nexport const ListItemHeading = withContext(InternalListItemHeading, \"title\");\n\nexport const ListItemContent = withContext(ark.div, \"content\", { baseComponent: true });\n\nconst InternalListItemImage = withContext(Image, \"image\");\n\nexport const ListItemImage = forwardRef<HTMLImageElement, ImageProps>(({ variant = \"rounded\", ...props }, ref) => (\n <InternalListItemImage variant={variant} {...props} ref={ref} />\n));\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,kDAAqB;CAChC,OAAO;EAAC;EAAQ;EAAS;EAAW;EAAQ;CAC5C,MAAM;EACJ,MAAM;GACJ,WAAW;GACX,aAAa;GACb,aAAa;GACb,aAAa;GACb,iBAAiB;GACjB,OAAO;GACP,UAAU;GACV,SAAS;GACT,KAAK;GACL,YAAY;GACZ,cAAc;GACd,eAAe;GACf,oBAAoB;GACpB,oBAAoB;GACpB,0BAA0B;GAC1B,WAAW;GACZ;EACD,SAAS;GACP,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,KAAK;GACL,OAAO;GACR;EACD,OAAO;GACL,WAAW;GACX,WAAW;GACX,UAAU;GACV,UAAU;GACV,WAAW;GACZ;EACF;CACD,iBAAiB,EACf,gBAAgB,OACjB;CACD,UAAU,EACR,gBAAgB,EACd,OAAO;EACL,MAAM;GACJ,cAAc;IACZ,aAAa;IACb,iBAAiB;IAClB;GACD,QAAQ;IACN,aAAa;IACb,iBAAiB;IAClB;GACD,SAAS;IACP,aAAa;IACb,iBAAiB;IAClB;GACF;EACD,OAAO;GACL,gBAAgB;GAChB,QAAQ,EACN,gBAAgB,QACjB;GACF;EACF,EACF,EACF;CACF,CAAC;AAEF,MAAM,EAAE,cAAc,gEAAmC,eAAe;AAMxE,MAAa,eAAe,aAAaA,kBAAI,KAAK,QAAQ,EAAE,eAAe,MAAM,CAAC;AAIlF,MAAM,iDACH,EAAE,YAAY,gBAAgB,aAAa,QAAQ,GAAG,SAAS,QAC9D,2CAACC;CAAmB;CAAuB;CAAY,GAAI;CAAY;EAAO,CAEjF;AAED,MAAa,kBAAkB,YAAY,yBAAyB,QAAQ;AAE5E,MAAa,kBAAkB,YAAYD,kBAAI,KAAK,WAAW,EAAE,eAAe,MAAM,CAAC;AAEvF,MAAM,wBAAwB,YAAYE,qBAAO,QAAQ;AAEzD,MAAa,uCAA0D,EAAE,UAAU,WAAW,GAAG,SAAS,QACxG,2CAAC;CAA+B;CAAS,GAAI;CAAY;EAAO,CAChE"}
|
package/lib/Menu.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { RecipeVariantProps, StyledProps } from "@ndla/styled-system/types";
|
|
9
8
|
import { Menu } from "@ark-ui/react";
|
|
9
|
+
import type { RecipeVariantProps, StyledProps } from "@ndla/styled-system/types";
|
|
10
10
|
import { type RefAttributes } from "react";
|
|
11
11
|
import { type TextProps } from "./Text";
|
|
12
12
|
declare const itemCva: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
@@ -32,17 +32,17 @@ declare const itemCva: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
|
32
32
|
"& svg": {
|
|
33
33
|
color: "icon.default";
|
|
34
34
|
};
|
|
35
|
-
background: "surface.
|
|
35
|
+
background: "surface.dangerSubtle.hover";
|
|
36
36
|
};
|
|
37
37
|
_highlighted: {
|
|
38
38
|
color: "text.default";
|
|
39
39
|
"& svg": {
|
|
40
40
|
color: "icon.default";
|
|
41
41
|
};
|
|
42
|
-
background: "surface.
|
|
42
|
+
background: "surface.dangerSubtle.hover";
|
|
43
43
|
};
|
|
44
44
|
_active: {
|
|
45
|
-
background: "surface.
|
|
45
|
+
background: "surface.dangerSubtle.active";
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
};
|
package/lib/Menu.js
CHANGED
|
@@ -6,6 +6,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
6
6
|
let react = require("react");
|
|
7
7
|
|
|
8
8
|
//#region src/Menu.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) 2024-present, NDLA.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
9
16
|
const itemStyle = _ndla_styled_system_css.css.raw({
|
|
10
17
|
display: "flex",
|
|
11
18
|
alignItems: "center",
|
|
@@ -47,14 +54,14 @@ const itemCva = (0, _ndla_styled_system_css.cva)({
|
|
|
47
54
|
_hover: {
|
|
48
55
|
color: "text.default",
|
|
49
56
|
"& svg": { color: "icon.default" },
|
|
50
|
-
background: "surface.
|
|
57
|
+
background: "surface.dangerSubtle.hover"
|
|
51
58
|
},
|
|
52
59
|
_highlighted: {
|
|
53
60
|
color: "text.default",
|
|
54
61
|
"& svg": { color: "icon.default" },
|
|
55
|
-
background: "surface.
|
|
62
|
+
background: "surface.dangerSubtle.hover"
|
|
56
63
|
},
|
|
57
|
-
_active: { background: "surface.
|
|
64
|
+
_active: { background: "surface.dangerSubtle.active" }
|
|
58
65
|
}
|
|
59
66
|
} }
|
|
60
67
|
});
|
package/lib/Menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","names":["css","menuAnatomy","Menu","Text"],"sources":["../src/Menu.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
|
|
1
|
+
{"version":3,"file":"Menu.js","names":["css","menuAnatomy","Menu","Text"],"sources":["../src/Menu.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 { Menu, menuAnatomy } from \"@ark-ui/react\";\nimport { css, cva, sva } from \"@ndla/styled-system/css\";\nimport { createStyleContext } from \"@ndla/styled-system/jsx\";\nimport type { RecipeVariantProps, StyledProps, SystemStyleObject } from \"@ndla/styled-system/types\";\nimport { forwardRef, type RefAttributes } from \"react\";\nimport { Text, type TextProps } from \"./Text\";\n\nconst itemStyle: SystemStyleObject = css.raw({\n display: \"flex\",\n alignItems: \"center\",\n borderRadius: \"xsmall\",\n cursor: \"pointer\",\n textStyle: \"label.medium\",\n paddingBlock: \"4xsmall\",\n paddingInline: \"xsmall\",\n gap: \"xsmall\",\n transitionDuration: \"fast\",\n transitionProperty: \"background, color\",\n transitionTimingFunction: \"default\",\n outline: \"none\",\n _hover: {\n textDecoration: \"underline\",\n },\n _highlighted: {\n textDecoration: \"underline\",\n },\n _disabled: {\n color: \"text.disabled\",\n cursor: \"not-allowed\",\n \"& svg\": {\n color: \"stroke.disabled\",\n },\n _hover: {\n color: \"text.disabled\",\n textDecoration: \"none\",\n background: \"surface.default\",\n \"& svg\": {\n color: \"stroke.disabled\",\n },\n },\n },\n});\n\nconst itemCva = cva({\n defaultVariants: {\n variant: \"action\",\n },\n variants: {\n variant: {\n action: {\n _hover: {\n background: \"surface.hover\",\n },\n _highlighted: {\n background: \"surface.hover\",\n },\n _active: {\n background: \"surface.active\",\n },\n },\n destructive: {\n color: \"text.error\",\n \"& svg\": {\n color: \"icon.error\",\n },\n _hover: {\n color: \"text.default\",\n \"& svg\": {\n color: \"icon.default\",\n },\n background: \"surface.dangerSubtle.hover\",\n },\n _highlighted: {\n color: \"text.default\",\n \"& svg\": {\n color: \"icon.default\",\n },\n background: \"surface.dangerSubtle.hover\",\n },\n _active: {\n background: \"surface.dangerSubtle.active\",\n },\n },\n },\n },\n});\n\nconst menuRecipe = sva({\n slots: menuAnatomy.keys(),\n base: {\n item: itemStyle,\n triggerItem: itemStyle,\n content: {\n color: \"text.default\",\n display: \"flex\",\n flexDirection: \"column\",\n width: \"fit-content\",\n minWidth: \"surface.xxsmall\",\n padding: \"3xsmall\",\n gap: \"3xsmall\",\n background: \"surface.default\",\n boxShadow: \"small\",\n borderRadius: \"xsmall\",\n outline: \"none\",\n zIndex: \"dropdown\",\n _open: {\n animation: \"fade-shift-in 0.25s ease-out\",\n _motionReduce: {\n animation: \"none\",\n },\n },\n _closed: {\n animation: \"fade-shift-out 0.25s ease-out\",\n _motionReduce: {\n animation: \"none\",\n },\n },\n },\n itemGroup: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"3xsmall\",\n },\n positioner: {\n zIndex: \"dropdown\",\n },\n },\n});\n\nconst { withRootProvider, withContext } = createStyleContext(menuRecipe);\n\nexport type MenuRootProps = Menu.RootProps;\n\nconst InternalMenuRoot = withRootProvider(Menu.Root);\n\nexport const MenuRoot = ({ lazyMount = true, unmountOnExit = true, ...props }: MenuRootProps) => (\n <InternalMenuRoot lazyMount={lazyMount} unmountOnExit={unmountOnExit} {...props} />\n);\n\nexport const MenuContentStandalone = withContext(Menu.Content, \"content\", { baseComponent: true });\n\ninterface MenuContentProps extends Menu.ContentProps, StyledProps {}\n\nexport const MenuContent = forwardRef<HTMLDivElement, MenuContentProps>((props, ref) => (\n <MenuPositioner>\n <MenuContentStandalone ref={ref} {...props} />\n </MenuPositioner>\n));\n\nconst InternalMenuItemGroupLabel = withContext(Menu.ItemGroupLabel, \"itemGroupLabel\");\n\ninterface MenuItemGroupLabelProps\n extends Omit<Menu.ItemGroupLabelProps, \"color\">, StyledProps, TextProps, RefAttributes<HTMLDivElement> {}\n\nexport const MenuItemGroupLabel = ({\n textStyle = \"label.medium\",\n fontWeight = \"bold\",\n children,\n ...props\n}: MenuItemGroupLabelProps) => (\n <InternalMenuItemGroupLabel {...props} asChild>\n <Text textStyle={textStyle} fontWeight={fontWeight}>\n {children}\n </Text>\n </InternalMenuItemGroupLabel>\n);\n\nexport const MenuItemGroup = withContext(Menu.ItemGroup, \"itemGroup\", { baseComponent: true });\n\nconst InternalMenuItem = withContext(Menu.Item, \"item\", { baseComponent: true });\n\nexport type MenuItemVariantProps = NonNullable<RecipeVariantProps<typeof itemCva>>;\nexport interface MenuItemProps\n extends Menu.ItemProps, StyledProps, MenuItemVariantProps, RefAttributes<HTMLDivElement> {}\n\nexport const MenuItem = forwardRef<HTMLDivElement, MenuItemProps>(({ css: cssProp = {}, variant, ...props }, ref) => (\n <InternalMenuItem\n css={[itemCva.raw({ variant }), ...(Array.isArray(cssProp) ? cssProp : [cssProp])]}\n {...props}\n ref={ref}\n />\n));\n\nexport const MenuPositioner = withContext(Menu.Positioner, \"positioner\", { baseComponent: true });\n\nconst InternalMenuTriggerItem = withContext(Menu.TriggerItem, \"triggerItem\", { baseComponent: true });\n\ninterface MenuTriggerItemProps\n extends Menu.TriggerItemProps, StyledProps, MenuItemVariantProps, RefAttributes<HTMLButtonElement> {}\n\nexport const MenuTriggerItem = forwardRef<HTMLDivElement, MenuTriggerItemProps>(\n ({ css: cssProp = {}, variant, ...props }, ref) => (\n <InternalMenuTriggerItem\n css={[itemCva.raw({ variant }), ...(Array.isArray(cssProp) ? cssProp : [cssProp])]}\n {...props}\n ref={ref}\n />\n ),\n);\n\nexport const MenuTrigger = withContext(Menu.Trigger, \"trigger\", { baseComponent: true });\n\nexport const MenuSeparator = withContext(Menu.Separator, \"separator\", { baseComponent: true });\n\nexport const MenuItemText = withContext(Menu.ItemText, \"itemText\", { baseComponent: true });\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,YAA+BA,4BAAI,IAAI;CAC3C,SAAS;CACT,YAAY;CACZ,cAAc;CACd,QAAQ;CACR,WAAW;CACX,cAAc;CACd,eAAe;CACf,KAAK;CACL,oBAAoB;CACpB,oBAAoB;CACpB,0BAA0B;CAC1B,SAAS;CACT,QAAQ,EACN,gBAAgB,aACjB;CACD,cAAc,EACZ,gBAAg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,CAAC"}
|
package/lib/MessageBox.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
9
8
|
import { type HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
10
10
|
declare const messageBoxRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
11
11
|
variant: {
|
|
12
12
|
info: {
|
package/lib/MessageBox.js
CHANGED
|
@@ -5,6 +5,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
7
|
//#region src/MessageBox.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) 2024-present, NDLA.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
8
15
|
const messageBoxRecipe = (0, _ndla_styled_system_css.cva)({
|
|
9
16
|
base: {
|
|
10
17
|
display: "flex",
|
package/lib/MessageBox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageBox.js","names":["ark","css"],"sources":["../src/MessageBox.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
|
|
1
|
+
{"version":3,"file":"MessageBox.js","names":["ark","css"],"sources":["../src/MessageBox.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 HTMLArkProps, ark } 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 messageBoxRecipe = cva({\n base: {\n display: \"flex\",\n alignItems: \"flex-start\",\n gap: \"small\",\n padding: \"medium\",\n border: \"1px solid\",\n borderRadius: \"xsmall\",\n },\n defaultVariants: {\n variant: \"info\",\n },\n variants: {\n variant: {\n info: {\n background: \"surface.infoSubtle\",\n borderColor: \"stroke.subtle\",\n },\n warning: {\n background: \"surface.warningSubtle\",\n borderColor: \"stroke.warning\",\n },\n success: {\n background: \"surface.successSubtle\",\n borderColor: \"stroke.success\",\n },\n error: {\n background: \"surface.errorSubtle\",\n borderColor: \"stroke.error\",\n },\n },\n },\n});\n\nexport type MessageBoxVariantProps = NonNullable<RecipeVariantProps<typeof messageBoxRecipe>>;\n\nexport interface MessageBoxProps extends HTMLArkProps<\"div\">, StyledProps, MessageBoxVariantProps {}\n\nconst StyledMessageBox = styled(ark.div, {}, { baseComponent: true });\n\nexport const MessageBox = forwardRef<HTMLDivElement, MessageBoxProps>(({ variant, css: cssProp, ...props }, ref) => (\n <StyledMessageBox css={css.raw(messageBoxRecipe.raw({ variant }), cssProp)} {...props} ref={ref} />\n));\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,oDAAuB;CAC3B,MAAM;EACJ,SAAS;EACT,YAAY;EACZ,KAAK;EACL,SAAS;EACT,QAAQ;EACR,cAAc;EACf;CACD,iBAAiB,EACf,SAAS,QACV;CACD,UAAU,EACR,SAAS;EACP,MAAM;GACJ,YAAY;GACZ,aAAa;GACd;EACD,SAAS;GACP,YAAY;GACZ,aAAa;GACd;EACD,SAAS;GACP,YAAY;GACZ,aAAa;GACd;EACD,OAAO;GACL,YAAY;GACZ,aAAa;GACd;EACF,EACF;CACF,CAAC;AAMF,MAAM,uDAA0BA,kBAAI,KAAK,EAAE,EAAE,EAAE,eAAe,MAAM,CAAC;AAErE,MAAa,oCAA0D,EAAE,SAAS,KAAK,SAAS,GAAG,SAAS,QAC1G,2CAAC;CAAiB,KAAKC,4BAAI,IAAI,iBAAiB,IAAI,EAAE,SAAS,CAAC,EAAE,QAAQ;CAAE,GAAI;CAAY;EAAO,CACnG"}
|
package/lib/NdlaLogo.js
CHANGED
|
@@ -4,6 +4,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
4
4
|
let react = require("react");
|
|
5
5
|
|
|
6
6
|
//#region src/NdlaLogo.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) 2024-present, NDLA.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
7
14
|
const BaseSvg = ({ color = "primary", "aria-hidden": ariaHidden = true, css: cssProp, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_styled_system_jsx.styled.svg, {
|
|
8
15
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9
16
|
"aria-hidden": ariaHidden,
|