etudes 0.52.0 → 0.55.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Andrew Wei
3
+ Copyright (c) 2022 Andrew Wei
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,16 +1,20 @@
1
1
  import { HTMLAttributes } from 'react';
2
- import { CSSProp } from 'styled-components';
3
2
  export declare type Props = HTMLAttributes<HTMLButtonElement> & {
3
+ height?: number;
4
4
  isActive?: boolean;
5
5
  isDoubleJointed?: boolean;
6
6
  isLastBarHalfWidth?: boolean;
7
- height?: number;
8
7
  thickness?: number;
9
- width?: number;
10
8
  tintColor?: string;
11
9
  transitionDuration?: number;
10
+ width?: number;
12
11
  onActivate?: () => void;
13
12
  onDeactivate?: () => void;
14
- cssBar?: CSSProp<any>;
15
13
  };
16
- export default function BurgerButton({ isActive: externalIsActive, isDoubleJointed, isLastBarHalfWidth, height, thickness, width, tintColor, transitionDuration, onActivate, onDeactivate, cssBar, ...props }: Props): JSX.Element;
14
+ /**
15
+ * Three-striped burger button component that transforms into an "X" when selected.
16
+ *
17
+ * @exports BurgerButtonBar - Component for each line on the burger button.
18
+ */
19
+ export default function BurgerButton({ height, isActive: externalIsActive, isDoubleJointed, isLastBarHalfWidth, thickness, tintColor, transitionDuration, width, onActivate, onDeactivate, ...props }: Props): JSX.Element;
20
+ export declare const BurgerButtonBar: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -64,12 +64,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
64
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
65
65
  };
66
66
  Object.defineProperty(exports, "__esModule", { value: true });
67
+ exports.BurgerButtonBar = void 0;
67
68
  var classnames_1 = __importDefault(require("classnames"));
68
69
  var react_1 = __importStar(require("react"));
69
70
  var styled_components_1 = __importDefault(require("styled-components"));
70
71
  var Repeat_1 = __importDefault(require("./Repeat"));
72
+ /**
73
+ * Three-striped burger button component that transforms into an "X" when selected.
74
+ *
75
+ * @exports BurgerButtonBar - Component for each line on the burger button.
76
+ */
71
77
  function BurgerButton(_a) {
72
- var _b = _a.isActive, externalIsActive = _b === void 0 ? false : _b, _c = _a.isDoubleJointed, isDoubleJointed = _c === void 0 ? false : _c, _d = _a.isLastBarHalfWidth, isLastBarHalfWidth = _d === void 0 ? false : _d, _e = _a.height, height = _e === void 0 ? 20 : _e, _f = _a.thickness, thickness = _f === void 0 ? 2 : _f, _g = _a.width, width = _g === void 0 ? 20 : _g, _h = _a.tintColor, tintColor = _h === void 0 ? '#000' : _h, _j = _a.transitionDuration, transitionDuration = _j === void 0 ? 200 : _j, onActivate = _a.onActivate, onDeactivate = _a.onDeactivate, cssBar = _a.cssBar, props = __rest(_a, ["isActive", "isDoubleJointed", "isLastBarHalfWidth", "height", "thickness", "width", "tintColor", "transitionDuration", "onActivate", "onDeactivate", "cssBar"]);
78
+ var _b = _a.height, height = _b === void 0 ? 20 : _b, _c = _a.isActive, externalIsActive = _c === void 0 ? false : _c, _d = _a.isDoubleJointed, isDoubleJointed = _d === void 0 ? false : _d, _e = _a.isLastBarHalfWidth, isLastBarHalfWidth = _e === void 0 ? false : _e, _f = _a.thickness, thickness = _f === void 0 ? 2 : _f, _g = _a.tintColor, tintColor = _g === void 0 ? '#000' : _g, _h = _a.transitionDuration, transitionDuration = _h === void 0 ? 200 : _h, _j = _a.width, width = _j === void 0 ? 20 : _j, onActivate = _a.onActivate, onDeactivate = _a.onDeactivate, props = __rest(_a, ["height", "isActive", "isDoubleJointed", "isLastBarHalfWidth", "thickness", "tintColor", "transitionDuration", "width", "onActivate", "onDeactivate"]);
73
79
  var _k = __read((0, react_1.useState)(externalIsActive), 2), isActive = _k[0], setIsActive = _k[1];
74
80
  (0, react_1.useEffect)(function () {
75
81
  if (isActive !== externalIsActive) {
@@ -84,15 +90,15 @@ function BurgerButton(_a) {
84
90
  onDeactivate === null || onDeactivate === void 0 ? void 0 : onDeactivate();
85
91
  }
86
92
  }, [isActive]);
87
- return (react_1.default.createElement(StyledRoot, __assign({ width: width, height: height, thickness: thickness, onClick: function () { return setIsActive(!isActive); } }, props),
93
+ return (react_1.default.createElement(StyledRoot, __assign({}, props, { width: width, height: height, thickness: thickness, onClick: function () { return setIsActive(!isActive); } }),
88
94
  react_1.default.createElement(Repeat_1.default, { count: isDoubleJointed ? 2 : 1 },
89
95
  react_1.default.createElement(StyledJoint, { className: (0, classnames_1.default)({ active: isActive, half: isDoubleJointed }), height: height, isLastBarHalfWidth: isLastBarHalfWidth, thickness: thickness, width: width },
90
96
  react_1.default.createElement(Repeat_1.default, { count: 3 },
91
- react_1.default.createElement(StyledBar, { className: (0, classnames_1.default)({ active: isActive, half: isDoubleJointed }), style: { height: "".concat(thickness, "px") }, css: cssBar }))))));
97
+ react_1.default.createElement(exports.BurgerButtonBar, { className: (0, classnames_1.default)({ active: isActive, half: isDoubleJointed }), style: { height: "".concat(thickness, "px") } }))))));
92
98
  }
93
99
  exports.default = BurgerButton;
94
- var StyledBar = styled_components_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: #fff;\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n transition-duration: 100ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n width: 100%;\n\n ", "\n"], ["\n background: #fff;\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n transition-duration: 100ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n width: 100%;\n\n ", "\n"])), function (props) { return props.css; });
95
- var StyledJoint = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 100%;\n position: absolute;\n width: 100%;\n\n &.half {\n width: 50%;\n }\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n\n ", ":nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n ", ":nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n ", ":nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n ", ":nth-child(1) {\n transform: ", ";\n }\n\n ", ":nth-child(2) {\n transform: ", ";\n }\n\n ", ":nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n\n &.half {\n ", ":nth-child(1) {\n transform-origin: right center;\n }\n\n ", ":nth-child(2) {\n transform-origin: right center;\n }\n\n ", ":nth-child(3) {\n transform-origin: right center;\n width: 100%;\n }\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n\n span:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n span:nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n span:nth-child(1) {\n transform: ", ";\n }\n\n span:nth-child(2) {\n transform: translate3d(0, 0, 0) scale(0);\n }\n\n span:nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n }\n"], ["\n height: 100%;\n position: absolute;\n width: 100%;\n\n &.half {\n width: 50%;\n }\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n\n ", ":nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n ", ":nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n ", ":nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n ", ":nth-child(1) {\n transform: ", ";\n }\n\n ", ":nth-child(2) {\n transform: ", ";\n }\n\n ", ":nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n\n &.half {\n ", ":nth-child(1) {\n transform-origin: right center;\n }\n\n ", ":nth-child(2) {\n transform-origin: right center;\n }\n\n ", ":nth-child(3) {\n transform-origin: right center;\n width: 100%;\n }\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n\n span:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n span:nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n span:nth-child(1) {\n transform: ", ";\n }\n\n span:nth-child(2) {\n transform: translate3d(0, 0, 0) scale(0);\n }\n\n span:nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n }\n"])), StyledBar, StyledBar, function (props) { return props.height * .5 - props.thickness * .5; }, StyledBar, function (props) { return props.height - props.thickness; }, function (props) { return props.isLastBarHalfWidth ? '50%' : '100%'; }, StyledBar, function (props) { return "translate3d(0, ".concat(props.height * .5 - props.thickness * .5, "px, 0) rotate(45deg)"); }, StyledBar, function (props) { return 'translate3d(0, 0, 0) scale(0)'; }, StyledBar, function (props) { return "translate3d(0, ".concat(props.thickness * .5 - props.height * .5, "px, 0) rotate(-45deg)"); }, StyledBar, StyledBar, StyledBar, function (props) { return props.height * .5 - props.thickness * .5; }, function (props) { return props.height - props.thickness; }, function (props) { return props.isLastBarHalfWidth ? 0 : '100%'; }, function (props) { return "translate3d(0, ".concat(props.height * .5 - props.thickness * .5, "px, 0) rotate(-45deg)"); }, function (props) { return "translate3d(0, ".concat(props.thickness * .5 - props.height * .5, "px, 0) rotate(45deg)"); });
100
+ exports.BurgerButtonBar = styled_components_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: #fff;\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n transition-duration: 100ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n width: 100%;\n"], ["\n background: #fff;\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n transition-duration: 100ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n width: 100%;\n"])));
101
+ var StyledJoint = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 100%;\n position: absolute;\n width: 100%;\n\n &.half {\n width: 50%;\n }\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n\n ", ":nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n ", ":nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n ", ":nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n ", ":nth-child(1) {\n transform: ", ";\n }\n\n ", ":nth-child(2) {\n transform: ", ";\n }\n\n ", ":nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n\n &.half {\n ", ":nth-child(1) {\n transform-origin: right center;\n }\n\n ", ":nth-child(2) {\n transform-origin: right center;\n }\n\n ", ":nth-child(3) {\n transform-origin: right center;\n width: 100%;\n }\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n\n span:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n span:nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n span:nth-child(1) {\n transform: ", ";\n }\n\n span:nth-child(2) {\n transform: translate3d(0, 0, 0) scale(0);\n }\n\n span:nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n }\n"], ["\n height: 100%;\n position: absolute;\n width: 100%;\n\n &.half {\n width: 50%;\n }\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n\n ", ":nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n ", ":nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n ", ":nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n ", ":nth-child(1) {\n transform: ", ";\n }\n\n ", ":nth-child(2) {\n transform: ", ";\n }\n\n ", ":nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n\n &.half {\n ", ":nth-child(1) {\n transform-origin: right center;\n }\n\n ", ":nth-child(2) {\n transform-origin: right center;\n }\n\n ", ":nth-child(3) {\n transform-origin: right center;\n width: 100%;\n }\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n\n span:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n span:nth-child(3) {\n left: 0;\n top: ", "px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ", ";\n }\n\n &.active {\n span:nth-child(1) {\n transform: ", ";\n }\n\n span:nth-child(2) {\n transform: translate3d(0, 0, 0) scale(0);\n }\n\n span:nth-child(3) {\n transform: ", ";\n width: 100%;\n }\n }\n }\n"])), exports.BurgerButtonBar, exports.BurgerButtonBar, function (props) { return props.height * .5 - props.thickness * .5; }, exports.BurgerButtonBar, function (props) { return props.height - props.thickness; }, function (props) { return props.isLastBarHalfWidth ? '50%' : '100%'; }, exports.BurgerButtonBar, function (props) { return "translate3d(0, ".concat(props.height * .5 - props.thickness * .5, "px, 0) rotate(45deg)"); }, exports.BurgerButtonBar, function (props) { return 'translate3d(0, 0, 0) scale(0)'; }, exports.BurgerButtonBar, function (props) { return "translate3d(0, ".concat(props.thickness * .5 - props.height * .5, "px, 0) rotate(-45deg)"); }, exports.BurgerButtonBar, exports.BurgerButtonBar, exports.BurgerButtonBar, function (props) { return props.height * .5 - props.thickness * .5; }, function (props) { return props.height - props.thickness; }, function (props) { return props.isLastBarHalfWidth ? 0 : '100%'; }, function (props) { return "translate3d(0, ".concat(props.height * .5 - props.thickness * .5, "px, 0) rotate(-45deg)"); }, function (props) { return "translate3d(0, ".concat(props.thickness * .5 - props.height * .5, "px, 0) rotate(45deg)"); });
96
102
  var StyledRoot = styled_components_1.default.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: transparent;\n border: none;\n box-sizing: border-box;\n display: block;\n height: ", "px;\n margin: 0;\n min-height: ", "px;\n min-width: ", "px;\n outline: none;\n padding: 0;\n pointer-events: auto;\n position: relative;\n width: ", "px;\n\n html:not(.touch) &:hover {\n ", ":not(.half) {\n span:nth-child(3) {\n width: ", "px;\n }\n }\n\n ", ".half:nth-of-type(2) {\n span:nth-child(3) {\n width: ", "px;\n }\n }\n }\n"], ["\n background: transparent;\n border: none;\n box-sizing: border-box;\n display: block;\n height: ", "px;\n margin: 0;\n min-height: ", "px;\n min-width: ", "px;\n outline: none;\n padding: 0;\n pointer-events: auto;\n position: relative;\n width: ", "px;\n\n html:not(.touch) &:hover {\n ", ":not(.half) {\n span:nth-child(3) {\n width: ", "px;\n }\n }\n\n ", ".half:nth-of-type(2) {\n span:nth-child(3) {\n width: ", "px;\n }\n }\n }\n"])), function (props) { return props.height; }, function (props) { return props.height; }, function (props) { return props.width; }, function (props) { return props.width; }, StyledJoint, function (props) { return props.width; }, StyledJoint, function (props) { return props.width * .5; });
