@elvia/elvis-spotlight 1.4.1 → 1.4.3

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.
@@ -2,83 +2,5 @@
2
2
  * THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE OVERWRITTEN.
3
3
  * DO NOT MAKE CHANGES TO THIS FILE DIRECTLY
4
4
  */
5
- "use strict";
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.default = void 0;
11
-
12
- var _react = _interopRequireDefault(require("react"));
13
-
14
- var _styledComponents = require("./styledComponents");
15
-
16
- var _useLockBodyScroll = require("./useLockBodyScroll");
17
-
18
- var _excluded = ["position", "shape", "radius", "hasLockBodyScroll", "transitionDuration", "rectangleProps", "className", "inlineStyle"];
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
-
24
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
25
-
26
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
27
-
28
- var Spotlight = function Spotlight(_ref) {
29
- var position = _ref.position,
30
- _ref$shape = _ref.shape,
31
- shape = _ref$shape === void 0 ? 'circle' : _ref$shape,
32
- _ref$radius = _ref.radius,
33
- radius = _ref$radius === void 0 ? 200 : _ref$radius,
34
- _ref$hasLockBodyScrol = _ref.hasLockBodyScroll,
35
- hasLockBodyScroll = _ref$hasLockBodyScrol === void 0 ? true : _ref$hasLockBodyScrol,
36
- _ref$transitionDurati = _ref.transitionDuration,
37
- transitionDuration = _ref$transitionDurati === void 0 ? '350ms' : _ref$transitionDurati,
38
- _ref$rectangleProps = _ref.rectangleProps,
39
- rectangleProps = _ref$rectangleProps === void 0 ? {
40
- width: 200,
41
- height: 200,
42
- borderRadius: 8
43
- } : _ref$rectangleProps,
44
- className = _ref.className,
45
- inlineStyle = _ref.inlineStyle,
46
- rest = _objectWithoutProperties(_ref, _excluded);
47
-
48
- var hasPosition = position && position.horizontal !== undefined && position.vertical !== undefined;
49
- (0, _useLockBodyScroll.useLockBodyScroll)(hasLockBodyScroll);
50
- return hasPosition ? /*#__PURE__*/_react.default.createElement("div", _extends({
51
- className: "".concat(className ? className : ''),
52
- style: inlineStyle
53
- }, rest), /*#__PURE__*/_react.default.createElement(_styledComponents.SpotlightArea, null, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("mask", {
54
- id: "hole"
55
- }, /*#__PURE__*/_react.default.createElement("rect", {
56
- width: "100%",
57
- height: "100%",
58
- fill: "white"
59
- }), shape === 'circle' ? /*#__PURE__*/_react.default.createElement(_styledComponents.SpotlightCircle, {
60
- transitionDuration: transitionDuration,
61
- r: radius,
62
- cx: position.horizontal,
63
- cy: position.vertical,
64
- fill: "black"
65
- }) : /*#__PURE__*/_react.default.createElement(_styledComponents.SpotlightRect, {
66
- transitionDuration: transitionDuration,
67
- width: rectangleProps.width,
68
- height: rectangleProps.height,
69
- x: position.horizontal,
70
- y: position.vertical,
71
- rx: rectangleProps.borderRadius,
72
- ry: rectangleProps.borderRadius,
73
- fill: "black"
74
- }))), /*#__PURE__*/_react.default.createElement("rect", {
75
- fill: "rgba(0,0,0,0.25)",
76
- width: "100%",
77
- height: "100%",
78
- mask: "url(#hole)"
79
- }))) : /*#__PURE__*/_react.default.createElement("div", null);
80
- };
81
-
82
- var _default = Spotlight;
83
- exports.default = _default;
5
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=_interopRequireDefault(require("react")),_styledComponents=require("./styledComponents"),_useLockBodyScroll=require("./useLockBodyScroll"),_excluded=["position","shape","radius","hasLockBodyScroll","transitionDuration","rectangleProps","className","inlineStyle"];function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _extends(){return _extends=Object.assign?Object.assign.bind():function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}var Spotlight=function(a){var b=a.position,c=a.shape,d=void 0===c?"circle":c,e=a.radius,f=void 0===e?200:e,g=a.hasLockBodyScroll,h=a.transitionDuration,i=void 0===h?"350ms":h,j=a.rectangleProps,k=void 0===j?{width:200,height:200,borderRadius:8}:j,l=a.className,m=a.inlineStyle,n=_objectWithoutProperties(a,_excluded),o=b&&void 0!==b.horizontal&&void 0!==b.vertical;return(0,_useLockBodyScroll.useLockBodyScroll)(void 0===g||g),o?/*#__PURE__*/_react.default.createElement("div",_extends({className:"".concat(l?l:""),style:m},n),/*#__PURE__*/_react.default.createElement(_styledComponents.SpotlightArea,null,/*#__PURE__*/_react.default.createElement("defs",null,/*#__PURE__*/_react.default.createElement("mask",{id:"hole"},/*#__PURE__*/_react.default.createElement("rect",{width:"100%",height:"100%",fill:"white"}),"circle"===d?/*#__PURE__*/_react.default.createElement(_styledComponents.SpotlightCircle,{transitionDuration:i,r:f,cx:b.horizontal,cy:b.vertical,fill:"black"}):/*#__PURE__*/_react.default.createElement(_styledComponents.SpotlightRect,{transitionDuration:i,width:k.width,height:k.height,x:b.horizontal,y:b.vertical,rx:k.borderRadius,ry:k.borderRadius,fill:"black"}))),/*#__PURE__*/_react.default.createElement("rect",{fill:"rgba(0,0,0,0.25)",width:"100%",height:"100%",mask:"url(#hole)"}))):/*#__PURE__*/_react.default.createElement("div",null)},_default=Spotlight;exports.default=_default;
84
6
  //# sourceMappingURL=elvia-spotlight.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["elvia-spotlight.tsx"],"names":["Spotlight","position","shape","radius","hasLockBodyScroll","transitionDuration","rectangleProps","width","height","borderRadius","className","inlineStyle","rest","hasPosition","horizontal","undefined","vertical","useLockBodyScroll"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;AA0BA,IAAMA,SAA6B,GAAG,SAAhCA,SAAgC,OAUhC;EAAA,IATJC,QASI,QATJA,QASI;EAAA,sBARJC,KAQI;EAAA,IARJA,KAQI,2BARI,QAQJ;EAAA,uBAPJC,MAOI;EAAA,IAPJA,MAOI,4BAPK,GAOL;EAAA,iCANJC,iBAMI;EAAA,IANJA,iBAMI,sCANgB,IAMhB;EAAA,iCALJC,kBAKI;EAAA,IALJA,kBAKI,sCALiB,OAKjB;EAAA,+BAJJC,cAII;EAAA,IAJJA,cAII,oCAJa;IAAEC,KAAK,EAAE,GAAT;IAAcC,MAAM,EAAE,GAAtB;IAA2BC,YAAY,EAAE;EAAzC,CAIb;EAAA,IAHJC,SAGI,QAHJA,SAGI;EAAA,IAFJC,WAEI,QAFJA,WAEI;EAAA,IADDC,IACC;;EACJ,IAAMC,WAAW,GAAGZ,QAAQ,IAAIA,QAAQ,CAACa,UAAT,KAAwBC,SAApC,IAAiDd,QAAQ,CAACe,QAAT,KAAsBD,SAA3F;EACA,IAAAE,oCAAA,EAAkBb,iBAAlB;EAEA,OAAOS,WAAW,gBAChB;IAAK,SAAS,YAAKH,SAAS,GAAGA,SAAH,GAAe,EAA7B,CAAd;IAAiD,KAAK,EAAEC;EAAxD,GAAyEC,IAAzE,gBACE,6BAAC,+BAAD,qBACE,wDACE;IAAM,EAAE,EAAC;EAAT,gBACE;IAAM,KAAK,EAAC,MAAZ;IAAmB,MAAM,EAAC,MAA1B;IAAiC,IAAI,EAAC;EAAtC,EADF,EAEGV,KAAK,KAAK,QAAV,gBACC,6BAAC,iCAAD;IACE,kBAAkB,EAAEG,kBADtB;IAEE,CAAC,EAAEF,MAFL;IAGE,EAAE,EAAEF,QAAQ,CAACa,UAHf;IAIE,EAAE,EAAEb,QAAQ,CAACe,QAJf;IAKE,IAAI,EAAC;EALP,EADD,gBASC,6BAAC,+BAAD;IACE,kBAAkB,EAAEX,kBADtB;IAEE,KAAK,EAAEC,cAAc,CAACC,KAFxB;IAGE,MAAM,EAAED,cAAc,CAACE,MAHzB;IAIE,CAAC,EAAEP,QAAQ,CAACa,UAJd;IAKE,CAAC,EAAEb,QAAQ,CAACe,QALd;IAME,EAAE,EAAEV,cAAc,CAACG,YANrB;IAOE,EAAE,EAAEH,cAAc,CAACG,YAPrB;IAQE,IAAI,EAAC;EARP,EAXJ,CADF,CADF,eA0BE;IAAM,IAAI,EAAC,kBAAX;IAA8B,KAAK,EAAC,MAApC;IAA2C,MAAM,EAAC,MAAlD;IAAyD,IAAI,EAAC;EAA9D,EA1BF,CADF,CADgB,gBAgChB,yCAhCF;AAkCD,CAhDD;;eAkDeT,S","file":"elvia-spotlight.js","sourcesContent":["import React, { CSSProperties, FC } from 'react';\r\nimport { SpotlightArea, SpotlightCircle, SpotlightRect } from './styledComponents';\r\nimport { useLockBodyScroll } from './useLockBodyScroll';\r\n\r\nexport type SpotlightShape = 'circle' | 'rectangle';\r\n\r\nexport interface SpotlightPosition {\r\n vertical: number;\r\n horizontal: number;\r\n}\r\n\r\nexport interface SpotlightRectangleProps {\r\n width?: number;\r\n height?: number;\r\n borderRadius?: number;\r\n}\r\n\r\nexport interface SpotlightProps {\r\n position: SpotlightPosition | undefined;\r\n shape?: SpotlightShape;\r\n radius?: number;\r\n rectangleProps?: SpotlightRectangleProps;\r\n hasLockBodyScroll?: boolean;\r\n transitionDuration?: string;\r\n className?: string;\r\n inlineStyle?: CSSProperties;\r\n}\r\n\r\nconst Spotlight: FC<SpotlightProps> = ({\r\n position,\r\n shape = 'circle',\r\n radius = 200,\r\n hasLockBodyScroll = true,\r\n transitionDuration = '350ms',\r\n rectangleProps = { width: 200, height: 200, borderRadius: 8 },\r\n className,\r\n inlineStyle,\r\n ...rest\r\n}) => {\r\n const hasPosition = position && position.horizontal !== undefined && position.vertical !== undefined;\r\n useLockBodyScroll(hasLockBodyScroll);\r\n\r\n return hasPosition ? (\r\n <div className={`${className ? className : ''}`} style={inlineStyle} {...rest}>\r\n <SpotlightArea>\r\n <defs>\r\n <mask id=\"hole\">\r\n <rect width=\"100%\" height=\"100%\" fill=\"white\" />\r\n {shape === 'circle' ? (\r\n <SpotlightCircle\r\n transitionDuration={transitionDuration}\r\n r={radius}\r\n cx={position.horizontal}\r\n cy={position.vertical}\r\n fill=\"black\"\r\n />\r\n ) : (\r\n <SpotlightRect\r\n transitionDuration={transitionDuration}\r\n width={rectangleProps.width}\r\n height={rectangleProps.height}\r\n x={position.horizontal}\r\n y={position.vertical}\r\n rx={rectangleProps.borderRadius}\r\n ry={rectangleProps.borderRadius}\r\n fill=\"black\"\r\n />\r\n )}\r\n </mask>\r\n </defs>\r\n <rect fill=\"rgba(0,0,0,0.25)\" width=\"100%\" height=\"100%\" mask=\"url(#hole)\" />\r\n </SpotlightArea>\r\n </div>\r\n ) : (\r\n <div></div>\r\n );\r\n};\r\n\r\nexport default Spotlight;\r\n"]}
