@streamscloud/embeddable 1.1.2
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/README.md +1 -0
- package/dist/advertising/ad-view/cmp.ad-view.svelte +82 -0
- package/dist/advertising/ad-view/cmp.ad-view.svelte.d.ts +8 -0
- package/dist/advertising/ad-view/index.d.ts +2 -0
- package/dist/advertising/ad-view/index.js +1 -0
- package/dist/advertising/ad-view/mapper.d.ts +3 -0
- package/dist/advertising/ad-view/mapper.js +16 -0
- package/dist/advertising/ad-view/operations.generated.d.ts +17 -0
- package/dist/advertising/ad-view/operations.generated.js +46 -0
- package/dist/advertising/ad-view/operations.graphql +14 -0
- package/dist/advertising/ad-view/types.d.ts +10 -0
- package/dist/advertising/ad-view/types.js +1 -0
- package/dist/advertising/index.d.ts +1 -0
- package/dist/advertising/index.js +1 -0
- package/dist/advertising/types.d.ts +5 -0
- package/dist/advertising/types.js +6 -0
- package/dist/core/continuation-token.d.ts +10 -0
- package/dist/core/continuation-token.js +32 -0
- package/dist/core/cursor-result.d.ts +9 -0
- package/dist/core/cursor-result.js +1 -0
- package/dist/core/data-loaders/cursor-data-loader.svelte.d.ts +14 -0
- package/dist/core/data-loaders/cursor-data-loader.svelte.js +35 -0
- package/dist/core/data-loaders/data-loader.d.ts +4 -0
- package/dist/core/data-loaders/data-loader.js +1 -0
- package/dist/core/data-loaders/index.d.ts +2 -0
- package/dist/core/data-loaders/index.js +1 -0
- package/dist/core/deferred.d.ts +6 -0
- package/dist/core/deferred.js +13 -0
- package/dist/core/graphql.d.ts +1 -0
- package/dist/core/graphql.js +10 -0
- package/dist/core/media/image-helper.d.ts +10 -0
- package/dist/core/media/image-helper.js +30 -0
- package/dist/core/media/images-size-detector.service.d.ts +6 -0
- package/dist/core/media/images-size-detector.service.js +15 -0
- package/dist/core/media/index.d.ts +4 -0
- package/dist/core/media/index.js +4 -0
- package/dist/core/media/media-item-url.service.d.ts +2 -0
- package/dist/core/media/media-item-url.service.js +2 -0
- package/dist/core/media/types.d.ts +28 -0
- package/dist/core/media/types.js +19 -0
- package/dist/core/toastr.d.ts +1 -0
- package/dist/core/toastr.js +26 -0
- package/dist/core/transitions/index.d.ts +1 -0
- package/dist/core/transitions/index.js +1 -0
- package/dist/core/transitions/slide-horizontally.d.ts +7 -0
- package/dist/core/transitions/slide-horizontally.js +55 -0
- package/dist/core/utils/array-helper.d.ts +23 -0
- package/dist/core/utils/array-helper.js +148 -0
- package/dist/core/utils/date-helper.d.ts +29 -0
- package/dist/core/utils/date-helper.js +146 -0
- package/dist/core/utils/dom-helper.d.ts +12 -0
- package/dist/core/utils/dom-helper.js +76 -0
- package/dist/core/utils/html-helper.d.ts +40 -0
- package/dist/core/utils/html-helper.js +97 -0
- package/dist/core/utils/index.d.ts +3 -0
- package/dist/core/utils/index.js +3 -0
- package/dist/core/utils/number-helper.d.ts +6 -0
- package/dist/core/utils/number-helper.js +28 -0
- package/dist/core/utils/string-generator.d.ts +2 -0
- package/dist/core/utils/string-generator.js +15 -0
- package/dist/core/utils/string-helper.d.ts +10 -0
- package/dist/core/utils/string-helper.js +53 -0
- package/dist/core/utils/url-helper.d.ts +3 -0
- package/dist/core/utils/url-helper.js +13 -0
- package/dist/core/utils/utils.d.ts +28 -0
- package/dist/core/utils/utils.js +100 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/products/index.d.ts +1 -0
- package/dist/products/index.js +1 -0
- package/dist/products/price-helper.d.ts +4 -0
- package/dist/products/price-helper.js +36 -0
- package/dist/products/product-card/cmp.product-card.svelte +121 -0
- package/dist/products/product-card/cmp.product-card.svelte.d.ts +10 -0
- package/dist/products/product-card/index.d.ts +3 -0
- package/dist/products/product-card/index.js +3 -0
- package/dist/products/product-card/mapper.d.ts +3 -0
- package/dist/products/product-card/mapper.js +14 -0
- package/dist/products/product-card/operations.generated.d.ts +22 -0
- package/dist/products/product-card/operations.generated.js +65 -0
- package/dist/products/product-card/operations.graphql +19 -0
- package/dist/products/product-card/product-card-localization.svelte.d.ts +7 -0
- package/dist/products/product-card/product-card-localization.svelte.js +11 -0
- package/dist/products/product-card/types.d.ts +10 -0
- package/dist/products/product-card/types.js +1 -0
- package/dist/products/types.d.ts +5 -0
- package/dist/products/types.js +6 -0
- package/dist/short-videos/short-video-viewer/cmp.attachments.svelte +71 -0
- package/dist/short-videos/short-video-viewer/cmp.attachments.svelte.d.ts +7 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte +145 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-details.svelte.d.ts +10 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-heading.svelte +86 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-heading.svelte.d.ts +9 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte +133 -0
- package/dist/short-videos/short-video-viewer/cmp.short-video-viewer.svelte.d.ts +12 -0
- package/dist/short-videos/short-video-viewer/description.svelte +46 -0
- package/dist/short-videos/short-video-viewer/description.svelte.d.ts +9 -0
- package/dist/short-videos/short-video-viewer/index.d.ts +6 -0
- package/dist/short-videos/short-video-viewer/index.js +4 -0
- package/dist/short-videos/short-video-viewer/mapper.d.ts +3 -0
- package/dist/short-videos/short-video-viewer/mapper.js +28 -0
- package/dist/short-videos/short-video-viewer/operations.generated.d.ts +56 -0
- package/dist/short-videos/short-video-viewer/operations.generated.js +187 -0
- package/dist/short-videos/short-video-viewer/operations.graphql +26 -0
- package/dist/short-videos/short-video-viewer/short-video-details-localization.svelte.d.ts +14 -0
- package/dist/short-videos/short-video-viewer/short-video-details-localization.svelte.js +21 -0
- package/dist/short-videos/short-video-viewer/short-video-viewer-localization.svelte.d.ts +10 -0
- package/dist/short-videos/short-video-viewer/short-video-viewer-localization.svelte.js +13 -0
- package/dist/short-videos/short-video-viewer/types.d.ts +17 -0
- package/dist/short-videos/short-video-viewer/types.js +1 -0
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.d.ts +12 -0
- package/dist/short-videos/short-video-viewer/ui-manager.svelte.js +26 -0
- package/dist/short-videos/short-videos-player/action-button.svelte +38 -0
- package/dist/short-videos/short-videos-player/action-button.svelte.d.ts +10 -0
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte +91 -0
- package/dist/short-videos/short-videos-player/cmp.short-videos-player.svelte.d.ts +13 -0
- package/dist/short-videos/short-videos-player/controls.svelte +215 -0
- package/dist/short-videos/short-videos-player/controls.svelte.d.ts +15 -0
- package/dist/short-videos/short-videos-player/index.d.ts +2 -0
- package/dist/short-videos/short-videos-player/index.js +1 -0
- package/dist/short-videos/short-videos-player/short-videos-player-localization.svelte.d.ts +14 -0
- package/dist/short-videos/short-videos-player/short-videos-player-localization.svelte.js +21 -0
- package/dist/short-videos/short-videos-player/ui-manager.svelte.d.ts +16 -0
- package/dist/short-videos/short-videos-player/ui-manager.svelte.js +25 -0
- package/dist/short-videos/short-videos-player-modal/cmp.short-videos-player-modal.svelte +485 -0
- package/dist/short-videos/short-videos-player-modal/cmp.short-videos-player-modal.svelte.d.ts +3 -0
- package/dist/short-videos/short-videos-player-modal/index.d.ts +79 -0
- package/dist/short-videos/short-videos-player-modal/index.js +78 -0
- package/dist/short-videos/short-videos-player-modal/short-videos-player-modal-state.svelte.d.ts +16 -0
- package/dist/short-videos/short-videos-player-modal/short-videos-player-modal-state.svelte.js +13 -0
- package/dist/streams/components/cmp.stream-page-component.svelte +16 -0
- package/dist/streams/components/cmp.stream-page-component.svelte.d.ts +10 -0
- package/dist/streams/components/components.factory.d.ts +22 -0
- package/dist/streams/components/components.factory.js +34 -0
- package/dist/streams/components/images/cmp.images-component.svelte +7 -0
- package/dist/streams/components/images/cmp.images-component.svelte.d.ts +7 -0
- package/dist/streams/components/images/index.d.ts +2 -0
- package/dist/streams/components/images/index.js +1 -0
- package/dist/streams/components/images/types.d.ts +8 -0
- package/dist/streams/components/images/types.js +5 -0
- package/dist/streams/components/index.d.ts +7 -0
- package/dist/streams/components/index.js +6 -0
- package/dist/streams/components/mapper.d.ts +3 -0
- package/dist/streams/components/mapper.js +43 -0
- package/dist/streams/components/operations.generated.d.ts +178 -0
- package/dist/streams/components/operations.generated.js +653 -0
- package/dist/streams/components/operations.graphql +35 -0
- package/dist/streams/components/product/cmp.product-component.svelte +148 -0
- package/dist/streams/components/product/cmp.product-component.svelte.d.ts +8 -0
- package/dist/streams/components/product/index.d.ts +3 -0
- package/dist/streams/components/product/index.js +2 -0
- package/dist/streams/components/product/mapper.d.ts +3 -0
- package/dist/streams/components/product/mapper.js +14 -0
- package/dist/streams/components/product/operations.generated.d.ts +22 -0
- package/dist/streams/components/product/operations.generated.js +53 -0
- package/dist/streams/components/product/operations.graphql +19 -0
- package/dist/streams/components/product/types.d.ts +10 -0
- package/dist/streams/components/product/types.js +1 -0
- package/dist/streams/components/short-video/cmp.short-video-component.svelte +9 -0
- package/dist/streams/components/short-video/cmp.short-video-component.svelte.d.ts +10 -0
- package/dist/streams/components/short-video/index.d.ts +3 -0
- package/dist/streams/components/short-video/index.js +2 -0
- package/dist/streams/components/short-video/mapper.d.ts +3 -0
- package/dist/streams/components/short-video/mapper.js +4 -0
- package/dist/streams/components/short-video/operations.generated.d.ts +56 -0
- package/dist/streams/components/short-video/operations.generated.js +193 -0
- package/dist/streams/components/short-video/operations.graphql +3 -0
- package/dist/streams/components/short-video/types.d.ts +2 -0
- package/dist/streams/components/short-video/types.js +1 -0
- package/dist/streams/components/stream-components-localization.svelte.d.ts +10 -0
- package/dist/streams/components/stream-components-localization.svelte.js +13 -0
- package/dist/streams/components/types.d.ts +27 -0
- package/dist/streams/components/types.js +6 -0
- package/dist/streams/slots/cmp.stream-component-slot.svelte +35 -0
- package/dist/streams/slots/cmp.stream-component-slot.svelte.d.ts +9 -0
- package/dist/streams/slots/index.d.ts +3 -0
- package/dist/streams/slots/index.js +2 -0
- package/dist/streams/slots/mapper.d.ts +3 -0
- package/dist/streams/slots/mapper.js +18 -0
- package/dist/streams/slots/operations.generated.d.ts +17 -0
- package/dist/streams/slots/operations.generated.js +34 -0
- package/dist/streams/slots/operations.graphql +14 -0
- package/dist/streams/slots/styles-transformer.d.ts +6 -0
- package/dist/streams/slots/styles-transformer.js +12 -0
- package/dist/streams/slots/types.d.ts +16 -0
- package/dist/streams/slots/types.js +1 -0
- package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte +47 -0
- package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte.d.ts +9 -0
- package/dist/streams/stream-page-viewer/index.d.ts +2 -0
- package/dist/streams/stream-page-viewer/index.js +1 -0
- package/dist/streams/stream-page-viewer/mapper.d.ts +3 -0
- package/dist/streams/stream-page-viewer/mapper.js +23 -0
- package/dist/streams/stream-page-viewer/operations.generated.d.ts +113 -0
- package/dist/streams/stream-page-viewer/operations.generated.js +400 -0
- package/dist/streams/stream-page-viewer/operations.graphql +13 -0
- package/dist/streams/stream-page-viewer/stream-page-viewer-localization.svelte.d.ts +10 -0
- package/dist/streams/stream-page-viewer/stream-page-viewer-localization.svelte.js +13 -0
- package/dist/streams/stream-page-viewer/types.d.ts +18 -0
- package/dist/streams/stream-page-viewer/types.js +1 -0
- package/dist/streams/stream-player/action-button.svelte +38 -0
- package/dist/streams/stream-player/action-button.svelte.d.ts +10 -0
- package/dist/streams/stream-player/cmp.stream-player.svelte +141 -0
- package/dist/streams/stream-player/cmp.stream-player.svelte.d.ts +16 -0
- package/dist/streams/stream-player/controls.svelte +222 -0
- package/dist/streams/stream-player/controls.svelte.d.ts +14 -0
- package/dist/streams/stream-player/index.d.ts +2 -0
- package/dist/streams/stream-player/index.js +1 -0
- package/dist/streams/stream-player/mapper.d.ts +3 -0
- package/dist/streams/stream-player/mapper.js +15 -0
- package/dist/streams/stream-player/operations.generated.d.ts +161 -0
- package/dist/streams/stream-player/operations.generated.js +559 -0
- package/dist/streams/stream-player/operations.graphql +32 -0
- package/dist/streams/stream-player/stream-overview.svelte +239 -0
- package/dist/streams/stream-player/stream-overview.svelte.d.ts +17 -0
- package/dist/streams/stream-player/stream-player-buffer.svelte.d.ts +25 -0
- package/dist/streams/stream-player/stream-player-buffer.svelte.js +84 -0
- package/dist/streams/stream-player/stream-player-localization.svelte.d.ts +18 -0
- package/dist/streams/stream-player/stream-player-localization.svelte.js +29 -0
- package/dist/streams/stream-player/types.d.ts +12 -0
- package/dist/streams/stream-player/types.js +1 -0
- package/dist/streams/stream-player/ui-manager.svelte.d.ts +17 -0
- package/dist/streams/stream-player/ui-manager.svelte.js +26 -0
- package/dist/streams/stream-player-modal/cmp.stream-player-modal.svelte +486 -0
- package/dist/streams/stream-player-modal/cmp.stream-player-modal.svelte.d.ts +3 -0
- package/dist/streams/stream-player-modal/index.d.ts +79 -0
- package/dist/streams/stream-player-modal/index.js +78 -0
- package/dist/streams/stream-player-modal/stream-player-modal-state.svelte.d.ts +17 -0
- package/dist/streams/stream-player-modal/stream-player-modal-state.svelte.js +14 -0
- package/dist/ui/button/cmp.button.svelte +10 -0
- package/dist/ui/button/cmp.button.svelte.d.ts +16 -0
- package/dist/ui/button/index.d.ts +2 -0
- package/dist/ui/button/index.js +2 -0
- package/dist/ui/button/resources/button-base.svelte +84 -0
- package/dist/ui/button/resources/button-base.svelte.d.ts +13 -0
- package/dist/ui/button/resources/button-theme.svelte +204 -0
- package/dist/ui/button/resources/button-theme.svelte.d.ts +10 -0
- package/dist/ui/button/resources/button-types.d.ts +21 -0
- package/dist/ui/button/resources/button-types.js +23 -0
- package/dist/ui/dynamic-component/cmp.dynamic-component.svelte +5 -0
- package/dist/ui/dynamic-component/cmp.dynamic-component.svelte.d.ts +7 -0
- package/dist/ui/dynamic-component/index.d.ts +2 -0
- package/dist/ui/dynamic-component/index.js +2 -0
- package/dist/ui/dynamic-component/types.svelte.d.ts +11 -0
- package/dist/ui/dynamic-component/types.svelte.js +13 -0
- package/dist/ui/icon/cmp.icon.svelte +113 -0
- package/dist/ui/icon/cmp.icon.svelte.d.ts +8 -0
- package/dist/ui/icon/index.d.ts +2 -0
- package/dist/ui/icon/index.js +2 -0
- package/dist/ui/icon/types.d.ts +9 -0
- package/dist/ui/icon/types.js +10 -0
- package/dist/ui/image/cmp.image-round.svelte +41 -0
- package/dist/ui/image/cmp.image-round.svelte.d.ts +11 -0
- package/dist/ui/image/cmp.image-rounded.svelte +71 -0
- package/dist/ui/image/cmp.image-rounded.svelte.d.ts +11 -0
- package/dist/ui/image/cmp.image-stub.svelte +34 -0
- package/dist/ui/image/cmp.image-stub.svelte.d.ts +18 -0
- package/dist/ui/image/cmp.image.svelte +82 -0
- package/dist/ui/image/cmp.image.svelte.d.ts +13 -0
- package/dist/ui/image/image-state.d.ts +6 -0
- package/dist/ui/image/image-state.js +17 -0
- package/dist/ui/image/index.d.ts +4 -0
- package/dist/ui/image/index.js +4 -0
- package/dist/ui/infinite-scrolling/cmp.infinite-scrolling.svelte +84 -0
- package/dist/ui/infinite-scrolling/cmp.infinite-scrolling.svelte.d.ts +11 -0
- package/dist/ui/infinite-scrolling/index.d.ts +1 -0
- package/dist/ui/infinite-scrolling/index.js +1 -0
- package/dist/ui/line-clamp/cmp.line-clamp.svelte +89 -0
- package/dist/ui/line-clamp/cmp.line-clamp.svelte.d.ts +12 -0
- package/dist/ui/line-clamp/index.d.ts +2 -0
- package/dist/ui/line-clamp/index.js +2 -0
- package/dist/ui/line-clamp/line-clamp-localization.svelte.d.ts +9 -0
- package/dist/ui/line-clamp/line-clamp-localization.svelte.js +15 -0
- package/dist/ui/line-clamp/line-clamp-types.d.ts +3 -0
- package/dist/ui/line-clamp/line-clamp-types.js +1 -0
- package/dist/ui/line-clamp/line-clamp-utils.d.ts +8 -0
- package/dist/ui/line-clamp/line-clamp-utils.js +33 -0
- package/dist/ui/loading/cmp.loading.svelte +97 -0
- package/dist/ui/loading/cmp.loading.svelte.d.ts +9 -0
- package/dist/ui/loading/index.d.ts +1 -0
- package/dist/ui/loading/index.js +1 -0
- package/dist/ui/media-item-view/cmp.media-item-view.svelte +90 -0
- package/dist/ui/media-item-view/cmp.media-item-view.svelte.d.ts +12 -0
- package/dist/ui/media-item-view/index.d.ts +1 -0
- package/dist/ui/media-item-view/index.js +1 -0
- package/dist/ui/media-items-gallery/cmp.media-items-gallery.svelte +277 -0
- package/dist/ui/media-items-gallery/cmp.media-items-gallery.svelte.d.ts +12 -0
- package/dist/ui/media-items-gallery/index.d.ts +1 -0
- package/dist/ui/media-items-gallery/index.js +1 -0
- package/dist/ui/media-items-gallery/types.d.ts +12 -0
- package/dist/ui/media-items-gallery/types.js +35 -0
- package/dist/ui/media-playback/index.d.ts +2 -0
- package/dist/ui/media-playback/index.js +2 -0
- package/dist/ui/media-playback/playback-manager.svelte.d.ts +25 -0
- package/dist/ui/media-playback/playback-manager.svelte.js +62 -0
- package/dist/ui/media-playback/volume-manager.svelte.d.ts +10 -0
- package/dist/ui/media-playback/volume-manager.svelte.js +27 -0
- package/dist/ui/player/cmp.player-slider.svelte +161 -0
- package/dist/ui/player/cmp.player-slider.svelte.d.ts +33 -0
- package/dist/ui/player/index.d.ts +4 -0
- package/dist/ui/player/index.js +3 -0
- package/dist/ui/player/player-buffer.svelte.d.ts +28 -0
- package/dist/ui/player/player-buffer.svelte.js +64 -0
- package/dist/ui/player/prevent-slider-scroll.d.ts +5 -0
- package/dist/ui/player/prevent-slider-scroll.js +11 -0
- package/dist/ui/player/types.d.ts +14 -0
- package/dist/ui/player/types.js +1 -0
- package/dist/ui/progress/cmp.progress.svelte +37 -0
- package/dist/ui/progress/cmp.progress.svelte.d.ts +6 -0
- package/dist/ui/progress/index.d.ts +1 -0
- package/dist/ui/progress/index.js +1 -0
- package/dist/ui/proportional-container/cmp.proportional-container.svelte +39 -0
- package/dist/ui/proportional-container/cmp.proportional-container.svelte.d.ts +8 -0
- package/dist/ui/proportional-container/index.d.ts +1 -0
- package/dist/ui/proportional-container/index.js +1 -0
- package/dist/ui/seek-bar/cmp.seek-bar.svelte +63 -0
- package/dist/ui/seek-bar/cmp.seek-bar.svelte.d.ts +12 -0
- package/dist/ui/seek-bar/index.d.ts +1 -0
- package/dist/ui/seek-bar/index.js +1 -0
- package/dist/ui/shadow-dom/cmp.shadow-dom.svelte +26 -0
- package/dist/ui/shadow-dom/cmp.shadow-dom.svelte.d.ts +7 -0
- package/dist/ui/shadow-dom/index.d.ts +1 -0
- package/dist/ui/shadow-dom/index.js +1 -0
- package/dist/ui/spotlight-layout/cmp.spotlight-layout.svelte +120 -0
- package/dist/ui/spotlight-layout/cmp.spotlight-layout.svelte.d.ts +18 -0
- package/dist/ui/spotlight-layout/index.d.ts +1 -0
- package/dist/ui/spotlight-layout/index.js +1 -0
- package/dist/ui/time-ago/cmp.time-ago.svelte +69 -0
- package/dist/ui/time-ago/cmp.time-ago.svelte.d.ts +9 -0
- package/dist/ui/time-ago/index.d.ts +2 -0
- package/dist/ui/time-ago/index.js +1 -0
- package/dist/ui/time-ago/time-ago-localization.svelte.d.ts +21 -0
- package/dist/ui/time-ago/time-ago-localization.svelte.js +39 -0
- package/dist/ui/video/cmp.video.svelte +377 -0
- package/dist/ui/video/cmp.video.svelte.d.ts +24 -0
- package/dist/ui/video/index.d.ts +1 -0
- package/dist/ui/video/index.js +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export class StringHelper {
|
|
2
|
+
static isBlobUrl(val) {
|
|
3
|
+
return !!val && val.startsWith('blob:');
|
|
4
|
+
}
|
|
5
|
+
static isEmail(val) {
|
|
6
|
+
if (!val) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
10
|
+
return re.test(String(val).toLowerCase());
|
|
11
|
+
}
|
|
12
|
+
static isNumeric(n) {
|
|
13
|
+
const parsed = parseFloat(n);
|
|
14
|
+
return !isNaN(parsed) && isFinite(parsed);
|
|
15
|
+
}
|
|
16
|
+
static isUrl(val) {
|
|
17
|
+
if (!val) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(val);
|
|
22
|
+
return (val.startsWith('http://') || val.startsWith('https://')) && url && ['http:', 'https:'].includes(url.protocol);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
static toKebabCase(str) {
|
|
29
|
+
return (str
|
|
30
|
+
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
|
31
|
+
?.join('-')
|
|
32
|
+
.toLowerCase() || str);
|
|
33
|
+
}
|
|
34
|
+
static toSnakeCase(str) {
|
|
35
|
+
if (!str) {
|
|
36
|
+
return str;
|
|
37
|
+
}
|
|
38
|
+
return str
|
|
39
|
+
.split(/(?=[A-Z])/)
|
|
40
|
+
.join('_')
|
|
41
|
+
.toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
static truncate(str, length) {
|
|
44
|
+
if (str.length <= length) {
|
|
45
|
+
return str;
|
|
46
|
+
}
|
|
47
|
+
str = str.slice(0, length) + '...';
|
|
48
|
+
return str;
|
|
49
|
+
}
|
|
50
|
+
static capitalizeFirstLetter(word) {
|
|
51
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class UrlHelper {
|
|
2
|
+
static getRootDomain(url) {
|
|
3
|
+
let tokens = url.hostname.split('.');
|
|
4
|
+
if (tokens.length <= 2) {
|
|
5
|
+
return url.hostname;
|
|
6
|
+
}
|
|
7
|
+
tokens = tokens.slice(-3);
|
|
8
|
+
if (['co', 'com'].indexOf(tokens[1]) > -1) {
|
|
9
|
+
return tokens.join('.');
|
|
10
|
+
}
|
|
11
|
+
return tokens.slice(-2).join('.');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class Utils {
|
|
2
|
+
static assertUnreachable(_x: never): never;
|
|
3
|
+
static clone<T>(value: T): T;
|
|
4
|
+
/**
|
|
5
|
+
* Find the greatest common divisor of 2 numbers
|
|
6
|
+
*/
|
|
7
|
+
static gcd(a: number, b: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* Find the least dividend and divisor by given quotient
|
|
10
|
+
*/
|
|
11
|
+
static ldd(quotient: number, divisorLimit?: number): {
|
|
12
|
+
dividend: number;
|
|
13
|
+
divisor: number;
|
|
14
|
+
} | null;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a function, that, as long as it continues to be invoked, will not
|
|
17
|
+
* be triggered. The function will be called after it stops being called for
|
|
18
|
+
* N milliseconds.
|
|
19
|
+
*/
|
|
20
|
+
static debounce(func: (...args: any[]) => void, wait: number): (...args: unknown[]) => void;
|
|
21
|
+
static throttle<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => ReturnType<T>;
|
|
22
|
+
static sleep: (s: number) => Promise<void>;
|
|
23
|
+
static nameof: <T>(name: keyof T) => keyof T;
|
|
24
|
+
static unsubscribe(sub: UnsubscribeMethod | UnsubscribeMethod[]): void;
|
|
25
|
+
static notNullValues(target: object): any[];
|
|
26
|
+
}
|
|
27
|
+
export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
28
|
+
export type UnsubscribeMethod = () => void;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export class Utils {
|
|
2
|
+
static assertUnreachable(_x) {
|
|
3
|
+
throw new Error("Didn't expect to get here");
|
|
4
|
+
}
|
|
5
|
+
static clone(value) {
|
|
6
|
+
return structuredClone(value);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Find the greatest common divisor of 2 numbers
|
|
10
|
+
*/
|
|
11
|
+
static gcd(a, b) {
|
|
12
|
+
a = Math.abs(a);
|
|
13
|
+
b = Math.abs(b);
|
|
14
|
+
if (b > a) {
|
|
15
|
+
const temp = a;
|
|
16
|
+
a = b;
|
|
17
|
+
b = temp;
|
|
18
|
+
}
|
|
19
|
+
while (true) {
|
|
20
|
+
if (b === 0) {
|
|
21
|
+
return a;
|
|
22
|
+
}
|
|
23
|
+
a %= b;
|
|
24
|
+
if (a === 0) {
|
|
25
|
+
return b;
|
|
26
|
+
}
|
|
27
|
+
b %= a;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Find the least dividend and divisor by given quotient
|
|
32
|
+
*/
|
|
33
|
+
static ldd(quotient, divisorLimit = 1000000) {
|
|
34
|
+
let divisor = 1;
|
|
35
|
+
while (divisor <= divisorLimit) {
|
|
36
|
+
const dividend = quotient * divisor;
|
|
37
|
+
if (dividend % 1 === 0) {
|
|
38
|
+
return { dividend, divisor };
|
|
39
|
+
}
|
|
40
|
+
divisor++;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns a function, that, as long as it continues to be invoked, will not
|
|
46
|
+
* be triggered. The function will be called after it stops being called for
|
|
47
|
+
* N milliseconds.
|
|
48
|
+
*/
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
static debounce(func, wait) {
|
|
51
|
+
let timeout;
|
|
52
|
+
return (...args) => {
|
|
53
|
+
const later = () => {
|
|
54
|
+
func.apply(this, args);
|
|
55
|
+
};
|
|
56
|
+
clearTimeout(timeout);
|
|
57
|
+
timeout = window.setTimeout(later, wait);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
static throttle(func, wait) {
|
|
62
|
+
// Capture the current time
|
|
63
|
+
let time = Date.now();
|
|
64
|
+
return (...args) => {
|
|
65
|
+
if (time + wait - Date.now() <= 0) {
|
|
66
|
+
time = Date.now();
|
|
67
|
+
// Run the function we've passed to our throttler,
|
|
68
|
+
// and reset the `time` variable (so we can check again).
|
|
69
|
+
return func.apply(this, args);
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
static sleep = async (s) => {
|
|
75
|
+
await setTimeout(() => {
|
|
76
|
+
return;
|
|
77
|
+
}, s);
|
|
78
|
+
};
|
|
79
|
+
static nameof = (name) => name;
|
|
80
|
+
static unsubscribe(sub) {
|
|
81
|
+
if (!sub) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const unsubscribeSingle = (sub) => {
|
|
85
|
+
if (!sub) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
sub();
|
|
89
|
+
};
|
|
90
|
+
if (sub instanceof Array) {
|
|
91
|
+
sub.forEach(unsubscribeSingle);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
unsubscribeSingle(sub);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
static notNullValues(target) {
|
|
98
|
+
return Object.values(target).filter((x) => !!x);
|
|
99
|
+
}
|
|
100
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Currency } from './types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Currency } from './types';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Currency } from './types';
|
|
2
|
+
export declare const toPriceRepresentation: (amount: number, currency: Currency) => string;
|
|
3
|
+
export declare const shouldUseSalePrice: (price: number, salePrice: number | null, effectiveDateFrom: string | null, effectiveDateTo: string | null) => boolean;
|
|
4
|
+
export declare const isSalePriceEffective: (salePrice: number | null, effectiveDateFrom: string | null, effectiveDateTo: string | null) => boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Utils } from '../core/utils';
|
|
2
|
+
import { Currency } from './types';
|
|
3
|
+
export const toPriceRepresentation = (amount, currency) => {
|
|
4
|
+
const hasDecimalPart = amount - Math.floor(amount) !== 0;
|
|
5
|
+
const decimalSeparator = (1.1).toLocaleString().substring(1, 2);
|
|
6
|
+
switch (currency) {
|
|
7
|
+
case Currency.Eur:
|
|
8
|
+
return `€ ${amount}`;
|
|
9
|
+
case Currency.Nok: {
|
|
10
|
+
return hasDecimalPart ? `kr ${amount}` : `kr ${amount}${decimalSeparator}-`;
|
|
11
|
+
}
|
|
12
|
+
case Currency.Usd:
|
|
13
|
+
return `$ ${amount}`;
|
|
14
|
+
default: {
|
|
15
|
+
Utils.assertUnreachable(currency);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const shouldUseSalePrice = (price, salePrice, effectiveDateFrom, effectiveDateTo) => {
|
|
20
|
+
if (!isSalePriceEffective(salePrice, effectiveDateFrom, effectiveDateTo)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return price !== salePrice;
|
|
24
|
+
};
|
|
25
|
+
export const isSalePriceEffective = (salePrice, effectiveDateFrom, effectiveDateTo) => {
|
|
26
|
+
if (!salePrice) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (!effectiveDateFrom && !effectiveDateTo) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
const fromDate = effectiveDateFrom && new Date(effectiveDateFrom);
|
|
34
|
+
const toDate = effectiveDateTo && new Date(effectiveDateTo);
|
|
35
|
+
return (!fromDate || now >= fromDate.getTime()) && (!toDate || now < toDate.getTime());
|
|
36
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script lang="ts">import { toPriceRepresentation } from '../price-helper';
|
|
2
|
+
import { ImageRounded } from '../../ui/image';
|
|
3
|
+
import { ProportionalContainer } from '../../ui/proportional-container';
|
|
4
|
+
import { ProductCardLocalization } from './product-card-localization.svelte';
|
|
5
|
+
let { model, localization: localizationInit, inert = false } = $props();
|
|
6
|
+
const localization = $derived(new ProductCardLocalization(localizationInit));
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div class="product-card" inert={inert}>
|
|
10
|
+
<ProportionalContainer ratio={4 / 5}>
|
|
11
|
+
<ImageRounded src={model.image} noBorders={true} />
|
|
12
|
+
</ProportionalContainer>
|
|
13
|
+
<div class="product-card__name">{model.title}</div>
|
|
14
|
+
<div class="product-card__price">
|
|
15
|
+
<div class="product-price">
|
|
16
|
+
{#if !model.effectiveSalePrice}
|
|
17
|
+
<div class="product-price__price">{toPriceRepresentation(model.price, model.currency)}</div>
|
|
18
|
+
{:else}
|
|
19
|
+
<div class="product-price__before-price">
|
|
20
|
+
{#if localization.beforeNowPrefix}
|
|
21
|
+
{localization.beforeNowPrefix}
|
|
22
|
+
{/if}
|
|
23
|
+
{toPriceRepresentation(model.price, model.currency)}
|
|
24
|
+
</div>
|
|
25
|
+
<div class="product-price__price product-price__price--sale">
|
|
26
|
+
{toPriceRepresentation(model.effectiveSalePrice, model.currency)}
|
|
27
|
+
</div>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
{#if model.link}
|
|
33
|
+
<a href={model.link} target="_blank" rel="noopener noreferrer" class="product-card__link" aria-label="none"> </a>
|
|
34
|
+
{/if}
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<style>@keyframes fadeIn {
|
|
38
|
+
0% {
|
|
39
|
+
opacity: 1;
|
|
40
|
+
}
|
|
41
|
+
50% {
|
|
42
|
+
opacity: 0.4;
|
|
43
|
+
}
|
|
44
|
+
100% {
|
|
45
|
+
opacity: 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
.product-card {
|
|
49
|
+
--_product-card--global--font-size: var(--product-card--global--font-size, 1rem);
|
|
50
|
+
--_product-card--name--align: var(--product-card--name--align, center);
|
|
51
|
+
--_product-card--price--align: var(--product-card--price--align, center);
|
|
52
|
+
--_product-card--price--color: var(--product-card--price--color, var(--product-card--text--color));
|
|
53
|
+
--_product-card--price--font-size: var(--product-card--price--font-size, 1.0625em);
|
|
54
|
+
--_product-card--price--gap: var(--product-card--price--gap, 0.4375em);
|
|
55
|
+
--_product-card--price--before--color: var(--product-card--price--before--color, #e5e7eb);
|
|
56
|
+
--_product-card--price--before--font-size: var(--product-card--price--before--font-size, 0.75em);
|
|
57
|
+
--_product-card--text--color: var(--product-card--text--color);
|
|
58
|
+
--_product-card--before-price--color: var(--product-card--before-price--color, #e5e7eb);
|
|
59
|
+
font-size: var(--_product-card--global--font-size);
|
|
60
|
+
width: 100%;
|
|
61
|
+
position: relative;
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
--image--rounded--outer--border-radius: 0.25em;
|
|
65
|
+
}
|
|
66
|
+
.product-card__name {
|
|
67
|
+
width: 100%;
|
|
68
|
+
color: var(--_product-card--text--color);
|
|
69
|
+
font-size: 0.9375em;
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
margin-top: 0.5em;
|
|
72
|
+
text-align: var(--_product-card--name--align);
|
|
73
|
+
padding: 0 0.3125em;
|
|
74
|
+
text-overflow: ellipsis;
|
|
75
|
+
width: 100%;
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
}
|
|
79
|
+
.product-card__price {
|
|
80
|
+
padding-top: 0.3125em;
|
|
81
|
+
margin-top: auto;
|
|
82
|
+
}
|
|
83
|
+
.product-card__link {
|
|
84
|
+
position: absolute;
|
|
85
|
+
top: 0;
|
|
86
|
+
left: 0;
|
|
87
|
+
width: 100%;
|
|
88
|
+
height: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.product-price {
|
|
92
|
+
--_product-price--gap: var(--product-price--gap, 0.4375em);
|
|
93
|
+
width: 100%;
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: var(--_product-price--gap);
|
|
97
|
+
}
|
|
98
|
+
.product-price__before-price {
|
|
99
|
+
width: 100%;
|
|
100
|
+
color: var(--_product-card--price--before--color);
|
|
101
|
+
text-decoration: line-through;
|
|
102
|
+
font-size: var(--_product-card--price--before--font-size);
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
text-align: var(--_product-card--price--align);
|
|
105
|
+
text-overflow: ellipsis;
|
|
106
|
+
width: 100%;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
}
|
|
110
|
+
.product-price__price {
|
|
111
|
+
width: 100%;
|
|
112
|
+
color: var(--_product-card--price--color);
|
|
113
|
+
font-size: var(--_product-card--price--font-size);
|
|
114
|
+
font-weight: 800;
|
|
115
|
+
margin-top: auto;
|
|
116
|
+
text-align: var(--_product-card--price--align);
|
|
117
|
+
text-overflow: ellipsis;
|
|
118
|
+
width: 100%;
|
|
119
|
+
white-space: nowrap;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
}</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IProductCardLocalization } from './product-card-localization.svelte';
|
|
2
|
+
import type { ProductCardModel } from './types';
|
|
3
|
+
type Props = {
|
|
4
|
+
model: ProductCardModel;
|
|
5
|
+
inert?: boolean;
|
|
6
|
+
localization?: IProductCardLocalization;
|
|
7
|
+
};
|
|
8
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
10
|
+
export default Cmp;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getMediaItemImageUrl } from '../../core/media';
|
|
2
|
+
import { shouldUseSalePrice } from '../price-helper';
|
|
3
|
+
export const mapToProductCard = (payload) => {
|
|
4
|
+
const effectiveSalePrice = payload.priceAndAvailability.productSalePrices?.find((x) => shouldUseSalePrice(payload.priceAndAvailability.price, x.salePrice, x.salePriceEffectiveDateFrom, x.salePriceEffectiveDateTo));
|
|
5
|
+
return {
|
|
6
|
+
id: payload.id,
|
|
7
|
+
title: payload.title,
|
|
8
|
+
image: payload.media.length ? getMediaItemImageUrl(payload.media[0]) : null,
|
|
9
|
+
currency: payload.priceAndAvailability.currency,
|
|
10
|
+
price: payload.priceAndAvailability.price,
|
|
11
|
+
effectiveSalePrice: effectiveSalePrice?.salePrice ?? null,
|
|
12
|
+
link: payload.link
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type * as SchemaTypes from '../../../gql/types';
|
|
2
|
+
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
export type ProductCardPayloadFragment = {
|
|
4
|
+
title: string;
|
|
5
|
+
id: string;
|
|
6
|
+
link: string | null;
|
|
7
|
+
media: Array<{
|
|
8
|
+
url: string;
|
|
9
|
+
thumbnailUrl: string | null;
|
|
10
|
+
type: SchemaTypes.MediaType;
|
|
11
|
+
}>;
|
|
12
|
+
priceAndAvailability: {
|
|
13
|
+
currency: SchemaTypes.Currency;
|
|
14
|
+
price: number;
|
|
15
|
+
productSalePrices: Array<{
|
|
16
|
+
salePrice: number;
|
|
17
|
+
salePriceEffectiveDateFrom: any | null;
|
|
18
|
+
salePriceEffectiveDateTo: any | null;
|
|
19
|
+
}> | null;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const ProductCardPayloadFragmentDoc: DocumentNode<ProductCardPayloadFragment, unknown>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const ProductCardPayloadFragmentDoc = {
|
|
2
|
+
kind: 'Document',
|
|
3
|
+
definitions: [
|
|
4
|
+
{
|
|
5
|
+
kind: 'FragmentDefinition',
|
|
6
|
+
name: { kind: 'Name', value: 'ProductCardPayloadFragment' },
|
|
7
|
+
typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Product' } },
|
|
8
|
+
selectionSet: {
|
|
9
|
+
kind: 'SelectionSet',
|
|
10
|
+
selections: [
|
|
11
|
+
{
|
|
12
|
+
kind: 'Field',
|
|
13
|
+
name: { kind: 'Name', value: 'media' },
|
|
14
|
+
selectionSet: {
|
|
15
|
+
kind: 'SelectionSet',
|
|
16
|
+
selections: [
|
|
17
|
+
{
|
|
18
|
+
kind: 'Field',
|
|
19
|
+
name: { kind: 'Name', value: 'url' },
|
|
20
|
+
arguments: [
|
|
21
|
+
{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'Variable', name: { kind: 'Name', value: 'image_scale' } } }
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
kind: 'Field',
|
|
26
|
+
name: { kind: 'Name', value: 'thumbnailUrl' },
|
|
27
|
+
arguments: [
|
|
28
|
+
{ kind: 'Argument', name: { kind: 'Name', value: 'scale' }, value: { kind: 'Variable', name: { kind: 'Name', value: 'image_scale' } } }
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'type' } }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'title' } },
|
|
36
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
|
|
37
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'link' } },
|
|
38
|
+
{
|
|
39
|
+
kind: 'Field',
|
|
40
|
+
name: { kind: 'Name', value: 'priceAndAvailability' },
|
|
41
|
+
selectionSet: {
|
|
42
|
+
kind: 'SelectionSet',
|
|
43
|
+
selections: [
|
|
44
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'currency' } },
|
|
45
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'price' } },
|
|
46
|
+
{
|
|
47
|
+
kind: 'Field',
|
|
48
|
+
name: { kind: 'Name', value: 'productSalePrices' },
|
|
49
|
+
selectionSet: {
|
|
50
|
+
kind: 'SelectionSet',
|
|
51
|
+
selections: [
|
|
52
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'salePrice' } },
|
|
53
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateFrom' } },
|
|
54
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'salePriceEffectiveDateTo' } }
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
fragment ProductCardPayloadFragment on Product {
|
|
2
|
+
media {
|
|
3
|
+
url(scale: $image_scale)
|
|
4
|
+
thumbnailUrl(scale: $image_scale)
|
|
5
|
+
type
|
|
6
|
+
}
|
|
7
|
+
title
|
|
8
|
+
id
|
|
9
|
+
link
|
|
10
|
+
priceAndAvailability {
|
|
11
|
+
currency
|
|
12
|
+
price
|
|
13
|
+
productSalePrices {
|
|
14
|
+
salePrice
|
|
15
|
+
salePriceEffectiveDateFrom
|
|
16
|
+
salePriceEffectiveDateTo
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Currency } from '..';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts">import { getMediaItemImageUrl } from '../../core/media';
|
|
2
|
+
import { Icon, IconColor } from '../../ui/icon';
|
|
3
|
+
import { ImageRounded } from '../../ui/image';
|
|
4
|
+
import IconTargetArrow from '@fluentui/svg-icons/icons/target_arrow_20_regular.svg';
|
|
5
|
+
let { model } = $props();
|
|
6
|
+
const attachmentsToShow = $derived.by(() => {
|
|
7
|
+
const products = model.products.filter((p) => !!p.image).map((p) => ({ isAd: false, image: p.image, link: p.link }));
|
|
8
|
+
const ads = (model.ad ? [model.ad] : []).filter((a) => !!a.media).map((a) => ({ isAd: true, image: getMediaItemImageUrl(a.media), link: a.buttonUrl }));
|
|
9
|
+
return [...products, ...ads];
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class="attachments-inline-container">
|
|
14
|
+
<div class="attachments-inline">
|
|
15
|
+
{#each attachmentsToShow as attachment (attachment)}
|
|
16
|
+
<div class="attachments-inline__item" onclick={() => attachment.link && window.open(attachment.link, '_blank')} onkeydown={() => {}} role="none">
|
|
17
|
+
<ImageRounded src={attachment.image} alt="" />
|
|
18
|
+
{#if attachment.isAd}
|
|
19
|
+
<div class="attachments-inline__item-icon">
|
|
20
|
+
<Icon src={IconTargetArrow} color={IconColor.White} />
|
|
21
|
+
</div>
|
|
22
|
+
{/if}
|
|
23
|
+
</div>
|
|
24
|
+
{/each}
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<style>@keyframes fadeIn {
|
|
29
|
+
0% {
|
|
30
|
+
opacity: 1;
|
|
31
|
+
}
|
|
32
|
+
50% {
|
|
33
|
+
opacity: 0.4;
|
|
34
|
+
}
|
|
35
|
+
100% {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
.attachments-inline-container {
|
|
40
|
+
flex: 1;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
min-height: 0;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
justify-content: flex-end;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.attachments-inline {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
gap: 0.5rem;
|
|
52
|
+
flex-wrap: wrap;
|
|
53
|
+
height: 100%;
|
|
54
|
+
justify-content: flex-end;
|
|
55
|
+
}
|
|
56
|
+
.attachments-inline__item {
|
|
57
|
+
--image--rounded--width: 3.125rem;
|
|
58
|
+
--image--rounded--height: 3.75rem;
|
|
59
|
+
--image--rounded--inner--border-width: 0;
|
|
60
|
+
--image--rounded--outer--border-radius: 0.25rem;
|
|
61
|
+
--image--rounded--outer--border-width: 1px;
|
|
62
|
+
--image--rounded--outer--border-color: #f3f4f6;
|
|
63
|
+
position: relative;
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
.attachments-inline__item-icon {
|
|
67
|
+
position: absolute;
|
|
68
|
+
bottom: 2px;
|
|
69
|
+
right: 2px;
|
|
70
|
+
--icon--size: 1rem;
|
|
71
|
+
}</style>
|