97
103
  var templateObject_1, templateObject_2, templateObject_3;
98
104
  //# sourceMappingURL=BurgerButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BurgerButton.js","sourceRoot":"/","sources":["BurgerButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,6CAAkE;AAClE,wEAAmD;AACnD,oDAA6B;AAgB7B,SAAwB,YAAY,CAAC,EAa7B;IAZN,IAAA,gBAAkC,EAAxB,gBAAgB,mBAAG,KAAK,KAAA,EAClC,uBAAuB,EAAvB,eAAe,mBAAG,KAAK,KAAA,EACvB,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA,EAC1B,cAAW,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,iBAAa,EAAb,SAAS,mBAAG,CAAC,KAAA,EACb,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,iBAAkB,EAAlB,SAAS,mBAAG,MAAM,KAAA,EAClB,0BAAwB,EAAxB,kBAAkB,mBAAG,GAAG,KAAA,EACxB,UAAU,gBAAA,EACV,YAAY,kBAAA,EACZ,MAAM,YAAA,EACH,KAAK,cAZ2B,gKAapC,CADS;IAEF,IAAA,KAAA,OAA0B,IAAA,gBAAQ,EAAC,gBAAgB,CAAC,IAAA,EAAnD,QAAQ,QAAA,EAAE,WAAW,QAA8B,CAAA;IAE1D,IAAA,iBAAS,EAAC;QACR,IAAI,QAAQ,KAAK,gBAAgB,EAAE;YACjC,WAAW,CAAC,gBAAgB,CAAC,CAAA;SAC9B;IACH,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAEtB,IAAA,iBAAS,EAAC;QACR,IAAI,QA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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAArC,CAAqC,EAKxC,UAAA,KAAK,IAAI,OAAA,yBAAkB,KAAK,CAAC,MAAM,GAAC,EAAE,GAAG,KAAK,CAAC,SAAS,GAAC,EAAE,0BAAuB,EAA7E,CAA6E,EAQtF,UAAA,KAAK,IAAI,OAAA,yBAAkB,KAAK,CAAC,SAAS,GAAC,EAAE,GAAG,KAAK,CAAC,MAAM,GAAC,EAAE,yBAAsB,EAA5E,CAA4E,CAKzG,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,MAAM,ujBAI9B,yGAKU,EAAqB,mCAEjB,EAAqB,oBACtB,EAAoB,iGAKxB,EAAoB,2CAGzB,EAAW,2DAEA,EAAoB,6BAI/B,EAAW,oEAEA,EAAuB,4BAIvC,KAvBW,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,EAAZ,CAAY,EAEjB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,EAAZ,CAAY,EACtB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,EAKxB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,EAGzB,WAAW,EAEA,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,EAI/B,WAAW,EAEA,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,GAAC,EAAE,EAAd,CAAc,CAIvC,CAAA","sourcesContent":["import classNames from 'classnames'\nimport React, { HTMLAttributes, useEffect, useState } from 'react'\nimport styled, { CSSProp } from 'styled-components'\nimport Repeat from './Repeat'\n\nexport type Props = HTMLAttributes<HTMLButtonElement> & {\n isActive?: boolean\n isDoubleJointed?: boolean\n isLastBarHalfWidth?: boolean\n height?: number\n thickness?: number\n width?: number\n tintColor?: string\n transitionDuration?: number\n onActivate?: () => void\n onDeactivate?: () => void\n cssBar?: CSSProp<any>\n}\n\nexport default function BurgerButton({\n isActive: externalIsActive = false,\n isDoubleJointed = false,\n isLastBarHalfWidth = false,\n height = 20,\n thickness = 2,\n width = 20,\n tintColor = '#000',\n transitionDuration = 200,\n onActivate,\n onDeactivate,\n cssBar,\n ...props\n}: Props) {\n const [isActive, setIsActive] = useState(externalIsActive)\n\n useEffect(() => {\n if (isActive !== externalIsActive) {\n setIsActive(externalIsActive)\n }\n }, [externalIsActive])\n\n useEffect(() => {\n if (isActive) {\n onActivate?.()\n }\n else {\n onDeactivate?.()\n }\n }, [isActive])\n\n return (\n <StyledRoot width={width} height={height} thickness={thickness} onClick={() => setIsActive(!isActive)} {...props}>\n <Repeat count={isDoubleJointed ? 2 : 1}>\n <StyledJoint\n className={classNames({ active: isActive, half: isDoubleJointed })}\n height={height}\n isLastBarHalfWidth={isLastBarHalfWidth}\n thickness={thickness}\n width={width}\n >\n <Repeat count={3}>\n <StyledBar className={classNames({ active: isActive, half: isDoubleJointed })} style={{ height: `${thickness}px` }} css={cssBar}/>\n </Repeat>\n </StyledJoint>\n </Repeat>\n </StyledRoot>\n )\n}\n\nconst StyledBar = styled.span`\n background: #fff;\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n transition-duration: 100ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n width: 100%;\n\n ${props => props.css}\n`\n\nconst StyledJoint = styled.div<{\n height: number\n isLastBarHalfWidth: boolean\n thickness: number\n width: number\n}>`\n height: 100%;\n position: absolute;\n width: 100%;\n\n &.half {\n width: 50%;\n }\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n\n ${StyledBar}:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n ${StyledBar}:nth-child(2) {\n left: 0;\n top: ${props => props.height*.5 - props.thickness*.5}px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n ${StyledBar}:nth-child(3) {\n left: 0;\n top: ${props => props.height - props.thickness}px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ${props => props.isLastBarHalfWidth ? '50%' : '100%'};\n }\n\n &.active {\n ${StyledBar}:nth-child(1) {\n transform: ${props => `translate3d(0, ${props.height*.5 - props.thickness*.5}px, 0) rotate(45deg)`};\n }\n\n ${StyledBar}:nth-child(2) {\n transform: ${props => 'translate3d(0, 0, 0) scale(0)'};\n }\n\n ${StyledBar}:nth-child(3) {\n transform: ${props => `translate3d(0, ${props.thickness*.5 - props.height*.5}px, 0) rotate(-45deg)`};\n width: 100%;\n }\n }\n\n &.half {\n ${StyledBar}:nth-child(1) {\n transform-origin: right center;\n }\n\n ${StyledBar}:nth-child(2) {\n transform-origin: right center;\n }\n\n ${StyledBar}:nth-child(3) {\n transform-origin: right center;\n width: 100%;\n }\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n\n span:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n span:nth-child(2) {\n left: 0;\n top: ${props => props.height*.5 - props.thickness*.5}px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n span:nth-child(3) {\n left: 0;\n top: ${props => props.height - props.thickness}px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ${props => props.isLastBarHalfWidth ? 0 : '100%'};\n }\n\n &.active {\n span:nth-child(1) {\n transform: ${props => `translate3d(0, ${props.height*.5 - props.thickness*.5}px, 0) rotate(-45deg)`};\n }\n\n span:nth-child(2) {\n transform: translate3d(0, 0, 0) scale(0);\n }\n\n span:nth-child(3) {\n transform: ${props => `translate3d(0, ${props.thickness*.5 - props.height*.5}px, 0) rotate(45deg)`};\n width: 100%;\n }\n }\n }\n`\n\nconst StyledRoot = styled.button<{\n height: number\n thickness: number\n width: number\n}>`\n background: transparent;\n border: none;\n box-sizing: border-box;\n display: block;\n height: ${props => props.height}px;\n margin: 0;\n min-height: ${props => props.height}px;\n min-width: ${props => props.width}px;\n outline: none;\n padding: 0;\n pointer-events: auto;\n position: relative;\n width: ${props => props.width}px;\n\n html:not(.touch) &:hover {\n ${StyledJoint}:not(.half) {\n span:nth-child(3) {\n width: ${props => props.width}px;\n }\n }\n\n ${StyledJoint}.half:nth-of-type(2) {\n span:nth-child(3) {\n width: ${props => props.width*.5}px;\n }\n }\n }\n`\n"]}
