@ndla/primitives 0.0.15 → 0.0.17
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 +6 -4
- package/dist/styles.css +325 -315
- package/es/Button.js +2 -1
- package/es/Figure.js +21 -4
- package/es/Image.js +92 -0
- package/es/Input.js +1 -1
- package/es/createStyleContext.js +2 -2
- package/es/index.js +2 -1
- package/lib/Button.d.ts +1 -1
- package/lib/Button.js +2 -1
- package/lib/Figure.d.ts +3 -3
- package/lib/Figure.js +21 -4
- package/lib/Image.d.ts +49 -0
- package/lib/Image.js +100 -0
- package/lib/Input.js +1 -1
- package/lib/createStyleContext.js +2 -2
- package/lib/index.d.ts +4 -1
- package/lib/index.js +37 -0
- package/package.json +5 -5
package/es/Button.js
CHANGED
|
@@ -11,6 +11,7 @@ import { ark } from "@ark-ui/react";
|
|
|
11
11
|
import { css, cva } from "@ndla/styled-system/css";
|
|
12
12
|
import { styled } from "@ndla/styled-system/jsx";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
// TODO: Consider if any of the backgrounds should actually be transparent
|
|
14
15
|
export const buttonBaseRecipe = cva({
|
|
15
16
|
base: {
|
|
16
17
|
display: "inline-flex",
|
|
@@ -67,7 +68,7 @@ export const buttonBaseRecipe = cva({
|
|
|
67
68
|
},
|
|
68
69
|
secondary: {
|
|
69
70
|
color: "text.strong",
|
|
70
|
-
background: "
|
|
71
|
+
background: "surface.default",
|
|
71
72
|
boxShadow: "inset 0 0 0 1px var(--shadow-color)",
|
|
72
73
|
_hover: {
|
|
73
74
|
background: "surface.actionSubtle.hover"
|
package/es/Figure.js
CHANGED
|
@@ -52,15 +52,13 @@ const figureRecipe = cva({
|
|
|
52
52
|
left: {
|
|
53
53
|
tablet: {
|
|
54
54
|
float: "left",
|
|
55
|
-
clear: "left"
|
|
56
|
-
paddingInlineEnd: "medium"
|
|
55
|
+
clear: "left"
|
|
57
56
|
}
|
|
58
57
|
},
|
|
59
58
|
right: {
|
|
60
59
|
tablet: {
|
|
61
60
|
float: "right",
|
|
62
|
-
clear: "right"
|
|
63
|
-
paddingInlineStart: "medium"
|
|
61
|
+
clear: "right"
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
}
|
|
@@ -75,6 +73,25 @@ const figureRecipe = cva({
|
|
|
75
73
|
left: "auto",
|
|
76
74
|
marginBlock: "xsmall"
|
|
77
75
|
}
|
|
76
|
+
}, {
|
|
77
|
+
float: "left",
|
|
78
|
+
size: ["medium", "small", "xsmall"],
|
|
79
|
+
css: {
|
|
80
|
+
paddingInlineEnd: "medium"
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
float: "right",
|
|
84
|
+
size: ["medium", "small", "xsmall"],
|
|
85
|
+
css: {
|
|
86
|
+
paddingInlineStart: "medium"
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
float: ["left", "right"],
|
|
90
|
+
size: ["full"],
|
|
91
|
+
css: {
|
|
92
|
+
paddingInlineStart: "0",
|
|
93
|
+
paddingInlineEnd: "0"
|
|
94
|
+
}
|
|
78
95
|
}]
|
|
79
96
|
});
|
|
80
97
|
const StyledFigure = styled(ark.figure, {}, {
|
package/es/Image.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { forwardRef } from "react";
|
|
10
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
export const makeSrcQueryString = (width, crop, focalPoint) => {
|
|
13
|
+
const widthParams = width && `width=${width}`;
|
|
14
|
+
const cropParams = crop && `cropStartX=${crop.startX}&cropEndX=${crop.endX}&cropStartY=${crop.startY}&cropEndY=${crop.endY}`;
|
|
15
|
+
const focalPointParams = focalPoint && `focalX=${focalPoint.x}&focalY=${focalPoint.y}`;
|
|
16
|
+
const params = [widthParams, cropParams, focalPointParams].filter(p => p).join("&");
|
|
17
|
+
return params;
|
|
18
|
+
};
|
|
19
|
+
export const getSrcSet = (src, crop, focalPoint) => {
|
|
20
|
+
const widths = [2720, 2080, 1760, 1440, 1120, 1000, 960, 800, 640, 480, 320, 240, 180];
|
|
21
|
+
return widths.map(width => `${src}?${makeSrcQueryString(width, crop, focalPoint)} ${width}w`).join(", ");
|
|
22
|
+
};
|
|
23
|
+
const FALLBACK_WIDTH = 1024;
|
|
24
|
+
const FALLBACK_SIZES = "(min-width: 1024px) 1024px, 100vw";
|
|
25
|
+
export const Picture = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
26
|
+
let {
|
|
27
|
+
children,
|
|
28
|
+
srcSet: srcSetProp,
|
|
29
|
+
crop,
|
|
30
|
+
focalPoint,
|
|
31
|
+
src,
|
|
32
|
+
contentType,
|
|
33
|
+
sizes = FALLBACK_SIZES,
|
|
34
|
+
...props
|
|
35
|
+
} = _ref;
|
|
36
|
+
const srcSet = srcSetProp ?? getSrcSet(src, crop, focalPoint);
|
|
37
|
+
return /*#__PURE__*/_jsxs(styled.picture, {
|
|
38
|
+
...props,
|
|
39
|
+
ref: ref,
|
|
40
|
+
children: [contentType !== "image/gif" && /*#__PURE__*/_jsx("source", {
|
|
41
|
+
type: contentType,
|
|
42
|
+
srcSet: srcSet,
|
|
43
|
+
sizes: sizes
|
|
44
|
+
}), children]
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
export const Img = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
48
|
+
let {
|
|
49
|
+
fallbackWidth = FALLBACK_WIDTH,
|
|
50
|
+
crop,
|
|
51
|
+
focalPoint,
|
|
52
|
+
contentType,
|
|
53
|
+
src,
|
|
54
|
+
alt,
|
|
55
|
+
...props
|
|
56
|
+
} = _ref2;
|
|
57
|
+
const queryString = makeSrcQueryString(fallbackWidth, crop, focalPoint);
|
|
58
|
+
return /*#__PURE__*/_jsx(styled.img, {
|
|
59
|
+
alt: alt,
|
|
60
|
+
src: contentType === "image/gif" ? src : `${src}?${queryString}`,
|
|
61
|
+
...props,
|
|
62
|
+
ref: ref
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
export const Image = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
66
|
+
let {
|
|
67
|
+
children,
|
|
68
|
+
srcSet: srcSetProp,
|
|
69
|
+
crop,
|
|
70
|
+
focalPoint,
|
|
71
|
+
src,
|
|
72
|
+
contentType,
|
|
73
|
+
fallbackWidth = FALLBACK_WIDTH,
|
|
74
|
+
sizes = FALLBACK_SIZES,
|
|
75
|
+
alt,
|
|
76
|
+
...props
|
|
77
|
+
} = _ref3;
|
|
78
|
+
const srcSet = srcSetProp ?? getSrcSet(src, crop, focalPoint);
|
|
79
|
+
const queryString = makeSrcQueryString(fallbackWidth, crop, focalPoint);
|
|
80
|
+
return /*#__PURE__*/_jsxs("picture", {
|
|
81
|
+
children: [contentType !== "image/gif" && /*#__PURE__*/_jsx("source", {
|
|
82
|
+
type: contentType,
|
|
83
|
+
srcSet: srcSet,
|
|
84
|
+
sizes: sizes
|
|
85
|
+
}), /*#__PURE__*/_jsx(styled.img, {
|
|
86
|
+
alt: alt,
|
|
87
|
+
src: contentType === "image/gif" ? src : `${src}?${queryString}`,
|
|
88
|
+
...props,
|
|
89
|
+
ref: ref
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
});
|
package/es/Input.js
CHANGED
|
@@ -141,7 +141,7 @@ export const TextArea = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
141
141
|
const resize = useCallback(() => {
|
|
142
142
|
if (!localRef.current) return;
|
|
143
143
|
localRef.current.style.height = "0";
|
|
144
|
-
localRef.current.style.height =
|
|
144
|
+
localRef.current.style.height = `${localRef.current.scrollHeight + 3}px`;
|
|
145
145
|
}, []);
|
|
146
146
|
useEffect(() => {
|
|
147
147
|
window.addEventListener("input", resize);
|
package/es/createStyleContext.js
CHANGED
|
@@ -46,7 +46,7 @@ export const createStyleContext = recipe => {
|
|
|
46
46
|
children: /*#__PURE__*/_jsx(StyledComponent, {
|
|
47
47
|
...otherProps,
|
|
48
48
|
ref: ref,
|
|
49
|
-
css: css.raw(slotStyles
|
|
49
|
+
css: css.raw(slotStyles?.[slot], cssProp)
|
|
50
50
|
})
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -65,7 +65,7 @@ export const createStyleContext = recipe => {
|
|
|
65
65
|
return /*#__PURE__*/_jsx(StyledComponent, {
|
|
66
66
|
...props,
|
|
67
67
|
ref: ref,
|
|
68
|
-
css: css.raw(slotStyles
|
|
68
|
+
css: css.raw(slotStyles?.[slot], cssProp)
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
};
|
package/es/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export { AccordionRoot, AccordionItemContent, AccordionItemIndicator, AccordionI
|
|
|
10
10
|
export { OrderedList, UnOrderedList, DefinitionList } from "./ArticleLists";
|
|
11
11
|
export { Badge } from "./Badge";
|
|
12
12
|
export { BlockQuote } from "./BlockQuote";
|
|
13
|
-
export { Button, IconButton } from "./Button";
|
|
13
|
+
export { Button, IconButton, buttonBaseRecipe, buttonRecipe, iconButtonRecipe } from "./Button";
|
|
14
14
|
export { CheckboxRoot, CheckboxIndicator, CheckboxLabel, CheckboxControl, CheckboxGroup, CheckboxHiddenInput } from "./Checkbox";
|
|
15
15
|
export { ComboboxRoot, ComboboxClearTrigger, ComboboxContent, ComboboxControl, ComboboxInput, ComboboxItemGroupLabel, ComboboxItemGroup, ComboboxItemIndicator, ComboboxItem, ComboboxItemText, ComboboxLabel, ComboboxPositioner, ComboboxTrigger } from "./Combobox";
|
|
16
16
|
export { DialogRoot, DialogBackdrop, DialogStandaloneContent, DialogPositioner, DialogContent, DialogDescription, DialogTitle, DialogTrigger, DialogCloseTrigger, DialogHeader, DialogBody } from "./Dialog";
|
|
@@ -20,6 +20,7 @@ export { FieldErrorMessage } from "./FieldErrorMessage";
|
|
|
20
20
|
export { FieldHelper } from "./FieldHelper";
|
|
21
21
|
export { Figure } from "./Figure";
|
|
22
22
|
export { FramedContent } from "./FramedContent";
|
|
23
|
+
export { Picture, Img, Image } from "./Image";
|
|
23
24
|
export { Input, FieldInput, InputContainer, TextArea, FieldTextArea } from "./Input";
|
|
24
25
|
export { Label, FieldLabel } from "./Label";
|
|
25
26
|
export { MenuRoot, MenuContent, MenuItemGroupLabel, MenuItemGroup, MenuItem, MenuPositioner, MenuTriggerItem, MenuTrigger, MenuSeparator } from "./Menu";
|
package/lib/Button.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare const buttonBaseRecipe: import("@ndla/styled-system/types").Recip
|
|
|
27
27
|
};
|
|
28
28
|
secondary: {
|
|
29
29
|
color: "text.strong";
|
|
30
|
-
background: "
|
|
30
|
+
background: "surface.default";
|
|
31
31
|
boxShadow: "inset 0 0 0 1px var(--shadow-color)";
|
|
32
32
|
_hover: {
|
|
33
33
|
background: "surface.actionSubtle.hover";
|
package/lib/Button.js
CHANGED
|
@@ -17,6 +17,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
// TODO: Consider if any of the backgrounds should actually be transparent
|
|
20
21
|
const buttonBaseRecipe = exports.buttonBaseRecipe = (0, _css.cva)({
|
|
21
22
|
base: {
|
|
22
23
|
display: "inline-flex",
|
|
@@ -73,7 +74,7 @@ const buttonBaseRecipe = exports.buttonBaseRecipe = (0, _css.cva)({
|
|
|
73
74
|
},
|
|
74
75
|
secondary: {
|
|
75
76
|
color: "text.strong",
|
|
76
|
-
background: "
|
|
77
|
+
background: "surface.default",
|
|
77
78
|
boxShadow: "inset 0 0 0 1px var(--shadow-color)",
|
|
78
79
|
_hover: {
|
|
79
80
|
background: "surface.actionSubtle.hover"
|
package/lib/Figure.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { HTMLArkProps } from "@ark-ui/react";
|
|
9
9
|
import { RecipeVariantProps } from "@ndla/styled-system/css";
|
|
10
|
-
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
10
|
+
import { JsxStyleProps, RecipeVariant } from "@ndla/styled-system/types";
|
|
11
11
|
declare const figureRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
12
12
|
size: {
|
|
13
13
|
full: {
|
|
@@ -43,19 +43,19 @@ declare const figureRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<
|
|
|
43
43
|
tablet: {
|
|
44
44
|
float: "left";
|
|
45
45
|
clear: "left";
|
|
46
|
-
paddingInlineEnd: "medium";
|
|
47
46
|
};
|
|
48
47
|
};
|
|
49
48
|
right: {
|
|
50
49
|
tablet: {
|
|
51
50
|
float: "right";
|
|
52
51
|
clear: "right";
|
|
53
|
-
paddingInlineStart: "medium";
|
|
54
52
|
};
|
|
55
53
|
};
|
|
56
54
|
};
|
|
57
55
|
}>;
|
|
58
56
|
export type FigureVariantProps = RecipeVariantProps<typeof figureRecipe>;
|
|
57
|
+
export type FigureSize = RecipeVariant<typeof figureRecipe>["size"];
|
|
58
|
+
export type FigureFloat = RecipeVariant<typeof figureRecipe>["float"];
|
|
59
59
|
export type FigureProps = HTMLArkProps<"figure"> & JsxStyleProps & FigureVariantProps;
|
|
60
60
|
export declare const Figure: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & {
|
|
61
61
|
consumeCss?: boolean | undefined;
|
package/lib/Figure.js
CHANGED
|
@@ -58,15 +58,13 @@ const figureRecipe = (0, _css.cva)({
|
|
|
58
58
|
left: {
|
|
59
59
|
tablet: {
|
|
60
60
|
float: "left",
|
|
61
|
-
clear: "left"
|
|
62
|
-
paddingInlineEnd: "medium"
|
|
61
|
+
clear: "left"
|
|
63
62
|
}
|
|
64
63
|
},
|
|
65
64
|
right: {
|
|
66
65
|
tablet: {
|
|
67
66
|
float: "right",
|
|
68
|
-
clear: "right"
|
|
69
|
-
paddingInlineStart: "medium"
|
|
67
|
+
clear: "right"
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
}
|
|
@@ -81,6 +79,25 @@ const figureRecipe = (0, _css.cva)({
|
|
|
81
79
|
left: "auto",
|
|
82
80
|
marginBlock: "xsmall"
|
|
83
81
|
}
|
|
82
|
+
}, {
|
|
83
|
+
float: "left",
|
|
84
|
+
size: ["medium", "small", "xsmall"],
|
|
85
|
+
css: {
|
|
86
|
+
paddingInlineEnd: "medium"
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
float: "right",
|
|
90
|
+
size: ["medium", "small", "xsmall"],
|
|
91
|
+
css: {
|
|
92
|
+
paddingInlineStart: "medium"
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
float: ["left", "right"],
|
|
96
|
+
size: ["full"],
|
|
97
|
+
css: {
|
|
98
|
+
paddingInlineStart: "0",
|
|
99
|
+
paddingInlineEnd: "0"
|
|
100
|
+
}
|
|
84
101
|
}]
|
|
85
102
|
});
|
|
86
103
|
const StyledFigure = (0, _jsx2.styled)(_react2.ark.figure, {}, {
|
package/lib/Image.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { ComponentPropsWithRef } from "react";
|
|
9
|
+
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
10
|
+
export interface ImageCrop {
|
|
11
|
+
startX: number;
|
|
12
|
+
startY: number;
|
|
13
|
+
endX: number;
|
|
14
|
+
endY: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ImageFocalPoint {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const makeSrcQueryString: (width: number | undefined, crop?: ImageCrop, focalPoint?: ImageFocalPoint) => string;
|
|
21
|
+
export declare const getSrcSet: (src: string, crop: ImageCrop | undefined, focalPoint: ImageFocalPoint | undefined) => string;
|
|
22
|
+
export interface PictureProps extends JsxStyleProps, ComponentPropsWithRef<"picture"> {
|
|
23
|
+
src: string;
|
|
24
|
+
sizes?: string;
|
|
25
|
+
contentType?: string;
|
|
26
|
+
srcSet?: string;
|
|
27
|
+
crop?: ImageCrop;
|
|
28
|
+
focalPoint?: ImageFocalPoint;
|
|
29
|
+
}
|
|
30
|
+
export declare const Picture: import("react").ForwardRefExoticComponent<Omit<PictureProps, "ref"> & import("react").RefAttributes<HTMLPictureElement>>;
|
|
31
|
+
export interface ImgProps extends JsxStyleProps, ComponentPropsWithRef<"img"> {
|
|
32
|
+
alt: string;
|
|
33
|
+
src: string;
|
|
34
|
+
fallbackWidth?: number;
|
|
35
|
+
contentType?: string;
|
|
36
|
+
crop?: ImageCrop;
|
|
37
|
+
focalPoint?: ImageFocalPoint;
|
|
38
|
+
}
|
|
39
|
+
export declare const Img: import("react").ForwardRefExoticComponent<Omit<ImgProps, "ref"> & import("react").RefAttributes<HTMLImageElement>>;
|
|
40
|
+
export interface ImageProps extends JsxStyleProps, ComponentPropsWithRef<"img"> {
|
|
41
|
+
alt: string;
|
|
42
|
+
src: string;
|
|
43
|
+
sizes?: string;
|
|
44
|
+
fallbackWidth?: number;
|
|
45
|
+
contentType?: string;
|
|
46
|
+
crop?: ImageCrop;
|
|
47
|
+
focalPoint?: ImageFocalPoint;
|
|
48
|
+
}
|
|
49
|
+
export declare const Image: import("react").ForwardRefExoticComponent<Omit<ImageProps, "ref"> & import("react").RefAttributes<HTMLImageElement>>;
|
package/lib/Image.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeSrcQueryString = exports.getSrcSet = exports.Picture = exports.Img = exports.Image = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
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
|
+
*/
|
|
17
|
+
|
|
18
|
+
const makeSrcQueryString = (width, crop, focalPoint) => {
|
|
19
|
+
const widthParams = width && `width=${width}`;
|
|
20
|
+
const cropParams = crop && `cropStartX=${crop.startX}&cropEndX=${crop.endX}&cropStartY=${crop.startY}&cropEndY=${crop.endY}`;
|
|
21
|
+
const focalPointParams = focalPoint && `focalX=${focalPoint.x}&focalY=${focalPoint.y}`;
|
|
22
|
+
const params = [widthParams, cropParams, focalPointParams].filter(p => p).join("&");
|
|
23
|
+
return params;
|
|
24
|
+
};
|
|
25
|
+
exports.makeSrcQueryString = makeSrcQueryString;
|
|
26
|
+
const getSrcSet = (src, crop, focalPoint) => {
|
|
27
|
+
const widths = [2720, 2080, 1760, 1440, 1120, 1000, 960, 800, 640, 480, 320, 240, 180];
|
|
28
|
+
return widths.map(width => `${src}?${makeSrcQueryString(width, crop, focalPoint)} ${width}w`).join(", ");
|
|
29
|
+
};
|
|
30
|
+
exports.getSrcSet = getSrcSet;
|
|
31
|
+
const FALLBACK_WIDTH = 1024;
|
|
32
|
+
const FALLBACK_SIZES = "(min-width: 1024px) 1024px, 100vw";
|
|
33
|
+
const Picture = exports.Picture = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
34
|
+
let {
|
|
35
|
+
children,
|
|
36
|
+
srcSet: srcSetProp,
|
|
37
|
+
crop,
|
|
38
|
+
focalPoint,
|
|
39
|
+
src,
|
|
40
|
+
contentType,
|
|
41
|
+
sizes = FALLBACK_SIZES,
|
|
42
|
+
...props
|
|
43
|
+
} = _ref;
|
|
44
|
+
const srcSet = srcSetProp ?? getSrcSet(src, crop, focalPoint);
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsx2.styled.picture, {
|
|
46
|
+
...props,
|
|
47
|
+
ref: ref,
|
|
48
|
+
children: [contentType !== "image/gif" && /*#__PURE__*/(0, _jsxRuntime.jsx)("source", {
|
|
49
|
+
type: contentType,
|
|
50
|
+
srcSet: srcSet,
|
|
51
|
+
sizes: sizes
|
|
52
|
+
}), children]
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
const Img = exports.Img = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
56
|
+
let {
|
|
57
|
+
fallbackWidth = FALLBACK_WIDTH,
|
|
58
|
+
crop,
|
|
59
|
+
focalPoint,
|
|
60
|
+
contentType,
|
|
61
|
+
src,
|
|
62
|
+
alt,
|
|
63
|
+
...props
|
|
64
|
+
} = _ref2;
|
|
65
|
+
const queryString = makeSrcQueryString(fallbackWidth, crop, focalPoint);
|
|
66
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsx2.styled.img, {
|
|
67
|
+
alt: alt,
|
|
68
|
+
src: contentType === "image/gif" ? src : `${src}?${queryString}`,
|
|
69
|
+
...props,
|
|
70
|
+
ref: ref
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
const Image = exports.Image = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
74
|
+
let {
|
|
75
|
+
children,
|
|
76
|
+
srcSet: srcSetProp,
|
|
77
|
+
crop,
|
|
78
|
+
focalPoint,
|
|
79
|
+
src,
|
|
80
|
+
contentType,
|
|
81
|
+
fallbackWidth = FALLBACK_WIDTH,
|
|
82
|
+
sizes = FALLBACK_SIZES,
|
|
83
|
+
alt,
|
|
84
|
+
...props
|
|
85
|
+
} = _ref3;
|
|
86
|
+
const srcSet = srcSetProp ?? getSrcSet(src, crop, focalPoint);
|
|
87
|
+
const queryString = makeSrcQueryString(fallbackWidth, crop, focalPoint);
|
|
88
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("picture", {
|
|
89
|
+
children: [contentType !== "image/gif" && /*#__PURE__*/(0, _jsxRuntime.jsx)("source", {
|
|
90
|
+
type: contentType,
|
|
91
|
+
srcSet: srcSet,
|
|
92
|
+
sizes: sizes
|
|
93
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsx2.styled.img, {
|
|
94
|
+
alt: alt,
|
|
95
|
+
src: contentType === "image/gif" ? src : `${src}?${queryString}`,
|
|
96
|
+
...props,
|
|
97
|
+
ref: ref
|
|
98
|
+
})]
|
|
99
|
+
});
|
|
100
|
+
});
|
package/lib/Input.js
CHANGED
|
@@ -147,7 +147,7 @@ const TextArea = exports.TextArea = /*#__PURE__*/(0, _react.forwardRef)((_ref3,
|
|
|
147
147
|
const resize = (0, _react.useCallback)(() => {
|
|
148
148
|
if (!localRef.current) return;
|
|
149
149
|
localRef.current.style.height = "0";
|
|
150
|
-
localRef.current.style.height =
|
|
150
|
+
localRef.current.style.height = `${localRef.current.scrollHeight + 3}px`;
|
|
151
151
|
}, []);
|
|
152
152
|
(0, _react.useEffect)(() => {
|
|
153
153
|
window.addEventListener("input", resize);
|
|
@@ -52,7 +52,7 @@ const createStyleContext = recipe => {
|
|
|
52
52
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledComponent, {
|
|
53
53
|
...otherProps,
|
|
54
54
|
ref: ref,
|
|
55
|
-
css: _css.css.raw(slotStyles
|
|
55
|
+
css: _css.css.raw(slotStyles?.[slot], cssProp)
|
|
56
56
|
})
|
|
57
57
|
});
|
|
58
58
|
});
|
|
@@ -71,7 +71,7 @@ const createStyleContext = recipe => {
|
|
|
71
71
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledComponent, {
|
|
72
72
|
...props,
|
|
73
73
|
ref: ref,
|
|
74
|
-
css: _css.css.raw(slotStyles
|
|
74
|
+
css: _css.css.raw(slotStyles?.[slot], cssProp)
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { Badge } from "./Badge";
|
|
|
14
14
|
export type { BlockQuoteVariantProps, BlockQuoteProps } from "./BlockQuote";
|
|
15
15
|
export { BlockQuote } from "./BlockQuote";
|
|
16
16
|
export type { ButtonProps, ButtonVariantProps, IconButtonProps, IconButtonVariantProps } from "./Button";
|
|
17
|
-
export { Button, IconButton } from "./Button";
|
|
17
|
+
export { Button, IconButton, buttonBaseRecipe, buttonRecipe, iconButtonRecipe } from "./Button";
|
|
18
18
|
export type { CheckboxVariantProps, CheckboxRootProps } from "./Checkbox";
|
|
19
19
|
export { CheckboxRoot, CheckboxIndicator, CheckboxLabel, CheckboxControl, CheckboxGroup, CheckboxHiddenInput, } from "./Checkbox";
|
|
20
20
|
export type { ComboboxVariantProps, ComboboxRootProps } from "./Combobox";
|
|
@@ -26,9 +26,12 @@ export { ExpandableBox, ExpandableBoxSummary } from "./ExpandableBox";
|
|
|
26
26
|
export { FieldRoot } from "./Field";
|
|
27
27
|
export { FieldErrorMessage } from "./FieldErrorMessage";
|
|
28
28
|
export { FieldHelper } from "./FieldHelper";
|
|
29
|
+
export type { FigureSize, FigureVariantProps, FigureProps, FigureFloat } from "./Figure";
|
|
29
30
|
export { Figure } from "./Figure";
|
|
30
31
|
export type { FramedContentVariantProps, FramedContentProps } from "./FramedContent";
|
|
31
32
|
export { FramedContent } from "./FramedContent";
|
|
33
|
+
export type { ImageCrop, ImageFocalPoint, PictureProps, ImgProps, ImageProps } from "./Image";
|
|
34
|
+
export { Picture, Img, Image } from "./Image";
|
|
32
35
|
export { Input, FieldInput, InputContainer, TextArea, FieldTextArea } from "./Input";
|
|
33
36
|
export type { LabelProps } from "./Label";
|
|
34
37
|
export { Label, FieldLabel } from "./Label";
|
package/lib/index.js
CHANGED
|
@@ -309,6 +309,18 @@ Object.defineProperty(exports, "IconButton", {
|
|
|
309
309
|
return _Button.IconButton;
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
|
+
Object.defineProperty(exports, "Image", {
|
|
313
|
+
enumerable: true,
|
|
314
|
+
get: function () {
|
|
315
|
+
return _Image.Image;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
Object.defineProperty(exports, "Img", {
|
|
319
|
+
enumerable: true,
|
|
320
|
+
get: function () {
|
|
321
|
+
return _Image.Img;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
312
324
|
Object.defineProperty(exports, "Input", {
|
|
313
325
|
enumerable: true,
|
|
314
326
|
get: function () {
|
|
@@ -441,6 +453,12 @@ Object.defineProperty(exports, "PaginationRoot", {
|
|
|
441
453
|
return _Pagination.PaginationRoot;
|
|
442
454
|
}
|
|
443
455
|
});
|
|
456
|
+
Object.defineProperty(exports, "Picture", {
|
|
457
|
+
enumerable: true,
|
|
458
|
+
get: function () {
|
|
459
|
+
return _Image.Picture;
|
|
460
|
+
}
|
|
461
|
+
});
|
|
444
462
|
Object.defineProperty(exports, "PopoverAnchor", {
|
|
445
463
|
enumerable: true,
|
|
446
464
|
get: function () {
|
|
@@ -915,6 +933,24 @@ Object.defineProperty(exports, "UnOrderedList", {
|
|
|
915
933
|
return _ArticleLists.UnOrderedList;
|
|
916
934
|
}
|
|
917
935
|
});
|
|
936
|
+
Object.defineProperty(exports, "buttonBaseRecipe", {
|
|
937
|
+
enumerable: true,
|
|
938
|
+
get: function () {
|
|
939
|
+
return _Button.buttonBaseRecipe;
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
Object.defineProperty(exports, "buttonRecipe", {
|
|
943
|
+
enumerable: true,
|
|
944
|
+
get: function () {
|
|
945
|
+
return _Button.buttonRecipe;
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
Object.defineProperty(exports, "iconButtonRecipe", {
|
|
949
|
+
enumerable: true,
|
|
950
|
+
get: function () {
|
|
951
|
+
return _Button.iconButtonRecipe;
|
|
952
|
+
}
|
|
953
|
+
});
|
|
918
954
|
var _Accordion = require("./Accordion");
|
|
919
955
|
var _ArticleLists = require("./ArticleLists");
|
|
920
956
|
var _Badge = require("./Badge");
|
|
@@ -929,6 +965,7 @@ var _FieldErrorMessage = require("./FieldErrorMessage");
|
|
|
929
965
|
var _FieldHelper = require("./FieldHelper");
|
|
930
966
|
var _Figure = require("./Figure");
|
|
931
967
|
var _FramedContent = require("./FramedContent");
|
|
968
|
+
var _Image = require("./Image");
|
|
932
969
|
var _Input = require("./Input");
|
|
933
970
|
var _Label = require("./Label");
|
|
934
971
|
var _Menu = require("./Menu");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/primitives",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Primitive components for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ark-ui/react": "^3.5.0",
|
|
32
|
-
"@ndla/styled-system": "^0.0.
|
|
32
|
+
"@ndla/styled-system": "^0.0.8",
|
|
33
33
|
"@ndla/util": "^4.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@ndla/preset-panda": "^0.0.
|
|
37
|
-
"@pandacss/dev": "^0.
|
|
36
|
+
"@ndla/preset-panda": "^0.0.10",
|
|
37
|
+
"@pandacss/dev": "^0.42.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": ">= 18",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "93dde6fe4aaca52642f8fa0a27f4acad359207cb"
|
|
47
47
|
}
|