1
+ {"version":3,"sources":["elvia-spotlight.tsx"],"names":["Spotlight","position","shape","radius","hasLockBodyScroll","transitionDuration","rectangleProps","width","height","borderRadius","className","inlineStyle","rest","hasPosition","horizontal","vertical","useLockBodyScroll"],"mappings":";;;;onCA4BMA,UAA6B,CAAG,WAUhC,IATJC,EAAQ,GAARA,QAAQ,KACRC,KAAK,CAALA,CAAK,YAAG,QAAQ,OAChBC,MAAM,CAANA,CAAM,YAAG,GAAG,OACZC,iBAAiB,KACjBC,kBAAkB,CAAlBA,CAAkB,YAAG,OAAO,OAC5BC,cAAc,CAAdA,CAAc,YAAG,CAAEC,KAAK,CAAE,GAAG,CAAEC,MAAM,CAAE,GAAG,CAAEC,YAAY,CAAE,CAAE,CAAC,GAC7DC,CAAS,GAATA,SAAS,CACTC,CAAW,GAAXA,WAAW,CACRC,CAAI,uCAEDC,CAAW,CAAGZ,CAAQ,EAAI,SAAAA,CAAQ,CAACa,UAAwB,EAAI,SAAAb,CAAQ,CAACc,QAAsB,CAGpG,MAFA,GAAAC,oCAAiB,gBAAmB,CAE7BH,CAAW,cAChB,6CAAK,SAAS,WAAKH,CAAS,CAAGA,CAAS,CAAG,EAAE,CAAG,CAAC,KAAK,CAAEC,CAAY,EAAKC,CAAI,eAC3E,6BAAC,+BAAa,mBACZ,sDACE,qCAAM,EAAE,CAAC,MAAM,eACb,qCAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAG,CACrC,QAAQ,GAAlBV,CAAkB,cACjB,6BAAC,iCAAe,EACd,kBAAkB,CAAEG,CAAmB,CACvC,CAAC,CAAEF,CAAO,CACV,EAAE,CAAEF,CAAQ,CAACa,UAAW,CACxB,EAAE,CAAEb,CAAQ,CAACc,QAAS,CACtB,IAAI,CAAC,OAAO,EACZ,cAEF,6BAAC,+BAAa,EACZ,kBAAkB,CAAEV,CAAmB,CACvC,KAAK,CAAEC,CAAc,CAACC,KAAM,CAC5B,MAAM,CAAED,CAAc,CAACE,MAAO,CAC9B,CAAC,CAAEP,CAAQ,CAACa,UAAW,CACvB,CAAC,CAAEb,CAAQ,CAACc,QAAS,CACrB,EAAE,CAAET,CAAc,CAACG,YAAa,CAChC,EAAE,CAAEH,CAAc,CAACG,YAAa,CAChC,IAAI,CAAC,OAAO,EAEf,CACI,CACF,cACP,qCAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAG,CAC/D,CACZ,cAEN,wCAEJ,CAAC,UAEcT,SAAS","file":"elvia-spotlight.js","sourcesContent":["import React, { CSSProperties, FC } from 'react';\nimport { SpotlightArea, SpotlightCircle, SpotlightRect } from './styledComponents';\nimport { useLockBodyScroll } from './useLockBodyScroll';\n\nexport type SpotlightShape = 'circle' | 'rectangle';\n\nexport interface SpotlightPosition {\n vertical: number;\n horizontal: number;\n}\n\nexport interface SpotlightRectangleProps {\n width?: number;\n height?: number;\n borderRadius?: number;\n}\n\nexport interface SpotlightProps {\n position: SpotlightPosition | undefined;\n shape?: SpotlightShape;\n radius?: number;\n rectangleProps?: SpotlightRectangleProps;\n hasLockBodyScroll?: boolean;\n transitionDuration?: string;\n className?: string;\n inlineStyle?: CSSProperties;\n}\n\nconst Spotlight: FC<SpotlightProps> = ({\n position,\n shape = 'circle',\n radius = 200,\n hasLockBodyScroll = true,\n transitionDuration = '350ms',\n rectangleProps = { width: 200, height: 200, borderRadius: 8 },\n className,\n inlineStyle,\n ...rest\n}) => {\n const hasPosition = position && position.horizontal !== undefined && position.vertical !== undefined;\n useLockBodyScroll(hasLockBodyScroll);\n\n return hasPosition ? (\n <div className={`${className ? className : ''}`} style={inlineStyle} {...rest}>\n <SpotlightArea>\n <defs>\n <mask id=\"hole\">\n <rect width=\"100%\" height=\"100%\" fill=\"white\" />\n {shape === 'circle' ? (\n <SpotlightCircle\n transitionDuration={transitionDuration}\n r={radius}\n cx={position.horizontal}\n cy={position.vertical}\n fill=\"black\"\n />\n ) : (\n <SpotlightRect\n transitionDuration={transitionDuration}\n width={rectangleProps.width}\n height={rectangleProps.height}\n x={position.horizontal}\n y={position.vertical}\n rx={rectangleProps.borderRadius}\n ry={rectangleProps.borderRadius}\n fill=\"black\"\n />\n )}\n </mask>\n </defs>\n <rect fill=\"rgba(0,0,0,0.25)\" width=\"100%\" height=\"100%\" mask=\"url(#hole)\" />\n </SpotlightArea>\n </div>\n ) : (\n <div></div>\n );\n};\n\nexport default Spotlight;\n"]}
@@ -2,39 +2,5 @@
2
2
  * THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE OVERWRITTEN.