1
+ {"version":3,"file":"BurgerButton.js","sourceRoot":"/","sources":["BurgerButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,6CAAkE;AAClE,wEAAsC;AACtC,oDAA6B;AAe7B;;;;GAIG;AACH,SAAwB,YAAY,CAAC,EAY7B;IAXN,IAAA,cAAW,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,gBAAkC,EAAxB,gBAAgB,mBAAG,KAAK,KAAA,EAClC,uBAAuB,EAAvB,eAAe,mBAAG,KAAK,KAAA,EACvB,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA,EAC1B,iBAAa,EAAb,SAAS,mBAAG,CAAC,KAAA,EACb,iBAAkB,EAAlB,SAAS,mBAAG,MAAM,KAAA,EAClB,0BAAwB,EAAxB,kBAAkB,mBAAG,GAAG,KAAA,EACxB,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,UAAU,gBAAA,EACV,YAAY,kBAAA,EACT,KAAK,cAX2B,sJAYpC,CADS;IAEF,IAAA,KAAA,OAA0B,IAAA,gBAAQ,EAAC,gBAAgB,CAAC,IAAA,EAAnD,QAAQ,QAAA,EAAE,WAAW,QAA8B,CAAA;IAE1D,IAAA,iBAAS,EAAC;QACR,IAAI,QAAQ,KAAK,gBAAgB,EAAE;YACjC,WAAW,CAAC,gBAAgB,CAAC,CAAA;SAC9B;IACH,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAE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KxC,UAAA,KAAK,IAAI,OAAA,yBAAkB,KAAK,CAAC,MAAM,GAAC,EAAE,GAAG,KAAK,CAAC,SAAS,GAAC,EAAE,0BAAuB,EAA7E,CAA6E,EAQtF,UAAA,KAAK,IAAI,OAAA,yBAAkB,KAAK,CAAC,SAAS,GAAC,EAAE,GAAG,KAAK,CAAC,MAAM,GAAC,EAAE,yBAAsB,EAA5E,CAA4E,CAKzG,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,MAAM,ujBAI9B,yGAKU,EAAqB,mCAEjB,EAAqB,oBACtB,EAAoB,iGAKxB,EAAoB,2CAGzB,EAAW,2DAEA,EAAoB,6BAI/B,EAAW,oEAEA,EAAuB,4BAIvC,KAvBW,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,EAAZ,CAAY,EAEjB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,EAAZ,CAAY,EACtB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,EAKxB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,EAGzB,WAAW,EAEA,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,EAI/B,WAAW,EAEA,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,GAAC,EAAE,EAAd,CAAc,CAIvC,CAAA","sourcesContent":["import classNames from 'classnames'\nimport React, { HTMLAttributes, useEffect, useState } from 'react'\nimport styled from 'styled-components'\nimport Repeat from './Repeat'\n\nexport type Props = HTMLAttributes<HTMLButtonElement> & {\n height?: number\n isActive?: boolean\n isDoubleJointed?: boolean\n isLastBarHalfWidth?: boolean\n thickness?: number\n tintColor?: string\n transitionDuration?: number\n width?: number\n onActivate?: () => void\n onDeactivate?: () => void\n}\n\n/**\n * Three-striped burger button component that transforms into an \"X\" when selected.\n *\n * @exports BurgerButtonBar - Component for each line on the burger button.\n */\nexport default function BurgerButton({\n height = 20,\n isActive: externalIsActive = false,\n isDoubleJointed = false,\n isLastBarHalfWidth = false,\n thickness = 2,\n tintColor = '#000',\n transitionDuration = 200,\n width = 20,\n onActivate,\n onDeactivate,\n ...props\n}: Props) {\n const [isActive, setIsActive] = useState(externalIsActive)\n\n useEffect(() => {\n if (isActive !== externalIsActive) {\n setIsActive(externalIsActive)\n }\n }, [externalIsActive])\n\n useEffect(() => {\n if (isActive) {\n onActivate?.()\n }\n else {\n onDeactivate?.()\n }\n }, [isActive])\n\n return (\n <StyledRoot {...props} width={width} height={height} thickness={thickness} onClick={() => setIsActive(!isActive)}>\n <Repeat count={isDoubleJointed ? 2 : 1}>\n <StyledJoint\n className={classNames({ active: isActive, half: isDoubleJointed })}\n height={height}\n isLastBarHalfWidth={isLastBarHalfWidth}\n thickness={thickness}\n width={width}\n >\n <Repeat count={3}>\n <BurgerButtonBar className={classNames({ active: isActive, half: isDoubleJointed })} style={{ height: `${thickness}px` }}/>\n </Repeat>\n </StyledJoint>\n </Repeat>\n </StyledRoot>\n )\n}\n\nexport const BurgerButtonBar = styled.span`\n background: #fff;\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n transition-duration: 100ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n width: 100%;\n`\n\nconst StyledJoint = styled.div<{\n height: number\n isLastBarHalfWidth: boolean\n thickness: number\n width: number\n}>`\n height: 100%;\n position: absolute;\n width: 100%;\n\n &.half {\n width: 50%;\n }\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n\n ${BurgerButtonBar}:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n ${BurgerButtonBar}:nth-child(2) {\n left: 0;\n top: ${props => props.height*.5 - props.thickness*.5}px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n ${BurgerButtonBar}:nth-child(3) {\n left: 0;\n top: ${props => props.height - props.thickness}px;\n transform-origin: center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ${props => props.isLastBarHalfWidth ? '50%' : '100%'};\n }\n\n &.active {\n ${BurgerButtonBar}:nth-child(1) {\n transform: ${props => `translate3d(0, ${props.height*.5 - props.thickness*.5}px, 0) rotate(45deg)`};\n }\n\n ${BurgerButtonBar}:nth-child(2) {\n transform: ${props => 'translate3d(0, 0, 0) scale(0)'};\n }\n\n ${BurgerButtonBar}:nth-child(3) {\n transform: ${props => `translate3d(0, ${props.thickness*.5 - props.height*.5}px, 0) rotate(-45deg)`};\n width: 100%;\n }\n }\n\n &.half {\n ${BurgerButtonBar}:nth-child(1) {\n transform-origin: right center;\n }\n\n ${BurgerButtonBar}:nth-child(2) {\n transform-origin: right center;\n }\n\n ${BurgerButtonBar}:nth-child(3) {\n transform-origin: right center;\n width: 100%;\n }\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n\n span:nth-child(1) {\n left: 0;\n top: 0;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n }\n\n span:nth-child(2) {\n left: 0;\n top: ${props => props.height*.5 - props.thickness*.5}px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) scale(1);\n }\n\n span:nth-child(3) {\n left: 0;\n top: ${props => props.height - props.thickness}px;\n transform-origin: left center;\n transform: translate3d(0, 0, 0) rotate(0deg);\n width: ${props => props.isLastBarHalfWidth ? 0 : '100%'};\n }\n\n &.active {\n span:nth-child(1) {\n transform: ${props => `translate3d(0, ${props.height*.5 - props.thickness*.5}px, 0) rotate(-45deg)`};\n }\n\n span:nth-child(2) {\n transform: translate3d(0, 0, 0) scale(0);\n }\n\n span:nth-child(3) {\n transform: ${props => `translate3d(0, ${props.thickness*.5 - props.height*.5}px, 0) rotate(45deg)`};\n width: 100%;\n }\n }\n }\n`\n\nconst StyledRoot = styled.button<{\n height: number\n thickness: number\n width: number\n}>`\n background: transparent;\n border: none;\n box-sizing: border-box;\n display: block;\n height: ${props => props.height}px;\n margin: 0;\n min-height: ${props => props.height}px;\n min-width: ${props => props.width}px;\n outline: none;\n padding: 0;\n pointer-events: auto;\n position: relative;\n width: ${props => props.width}px;\n\n html:not(.touch) &:hover {\n ${StyledJoint}:not(.half) {\n span:nth-child(3) {\n width: ${props => props.width}px;\n }\n }\n\n ${StyledJoint}.half:nth-of-type(2) {\n span:nth-child(3) {\n width: ${props => props.width*.5}px;\n }\n }\n }\n`\n"]}
package/lib/Dial.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { HTMLAttributes } from 'react';
2
- import { CSSProp } from 'styled-components';
3
2
  export declare type Props = HTMLAttributes<HTMLDivElement> & {
4
3
  /**
5
4
  * Current angle reading of the compass, between 0.0 - 360.0 degrees, inclusive.
@@ -23,21 +22,18 @@ export declare type Props = HTMLAttributes<HTMLDivElement> & {
23
22
  * Note that this overwrites the `stroke-width` set inside `cssKnob`.
24
23
  */
25
24
  knobThickness?: number;
26
- /**
27
- * CSS of the knob, which is a `<path>` element.
28
- */
29
- cssKnob?: CSSProp<any>;
30
25
  /**
31
26
  * The thickness of the circular track, which is equivalent to the `stroke-width` of the
32
27
  * `<circle>` element. Note that this overwrites the `stroke-width` set inside `cssTrack`.
33
28
  */
34
29
  trackThickness?: number;
35
- /**
36
- * CSS of the track, which is a `<circle>` element.
37
- */
38
- cssTrack?: CSSProp<any>;
39
30
  };
40
31
  /**
41
32
  * A circular dial with a knob and a track.
33
+ *
34
+ * @exports DialKnob
35
+ * @exports DialTrack
42
36
  */
43
- export default function Dial({ angle, radius, knobLength, knobThickness, cssKnob, trackThickness, cssTrack, style, ...props }: Props): JSX.Element;
37
+ export default function Dial({ angle, radius, knobLength, knobThickness, trackThickness, style, ...props }: Props): JSX.Element;
38
+ export declare const DialTrack: import("styled-components").StyledComponent<"circle", any, {}, never>;
39
+ export declare const DialKnob: import("styled-components").StyledComponent<"path", any, {}, never>;
package/lib/Dial.js CHANGED
@@ -29,6 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.DialKnob = exports.DialTrack = void 0;
32
33
  var react_1 = __importDefault(require("react"));
33
34
  var styled_components_1 = __importDefault(require("styled-components"));
34
35
  function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
@@ -50,24 +51,27 @@ function arcPath(x, y, radius, startAngle, endAngle) {
50
51
  }
51
52
  /**
52
53
  * A circular dial with a knob and a track.
54
+ *
55
+ * @exports DialKnob
56
+ * @exports DialTrack
53
57
  */
54
58
  function Dial(_a) {
55
- var _b = _a.angle, angle = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ? 50 : _c, _d = _a.knobLength, knobLength = _d === void 0 ? 30 : _d, _e = _a.knobThickness, knobThickness = _e === void 0 ? 10 : _e, cssKnob = _a.cssKnob, _f = _a.trackThickness, trackThickness = _f === void 0 ? 2 : _f, cssTrack = _a.cssTrack, style = _a.style, props = __rest(_a, ["angle", "radius", "knobLength", "knobThickness", "cssKnob", "trackThickness", "cssTrack", "style"]);
59
+ var _b = _a.angle, angle = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ? 50 : _c, _d = _a.knobLength, knobLength = _d === void 0 ? 30 : _d, _e = _a.knobThickness, knobThickness = _e === void 0 ? 10 : _e, _f = _a.trackThickness, trackThickness = _f === void 0 ? 2 : _f, style = _a.style, props = __rest(_a, ["angle", "radius", "knobLength", "knobThickness", "trackThickness", "style"]);
56
60
  var diameter = radius * 2;
57
61
  var clampedKnobAngle = Math.max(0, Math.min(360, knobLength));
58
62
  return (react_1.default.createElement(StyledRoot, __assign({ style: __assign(__assign({}, style), { width: "".concat(diameter, "px"), height: "".concat(diameter, "px") }) }, props),
59
- react_1.default.createElement(StyledTrack, null,
63
+ react_1.default.createElement(StyledTrackContainer, null,
60
64
  react_1.default.createElement("svg", { width: diameter, height: diameter, viewBox: "0 0 ".concat(diameter, " ").concat(diameter) },
61
- react_1.default.createElement(StyledTrackCircle, { cx: radius, cy: radius, r: radius - trackThickness / 2, css: cssTrack, strokeWidth: trackThickness }))),
62
- react_1.default.createElement(StyledKnob, { style: { transform: "rotate(".concat((angle + 360) % 360, "deg)") } },
65
+ react_1.default.createElement(exports.DialTrack, { cx: radius, cy: radius, r: radius - trackThickness / 2, strokeWidth: trackThickness }))),
66
+ react_1.default.createElement(StyledKnobContainer, { style: { transform: "rotate(".concat((angle + 360) % 360, "deg)") } },
63
67
  react_1.default.createElement("svg", { viewBox: "0 0 ".concat(diameter, " ").concat(diameter), xmlns: 'http://www.w3.org/2000/svg' },
64
- react_1.default.createElement(StyledKnobPath, { css: cssKnob, strokeWidth: knobThickness, d: arcPath(radius, radius, radius - knobThickness / 2 - (trackThickness - knobThickness) / 2, -clampedKnobAngle / 2, clampedKnobAngle / 2) })))));
68
+ react_1.default.createElement(exports.DialKnob, { strokeWidth: knobThickness, d: arcPath(radius, radius, radius - knobThickness / 2 - (trackThickness - knobThickness) / 2, -clampedKnobAngle / 2, clampedKnobAngle / 2) })))));
65
69
  }
