@uxf/core 10.0.0-beta.22 → 10.0.0-beta.28
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/components/hide.d.ts +7 -0
- package/components/hide.js +14 -0
- package/components/show.d.ts +7 -0
- package/components/show.js +14 -0
- package/package.json +1 -1
- package/utils/image.d.ts +2 -0
- package/utils/image.js +16 -2
- package/utils/resizer.js +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Hide = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Hide(props) {
|
|
9
|
+
if (props.when) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return react_1.default.createElement(react_1.default.Fragment, null, props.children);
|
|
13
|
+
}
|
|
14
|
+
exports.Hide = Hide;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Show = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Show(props) {
|
|
9
|
+
if (!props.when) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return react_1.default.createElement(react_1.default.Fragment, null, props.children);
|
|
13
|
+
}
|
|
14
|
+
exports.Show = Show;
|
package/package.json
CHANGED
package/utils/image.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type Quality = number | Record<Format, number>;
|
|
|
6
6
|
export declare function getSvgImgUrl(src: ImageSource): string | undefined;
|
|
7
7
|
export declare function getImgQuality(quality: Quality | undefined, format: Format): number | undefined;
|
|
8
8
|
export declare function getImgUniqueIdentifier(src: ImageSource): string | undefined;
|
|
9
|
+
export declare function getImgElementHeight(src: ImageSource, width: number | undefined, height: number | undefined): number | undefined;
|
|
10
|
+
export declare function getImgElementWidth(src: ImageSource, width: number | undefined, height: number | undefined): number | undefined;
|
|
9
11
|
export declare function getImgSrcSet(src?: ImageSource, width?: Dimension, height?: Dimension, options?: ResizerImageProps): string | undefined;
|
|
10
12
|
interface ImageSourcesProps {
|
|
11
13
|
breakpointIndex?: number;
|
package/utils/image.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ImgSources = exports.getImgSrcSet = exports.getImgUniqueIdentifier = exports.getImgQuality = exports.getSvgImgUrl = void 0;
|
|
6
|
+
exports.ImgSources = exports.getImgSrcSet = exports.getImgElementWidth = exports.getImgElementHeight = exports.getImgUniqueIdentifier = exports.getImgQuality = exports.getSvgImgUrl = void 0;
|
|
7
7
|
const file_1 = require("./file");
|
|
8
8
|
const resizer_1 = require("./resizer");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
@@ -41,6 +41,20 @@ function getImgUniqueIdentifier(src) {
|
|
|
41
41
|
return typeof src === "string" ? src : (_b = (_a = toImageResponse(src)) === null || _a === void 0 ? void 0 : _a.uuid) !== null && _b !== void 0 ? _b : (_c = toStaticImageData(src)) === null || _c === void 0 ? void 0 : _c.src;
|
|
42
42
|
}
|
|
43
43
|
exports.getImgUniqueIdentifier = getImgUniqueIdentifier;
|
|
44
|
+
function getImgElementHeight(src, width, height) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
return typeof src === "string"
|
|
47
|
+
? height
|
|
48
|
+
: height !== null && height !== void 0 ? height : (Math.floor((((_a = src.height) !== null && _a !== void 0 ? _a : 0) / ((_b = src.width) !== null && _b !== void 0 ? _b : 0)) * (width || 0)) || undefined);
|
|
49
|
+
}
|
|
50
|
+
exports.getImgElementHeight = getImgElementHeight;
|
|
51
|
+
function getImgElementWidth(src, width, height) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
return typeof src === "string"
|
|
54
|
+
? width
|
|
55
|
+
: width !== null && width !== void 0 ? width : (Math.floor(((_a = src.width) !== null && _a !== void 0 ? _a : 0) / ((_b = src.height) !== null && _b !== void 0 ? _b : 0)) * (height || 0) || undefined);
|
|
56
|
+
}
|
|
57
|
+
exports.getImgElementWidth = getImgElementWidth;
|
|
44
58
|
const HIDPI_SIZES = [3, 2, 1];
|
|
45
59
|
function getImgSrcSet(src, width, height, options = {}) {
|
|
46
60
|
var _a, _b;
|
|
@@ -72,7 +86,7 @@ function getImgSrcSet(src, width, height, options = {}) {
|
|
|
72
86
|
w = w || staticImageData.width;
|
|
73
87
|
}
|
|
74
88
|
if (typeof h === "number" || typeof w === "number") {
|
|
75
|
-
return HIDPI_SIZES.map((size) => (0, resizer_1.resizerImageUrl)(src, w * size, h * size, {
|
|
89
|
+
return HIDPI_SIZES.map((size) => (0, resizer_1.resizerImageUrl)(src, typeof w === "number" ? w * size : "auto", typeof h === "number" ? h * size : "auto", {
|
|
76
90
|
toFormat,
|
|
77
91
|
...options,
|
|
78
92
|
}) + (size > 1 ? ` ${size}x` : "")).join(", ");
|
package/utils/resizer.js
CHANGED
|
@@ -48,7 +48,7 @@ const resizerStaticImageUrl = (src, width = "auto", height = "auto", props = {},
|
|
|
48
48
|
};
|
|
49
49
|
const resizerImageUrl = (source, width = "auto", height = "auto", props = {}, version = 1) => {
|
|
50
50
|
var _a, _b;
|
|
51
|
-
if (source === null || source === undefined) {
|
|
51
|
+
if (source === null || source === undefined || source === "") {
|
|
52
52
|
return undefined;
|
|
53
53
|
}
|
|
54
54
|
if (typeof source === "string" || "src" in source) {
|