@crystaldesign/widget-media-viewer 25.7.0-beta.30
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/build/esm/index.js +109 -0
- package/build/types/widget-media-viewer/src/components/index.d.ts +4 -0
- package/build/types/widget-media-viewer/src/components/index.d.ts.map +1 -0
- package/build/types/widget-media-viewer/src/index.d.ts +11 -0
- package/build/types/widget-media-viewer/src/index.d.ts.map +1 -0
- package/build/types/widget-media-viewer/src/stories/default.stories.d.ts +8 -0
- package/build/types/widget-media-viewer/src/stories/default.stories.d.ts.map +1 -0
- package/build/types/widget-media-viewer/src/types/index.d.ts +10 -0
- package/build/types/widget-media-viewer/src/types/index.d.ts.map +1 -0
- package/build/types/widget-media-viewer/src/useMediaViewer.d.ts +9 -0
- package/build/types/widget-media-viewer/src/useMediaViewer.d.ts.map +1 -0
- package/build/umd/report.html +38 -0
- package/build/umd/widget-media-viewer.umd.min.js +2 -0
- package/build/umd/widget-media-viewer.umd.min.js.LICENSE.txt +26 -0
- package/package.json +35 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useCss, useProductData, MediaItem, useConfiguration } from '@crystaldesign/widget-library';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
(function() {
|
|
7
|
+
const env = {"STAGE":"production"};
|
|
8
|
+
try {
|
|
9
|
+
if (process) {
|
|
10
|
+
process.env = Object.assign({}, process.env);
|
|
11
|
+
Object.assign(process.env, env);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
15
|
+
globalThis.process = { env:env };
|
|
16
|
+
})();
|
|
17
|
+
|
|
18
|
+
function useMediaViewer(_ref) {
|
|
19
|
+
var _productVariants$, _productVariants$2, _productVariants$3;
|
|
20
|
+
var productId = _ref.productId,
|
|
21
|
+
settings = _ref.settings;
|
|
22
|
+
useCss(settings);
|
|
23
|
+
var productIds = useMemo(function () {
|
|
24
|
+
return productId ? [productId] : undefined;
|
|
25
|
+
}, [productId]);
|
|
26
|
+
var _useProductData = useProductData({
|
|
27
|
+
productIds: productIds
|
|
28
|
+
}),
|
|
29
|
+
productVariants = _useProductData.productVariants,
|
|
30
|
+
error = _useProductData.error,
|
|
31
|
+
loading = _useProductData.loading;
|
|
32
|
+
var media = (_productVariants$ = productVariants[0]) !== null && _productVariants$ !== void 0 && _productVariants$.image ? productVariants[0].image : (_productVariants$2 = productVariants[0]) === null || _productVariants$2 === void 0 ? void 0 : _productVariants$2.image2D;
|
|
33
|
+
var productMedia = (_productVariants$3 = productVariants[0]) === null || _productVariants$3 === void 0 ? void 0 : _productVariants$3.media;
|
|
34
|
+
var _loop = function _loop() {
|
|
35
|
+
var functionType = settings.functionTypePriority[i];
|
|
36
|
+
if (productMedia) {
|
|
37
|
+
var prodMedia = productMedia.find(function (mediaItem) {
|
|
38
|
+
return mediaItem.functionType === functionType;
|
|
39
|
+
});
|
|
40
|
+
if (prodMedia) {
|
|
41
|
+
media = prodMedia;
|
|
42
|
+
return 1; // break
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
for (var i = 0; i < settings.functionTypePriority.length; i++) {
|
|
47
|
+
if (_loop()) break;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
media: typeof media !== 'string' ? media : undefined,
|
|
51
|
+
mediaUrl: typeof media === 'string' ? media : undefined,
|
|
52
|
+
error: error,
|
|
53
|
+
loading: loading
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function MainComponent(props) {
|
|
58
|
+
var _useMediaViewer = useMediaViewer(props),
|
|
59
|
+
media = _useMediaViewer.media,
|
|
60
|
+
mediaUrl = _useMediaViewer.mediaUrl,
|
|
61
|
+
error = _useMediaViewer.error,
|
|
62
|
+
loading = _useMediaViewer.loading;
|
|
63
|
+
if (loading) {
|
|
64
|
+
return /*#__PURE__*/jsx("div", {
|
|
65
|
+
children: "Loading..."
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (error) {
|
|
69
|
+
return /*#__PURE__*/jsx("div", {
|
|
70
|
+
children: "Error"
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return /*#__PURE__*/jsx("div", {
|
|
74
|
+
className: "diva-widget-media-viewer",
|
|
75
|
+
children: (media || mediaUrl) && /*#__PURE__*/jsx(MediaItem, {
|
|
76
|
+
media: media,
|
|
77
|
+
mediaUrl: mediaUrl,
|
|
78
|
+
isCurrentlyVisible: true,
|
|
79
|
+
config: {
|
|
80
|
+
disableSirv: true
|
|
81
|
+
},
|
|
82
|
+
videoAutolay: props.settings.videoAutolay
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
88
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
89
|
+
var Main = function Main(_ref) {
|
|
90
|
+
var _parameters$productId;
|
|
91
|
+
var settings = _ref.settings,
|
|
92
|
+
parameters = _ref.parameters;
|
|
93
|
+
return /*#__PURE__*/jsx(ImageViewerComponent, {
|
|
94
|
+
settings: settings,
|
|
95
|
+
productId: (_parameters$productId = parameters === null || parameters === void 0 ? void 0 : parameters.productId) !== null && _parameters$productId !== void 0 ? _parameters$productId : ''
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
var ImageViewerComponent = function ImageViewerComponent(props) {
|
|
99
|
+
var settings = useConfiguration(ImageViewer.name, props.settings);
|
|
100
|
+
return /*#__PURE__*/jsx(MainComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
101
|
+
settings: settings
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
var ImageViewer = {
|
|
105
|
+
name: 'MEDIA_VIEWER',
|
|
106
|
+
renderFunction: Main
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export { ImageViewerComponent, ImageViewer as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAgB5C,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,gBAAgB,qBAuB5D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export * from './types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { ComponentDefinition } from '@crystaldesign/diva-core';
|
|
6
|
+
import { Configuration, MediaViewerProps } from './types';
|
|
7
|
+
export declare const ImageViewerComponent: React.FC<MediaViewerProps>;
|
|
8
|
+
declare const ImageViewer: ComponentDefinition<Configuration>;
|
|
9
|
+
export default ImageViewer;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
11
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAkB,MAAM,0BAA0B,CAAC;AAG/E,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAM1D,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAG3D,CAAC;AAEF,QAAA,MAAM,WAAW,EAAE,mBAAmB,CAAC,aAAa,CAGnD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { WithDivaMock } from '@crystaldesign/diva-core';
|
|
3
|
+
import { MediaViewerProps } from '../types';
|
|
4
|
+
declare const meta: Meta<WithDivaMock<MediaViewerProps>>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<WithDivaMock<MediaViewerProps>>;
|
|
7
|
+
export declare const MediaViewer: Story;
|
|
8
|
+
//# sourceMappingURL=default.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.stories.d.ts","sourceRoot":"","sources":["../../../../../src/stories/default.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAqB,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAmB9C,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA+BtD,eAAO,MAAM,WAAW,EAAE,KAEzB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseConfiguration } from '@crystaldesign/widget-library';
|
|
2
|
+
export interface MediaViewerProps {
|
|
3
|
+
settings: Configuration;
|
|
4
|
+
productId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Configuration extends BaseConfiguration {
|
|
7
|
+
functionTypePriority: string[];
|
|
8
|
+
videoAutolay?: boolean;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MediaViewerProps } from './types';
|
|
2
|
+
import { Media } from '@crystaldesign/diva-core';
|
|
3
|
+
export declare function useMediaViewer({ productId, settings }: MediaViewerProps): {
|
|
4
|
+
media: Media | undefined;
|
|
5
|
+
mediaUrl: string | undefined;
|
|
6
|
+
error: boolean;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useMediaViewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaViewer.d.ts","sourceRoot":"","sources":["../../../../src/useMediaViewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGjD,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,gBAAgB;;;;;EA2BvE"}
|