66
70
  exports.default = Dial;
67
- var StyledTrack = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n"], ["\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n"])));
68
- var StyledTrackCircle = styled_components_1.default.circle(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n stroke-dasharray: 4;\n stroke: #fff;\n ", "\n"], ["\n stroke-dasharray: 4;\n stroke: #fff;\n ", "\n"])), function (props) { return props.css; });
69
- var StyledKnob = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n\n svg {\n overflow: visible;\n position: absolute;\n right: 0;\n top: 0;\n }\n"], ["\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n\n svg {\n overflow: visible;\n position: absolute;\n right: 0;\n top: 0;\n }\n"])));
70
- var StyledKnobPath = styled_components_1.default.path(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n stroke: #fff;\n ", "\n"], ["\n stroke: #fff;\n ", "\n"])), function (props) { return props.css; });
71
+ exports.DialTrack = styled_components_1.default.circle(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n stroke-dasharray: 4;\n stroke: #fff;\n"], ["\n stroke-dasharray: 4;\n stroke: #fff;\n"])));
72
+ exports.DialKnob = styled_components_1.default.path(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n stroke: #fff;\n"], ["\n stroke: #fff;\n"])));
73
+ var StyledTrackContainer = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n"], ["\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n"])));
74
+ var StyledKnobContainer = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n\n svg {\n overflow: visible;\n position: absolute;\n right: 0;\n top: 0;\n }\n"], ["\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n\n svg {\n overflow: visible;\n position: absolute;\n right: 0;\n top: 0;\n }\n"])));
71
75
  var StyledRoot = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n box-sizing: border-box;\n display: block;\n"], ["\n box-sizing: border-box;\n display: block;\n"])));
72
76
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
73
77
  //# sourceMappingURL=Dial.js.map
package/lib/Dial.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Dial.js","sourceRoot":"/","sources":["Dial.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA6C;AAC7C,wEAAmD;AA8CnD,SAAS,gBAAgB,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,cAAsB;IAChG,IAAM,cAAc,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,KAAK,CAAA;IAE9D,OAAO;QACL,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAChD,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;KACjD,CAAA;AACH,CAAC;AAED,SAAS,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,MAAc,EAAE,UAAkB,EAAE,QAAgB;IACzF,IAAM,KAAK,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IACtD,IAAM,GAAG,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;IACtD,IAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IAC7D,IAAM,CAAC,GAAG;QACR,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACrB,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;KACtD,CAAA;IAED,OAAO,CAAC,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7E,8BAAC,cAAc,IAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,CAAC,GAAG,CAAC,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,GAAG,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,GAAG,CACnM,CACK,CACF,CACd,CAAA;AACH,CAAC;AAlCD,uBAkCC;AAED,IAAM,WAAW,GAAG,2BAAM,CAAC,GAAG,mLAAA,gHAO7B,IAAA,CAAA;AAED,IAAM,iBAAiB,GAAG,2BAAM,CAAC,MAAM,wHAAA,+CAGnC,EAAkB,IACrB,KADG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,GAAG,EAAT,CAAS,CACrB,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,2WAAA,wSAiB5B,IAAA,CAAA;AAED,IAAM,cAAc,GAAG,2BAAM,CAAC,IAAI,gGAAA,uBAE9B,EAAkB,IACrB,KADG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,GAAG,EAAT,CAAS,CACrB,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,qHAAA,kDAG5B,IAAA,CAAA","sourcesContent":["import React, { HTMLAttributes } from 'react'\nimport styled, { CSSProp } from 'styled-components'\n\nexport type Props = HTMLAttributes<HTMLDivElement> & {\n /**\n * Current angle reading of the compass, between 0.0 - 360.0 degrees, inclusive.\n */\n angle?: number\n\n /**\n * Length of the knob along the track expressed in degrees, between 0.0 and 360.0 degrees,\n * exclusive. If set to 0 or 360, the knob disappears.\n *\n * @example Suppose the compass were to be used to control a photosphere of an image that is 1000\n * x 500, and the window size is 500 x 500, that would mean the FOV is 500 / 1000 * 360 =\n * 180 degrees.\n */\n knobLength?: number\n\n /**\n * Radius of the compass.\n */\n radius?: number\n\n /**\n * The thickness of the knob, which is equivalent to the `stroke-width` of the `<path>` element.\n * Note that this overwrites the `stroke-width` set inside `cssKnob`.\n */\n knobThickness?: number\n\n /**\n * CSS of the knob, which is a `<path>` element.\n */\n cssKnob?: CSSProp<any>\n\n /**\n * The thickness of the circular track, which is equivalent to the `stroke-width` of the\n * `<circle>` element. Note that this overwrites the `stroke-width` set inside `cssTrack`.\n */\n trackThickness?: number\n\n /**\n * CSS of the track, which is a `<circle>` element.\n */\n cssTrack?: CSSProp<any>\n}\n\nfunction polarToCartesian(centerX: number, centerY: number, radius: number, angleInDegrees: number) {\n const angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0\n\n return {\n x: centerX + (radius * Math.cos(angleInRadians)),\n y: centerY + (radius * Math.sin(angleInRadians)),\n }\n}\n\nfunction arcPath(x: number, y: number, radius: number, startAngle: number, endAngle: number) {\n const start = polarToCartesian(x, y, radius, endAngle)\n const end = polarToCartesian(x, y, radius, startAngle)\n const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1'\n const d = [\n 'M', start.x, start.y,\n 'A', radius, radius, 0, largeArcFlag, 0, end.x, end.y,\n ]\n\n return d.join(' ')\n}\n\n/**\n * A circular dial with a knob and a track.\n */\nexport default function Dial({\n angle = 0,\n radius = 50,\n knobLength = 30,\n knobThickness = 10,\n cssKnob,\n trackThickness = 2,\n cssTrack,\n style,\n ...props\n}: Props) {\n const diameter = radius * 2\n const clampedKnobAngle = Math.max(0, Math.min(360, knobLength))\n\n return (\n <StyledRoot style={{ ...style, width: `${diameter}px`, height: `${diameter}px` }} {...props}>\n <StyledTrack>\n <svg width={diameter} height={diameter} viewBox={`0 0 ${diameter} ${diameter}`}>\n <StyledTrackCircle\n cx={radius}\n cy={radius}\n r={radius - trackThickness / 2}\n css={cssTrack}\n strokeWidth={trackThickness}\n />\n </svg>\n </StyledTrack>\n <StyledKnob style={{ transform: `rotate(${(angle + 360) % 360}deg)` }}>\n <svg viewBox={`0 0 ${diameter} ${diameter}`} xmlns='http://www.w3.org/2000/svg'>\n <StyledKnobPath css={cssKnob} strokeWidth={knobThickness} d={arcPath(radius, radius, radius - knobThickness / 2 - (trackThickness - knobThickness) / 2, -clampedKnobAngle / 2, clampedKnobAngle / 2)}/>\n </svg>\n </StyledKnob>\n </StyledRoot>\n )\n}\n\nconst StyledTrack = styled.div`\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n`\n\nconst StyledTrackCircle = styled.circle`\n stroke-dasharray: 4;\n stroke: #fff;\n ${props => props.css}\n`\n\nconst StyledKnob = styled.div`\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n\n svg {\n overflow: visible;\n position: absolute;\n right: 0;\n top: 0;\n }\n`\n\nconst StyledKnobPath = styled.path`\n stroke: #fff;\n ${props => props.css}\n`\n\nconst StyledRoot = styled.div`\n box-sizing: border-box;\n display: block;\n`\n"]}
1
+ {"version":3,"file":"Dial.js","sourceRoot":"/","sources":["Dial.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA6C;AAC7C,wEAAsC;AAoCtC,SAAS,gBAAgB,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,cAAsB;IAChG,IAAM,cAAc,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,KAAK,CAAA;IAE9D,OAAO;QACL,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAChD,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;KACjD,CAAA;AACH,CAAC;AAED,SAAS,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,MAAc,EAAE,UAAkB,EAAE,QAAgB;IACzF,IAAM,KAAK,GAAG,gBAAgB,CAAC,CAAC,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E,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAO,QAAQ,cAAI,QAAQ,CAAE;gBAC5E,8BAAC,iBAAS,IACR,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,CAAC,EAC9B,WAAW,EAAE,cAAc,GAC3B,CACE,CACe;QACvB,8BAAC,mBAAmB,IAAC,KAAK,EAAE,EAAE,SAAS,EAAE,iBAAU,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,SAAM,EAAE;YAC5E,uCAAK,OAAO,EAAE,cAAO,QAAQ,cAAI,QAAQ,CAAE,EAAE,KAAK,EAAC,4BAA4B;gBAC7E,8BAAC,gBAAQ,IAAC,WAAW,EAAE,aAAa,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,CAAC,GAAG,CAAC,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,GAAG,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,GAAG,CAC/K,CACc,CACX,CACd,CAAA;AACH,CAAC;AA/BD,uBA+BC;AAEY,QAAA,SAAS,GAAG,2BAAM,CAAC,MAAM,gHAAA,6CAGrC,KAAA;AAEY,QAAA,QAAQ,GAAG,2BAAM,CAAC,IAAI,wFAAA,qBAElC,KAAA;AAED,IAAM,oBAAoB,GAAG,2BAAM,CAAC,GAAG,mLAAA,gHAOtC,IAAA,CAAA;AAED,IAAM,mBAAmB,GAAG,2BAAM,CAAC,GAAG,2WAAA,wSAiBrC,IAAA,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,qHAAA,kDAG5B,IAAA,CAAA","sourcesContent":["import React, { HTMLAttributes } from 'react'\nimport styled from 'styled-components'\n\nexport type Props = HTMLAttributes<HTMLDivElement> & {\n /**\n * Current angle reading of the compass, between 0.0 - 360.0 degrees, inclusive.\n */\n angle?: number\n\n /**\n * Length of the knob along the track expressed in degrees, between 0.0 and 360.0 degrees,\n * exclusive. If set to 0 or 360, the knob disappears.\n *\n * @example Suppose the compass were to be used to control a photosphere of an image that is 1000\n * x 500, and the window size is 500 x 500, that would mean the FOV is 500 / 1000 * 360 =\n * 180 degrees.\n */\n knobLength?: number\n\n /**\n * Radius of the compass.\n */\n radius?: number\n\n /**\n * The thickness of the knob, which is equivalent to the `stroke-width` of the `<path>` element.\n * Note that this overwrites the `stroke-width` set inside `cssKnob`.\n */\n knobThickness?: number\n\n /**\n * The thickness of the circular track, which is equivalent to the `stroke-width` of the\n * `<circle>` element. Note that this overwrites the `stroke-width` set inside `cssTrack`.\n */\n trackThickness?: number\n}\n\nfunction polarToCartesian(centerX: number, centerY: number, radius: number, angleInDegrees: number) {\n const angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0\n\n return {\n x: centerX + (radius * Math.cos(angleInRadians)),\n y: centerY + (radius * Math.sin(angleInRadians)),\n }\n}\n\nfunction arcPath(x: number, y: number, radius: number, startAngle: number, endAngle: number) {\n const start = polarToCartesian(x, y, radius, endAngle)\n const end = polarToCartesian(x, y, radius, startAngle)\n const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1'\n const d = [\n 'M', start.x, start.y,\n 'A', radius, radius, 0, largeArcFlag, 0, end.x, end.y,\n ]\n\n return d.join(' ')\n}\n\n/**\n * A circular dial with a knob and a track.\n *\n * @exports DialKnob\n * @exports DialTrack\n */\nexport default function Dial({\n angle = 0,\n radius = 50,\n knobLength = 30,\n knobThickness = 10,\n trackThickness = 2,\n style,\n ...props\n}: Props) {\n const diameter = radius * 2\n const clampedKnobAngle = Math.max(0, Math.min(360, knobLength))\n\n return (\n <StyledRoot style={{ ...style, width: `${diameter}px`, height: `${diameter}px` }} {...props}>\n <StyledTrackContainer>\n <svg width={diameter} height={diameter} viewBox={`0 0 ${diameter} ${diameter}`}>\n <DialTrack\n cx={radius}\n cy={radius}\n r={radius - trackThickness / 2}\n strokeWidth={trackThickness}\n />\n </svg>\n </StyledTrackContainer>\n <StyledKnobContainer style={{ transform: `rotate(${(angle + 360) % 360}deg)` }}>\n <svg viewBox={`0 0 ${diameter} ${diameter}`} xmlns='http://www.w3.org/2000/svg'>\n <DialKnob strokeWidth={knobThickness} d={arcPath(radius, radius, radius - knobThickness / 2 - (trackThickness - knobThickness) / 2, -clampedKnobAngle / 2, clampedKnobAngle / 2)}/>\n </svg>\n </StyledKnobContainer>\n </StyledRoot>\n )\n}\n\nexport const DialTrack = styled.circle`\n stroke-dasharray: 4;\n stroke: #fff;\n`\n\nexport const DialKnob = styled.path`\n stroke: #fff;\n`\n\nconst StyledTrackContainer = styled.div`\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n`\n\nconst StyledKnobContainer = styled.div`\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n width: 100%;\n\n svg {\n overflow: visible;\n position: absolute;\n right: 0;\n top: 0;\n }\n`\n\nconst StyledRoot = styled.div`\n box-sizing: border-box;\n display: block;\n`\n"]}
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import React, { HTMLAttributes, PropsWithChildren } from 'react';
2
+ export declare type Props = PropsWithChildren<HTMLAttributes<HTMLElement>>;
2
3
  declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
3
4
  children?: React.ReactNode;
4
5
  } & React.RefAttributes<HTMLElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"ExtractChild.js","sourceRoot":"/","sources":["ExtractChild.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,kDAAsB;AACtB,6CAAoH;AAIpH;;;GAGG;AACH,kBAAe,IAAA,kBAAU,EAAqB,UAAC,EAI9C,EAAE,GAAG;IAHJ,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACN,KAAK,cAHqC,yBAI9C,CADS;IAER,IAAI,gBAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACvB,yCAAyC;QACzC,OAAO,CAAC,KAAK,CAAC,uEAAgE,QAAQ,CAAC,MAAM,sEAAmE,CAAC,CAAA;KAClK;IAED,OAAO,CACL,8DACG,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAC,KAAK,EAAE,GAAG;QACjC,IAAI,GAAG,GAAG,CAAC;YAAE,OAAO,SAAS,CAAA;QAE7B,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE;YACzB,OAAO,IAAA,oBAAY,EAAC,KAAK,sBAAI,SAAS,EAAE,IAAA,oBAAU,EAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,IAAK,KAAK,KAAE,GAAG,KAAA,IAAG,CAAA;SACvG;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CACD,CACJ,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import classNames from 'classnames'\nimport _ from 'lodash'\nimport React, { Children, cloneElement, forwardRef, HTMLAttributes, isValidElement, PropsWithChildren } from 'react'\n\ntype Props = PropsWithChildren<HTMLAttributes<HTMLElement>>\n\n/**\n * Extracts a single child of a parent component into its own component. If the parent component has\n * multiple children, only the first one will be extracted, the rest will be ignored.\n */\nexport default forwardRef<HTMLElement, Props>(({\n children,\n className,\n ...props\n}, ref) => {\n if (_.isArray(children)) {\n /* eslint-disable-next-line no-console */\n console.error(`[etudes::ExtractChild] Only one child is expected, but found ${children.length}. Only the first child is extracted while the rest are discarded.`)\n }\n\n return (\n <>\n {Children.map(children, (child, idx) => {\n if (idx > 0) return undefined\n\n if (isValidElement(child)) {\n return cloneElement(child, { className: classNames(className, child.props.className), ...props, ref })\n }\n\n return child\n })}\n </>\n )\n})\n"]}
1
+ {"version":3,"file":"ExtractChild.js","sourceRoot":"/","sources":["ExtractChild.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,kDAAsB;AACtB,6CAAoH;AAIpH;;;GAGG;AACH,kBAAe,IAAA,kBAAU,EAAqB,UAAC,EAI9C,EAAE,GAAG;IAHJ,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACN,KAAK,cAHqC,yBAI9C,CADS;IAER,IAAI,gBAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACvB,yCAAyC;QACzC,OAAO,CAAC,KAAK,CAAC,uEAAgE,QAAQ,CAAC,MAAM,sEAAmE,CAAC,CAAA;KAClK;IAED,OAAO,CACL,8DACG,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAC,KAAK,EAAE,GAAG;QACjC,IAAI,GAAG,GAAG,CAAC;YAAE,OAAO,SAAS,CAAA;QAE7B,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE;YACzB,OAAO,IAAA,oBAAY,EAAC,KAAK,sBAAI,SAAS,EAAE,IAAA,oBAAU,EAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,IAAK,KAAK,KAAE,GAAG,KAAA,IAAG,CAAA;SACvG;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CACD,CACJ,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import classNames from 'classnames'\nimport _ from 'lodash'\nimport React, { Children, cloneElement, forwardRef, HTMLAttributes, isValidElement, PropsWithChildren } from 'react'\n\nexport type Props = PropsWithChildren<HTMLAttributes<HTMLElement>>\n\n/**\n * Extracts a single child of a parent component into its own component. If the parent component has\n * multiple children, only the first one will be extracted, the rest will be ignored.\n */\nexport default forwardRef<HTMLElement, Props>(({\n children,\n className,\n ...props\n}, ref) => {\n if (_.isArray(children)) {\n /* eslint-disable-next-line no-console */\n console.error(`[etudes::ExtractChild] Only one child is expected, but found ${children.length}. Only the first child is extracted while the rest are discarded.`)\n }\n\n return (\n <>\n {Children.map(children, (child, idx) => {\n if (idx > 0) return undefined\n\n if (isValidElement(child)) {\n return cloneElement(child, { className: classNames(className, child.props.className), ...props, ref })\n }\n\n return child\n })}\n </>\n )\n})\n"]}
@@ -1,5 +1,6 @@
1
1
  import { HTMLAttributes, PropsWithChildren } from 'react';
2
+ export declare type Props = PropsWithChildren<HTMLAttributes<HTMLElement>>;
2
3
  /**
3
4
  * Extracts all children of a parent component into its own component.
4
5
  */
5
- export default function ExtractChildren({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLElement>>): JSX.Element;
6
+ export default function ExtractChildren({ children, className, ...props }: Props): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"ExtractChildren.js","sourceRoot":"/","sources":["ExtractChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,6CAAwG;AAExG;;GAEG;AACH,SAAwB,eAAe,CAAC,EAAiF;IAA/E,IAAA,QAAQ,cAAA,EAAE,SAAS,eAAA,EAAK,KAAK,cAA/B,yBAAiC,CAAF;IACrE,OAAO,CACL,8DACG,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAC,KAAK,EAAE,GAAG;QACjC,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE;YACzB,OAAO,IAAA,oBAAY,EAAC,KAAK,aAAI,SAAS,EAAE,IAAA,oBAAU,EAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,IAAK,KAAK,EAAG,CAAA;SAClG;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CACD,CACJ,CAAA;AACH,CAAC;AAZD,kCAYC","sourcesContent":["import classNames from 'classnames'\nimport React, { Children, cloneElement, HTMLAttributes, isValidElement, PropsWithChildren } from 'react'\n\n/**\n * Extracts all children of a parent component into its own component.\n */\nexport default function ExtractChildren({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLElement>>) {\n return (\n <>\n {Children.map(children, (child, idx) => {\n if (isValidElement(child)) {\n return cloneElement(child, { className: classNames(className, child.props.className), ...props })\n }\n\n return child\n })}\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"ExtractChildren.js","sourceRoot":"/","sources":["ExtractChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,6CAAwG;AAIxG;;GAEG;AACH,SAAwB,eAAe,CAAC,EAIhC;IAHN,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACN,KAAK,cAH8B,yBAIvC,CADS;IAER,OAAO,CACL,8DACG,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAC,KAAK,EAAE,GAAG;QACjC,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE;YACzB,OAAO,IAAA,oBAAY,EAAC,KAAK,aAAI,SAAS,EAAE,IAAA,oBAAU,EAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,IAAK,KAAK,EAAG,CAAA;SAClG;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CACD,CACJ,CAAA;AACH,CAAC;AAhBD,kCAgBC","sourcesContent":["import classNames from 'classnames'\nimport React, { Children, cloneElement, HTMLAttributes, isValidElement, PropsWithChildren } from 'react'\n\nexport type Props = PropsWithChildren<HTMLAttributes<HTMLElement>>\n\n/**\n * Extracts all children of a parent component into its own component.\n */\nexport default function ExtractChildren({\n children,\n className,\n ...props\n}: Props) {\n return (\n <>\n {Children.map(children, (child, idx) => {\n if (isValidElement(child)) {\n return cloneElement(child, { className: classNames(className, child.props.className), ...props })\n }\n\n return child\n })}\n </>\n )\n}\n"]}
package/lib/FlatSVG.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import React, { HTMLAttributes } from 'react';
2
- import { CSSProp } from 'styled-components';
3
2
  export declare type Props = HTMLAttributes<HTMLDivElement> & {
4
3
  /**
5
4
  * The SVG string markup, i.e. "<svg>...</svg>".
@@ -25,10 +24,6 @@ export declare type Props = HTMLAttributes<HTMLDivElement> & {
25
24
  * node and all of its child nodes.
26
25
  */
27
26
  stripStyles?: boolean;
28
- /**
29
- * Extended CSS to be provided to the SVG root node.
30
- */
31
- cssSVG?: CSSProp<any>;
32
27
  /**
33
28
  * Specifies attribute names to exclude from being stripped if `stripExtraneousAttributes` is
34
29
  * enabled. By default, only `viewBox` is whitelisted.
@@ -60,10 +55,6 @@ declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTM
60
55
  * node and all of its child nodes.
61
56
  */
62
57
  stripStyles?: boolean | undefined;
63
- /**
64
- * Extended CSS to be provided to the SVG root node.
65
- */
66
- cssSVG?: CSSProp<any> | undefined;
67
58
  /**
68
59
  * Specifies attribute names to exclude from being stripped if `stripExtraneousAttributes` is
69
60
  * enabled. By default, only `viewBox` is whitelisted.
package/lib/FlatSVG.js CHANGED
@@ -112,7 +112,7 @@ function removeAttributes(element, attributes, recursive, whitelist) {
112
112
  * sanitize the markup (i.e. stripping useless attributes) according to the props specified.
113
113
  */
114
114
  exports.default = (0, react_1.forwardRef)(function (_a, ref) {
115
- var markup = _a.markup, _b = _a.stripClasses, stripClasses = _b === void 0 ? true : _b, _c = _a.stripExtraneousAttributes, stripExtraneousAttributes = _c === void 0 ? true : _c, _d = _a.stripIds, stripIds = _d === void 0 ? true : _d, _e = _a.stripStyles, stripStyles = _e === void 0 ? true : _e, cssSVG = _a.cssSVG, _f = _a.whitelistedAttributes, whitelistedAttributes = _f === void 0 ? ['viewBox'] : _f, props = __rest(_a, ["markup", "stripClasses", "stripExtraneousAttributes", "stripIds", "stripStyles", "cssSVG", "whitelistedAttributes"]);
115
+ var markup = _a.markup, _b = _a.stripClasses, stripClasses = _b === void 0 ? true : _b, _c = _a.stripExtraneousAttributes, stripExtraneousAttributes = _c === void 0 ? true : _c, _d = _a.stripIds, stripIds = _d === void 0 ? true : _d, _e = _a.stripStyles, stripStyles = _e === void 0 ? true : _e, _f = _a.whitelistedAttributes, whitelistedAttributes = _f === void 0 ? ['viewBox'] : _f, props = __rest(_a, ["markup", "stripClasses", "stripExtraneousAttributes", "stripIds", "stripStyles", "whitelistedAttributes"]);
116
116
  function sanitizedMarkup() {
117
117
  var mockContainer = document.createElement('div');
118
118
  mockContainer.innerHTML = markup;
@@ -132,8 +132,8 @@ exports.default = (0, react_1.forwardRef)(function (_a, ref) {
132
132
  removeStyles(svgElement);
133
133
  return svgElement.outerHTML;
134
134
  }
135
- return (react_1.default.createElement(StyledRoot, __assign({ ref: ref, dangerouslySetInnerHTML: { __html: sanitizedMarkup() }, cssSVG: cssSVG }, props)));
135
+ return (react_1.default.createElement(StyledRoot, __assign({ ref: ref, dangerouslySetInnerHTML: { __html: sanitizedMarkup() } }, props)));
136
136
  });
137
- var StyledRoot = styled_components_1.default.figure(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n > svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n\n ", "\n }\n"], ["\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n > svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n\n ", "\n }\n"])), function (props) { return props.cssSVG; });
137
+ var StyledRoot = styled_components_1.default.figure(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n }\n"], ["\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n }\n"])));
138
138
  var templateObject_1;
139
139
  //# sourceMappingURL=FlatSVG.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlatSVG.js","sourceRoot":"/","sources":["FlatSVG.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyD;AACzD,wEAAmD;AA4CnD,SAAS,YAAY,CAAC,OAAgB;IACpC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAEhC,IAAM,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAC1D,IAAM,eAAe,GAAG,YAAY,CAAC,MAAM,CAAA;IAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,EAAE,EAAE;QACxC,IAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;QACnC,WAAW,CAAC,MAAM,EAAE,CAAA;KACrB;IAED,IAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAA;IAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE;QACpC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;KAClC;AACH,CAAC;AA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A","sourcesContent":["import React, { forwardRef, HTMLAttributes } from 'react'\nimport styled, { CSSProp } from 'styled-components'\n\nexport type Props = HTMLAttributes<HTMLDivElement> & {\n /**\n * The SVG string markup, i.e. \"<svg>...</svg>\".\n */\n markup: string\n\n /**\n * Specifies whether the 'class' should be removed in the SVG root node and all of its child\n * nodes.\n */\n stripClasses?: boolean\n\n /**\n * Specifies whether extraneous attributes should be removed from the SVG root node. The\n * `whitelistedAttributes` prop defines what attributes should be kept.\n */\n stripExtraneousAttributes?: boolean\n\n /**\n * Specifies whether the 'id' attribute should be removed in the SVG root node and all of its\n * child nodes.\n */\n stripIds?: boolean\n\n /**\n * Specifies whether the 'style' atribute and any <style> nodes should be removed in the SVG root\n * node and all of its child nodes.\n */\n stripStyles?: boolean\n\n /**\n * Extended CSS to be provided to the SVG root node.\n */\n cssSVG?: CSSProp<any>\n\n /**\n * Specifies attribute names to exclude from being stripped if `stripExtraneousAttributes` is\n * enabled. By default, only `viewBox` is whitelisted.\n */\n whitelistedAttributes?: string[]\n}\n\nfunction removeStyles(element: Element) {\n element.removeAttribute('style')\n\n const inlineStyles = element.getElementsByTagName('style')\n const numInlineStyles = inlineStyles.length\n\n for (let i = 0; i < numInlineStyles; i++) {\n const inlineStyle = inlineStyles[i]\n inlineStyle.remove()\n }\n\n const numChildren = element.children.length\n\n for (let i = 0; i < numChildren; i++) {\n removeStyles(element.children[i])\n }\n}\n\nfunction removeAttributes(element: Element, attributes: string[] | undefined = undefined, recursive = false, whitelist: string[] = []) {\n const attrs = attributes ?? element.getAttributeNames()\n const numAttrs = attrs.length\n\n for (let i = 0; i < numAttrs; i++) {\n const attr = attrs[i]\n const keep = whitelist.indexOf(attr) > -1\n if (!keep) element.removeAttribute(attr)\n }\n\n if (recursive) {\n const numChildren = element.children.length\n\n for (let i = 0; i < numChildren; i++) {\n removeAttributes(element.children[i], attributes, recursive, whitelist)\n }\n }\n}\n\n/**\n * A component whose root element wraps an SVG markup. When wrapping the SVG, it will attempt to\n * sanitize the markup (i.e. stripping useless attributes) according to the props specified.\n */\nexport default forwardRef<HTMLDivElement, Props>(({\n markup,\n stripClasses = true,\n stripExtraneousAttributes = true,\n stripIds = true,\n stripStyles = true,\n cssSVG,\n whitelistedAttributes = ['viewBox'],\n ...props\n}, ref) => {\n function sanitizedMarkup(): string {\n const mockContainer = document.createElement('div')\n mockContainer.innerHTML = markup\n\n const elements = mockContainer.getElementsByTagName('svg')\n if (elements.length > 1) throw new Error('More than one SVG element found in provided markup')\n\n const svgElement = elements[0]\n if (!svgElement) throw new Error('No SVG in provided markup')\n\n if (stripExtraneousAttributes) removeAttributes(svgElement, undefined, false, [...whitelistedAttributes, 'style', 'class', 'id'])\n if (stripIds) removeAttributes(svgElement, ['id'], true)\n if (stripClasses) removeAttributes(svgElement, ['class'], true)\n if (stripStyles) removeStyles(svgElement)\n\n return svgElement.outerHTML\n }\n\n return (\n <StyledRoot\n ref={ref}\n dangerouslySetInnerHTML={{ __html: sanitizedMarkup() }}\n cssSVG={cssSVG}\n {...props}\n />\n )\n})\n\nconst StyledRoot = styled.figure<{ cssSVG: Props['cssSVG'] }>`\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n > svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n\n ${props => props.cssSVG}\n }\n`\n"]}
1
+ {"version":3,"file":"FlatSVG.js","sourceRoot":"/","sources":["FlatSVG.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyD;AACzD,wEAAsC;AAuCtC,SAAS,YAAY,CAAC,OAAgB;IACpC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAEhC,IA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Y;YAAE,gBAAgB,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;QAC/D,IAAI,WAAW;YAAE,YAAY,CAAC,UAAU,CAAC,CAAA;QAEzC,OAAO,UAAU,CAAC,SAAS,CAAA;IAC7B,CAAC;IAED,OAAO,CACL,8BAAC,UAAU,aACT,GAAG,EAAE,GAAG,EACR,uBAAuB,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,IAClD,KAAK,EACT,CACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAM,UAAU,GAAG,2BAAM,CAAC,MAAM,sjBAAA,mfAuB/B,IAAA,CAAA","sourcesContent":["import React, { forwardRef, HTMLAttributes } from 'react'\nimport styled from 'styled-components'\n\nexport type Props = HTMLAttributes<HTMLDivElement> & {\n /**\n * The SVG string markup, i.e. \"<svg>...</svg>\".\n */\n markup: string\n\n /**\n * Specifies whether the 'class' should be removed in the SVG root node and all of its child\n * nodes.\n */\n stripClasses?: boolean\n\n /**\n * Specifies whether extraneous attributes should be removed from the SVG root node. The\n * `whitelistedAttributes` prop defines what attributes should be kept.\n */\n stripExtraneousAttributes?: boolean\n\n /**\n * Specifies whether the 'id' attribute should be removed in the SVG root node and all of its\n * child nodes.\n */\n stripIds?: boolean\n\n /**\n * Specifies whether the 'style' atribute and any <style> nodes should be removed in the SVG root\n * node and all of its child nodes.\n */\n stripStyles?: boolean\n\n /**\n * Specifies attribute names to exclude from being stripped if `stripExtraneousAttributes` is\n * enabled. By default, only `viewBox` is whitelisted.\n */\n whitelistedAttributes?: string[]\n}\n\nfunction removeStyles(element: Element) {\n element.removeAttribute('style')\n\n const inlineStyles = element.getElementsByTagName('style')\n const numInlineStyles = inlineStyles.length\n\n for (let i = 0; i < numInlineStyles; i++) {\n const inlineStyle = inlineStyles[i]\n inlineStyle.remove()\n }\n\n const numChildren = element.children.length\n\n for (let i = 0; i < numChildren; i++) {\n removeStyles(element.children[i])\n }\n}\n\nfunction removeAttributes(element: Element, attributes: string[] | undefined = undefined, recursive = false, whitelist: string[] = []) {\n const attrs = attributes ?? element.getAttributeNames()\n const numAttrs = attrs.length\n\n for (let i = 0; i < numAttrs; i++) {\n const attr = attrs[i]\n const keep = whitelist.indexOf(attr) > -1\n if (!keep) element.removeAttribute(attr)\n }\n\n if (recursive) {\n const numChildren = element.children.length\n\n for (let i = 0; i < numChildren; i++) {\n removeAttributes(element.children[i], attributes, recursive, whitelist)\n }\n }\n}\n\n/**\n * A component whose root element wraps an SVG markup. When wrapping the SVG, it will attempt to\n * sanitize the markup (i.e. stripping useless attributes) according to the props specified.\n */\nexport default forwardRef<HTMLDivElement, Props>(({\n markup,\n stripClasses = true,\n stripExtraneousAttributes = true,\n stripIds = true,\n stripStyles = true,\n whitelistedAttributes = ['viewBox'],\n ...props\n}, ref) => {\n function sanitizedMarkup(): string {\n const mockContainer = document.createElement('div')\n mockContainer.innerHTML = markup\n\n const elements = mockContainer.getElementsByTagName('svg')\n if (elements.length > 1) throw new Error('More than one SVG element found in provided markup')\n\n const svgElement = elements[0]\n if (!svgElement) throw new Error('No SVG in provided markup')\n\n if (stripExtraneousAttributes) removeAttributes(svgElement, undefined, false, [...whitelistedAttributes, 'style', 'class', 'id'])\n if (stripIds) removeAttributes(svgElement, ['id'], true)\n if (stripClasses) removeAttributes(svgElement, ['class'], true)\n if (stripStyles) removeStyles(svgElement)\n\n return svgElement.outerHTML\n }\n\n return (\n <StyledRoot\n ref={ref}\n dangerouslySetInnerHTML={{ __html: sanitizedMarkup() }}\n {...props}\n />\n )\n})\n\nconst StyledRoot = styled.figure`\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n }\n`\n"]}
package/lib/Map.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare type Props<T> = {
3
+ children: JSX.Element | ((value: T, index: number) => JSX.Element);
4
+ array?: T[];
5
+ };
6
+ export default function Map<T>({ array, children, }: Props<T>): JSX.Element;
package/lib/Map.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ var react_1 = __importStar(require("react"));
23
+ function Map(_a) {
24
+ var array = _a.array, children = _a.children;
25
+ if (!(array instanceof Array))
26
+ throw TypeError("Provided collection must be an array: ".concat(array));
27
+ return (react_1.default.createElement(react_1.default.Fragment, null, array.map(function (v, i) { return (react_1.default.createElement(react_1.Fragment, { key: "element-".concat(i) }, typeof children === 'function' ? children(v, i) : children)); })));
28
+ }
29
+ exports.default = Map;
30
+ //# sourceMappingURL=Map.js.map
package/lib/Map.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Map.js","sourceRoot":"/","sources":["Map.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuC;AAOvC,SAAwB,GAAG,CAAI,EAGpB;QAFT,KAAK,WAAA,EACL,QAAQ,cAAA;IAER,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,MAAM,SAAS,CAAC,gDAAyC,KAAK,CAAE,CAAC,CAAA;IAEhG,OAAO,CACL,8DACG,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CACnB,8BAAC,gBAAQ,IAAC,GAAG,EAAE,kBAAW,CAAC,CAAE,IAC1B,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAClD,CACZ,EAJoB,CAIpB,CAAC,CACD,CACJ,CAAA;AACH,CAAC;AAfD,sBAeC","sourcesContent":["import React, { Fragment } from 'react'\n\nexport type Props<T> = {\n children: JSX.Element | ((value: T, index: number) => JSX.Element)\n array?: T[]\n}\n\nexport default function Map<T>({\n array,\n children,\n}: Props<T>) {\n if (!(array instanceof Array)) throw TypeError(`Provided collection must be an array: ${array}`)\n\n return (\n <>\n {array.map((v, i) => (\n <Fragment key={`element-${i}`}>\n {typeof children === 'function' ? children(v, i) : children}\n </Fragment>\n ))}\n </>\n )\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  import { HTMLAttributes } from 'react';
2
2
  import { Size } from 'spase';
3
- import { CSSProp } from 'styled-components';
4
- import { Props as PanoramaProps } from './Panorama';
3
+ import Panorama, { Props as PanoramaProps } from './Panorama';
5
4
  export declare type Props = HTMLAttributes<HTMLDivElement> & PanoramaProps & {
6
5
  /**
7
6
  * Field-of-view (0.0 - 360.0 degrees, inclusive) that represents the size of the reticle. 360
@@ -21,21 +20,17 @@ export declare type Props = HTMLAttributes<HTMLDivElement> & PanoramaProps & {
21
20
  * `fov` prop is not specified. If it is, this prop is ignored.
22
21
  */
23
22
  viewportSize?: Size;
24
- /**
25
- * Additional CSS to be provided to the internal panorama component.
26
- */
27
- cssPanorama?: CSSProp<any>;
28
- /**
29
- * Additional CSS to be provided to the reticle.
30
- */
31
- cssReticle?: CSSProp<any>;
32
- /**
33
- * Additional CSS to be provided to the track.
34
- */
35
- cssTrack?: CSSProp<any>;
36
- /**
37
- * Additional CSS to be provided to the indicator.
38
- */
39
- cssIndicator?: CSSProp<any>;
40
23
  };
41
- export default function PanoramaSlider({ fov, autoDimension, viewportSize, cssPanorama, cssReticle, cssTrack, cssIndicator, angle, speed, src, zeroAnchor, onAngleChange, onPositionChange, onDragStart, onDragEnd, onImageLoadStart, onImageLoadComplete, onImageLoadError, onImageSizeChange, onResize, style, ...props }: Props): JSX.Element;
24
+ /**
25
+ * A slider for {@link Panorama} components.
26
+ *
27
+ * @exports PanoramaSliderImage
28
+ * @exports PanoramaSliderIndicator
29
+ * @exports PanoramaSliderTrack
30
+ * @exports PanoramaSliderReticle
31
+ */
32
+ export default function PanoramaSlider({ fov, autoDimension, viewportSize, angle, speed, src, zeroAnchor, onAngleChange, onPositionChange, onDragStart, onDragEnd, onImageLoadStart, onImageLoadComplete, onImageLoadError, onImageSizeChange, onResize, style, ...props }: Props): JSX.Element;
33
+ export declare const PanoramaSliderReticle: import("styled-components").StyledComponent<"div", any, {}, never>;
34
+ export declare const PanoramaSliderTrack: import("styled-components").StyledComponent<"div", any, {}, never>;
35
+ export declare const PanoramaSliderIndicator: import("styled-components").StyledComponent<"div", any, {}, never>;
36
+ export declare const PanoramaSliderImage: import("styled-components").StyledComponent<typeof Panorama, any, {}, never>;
@@ -64,14 +64,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
64
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
65
65
  };
66
66
  Object.defineProperty(exports, "__esModule", { value: true });
67
+ exports.PanoramaSliderImage = exports.PanoramaSliderIndicator = exports.PanoramaSliderTrack = exports.PanoramaSliderReticle = void 0;
67
68
  var classnames_1 = __importDefault(require("classnames"));
68
69
  var lodash_1 = __importDefault(require("lodash"));
69
70
  var react_1 = __importStar(require("react"));
70
71
  var styled_components_1 = __importDefault(require("styled-components"));
71
72
  var useResizeEffect_1 = __importDefault(require("./hooks/useResizeEffect"));
72
73
  var Panorama_1 = __importDefault(require("./Panorama"));
74
+ /**
75
+ * A slider for {@link Panorama} components.
76
+ *
77
+ * @exports PanoramaSliderImage
78
+ * @exports PanoramaSliderIndicator
79
+ * @exports PanoramaSliderTrack
80
+ * @exports PanoramaSliderReticle
81
+ */
73
82
  function PanoramaSlider(_a) {
74
- var fov = _a.fov, _b = _a.autoDimension, autoDimension = _b === void 0 ? 'width' : _b, viewportSize = _a.viewportSize, cssPanorama = _a.cssPanorama, cssReticle = _a.cssReticle, cssTrack = _a.cssTrack, cssIndicator = _a.cssIndicator, _c = _a.angle, angle = _c === void 0 ? 0 : _c, _d = _a.speed, speed = _d === void 0 ? 1 : _d, src = _a.src, _e = _a.zeroAnchor, zeroAnchor = _e === void 0 ? 0 : _e, onAngleChange = _a.onAngleChange, onPositionChange = _a.onPositionChange, onDragStart = _a.onDragStart, onDragEnd = _a.onDragEnd, onImageLoadStart = _a.onImageLoadStart, onImageLoadComplete = _a.onImageLoadComplete, onImageLoadError = _a.onImageLoadError, onImageSizeChange = _a.onImageSizeChange, onResize = _a.onResize, style = _a.style, props = __rest(_a, ["fov", "autoDimension", "viewportSize", "cssPanorama", "cssReticle", "cssTrack", "cssIndicator", "angle", "speed", "src", "zeroAnchor", "onAngleChange", "onPositionChange", "onDragStart", "onDragEnd", "onImageLoadStart", "onImageLoadComplete", "onImageLoadError", "onImageSizeChange", "onResize", "style"]);
83
+ var fov = _a.fov, _b = _a.autoDimension, autoDimension = _b === void 0 ? 'width' : _b, viewportSize = _a.viewportSize, _c = _a.angle, angle = _c === void 0 ? 0 : _c, _d = _a.speed, speed = _d === void 0 ? 1 : _d, src = _a.src, _e = _a.zeroAnchor, zeroAnchor = _e === void 0 ? 0 : _e, onAngleChange = _a.onAngleChange, onPositionChange = _a.onPositionChange, onDragStart = _a.onDragStart, onDragEnd = _a.onDragEnd, onImageLoadStart = _a.onImageLoadStart, onImageLoadComplete = _a.onImageLoadComplete, onImageLoadError = _a.onImageLoadError, onImageSizeChange = _a.onImageSizeChange, onResize = _a.onResize, style = _a.style, props = __rest(_a, ["fov", "autoDimension", "viewportSize", "angle", "speed", "src", "zeroAnchor", "onAngleChange", "onPositionChange", "onDragStart", "onDragEnd", "onImageLoadStart", "onImageLoadComplete", "onImageLoadError", "onImageSizeChange", "onResize", "style"]);
75
84
  var getAspectRatio = function () {
76
85
  if (!imageSize)
77
86
  return 0;
@@ -101,7 +110,7 @@ function PanoramaSlider(_a) {
101
110
  } : {
102
111
  height: "".concat(size.width / aspectRatio, "px"),
103
112
  }) }, props),
104
- react_1.default.createElement(StyledPanorama, { angle: angle, css: cssPanorama, onAngleChange: onAngleChange, onDragEnd: function () {
113
+ react_1.default.createElement(exports.PanoramaSliderImage, { angle: angle, onAngleChange: onAngleChange, onDragEnd: function () {
105
114
  setIsDragging(false);
106
115
  onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd();
107
116
  }, onDragStart: function () {
@@ -110,17 +119,17 @@ function PanoramaSlider(_a) {
110
119
  }, onImageLoadComplete: onImageLoadComplete, onImageLoadError: onImageLoadError, onImageLoadStart: onImageLoadStart, onImageSizeChange: function (size) { return setImageSize(size); }, onPositionChange: onPositionChange, speed: speed, src: src, style: { height: '100%', width: '100%' }, zeroAnchor: adjustedZeroAnchor }),
111
120
  react_1.default.createElement(StyledTrackContainer, null,
112
121
  react_1.default.createElement("div", null,
113
- react_1.default.createElement(StyledTrack, { className: (0, classnames_1.default)({ dragging: isDragging }), css: cssTrack }),
114
- react_1.default.createElement(StyledReticle, { className: (0, classnames_1.default)({ dragging: isDragging }), css: cssReticle, style: { width: "".concat(reticleWidth, "px") } }),
115
- react_1.default.createElement(StyledTrack, { className: (0, classnames_1.default)({ dragging: isDragging }), css: cssTrack }))),
116
- react_1.default.createElement(StyledIndicator, { className: (0, classnames_1.default)({ dragging: isDragging }), style: { width: "".concat(reticleWidth, "px") }, css: cssIndicator })));
122
+ react_1.default.createElement(exports.PanoramaSliderTrack, { className: (0, classnames_1.default)({ dragging: isDragging }) }),
123
+ react_1.default.createElement(exports.PanoramaSliderReticle, { className: (0, classnames_1.default)({ dragging: isDragging }), style: { width: "".concat(reticleWidth, "px") } }),
124
+ react_1.default.createElement(exports.PanoramaSliderTrack, { className: (0, classnames_1.default)({ dragging: isDragging }) }))),
125
+ react_1.default.createElement(exports.PanoramaSliderIndicator, { className: (0, classnames_1.default)({ dragging: isDragging }), style: { width: "".concat(reticleWidth, "px") } })));
117
126
  }
118
127
  exports.default = PanoramaSlider;
119
- var StyledReticle = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: rgba(0, 0, 0, .3);\n flex: 0 0 auto;\n height: 100%;\n transition-duration: 100ms;\n transition-property: background;\n transition-timing-function: ease-out;\n\n &.dragging {\n background: rgba(0, 0, 0, 0);\n }\n\n ", "\n "], ["\n background: rgba(0, 0, 0, .3);\n flex: 0 0 auto;\n height: 100%;\n transition-duration: 100ms;\n transition-property: background;\n transition-timing-function: ease-out;\n\n &.dragging {\n background: rgba(0, 0, 0, 0);\n }\n\n ", "\n "])), function (props) { return props.css; });
120
- var StyledTrack = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: rgba(0, 0, 0, .7);\n display: block;\n flex: 1 0 auto;\n height: 100%;\n pointer-events: none;\n\n ", "\n"], ["\n background: rgba(0, 0, 0, .7);\n display: block;\n flex: 1 0 auto;\n height: 100%;\n pointer-events: none;\n\n ", "\n"])), function (props) { return props.css; });
121
- var StyledTrackContainer = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n box-sizing: border-box;\n display: block;\n height: 100%;\n left: 0;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n top: 0;\n width: 100%;\n\n > div {\n align-items: center;\n display: flex;\n height: 100%;\n justify-content: flex-start;\n left: 0;\n overflow: visible;\n position: absolute;\n top: 0;\n width: 100%;\n }\n"], ["\n box-sizing: border-box;\n display: block;\n height: 100%;\n left: 0;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n top: 0;\n width: 100%;\n\n > div {\n align-items: center;\n display: flex;\n height: 100%;\n justify-content: flex-start;\n left: 0;\n overflow: visible;\n position: absolute;\n top: 0;\n width: 100%;\n }\n"])));
122
- var StyledIndicator = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: #fff;\n border-radius: 2px;\n bottom: -10px;\n box-sizing: border-box;\n display: block;\n height: 2px;\n left: 0;\n margin: 0 auto;\n opacity: 0;\n right: 0;\n transition: opacity .3s ease-out;\n\n &.dragging {\n opacity: 1;\n }\n\n ", "\n"], ["\n background: #fff;\n border-radius: 2px;\n bottom: -10px;\n box-sizing: border-box;\n display: block;\n height: 2px;\n left: 0;\n margin: 0 auto;\n opacity: 0;\n right: 0;\n transition: opacity .3s ease-out;\n\n &.dragging {\n opacity: 1;\n }\n\n ", "\n"])), function (props) { return props.css; });
123
- var StyledPanorama = (0, styled_components_1.default)(Panorama_1.default)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) { return props.css; });
128
+ exports.PanoramaSliderReticle = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: rgba(0, 0, 0, .3);\n flex: 0 0 auto;\n height: 100%;\n transition-duration: 100ms;\n transition-property: background;\n transition-timing-function: ease-out;\n\n &.dragging {\n background: rgba(0, 0, 0, 0);\n }\n"], ["\n background: rgba(0, 0, 0, .3);\n flex: 0 0 auto;\n height: 100%;\n transition-duration: 100ms;\n transition-property: background;\n transition-timing-function: ease-out;\n\n &.dragging {\n background: rgba(0, 0, 0, 0);\n }\n"])));
129
+ exports.PanoramaSliderTrack = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: rgba(0, 0, 0, .7);\n display: block;\n flex: 1 0 auto;\n height: 100%;\n pointer-events: none;\n"], ["\n background: rgba(0, 0, 0, .7);\n display: block;\n flex: 1 0 auto;\n height: 100%;\n pointer-events: none;\n"])));
130
+ exports.PanoramaSliderIndicator = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: #fff;\n border-radius: 2px;\n bottom: -10px;\n box-sizing: border-box;\n display: block;\n height: 2px;\n left: 0;\n margin: 0 auto;\n opacity: 0;\n right: 0;\n transition: opacity .3s ease-out;\n\n &.dragging {\n opacity: 1;\n }\n"], ["\n background: #fff;\n border-radius: 2px;\n bottom: -10px;\n box-sizing: border-box;\n display: block;\n height: 2px;\n left: 0;\n margin: 0 auto;\n opacity: 0;\n right: 0;\n transition: opacity .3s ease-out;\n\n &.dragging {\n opacity: 1;\n }\n"])));
131
+ exports.PanoramaSliderImage = (0, styled_components_1.default)(Panorama_1.default)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\n"], ["\n\n"])));
132
+ var StyledTrackContainer = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n box-sizing: border-box;\n display: block;\n height: 100%;\n left: 0;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n top: 0;\n width: 100%;\n\n > div {\n align-items: center;\n display: flex;\n height: 100%;\n justify-content: flex-start;\n left: 0;\n overflow: visible;\n position: absolute;\n top: 0;\n width: 100%;\n }\n"], ["\n box-sizing: border-box;\n display: block;\n height: 100%;\n left: 0;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n top: 0;\n width: 100%;\n\n > div {\n align-items: center;\n display: flex;\n height: 100%;\n justify-content: flex-start;\n left: 0;\n overflow: visible;\n position: absolute;\n top: 0;\n width: 100%;\n }\n"])));
124
133
  var StyledRoot = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n box-sizing: border-box;\n display: block;\n flex: 0 0 auto;\n height: 100%;\n width: 100%;\n"], ["\n box-sizing: border-box;\n display: block;\n flex: 0 0 auto;\n height: 100%;\n width: 100%;\n"])));
125
134
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
126
135
  //# sourceMappingURL=PanoramaSlider.js.map