3
3
  * DO NOT MAKE CHANGES TO THIS FILE DIRECTLY
4
4
  */
5
- "use strict";
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.SpotlightRect = exports.SpotlightCircle = exports.SpotlightArea = void 0;
11
-
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- var SpotlightArea = _styledComponents.default.svg.withConfig({
17
- displayName: "styledComponents__SpotlightArea",
18
- componentId: "sc-env4mw-0"
19
- })(["position:fixed;top:0;left:0;z-index:99999;width:100vw;height:100vh;"]);
20
-
21
- exports.SpotlightArea = SpotlightArea;
22
-
23
- var SpotlightCircle = _styledComponents.default.circle.withConfig({
24
- displayName: "styledComponents__SpotlightCircle",
25
- componentId: "sc-env4mw-1"
26
- })(["transition:all ", " ease-in-out;"], function (props) {
27
- return props.transitionDuration;
28
- });
29
-
30
- exports.SpotlightCircle = SpotlightCircle;
31
-
32
- var SpotlightRect = _styledComponents.default.rect.withConfig({
33
- displayName: "styledComponents__SpotlightRect",
34
- componentId: "sc-env4mw-2"
35
- })(["transition:all ", " ease-in-out;"], function (props) {
36
- return props.transitionDuration;
37
- });
38
-
39
- exports.SpotlightRect = SpotlightRect;
5
+ "use strict";var _styledComponents=_interopRequireDefault(require("styled-components"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.SpotlightRect=exports.SpotlightCircle=exports.SpotlightArea=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var SpotlightArea=_styledComponents.default.svg.withConfig({displayName:"styledComponents__SpotlightArea",componentId:"sc-env4mw-0"})(["position:fixed;top:0;left:0;z-index:99999;width:100vw;height:100vh;"]);exports.SpotlightArea=SpotlightArea;var SpotlightCircle=_styledComponents.default.circle.withConfig({displayName:"styledComponents__SpotlightCircle",componentId:"sc-env4mw-1"})(["transition:all "," ease-in-out;"],function(a){return a.transitionDuration});exports.SpotlightCircle=SpotlightCircle;var SpotlightRect=_styledComponents.default.rect.withConfig({displayName:"styledComponents__SpotlightRect",componentId:"sc-env4mw-2"})(["transition:all "," ease-in-out;"],function(a){return a.transitionDuration});exports.SpotlightRect=SpotlightRect;
40
6
  //# sourceMappingURL=styledComponents.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["styledComponents.tsx"],"names":["SpotlightArea","styled","svg","SpotlightCircle","circle","props","transitionDuration","SpotlightRect","rect"],"mappings":";;;;;;;;;;;AAAA;;;;AAEO,IAAMA,aAAa,GAAGC,yBAAA,CAAOC,GAAV;EAAA;EAAA;AAAA,2EAAnB;;;;AAaA,IAAMC,eAAe,GAAGF,yBAAA,CAAOG,MAAV;EAAA;EAAA;AAAA,yCACR,UAACC,KAAD;EAAA,OAAWA,KAAK,CAACC,kBAAjB;AAAA,CADQ,CAArB;;;;AAOA,IAAMC,aAAa,GAAGN,yBAAA,CAAOO,IAAV;EAAA;EAAA;AAAA,yCACN,UAACH,KAAD;EAAA,OAAWA,KAAK,CAACC,kBAAjB;AAAA,CADM,CAAnB","file":"styledComponents.js","sourcesContent":["import styled from 'styled-components';\r\n\r\nexport const SpotlightArea = styled.svg`\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n z-index: 99999;\r\n width: 100vw;\r\n height: 100vh;\r\n`;\r\n\r\ninterface SpotlightCircleProps {\r\n transitionDuration: string;\r\n}\r\n\r\nexport const SpotlightCircle = styled.circle<SpotlightCircleProps>`\r\n transition: all ${(props) => props.transitionDuration} ease-in-out;\r\n`;\r\ninterface SpotlightRectProps {\r\n transitionDuration: string;\r\n}\r\n\r\nexport const SpotlightRect = styled.rect<SpotlightRectProps>`\r\n transition: all ${(props) => props.transitionDuration} ease-in-out;\r\n`;\r\n"]}
1
+ {"version":3,"sources":["styledComponents.tsx"],"names":["SpotlightArea","styled","svg","SpotlightCircle","circle","props","transitionDuration","SpotlightRect","rect"],"mappings":";;;;aAAA,2EAAuC,0MAEhC,GAAMA,cAAa,CAAGC,yBAAM,CAACC,GAAG,+JAOtC,CAAC,oCAMK,GAAMC,gBAAe,CAAGF,yBAAM,CAACG,MAAM,6HACxB,SAACC,CAAK,QAAKA,EAAK,CAACC,kBAAkB,EACtD,CAAC,wCAKK,GAAMC,cAAa,CAAGN,yBAAM,CAACO,IAAI,2HACpB,SAACH,CAAK,QAAKA,EAAK,CAACC,kBAAkB,EACtD,CAAC","file":"styledComponents.js","sourcesContent":["import styled from 'styled-components';\n\nexport const SpotlightArea = styled.svg`\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99999;\n width: 100vw;\n height: 100vh;\n`;\n\ninterface SpotlightCircleProps {\n transitionDuration: string;\n}\n\nexport const SpotlightCircle = styled.circle<SpotlightCircleProps>`\n transition: all ${(props) => props.transitionDuration} ease-in-out;\n`;\ninterface SpotlightRectProps {\n transitionDuration: string;\n}\n\nexport const SpotlightRect = styled.rect<SpotlightRectProps>`\n transition: all ${(props) => props.transitionDuration} ease-in-out;\n`;\n"]}
@@ -2,33 +2,6 @@
2
2
  * THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE OVERWRITTEN.
3
3
  * DO NOT MAKE CHANGES TO THIS FILE DIRECTLY
4
4
  */
5
- "use strict";
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.useLockBodyScroll = useLockBodyScroll;
11
-
12
- var _react = require("react");
13
-
14
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
15
- function useLockBodyScroll(removeLockBodyScroll) {
16
- (0, _react.useEffect)(function () {
17
- var originalStyleOverflowBody = window.getComputedStyle(document.body).overflow;
18
- var originalStyleOverflowHtml = window.getComputedStyle(document.documentElement).overflow;
19
-
20
- if (!removeLockBodyScroll) {
21
- document.body.style.overflow = originalStyleOverflowBody;
22
- document.documentElement.style.overflow = originalStyleOverflowHtml;
23
- return;
24
- }
25
-
26
- document.body.style.overflow = 'hidden';
27
- document.documentElement.style.overflow = 'hidden';
28
- return function () {
29
- document.body.style.overflow = originalStyleOverflowBody;
30
- document.documentElement.style.overflow = originalStyleOverflowHtml;
31
- };
32
- }, [removeLockBodyScroll]);
33
- }
5
+ "use strict";var _react=require("react");Object.defineProperty(exports,"__esModule",{value:!0}),exports.useLockBodyScroll=useLockBodyScroll;// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6
+ function useLockBodyScroll(a){(0,_react.useEffect)(function(){var b=window.getComputedStyle(document.body).overflow,c=window.getComputedStyle(document.documentElement).overflow;return a?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",function(){document.body.style.overflow=b,document.documentElement.style.overflow=c}):(document.body.style.overflow=b,void(document.documentElement.style.overflow=c))},[a])}
34
7
  //# sourceMappingURL=useLockBodyScroll.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useLockBodyScroll.tsx"],"names":["useLockBodyScroll","removeLockBodyScroll","useEffect","originalStyleOverflowBody","window","getComputedStyle","document","body","overflow","originalStyleOverflowHtml","documentElement","style"],"mappings":";;;;;;;;;;;AAAA;;AAEA;AACO,SAASA,iBAAT,CAA2BC,oBAA3B,EAA0D;EAC/D,IAAAC,gBAAA,EAAU,YAAM;IACd,IAAMC,yBAAyB,GAAGC,MAAM,CAACC,gBAAP,CAAwBC,QAAQ,CAACC,IAAjC,EAAuCC,QAAzE;IACA,IAAMC,yBAAyB,GAAGL,MAAM,CAACC,gBAAP,CAAwBC,QAAQ,CAACI,eAAjC,EAAkDF,QAApF;;IACA,IAAI,CAACP,oBAAL,EAA2B;MACzBK,QAAQ,CAACC,IAAT,CAAcI,KAAd,CAAoBH,QAApB,GAA+BL,yBAA/B;MACAG,QAAQ,CAACI,eAAT,CAAyBC,KAAzB,CAA+BH,QAA/B,GAA0CC,yBAA1C;MACA;IACD;;IACDH,QAAQ,CAACC,IAAT,CAAcI,KAAd,CAAoBH,QAApB,GAA+B,QAA/B;IACAF,QAAQ,CAACI,eAAT,CAAyBC,KAAzB,CAA+BH,QAA/B,GAA0C,QAA1C;IAEA,OAAO,YAAM;MACXF,QAAQ,CAACC,IAAT,CAAcI,KAAd,CAAoBH,QAApB,GAA+BL,yBAA/B;MACAG,QAAQ,CAACI,eAAT,CAAyBC,KAAzB,CAA+BH,QAA/B,GAA0CC,yBAA1C;IACD,CAHD;EAID,CAfD,EAeG,CAACR,oBAAD,CAfH;AAgBD","file":"useLockBodyScroll.js","sourcesContent":["import { useEffect } from 'react';\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function useLockBodyScroll(removeLockBodyScroll: boolean) {\n useEffect(() => {\n const originalStyleOverflowBody = window.getComputedStyle(document.body).overflow;\n const originalStyleOverflowHtml = window.getComputedStyle(document.documentElement).overflow;\n if (!removeLockBodyScroll) {\n document.body.style.overflow = originalStyleOverflowBody;\n document.documentElement.style.overflow = originalStyleOverflowHtml;\n return;\n }\n document.body.style.overflow = 'hidden';\n document.documentElement.style.overflow = 'hidden';\n\n return () => {\n document.body.style.overflow = originalStyleOverflowBody;\n document.documentElement.style.overflow = originalStyleOverflowHtml;\n };\n }, [removeLockBodyScroll]);\n}\n"]}
1
+ {"version":3,"sources":["useLockBodyScroll.tsx"],"names":["useLockBodyScroll","removeLockBodyScroll","useEffect","originalStyleOverflowBody","window","getComputedStyle","document","body","overflow","originalStyleOverflowHtml","documentElement","style"],"mappings":";;;;aAAA,4BAAkC,mGAElC;AACO,QAASA,kBAAiB,CAACC,CAA6B,CAAE,CAC/D,GAAAC,gBAAS,EAAC,UAAM,IACRC,EAAyB,CAAGC,MAAM,CAACC,gBAAgB,CAACC,QAAQ,CAACC,IAAI,CAAC,CAACC,QAAQ,CAC3EC,CAAyB,CAAGL,MAAM,CAACC,gBAAgB,CAACC,QAAQ,CAACI,eAAe,CAAC,CAACF,QAAQ,OACvFP,EAAoB,EAKzBK,QAAQ,CAACC,IAAI,CAACI,KAAK,CAACH,QAAQ,CAAG,QAAQ,CACvCF,QAAQ,CAACI,eAAe,CAACC,KAAK,CAACH,QAAQ,CAAG,QAAQ,CAE3C,UAAM,CACXF,QAAQ,CAACC,IAAI,CAACI,KAAK,CAACH,QAAQ,CAAGL,CAAyB,CACxDG,QAAQ,CAACI,eAAe,CAACC,KAAK,CAACH,QAAQ,CAAGC,CAC5C,CAAC,GAVCH,QAAQ,CAACC,IAAI,CAACI,KAAK,CAACH,QAAQ,CAAGL,CAAyB,MACxDG,QAAQ,CAACI,eAAe,CAACC,KAAK,CAACH,QAAQ,CAAGC,CAAyB,EAUvE,CAAC,CAAE,CAACR,CAAoB,CAAC,CAC3B","file":"useLockBodyScroll.js","sourcesContent":["import { useEffect } from 'react';\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function useLockBodyScroll(removeLockBodyScroll: boolean) {\n useEffect(() => {\n const originalStyleOverflowBody = window.getComputedStyle(document.body).overflow;\n const originalStyleOverflowHtml = window.getComputedStyle(document.documentElement).overflow;\n if (!removeLockBodyScroll) {\n document.body.style.overflow = originalStyleOverflowBody;\n document.documentElement.style.overflow = originalStyleOverflowHtml;\n return;\n }\n document.body.style.overflow = 'hidden';\n document.documentElement.style.overflow = 'hidden';\n\n return () => {\n document.body.style.overflow = originalStyleOverflowBody;\n document.documentElement.style.overflow = originalStyleOverflowHtml;\n };\n }, [removeLockBodyScroll]);\n}\n"]}
@@ -4,189 +4,146 @@
4
4
  */
5
5
  import * as ReactComponent from '../../../react.js';
6
6
  import { ElvisComponentWrapper } from '@elvia/elvis-component-wrapper';
7
- const style = ``;
8
7
  export default class ElviaComponent extends ElvisComponentWrapper {
9
8
  static get observedAttributes() {
10
9
  return ["position", "shape", "radius", "rectangleprops", "haslockbodyscroll", "transitionduration", "classname", "inlinestyle"];
11
10
  }
12
-
13
11
  static getComponentData() {
14
12
  return {
15
- "name": "elvis-spotlight",
16
- "elementName": "elvia-spotlight",
13
+ "reactName": "Spotlight",
17
14
  "attributes": [{
18
15
  "name": "position",
19
- "type": "object",
20
- "propType": "object"
16
+ "type": "object"
21
17
  }, {
22
18
  "name": "shape",
23
- "type": "string",
24
- "propType": "string"
19
+ "type": "string"
25
20
  }, {
26
21
  "name": "radius",
27
- "type": "number",
28
- "propType": "number"
22
+ "type": "number"
29
23
  }, {
30
24
  "name": "rectangleProps",
31
- "type": "object",
32
- "propType": "object"
25
+ "type": "object"
33
26
  }, {
34
27
  "name": "hasLockBodyScroll",
35
- "type": "boolean",
36
- "propType": "boolean"
28
+ "type": "boolean"
37
29
  }, {
38
30
  "name": "transitionDuration",
39
- "type": "string",
40
- "propType": "boolean"
31
+ "type": "string"
41
32
  }, {
42
33
  "name": "className",
43
- "type": "string",
44
- "propType": "string | undefined"
34
+ "type": "string"
45
35
  }, {
46
36
  "name": "inlineStyle",
47
- "type": "object",
48
- "propType": "object | undefined"
49
- }],
50
- "reactName": "Spotlight",
51
- "slotItems": false,
52
- "useWrapper": false,
53
- "reactTypescriptDeclaration": true
37
+ "type": "object"
38
+ }]
54
39
  };
55
40
  }
56
-
57
41
  set position(newValue) {
58
42
  super.setProps({
59
43
  'position': newValue
60
44
  });
61
45
  }
62
-
63
46
  get position() {
64
47
  return super.getProps()['position'];
65
48
  }
66
-
67
49
  set shape(newValue) {
68
50
  super.setProps({
69
51
  'shape': newValue
70
52
  });
71
53
  }
72
-
73
54
  get shape() {
74
55
  return super.getProps()['shape'];
75
56
  }
76
-
77
57
  set radius(newValue) {
78
58
  super.setProps({
79
59
  'radius': newValue
80
60
  });
81
61
  }
82
-
83
62
  get radius() {
84
63
  return super.getProps()['radius'];
85
64
  }
86
-
87
65
  set rectangleProps(newValue) {
88
66
  super.setProps({
89
67
  'rectangleprops': newValue
90
68
  });
91
69
  }
92
-
93
70
  get rectangleProps() {
94
71
  return super.getProps()['rectangleprops'];
95
72
  }
96
-
97
73
  set rectangleprops(newValue) {
98
74
  super.setProps({
99
75
  'rectangleprops': newValue
100
76
  });
101
77
  }
102
-
103
78
  get rectangleprops() {
104
79
  return super.getProps()['rectangleprops'];
105
80
  }
106
-
107
81
  set hasLockBodyScroll(newValue) {
108
82
  super.setProps({
109
83
  'haslockbodyscroll': newValue
110
84
  });
111
85
  }
112
-
113
86
  get hasLockBodyScroll() {
114
87
  return super.getProps()['haslockbodyscroll'];
115
88
  }
116
-
117
89
  set haslockbodyscroll(newValue) {
118
90
  super.setProps({
119
91
  'haslockbodyscroll': newValue
120
92
  });
121
93
  }
122
-
123
94
  get haslockbodyscroll() {
124
95
  return super.getProps()['haslockbodyscroll'];
125
96
  }
126
-
127
97
  set transitionDuration(newValue) {
128
98
  super.setProps({
129
99
  'transitionduration': newValue
130
100
  });
131
101
  }
132
-
133
102
  get transitionDuration() {
134
103
  return super.getProps()['transitionduration'];
135
104
  }
136
-
137
105
  set transitionduration(newValue) {
138
106
  super.setProps({
139
107
  'transitionduration': newValue
140
108
  });
141
109
  }
142
-
143
110
  get transitionduration() {
144
111
  return super.getProps()['transitionduration'];
145
112
  }
146
-
147
113
  set className(newValue) {
148
114
  super.setProps({
149
115
  'classname': newValue
150
116
  });
151
117
  }
152
-
153
118
  get className() {
154
119
  return super.getProps()['classname'];
155
120
  }
156
-
157
121
  set classname(newValue) {
158
122
  super.setProps({
159
123
  'classname': newValue
160
124
  });
161
125
  }
162
-
163
126
  get classname() {
164
127
  return super.getProps()['classname'];
165
128
  }
166
-
167
129
  set inlineStyle(newValue) {
168
130
  super.setProps({
169
131
  'inlinestyle': newValue
170
132
  });
171
133
  }
172
-
173
134
  get inlineStyle() {
174
135
  return super.getProps()['inlinestyle'];
175
136
  }
176
-
177
137
  set inlinestyle(newValue) {
178
138
  super.setProps({
179
139
  'inlinestyle': newValue
180
140
  });
181
141
  }
182
-
183
142
  get inlinestyle() {
184
143
  return super.getProps()['inlinestyle'];
185
144
  }
186
-
187
145
  constructor() {
188
- super(ElviaComponent, ReactComponent['Spotlight'], style);
146
+ super(ElviaComponent, ReactComponent['Spotlight']);
189
147
  }
190
-
191
148
  }
192
149
  window.customElements.define(`elvia-spotlight`, ElviaComponent);
package/package.json CHANGED
@@ -1,22 +1,25 @@
1
1
  {
2
2
  "name": "@elvia/elvis-spotlight",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "",
5
5
  "main": "web_component.js",
6
6
  "author": "",
7
7
  "license": "MIT",
8
+ "files": [
9
+ "web_component.js",
10
+ "react.js",
11
+ "react.d.ts",
12
+ "CHANGELOG.json",
13
+ "README.md",
14
+ "dist/**/*"
15
+ ],
8
16
  "dependencies": {
9
- "@elvia/elvis-component-wrapper": "^2.3.0",
17
+ "@elvia/elvis-component-wrapper": "^3.0.3",
10
18
  "styled-components": "^5.3.3"
11
19
  },
12
- "devDependencies": {
13
- "react": "^16.8.0 || ^17.0.0",
14
- "react-dom": "^16.8.0 || ^17.0.0",
15
- "react-is": ">= 16.8.0"
16
- },
17
20
  "peerDependencies": {
18
- "react": "^16.8.0 || ^17.0.0",
19
- "react-dom": "^16.8.0 || ^17.0.0",
20
- "react-is": ">= 16.8.0"
21
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
22
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
23
+ "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0"
21
24
  }
22
25
  }
@@ -1,79 +0,0 @@
1
- import React, { CSSProperties, FC } from 'react';
2
- import { SpotlightArea, SpotlightCircle, SpotlightRect } from './styledComponents';
3
- import { useLockBodyScroll } from './useLockBodyScroll';
4
-
5
- export type SpotlightShape = 'circle' | 'rectangle';
6
-
7
- export interface SpotlightPosition {
8
- vertical: number;
9
- horizontal: number;
10
- }
11
-
12
- export interface SpotlightRectangleProps {
13
- width?: number;
14
- height?: number;
15
- borderRadius?: number;
16
- }
17
-
18
- export interface SpotlightProps {
19
- position: SpotlightPosition | undefined;
20
- shape?: SpotlightShape;
21
- radius?: number;
22
- rectangleProps?: SpotlightRectangleProps;
23
- hasLockBodyScroll?: boolean;
24
- transitionDuration?: string;
25
- className?: string;
26
- inlineStyle?: CSSProperties;
27
- }
28
-
29
- const Spotlight: FC<SpotlightProps> = ({
30
- position,
31
- shape = 'circle',
32
- radius = 200,
33
- hasLockBodyScroll = true,
34
- transitionDuration = '350ms',
35
- rectangleProps = { width: 200, height: 200, borderRadius: 8 },
36
- className,
37
- inlineStyle,
38
- ...rest
39
- }) => {
40
- const hasPosition = position && position.horizontal !== undefined && position.vertical !== undefined;
41
- useLockBodyScroll(hasLockBodyScroll);
42
-
43
- return hasPosition ? (
44
- <div className={`${className ? className : ''}`} style={inlineStyle} {...rest}>
45
- <SpotlightArea>
46
- <defs>
47
- <mask id="hole">
48
- <rect width="100%" height="100%" fill="white" />
49
- {shape === 'circle' ? (
50
- <SpotlightCircle
51
- transitionDuration={transitionDuration}
52
- r={radius}
53
- cx={position.horizontal}
54
- cy={position.vertical}
55
- fill="black"
56
- />
57
- ) : (
58
- <SpotlightRect
59
- transitionDuration={transitionDuration}
60
- width={rectangleProps.width}
61
- height={rectangleProps.height}
62
- x={position.horizontal}
63
- y={position.vertical}
64
- rx={rectangleProps.borderRadius}
65
- ry={rectangleProps.borderRadius}
66
- fill="black"
67
- />
68
- )}
69
- </mask>
70
- </defs>
71
- <rect fill="rgba(0,0,0,0.25)" width="100%" height="100%" mask="url(#hole)" />
72
- </SpotlightArea>
73
- </div>
74
- ) : (
75
- <div></div>
76
- );
77
- };
78
-
79
- export default Spotlight;
@@ -1,25 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- export const SpotlightArea = styled.svg`
4
- position: fixed;
5
- top: 0;
6
- left: 0;
7
- z-index: 99999;
8
- width: 100vw;
9
- height: 100vh;
10
- `;
11
-
12
- interface SpotlightCircleProps {
13
- transitionDuration: string;
14
- }
15
-
16
- export const SpotlightCircle = styled.circle<SpotlightCircleProps>`
17
- transition: all ${(props) => props.transitionDuration} ease-in-out;
18
- `;
19
- interface SpotlightRectProps {
20
- transitionDuration: string;
21
- }
22
-
23
- export const SpotlightRect = styled.rect<SpotlightRectProps>`
24
- transition: all ${(props) => props.transitionDuration} ease-in-out;
25
- `;
@@ -1,21 +0,0 @@
1
- import { useEffect } from 'react';
2
-
3
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4
- export function useLockBodyScroll(removeLockBodyScroll: boolean) {
5
- useEffect(() => {
6
- const originalStyleOverflowBody = window.getComputedStyle(document.body).overflow;
7
- const originalStyleOverflowHtml = window.getComputedStyle(document.documentElement).overflow;
8
- if (!removeLockBodyScroll) {
9
- document.body.style.overflow = originalStyleOverflowBody;
10
- document.documentElement.style.overflow = originalStyleOverflowHtml;
11
- return;
12
- }
13
- document.body.style.overflow = 'hidden';
14
- document.documentElement.style.overflow = 'hidden';
15
-
16
- return () => {
17
- document.body.style.overflow = originalStyleOverflowBody;
18
- document.documentElement.style.overflow = originalStyleOverflowHtml;
19
- };
20
- }, [removeLockBodyScroll]);
21
- }