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 7.65 kB
{"version":3,"sources":["../src/type.ts","../src/shared/svg-wrapper.tsx","../src/shared/constants.ts","../src/loader/rings.tsx"],"names":["DEFAULT_COLOR","DEFAULT_WAI_ARIA_ATTRIBUTE","SvgWrapper","styled","props","SVG_NAMESPACE","Rings","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;ECHjD,IAAMC,CAAAA,CAAgB,4BAAA,CCuCtB,IAAMC,CAAAA,CAAuC,CAAC,CACnD,OAAAC,CAAAA,CAAS,EAAA,CACT,KAAA,CAAAC,CAAAA,CAAQ,EAAA,CACR,MAAA,CAAAC,EAAS,CAAA,CACT,KAAA,CAAAC,CAAAA,CAAQV,CAAAA,CACR,SAAA,CAAAW,CAAAA,CAAY,gBACZ,YAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CAAU,IACZ,CAAA,GACEC,cAAAA,CAACb,CAAAA,CAAA,CACC,KAAA,CAAOU,CAAAA,CACP,SAAUE,CAAAA,CACV,SAAA,CAAWD,CAAAA,CACX,aAAA,CAAY,eAAA,CACZ,YAAA,CAAYF,EACX,GAAGV,CAAAA,CAEJ,QAAA,CAAAc,cAAAA,CAAC,KAAA,CAAA,CACC,KAAA,CAAOP,EACP,MAAA,CAAQD,CAAAA,CACR,OAAA,CAAQ,WAAA,CACR,KAAA,CAAOF,CAAAA,CACP,OAAQK,CAAAA,CACR,aAAA,CAAY,WAAA,CAEZ,QAAA,C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AA,CACT,WAAA,CAAY,aACd,CAAA,CACAA,cAAAA,CAAC,SAAA,CAAA,CACC,aAAA,CAAc,aAAA,CACd,KAAA,CAAM,KACN,GAAA,CAAI,IAAA,CACJ,MAAA,CAAO,KAAA,CACP,QAAA,CAAS,QAAA,CACT,YAAY,YAAA,CACd,CAAA,CAAA,CACF,CAAA,CACAA,cAAAA,CAAC,QAAA,CAAA,CAAO,EAAA,CAAG,KAAK,EAAA,CAAG,IAAA,CAAK,CAAA,CAAG,MAAA,CAAON,CAAM,CAAA,CAAI,EAC1C,QAAA,CAAAM,cAAAA,CAAC,SAAA,CAAA,CACC,aAAA,CAAc,GAAA,CACd,KAAA,CAAM,KACN,GAAA,CAAI,MAAA,CACJ,MAAA,CAAO,eAAA,CACP,QAAA,CAAS,QAAA,CACT,YAAY,YAAA,CACd,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CACF","file":"rings.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 Rings loader component.\n * \n * The Rings loader shows multiple concentric rings that rotate at different speeds.\n * \n * @interface RingsProps\n */\ninterface RingsProps {\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}\n\nexport const Rings: FunctionComponent<RingsProps> = ({\n height = 80,\n width = 80,\n radius = 6,\n color = DEFAULT_COLOR,\n ariaLabel = 'rings-loading',\n wrapperStyle,\n wrapperClass,\n visible = true,\n}) => (\n <SvgWrapper\n style={wrapperStyle}\n $visible={visible}\n className={wrapperClass}\n data-testid=\"rings-loading\"\n aria-label={ariaLabel}\n {...DEFAULT_WAI_ARIA_ATTRIBUTE}\n >\n <svg\n width={width}\n height={height}\n viewBox=\"0 0 45 45\"\n xmlns={SVG_NAMESPACE}\n stroke={color}\n data-testid=\"rings-svg\"\n >\n <g\n fill=\"none\"\n fillRule=\"evenodd\"\n transform=\"translate(1 1)\"\n strokeWidth=\"2\"\n >\n <circle cx=\"22\" cy=\"22\" r={radius} strokeOpacity=\"0\">\n <animate\n attributeName=\"r\"\n begin=\"1.5s\"\n dur=\"3s\"\n values=\"6;22\"\n calcMode=\"linear\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"1.5s\"\n dur=\"3s\"\n values=\"1;0\"\n calcMode=\"linear\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-width\"\n begin=\"1.5s\"\n dur=\"3s\"\n values=\"2;0\"\n calcMode=\"linear\"\n repeatCount=\"indefinite\"\n />\n </circle>\n <circle cx=\"22\" cy=\"22\" r={radius} strokeOpacity=\"0\">\n <animate\n attributeName=\"r\"\n begin=\"3s\"\n dur=\"3s\"\n values=\"6;22\"\n calcMode=\"linear\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"strokeOpacity\"\n begin=\"3s\"\n dur=\"3s\"\n values=\"1;0\"\n calcMode=\"linear\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"strokeWidth\"\n begin=\"3s\"\n dur=\"3s\"\n values=\"2;0\"\n calcMode=\"linear\"\n repeatCount=\"indefinite\"\n />\n </circle>\n <circle cx=\"22\" cy=\"22\" r={Number(radius) + 2}>\n <animate\n attributeName=\"r\"\n begin=\"0s\"\n dur=\"1.5s\"\n values=\"6;1;2;3;4;5;6\"\n calcMode=\"linear\"\n repeatCount=\"indefinite\"\n />\n </circle>\n </g>\n </svg>\n </SvgWrapper>\n)\n"]}