UNPKG

react-loader-spinner

Version:

react-spinner-loader provides simple React.js spinner component which can be implemented for async wait operation before data load to the view.

1 lines 6.54 kB
{"version":3,"sources":["../src/type.ts","../src/shared/svg-wrapper.tsx","../src/shared/constants.ts","../src/loader/puff.tsx"],"names":["DEFAULT_COLOR","DEFAULT_WAI_ARIA_ATTRIBUTE","SvgWrapper","styled","props","SVG_NAMESPACE","Puff","height","width","radius","color","ariaLabel","wrapperStyle","wrapperClass","visible","jsx","jsxs"],"mappings":"wMAEO,IAAMA,CAAAA,CAAgB,SAAA,CAEhBC,CAAAA,CAA6B,CACxC,YAAa,IAAA,CACb,IAAA,CAAM,aACR,CAAA,CCLO,IAAMC,EAAaC,kBAAAA,CAAO,GAAA;AAAA,WAAA,EACpBC,CAAAA,EAAUA,CAAAA,CAAM,QAAA,CAAW,MAAA,CAAS,MAAO,CAAA;ACHjD,CAAA,CAAA,IAAMC,EAAgB,4BAAA,CCwCtB,IAAMC,CAAAA,CAAqC,CAAC,CACjD,MAAA,CAAAC,CAAAA,CAAS,GACT,KAAA,CAAAC,CAAAA,CAAQ,GACR,MAAA,CAAAC,CAAAA,CAAS,CAAA,CACT,KAAA,CAAAC,EAAQV,CAAAA,CACR,SAAA,CAAAW,EAAY,cAAA,CACZ,YAAA,CAAAC,EACA,YAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CAAU,IACZ,CAAA,GACEC,cAAAA,CAACb,EAAA,CACC,KAAA,CAAOU,EACP,QAAA,CAAUE,CAAAA,CACV,SAAA,CAAWD,CAAAA,CACX,cAAY,cAAA,CACZ,YAAA,CAAYF,EACX,GAAGV,CAAAA,CAEJ,SAAAc,cAAAA,CAAC,KAAA,CAAA,CACC,KAAA,CAAOP,CAAAA,CACP,OAAQD,CAAAA,CACR,OAAA,CAAQ,YACR,KAAA,CAAOF,CAAAA,CACP,OAAQK,CAAAA,CACR,aAAA,CAAY,UAAA,CAEZ,QAAA,CAAAM,gBAAC,GAAA,CAAA,CAAE,IAAA,CAAK,OAAO,QAAA,CAAS,SAAA,CAAU,YAAY,GAAA,CAC5C,QAAA,CAAA,CAAAA,eAAAA,CAAC,QAAA,CAAA,CAAO,GAAG,IAAA,CAAK,EAAA,CAAG,KAAK,CAAA,CAAGP,CAAAA,CACzB,UAAAM,cAAAA,CAAC,SAAA,CAAA,CACC,aAAA,CAAc,GAAA,CACd,MAAM,IAAA,CACN,GAAA,CAAI,OACJ,MAAA,CAAO,OAAA,CACP,SAAS,QAAA,CACT,QAAA,CAAS,MAAA,CACT,UAAA,CAAW,uBACX,WAAA,CAAY,YAAA,CACd,EACAA,cAAAA,CAAC,SAAA,CAAA,CACC,cAAc,eAAA,CACd,KAAA,CAAM,IAAA,CACN,GAAA,CAAI,OACJ,MAAA,CAAO,MAAA,CACP,SAAS,QAAA,CACT,QAAA,CAAS,OACT,UAAA,CAAW,qBAAA,CACX,WAAA,CAAY,YAAA,CACd,GACF,CAAA,CACAC,eAAAA,CAAC,UAAO,EAAA,CAAG,IAAA,CAAK,GAAG,IAAA,CAAK,CAAA,CAAGP,CAAAA,CACzB,QAAA,CAAA,CAAAM,eAAC,SAAA,CAAA,CACC,aAAA,CAAc,IACd,KAAA,CAAM,OAAA,CACN,IAAI,MAAA,CACJ,MAAA,CAAO,OAAA,CACP,QAAA,CAAS,SACT,QAAA,CAAS,MAAA,CACT,WAAW,sBAAA,CACX,WAAA,CAAY,aACd,CAAA,CACAA,cAAAA,CAAC,SAAA,CAAA,CACC,aAAA,CAAc,gBACd,KAAA,CAAM,OAAA,CACN,IAAI,MAAA,CACJ,MAAA,CAAO,OACP,QAAA,CAAS,QAAA,CACT,QAAA,CAAS,MAAA,CACT,WAAW,qBAAA,CACX,WAAA,CAAY,aACd,CAAA,CAAA,CACF,CAAA,CAAA,CACF,EACF,CAAA,CACF","file":"puff.cjs","sourcesContent":["import { CSSProperties } from 'react'\n\nexport const DEFAULT_COLOR = '#4fa94d'\n\nexport const DEFAULT_WAI_ARIA_ATTRIBUTE = {\n 'aria-busy': true,\n role: 'progressbar',\n}\n\n// Reuse React's CSSProperties for consistent style typing across components\nexport type Style = CSSProperties\n\n// PrimaryProps includes common props shared by experimental components\nexport interface PrimaryProps {\n height?: string | number\n width?: string | number\n color?: string\n ariaLabel?: string\n wrapperStyle?: CSSProperties\n wrapperClass?: string\n visible?: boolean\n}\n\n\n","import styled from 'styled-components'\n\nexport const SvgWrapper = styled.div<{ $visible: boolean }>`\n display: ${props => (props.$visible ? 'flex' : 'none')};\n`\n","export const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'\n","import { FunctionComponent, CSSProperties } from 'react'\nimport { DEFAULT_COLOR, DEFAULT_WAI_ARIA_ATTRIBUTE } from '../type'\nimport { SvgWrapper } from '../shared/svg-wrapper'\nimport { SVG_NAMESPACE } from '../shared/constants'\n\n/**\n * Props for the Puff loader component.\n * \n * The Puff loader displays a puffing cloud-like animation that expands and contracts.\n * \n * @interface PuffProps\n */\ninterface PuffProps {\n /** Height of the SVG (number interpreted as px). */\n height?: string | number\n /** Width of the SVG (number interpreted as px). */\n width?: string | number\n /** Primary color applied to the loader. Defaults to DEFAULT_COLOR. */\n color?: string\n /** Accessible label announced to screen readers. */\n ariaLabel?: string\n /** Inline style object applied to the wrapper element. */\n wrapperStyle?: CSSProperties\n /** CSS class applied to the wrapper for custom styling. */\n wrapperClass?: string\n /** When false, the loader is not rendered. Defaults to true. */\n visible?: boolean\n /** \n * Provide multiple colors to render a gradient instead of a solid color.\n * When 2 or more colors are supplied a gradient will be applied to the loader.\n */\n colors?: string[]\n /** Type of gradient (linear or radial). Defaults to linear. */\n gradientType?: 'linear' | 'radial'\n /** Angle (in degrees) applied via rotate() transform for linear gradients. */\n gradientAngle?: number\n radius?: string | number\n secondaryColor?: string\n}\n\nexport const Puff: FunctionComponent<PuffProps> = ({\n height = 80,\n width = 80,\n radius = 1,\n color = DEFAULT_COLOR,\n ariaLabel = 'puff-loading',\n wrapperStyle,\n wrapperClass,\n visible = true,\n}) => (\n <SvgWrapper\n style={wrapperStyle}\n $visible={visible}\n className={wrapperClass}\n data-testid=\"puff-loading\"\n aria-label={ariaLabel}\n {...DEFAULT_WAI_ARIA_ATTRIBUTE}\n >\n <svg\n width={width}\n height={height}\n viewBox=\"0 0 44 44\"\n xmlns={SVG_NAMESPACE}\n stroke={color}\n data-testid=\"puff-svg\"\n >\n <g fill=\"none\" fillRule=\"evenodd\" strokeWidth=\"2\">\n <circle cx=\"22\" cy=\"22\" r={radius}>\n <animate\n attributeName=\"r\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"strokeOpacity\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n <circle cx=\"22\" cy=\"22\" r={radius}>\n <animate\n attributeName=\"r\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"strokeOpacity\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n </g>\n </svg>\n </SvgWrapper>\n)\n"]}