Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@muzikanto/picture

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@muzikanto/picture - npm Package Compare versions

Comparing version 1.0.0-beta to 1.0.0

picture.gif

48

index.d.ts
import { SvgIconProps } from '@material-ui/core/SvgIcon';
import { CardMediaProps } from '@material-ui/core/CardMedia';
import { CircularProgressProps } from '@material-ui/core/CircularProgress';
import { WithStyles } from '@material-ui/core/styles/withStyles';
import React from 'react';
declare type Omit<T, K extends keyof any> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
declare const styles: () => {
root: {
width: string;
position: "relative";
overflow: string;
paddingTop: ({ aspectRatio }: Pick<PictureProps, "src" | "className" | "style" | "aspectRatio" | "disableError" | "disableSpinner" | "disableTransition" | "loading" | "renderLoading" | "renderError" | "onClick" | "onLoad" | "onError" | "ContainerProps" | "MediaProps" | "ProgressProps" | "ErrorProps">) => string;
};
image: {
width: string;
height: string;
position: "absolute";
top: number;
left: number;
transition: ({ disableTransition }: Pick<PictureProps, "src" | "className" | "style" | "aspectRatio" | "disableError" | "disableSpinner" | "disableTransition" | "loading" | "renderLoading" | "renderError" | "onClick" | "onLoad" | "onError" | "ContainerProps" | "MediaProps" | "ProgressProps" | "ErrorProps">) => string | undefined;
};
empty: {
opacity: number;
};
status: {
position: "absolute";
top: string;
left: string;
transform: string;
};
progress: {};
error: {
color: string;
fontSize: number;
};
};
export interface PictureProps extends WithStyles<typeof styles> {
import { Omit, StandardProps } from "@material-ui/core";
export declare type PictureClassKey = 'root' | 'image' | 'empty' | 'status' | 'progress' | 'error';
export interface PictureProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>, PictureClassKey> {
src: string;

@@ -46,12 +16,8 @@ className?: string;

loading?: boolean;
renderLoading?: (props: {
className: string;
}) => React.ReactNode;
renderError?: (props: {
className: string;
}) => React.ReactNode;
renderLoading?: () => React.ReactNode;
renderError?: () => React.ReactNode;
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
onLoad?: () => void;
onError?: () => void;
ContainerProps?: Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'>;
ContainerProps?: Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'className' | 'style'>;
MediaProps?: Omit<CardMediaProps<'img'>, 'src' | 'component' | 'onLoad' | 'onError'>;

@@ -61,3 +27,3 @@ ProgressProps?: CircularProgressProps;

}
declare const Picture: React.MemoExoticComponent<React.ComponentType<Pick<PictureProps, "src" | "className" | "style" | "aspectRatio" | "disableError" | "disableSpinner" | "disableTransition" | "loading" | "renderLoading" | "renderError" | "onClick" | "onLoad" | "onError" | "ContainerProps" | "MediaProps" | "ProgressProps" | "ErrorProps"> & import("@material-ui/styles/withStyles/withStyles").StyledComponentProps<"progress" | "image" | "root" | "empty" | "status" | "error">>>;
declare const Picture: React.MemoExoticComponent<React.ComponentType<Pick<PictureProps, "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | "ref" | "innerRef" | "src" | "disableError" | "disableSpinner" | "aspectRatio" | "disableTransition" | "loading" | "renderLoading" | "renderError" | "ContainerProps" | "MediaProps" | "ProgressProps" | "ErrorProps"> & import("@material-ui/core").StyledComponentProps<PictureClassKey>>>;
export default Picture;

@@ -46,3 +46,4 @@ "use strict";

function Component(props) {
const { classes, disableError, disableSpinner, onClick } = props;
const { disableError, disableSpinner, onClick } = props;
const classes = props.classes;
const [state, setState] = react_1.default.useState({ src: '', error: false, loaded: false });

@@ -66,17 +67,12 @@ react_1.default.useEffect(() => {

const showError = !disableError && state.error;
return (react_1.default.createElement("div", Object.assign({}, props.ContainerProps, { className: clsx_1.default(classes.root, props.ContainerProps && props.ContainerProps.className, props.className), onClick: onClick }),
react_1.default.createElement("img", null),
return (react_1.default.createElement("div", Object.assign({}, props.ContainerProps, { className: clsx_1.default(classes.root, props.className), onClick: onClick, style: props.style }),
(state.src && !props.loading && !state.error) && (react_1.default.createElement(CardMedia_1.default, Object.assign({ component: 'img' }, props.MediaProps, { className: clsx_1.default(classes.image, {
[classes.empty]: !state.loaded,
}, props.MediaProps && props.MediaProps.className), src: state.src, onLoad: handleLoadImage, onError: handleImageError }))),
(showLoading || showError) && (react_1.default.createElement(react_1.default.Fragment, null,
(showLoading || showError) && (react_1.default.createElement("div", { className: classes.status },
showLoading && (react_1.default.createElement("div", { className: classes.status }, props.renderLoading ?
props.renderLoading({
className: clsx_1.default(classes.progress, props.ProgressProps && props.ProgressProps.className),
}) :
props.renderLoading() :
react_1.default.createElement(CircularProgress_1.default, Object.assign({}, props.ProgressProps, { className: clsx_1.default(classes.progress, props.ProgressProps && props.ProgressProps.className) })))),
showError && (react_1.default.createElement(react_1.default.Fragment, null, props.renderError ?
props.renderError({
className: clsx_1.default(classes.status, classes.error, props.ErrorProps && props.ErrorProps.className),
}) :
props.renderError() :
react_1.default.createElement(SvgIcon_1.default, Object.assign({ viewBox: "0 0 384 384", width: "40", height: "40" }, props.ErrorProps, { className: clsx_1.default(classes.status, classes.error, props.ErrorProps && props.ErrorProps.className) }),

@@ -83,0 +79,0 @@ react_1.default.createElement("path", { d: "M234.667,264.533L149.333,179.2L64,264.533l-64-64v140.8C0,364.8,19.2,384,42.667,384h298.667 C364.8,384,384,364.8,384,341.333V243.2l-64-64L234.667,264.533z" }),

{
"name": "@muzikanto/picture",
"version": "1.0.0-beta",
"version": "1.0.0",
"description": "image component",
"license": "MIT",

@@ -5,0 +6,0 @@ "main": "./index.js",

@@ -12,2 +12,3 @@ ## Observable and Observable-form

- [Installation](#installation)
- [Preview](#preview)
- [Examples](#examples)

@@ -27,2 +28,6 @@ - [base](#base)

## Preview
![](./picture.gif)
## Installation

@@ -29,0 +34,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc